Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 3 1 2 3 LastLast
Results 1 to 25 of 51

Thread: Teensy4.1 - reading from Serial Monitor of Arduino IDE

  1. #1

    Teensy4.1 - reading from Serial Monitor of Arduino IDE

    Hi,

    some sketches waiting for a key stroke seems not to work on a Teensy 4.1 (Arduino IDE 2.0 rc9).
    So I use this example:

    Code:
    int incomingByte = 0; 
    uint32_t  i = 1;
    
    // replace non printable characters by a blank
    char mychr(int wert){
      if (wert >= 30) return char(wert);
      else return ' ';
    }
    
    void setup() {
      Serial.begin(9600);      // not needed
      // Wait for USB Serial
      while (!Serial) {
        yield();
      }
      Serial.println("Test Teensy4.1 and USBserial");
    }
    
    void loop() {
      if (Serial.available() > 0) {
        // read the incoming byte:
        incomingByte = Serial.read();
        Serial.printf("(%lu) received: %0X '%c'\n",i, incomingByte, mychr(incomingByte) );
        i++;
      }
    }
    I type 1 + Ctrl + Enter , nothing happens. I type 2 + Ctrl + Enter, now I can see an output.

    08:45:16.287 -> Test Teensy 4.1 and USB-serial
    08:45:29.961 -> (1) received: 32 = '2'
    08:45:29.961 -> (2) received: D = ' '
    08:45:29.961 -> (3) received: A = ' '
    08:45:35.454 -> (4) received: 34 = '4'
    08:45:35.454 -> (5) received: D = ' '
    08:45:35.454 -> (6) received: A = ' '
    08:45:44.885 -> (7) received: 36 = '6'
    So only each second stroke gives an output. After removing USB cable and reconnect it can happen, that I see 1st, 3rd and so on keystroke. Or I see 4th, 8th and so on.

    And trying a long input:
    aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqq qrrrssstttuuuvvvwwwxxxyyyzzz1112223334445556667778 88999000
    I get this ouput:
    08:49:21.654 -> (7) received: 6E = 'n'
    08:49:21.654 -> (8) received: 6E = 'n'
    08:49:21.654 -> (9) received: 6F = 'o'
    08:49:21.654 -> (10) received: 6F = 'o'
    08:49:21.654 -> (11) received: 6F = 'o'
    08:49:21.654 -> (12) received: 70 = 'p'
    08:49:21.654 -> (13) received: 70 = 'p'
    08:49:21.654 -> (14) received: 70 = 'p'
    08:49:21.654 -> (15) received: 71 = 'q'
    08:49:21.654 -> (16) received: 71 = 'q'
    08:49:21.654 -> (17) received: 71 = 'q'
    08:49:21.654 -> (18) received: 72 = 'r'
    08:49:21.654 -> (19) received: 72 = 'r'
    08:49:21.654 -> (20) received: 72 = 'r'
    08:49:21.654 -> (21) received: 73 = 's'
    08:49:21.654 -> (22) received: 73 = 's'
    08:49:21.654 -> (23) received: 73 = 's'
    08:49:21.654 -> (24) received: 74 = 't'
    08:49:21.654 -> (25) received: 74 = 't'
    08:49:21.654 -> (26) received: 74 = 't'
    08:49:21.654 -> (27) received: 61 = 'a'
    08:49:21.654 -> (28) received: 61 = 'a'
    08:49:21.654 -> (29) received: 61 = 'a'
    08:49:21.654 -> (30) received: 62 = 'b'
    08:49:21.654 -> (31) received: 62 = 'b'
    08:49:21.654 -> (32) received: 62 = 'b'
    08:49:21.654 -> (33) received: 63 = 'c'
    08:49:21.654 -> (34) received: 63 = 'c'
    08:49:21.654 -> (35) received: 63 = 'c'
    08:49:21.654 -> (36) received: 64 = 'd'
    08:49:21.654 -> (37) received: 64 = 'd'
    08:49:21.654 -> (38) received: 64 = 'd'
    08:49:21.654 -> (39) received: 65 = 'e'
    08:49:21.654 -> (40) received: 65 = 'e'
    08:49:21.654 -> (41) received: 65 = 'e'
    08:49:21.654 -> (42) received: 66 = 'f'
    08:49:21.654 -> (43) received: 66 = 'f'
    08:49:21.654 -> (44) received: 66 = 'f'
    08:49:21.654 -> (45) received: 67 = 'g'
    08:49:21.654 -> (46) received: 67 = 'g'
    Does someone know what my mistake is?

    Bye,
    Jürgen

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,382
    At this point, I would suggest updating your IDE2. You are using an earlier RC and it has already released.

    Actually would suggest using the daily build as other things have been fixed since the release.

  3. #3
    Github https://github.com/arduino/arduino-ide/releases tells me, that my version from 14.09.2022 is the latest. I will definitly not use a nightly build.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,406
    In IDE2, click the boards manager and type "teensy" in the search. Which version (of Teensy file) is installed.

    Since you're using Arduino IDE 2.0.0-rc9 (from before the 2.0.0 release), my guess is you might have a copy of Teensyduino before 1.57.0. Also guessing you might be using Microsoft Windows. A bug in the "pluggable monitor" teensy-monitor on Windows was fixed shortly before the 1.57 release. Just a blind guess, maybe the problems you're seeing are from that bug?

  5. #5
    Quote Originally Posted by PaulStoffregen View Post
    Since you're using Arduino IDE 2.0.0-rc9 (from before the 2.0.0 release), my guess is you might have a copy of Teensyduino before 1.57.0.
    No. Each version of Arduino is only called 2.0.0. There is no 2.0.1 or 2.1.0 like other companies name the their software. Only additional information is a timestamp, may be from compiling and offering for download.
    Code:
    Version: 2.0.0
    Date: 2022-09-14T07:06:37.759Z
    CLI Version: 0.27.1 [a900cfb2]
    Copyright © 2022 Arduino SA
    On some Github-pages you can see, that they still count up a rc-number. So believe me, that my IDE is the latest stable version.

    Windows 10 and Teensy package is 1.57.

    Bye,
    Jürgen
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Teensy-Package.jpg 
Views:	22 
Size:	32.8 KB 
ID:	29650  

  6. #6
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    Hmm, see the same issue here.
    Click image for larger version. 

