Skip to content

while (Monitor.read() != -1) {} hangs#51

Merged
eigen-value merged 1 commit intoarduino-libraries:mainfrom
KurtE:read_ret_m1
Feb 3, 2026
Merged

while (Monitor.read() != -1) {} hangs#51
eigen-value merged 1 commit intoarduino-libraries:mainfrom
KurtE:read_ret_m1

Conversation

@KurtE
Copy link
Copy Markdown
Contributor

@KurtE KurtE commented Jan 28, 2026

As I mentioned in the ArduinoCore-zephyr issues:
arduino/ArduinoCore-zephyr#320

A sketch that does that will hang as Monitor.read() when the queue is empty returns 0 not -1, as specified in the Stream class

https://docs.arduino.cc/language-reference/en/functions/communication/stream/streamRead/

As I mentioned in the ArduinoCore-zephyr issues:
arduino/ArduinoCore-zephyr#320

A sketch that does that will hang as Monitor.read()  when the queue is empty
returns 0 not -1, as specified in the Stream class

https://docs.arduino.cc/language-reference/en/functions/communication/stream/streamRead/
@github-actions
Copy link
Copy Markdown

Memory usage change @ 316e042

Board flash % RAM for global variables %
arduino:zephyr:unoq 🔺 +8 - +16 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/client
flash
% examples/client
RAM for global variables
% examples/clientSSL
flash
% examples/clientSSL
RAM for global variables
% examples/hci
flash
% examples/hci
RAM for global variables
% examples/monitor
flash
% examples/monitor
RAM for global variables
% examples/server
flash
% examples/server
RAM for global variables
% examples/simple_bridge
flash
% examples/simple_bridge
RAM for global variables
% examples/test
flash
% examples/test
RAM for global variables
% examples/test_rpc_thread
flash
% examples/test_rpc_thread
RAM for global variables
% examples/udp_ntp_client
flash
% examples/udp_ntp_client
RAM for global variables
%
arduino:zephyr:unoq 8 0.0 0 0.0 16 0.0 0 0.0 8 0.0 0 0.0 8 0.0 0 0.0 16 0.0 0 0.0 8 0.0 0 0.0 8 0.0 0 0.0 8 0.0 0 0.0 8 0.0 0 0.0
Click for full report CSV
Board,examples/client<br>flash,%,examples/client<br>RAM for global variables,%,examples/clientSSL<br>flash,%,examples/clientSSL<br>RAM for global variables,%,examples/hci<br>flash,%,examples/hci<br>RAM for global variables,%,examples/monitor<br>flash,%,examples/monitor<br>RAM for global variables,%,examples/server<br>flash,%,examples/server<br>RAM for global variables,%,examples/simple_bridge<br>flash,%,examples/simple_bridge<br>RAM for global variables,%,examples/test<br>flash,%,examples/test<br>RAM for global variables,%,examples/test_rpc_thread<br>flash,%,examples/test_rpc_thread<br>RAM for global variables,%,examples/udp_ntp_client<br>flash,%,examples/udp_ntp_client<br>RAM for global variables,%
arduino:zephyr:unoq,8,0.0,0,0.0,16,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,16,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0,8,0.0,0,0.0

@eigen-value eigen-value self-requested a review January 31, 2026 15:21
Copy link
Copy Markdown
Collaborator

@eigen-value eigen-value left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KurtE Thank you for spotting it!
The fix LGTM

@eigen-value eigen-value merged commit 7f28f3e into arduino-libraries:main Feb 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants