0

I would like to transfer data from a USB Host (of my Laptop or Android Device) to Serial COM port (of a Desktop PC) through a USB - Serial port(DB-9) adapter.

Is there any library existed to do this task??

i have already studied and tried http://developer.android.com/guide/topics/connectivity/usb/host.html but failed.

Can i send data by a using a java program or Android App from my Laptop or Android Device ??

Can i receive data by an app in Desktop PC and show us????

If so please guide me how.

Dineshgaru
  • 181
  • 1
  • 3
  • 16

1 Answers1

1

Yes, this is possible, the implementation will depend on what device you pick.

Check out the usb-serial-for-android project for the communication from Android to the USB device. This has support for most major USB to UART Bridge devices such as a Silicon Labs, Prolific, FTDI and CDC Class devices.

You can talk to it as a serial device from your laptop computer using normal serial communications such as POSIX method for Linux or OSX or the Commuincations API for Windows.

Preston
  • 2,543
  • 1
  • 17
  • 26
  • 2
    Yes, that should cover the software side. However to connect two DTE devices such as USB-serial converters or PCs, a *crossover cable* or wiring will typically be needed, such that the transmit of one connects to the receive of the other and so on (including flow control signals if used). – Chris Stratton Mar 04 '14 at 17:23
  • Mr. Preston, i have tried [link](https://github.com/mik3y/usb-serial-for-android) but Android device unable to find the device. I adjusted the baud-rate as per the requirement in the code.....but it's not working. – Dineshgaru Mar 08 '14 at 13:21
  • My Android device details: A210 Micromax Canvas 4 - 4.2.1 Jelly Bean. – Dineshgaru Mar 08 '14 at 13:29
  • I see you accepted the answer - did you solve your connection problem? – Preston Mar 10 '14 at 04:41
  • I have connected android to an STM32F4 MCU before using an FTDI chip. First of all, forget about serial port emulation on android ... Linux ok, but not android, since its not rooted so you wont have any drivers installed and certainly you wont have access to device in /dev without proper signatures which is a nightmare for development. What i did was to access USB host from my phone, enumerate the usb hub using usb4java library, find the FTDI chip, send the initialization sequence (a sequence of bytes to init the chip, google it or you will bang your head for a long time !!) – a.atlam Feb 15 '16 at 08:52
  • Then you can simply talk using USB bulk transfers. Read and write no problem at all !! Note the init sequence sets the baudrate and buffer sizes and what not so look a bit into it, will save you headaches later. Aslo you must keep polling the chip and flushing its Tx buffer before it overflows. Have a dedicated polling thread with a callback function for data available in your coms thread. Dont implement any of that in any thread that has UI or your app will freeze till usb is done – a.atlam Feb 15 '16 at 08:55