Name:	oct26b.png 
Views:	40 
Size:	49.5 KB 
ID:	29653

    Steps to reproduce:
    1. Open Arduino IDE2
    Version: 2.0.0
    Date: 2022-09-14T07:06:37.759Z
    CLI Version: 0.27.1 [a900cfb2]
    Copyright © 2022 Arduino SA

    2. Copy the code from message #1, compile and upload
    3. Open serial monitor
    4. Disconnect and connect Teensy 4.1
    5. Type 1 <CNTR + ENTER>, no response in serial monitor
    6. Type 2 <CNTR + ENTER>, no response in serial monitor
    7. Type 3 <CNTR + ENTER>, response, see screenshot
    8. Type 4 <CNTR + ENTER>, response, see screenshot
    9. Type 5 <CNTR + ENTER>, no response in serial monitor
    10. Type 6 <CNTR + ENTER>, no response in serial monitor
    11. Type 7 <CNTR + ENTER>, response, see screenshot

    Also Windows 10 & Teensyduino 1.57.

    Paul

  7. #7
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    Another observation: right after compiling and uploading, all serial responses looks normal. But after disconnecting and connecting the Teensy, missing responses occur.

    Paul

  8. #8
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,382
    Quote Originally Posted by PaulS View Post
    Another observation: right after compiling and uploading, all serial responses looks normal. But after disconnecting and connecting the Teensy, missing responses occur.

    Paul
    Suggest that you install daily build. Not to necessarily replace the released and see if it reproduces with it. If so search the open issues in the arduino ide GitHub project. If none appear to cover this, open a new one. Also maybe open thread on arduino forum in the ide 2 area. Usually one of the arduino developers will respond

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,406
    Please hold off opening an issue with the Arduino developers on github. I'll get my Windows test machine and USB protocol analyzer out and take a look at what's really going on. Let's wait just a day or two to get a better idea whether it's really an issue inside the IDE or something going wrong with Teensy's pluggable monitor utility.

  10. #10
    Quote Originally Posted by PaulStoffregen View Post
    Please hold off opening an issue with the Arduino developers on github. I'll get my Windows test machine and USB protocol analyzer out and take a look at what's really going on. Let's wait just a day or two to get a better idea whether it's really an issue inside the IDE or something going wrong with Teensy's pluggable monitor utility.
    I take out an older Arduino UNO with USB-B socket ...
    I have to replace Serial.printf line by

    Code:
    Serial.print(i,DEC);
    Serial.print(" received: ");
    Serial.println(incomingByte,HEX);
    because of an error class HardwareSerial' has no member named 'printf'

    With Arduino UNO the test sketch gives output for each keystroke.
    So it is not a problem with Arduino IDE 2.0.0


    Next step I'm going back to Teensy 4.1 and upload the changed sketch with 3 Serial.print-lines. Again only each second keystroke gives an output to Serial Monitor.

    @Paul: do you still have Arduino 1.8.x IDE on your test computer? If problem occurs also with such an old version, it must be a problem with Teensy 4.1.

    Bye,
    Jürgen
    Last edited by bastler59; 10-27-2022 at 05:36 AM.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,406
    Quote Originally Posted by bastler59 View Post
    @Paul: do you still have Arduino 1.8.x IDE on your test computer?
    Right now, no versions of Arduino are installed on my Windows test machine. It was recently wiped clean.

    I have another project on my workbench at this moment, but later today I'll put it away and look at this problem. Also need to look at what's going wrong with the new MacOS which Apple released just a few days ago.

  12. #12
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    8,539
    Quote Originally Posted by PaulS View Post
    Hmm, see the same issue here.
    Click image for larger version. 

