Serial Read Data via Dragonboard USB port


#1

Hello everyone,

I intend to read string data with USB port (using UART, but with USB port , because I read that USB port can work more stable, and quickly), is there any library or basic function to read it?

Thank you all


#2

Hi @Alexandre_Felipe_Oli

I don’t remember hearing the USB was more or less stable than UART, in both cases you need to ensure that the hardware is set up correctly (correct voltage levels and baud rates) but once you have the HW set up correctly they should both have the same stability.

As far as API goes, I am not sure which operating system you are using (Linux, Android, or Win10-IOT), but under Linux you open() the serial device (for example /dev/tty96B0 or /dev/ttyACM0 depending on if you are using UART or USB), and then readln() to read the serial string. From a code point of view the only difference between UART and USB is the name of the device in the /dev directory.

Hope this helps.

Full Disclosure: I m an employee of Qualcomm Canada, any opinions I may have expressed in this or any other post may not reflect the opinions of my employer.


#3

I wouldn’t say that serial/uart is unstable, this is a cheaper design widely used as 1:1 interconnect (console, BT, NFC, GPS, GSM modules…). There is no defined limit to the baud-rate, this is in practice limited by the clock generator capabilities, you can typically find ~4Mpbs capable UARTs integrated in modern SoCs. For sure, if you want strong data reliability, you will need to implement your own protocol on top (retransmit, ack, CRC, etc). USB is a serial bus which is a much more complex specification than a simple block of circuitry, however, concepts of reliability, interoperability, hotplug, etc are addressed. Device Behavior/functionnalities are also part of the spec. You can reach 480Mpbs with USB2.0.

Now, all depends on your need/goal. If you want to have the speed and data reliability of USB with the simplicity of serial-uart you can use The CDC (ACM) class which is typically offer you a similar interface to standard serial/uart. So, as said by ljking, you will be able to use standard open/read/write functions on the device interface (/dev/tty…).

Design of USB is such a way that you need a HOST and a SLAVE, If I doubt that your PC is SLAVE capable, the Dragonbord is able to act in this role. Indeed, thanks to its OTG capability the board can switch to HOST or SLAVE role. However, you need to know that the board will not be able to act as both HOST/SLAVE at the same time and therefore USB keyboard, mouse, etc will not be operational in SLAVE role.

Your setup will be:
COMPUTER(HOST/)USB <----> BOARD(SLAVE/)MICRO-USB

You also need to load the correct USB gadget(slave) driver on the dragonboard:
modprobe g_serial

Then you should see a /dev/ttyGS* on dragonboard side and a /dev/ttyACM* on the Host side (in case of regular Linux Host),


#4

Although both @Loic and I discussed philosophy of UART and USB, we didn’t really answer your question about APIs. I worked as a mentor at a Hackathon this weekend (Hack The North) and all of the teams using DragonBoard found that Python’s pyserial package worked really well for accessing the serial port.

Full Disclosure: I am an employee of Qualcomm Canada, any opinions I may have expressed in this or any other post may not reflect the opinions of my employer.


#5

Thanks everyone, I searched about here, and decided to use a mezanine to communication Serial,
In fact, my need is receive data from a RF receiver (NRF24L01), connected in the mezanine, to communicate to the Dragondboard.