diff --git a/scripts/logdecoder/General/logdecoder.cpp b/scripts/logdecoder/General/logdecoder.cpp index 89f6f1a2bbff1cc81c7b5fb0729fd290a0cdeacd..ba47bc6cd1c2a2705d65af30defc81708e620287 100644 --- a/scripts/logdecoder/General/logdecoder.cpp +++ b/scripts/logdecoder/General/logdecoder.cpp @@ -21,6 +21,8 @@ */ #include <Groundstation/Automated/Actuators/ActuatorsData.h> +#include <Groundstation/Automated/HubData.h> +#include <Groundstation/Automated/LogSniffing.h> #include <Groundstation/Automated/PinHandler/PinData.h> #include <Groundstation/Automated/SMA/SMAData.h> #include <Groundstation/LyraGS/Radio/RadioData.h> @@ -49,8 +51,6 @@ #include <logger/Deserializer.h> #include <logger/LogTypes.h> #include <tscpp/stream.h> -#include <Groundstation/Automated/LogSniffing.h> - #include <fstream> #include <iostream> @@ -142,7 +142,8 @@ void registerTypes(Deserializer& ds) ds.registerType<Antennas::SMAStatus>(); ds.registerType<Antennas::PinChangeData>(); ds.registerType<LyraGS::MainRadioLog>(); - ds.registerType<Antennas::LogSniffing(); + ds.registerType<Antennas::LogSniffing>(); + ds.registerType<Antennas::HubData>(); } void showUsage(const string& cmdName) diff --git a/src/Groundstation/Automated/Hub.cpp b/src/Groundstation/Automated/Hub.cpp index 7e95a699c8f07eb88af64cc1c66c0c00f87c5185..d9a62adbe7ebeac5446da620daf2d25c1629436f 100644 --- a/src/Groundstation/Automated/Hub.cpp +++ b/src/Groundstation/Automated/Hub.cpp @@ -44,6 +44,10 @@ using namespace miosix; void Hub::dispatchOutgoingMsg(const mavlink_message_t& msg) { + logHubData.timestamp = TimestampTimer::getTimestamp(); + logHubData.groundRx = logHubData.groundRx + 1; + Logger::getInstance().log(logHubData); + TRACE("[info] Hub: Packet arrived from outgoing messages!!!\n"); LyraGS::BoardStatus* status = getModule<LyraGS::BoardStatus>(); LyraGS::RadioMain* radioMain = getModule<LyraGS::RadioMain>(); @@ -256,6 +260,10 @@ void Hub::dispatchOutgoingMsg(const mavlink_message_t& msg) dispatchIncomingMsg(msg); LogSniffing sniffing = {TimestampTimer::getTimestamp(), 1}; Logger::getInstance().log(sniffing); + + logHubData.timestamp = TimestampTimer::getTimestamp(); + logHubData.sniffedRx = logHubData.sniffedRx + 1; + Logger::getInstance().log(logHubData); } } @@ -268,6 +276,10 @@ void Hub::dispatchIncomingMsg(const mavlink_message_t& msg) (void)serial; #endif + logHubData.timestamp = TimestampTimer::getTimestamp(); + logHubData.rocketRx = logHubData.rocketRx + 1; + Logger::getInstance().log(logHubData); + // Extracting NAS rocket state if (msg.msgid == MAVLINK_MSG_ID_ROCKET_FLIGHT_TM) { diff --git a/src/Groundstation/Automated/Hub.h b/src/Groundstation/Automated/Hub.h index 12c78b197dfc9124862f69bd0e05749f4d0c4e52..a61b174e89b8bbab7788287d2c11da112aef3c93 100644 --- a/src/Groundstation/Automated/Hub.h +++ b/src/Groundstation/Automated/Hub.h @@ -22,6 +22,7 @@ #pragma once +#include <Groundstation/Automated/HubData.h> #include <Groundstation/Automated/LogSniffing.h> #include <Groundstation/Automated/SMA/SMA.h> #include <Groundstation/Common/HubBase.h> @@ -112,6 +113,8 @@ private: bool hasNewNasSet = false; uint64_t lastFlightTMTimestamp = 0; uint64_t lastStatsTMTimestamp = 0; + + HubData logHubData; // Data for logging }; } // namespace Antennas diff --git a/src/Groundstation/Automated/HubData.h b/src/Groundstation/Automated/HubData.h new file mode 100644 index 0000000000000000000000000000000000000000..ca56c5e4e91da3893645d6055c9b31b48ff5b4e2 --- /dev/null +++ b/src/Groundstation/Automated/HubData.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2024 Skyward Experimental Rocketry + * Author: Nicolò Caruso + * + * 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. + */ +#pragma once + +#include <stdint.h> + +#include <iostream> +#include <string> + +namespace Antennas +{ + +/** + * @brief Structure to save informations about the Hub reception + */ +struct HubData +{ + uint64_t timestamp = 0; + uint16_t groundRx = 0; + uint16_t rocketRx = 0; + uint16_t sniffedRx = 0; + + static std::string header() + { + return "timestamp,groundRx,rocketRx,sniffedRx\n"; + } + + void print(std::ostream& os) const + { + os << timestamp << "," << groundRx << "," << rocketRx << "," + << sniffedRx << "\n"; + } +}; +} // namespace Antennas