This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

"usb_dev_serial" receiving unusual data not sent from host application

Hi,

I have modified the usb_dev_serial example and removed the redirected link through UART0. I am able to sending and receive data through the CDC USB link very much like the usb_dev_bulk example. When I run the modified usb_dev_serial example, the log of usb control/received/transmit events reported by the callback handlers shows that the USB buffer is received data (19 bytes in total) on the TM4C123GXL while the host is not sending any data. Here is the log of events, where Ct, Rx, and TX respectively denote the event reported by the ControlEventHandler, RxEventHandler, and  TxEventHandler. Moreover,  Rx: 0,  Rx: 2, -> 2 corresponds to previous total of received bytes, new total of received bytes, and their difference. I could not understand what to do with this received data when it is not sent by the host application.

Tiva C Series USB Serial Device Example
--------------------------------------------------------
Configuring USB
Waiting for host...
Ct: USB_EVENT_SUSPEND
Ct: USB_EVENT_SUSPEND
Ct: Connected
Rx: USB_EVENT_DATA_REMAINING
Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE
Rx: USB_EVENT_DATA_REMAINING
Ct: USBD_CDC_EVENT_SET_LINE_CODING
Rx: USB_EVENT_DATA_REMAINING
Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE
Rx: USB_EVENT_DATA_REMAINING
Ct: USBD_CDC_EVENT_SET_LINE_CODING
Rx: USB_EVENT_DATA_REMAINING
Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE
Rx: USB_EVENT_DATA_REMAINING
Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE
Rx: USB_EVENT_RX_AVAILABLE
Rx: USB_EVENT_RX_AVAILABLE
Rx: 0,  Rx: 2, -> 2
Rx: USB_EVENT_RX_AVAILABLE
Rx: 2,  Rx: 3, -> 1
Rx: USB_EVENT_RX_AVAILABLE
Rx: USB_EVENT_RX_AVAILABLE
Rx: 3,  Rx: 5, -> 2
Rx: USB_EVENT_RX_AVAILABLE
Rx: 5,  Rx: 6, -> 1
Rx: USB_EVENT_RX_AVAILABLE
Rx: USB_EVENT_RX_AVAILABLE
Rx: 6,  Rx: 8, -> 2
Rx: USB_EVENT_RX_AVAILABLE
Rx: 8,  Rx: 9, -> 1
Rx: USB_EVENT_DATA_REMAINING
Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE
Rx: USB_EVENT_DATA_REMAINING
Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE
Rx: USB_EVENT_DATA_REMAINING
Ct: USBD_CDC_EVENT_SET_LINE_CODING
Rx: USB_EVENT_RX_AVAILABLE
Rx: 9,  Rx: 14, -> 5
Rx: USB_EVENT_RX_AVAILABLE
Rx: 14,  Rx: 19, -> 5

The above events happened in the setup where Debug usb cable was connected with a PC running Windows 7, whereas Device usb cable was connected with a PC running Ubunt 14.04. However when I connected both cables to the PC running windows 7, I noticed following events.

Tiva C Series USB Serial Device Example
--------------------------------------------------------
Configuring USB
Waiting for host...
Ct: USB_EVENT_SUSPEND
Ct: Connected
Ct: USBD_CDC_EVENT_GET_LINE_CODING
Rx: USB_EVENT_DATA_REMAINING
Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE

