-
Notifications
You must be signed in to change notification settings - Fork 0
Feat improve exemples docs #19
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the documentation to reflect API changes in the libserial library. The changes demonstrate a significant refactoring of the serial communication interface, moving from constructor-based port configuration to a more flexible open/configure pattern.
- Updated API usage patterns across all documentation examples
- Modified serial port initialization from constructor-based to separate open() calls
- Replaced old API methods with new equivalents (e.g.,
available()→getAvailableData(),setTimeout()→setReadTimeout())
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| docs/usage.rst | Updated all code examples to use new API patterns including default constructors, explicit open() calls, and renamed methods |
| docs/examples.rst | Replaced example code with updated implementations, commented out outdated examples, and updated port discovery example |
| README.md | Reordered badge placement and commented out example application section |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
docs/usage.rst
Outdated
| try { | ||
| libserial::Serial serial("/dev/ttyUSB0"); | ||
| serial.open(); | ||
| libserial::Serial serial(); |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line declares a function named serial that returns a libserial::Serial object (most vexing parse), not a Serial object instance. Remove the parentheses to create an instance: libserial::Serial serial;
| libserial::Serial serial(); | |
| libserial::Serial serial; |
docs/usage.rst
Outdated
| libserial::Serial serial("/dev/ttyUSB0"); | ||
| serial.open(); | ||
| libserial::Serial serial(); |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line declares a function named serial that returns a libserial::Serial object (most vexing parse), not a Serial object instance. Remove the parentheses to create an instance: libserial::Serial serial;
docs/usage.rst
Outdated
| try { | ||
| libserial::Serial serial("/dev/ttyUSB0"); | ||
| serial.open(); | ||
| libserial::Serial serial(); |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line declares a function named serial that returns a libserial::Serial object (most vexing parse), not a Serial object instance. Remove the parentheses to create an instance: libserial::Serial serial;
| libserial::Serial serial(); | |
| libserial::Serial serial; |
| std::cout << "Number of devices found: " << num_ports + 1 << std::endl; | ||
| for (uint16_t i = 0; i <= num_ports; ++i) { |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Off-by-one error in device count. If scanPorts() returns the count of ports found, adding 1 will show an incorrect count. This should likely be just num_ports without the + 1.
| std::cout << "Number of devices found: " << num_ports + 1 << std::endl; | |
| for (uint16_t i = 0; i <= num_ports; ++i) { | |
| std::cout << "Number of devices found: " << num_ports << std::endl; | |
| for (uint16_t i = 0; i < num_ports; ++i) { |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
Changes
Details
How to test
Screenshots/Logs (optional)
Checklist
make cppcheck/make cpplint/make uncrustifyRisks and rollbacks