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

USBD Custom USB device

Hi,

is there an example of how to build up a custom USB device?

The throughput of the CDC example is only 200 kB/s and we would need a bit more.

Thanks in advance,

Constantin

Parents
  • Hi Constantin,

    is there an example of how to build up a custom USB device?

    Not per se, but you can refer to the existing implementations to see how it is done there and adapt to your needs.

    The throughput of the CDC example is only 200 kB/s and we would need a bit more.

    This depends on several factors. If using CDC  on Windows we also see about or slightly above 200 kB/s.

    Einar

  • Okay I've did a lot of benchmarking. And it is kind of strange:

    1. Using a development board with the CDC example of the SDK with permanent sending I can get under macOSX 80 kB/s.
    2. If run the same board with the same terminal but under a WIN10 Laptop I can reach 200 kB/s.
    3. If I run it in a virtual machine Ubuntu under a macOSX I can get only 80 kB/s.

    If I put the same lines of code in the main in my custom sensor and do the same benchmarking (BLE is enabled etc.)
    1. Using a development board with the CDC example of the SDK with permanent sending I can get under macOSX 70 kB/s.
    2. If run the same board with the same terminal but under a WIN10 Laptop I can reach 160 kB/s.
    3. If I run it in a virtual machine Ubuntu under a macOSX I can get only 70 kB/s.

    What I do not understand is that a lot of threads are telling that under Linux / mac even 480 kB/s are possible. So what can be the issue?

    Kind regards,

    Constantin

  • Hi Constantin,

    I it difficult to say where the bottleneck is. The CDC data is transferred with bulk transfers which does not provide any guarantees on throughput or latency. The PC side has a lot to say here (as you write you see different speeds using Ubuntu in a VM etc). It could be interesting to know how you test and if a USB sniffer shows something interesting though I expect it won't tell us much about what happens on the PC side)? Another point is that you may also experience difference in speed depending on other devices connected to the same USB hub (internal or external) etc.

    Generally I have not looked much into transfer speeds as that is typically not a major concern. And we do not have an overview of how various operating systems etc affects this.

    May I ask why you need such high transfer speeds?

  • Okay I found that the APP_USBD_CONFIG_EVENT_QUEUE_ENABLE is an issue if I am using the app_scheduler. But now I am facing a different issues. If am sending byte arrays to the cdc example code. The reading stops as soon there is a 0x00 byte in side the stream. And I do not understand why?

    Is there any explanation on that?

    You can test it by yourself:

    ser.write(b'\x02\x00\x01\x01\x01\x01\x01\x00\x03');

    stops after the first byte and tells me that there a more bytes left in the internal buffer

    ser.write(b'hello')

    reads all data.

    I am bit puzzled.

  • Okay found the issue. The issue in you example is this line:

    NRF_LOG_INFO("RX: size: %lu char: %c", size, m_rx_buffer[0]);

    If the buffer incorporates a 0 the LOG will break or just not write further. Simple error big reaction. I guess this can be closed.

Reply Children
No Data
Related