This commit is contained in:
2026-02-10 23:59:40 -05:00
parent 33c3ebad53
commit a2d0f1de2e
10 changed files with 105 additions and 2 deletions

12
.clang-format Normal file
View File

@@ -0,0 +1,12 @@
BasedOnStyle: LLVM
IndentWidth: 4
UseTab: Never
ColumnLimit: 100
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
AllowShortBlocksOnASingleLine: Never
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
ReflowComments: false

1
.gitignore vendored
View File

@@ -49,3 +49,4 @@ CMakeCache.txt
/CMakeFiles
/examples/display/build
*.log
/examples/rpc_call/build

View File

@@ -39,7 +39,7 @@ class MyLibraryConan(ConanFile):
def requirements(self):
self.requires("flatbuffers/24.12.23")
self.requires("librpc/1.1.6")
self.requires("librpc/1.1.7")
self.requires("eigen/3.4.1")
self.requires("spdlog/1.16.0")
self.requires("sentry-native/0.12.2")

View File

@@ -2,7 +2,7 @@
libcontrol/1.0.0
flatbuffers/24.12.23
spdlog/1.16.0
librpc/1.1.6
librpc/1.1.7
[generators]
CMakeDeps

View File

@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.15)
project(RpcCallExample)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(libcontrol REQUIRED)
find_package(spdlog REQUIRED)
find_package(librpc REQUIRED)
add_executable(RpcCallExample main.cpp)
target_link_libraries(RpcCallExample
PRIVATE
libcontrol::libcontrol
spdlog::spdlog
librpc::librpc
)

View File

@@ -0,0 +1,9 @@
{
"version": 4,
"vendor": {
"conan": {}
},
"include": [
"build/CMakePresets.json"
]
}

View File

@@ -0,0 +1,10 @@
# RPC Call Example
## Compiling
```
conan install . --build=missing --output-folder=build -s build_type=Release
cmake -S . -B "build" -DCMAKE_TOOLCHAIN_FILE="build/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE="Release"
cmake --build "./build" --config "Release"
./build/RpcCallExample
```

3
examples/rpc_call/build.sh Executable file
View File

@@ -0,0 +1,3 @@
conan install . --build=missing --output-folder=build -s build_type=Release
cmake -S . -B "build" -DCMAKE_TOOLCHAIN_FILE="build/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE="Release"
cmake --build "./build" --config "Release"

View File

@@ -0,0 +1,9 @@
[requires]
libcontrol/1.0.0
flatbuffers/24.12.23
spdlog/1.16.0
librpc/1.1.7
[generators]
CMakeDeps
CMakeToolchain

View File

@@ -0,0 +1,40 @@
#include <chrono>
#include <cstdint>
#include <cstring>
#include <format>
#include <iostream>
#include <thread>
#include <vector>
#include "libcontrol.h"
int main() {
const auto messaging_interface = std::make_unique<MessagingInterface>();
const auto modules =
messaging_interface->find_connected_modules(std::chrono::seconds(3));
std::cout << "Found " << modules.size() << " modules" << std::endl;
for (const auto module : modules) {
std::cout << "Found ID " << (int)module << std::endl;
}
const auto function_tag = 100;
const auto module = 98;
std::string msg = "Hello world!";
std::vector<uint8_t> parameters(msg.begin(), msg.end());
auto maybe_return_value =
messaging_interface->remote_call(function_tag, module, parameters);
if (maybe_return_value) {
auto return_value = std::move(*maybe_return_value);
std::cout << "Got return value " << (char *)return_value->data()
<< std::endl;
} else {
std::cout << "Function call time out" << std::endl;
}
return 0;
}