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

USB CDC ACM Understanding bulk writes.

Hi All, 

Using SDK15.3, NRF52840 USB Dongle. 

After a few experiments I would like to clarify my understanding on how the usb bulk write works. 

I am currently writting packets of ~ 250 bytes at a given frequency to the VCP on windows 10. 

If I write once per second I can see that the data comes through in one packet and the time stamps for the packets are one second apart. Which makes sense. 

If I repeat the same procedure every 100 milliseconds packets still get written individually. 

However when I start writting this data at higer rates say once every 10 miliseconds, I can observe that the data is complete in this case 100 different packets in one second, but the timestamps indicate that at least four/five packets arived at the same time, so it is being written in bulk.

Is there any way to avoid this bulk write behavior ?

Why does the bulk write behaviour only appears at high rates ?

I have tried modifying, the following but it seems to have no effect whatsoever: 

/**
 * @brief Number of bytes in the endpoint
 *
 * Constant that informs about endpoint size
 */
#define NRF_DRV_USBD_EPSIZE 64

/**
 * @brief Number of bytes for isochronous endpoints
 *
 * Number of bytes for isochronous endpoints in total.
 * This number would be shared between IN and OUT endpoint.
 * It may be also assigned totaly to one endpoint.
 * @sa nrf_usbd_isosplit_set
 * @sa nrf_usbd_isosplit_get
 */
#define NRF_DRV_USBD_ISOSIZE 1024

Thanks, 

Regards

Parents
  • Hi Felipe

    Sorry for the slow response. I expect there is some buffering happening under the hood that makes the data stream more continuous as you increase the throughput, but I need to discuss this with our USB developer when he is back over the new year. 

    Is there any way to avoid this bulk write behavior ?

    I strongly doubt there is any way to change this. If possible I would look into making the application robust against this write behavior (bulk data transfers are not designed for applications requiring constant latency or throughput, bulk only guarantees that no data is lost or corrupted). 

    Best regards
    Torbjørn

  • Hi Ovrebekk, 

    Jus following up on this thread. 

    I strongly doubt there is any way to change this. If possible I would look into making the application robust against this write behavior (bulk data transfers are not designed for applications requiring constant latency or throughput, bulk only guarantees that no data is lost or corrupted). 

    Is there any way to reduce the bulk size or force it to be a constant value in order to reduce latency ?

    If so, is this done in the USB device as such or would it be configurable in the USB Host side ?

    Thanks for looking into this. 

    Cheers, 

  • Hi Felipe

    It is unlikely that reducing the endpoint size will change the latency, as the latency is primarily set by the poll interval of the host (1 millisecond). 

    In order to reduce the endpoint size for a specific endpoint you would have to change the value provided to the nrfx_usbd_ep_max_packet_size_set() function called by nrfx_usbd_init() in nrfx_usbd.c. 
    By default this will be set to NRFX_USBD_EPSIZE for any endpoint that is not a ISO endpoint, but you can change this to some other number. 
    Please note that this involves changing the USB driver itself, and it is not something we have tested, so there might be unintended side effects or issues by making this change. 

    Based on my discussion with the USB developer the bulk write behavior you see is most likely caused by how the data is handled on the host side, and not how it is sent. If you are able to sniff the USB communication itself you should see that the data is sent more or less every 10 milliseconds. 

    Best regards
    Torbjørn

Reply
  • Hi Felipe

    It is unlikely that reducing the endpoint size will change the latency, as the latency is primarily set by the poll interval of the host (1 millisecond). 

    In order to reduce the endpoint size for a specific endpoint you would have to change the value provided to the nrfx_usbd_ep_max_packet_size_set() function called by nrfx_usbd_init() in nrfx_usbd.c. 
    By default this will be set to NRFX_USBD_EPSIZE for any endpoint that is not a ISO endpoint, but you can change this to some other number. 
    Please note that this involves changing the USB driver itself, and it is not something we have tested, so there might be unintended side effects or issues by making this change. 

    Based on my discussion with the USB developer the bulk write behavior you see is most likely caused by how the data is handled on the host side, and not how it is sent. If you are able to sniff the USB communication itself you should see that the data is sent more or less every 10 milliseconds. 

    Best regards
    Torbjørn

Children
No Data
Related