Skip to content

Proposal to improve upon SerialEvent. #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RobTillaart opened this issue Dec 28, 2012 · 1 comment
Closed

Proposal to improve upon SerialEvent. #248

RobTillaart opened this issue Dec 28, 2012 · 1 comment
Assignees

Comments

@RobTillaart
Copy link

In the 1.x version of Arduino language the SerialEvent() is supported. Although the opinions agree to disagree about the usefulness I would like to propose an improvement on it.

To fire SerialEvent() there is a call in main() that does something like

SerialEventRun()
{
if (Serial.Available()) SerialEvent();
}

for a Mega this is done for every port.

I would like to propose to pass the number of bytes seen by available() as a parameter to SerialEvent() as then the latter does not need to call the available function keeping the eventhandling shorter.

SerialEventRun()
{
int count = Serial.Available();
if (count) SerialEvent(count);
}

of course the Mega does this four times reusing the var count.

The programmer implementing SerialEvent(int count) can use count and does not need to call available(). Which removes one function call per serialEvent, might add up.

A more elaborated discussion can be found on the forum:

Regards,
Rob

@sandeepmistry sandeepmistry transferred this issue from arduino/Arduino Sep 16, 2019
@RobTillaart
Copy link
Author

too old to be relevant anymore

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

No branches or pull requests

2 participants