Resources consumed by HardwareSerial even when not actually used
- Dominant language
- Java
- Stars
- 14.6k
- Forks
- 7k
- PR merge metrics
- No merged PRs in 30d
Description
My library contains serial communication function calls referring to HardwareSerial (not included at the level of my library) and when I include my aforementioned library, program memory and global registers related to HardwareSerial are used even though none of the functions in my library which specifically use serial communication are actually used.
Here is part of the .cpp file from my library in question:
```cpp
void MyLibrary::MyFunction(uint32_t value) {
if (Serial.available() > 0) { // this line will direct the compiler to include HardwareSerial and use resources even though MyFunction is not used
}
```
Contributor guide
Research direction
Start with the shown MyLibrary::MyFunction implementation and compare a build that includes the library with one that does not call MyFunction. Inspect the generated program memory and global-register usage around Serial.available() and HardwareSerial. Done means unused serial functionality no longer increases the built sketch's resources.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100