Thank you for this post, it helped me get started with the same thing. I'm using LabVIEW at the receiving end. What I found is that the Due is sending serial out in 4096 chunks. This must be the default size of the Tx buffer. When I varied the receive buffer size in LabVIEW, the input always came in the same. I modified the Due code to alter the data every time it is sent so I can see each SerialUSB.write. I put a delay after each write to make it easier to see what was going on at the Rx end. The data is coming in very fast.
int x,b,i;
uint16_t buf[4][256];
void setup()
{ SerialUSB.begin(0);
while(!SerialUSB);
for(b=0; b<=3; b++)
for(i = 0; i < 256; i++)
buf[b][i] = (uint16_t)i*(b+1)*32;
}
void loop()
{ SerialUSB.write((uint8_t*)buf[b], 512);
b=(b+1)&3;
delay(125);
}
In LabVIEW, I found that the only serial setting I had to change (from defaults) to make it work was "Serial End Mode for Reads" or "ASRL End In". I needed to make this "None"
Attached are pictures of the LabVIEW diagram and panel.
The length ("len") shown is the length of the 16 bit array, so the string length was twice that.
I had to do a byte swap of the 16 bit numbers for them to be correct for the PC.
For those not versed in LabVIEW, a short explanation of the diagram:
A serial port connection is opened, and I am only changing one property: ASRL End In
I set the buffer size to 4096 bytes
The grey rectangle is a while loop. The loop continues until there is an error, or a stop it executed.
The serial port is polled to see if there in anything in the receive buffer; if so, then the buffer is read, the string output is type cast to a unsigned 16 bit integer array, the bytes of the 16 bit numbers are swapped, and the output is displayed on a graph (Waveform).
The panel shows the waveform. The Due is sending ramp waveforms with 4 different amplitudes.
I don't have a precise timing for the incoming signal, but when I use the LabVIEW millisecond timer to measure things, the incoming 4096 bytes doesn't even register, so it is under 1 msec.
... later ...
I just found something with SerialUSB.write(). When I send 512 bytes, it waits until there is 512*8 before sending (sends after every 8 SerialUSB.write statements), but if I send 511 bytes or less, it sends immediately. SerialUSB.flush() has no effect on this. This is what made me think that the write buffer was 4096.

