-
Notifications
You must be signed in to change notification settings - Fork 0
Advanced features #2
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
…ADME, CI, and examples
… updating example and tests accordingly
… collecting USB device information and updating the callback mechanism; remove redundant implementation from serial.cpp
…o examples, and usage guidelines
… enable position-independent code, link libraries statically, and update build steps in CI to use a container image.
…ng installation and build steps into a single command for improved efficiency.
…container for enhanced build capabilities.
…ontainer for improved build compatibility.
c36c1e2 to
bb2e1ce
Compare
…and error handling; remove legacy serial and status_codes headers, and adjust CMake configuration to link cpp_core for improved modularity.
…criptions, error handling examples, and new convenience functions for serial communication, enhancing clarity and usability for developers.
| name: libcpp_unix_bindings | ||
| path: build/libcpp_unix_bindings.so |
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.
| name: libcpp_unix_bindings | |
| path: build/libcpp_unix_bindings.so | |
| name: bindings_linux | |
| path: build/bindings_linux.so |
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| files: build/libCPP-Unix-Bindings.so | ||
| files: build/libcpp_unix_bindings.so |
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.
| files: build/libcpp_unix_bindings.so | |
| files: build/bindings_linux.so |
CMakeLists.txt
Outdated
| set(VERSION_PATCH 0) | ||
|
|
||
| set(PROJECT_N CPP-Unix-Bindings) | ||
| set(PROJECT_N cpp_unix_bindings) |
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.
| set(PROJECT_N cpp_unix_bindings) | |
| set(PROJECT_N cpp_bindings_linux) |
| @@ -1,7 +1,7 @@ | |||
| # CPP-Unix-Bindings | |||
| # cpp_unix_bindings | |||
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.
| # cpp_unix_bindings | |
| # C++ Bindings Linux |
|
|
||
| A compact C++23 library for talking to serial devices on Linux (e.g. Arduino). | ||
| The project builds a **shared library `libCPP-Unix-Bindings.so`** that can be used via | ||
| The project builds a **shared library `libcpp_unix_bindings.so`** that can be used via |
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.
| The project builds a **shared library `libcpp_unix_bindings.so`** that can be used via | |
| The project builds a **shared library `bindings_linux.so`** that can be used via |
|
|
||
| # The resulting library will be located at | ||
| # build/libCPP-Unix-Bindings.so | ||
| # build/libcpp_unix_bindings.so |
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.
| # build/libcpp_unix_bindings.so | |
| # build/bindings_linux.so |
| ```ts | ||
| // serial_deno.ts | ||
| const lib = Deno.dlopen('./build/libCPP-Unix-Bindings.so', { | ||
| const lib = Deno.dlopen('./build/libcpp_unix_bindings.so', { |
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.
| const lib = Deno.dlopen('./build/libcpp_unix_bindings.so', { | |
| const lib = Deno.dlopen('./build/bindings_linux.so', { |
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.
all libs under linux are prefixed with a lib, would not go against the default here
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.
go under /usr/lib or /usr/lib64 in any linux distro and show me one lib that has not the prefix lib and is not built by you.
…dular functions for serial communication, including read, write, and buffer management. Update CMake configuration to exclude serial.cpp and enhance project structure for improved maintainability.
…m 'function' to 'callback_fn' for improved clarity and consistency in naming conventions.
Introduce std::lock_guard to ensure thread-safe access to shared resources in serial communication functions, including buffer management and read/write operations. This change enhances the robustness of the API by preventing data races during concurrent access.
- Simplified CMakeLists.txt by removing redundant versioning variables and consolidating project setup. - Updated project to use C++23 standard and improved dependency management with CPM. - Introduced new source file `serial_list_ports.cpp` for enhanced USB port information retrieval. - Renamed `serialGetPortsInfo` to `serialListPorts` for clarity and consistency in the API. - Adjusted unit tests to reflect the new function name and ensure proper functionality.
- Updated function signatures across multiple serial API functions to improve clarity by aligning parameter formatting and spacing. - Enhanced error handling messages for better debugging and consistency in reporting invalid handles. - Adjusted unit tests to reflect changes in function signatures and maintain code quality.
…readability - Updated function signatures across multiple serial API functions to use 'auto' return type and improved parameter formatting. - Replaced std::lock_guard with std::scoped_lock for better mutex management. - Enhanced error handling messages for clarity and consistency in reporting invalid handles.
|
|
||
| set(PROJECT_N cpp_unix_bindings) | ||
| project(${PROJECT_N} VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) | ||
| project(cpp_unix_bindings VERSION 1.0.0 LANGUAGES CXX) |
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.
| project(cpp_unix_bindings VERSION 1.0.0 LANGUAGES CXX) | |
| project( | |
| cpp-bindings-linux | |
| VERSION 1.0.0 | |
| DESCRIPTION "C++ Linux Bindings for the serial library" | |
| LANGUAGES CXX | |
| ) |
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.
Also you should think about adding a VERSION variable.
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.
yes, got something cooking for that right here https://github.com/Katze719/cmake-git-versioning
| "GTEST_BUILD_TESTS OFF" | ||
| "GTEST_BUILD_EXAMPLES OFF" | ||
| "GTEST_BUILD_DOCS OFF" |
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.
| "GTEST_BUILD_TESTS OFF" | |
| "GTEST_BUILD_EXAMPLES OFF" | |
| "GTEST_BUILD_DOCS OFF" | |
| "GTEST_BUILD_TESTS OFF" | |
| "GTEST_BUILD_EXAMPLES OFF" | |
| "GTEST_BUILD_DOCS OFF" |
| set_target_properties(${PROJECT_NAME} PROPERTIES | ||
| VERSION ${PROJECT_VERSION} | ||
| SOVERSION ${PROJECT_VERSION_MAJOR} | ||
| ) |
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.
| set_target_properties(${PROJECT_NAME} PROPERTIES | |
| VERSION ${PROJECT_VERSION} | |
| SOVERSION ${PROJECT_VERSION_MAJOR} | |
| ) | |
| set_target_properties( | |
| ${PROJECT_NAME} | |
| PROPERTIES | |
| VERSION ${PROJECT_VERSION} | |
| SOVERSION ${PROJECT_VERSION_MAJOR} | |
| ) |
| ) | ||
|
|
||
| # Test executable | ||
| add_executable(tests |
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.
| add_executable(tests | |
| add_executable( | |
| tests |
| target_include_directories(tests PRIVATE ${PROJECT_SOURCE_DIR}/src) | ||
|
|
||
| # Copy shared library next to test binary | ||
| add_custom_command(TARGET tests POST_BUILD |
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.
| add_custom_command(TARGET tests POST_BUILD | |
| add_custom_command( | |
| TARGET tests POST_BUILD |
| COMMENT "Copy shared library next to aggregated test binary") | ||
| $<TARGET_FILE:${PROJECT_NAME}> | ||
| $<TARGET_FILE_DIR:tests> | ||
| COMMENT "Copy shared library next to test binary" |
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.
What is this comment?
src/serial_list_ports.cpp
Outdated
| extern "C" int serialListPorts(void (*callback_fn)(const char* port, | ||
| const char* path, | ||
| const char* manufacturer, | ||
| const char* serialNumber, | ||
| const char* pnpId, | ||
| const char* locationId, | ||
| const char* productId, | ||
| const char* vendorId), | ||
| ErrorCallbackT error_callback) |
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.
Why is this formatting still so f*ked up?
| extern "C" int serialListPorts(void (*callback_fn)(const char* port, | |
| const char* path, | |
| const char* manufacturer, | |
| const char* serialNumber, | |
| const char* pnpId, | |
| const char* locationId, | |
| const char* productId, | |
| const char* vendorId), | |
| ErrorCallbackT error_callback) | |
| extern "C" int serialListPorts( | |
| void (*callback_fn)( | |
| const char* port, | |
| const char* path, | |
| const char* manufacturer, | |
| const char* serialNumber, | |
| const char* pnpId, | |
| const char* locationId, | |
| const char* productId, | |
| const char* vendorId | |
| ), | |
| ErrorCallbackT error_callback | |
| ) |
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 is technically just one long type
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.
will replace it with a using
|
Please fix the formatting like it was before. |
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.
Vibe coded and generated as f*ck bro 😅 No one would use … as ... in a description like that 😂
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.
Also you can remove this example, since documenting this is my job 👍 You can also remove the whole TypeScript examples folder.
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.
Remove
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.
Remove
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.
Remove
|
|
||
| #include <cpp_core/interface/serial_set_error_callback.h> | ||
|
|
||
| extern "C" void serialSetErrorCallback(ErrorCallbackT error_callback) |
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.
Not sure if this function is still usefull, if we have an error callback function that we pass to each function individually.
|
|
||
| #include <cpp_core/interface/serial_set_read_callback.h> | ||
|
|
||
| extern "C" void serialSetReadCallback(void (*callback_fn)(int)) |
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.
Same here. I am not sure if this function is usefull at all.
|
|
||
| #include <cpp_core/interface/serial_set_write_callback.h> | ||
|
|
||
| extern "C" void serialSetWriteCallback(void (*callback_fn)(int)) |
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.
Same here. I am not sure if this function is usefull at all.
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.
Why is this its own file, but the rest is crammed into one internal file (serial_internal.hpp) above?
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.
Please refactor to individual unit test files next to the actual files.
Ex. File to test: serial_read.cpp, Unit test file next to it: serial_read.test.cpp
I know, for archiving this we(you) need to change the CMake again, but please do it that way. Adding/Changing/Removing indivitual tests that way is much easier and more clearer in terms of what you are doing/testing.
No description provided.