You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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
The text was updated successfully, but these errors were encountered: