Data packet format when USB initialized as COM port

arduinoserialusb

Does anyone know how the data in data packet looks like when the USB is initialized as COM port?

I have a Arduino Mega 2560. I have initialized COM port with a baud rate of 9600. I know that there are four types of USB packets as

  1. Token Packet (Commonly used for device identification and transaction initiation.)
  2. Data Packet (Contains the data that needs to be transferred from host to client or vice-versa.)
  3. Acknowledgement Packet (Acknowledgement for error-free data reception.)
  4. Special Packets (Hub to hub communication and speed differential.)

The payload in data packet is formatted as

DATA1 >> PAYLOAD >> CRC16 ; DATA2 >> >> PAYLOAD >> CRC16 ; etc.

Till this point I am clear about whats happening.

Now all I want to know is

  • How the data is structured in the PAYLOAD section, when USB is initialized as COM port?
  • How the baud rate comes into picture i.e how a particular baudrate is achieved in this type of communication?
  • How is communication in terms of packet sequence? Does the sequence of packets change? (Like token>>data>>ack>>data>>ack>>…)

As @Simon said that this might be a vendor specific protocol, does anyone know how its used in Arduino?

This is really important to me to explore. Below is what I am trying.

enter image description here

  1. This is what I have already done. I was successfully able to transfer the data of 180KBytes of data in one sec. If I increase the data even by 1Kbytes, it starts to show error in the received data. I didn't initialized communication at any fixed baud rate. Mega is just waiting for data. I the next bit doesn't arrive in next 50 milliseconds, it considers this as end of communication.
  2. I wish to achieve same data rate for each Arduino Mega. Thus USB has to transfer total of 540KBytes of data in one sec. Here also I have to use USB hub. I would also like to know if this might cause any trouble, for proposed data transfer.

Now here I want to know weather this limitation is from USB side or Mega side or combination of both. So before I actually go and buy new Mega to test, I would just like to know if it will work or not.

Best Answer

The COM port is either a USB CDC device, implements a vendor specific protocol, or both.

These are high-level protocols on top of USB endpoints, so the wire protocol for the actual data transfers are most likely to be BULK OUT and BULK IN packets, with a few CONTROL transfers interspersed (so USB packets do not correspond 1:1 to data transfers over the virtual serial port).

The USB wire protocol is fixed, because the exchange of data and acknowledgements must happen in a short timeframe, and will follow the same pattern regardless of what device classes and interfaces the USB device implements.

To address your use case: it is unlikely that the USB will be the bottleneck.

Related Topic