This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USB CDC ACM flow control

In our current implementation of the CDC ACM output, we use a blocking wait for the APP_USBD_CDC_ACM_USER_EVT_TX_DONE after writing to the cdc acm stack. We are using Teraterm to receive and print the data on the PC. We noticed that in particular when there's large amount of data, the Teraterm terminal will become overwhelmed, causing it to go out of sync with the nrf chip and printing garbage. To address this, we would like to use any available flow control mechanism.

Currently, we just put in a fixed delay on top of the wait-for-interrupt in order to stop Teraterm output from corrupting.

We read from this thread: https://devzone.nordicsemi.com/f/nordic-q-a/46217/nrf52840-usb-cdc-acm-baud-rate-question, that there's a RTS line we can check to see if the PC terminal application is ready. Can we simply use the app_usbd_cdc_acm_line_state_get method to access this state? Are there any other setup required (eg on PC side)?

Thank you.

Parents
  • In principle this should work, you could query app_usbd_cdc_acm_line_state_get for RTS signal, however I have not tested if this actually will work as expected, but I guess you could try. Alternatively you could just use some handshaking on the application layer, e.g. send for instance 1kB and then wait for a command before sending the next 1kB. The command can also contain information about how much data have been received (e.g. and offset) in case data is lost/missed etc.

    Best regards,
    Kenneth

Reply
  • In principle this should work, you could query app_usbd_cdc_acm_line_state_get for RTS signal, however I have not tested if this actually will work as expected, but I guess you could try. Alternatively you could just use some handshaking on the application layer, e.g. send for instance 1kB and then wait for a command before sending the next 1kB. The command can also contain information about how much data have been received (e.g. and offset) in case data is lost/missed etc.

    Best regards,
    Kenneth

Children
No Data
Related