From 3dae4b5b9077119dc55c69b31528d63865d05b29 Mon Sep 17 00:00:00 2001 From: mario Date: Thu, 11 Apr 2024 16:16:26 +0200 Subject: [PATCH] dont parse old commands --- CMakeLists.txt | 2 +- source/external_server_api.cpp | 39 ++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d8babc..4c07ec1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ INCLUDE(CheckPIESupported) CHECK_PIE_SUPPORTED() SET(CMAKE_POSITION_INDEPENDENT_CODE ON) -SET(MISSION_MODULE_VERSION 1.2.2) +SET(MISSION_MODULE_VERSION 1.2.3) OPTION(BRINGAUTO_INSTALL "Configure install" OFF) OPTION(BRINGAUTO_PACKAGE "Configure package creation" OFF) diff --git a/source/external_server_api.cpp b/source/external_server_api.cpp index 5ebd2f3..c54ad26 100644 --- a/source/external_server_api.cpp +++ b/source/external_server_api.cpp @@ -248,6 +248,7 @@ int wait_for_command(int timeout_time_in_ms, void *context) { auto con = static_cast (context); std::unique_lock lock(con->mutex); std::vector> commands; + bool parse_commands = con->last_command_timestamp != 0; try { commands = con->fleet_api_client->getCommands(con->last_command_timestamp + 1, true); @@ -260,27 +261,29 @@ int wait_for_command(int timeout_time_in_ms, void *context) { con->last_command_timestamp = command->getTimestamp(); } - auto received_device_id = command->getDeviceId(); - MissionModule::AutonomyCommand proto_command {}; - const auto parse_status = google::protobuf::util::JsonStringToMessage( - command->getPayload()->getData()->getJson().serialize(), &proto_command - ); - if(!parse_status.ok()) { - return NOT_OK; + if(parse_commands) { + auto received_device_id = command->getDeviceId(); + MissionModule::AutonomyCommand proto_command {}; + const auto parse_status = google::protobuf::util::JsonStringToMessage( + command->getPayload()->getData()->getJson().serialize(), &proto_command + ); + if(!parse_status.ok()) { + return NOT_OK; + } + std::string command_str; + proto_command.SerializeToString(&command_str); + + con->command_vector.emplace_back(command_str, bringauto::fleet_protocol::cxx::DeviceID( + received_device_id->getModuleId(), + received_device_id->getType(), + 0, //priority + received_device_id->getRole(), + received_device_id->getName() + )); } - std::string command_str; - proto_command.SerializeToString(&command_str); - - con->command_vector.emplace_back(command_str, bringauto::fleet_protocol::cxx::DeviceID( - received_device_id->getModuleId(), - received_device_id->getType(), - 0, //priority - received_device_id->getRole(), - received_device_id->getName() - )); } - if(commands.empty()) { + if(commands.empty() || !parse_commands) { return TIMEOUT_OCCURRED; } else {