Skip to content
Snippets Groups Projects
Commit d0099e90 authored by Nicolò Caruso's avatar Nicolò Caruso
Browse files

[ARP] Added HubData struct for more logging informations

HubData now logs the packets received from the ground and from rocket and the sniffed packets.
parent 2da719f9
Branches
Tags
No related merge requests found
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
*/ */
#include <Groundstation/Automated/Actuators/ActuatorsData.h> #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/PinHandler/PinData.h>
#include <Groundstation/Automated/SMA/SMAData.h> #include <Groundstation/Automated/SMA/SMAData.h>
#include <Groundstation/LyraGS/Radio/RadioData.h> #include <Groundstation/LyraGS/Radio/RadioData.h>
...@@ -49,8 +51,6 @@ ...@@ -49,8 +51,6 @@
#include <logger/Deserializer.h> #include <logger/Deserializer.h>
#include <logger/LogTypes.h> #include <logger/LogTypes.h>
#include <tscpp/stream.h> #include <tscpp/stream.h>
#include <Groundstation/Automated/LogSniffing.h>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
...@@ -142,7 +142,8 @@ void registerTypes(Deserializer& ds) ...@@ -142,7 +142,8 @@ void registerTypes(Deserializer& ds)
ds.registerType<Antennas::SMAStatus>(); ds.registerType<Antennas::SMAStatus>();
ds.registerType<Antennas::PinChangeData>(); ds.registerType<Antennas::PinChangeData>();
ds.registerType<LyraGS::MainRadioLog>(); ds.registerType<LyraGS::MainRadioLog>();
ds.registerType<Antennas::LogSniffing(); ds.registerType<Antennas::LogSniffing>();
ds.registerType<Antennas::HubData>();
} }
void showUsage(const string& cmdName) void showUsage(const string& cmdName)
......
...@@ -44,6 +44,10 @@ using namespace miosix; ...@@ -44,6 +44,10 @@ using namespace miosix;
void Hub::dispatchOutgoingMsg(const mavlink_message_t& msg) 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"); TRACE("[info] Hub: Packet arrived from outgoing messages!!!\n");
LyraGS::BoardStatus* status = getModule<LyraGS::BoardStatus>(); LyraGS::BoardStatus* status = getModule<LyraGS::BoardStatus>();
LyraGS::RadioMain* radioMain = getModule<LyraGS::RadioMain>(); LyraGS::RadioMain* radioMain = getModule<LyraGS::RadioMain>();
...@@ -256,6 +260,10 @@ void Hub::dispatchOutgoingMsg(const mavlink_message_t& msg) ...@@ -256,6 +260,10 @@ void Hub::dispatchOutgoingMsg(const mavlink_message_t& msg)
dispatchIncomingMsg(msg); dispatchIncomingMsg(msg);
LogSniffing sniffing = {TimestampTimer::getTimestamp(), 1}; LogSniffing sniffing = {TimestampTimer::getTimestamp(), 1};
Logger::getInstance().log(sniffing); 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) ...@@ -268,6 +276,10 @@ void Hub::dispatchIncomingMsg(const mavlink_message_t& msg)
(void)serial; (void)serial;
#endif #endif
logHubData.timestamp = TimestampTimer::getTimestamp();
logHubData.rocketRx = logHubData.rocketRx + 1;
Logger::getInstance().log(logHubData);
// Extracting NAS rocket state // Extracting NAS rocket state
if (msg.msgid == MAVLINK_MSG_ID_ROCKET_FLIGHT_TM) if (msg.msgid == MAVLINK_MSG_ID_ROCKET_FLIGHT_TM)
{ {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#pragma once #pragma once
#include <Groundstation/Automated/HubData.h>
#include <Groundstation/Automated/LogSniffing.h> #include <Groundstation/Automated/LogSniffing.h>
#include <Groundstation/Automated/SMA/SMA.h> #include <Groundstation/Automated/SMA/SMA.h>
#include <Groundstation/Common/HubBase.h> #include <Groundstation/Common/HubBase.h>
...@@ -112,6 +113,8 @@ private: ...@@ -112,6 +113,8 @@ private:
bool hasNewNasSet = false; bool hasNewNasSet = false;
uint64_t lastFlightTMTimestamp = 0; uint64_t lastFlightTMTimestamp = 0;
uint64_t lastStatsTMTimestamp = 0; uint64_t lastStatsTMTimestamp = 0;
HubData logHubData; // Data for logging
}; };
} // namespace Antennas } // namespace Antennas
/* 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment