The following demonstrates a problem I am having with the Serial interface on the Teensy. Large transfers fail as shown below.
Code snippet from Teensy 3.2
Python
And the result, is the two short lines of text are transferred, then the first 4096, then 302 bytes of the next buffer, and then nothing.
Code snippet from Teensy 3.2
Code:
case 'v':
case 'V':
if (*nextcharpointer == 'x') {
char *pc = (char *)databuffer;
Serial.println( (char *)"starting" );
for (n = 0; n < 4096; n++ ) {
pc[n] = 'a' + n%26;
}
for (n = 0; n < 100; n++ ) {
Serial.write( (uint8_t *) databuffer, 4096 );
}
break;
}
if ( parseint( p0, &p1, &debug ) ) {
debug = strtoul( p0, &p1, 0 );
serialprintf( (char *)"%s - debug = %d\n", versionstr, debug );
}
else {
serialprintf( (char *)"%s\n", versionstr );
}
break;
Python
Code:
#!/usr/bin/python
import serial
ser = serial.Serial( '/dev/ttyACM0', 19600, timeout = 2 )
ser.write( 'v'.encode() )
rawbuf = ser.readline( )
print( rawbuf.decode() )
ser.write( 'x'.encode() )
rawbuf = ser.readline( )
print( rawbuf.decode() )
n = 0
while True:
rawbuf = ser.read( 4096)
print( 'read', n, len(rawbuf) )
n += 1
if n > 10:
break
And the result, is the two short lines of text are transferred, then the first 4096, then 302 bytes of the next buffer, and then nothing.
Code:
$ ./HostFlowTest.py
TDAQ Firmware 2.4
DONE
read 0 4096
read 1 302
read 2 0
read 3 0
read 4 0
read 5 0
read 6 0
read 7 0
read 8 0
read 9 0
read 10 0