Timeline for Would an infinite loop inside loop() perform faster?
Current License: CC BY-SA 3.0
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 3, 2014 at 16:23 | comment | added | microtherion |
@Cybergibbons, serialEventRun() calls serialEvent() for the various serial ports. By default, all of these are empty procedures, but they can be overridden by the user to do something useful if desired. If you're not overriding it, there's no need to call it.
|
|
| Feb 21, 2014 at 22:42 | vote | accept | Peter Bloomfield | ||
| Feb 21, 2014 at 21:24 | comment | added | Cybergibbons | Yeah, it is part of the main.c as quoted, but I would expect it to be optimised out if not required hence I think aspects of Serial are always included. I frequently write code that will never return from loop() and don't notice issues with Serial. | |
| Feb 21, 2014 at 21:20 | history | edited | Cybergibbons | CC BY-SA 3.0 |
added 657 characters in body
|
| Feb 21, 2014 at 20:07 | comment | added | jfpoilpret |
However HardwareSerial library gets probably included (can someone confirm that?) if you use some arduino functions like Serial.print(). In this situation, what can happen if your loop() loops forever and thus never calls serialEventRun()? I'm afraid Serial may not work in this case.
|
|
| Feb 21, 2014 at 20:04 | comment | added | jfpoilpret |
@Cybergibbons it is never taken out because it is part of standard main.c used by Arduino IDE. However it does not mean that HardwareSerial library is included to your sketch; actually it is not included if you don't use it (that's why there is if (serialEventRun) in main() function. If you don't use HardwareSerial library then serialEventRun will be null, hence no call.
|
|
| Feb 21, 2014 at 19:41 | comment | added | jippie | Would be helpful to briefly explain how you generated the ASM output so people can check themselves. | |
| Feb 21, 2014 at 17:29 | comment | added | Cybergibbons | It's part of the functionality used by HardwareSerial, not sure why it isn't taken out when Serial isn't needed. | |
| Feb 21, 2014 at 17:18 | comment | added | jfpoilpret | OK, but isn't there a reason for calling serialEventRun() function? What is it for? | |
| Feb 21, 2014 at 17:12 | history | undeleted | Cybergibbons | ||
| Feb 21, 2014 at 17:12 | history | edited | Cybergibbons | CC BY-SA 3.0 |
added 1160 characters in body
|
| Feb 21, 2014 at 16:43 | history | deleted | Cybergibbons | via Vote | |
| Feb 21, 2014 at 16:43 | history | answered | Cybergibbons | CC BY-SA 3.0 |