diff --git a/src/boards/HeliTest/FlightModeManager/FMMStatus.h b/src/boards/HeliTest/FlightModeManager/FMMStatus.h index 8a071a51825cb8087b34da415464be64235e7fb4..2bac78b4633b9a0f09829ab5a49d8c3cc97ce4f9 100644 --- a/src/boards/HeliTest/FlightModeManager/FMMStatus.h +++ b/src/boards/HeliTest/FlightModeManager/FMMStatus.h @@ -56,7 +56,7 @@ struct HeliStatus static std::string header() { - return "timestamp,state,fail_reason,time_free_fal,time_start_cut,time_" + return "timestamp,state,fail_reason,time_free_fall,time_start_cut,time_" "end_cut\n"; } diff --git a/src/boards/HeliTest/ThermalCutter/CutterData.h b/src/boards/HeliTest/ThermalCutter/CutterData.h index b24878c74dab3fee70187b66973c029102151a98..6a790cffa4a766455af1f0780c61ec3de3bebe2e 100644 --- a/src/boards/HeliTest/ThermalCutter/CutterData.h +++ b/src/boards/HeliTest/ThermalCutter/CutterData.h @@ -37,8 +37,18 @@ enum class CutterState : uint8_t struct CutterStatus { - long long timestamp; + long long timestamp = 0; CutterState state = CutterState::IDLE; + + static std::string header() + { + return "timestamp,state\n"; + } + + void print(std::ostream& os) const + { + os << timestamp << "," << (int)state << "\n"; + } }; } // namespace DeathStackBoard diff --git a/src/boards/HeliTest/heli_log_types.h b/src/boards/HeliTest/heli_log_types.h index 09956685e38268a3ec428ee0f595fed6662521bf..c0cd63020b16d8767ecf6912dff150708539289c 100644 --- a/src/boards/HeliTest/heli_log_types.h +++ b/src/boards/HeliTest/heli_log_types.h @@ -34,10 +34,13 @@ #include "logger/Deserializer.h" #include "logger/LogStats.h" #include "sensors/BME280/BME280Data.h" -#include "ThermalCutter/CutterStatus.h" - +#include "ThermalCutter/CutterData.h" +#include "PinStatus.h" +#include "Sensors/CurrentSenseData.h" using std::ofstream; +using namespace RogallinaBoard; + template <typename T> void print(T& t, ostream& os) { @@ -66,10 +69,16 @@ void registerTypes(Deserializer& ds) // System & thread stats ds.registerType<StackData>(print<StackData>, StackData::header()); - ds.registerType<SystemData>(print<SystemData>, SystemData::header()); + // Cutter ds.registerType<CutterStatus>(print<CutterStatus>, CutterStatus::header()); + + // Current sense + ds.registerType<CurrentSenseData>(print<CurrentSenseData>, CurrentSenseData::header()); + + // Pin Observer + ds.registerType<PinStatus>(print<PinStatus>, PinStatus::header()); } #endif diff --git a/src/shared/PinStatus.h b/src/shared/PinStatus.h index ffee2b1fcf1fd0f417c37b4c98f21e112f189072..e2302d7f5123bf720640ba453fbb3e27d3ded14b 100644 --- a/src/shared/PinStatus.h +++ b/src/shared/PinStatus.h @@ -1,17 +1,17 @@ -/* +/* * Copyright (c) 2019 Skyward Experimental Rocketry * Authors: Luca Erbetta - * + * * 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 @@ -24,6 +24,8 @@ #pragma once #include <cstdint> +#include <ostream> +#include <string> struct PinStatus { @@ -33,4 +35,15 @@ struct PinStatus uint16_t num_state_changes = 0; long long last_detection; + + static std::string header() + { + return "id,state,last_state_change,num_state_changes,last_detection\n"; + } + + void print(std::ostream& os) const + { + os << (int)id << "," << (int)state << "," << last_state_change << "," + << num_state_changes << "," << last_detection << "\n"; + } }; \ No newline at end of file diff --git a/src/shared/Sensors/CurrentSenseData.h b/src/shared/Sensors/CurrentSenseData.h index 6a224c3d2c7f3d167361707d2f8091215581e83c..b012010134add972a51d7ce13aa16a9e27b1191a 100644 --- a/src/shared/Sensors/CurrentSenseData.h +++ b/src/shared/Sensors/CurrentSenseData.h @@ -23,10 +23,20 @@ #pragma once +#include <ostream> +#include <string> + struct CurrentSenseData { long long timestamp = 0; float current_value = 0; float current_max_value = 0; + + static std::string header() { return "timestamp,current_value,current_max_val\n"; } + + void print(std::ostream& os) const + { + os << timestamp << "," << current_value << "," << current_max_value << "\n"; + } }; \ No newline at end of file diff --git a/src/shared/Sensors/CurrentSensor.h b/src/shared/Sensors/CurrentSensor.h index cc7ac0a73ec9f55a320965e7f2a23873edaa6e2f..4615e54133b4bb88b623de8d607e1cae609a94f8 100644 --- a/src/shared/Sensors/CurrentSensor.h +++ b/src/shared/Sensors/CurrentSensor.h @@ -47,6 +47,7 @@ public: */ bool onSimpleUpdate() override { + current_data.timestamp = miosix::getTick(); current_data.current_value = adc.convertChannel(CS_CHANNEL); if(current_data.current_value > current_data.current_max_value) {