Name:	oct26b.png 
Views:	40 
Size:	49.5 KB 
ID:	29653

    Steps to reproduce:
    1. Open Arduino IDE2
    Version: 2.0.0
    Date: 2022-09-14T07:06:37.759Z
    CLI Version: 0.27.1 [a900cfb2]
    Copyright © 2022 Arduino SA

    2. Copy the code from message #1, compile and upload
    3. Open serial monitor
    4. Disconnect and connect Teensy 4.1
    5. Type 1 <CNTR + ENTER>, no response in serial monitor
    6. Type 2 <CNTR + ENTER>, no response in serial monitor
    7. Type 3 <CNTR + ENTER>, response, see screenshot
    8. Type 4 <CNTR + ENTER>, response, see screenshot
    9. Type 5 <CNTR + ENTER>, no response in serial monitor
    10. Type 6 <CNTR + ENTER>, no response in serial monitor
    11. Type 7 <CNTR + ENTER>, response, see screenshot

    Also Windows 10 & Teensyduino 1.57.

    Paul
    @PaulStoffregen
    Seeing the same thing with Arduino 2.0.0 with TD1.58beta2. However, following the same steps using Arduino 1.8.19 with 1.58beta2 does not look like it is having the same problem.
    Click image for larger version. 

Name:	Capture.PNG 
Views:	23 
Size:	14.2 KB 
ID:	29656

  13. #13
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    Quote Originally Posted by PaulS View Post
    Another observation: right after compiling and uploading, all serial responses looks normal. But after disconnecting and connecting the Teensy, missing responses occur
    When using Arduino 1.8.19/Teensyduino 1.57, I don't see any missing responses after compiling and uploading and no missing responses after disconnecting-connecting.

    Paul

  14. #14
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,709

    IDE 2.0.1 released

    Opening IDE 2 to check this there is a Notice of IDE 2.0.1 update available. Installing that to test ...


    ZIP install for IDE 2 note: Had been in the habit of ZIP install for IDE 1.8.x, so first IDE 2 was done that way.

    When an Auto update is done (on Windows) - it downloads the Installer and moves the installation to that location abandoning the prior ZIP install.

  15. #15
    Again an awful installation with progress bar that looks like hanging in the middle of installation and not changing for several minutes. Killed by task manager. Then second try. Looks similar, but then bar jumps back, moves fast from zero to the end, jumps back again, staying somewhere and then message, that installation is ready

    But: it looks like test sketch is working! Each keystroke generates an output.

    Bye
    Jürgen

  16. #16
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    After updating to Arduino 2.0.1. and trying to compile the exact same code from message #6, I got this error:
    Invalid FQBN: not an FQBN: teensy:avr:teensy41:usb=serial:usb=serial,speed=60 0,opt=o2std,keys=en-us
    Compilation error: Invalid FQBN: not an FQBN: teensy:avr:teensy41:usb=serial:usb=serial,speed=60 0,opt=o2std,keys=en-us
    - Quited the Arduino IDE, disconnected the Teensy 4.1,
    - Re-opened the Arduino IDE and connected the Teensy,
    - Took a few seconds to recognize the Teensy 4.1,
    - Hit the UPLOAD button,
    - Same compilation error as above.

    Paul

    *update*:after rebooting my PC still see the same compilation error
    Last edited by PaulS; 10-27-2022 at 09:55 PM. Reason: update after rebooting

  17. #17
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,709
    Indeed, Install took some time ... Download - then find Install Window ... then walk away and completed it asks to start IDE ...

    Then pasting code to NEW and selecting T_4.1 it won't build?
    Code:
    Invalid FQBN: not an FQBN: teensy:avr:teensy41:usb=serial:usb=serial,speed=600,opt=o2std,keys=en-us
    
    Compilation error: Invalid FQBN: not an FQBN: teensy:avr:teensy41:usb=serial:usb=serial,speed=600,opt=o2std,keys=en-us
    Not sure why - the menu items are set and that covers the menu items? Except "usb=serial:usb=serial" seems a bit redundant and repetitive?

  18. #18
    I had sketch already on my Teensy 4.1, so I don't compile/upload it again.

    When I try to compile it starts with that "Invalid FQBN: "-message too.
    I uninstall Teensy package, install it again. Same error.

  19. #19
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    From the Arduino IDE Tools menu, I had to re-select the Teensy 4.1 board and now it compiles and uploads without any problem.
    But the initial problem is still there after disconnecting and connecting the Teensy:
    22:59:50.761 ->22:59:32.689 -> Test Teensy4.1 and USBserial
    22:59:43.180 -> (1) received: 32 '2'
    22:59:43.180 -> (2) received: D ' '
    22:59:43.180 -> (3) received: A ' '
    22:59:50.761 -> (6) received: 34 '4'
    22:59:50.761 -> (7) received: D ' '
    22:59:50.761 -> (8) received: A ' '
    22:59:57.402 -> (9) received: 36 '6'
    22:59:57.402 -> (10) received: D ' '
    22:59:57.402 -> (11) received: A ' '
    23:00:22.987 -> (12) received: 37 '7'
    23:00:22.987 -> (13) received: D ' '
    23:00:22.987 -> (14) received: A ' '
    23:00:27.588 -> (15) received: 39 '9'
    23:00:27.588 -> (16) received: D ' '
    23:00:27.588 -> (17) received: A ' '
    Responses on 1, 3, 5, 8, and 0 are missing.

    Paul

  20. #20
    OK, a little success ...

    Normally right to the buttons (verify, upload, debug) is a small window. There I see "Teensy", but not with a USB-fork-Icon. It has 3d-cube instead. I change the board by pulldown to "unknown COM5". Now the dialog comes up "Select a board and port". Here I select "Teensy 4.1" and "COM5 Serial Teensy ports". Now I can compile without error.

    After uploading by Teensy Loader I also have missing output again.


    Bye
    Jürgen

    Click image for larger version. 

