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

Thread: Teensy LC and 3.1 slow usb serial reads

  1. #26
    Junior Member
    Join Date
    Feb 2020
    Posts
    16
    I'd like to thank you all for your assistance. Seems this is a rather arcane problem that will prove difficult to fix

    Click image for larger version. 

Name:	LK8000 screenshot.png 
Views:	4 
Size:	45.4 KB 
ID:	19006
    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.

  2. #27
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,163
    So, show your code
    Maybe we can fix it.

  3. #28
    Junior Member
    Join Date
    Feb 2020
    Posts
    16
    Quote Originally Posted by Frank B View Post
    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

  4. #29
    Junior Member
    Join Date
    Feb 2020
    Posts
    16
    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
    Click image for larger version. 

Name:	FrankB teensy1.png 
Views:	2 
Size:	41.7 KB 
ID:	19010

  5. #30
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,163
    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 by Frank B; 02-09-2020 at 08:45 PM.

  6. #31
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,163
    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 :-)

  7. #32
    Junior Member
    Join Date
    Feb 2020
    Posts
    16
    Quote Originally Posted by Frank B View Post
    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.

Posting Permissions

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