Skip to content

Commit

Permalink
Data consistency checks in vmsrawdump
Browse files Browse the repository at this point in the history
  • Loading branch information
pkubanek committed Jun 11, 2024
1 parent b1f4386 commit d6ecc53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ts-VMSd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <cRIO/SALSink.h>
#include <cRIO/Settings/Path.h>

#include <Accelerometer.h>
#include <SALAccelerometer.h>
#include <Commands/EnterControl.h>
#include <Commands/Update.h>
#include <Events/FPGAState.h>
Expand Down Expand Up @@ -64,7 +64,7 @@ class MTVMSd : public LSST::cRIO::CSC {
// SAL object to receive all events from other VMS
std::shared_ptr<SAL_MTVMS> _allvmsSAL;

Accelerometer *accelerometer;
SALAccelerometer *accelerometer;
};

SALSinkMacro(MTVMS);
Expand Down Expand Up @@ -124,7 +124,7 @@ void MTVMSd::init() {

// spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) { l->flush(); });

accelerometer = new Accelerometer(&_vmsApplicationSettings);
accelerometer = new SALAccelerometer(&_vmsApplicationSettings);

SPDLOG_INFO("Main: Setting publisher");
VMSPublisher::instance().setSAL(_vmsSAL);
Expand Down
10 changes: 10 additions & 0 deletions utils/vmsrawdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,17 @@ void dump_file(const char *filename) {
std::cout << std::endl;

auto micros_d = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count();
long int old_micros = 0;

while (!file.eof()) {
file.read(reinterpret_cast<char *>(&micros_d), sizeof(micros_d));

if (old_micros >= micros_d) {
std::cerr << "Recorded timestamps in file " << filename << " aren't increasing ("
<< old_micros << " >= " << micros_d << "), skipping rest of the file!" << std::endl;
return;
}

microseconds micros(micros_d);
seconds sec = duration_cast<seconds>(micros);
micros -= sec;
Expand All @@ -159,6 +167,8 @@ void dump_file(const char *filename) {
}

std::cout << std::endl;

old_micros = micros_d;
}
} catch (const std::ios_base::failure &e) {
if (file.eof()) {
Expand Down

0 comments on commit d6ecc53

Please sign in to comment.