diff --git a/.gitignore b/.gitignore index 0dbe996a90b2c7e8146bd9aa672f18d74708430b..a626a4d8754f6849d29125f85b62ac76f0f6ca83 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,3 @@ __pycache__ **/generated **/scxmls - -src/scripts/logdecoder - diff --git a/src/boards/MockupMain/TMRepository/TMRepository.cpp b/src/boards/MockupMain/TMRepository/TMRepository.cpp index f48aa45dd78219711f94a073e0cd89345aabfc9e..87d53021beaa137f0eabd6075d3393386366ff65 100644 --- a/src/boards/MockupMain/TMRepository/TMRepository.cpp +++ b/src/boards/MockupMain/TMRepository/TMRepository.cpp @@ -172,8 +172,11 @@ mavlink_message_t TMRepository::packSystemTm(SystemTMList tmId, uint8_t msgId, modules.get<FlightModeManager>()->getStatus().state); tm.wes_state = 0; - tm.wes_n = 0; - tm.wes_e = 0; + tm.wes_n = modules.get<Sensors>()->getLoadCellLastSample().load; + tm.wes_e = modules.get<Sensors>() + ->getADS131LastSample() + .getVoltage(SensorsConfig::LOAD_CELL_ADC_CHANNEL) + .voltage; tm.pressure_digi = lps22df.pressure; diff --git a/src/scripts/logdecoder/MockupMain/Makefile b/src/scripts/logdecoder/MockupMain/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..6bbaf34fc2008754ca1425004f33514659c56baf --- /dev/null +++ b/src/scripts/logdecoder/MockupMain/Makefile @@ -0,0 +1,16 @@ +BOARDCORE := ../../../../skyward-boardcore/ +OBSW := ../../../../src/boards/ + +all: + g++ -std=c++17 -O2 -o logdecoder logdecoder.cpp \ + -DCOMPILE_FOR_X86 \ + -DCOMPILE_FOR_HOST \ + $(BOARDCORE)libs/tscpp/tscpp/stream.cpp \ + -I$(BOARDCORE)libs/miosix-host \ + -I$(BOARDCORE)libs/mavlink-skyward-lib \ + -I$(BOARDCORE)libs/eigen \ + -I$(BOARDCORE)libs/tscpp \ + -I$(BOARDCORE)src/shared \ + -I$(OBSW) +clean: + rm logdecoder diff --git a/src/scripts/logdecoder/MockupMain/logdecoder b/src/scripts/logdecoder/MockupMain/logdecoder new file mode 100755 index 0000000000000000000000000000000000000000..9df9b89c053ef4a1d2ccded6abc44746f9fade96 Binary files /dev/null and b/src/scripts/logdecoder/MockupMain/logdecoder differ diff --git a/src/scripts/logdecoder/MockupMain/logdecoder.cpp b/src/scripts/logdecoder/MockupMain/logdecoder.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5cee431c2ceb74d30543c623f596009d94b58929 --- /dev/null +++ b/src/scripts/logdecoder/MockupMain/logdecoder.cpp @@ -0,0 +1,136 @@ +/* Copyright (c) 2018-2022 Skyward Experimental Rocketry + * Author: Federico Terraneo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include <MockupMain/Sensors/AnalogLoadCellSensor.h> +#include <MockupMain/StateMachines/FlightModeManager/FlightModeManagerData.h> +#include <MockupMain/StateMachines/NASController/NASControllerData.h> +#include <logger/Deserializer.h> +#include <logger/LogTypes.h> +#include <radio/Xbee/APIFramesLog.h> +#include <sensors/analog/Pitot/PitotData.h> +#include <tscpp/stream.h> + +#include <fstream> +#include <iostream> +#include <stdexcept> +#include <string> + +/** + * @brief Binary log files decoder. + * + * This program is to compile for you computer and decodes binary log files + * through the tscpp library. + * + * In LogTypes.h there should be included all the classes you want to + * deserialize. + */ + +using namespace tscpp; +using namespace Boardcore; +using namespace MockupMain; +using namespace Xbee; + +void registerTypes(Deserializer& ds) +{ + // Register all Boardcore types + LogTypes::registerTypes(ds); + + // Custom types + ds.registerType<FlightModeManagerStatus>(); + ds.registerType<NASControllerStatus>(); + ds.registerType<LoadCellData>(); + ds.registerType<PitotData>(); + ds.registerType<APIFrameLog>(); + ds.registerType<ATCommandFrameLog>(); + ds.registerType<TXRequestFrameLog>(); + ds.registerType<ATCommandResponseFrameLog>(); + ds.registerType<ModemStatusFrameLog>(); + ds.registerType<TXStatusFrameLog>(); + ds.registerType<RXPacketFrameLog>(); +} + +void showUsage(const string& cmdName) +{ + std::cerr << "Usage: " << cmdName << " {-a | <log_file_name> | -h}" + << "Options:\n" + << "\t-h,--help\t\tShow help message\n" + << "\t-a,--all Deserialize all logs in the current directory\n" + << std::endl; +} + +bool deserialize(string logName) +{ + std::cout << "Deserializing " << logName << "...\n"; + Deserializer d(logName); + LogTypes::registerTypes(d); + registerTypes(d); + + return d.deserialize(); +} + +bool deserializeAll() +{ + for (int i = 0; i < 100; i++) + { + char nextName[11]; + sprintf(nextName, "log%02d.dat", i); + struct stat st; + if (stat(nextName, &st) != 0) + continue; // File not found + // File found + if (!deserialize(string(nextName))) + return false; + } + return true; +} + +int main(int argc, char* argv[]) +{ + if (argc < 2) + { + showUsage(string(argv[0])); + return 1; // Error + } + + bool success = false; + string arg1 = string(argv[1]); + + // Help message + if (arg1 == "-h" || arg1 == "--help") + { + showUsage(string(argv[0])); + return 0; + } + + // File deserialization + if (arg1 == "-a" || arg1 == "--all") + success = deserializeAll(); + else + success = deserialize(arg1); + + // End + if (success) + std::cout << "Deserialization completed successfully\n"; + else + std::cout << "Deserialization ended with errors\n"; + return 0; +}