Go Down

Topic: Data loss when sending to native USB port (SerialUSB) (Read 22024 times) previous topic - next topic


Not yet, I'll wait until the patch is reliable before making a pull request. At the moment it's still losing data somewhere.

It can't be directly related to the issue you linked to (because UHD_ functions are for USB host, but here we are using UDD_ functions for USB device mode). However I am convinced that the bug is in libsam rather than SerialUSB.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html



Oct 25, 2013, 09:43 am Last Edit: Oct 25, 2013, 03:19 pm by dlloyd Reason: 1
I do seem to be getting occasional errors but only about once every several gigabytes, which makes it hard to debug as I don't know if it's a problem with the code or the cable or with the way I am testing it. Testing so far indicates it is a problem with transmission (SerialUSB.write())

I think there's a problem in the ring buffer, where OVERFLOW of variable "i" (which is an unsigned 32 bit integer) is not dealt with. In the ring buffer code below, where i = (i + 1) % CDC_SERIAL_BUFFER_SIZE;, the value of "i" will keep counting up by one for each iteration (until it overflows), but the value of the statement will count from 0-511 then recycle (for CDC_SERIAL_BUFFER_SIZE = 512).

Ring buffer code in CDC.cpp:
Code: [Select]
ring_buffer *buffer = &cdc_rx_buffer;
uint32_t i = (uint32_t)(buffer->head+1) % CDC_SERIAL_BUFFER_SIZE;

// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
while (i != buffer->tail) {
uint32_t c;
if (!USBD_Available(CDC_RX)) {
c = USBD_Recv(CDC_RX);
// c = UDD_Recv8(CDC_RX & 0xF);
buffer->buffer[buffer->head] = c;
buffer->head = i;




I think there's a problem in the ring buffer

The ring buffer no longer exists in the code being discussed (see stimmers attached files and the thread).

I'm having a lot of problems running Paul Stoffregen's multi-byte benchmark on a fairly new Macbook pro, which is strange as he managed to get reportable results on a Macbook pro.

stimmers test scripts all work perfectly however :~.

The host hangs before the end of the test. Resetting the due causes the host to signal an error (number of bytes delivered) and it aborts. The due however is happily waiting in a 'nothing to receive' loop.

I'm now sending sequenced data and stuff appears to be going missing. I really want to use this so I'll be resuming  in the morning!


This is an updated version of the alternative USB serial code. This fixes one of the problems I was having with the receive_test benchmark and fixes a memory corruption bug.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html


Hi stimmer!

I'd like to follow this one, but its not very handy to manually copy the files and figure out what changed from the last time, it will be much more practical if you start a branch on github. I understand that the patch may be not complete, but I'd really appreciate if you can do that :-)



I'd already made a branch, I just forgot to say :) It's here:

Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html


May 27, 2015, 03:40 pm Last Edit: May 27, 2015, 03:42 pm by iyappan
 I'm trying  to read the ADC data through the  native port ( using CDC Driver ) in Arduino due . My question is
  1. How to write the CDC driver program in Vc++ to getting the ADC data in Command prompt using?

Go Up