Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Teensy 3.6: Sending blocks of data through USB

  1. #1

    Teensy 3.6: Sending blocks of data through USB

    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! :)

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,867
    Quote Originally Posted by ErikRasmussen View Post
    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 "&".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •