Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Burstiness of nRF 52840 Dev Kit USB CDC ADM code on Mac OS

We're using a combination of the ESB library/example code and the USB CDC ADM example code to transfer data from one 52840 dev kit to another system via a 2nd 52840 dev kit, via this setup:

  1. The transmitting 52840 send 128 bytes of data every millisecond via nrf_esb_write_payload().
  2. The receiving 52840 receives the 128 byte packet and immediately does an app_usbd_cdc_acm_write() with the data.  
  3. The system reads the data by polling /dev/tty.usbmodemxyz waiting for a complete 128 byte packet.  This is done via either a C++ program or a python3 script.

This all seems to work fine.  By looking at time stamps that are included in the data, we can tell the receive side is getting packets as expected once a millisecond.  But the problem is the reads of the data from the USB are bursty - the first read takes about 4 ms, then we'll get the next 3 or so almost immediately.  Then 4 ms to the next packet, then 3 to 4 more, etc.

I'm seeing this both with an C program (Xcode, Open Framework C++ app) and with python3 script.  I've tried various flags on the device open like O_NDELAY, but nothing I've done really changes the behavior.  Mac OS does not support the N_DIRECT flag.  

Is there a way to eliminate this bursty type of USB read with the CDC ADM example code?  Is there a better Nordic USB device/example code to use?  Any ideas are appreciated, it is important that the data arrive as consistently as is possible (given a non-real time OS like Mac OS).

nRF SDK 15, Mac OS 10.13.4, Xcode 9.3, Python 3.6.2

Thanks

Ed

Parents
  • Hi,

    Could you measure the interval between the APP_USBD_CDC_ACM_USER_EVT_TX_DONE events?

    Do you see the same beahvior if you split your 128 byte packets in two, i.e. use 64 bytes per packet for app_usbd_cdc_acm_write instead?

  • A bit more info.  Tried a few different configurations of packet size, and it appears the minimum "burst" is about 4 ms.  Nothing I've been able to do reduces this number, smaller packets just result within the burst window.

    Ignoring ESB, I modified the main loop of my code to do nothing but 128 byte app_usbd_cdc_acm_writes (not waiting for any ESB provided data.  At 128 bytes, I see a burst of 4 transfers - first one about 1 ms, then the next 3 happening almost immediately.  Seems to related to USB transfers????

    Ed

Reply
  • A bit more info.  Tried a few different configurations of packet size, and it appears the minimum "burst" is about 4 ms.  Nothing I've been able to do reduces this number, smaller packets just result within the burst window.

    Ignoring ESB, I modified the main loop of my code to do nothing but 128 byte app_usbd_cdc_acm_writes (not waiting for any ESB provided data.  At 128 bytes, I see a burst of 4 transfers - first one about 1 ms, then the next 3 happening almost immediately.  Seems to related to USB transfers????

    Ed

Children
No Data
Related