Teensy 3.6: Sending blocks of data through USB

Status
Not open for further replies.
I am working on a project, where I have to send blocks of data through the USB connector. Each block is 40016 bytes long. Can I simply write this block in one go: Serial.write(&block, 40016);

Does Teensy provide buffer control?
I ask because I seem to be loosing data during the transmission.

Or is there a better method for sending big blocks of data through USB?

Thanks for any help! :)
 
Each block is 40016 bytes long. Can I simply write this block in one go:

Yes, this should work. But the USB stack has a fixed number of buffers, usually about 12 and usually 4 or so are used for other stuff. The buffers are 64 bytes, so you can expect about the first 512 bytes to copy directly to the buffers. For the remaining 35.5K of data, it should end up waiting and copying it into the buffers as they finish transmitting and become available again. If you're ok with Serial.write() waiting and not returning to the rest of your program for some time, then go ahead and use it.

Serial.write(&block, 40016);
....
I ask because I seem to be loosing data during the transmission.

Maybe this syntax isn't quite right? Just a blind guess, since I can't see the rest of your code which has the definition of "block". But normally something like this would be an array, where you wouldn't use "&".
 
Status
Not open for further replies.
Back
Top