From 96522cf70646354c6baa6049f1204a8e564e0ebf Mon Sep 17 00:00:00 2001 From: pixhawk Date: Mon, 7 Jun 2010 21:45:45 +0200 Subject: [PATCH] Working on real log replay in simulation link --- src/comm/MAVLinkProtocol.h | 2 +- src/comm/MAVLinkSimulationLink.cc | 20 ++++++++++++++++++++ src/comm/MAVLinkSimulationLink.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/comm/MAVLinkProtocol.h b/src/comm/MAVLinkProtocol.h index e2fbafb..82cf9b1 100644 --- a/src/comm/MAVLinkProtocol.h +++ b/src/comm/MAVLinkProtocol.h @@ -69,7 +69,7 @@ public: /** @brief Get logging state */ bool loggingEnabled(void); /** @brief Get the name of the packet log file */ - QString getLogfileName(); + static QString getLogfileName(); public slots: /** @brief Receive bytes from a communication interface */ diff --git a/src/comm/MAVLinkSimulationLink.cc b/src/comm/MAVLinkSimulationLink.cc index 8af036e..2049e55 100644 --- a/src/comm/MAVLinkSimulationLink.cc +++ b/src/comm/MAVLinkSimulationLink.cc @@ -38,6 +38,7 @@ This file is part of the PIXHAWK project #include #include "MG.h" #include "LinkManager.h" +#include "MAVLinkProtocol.h" #include "MAVLinkSimulationLink.h" // MAVLINK includes #include @@ -92,6 +93,10 @@ MAVLinkSimulationLink::MAVLinkSimulationLink(QString readFile, QString writeFile maxTimeNoise = 0; this->id = getNextLinkId(); LinkManager::instance()->add(this); + + // Open packet log + mavlinkLogFile = new QFile(MAVLinkProtocol::getLogfileName()); + mavlinkLogFile->open(QIODevice::ReadOnly); } MAVLinkSimulationLink::~MAVLinkSimulationLink() @@ -121,6 +126,21 @@ void MAVLinkSimulationLink::run() if (_isConnected) { mainloop(); + + // FIXME Hacky code to read from packet log file +// readyBufferMutex.lock(); +// for (int i = 0; i < streampointer; i++) +// { +// readyBuffer.enqueue(*(stream + i)); +// } +// readyBufferMutex.unlock(); + + + + + + + emit bytesReady(this); } last = MG::TIME::getGroundTimeNow(); diff --git a/src/comm/MAVLinkSimulationLink.h b/src/comm/MAVLinkSimulationLink.h index b6b5564..0b10e37 100644 --- a/src/comm/MAVLinkSimulationLink.h +++ b/src/comm/MAVLinkSimulationLink.h @@ -98,6 +98,7 @@ protected: QTimer* timer; /** File which contains the input data (simulated robot messages) **/ QFile* simulationFile; + QFile* mavlinkLogFile; QString simulationHeader; /** File where the commands sent by the groundstation are stored **/ QFile* receiveFile;