diff --git a/glinx-core/CMakeLists.txt b/glinx-core/CMakeLists.txt index b613402..7cda88c 100644 --- a/glinx-core/CMakeLists.txt +++ b/glinx-core/CMakeLists.txt @@ -4,6 +4,7 @@ project(glinx-core VERSION 0.1.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Compiler flags for performance if(MSVC) diff --git a/glinx-core/benchmarks/throughput_bench.cpp b/glinx-core/benchmarks/throughput_bench.cpp index 7d94f03..475e34f 100644 --- a/glinx-core/benchmarks/throughput_bench.cpp +++ b/glinx-core/benchmarks/throughput_bench.cpp @@ -17,7 +17,9 @@ void producer(SensorBuffer* buffer, size_t messages_per_sec) { std::strncpy(msg.protocol, "i2c", sizeof(msg.protocol) - 1); msg.payload_size = 12; // 3 x 4-byte floats - auto interval = duration(1.0 / messages_per_sec); + auto interval = duration_cast( + duration(1.0 / messages_per_sec) + ); auto next_send = high_resolution_clock::now(); while (running.load()) { @@ -95,10 +97,10 @@ int main(int argc, char* argv[]) { std::cout << "Buffer efficiency: " << ((total_consumed / static_cast(total_produced)) * 100.0) << "%\n"; std::cout << "\n=== Performance Targets ===\n"; - std::cout << "Target: 10,000 msgs/sec sustained\n"; + std::cout << "Target: " << target_rate << " msgs/sec sustained\n"; std::cout << "Actual: " << actual_rate << " msgs/sec "; - if (actual_rate >= 10000 && loss_rate < 1.0) { + if (actual_rate >= (target_rate * 0.95) && loss_rate < 1.0) { std::cout << "✓ PASS\n"; return 0; } else { diff --git a/glinx-core/bindings/python.cpp b/glinx-core/bindings/python.cpp index 3782926..f12e262 100644 --- a/glinx-core/bindings/python.cpp +++ b/glinx-core/bindings/python.cpp @@ -14,8 +14,22 @@ NB_MODULE(_glinx_core, m) { // SensorMessage nb::class_(m, "SensorMessage") .def(nb::init<>()) - .def_rw("source_id", &SensorMessage::source_id) - .def_rw("protocol", &SensorMessage::protocol) + .def_prop_rw("source_id", + [](const SensorMessage& self) { + return std::string(self.source_id); + }, + [](SensorMessage& self, const std::string& value) { + std::memset(self.source_id, 0, sizeof(self.source_id)); + std::strncpy(self.source_id, value.c_str(), sizeof(self.source_id) - 1); + }) + .def_prop_rw("protocol", + [](const SensorMessage& self) { + return std::string(self.protocol); + }, + [](SensorMessage& self, const std::string& value) { + std::memset(self.protocol, 0, sizeof(self.protocol)); + std::strncpy(self.protocol, value.c_str(), sizeof(self.protocol) - 1); + }) .def_rw("timestamp", &SensorMessage::timestamp) .def_rw("payload_size", &SensorMessage::payload_size) .def_prop_rw("payload", diff --git a/glinx-core/include/glinx/ipc.hpp b/glinx-core/include/glinx/ipc.hpp index 3dcdbb5..50a4560 100644 --- a/glinx-core/include/glinx/ipc.hpp +++ b/glinx-core/include/glinx/ipc.hpp @@ -1,6 +1,7 @@ #pragma once #include "buffer.hpp" +#include "driver.hpp" #include #include