I haven't tested this with 1.43 yet, but it appears that teensy 3.2 hardware with the teensyduino 1.42 and arduino 1.8.5 has a USB buffering issue.
Code:
void setup()
{
Serial.begin(9600);
}
void loop()
{
static uint8_t buf[4096];
for(unsigned i = 0 ; i < sizeof(buf) ; i++)
{
while(1)
{
int c = Serial.read();
if (c == -1)
continue;
buf[i] = c;
break;
}
}
// and check for proper pattern
// every 4 bytes should increment
uint32_t x = ((uint32_t*) buf)[0];
unsigned fail = 0;
for(unsigned i = 0 ; i < sizeof(buf) ; i+=4, x += 1)
{
uint32_t y = ((uint32_t*) buf)[i/4];
if (y == x)
continue;
Serial.print(i, HEX);
Serial.print(" ");
Serial.print(x, HEX);
Serial.print("!=");
Serial.print(y, HEX);
Serial.println();
fail++;
}
if (fail != 0)
{
Serial.print("FAIL ");
Serial.println(fail);
}
// and simulate a flash write delay to force USB buffering
delay(10);
}
Feed this with serial data from:
Code:
#!/usr/bin/perl
use warnings;
use strict;
for(my $x = 0 ; $x < 8*1024*1024 ; $x+=1)
{
print pack("V", $x);
}
After a few megabytes it gets an failure when the previous 64 bytes are replayed:
Code:
......22C FD88B!=FD8AB
230 FD88C!=FD8AC
234 FD88D!=FD8AD
238 FD88E!=FD8AE
23C FD88F!=FD8AF
240 FD890!=FD8B0
244 FD891!=FD8B1
248 FD892!=FD8B2
24C FD893!=FD8B3
250 FD894!=FD8B4
254 FD895!=FD8B5
258 FD896!=FD8B6
25C FD897!=FD8B7
260 FD898!=FD8B8
264 FD899!=FD8B9
268 FD89A!=FD8BA
2A8 FD8AA!=FD7AA
2AC FD8AB!=FD7FB
2B0 FD8AC!=FD7FC
2B4 FD8AD!=FD7FD
2B8 FD8AE!=FD7FE
2BC FD......
With 1.6.8 and an ancient teensyduino this error never occurs. What's interesting is only that 64 byte block is in error; the stream re-synchronizes afterwards.