Sensor data implementation

This commit is contained in:
2026-01-15 01:24:57 -05:00
parent 550d0643e7
commit 2688ed1290
10 changed files with 218 additions and 125 deletions

View File

@@ -19,14 +19,14 @@
[[noreturn]] void LoopManager::control_loop() const {
uint8_t buffer[512];
while (true) {
m_messaging_interface->recv(reinterpret_cast<char *>(buffer), 512, PC_ADDR, ACTUATOR_CMD_TAG);
m_messaging_interface->recv(reinterpret_cast<char *>(buffer), 512, PC_ADDR,
ACTUATOR_CMD_TAG);
m_actuator->actuate(buffer);
send_sensor_reading(false);
}
}
[[noreturn]] void LoopManager::sensor_loop(char * args) {
[[noreturn]] void LoopManager::sensor_loop(char *args) {
const auto that = reinterpret_cast<LoopManager *>(args);
while (true) {
@@ -35,12 +35,14 @@
}
}
[[noreturn]] void LoopManager::metadata_tx_loop(char * args) {
[[noreturn]] void LoopManager::metadata_tx_loop(char *args) {
const auto that = reinterpret_cast<LoopManager *>(args);
const auto topology_message_builder = std::make_unique<Flatbuffers::TopologyMessageBuilder>();
while (true) {
const auto [module_ids, orientations] = that->m_messaging_interface->get_physically_connected_modules();
// todo: this is awful, we can't cast from a vector of orientation to int.... :(
const auto [module_ids, orientations] =
that->m_messaging_interface->get_physically_connected_modules();
// todo: this is awful, we can't cast from a vector of orientation to
// int.... :(
std::vector<int8_t> casted_orientations{};
casted_orientations.reserve(orientations.size());
for (const auto orientation : orientations) {
@@ -48,13 +50,11 @@
}
const auto [data, size] = topology_message_builder->build_topology_message(
that->m_config_manager.get_module_id(),
that->m_config_manager.get_module_type(),
module_ids,
casted_orientations,
that->m_messaging_interface->get_connection_type(),
that->m_config_manager.get_module_id(), that->m_config_manager.get_module_type(),
module_ids, casted_orientations, that->m_messaging_interface->get_connection_type(),
that->m_messaging_interface->get_leader());
that->m_messaging_interface->send(static_cast<char *>(data), size, PC_ADDR, TOPOLOGY_CMD_TAG, false);
that->m_messaging_interface->send(static_cast<char *>(data), size, PC_ADDR,
TOPOLOGY_CMD_TAG, false);
vTaskDelay(METADATA_PERIOD_MS / portTICK_PERIOD_MS);
}
}