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

Thread: Arduino IDE2 - Serial Monitor sometimes does not work - continue from Upload Thread

  1. #51
    Senior Member wwatson's Avatar
    Join Date
    Aug 2017
    Posts
    776
    Quote Originally Posted by defragster View Post
    Windows only ... See Tset. It makes a batch file that runs from Dos box or explorer or notepadd++ - anything that can run the batch file.
    It is due for an update - to note the IDE 2 changes - local.txt option and it includes Arduino15 directories making it use IDE 2 install and removing those can have it use old install process instead.
    Though others have worked out a linux script that can do the same. Though not ever seen it published.
    >> Will update Use-Sublime-Text-as-an-Arduino-IDE-replacement when TSET is updated and can discuss there.
    Thanks, I assumed it was Windows only

  2. #52
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,366
    Ok, here is my first attempt a workaround for delayed or missing WM_DEVICECHANGE messages. It uses polling at 20 Hz when a change seems likely, then backs off to slow 1.2 seconds polling after 15 seconds of rapid polling to reduce CPU usage long-term. I tried to make it as efficient as reasonably possible, so hopefully it doesn't burn too much CPU even in those 15 seconds? WM_DEVICECHANGE is still used, for fastest possible response when Windows is delivering those messages.

    As usual, this goes into C:/Users/me/AppData/Local/Arduino15/packages/teensy/tools/teensy-monitor/1.57.0/, replacing the copy of teensy-monitor.exe in that folder.

    Arduino just released IDE 2.0.3. This works with 2.0.3 and should work with all 2.0.x versions.

    Please let me know if this fully solves the problems? (and if I'm saved from having to run Windows 11) So far, I've tested only on a single Windows 10 machine, with Arduino 2.0.2 and 2.0.3.
    Attached Files Attached Files

  3. #53
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,375
    Downloaded,

    So far I have not run into the issue again. But it was not always getting consistent repeats before.

    Keeping fingers crossed. Running on Windows 11 and hopefully will save me from having to run Ubuntu 22.04

  4. #54
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    8,538
    Morning all

    Downloaded and installed both IDE 2.0.3 and the new teensy-monitor. Reran in accordance with this:
    Code:
    I'm running Defragster's sketch from msg #7.
    
    To reproduce the problem, after uploading and opening the serial monitor (with Teensy Port selected), I quit and restart the IDE. When the IDE restarts, it automatically opens the serial monitor. If the sketch is already running with the LED blinking, nothing is supposed to appear. The sketch only prints stuff when the sketch starts running.
    
    Then with the serial monitor open, I press the pushbutton on Teensy. Teensy Loader uploads the code again.
    
    On the first pushbutton-triggered upload after starting the IDE, when Teensy starts running the sketch again, the serial monitor fails to connect to the freshly reprogrammed Teensy. Its LED stays on solid, indicating it's waiting for the serial monitor to open.
    
    But if I first kill the serial-discovery.exe process, then press the pushbutton, after upload and Teensy begins running Defragster's sketch, the serial monitor does connect. The 2 lines appear (0.33 and 1.33 seconds on my test machine) and the LED blinks, indicating the sketch saw the serial monitor open.
    and it worked no hangs and output displayed:
    Code:
    D:\Users\Merli\Documents\Arduino\sketch_dec4a\sketch_dec4a.ino Dec  5 2022 09:45:43
    run secs A=0.43
    
    D:\Users\Merli\Documents\Arduino\sketch_dec4a\sketch_dec4a.ino Dec  5 2022 09:45:43
    run secs B=1.43
    See Me: 1
    See Me: 2
    See Me: 3
    So at least for the test case its working. Will be playing more today with other stuff so will let you know if anything pops up.

    NOTE: Running on a windows10x64 that had alot of junk on it - definitely not a fresh install.

  5. #55
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,375
    Paul,

    I did run into an issue here, not sure if related.

    I was trying out some changes to USBHost on a few different examples. It was working fine on T4.1 with Teensy Serial Com 7. I opened up another one, and built again, pretty sure I had turned off Serial monitor in other window.... Built and no output. I then changed to the Arduino Com7 and built again and output showed up. I went back to Teensy port... Empty. Then rebuilt still empty. Unplugged Teensy, plugged it back in and Serial output worked.

  6. #56
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,698
    Downloaded and copied into place and started and updated to IDE 2.0.3

    Now I need to restart to get that offending Win EXE restarted like last time.

    ... now just pending reboot to test ...

  7. #57
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    8,538
    Quote Originally Posted by KurtE View Post
    Paul,

    I did run into an issue here, not sure if related.

    I was trying out some changes to USBHost on a few different examples. It was working fine on T4.1 with Teensy Serial Com 7. I opened up another one, and built again, pretty sure I had turned off Serial monitor in other window.... Built and no output. I then changed to the Arduino Com7 and built again and output showed up. I went back to Teensy port... Empty. Then rebuilt still empty. Unplugged Teensy, plugged it back in and Serial output worked.
    was trying to duplicate with one IDE Window with a BLE Sketch and a second IDE window running the post 7 test sketch. Both cases they were on Teensy Port Com 10. With Serial Monitor open on both the output shows up in both windows:

    Click image for larger version. 

Name:	Capture.PNG 
Views:	9 
Size:	118.5 KB 
ID:	29877

    I have noticed that unless I put in a delay of about 2500 ms the Seral Monitor doesn't capture the output of the test sketch unless the serial monitor is already open in the IDE:
    Code:
    delay 1500:
    run secs B=5.70
    See Me: 1
    See Me: 2
    See Me: 3
    
    delay 2500:
    D:\Users\Me\Documents\Arduino\sketch_dec4a\sketch_dec4a.ino Dec  5 2022 13:50:23
    run secs A=5.68
    
    D:\Users\Me\Documents\Arduino\sketch_dec4a\sketch_dec4a.ino Dec  5 2022 13:50:23
    run secs B=6.68
    See Me: 1
    See Me: 2
    See Me: 3

  8. #58
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,698
    Luckily tried running before restart with Ctrl+U: Windows wouldn't allow it to execute as unsafe - it didn't say that with the 11/15 update? Didn't work right - - would have had to restart IDE?

    Using POLLED TeensySerMon: Rebooted and slowest reconnect is 1.03 seconds, using Button or Ctrl+U, most about 0.95 seconds reported

    Changed to IDE_SM and allowed EXE restored to the prior fix 11/25 version: 18 second - or NO CONNECT - behavior returned

    Changed to IDE_SM and allowed EXE restored to POLLING_TeensySerialMonitor: Ctrl+U and Button showed sketch start at 0.90 seconds.

    > IDE_SerMon gives about the same ~1 second timing.

    Button Push does result in ALL CORES(real and HT) 100% SPIKE:
    Click image for larger version. 

Name:	PollSpikes.png 
Views:	9 
Size:	160.1 KB 
ID:	29878

  9. #59
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,698
    Quote Originally Posted by mjs513 View Post
    ...
    I have noticed that unless I put in a delay of about 2500 ms the Seral Monitor doesn't capture the output of the test sketch unless the serial monitor is already open in the IDE:
    Code:
    delay 1500:
    run secs B=5.70
    See Me: 1
    See Me: 2
    See Me: 3
    
    delay 2500:
    D:\Users\Me\Documents\Arduino\sketch_dec4a\sketch_dec4a.ino Dec  5 2022 13:50:23
    run secs A=5.68
    
    D:\Users\Me\Documents\Arduino\sketch_dec4a\sketch_dec4a.ino Dec  5 2022 13:50:23
    run secs B=6.68
    See Me: 1
    See Me: 2
    See Me: 3
    I have seen where the first "A=" section is missed (as above) - both with IDE and Teensy Sermon in some instances.

    It is intermittent and not reliably reproducible. Just tried it here starting with Teensy SerMon closed and open after upload and: No Issue - all output captured and displayed.

    For some reason IDE showed sketch output, then posted that 'teensy not available' and showed disconnected a second - then reconnected before the message could be captured. Will Not Repro.

    Also: even with Serial Monitor active and in AutoScroll IDE 2.0.3 is no longer fully autoscrolling? A Button upload advances to "A=" section, but does not scroll to the end after "B=" section? Same happens when USB 'Message' characters sent that Teensy echoes back.
    > Though there seems to be an IDE 2.0.3 change that the Serial Monitor windows is no longer BLANK when switched to, but it is showing and active on the top portion with No Autoscroll?

    There is something in the IDE GUI system it seems where the buffered lines are segmented? Take the mouse and select all and COPY and paste into Notepad - often only a portion of the selection is shown in the Paste.
    Change line 14 in setup() to: showSome( 19 );
    Run (upload) it twice, select all output with Mouse Click Drag and paste and more than half is missing:
    Code:
    See Me: 5
    See Me: 6
    See Me: 7
    See Me: 8
    See Me: 9
    See Me: 10
    See Me: 11
    See Me: 12
    See Me: 13
    See Me: 14
    See Me: 15
    See Me: 16
    See Me: 17
    See Me: 18
    See Me: 19

  10. #60

  11. #61
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    8,538
    Quote Originally Posted by defragster View Post
    .......

    Button Push does result in ALL CORES(real and HT) 100% SPIKE:
    Click image for larger version. 

Name:	PollSpikes.png 
Views:	9 
Size:	160.1 KB 
ID:	29878
    So when you push the reset button on the Teensy you see all cores spiking to 100%? If so I tried that with the test sketch Win10x64, IDE2.0.3, 0.58.2 and didn;t see that,
    Click image for larger version. 

Name:	Capture.PNG 
Views:	10 
Size:	19.9 KB 
ID:	29879

    the last spike is when I hit the button and the sketch ran - cores 4-9 were almost 0 usage.

  12. #62
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,698
    Quote Originally Posted by mjs513 View Post
    So when you push the reset button on the Teensy you see all cores spiking to 100%? If so I tried that with the test sketch Win10x64, IDE2.0.3, 0.58.2 and didn;t see that,
    ...
    the last spike is when I hit the button and the sketch ran - cores 4-9 were almost 0 usage.
    Yes, Windows 11 with 10th Gen i7. Pressed 'Bootloader' Button to upload last HEX file. After Upload completed before Teensy restarted was LOW %, then as it started that spike hit all 8 cores and their imaginary HyperThread part most at near 100% for some 1-2 seconds across USB Chime OUT>IN, then dropped. Repro 6 of 6 times. Same with Ctrl+U where few cores working during the build.

  13. #63
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,375
    Yes when a build completes and upload... There is a pretty good spike:
    Click image for larger version. 

Name:	Screenshot.jpg 
Views:	17 
Size:	58.2 KB 
ID:	29880

    Looks like almost all 20 CPUs

  14. #64
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    8,538
    @KurtE - @defragster

    Redid it using the test sketch and ignored looking at all the cores.

    On a Win10 machine:
    Initial Upload: 68% utilization.
    Button Push: 65-70%
    Click image for larger version. 

Name:	Capture.PNG 
Views:	9 
Size:	31.4 KB 
ID:	29881

  15. #65
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,366
    Quote Originally Posted by defragster View Post
    Also: even with Serial Monitor active and in AutoScroll IDE 2.0.3 is no longer fully autoscrolling?
    Yes, I saw that too. Pretty sure it's Arduino IDE, not anything about Teensy. Looks like auto-scroll which wasn't perfect in 2.0.2 got even worse in 2.0.3.

  16. #66
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,366
    teensy-serialmon.exe has 4 threads, so in a worst case scenario it could tie up only 4 CPU cores. Whatever is hitting all 20 cores is probably from Arduino.

  17. #67
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,698
    Quote Originally Posted by PaulStoffregen View Post
    teensy-serialmon.exe has 4 threads, so in a worst case scenario it could tie up only 4 CPU cores. Whatever is hitting all 20 cores is probably from Arduino.
    That seems to be CORRECT! When IDE SerMon is selected on Port the same Spike happens across all 'logical processors' as shown.

    As for 'Autoscroll' - got feedback question on the update to IDE#1724 that was also 'title changed' - tested and replied there with clear fail of autoscroll - but most times text always shows - at least once IDE SerMon looked blank - but not always like before.

  18. #68
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,366
    On the CPU usage from teensy-serialmon.exe polling, if you just unplug the USB cable while the serial monitor is open and working, it will go into rapid polling mode for 15 seconds. The polling is done by 1 of the 4 threads, so all the polling overhead should appear on 1 core. The other 3 threads are 1: communication with Arduino for managing the session, 2: data from Teensy to Arduino Serial Monitor, and 3: data from Arduino Serial Monitor to Teensy.

  19. #69
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,698
    Indeed, all Logical Procs show spikes on either IDE plug and unplug.
    Also Spikes about +60% with Serial Monitor closed.

    And going to 'Processes' view sorted by CPU% - no SerMon puts IDE just under 10% and with T_SerMon it hits maybe 12%, and 20% with IDE_SerMon - so the rest is the OS.

  20. #70
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,366
    Quote Originally Posted by KurtE View Post
    I was trying out some changes to USBHost on a few different examples. It was working fine on T4.1 with Teensy Serial Com 7. I opened up another one, and built again, pretty sure I had turned off Serial monitor in other window.... Built and no output. I then changed to the Arduino Com7 and built again and output showed up. I went back to Teensy port... Empty. Then rebuilt still empty. Unplugged Teensy, plugged it back in and Serial output worked.
    Might still be more issues to fix. Difficult to say without a way to reproduce the problem.

    I'm going to put the timer code into teensy-discovery.exe too, but only slow polling, so it also doesn't fully depend on Windows WM_DEVICECHANGE messages.

    Planning to package up 1.58-beta3 soon with that and all the recent fixes. Yesterday worked on bringing the new toolchain into the MacOS version, and now I'm trying to restore support for the 3 other Linux platforms (building the toolchain from source takes many hours, especially on Raspberry Pi).

    Hopefully once we're all sync'd up to beta3 a way can be found to reproduce whatever problems remain.

  21. #71
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,366
    Testing teensy-discovery.exe now, and yup, it too is suffering from Windows not delivering WM_DEVICECHANGE, or sending them far too late at times. Still the only case I can reliably reproduce is just having started the IDE, but I'm pretty sure others exist.

    Going to set teensy-discovery.exe timer for 0.667 seconds for 1.58-beta3. On my old laptop that's slow enough that Windows 10 Task Manager shows it as 0% CPU usage. Interesting to see Arduino's serial-discovery.exe is running between 0.2% to 0.5% CPU, and using 8X the memory.

  22. #72
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,366
    I'm pretty sure 1.58-beta3 (0.58.3 in Arduino IDE 2.0.x) fully solved the problems reported on this thread.

    If anyone is still seeing these problems with 1.58-beta3, please let me know? Otherwise I'm going to consider this fully resolved.

Posting Permissions

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