Teensy LC and 3.1 slow usb serial reads

Status
Not open for further replies.
I'd like to thank you all for your assistance. Seems this is a rather arcane problem that will prove difficult to fix

LK8000 screenshot.png
I've configured the LK8000 application to run on a pc as host connected to the GPS and teensy 3.1 through different terminals of a usb hub.
I've put a print statement in my code to confirm when one particular line ($PFLAU) is found by the teensy and then print a line confirming.
The behaviour is slightly different in that the third sentence ($GPGSA) is now detected, but the confirmation of $PFLAU is intermittent (as can be seen by the earlier occurrence of $PFLAU)
I suspect that all sentences are detected intermittently because when I disconnect the GPS my application outputs some of the messages that are missed.
What I see on the monitors on both Kobo and pc is strobed by the problem that I'm trying to solve.
 
So, show your code :)
Maybe we can fix it.

My nano code fills the available space; here's the part that reads the serial (I print it back to the Kobo with no problem so I can see that all works ok)

int charsRead;
char inputString[200];

if (Serial.available()) {
charsRead = Serial.readBytesUntil('\n', inputString, sizeof(inputString) - 1);
inputString[charsRead] = '\0';
String buffer_test = inputString;
Serial.println(buffer_test);

I put your code in place of this with no luck, I'll check again to see if there are paste errors
 
Hi Frank, I've run your code on the pc version of the usb host (LK8000). It detects all the sentences and the serial read times are similar to those on the Kobo.
All I can conclude is there is something different when LK8000 is running on the Kobo that the teensy doesn't like. The theory about strobing was incorrect. All appears correct on the pc version.
The only difference I see when I connect the nano version of my device is that the nano automatically reboots itself when the Kobo connects. From time to time I have seen the LK8000 application announce a "Master Timer reset" when the teensy is running my code and loosing sentences
FrankB teensy1.png
 
I'm more under the impression, that the Kobo is the problem. You're not the the first who uses Serial over USB on Teensy ;) (thousands..millions? parts sold) and I've never heard about such problems.
Then, why did you post code that you don't even use (post #1 <-> post #28) - this was NOT helpful. It wastes the time of everyone involved.
Yes, Serial.readBytesUntil is better - I could have used it in my exmple code but thought I'll write it like you to make it easier for you.

You've seen it works on your PC - so I don't know how we can help. A problem with the Teensy is still possible - but extremely unlikely. I still think, it's just that the KOBO is too slow and looses USB data somehow. Maybe write a loop that sends back char for char - not as string - and insert a Serial.flush() and a delay after every char to mimic the nanos slow sending?
Is this echoing back really needed?

Edit:
I have a KOBO e_book - it's dead-slow (for reading good enough). If your device is similar, it's no surprise for me that you have problems.
 
Last edited:
The easiest solution might be to just add a cheap 3 US$ serial-usb converter to pins 0 and 1 and use Serial1.xxx().. with Serial1.begin(38400)
This will save you hours of navigating around bugs and problems :)
 
The easiest solution might be to just add a cheap 3 US$ serial-usb converter to pins 0 and 1 and use Serial1.xxx().. with Serial1.begin(38400)
This will save you hours of navigating around bugs and problems :)
Yes, I've considered the usb/serial converter route but decided not to go down another rabbit hole which will end up with hours spent on a logic analyser. I now understand that there's no usb problem between a pc and the teensy. However, I may be one of the first people to try use a teensy 3.1/LC to communicate with a Kobo running LK8000 through a hub. I think we've spent enough time on this, thanks for your help.
 
Hi, well I went down the STM32 route and ended up back here!
I took Frank's suggestion and used HWSERIAL via a FTDI serial/usb converter on the LC and it sees all the sentences coming from the Kobo.
This may prove interesting for others struggling with the 64k usb serial buffer. (I tried playing with the size of the buffer unsuccessfully). I didn't find the reason for the missing sentences via usb.
 
Status
Not open for further replies.
Back
Top