In this case, no 'USB_EVENT_RX_AVAILABLE' event is reported by the CDC Driver class, unless there is transmitted data from the host to the board. Could anyone explain why this happening?

  • Hello Jatala,

    Couple of things

    1. When you start the example does it start with the USB peripheral being reset? I suspect a rerun of the code is causing it when a new code image is loaded and the example re-run
    2. When the bytes are being received, can you check what the content of the RX byte is. The reason why I ask so is to see if there is some trend in the RX bytes which may suggest the source being your host application or a driver artifact.
    3. To check the driver artifact a good idea (though not possible) would be analyze the USB traffic.
    4. Without the modified code you have it would be tough for us to see where the issue is coming from.

    Regards
    Amit
  • Hello Amit,

    Thanks for the response. Here is exactly what I am doing:

    1. Connect the ubuntu 14.04 PC to the Device port, and the windows 7 PC to the Debug port with USB cables as shown in the attached picture. On the ubuntu PC I do not run my application to read/write data to the USB Device port (/dev/ttyACM0), no application opens the port. In fact I do nothing except connecting the device port to ubuntu. On windows PC I am running CCS and Putty: first I connect to the board through putty; afterwards I  launch the modified usb_dev_serial program through the CCS.

     

    Here is log of events, along with received data

    Tiva C Series USB Serial Device Example

    ---------------------------------

    Configuring USB

    Waiting for host...

    Ct: USB_EVENT_SUSPEND

    Ct: USB_EVENT_SUSPEND

    Ct: Connected

    Rx: USB_EVENT_DATA_REMAINING

    Ct: USBD_CDC_EVENT_SET_LINE_CODING

    Rx: USB_EVENT_DATA_REMAINING

    Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE

    Rx: USB_EVENT_DATA_REMAINING

    Ct: USBD_CDC_EVENT_SET_LINE_CODING

    Rx: USB_EVENT_DATA_REMAINING

    Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE

    Rx: USB_EVENT_DATA_REMAINING

    Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x41

    Rx: 0,  Rx: 1, -> 1

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x54

    Rx: 1,  Rx: 2, -> 1

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x0d

    Rx: 2,  Rx: 3, -> 1

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x41

    Rx: 3,  Rx: 4, -> 1

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x54

    Rx: 4,  Rx: 5, -> 1

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x0d

    Rx: 5,  Rx: 6, -> 1

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x41

    Rx: 6,  Rx: 7, -> 1

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x54

    Rx: 7,  Rx: 8, -> 1

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x0d

    Rx: 8,  Rx: 9, -> 1

    Rx: USB_EVENT_DATA_REMAINING

    Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE

    Rx: USB_EVENT_DATA_REMAINING

    Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE

    Rx: USB_EVENT_DATA_REMAINING

    Ct: USBD_CDC_EVENT_SET_LINE_CODING

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x7e, 0x00, 0x78, 0xf0, 0x7e

    Rx: 9,  Rx: 14, -> 5

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x7e, 0x00, 0x78, 0xf0, 0x7e

    Rx: 14,  Rx: 19, -> 5

    Rx: USB_EVENT_DATA_REMAINING

    Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE

    2. In the second setup, both the device and debug ports of the board are connected with the windows PC as shown here

    Similar to the ubuntu case, I do not run my application to read/write data to the USB Device port, no application opens the port. In fact I do nothing except connecting the device port to the PC. Afterwards, I connect to the Debug port through Putty, and  launch the modified usb_dev_serial program from CCS. Here is log of events.  no received data is reported in this case. 

    Tiva C Series USB Serial Device Example
    ---------------------------------
    Configuring USB
    Waiting for host...
    Ct: USB_EVENT_SUSPEND
    Ct: Connected
    Ct: USBD_CDC_EVENT_GET_LINE_CODING
    Rx: USB_EVENT_DATA_REMAINING
    Ct: USBD_CDC_EVENT_SET_CONTROL_LINE_STATE

    I am struggling to make sense of why in the Ubuntu case, the USB CDC class driver is reporting received data.

    Kind regards

    Jatala

  • Hi Jatala,

    I am struggling to make sense of why in the Ubuntu case, the USB CDC class driver is reporting received data.

    Modem manager on Ubuntu does probing to your CDC-ACM device.
    Disable it on Ubuntu, using udev rules for the VID/PID of your device.
    ubuntuforums.org/showthread.php;p=12581391#post12581391

    Tsuneo

  • Jatala said:

    Rx: 2,  Rx: 3, -> 1

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x41 --> ASCII 'A'

    Rx: 3,  Rx: 4, -> 1

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x54 --> ASCII 'T'

    Rx: 4,  Rx: 5, -> 1

    Rx: USB_EVENT_RX_AVAILABLE

    Rx Data: 0x0d --> ASCII  '/r'

    Rx: 5,  Rx: 6, -> 1

     On next debug session remember also print character as ASCII, printing ASCII char or attaching a terminal was clear what mean cr (for Baud rate auto setting)  "AT/n".

  • Hello Tsuneo,

    Thanks for the explaining the cause of the data. Should not the CDC class driver handle this control data, instead of passing it to the user Rx buffer.