Skip to content

Commit

Permalink
Adding a task to periodically resets the packet buffers #20
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm8 committed Jun 24, 2019
1 parent b3d9b8b commit 9d5cfa5
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 13 deletions.
45 changes: 43 additions & 2 deletions src/fsat-grs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.6.7
* \version 0.6.8
*
* \date 10/09/2017
*
Expand Down Expand Up @@ -833,10 +833,13 @@ int FSatGRS::Run(Glib::RefPtr<Gtk::Application> app)
system(cmd.c_str());

this->LoadConfigs();

auto timer_slot = sigc::mem_fun(*this, &FSatGRS::Timer);
auto conn = Glib::signal_timeout().connect(timer_slot, DATA_RECEPTION_SAMPLE_RATE);

auto timer_slot_buffer_reset = sigc::mem_fun(*this, &FSatGRS::TimerBufferReset);
auto conn_buffer_reset = Glib::signal_timeout().connect(timer_slot_buffer_reset, DATA_RECEPTION_BUFFER_RESET_PERIOD_MS);

return app->run(*window_fsat_grs);
}
/*
Expand Down Expand Up @@ -1028,6 +1031,44 @@ bool FSatGRS::Timer()
return true;
}

bool FSatGRS::TimerBufferReset()
{
if (togglebutton_play_beacon->get_active())
{

// Save bin stream for further analysis
system(string(string("mkdir -p ") + string(FSAT_GRS_OUTPUT_DIR) + string(FSAT_GRS_BINDATA_DIR)).c_str());
system(string(string("cp -a ") + string(FSAT_GRS_GRC_BEACON_BIN) + string(" ") + string(FSAT_GRS_OUTPUT_DIR) + string(FSAT_GRS_BINDATA_DIR) + string("/BEACON_`date +\"%Y-%m-%d_%H-%M-%S\"`.bin")).c_str());

// Deleting the buffer
system("rm -f " FSAT_GRS_GRC_BEACON_BIN);

// Creating an empty buffer
system("touch " FSAT_GRS_GRC_BEACON_BIN);

// Reseting the buffer counters
ngham_pkts_beacon->reset();
}

if (togglebutton_play_telemetry->get_active())
{
// Save bin stream for further analysis
system(string(string("mkdir -p ") + string(FSAT_GRS_OUTPUT_DIR) + string(FSAT_GRS_BINDATA_DIR)).c_str());
system(string(string("cp -a ") + string(FSAT_GRS_GRC_TELEMETRY_BIN) + string(" ") + string(FSAT_GRS_OUTPUT_DIR) + string(FSAT_GRS_BINDATA_DIR) + string("/DOWNLINK_`date +\"%Y-%m-%d_%H-%M-%S\"`.bin")).c_str());

// Deleting the buffer
system("rm -f " FSAT_GRS_GRC_TELEMETRY_BIN);

// Creating an empty buffer
system("touch " FSAT_GRS_GRC_TELEMETRY_BIN);

// Reseting the buffer counters
ngham_pkts_telemetry->reset();
}

return true;
}

void FSatGRS::UpdateBeaconDataTab(grs::BeaconData beacon)
{
// EPS data
Expand Down
12 changes: 10 additions & 2 deletions src/fsat-grs.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* fsat-grs.h
*
* Copyright (C) 2017-2019, Federal University of Santa Catarina.
* Copyright (C) 2017-2019, Universidade Federal de Santa Catarina.
*
* This file is part of FloripaSat-GRS.
*
Expand All @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.5.11
* \version 0.6.8
*
* \date 10/09/2017
*
Expand Down Expand Up @@ -58,6 +58,7 @@
#define FSAT_PKT_ANA_DEFAULT_UI_FILE_LOCAL "glade/fsat_grs_gui.glade"

#define DATA_RECEPTION_SAMPLE_RATE 1000
#define DATA_RECEPTION_BUFFER_RESET_PERIOD_MS (60*60*1000) // 1 hour

#define FSAT_GRS_RX_BEACON 0
#define FSAT_GRS_RX_TELEMETRY 1
Expand Down Expand Up @@ -532,6 +533,13 @@ class FSatGRS
*/
bool Timer();

