I used 52840DK and SDK15.2 to test usb cdc, every thing goes will, but in rx event, it always missed first byte, for example, if send "123456", it just received "23456", if send just "1", there is no rx event. though I can see the first byte right in the internal_rx_buf, but how to make the rx event correctly receive first byte?
Was able to reproduce the exact same behavior here and it seems to be caused by a logical error in the app_usbd_cdc_acm.c->cdc_acm_rx_block_finished() implementation. It "worked" when I commented out the following lines:
// First buffer is full p_cdc_acm_ctx->last_read = p_cdc_acm_ctx->bytes_read; //+ bytes_to_cpy; p_cdc_acm_ctx->bytes_read = 0; p_cdc_acm_ctx->bytes_left = bytes_read; // - bytes_to_cpy; p_cdc_acm_ctx->p_copy_pos = p_cdc_acm_ctx->internal_rx_buf;// + bytes_to_cpy;
However, it breaks the buffer switching so would not suggest to make this change. I have reported it as a bug internally.
I have the same problem reported by Brian. I have solved it with the "solution" you provided. However, you mention that this is not recommended.
Is there any recomended solution? We are developing a prototype and we would like to have a stable code as soon as possible.
Any updates about this issue? Will the patch be available in the next release of the SDK?
yqin15,drk_tg, @Juan, for some reason I'm not able to replicate this issue anymore, nor is the developer who is tasked with fixing it. This is how I'm testing it:
- First I build and program the example from SDK 15.2.0 using SES then open a separate serial terminal to view the debug log
- Use realterm serial client to send a text string through the nRF USB
- Check if all data gets received by inspecting the debug log
Please let me know if you are testing it differently so that I can try the same here.
Here's the .hex file used:
Yes, it is working for me now. Actually, there was not a bug. It was a concept mistake. But now things are clear for me.