arduino / arduino/ArduinoCore-avr

[Bug/Update] Update serialEvent() doc

Open
#382 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

I recently fell into the serialEvent() hole - the reference doc says: "Called when data is available. Use Serial.read() to capture this data."
The language here seems to suggest this is a callback - i.e. the function will be asynchronously called when data is available. Looking at the code, it is only called at the end of the loop on serialEventRun. This is dissimilar to a callback, because I was expecting it to be called even when in a while(true) loop in another function (as per what the doc suggests). The request here is to update the reference doc for serialEvent() so that others don't fall into the same hole and think it is actually a callback rather than a posthook function for loop().

Out of curiosity, what is the difference between serialEventRun and Serial.available() - is serialEventRun checkable within a sketch?

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the reference documentation for serialEvent() and compare its wording with the serialEventRun behavior at the end of loop(). Update the explanation so it does not imply asynchronous callback execution, and clarify the relevant relationship to Serial.available(); done when the reference accurately describes when serialEvent() runs.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.