diff --git a/src/comm/MAVLinkProtocol.h b/src/comm/MAVLinkProtocol.h index e2fbafbf233ff6bf4691d4b9597f0516c092eb35..82cf9b1132d25b8e2b0c218e932725603bd4e894 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 8af036e9534c18c17a3b821843cb965962787e6c..2049e55f76b232d05ced9b380495dc56ef34abe1 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 b6b55644d9dc0e2b01b265a72f05c9e5d9888ee1..0b10e375390a225f4f8d7a247dd41a3754b7c96c 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;