Name:	IDE-Teensy1.png 
Views:	22 
Size:	8.4 KB 
ID:	29661
    -----------------
    Click image for larger version. 

Name:	IDE-Teensy2.jpg 
Views:	22 
Size:	51.8 KB 
ID:	29660

  21. #21
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    Quote Originally Posted by bastler59 View Post
    it looks like test sketch is working! Each keystroke generates an output
    Did you also disconnect and connect the Teensy while in the IDE/Serial monitor and then try a number of keystrokes again?

    Paul

  22. #22
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,382
    Quote Originally Posted by PaulS View Post
    After updating to Arduino 2.0.1. and trying to compile the exact same code from message #6, I got this error:


    - Quited the Arduino IDE, disconnected the Teensy 4.1,
    - Re-opened the Arduino IDE and connected the Teensy,
    - Took a few seconds to recognize the Teensy 4.1,
    - Hit the UPLOAD button,
    - Same compilation error as above.

    Paul

    *update*:after rebooting my PC still see the same compilation error
    Note: I opened a thread up early this morning on the Arduino Forum, as I saw that error on the daily build:
    https://forum.arduino.cc/t/invalid-f...n-fqbn/1046630

    @PerT (@ptillisch on Arduino) - has confirmed the problem and will be creating a new issue in the Arduino github projects (not sure if this will be under IDE or CLI.

    I wondered if they were about to issue a new release as there were updates over the last week including pulling in new version of CLI.

  23. #23
    OK, I select Teensy board with that 3D cube.

    Click image for larger version. 

Name:	IDE-Teensy3.png 
Views:	21 
Size:	34.3 KB 
ID:	29662

    Again I have the error, when I try to compile the sketch. But all keystrokes comes back to Serial Monitor.

    I think the problem has something to do with the way Teensy 4.1 handles USB connection ...

    Bye
    Jürgen

  24. #24
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    963
    Quote Originally Posted by KurtE View Post
    Note: I opened a thread up early this morning on the Arduino Forum, as I saw that error on the daily build
    I think this new Invalid FQBN error is not related to the missing serial responses after disconnecting and reconnecting the Teensy.
    Perhaps we should give Paul Stoffregen some time now to investigate whether something is wrong with Teensy's pluggable monitor utility.

    Paul

  25. #25
    Quote Originally Posted by bastler59 View Post
    Again I have the error, when I try to compile the sketch. But all keystrokes comes back to Serial Monitor.
    And again I have to update: after disconnect and connect again some keystrokes are missing. And compile error is still there.

    Time to go to bed ...

Posting Permissions

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