diff --git a/scripts/logdecoder/General/logdecoder.cpp b/scripts/logdecoder/General/logdecoder.cpp index d0070452994e426bbdf9ca2bb92eb1166f17bc1f..89f6f1a2bbff1cc81c7b5fb0729fd290a0cdeacd 100644 --- a/scripts/logdecoder/General/logdecoder.cpp +++ b/scripts/logdecoder/General/logdecoder.cpp @@ -49,6 +49,8 @@ #include <logger/Deserializer.h> #include <logger/LogTypes.h> #include <tscpp/stream.h> +#include <Groundstation/Automated/LogSniffing.h> + #include <fstream> #include <iostream> @@ -140,6 +142,7 @@ void registerTypes(Deserializer& ds) ds.registerType<Antennas::SMAStatus>(); ds.registerType<Antennas::PinChangeData>(); ds.registerType<LyraGS::MainRadioLog>(); + ds.registerType<Antennas::LogSniffing(); } void showUsage(const string& cmdName) diff --git a/src/Groundstation/Automated/Hub.cpp b/src/Groundstation/Automated/Hub.cpp index 51565c928904953d03fa6ae7d66b4aaa4aca5a8d..02ca1886431698a13a46f8bb57f889506a93b25d 100644 --- a/src/Groundstation/Automated/Hub.cpp +++ b/src/Groundstation/Automated/Hub.cpp @@ -254,6 +254,8 @@ void Hub::dispatchOutgoingMsg(const mavlink_message_t& msg) * command but the telemetry spoofed, therefore is then used as incoming */ dispatchIncomingMsg(msg); + LogSniffing sniffing = {TimestampTimer::getTimestamp(),1}; + Logger::getInstance().log(sniffing); } } @@ -271,7 +273,7 @@ void Hub::dispatchIncomingMsg(const mavlink_message_t& msg) { mavlink_rocket_flight_tm_t rocketTM; mavlink_msg_rocket_flight_tm_decode(&msg, &rocketTM); - uint64_t timestamp = mavlink_msg_rocket_flight_tm_get_timestamp(&msg); + uint64_t timestamp = rocketTM.timestamp; TRACE( "[info][Radio/Sniffing] Hub: A FLIGHT_ROCKET_TM packet was " "received " diff --git a/src/Groundstation/Automated/Hub.h b/src/Groundstation/Automated/Hub.h index 0c537945bb647986101376a73445a6806c641dba..30ca024829511f156e00c555fcc53401f95cf24a 100644 --- a/src/Groundstation/Automated/Hub.h +++ b/src/Groundstation/Automated/Hub.h @@ -33,6 +33,7 @@ #include <miosix.h> #include <sensors/SensorData.h> #include <utils/DependencyManager/DependencyManager.h> +#include <Groundstation/Automated/LogSniffing.h> namespace LyraGS { diff --git a/src/Groundstation/Automated/LogSniffing.h b/src/Groundstation/Automated/LogSniffing.h new file mode 100644 index 0000000000000000000000000000000000000000..13d38523f01adb1c6a32ab98365917d5a7da15ba --- /dev/null +++ b/src/Groundstation/Automated/LogSniffing.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2023 Skyward Experimental Rocketry + * Author: Davide Mor + * + * 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 +{ + +struct LogSniffing +{ + uint64_t timestamp; + uint8_t sniffed; + + static std::string header() { return "timestamp,sniffed\n"; } + + void print(std::ostream& os) const + { + os << timestamp << "," << sniffed << "\n"; + } +}; + +} // namespace Boarcore