Implement serial communication functions and refactor existing code#19
Open
Katze719 wants to merge 9 commits into
Open
Implement serial communication functions and refactor existing code#19Katze719 wants to merge 9 commits into
Katze719 wants to merge 9 commits into
Conversation
- Added new functions for serial communication including: - `serialOutBytesTotal` - `serialOutBytesWaiting` - `serialReadLine` - `serialReadUntil` - `serialReadUntilSequence` - `serialSendBreak` - `serialSetBaudrate` - `serialSetDataBits` - `serialSetDtr` - `serialSetFlowControl` - `serialSetParity` - `serialSetReadCallback` - `serialSetRts` - `serialSetStopBits` - `serialSetWriteCallback` - Refactored `serialRead` and `serialWrite` functions to use a common implementation (`readImpl` and `writeImpl`). - Updated error handling to use new status code definitions. - Modified unit tests to reflect changes in error codes and added new tests for the newly implemented functions. - Ensured consistent naming and usage of status codes across the codebase.
…rove Arduino test suite
…ub Actions for unreliable serial endpoints
Mqxx
requested changes
Jun 26, 2026
| uses: './.github/workflows/test_unit_cpp.yml' | ||
| with: | ||
| artifact-name: cpp_bindings_linux_tests | ||
| artifact-name: libcpp_bindings_linux |
Member
There was a problem hiding this comment.
Why the change? Isn't this just the test file?
Mqxx
requested changes
Jun 26, 2026
Member
There was a problem hiding this comment.
This file is WAY to long! please refactor into separate helper files. And also please try to organize them accordingly.
| inline auto acquireHandleContext(int64_t handle, ErrorCallbackT error_callback, HandleContext *out_context) -> Ret | ||
| { | ||
| int fd = -1; | ||
| const auto rc = validatePosixFd<Ret>(handle, error_callback, &fd); |
Member
There was a problem hiding this comment.
Please use proper variables names. Not just 2 letters...
| MODULE_API auto serialAbortRead(int64_t handle, ErrorCallbackT error_callback) -> int | ||
| { | ||
| cpp_bindings_linux::detail::HandleContext context; | ||
| const auto rc = cpp_bindings_linux::detail::acquireHandleContext<int>(handle, error_callback, &context); |
| MODULE_API auto serialAbortWrite(int64_t handle, ErrorCallbackT error_callback) -> int | ||
| { | ||
| cpp_bindings_linux::detail::HandleContext context; | ||
| const auto rc = cpp_bindings_linux::detail::acquireHandleContext<int>(handle, error_callback, &context); |
| MODULE_API auto serialClearBufferIn(int64_t handle, ErrorCallbackT error_callback) -> int | ||
| { | ||
| cpp_bindings_linux::detail::HandleContext context; | ||
| const auto rc = cpp_bindings_linux::detail::acquireHandleContext<int>(handle, error_callback, &context); |
| MODULE_API auto serialSetDtr(int64_t handle, int state, ErrorCallbackT error_callback) -> int | ||
| { | ||
| cpp_bindings_linux::detail::HandleContext context; | ||
| const auto rc = cpp_bindings_linux::detail::acquireHandleContext<int>(handle, error_callback, &context); |
| MODULE_API auto serialSetFlowControl(int64_t handle, int mode, ErrorCallbackT error_callback) -> int | ||
| { | ||
| cpp_bindings_linux::detail::HandleContext context; | ||
| const auto rc = cpp_bindings_linux::detail::acquireHandleContext<int>(handle, error_callback, &context); |
| MODULE_API auto serialSetParity(int64_t handle, int parity, ErrorCallbackT error_callback) -> int | ||
| { | ||
| cpp_bindings_linux::detail::HandleContext context; | ||
| const auto rc = cpp_bindings_linux::detail::acquireHandleContext<int>(handle, error_callback, &context); |
| MODULE_API auto serialSetRts(int64_t handle, int state, ErrorCallbackT error_callback) -> int | ||
| { | ||
| cpp_bindings_linux::detail::HandleContext context; | ||
| const auto rc = cpp_bindings_linux::detail::acquireHandleContext<int>(handle, error_callback, &context); |
| MODULE_API auto serialSetStopBits(int64_t handle, int stop_bits, ErrorCallbackT error_callback) -> int | ||
| { | ||
| cpp_bindings_linux::detail::HandleContext context; | ||
| const auto rc = cpp_bindings_linux::detail::acquireHandleContext<int>(handle, error_callback, &context); |
Mqxx
requested changes
Jun 30, 2026
| } | ||
| } | ||
|
|
||
| template <typename Ret> |
Member
There was a problem hiding this comment.
What is Ret? I assume ReturnType? Or something else? Please choose a respective type name. Please also check for this in all other files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added new functions for serial communication including:
serialOutBytesTotalserialOutBytesWaitingserialReadLineserialReadUntilserialReadUntilSequenceserialSendBreakserialSetBaudrateserialSetDataBitsserialSetDtrserialSetFlowControlserialSetParityserialSetReadCallbackserialSetRtsserialSetStopBitsserialSetWriteCallbackRefactored
serialReadandserialWritefunctions to use a common implementation (readImplandwriteImpl).Updated error handling to use new status code definitions.
Modified unit tests to reflect changes in error codes and added new tests for the newly implemented functions.
Ensured consistent naming and usage of status codes across the codebase.