Issue with USB Serial data transfer to PC.

{sasha}

New member
Good day everyone.

Might be a dumb question, but I did search here and google for couple of days now, but couldn't find precise answer/solution.

I'm having weird data loss/corruption issues with data transfer over USB serial from Teensy 4.0 & 4.1.

I generate test data pattern from teensy 4.0 (same issue 4.1) using simple sketch:

Code:
#define BUFF_SIZE 512                  // I've played here with different sizes
#define TOTAL_TRANSACTIONS 16384       // Total dump file size: 16384 * 512 = 8388608 B

void setup()
{
}

void loop()
{
  delay(10000);
  unsigned char buff[BUFF_SIZE] = {0};      // Buffer to send
  unsigned int i, j;

  for (i = 0; i < TOTAL_TRANSACTIONS; i++)  // Loop to send multiple transactions
  {
    for (j = 0; j < BUFF_SIZE; j++)         // Loop to shape buffer for transcation (test data)
    {
      buff[j] = 0x55;
    }
    Serial.write(buff, BUFF_SIZE);
    delayMicroseconds(100);
  }
  exit(0);
}

On receiving end I use TeraTerm with enabled option to save data to binary log file.

While investigating received dump with HxD, I can spot some garbage "inclusions" of garbage data.
I can only explain it as some sectors on my disk allocated to file were not overwritten due to usb lock-up and it's my old junk data ?).

Here's pic
pic.png

It's random-ish, location and size of those chunks differs from attempt to attempt.
I'm assuming, it may have to do with lack of "handshake" between TX/RX or some flags?

I appreciate for any help and sorry for my possibly noob-ish question.

P.S. I love Teensy, it is a little BEAST.
 
I realized I have definitely missed several posts on this forum regarding this issue,
I should probably rephrase my questions to:

Is there any fresh fix to the high speed USB serial data transfer to avoid data loss and corruption?
 
I do believe I found solution/workaround here by @luni.
I assume that it not only does solve the data loss issues but also prevents data corruption?

I will test it within couple of days and report back here.
 
Yes, don't use Windows :)
You would need to fix the Windows driver. It's (mainly) not a Teensy issue, it's a common problem with other MCUs and Windows, too. However, I've seen data-loss due to a teensy problem, too.
As workaround you can add a longer delay (fixes both), so that the windows buffer does not overflow.

Edit: Oops, crosspost.
 
Back
Top