-
Notifications
You must be signed in to change notification settings - Fork 0
Add module function definitions #8
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
Open
MarioIvancik
wants to merge
4
commits into
master
Choose a base branch
from
BAF-1155/add_module_function_definitions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| FIND_PACKAGE(CMLIB REQUIRED COMPONENTS CMCONF) | ||
|
|
||
| CMCONF_INIT_SYSTEM(FLEET_PROTOCOL) | ||
|
|
||
| SET(STORAGE_LIST DEP) | ||
|
|
||
| SET(STORAGE_LIST_DEP "https://github.com/bacpack-system/package-tracker.git") |
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
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
105 changes: 105 additions & 0 deletions
105
include/bringauto/fleet_protocol/cxx/AsyncModuleFunctionDefinitions.hpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| #pragma once | ||
|
|
||
| #include <bringauto/fleet_protocol/cxx/ConvertibleBuffer.hpp> | ||
| #include <bringauto/fleet_protocol/cxx/ConvertibleBufferReturn.hpp> | ||
|
|
||
| #include <bringauto/async_function_execution/AsyncFunctionExecutor.hpp> | ||
|
|
||
|
|
||
| namespace bringauto::fleet_protocol::cxx { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please move it to different namesapace. not cx. |
||
|
|
||
| inline static const async_function_execution::FunctionDefinition getModuleNumberAsync { | ||
| async_function_execution::FunctionId { 0 }, | ||
| async_function_execution::Return { int {} }, | ||
| async_function_execution::Arguments {} | ||
| }; | ||
|
|
||
| inline static const async_function_execution::FunctionDefinition isDeviceTypeSupportedAsync { | ||
| async_function_execution::FunctionId { 1 }, | ||
| async_function_execution::Return { int {} }, | ||
| async_function_execution::Arguments { uint32_t {} } | ||
| }; | ||
|
|
||
| inline static const async_function_execution::FunctionDefinition sendStatusConditionAsync { | ||
| async_function_execution::FunctionId { 2 }, | ||
| async_function_execution::Return { int {} }, | ||
| async_function_execution::Arguments { ConvertibleBuffer {}, ConvertibleBuffer {}, uint32_t {} } | ||
| }; | ||
|
|
||
| inline static const async_function_execution::FunctionDefinition generateCommandAsync { | ||
| async_function_execution::FunctionId { 3 }, | ||
| async_function_execution::Return { ConvertibleBufferReturn {} }, | ||
| async_function_execution::Arguments { ConvertibleBuffer {}, ConvertibleBuffer {}, ConvertibleBuffer {}, uint32_t {} } | ||
| }; | ||
|
|
||
| inline static const async_function_execution::FunctionDefinition aggregateStatusAsync { | ||
| async_function_execution::FunctionId { 4 }, | ||
| async_function_execution::Return { ConvertibleBufferReturn {} }, | ||
| async_function_execution::Arguments { ConvertibleBuffer {}, ConvertibleBuffer {}, uint32_t {} } | ||
| }; | ||
|
|
||
| inline static const async_function_execution::FunctionDefinition aggregateErrorAsync { | ||
| async_function_execution::FunctionId { 5 }, | ||
| async_function_execution::Return { ConvertibleBufferReturn {} }, | ||
| async_function_execution::Arguments { ConvertibleBuffer {}, ConvertibleBuffer {}, uint32_t {} } | ||
| }; | ||
|
|
||
| inline static const async_function_execution::FunctionDefinition generateFirstCommandAsync { | ||
| async_function_execution::FunctionId { 6 }, | ||
| async_function_execution::Return { ConvertibleBufferReturn {} }, | ||
| async_function_execution::Arguments { uint32_t {} } | ||
| }; | ||
|
|
||
| inline static const async_function_execution::FunctionDefinition statusDataValidAsync { | ||
| async_function_execution::FunctionId { 7 }, | ||
| async_function_execution::Return { int {} }, | ||
| async_function_execution::Arguments { ConvertibleBuffer {}, uint32_t {} } | ||
| }; | ||
|
|
||
| inline static const async_function_execution::FunctionDefinition commandDataValidAsync { | ||
| async_function_execution::FunctionId { 8 }, | ||
| async_function_execution::Return { int {} }, | ||
| async_function_execution::Arguments { ConvertibleBuffer {}, uint32_t {} } | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Type alias for an AsyncFunctionExecutor specialized with module-related functions. | ||
| */ | ||
| using ModuleFunctionExecutor = async_function_execution::AsyncFunctionExecutor< | ||
| decltype(getModuleNumberAsync), | ||
| decltype(isDeviceTypeSupportedAsync), | ||
| decltype(sendStatusConditionAsync), | ||
| decltype(generateCommandAsync), | ||
| decltype(aggregateStatusAsync), | ||
| decltype(aggregateErrorAsync), | ||
| decltype(generateFirstCommandAsync), | ||
| decltype(statusDataValidAsync), | ||
| decltype(commandDataValidAsync) | ||
| >; | ||
|
|
||
| /** | ||
| * @brief FunctionList containing all module-related function definitions. | ||
| */ | ||
| inline static const async_function_execution::FunctionList< | ||
| decltype(getModuleNumberAsync), | ||
| decltype(isDeviceTypeSupportedAsync), | ||
| decltype(sendStatusConditionAsync), | ||
| decltype(generateCommandAsync), | ||
| decltype(aggregateStatusAsync), | ||
| decltype(aggregateErrorAsync), | ||
| decltype(generateFirstCommandAsync), | ||
| decltype(statusDataValidAsync), | ||
| decltype(commandDataValidAsync) | ||
| > moduleFunctionList { | ||
| getModuleNumberAsync, | ||
| isDeviceTypeSupportedAsync, | ||
| sendStatusConditionAsync, | ||
| generateCommandAsync, | ||
| aggregateStatusAsync, | ||
| aggregateErrorAsync, | ||
| generateFirstCommandAsync, | ||
| statusDataValidAsync, | ||
| commandDataValidAsync | ||
| }; | ||
|
|
||
| } | ||
32 changes: 32 additions & 0 deletions
32
include/bringauto/fleet_protocol/cxx/ConvertibleBuffer.hpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #pragma once | ||
|
|
||
| #include <fleet_protocol/common_headers/device_management.h> | ||
|
|
||
| #include <cstdint> | ||
| #include <span> | ||
|
|
||
|
|
||
|
|
||
| namespace bringauto::fleet_protocol::cxx { | ||
|
|
||
| /** | ||
| * @brief ConvertibleBuffer is a helper class to convert a fleet_protocol 'buffer' struct | ||
| * to/from a byte span for serialization/deserialization. | ||
| */ | ||
| struct ConvertibleBuffer final { | ||
| struct ::buffer buffer {}; | ||
| ConvertibleBuffer() = default; | ||
| ConvertibleBuffer(struct ::buffer buff) : buffer(buff) {} | ||
|
|
||
| std::span<const uint8_t> serialize() const { | ||
| return std::span {reinterpret_cast<const uint8_t *>(buffer.data), buffer.size_in_bytes}; | ||
| } | ||
| void deserialize(std::span<const uint8_t> bytes) { | ||
| auto size = bytes.size(); | ||
| buffer.data = new uint8_t[size]; | ||
| buffer.size_in_bytes = size; | ||
| std::memcpy(buffer.data, bytes.data(), size); | ||
| } | ||
| }; | ||
|
|
||
| } |
42 changes: 42 additions & 0 deletions
42
include/bringauto/fleet_protocol/cxx/ConvertibleBufferReturn.hpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #pragma once | ||
|
|
||
| #include <fleet_protocol/common_headers/device_management.h> | ||
|
|
||
| #include <cstdint> | ||
| #include <cstring> | ||
| #include <span> | ||
|
|
||
|
|
||
|
|
||
| namespace bringauto::fleet_protocol::cxx { | ||
|
|
||
| /** | ||
| * @brief ConvertibleBufferReturn is a helper class to convert a fleet_protocol 'buffer' struct | ||
| * and a return code to/from a byte span for serialization/deserialization. | ||
| * The first 4 bytes represent the return code (int), followed by the buffer data. | ||
| */ | ||
| struct ConvertibleBufferReturn final { | ||
| int returnCode {}; | ||
| struct ::buffer buffer {}; | ||
| ConvertibleBufferReturn() = default; | ||
| ConvertibleBufferReturn(int code, struct ::buffer buff) : returnCode(code), buffer(buff) {} | ||
|
|
||
| std::span<const uint8_t> serialize() const { | ||
| size_t total_size = sizeof(int) + buffer.size_in_bytes; | ||
| uint8_t* data = new uint8_t[total_size]; | ||
| std::memcpy(data, &returnCode, sizeof(int)); | ||
| std::memcpy(data + sizeof(int), buffer.data, buffer.size_in_bytes); | ||
| return {data, total_size}; | ||
| } | ||
| void deserialize(std::span<const uint8_t> bytes) { | ||
| auto size = bytes.size(); | ||
| if (size < sizeof(int)) return; | ||
| std::memcpy(&returnCode, bytes.data(), sizeof(int)); | ||
| size -= sizeof(int); | ||
| buffer.data = new uint8_t[size]; | ||
| buffer.size_in_bytes = size; | ||
| std::memcpy(buffer.data, bytes.data() + sizeof(int), size); | ||
| } | ||
| }; | ||
|
|
||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #include <bringauto/fleet_protocol/cxx/AsyncModuleFunctionDefinitions.hpp> | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| using namespace bringauto::fleet_protocol::cxx; | ||
|
|
||
|
|
||
| TEST(AsyncModuleFunctionDefinitions_tests, FunctionDefinitionsExist) { | ||
| EXPECT_EQ(getModuleNumberAsync.id.value, 0); | ||
| EXPECT_EQ(isDeviceTypeSupportedAsync.id.value, 1); | ||
| EXPECT_EQ(sendStatusConditionAsync.id.value, 2); | ||
| EXPECT_EQ(generateCommandAsync.id.value, 3); | ||
| EXPECT_EQ(aggregateStatusAsync.id.value, 4); | ||
| EXPECT_EQ(aggregateErrorAsync.id.value, 5); | ||
| EXPECT_EQ(generateFirstCommandAsync.id.value, 6); | ||
| EXPECT_EQ(statusDataValidAsync.id.value, 7); | ||
| EXPECT_EQ(commandDataValidAsync.id.value, 8); | ||
| } |
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.
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.
🧩 Analysis chain
Ensure BA package names match the CMake
find_packageusageAdding
aeron v1.48.6andasync-function-execution v1.0.0here looks consistent with the PR description, but please confirm that:aeron,async-function-execution) correspond to the actual package IDs in your package tracker.find_package(e.g.,async-function-execution-sharedin CMakeLists, if that’s what you use), so CMLIB resolves the same artifact.You can grep for how these libraries are consumed:
🏁 Script executed:
Length of output: 392
Fix package name mismatch for async-function-execution-shared
The verification reveals a critical inconsistency:
cmake/Dependencies.cmake:4definesBA_PACKAGE_LIBRARY(async-function-execution v1.0.0), butCMakeLists.txt:44callsFIND_PACKAGE(async-function-execution-shared 1.0.0 REQUIRED).The BA package name must match what
find_packageresolves. Change line 4 incmake/Dependencies.cmakefromasync-function-executiontoasync-function-execution-shared. The aeron entry (line 3) is correctly named.🤖 Prompt for AI Agents