Frequent -16 Error When Using USB CDC with UART Async TX at 102 kB/s

Hi all,

I’m developing firmware using USB CDC with UART async API to transmit data at about 102 kB/s. However, during uart_tx() calls, I often get a -16 error (EBUSY). Sometimes the transmission succeeds after several retries.

Here’s my setup and logic:

  1. Bluetooth (NUS service) receives about 204 bytes every 2 ms.

  2. After receiving data, I push it into a message queue (k_msgq) for the UART TX thread.

  3. The UART TX thread retrieves data from the queue and immediately calls uart_tx().

  4. After sending, the thread waits about 1 µs before checking the queue again.

Issue:

  • uart_tx() frequently returns -16 (EBUSY).

  • Sometimes it takes several retries before the data can be sent successfully.

Question:

  • What is the most likely cause of the frequent -16 errors in this async setup?

  • Is there a recommended way to manage continuous data transmission via USB CDC (UART async) to avoid TX busy states?

Thank you for your support!

Best Regards!

Ben

Parents Reply
  • Hi Simonr,

    Thank you for your reply!

    Sorry for the late response. I found that the issue was caused by the serial debugging tool I was using — it seems that its buffer was too small, which led to some data not being process timely and resulted in the -16 error. When I tested with a Python script, this error did not occur.

    PS: I’m currently using USB CDC with UART Async TX, and based on what I’ve seen on the forum, the physical USB data rate does not appear to be limited by the configured baud rate.

    Thanks again for your support!

    Ben

Children
No Data
Related