/**
* \brief Buffer reset task.
*
* \return TRUE/FALSE if the task must continue or not.
*/
bool TimerBufferReset();

/**
* \brief Updates the beacon data tab.
*
Expand Down
8 changes: 7 additions & 1 deletion src/packets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.4.9
* \version 0.6.8
*
* \date 06/10/2017
*
Expand Down Expand Up @@ -195,4 +195,10 @@ string Packets::LogPayload()
return string();
}

void Packets::reset()
{
this->prev_fin_byte_counter = 0;
this->fin_byte_counter = 0;
}

//! \} End of packets group
38 changes: 32 additions & 6 deletions src/packets.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* packets.h
*
* Copyright (C) 2017, Federal University of Santa Catarina.
* Copyright (C) 2017-2019, Universidade Federal de Santa Catarina.
*
* This file is part of FloripaSat-GRS.
*
Expand All @@ -21,13 +21,11 @@
*/

/**
* \file packets.h
*
* \brief Packets class.
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 1.0-dev
* \version 0.6.8
*
* \date 06/10/2017
*
Expand All @@ -54,94 +52,112 @@
#define PACKETS_SYNC_BYTE_S3_DEFAULT 0x5D

/**
* \class Packets
*
* \brief
*/
class Packets: public std::ifstream
{
protected:

/**
* \brief
*/
std::vector<uint8_t> preamble;

/**
* \brief
*/
std::vector<uint8_t> sync_bytes;

/**
* \brief
*/
bool receive_pkt;

/**
* \brief
*/
std::vector<uint8_t> sync_bytes_buffer;

/**
* \brief
*/
std::vector<uint8_t> byte_buffer;

/**
* \brief
*/
bool make_log;

/**
* \brief
*/
Log *log_pkts;

/**
* \brief
*/
bool make_data_log;

/**
* \brief
*/
Log *log_data_pkts;

/**
* \brief
*/
EventLog *event_log;

/**
* \brief
*/
PacketData *packet_data;

/**
* \brief
*/
ProtocolStatistic *protocol_statistic;

/**
* \brief
*/
uint64_t prev_fin_byte_counter;

/**
* \brief
*/
uint64_t fin_byte_counter;

public:

/**
* \brief
*
* \return None
*/
Packets();

/**
* \brief Class destructor.
*
* \return None
*/
~Packets();

/**
* \brief Variables initialization.
*
* \return None
*/
void InitPkts();

/**
* \brief Sets the preamle value.
*
* \return None
*/
void SetPreamble(uint8_t byte, uint8_t quant);

/**
* \brief Sets the sync. word.
*
Expand All @@ -153,6 +169,7 @@ class Packets: public std::ifstream
* \return None
*/
void SetSyncBytes(uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3);

/**
* \brief
*
Expand All @@ -161,6 +178,7 @@ class Packets: public std::ifstream
* \return
*/
virtual bool ProcessByte(uint8_t b);

/**
* \brief Search for packets in a binary file.
*
Expand All @@ -169,12 +187,20 @@ class Packets: public std::ifstream
* \return None
*/
virtual void Search(const char *file);

/**
* \brief Log the payload of a found packet.
*
* \return The respective log line of the packet payload to the log file.
*/
std::string LogPayload();

/**
* \brief Resets the buffer position.
*
* \return None.
*/
void reset();
};

#endif // PACKETS_H_
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.6.7
* \version 0.6.8
*
* \date 13/02/2019
*
Expand All @@ -37,7 +37,7 @@
#ifndef VERSION_H_
#define VERSION_H_

#define GRS_SOFTWARE_VERSION "0.6.7"
#define GRS_SOFTWARE_VERSION "0.6.8"

#endif // VERSION_H_

Expand Down

0 comments on commit 9d5cfa5

Please sign in to comment.