Browse Source

Working on real log replay in simulation link

QGC4.4
pixhawk 15 years ago
parent
commit
96522cf706
  1. 2
      src/comm/MAVLinkProtocol.h
  2. 20
      src/comm/MAVLinkSimulationLink.cc
  3. 1
      src/comm/MAVLinkSimulationLink.h

2
src/comm/MAVLinkProtocol.h

@ -69,7 +69,7 @@ public:
/** @brief Get logging state */ /** @brief Get logging state */
bool loggingEnabled(void); bool loggingEnabled(void);
/** @brief Get the name of the packet log file */ /** @brief Get the name of the packet log file */
QString getLogfileName(); static QString getLogfileName();
public slots: public slots:
/** @brief Receive bytes from a communication interface */ /** @brief Receive bytes from a communication interface */

20
src/comm/MAVLinkSimulationLink.cc

@ -38,6 +38,7 @@ This file is part of the PIXHAWK project
#include <QDebug> #include <QDebug>
#include "MG.h" #include "MG.h"
#include "LinkManager.h" #include "LinkManager.h"
#include "MAVLinkProtocol.h"
#include "MAVLinkSimulationLink.h" #include "MAVLinkSimulationLink.h"
// MAVLINK includes // MAVLINK includes
#include <mavlink.h> #include <mavlink.h>
@ -92,6 +93,10 @@ MAVLinkSimulationLink::MAVLinkSimulationLink(QString readFile, QString writeFile
maxTimeNoise = 0; maxTimeNoise = 0;
this->id = getNextLinkId(); this->id = getNextLinkId();
LinkManager::instance()->add(this); LinkManager::instance()->add(this);
// Open packet log
mavlinkLogFile = new QFile(MAVLinkProtocol::getLogfileName());
mavlinkLogFile->open(QIODevice::ReadOnly);
} }
MAVLinkSimulationLink::~MAVLinkSimulationLink() MAVLinkSimulationLink::~MAVLinkSimulationLink()
@ -121,6 +126,21 @@ void MAVLinkSimulationLink::run()
if (_isConnected) if (_isConnected)
{ {
mainloop(); 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); emit bytesReady(this);
} }
last = MG::TIME::getGroundTimeNow(); last = MG::TIME::getGroundTimeNow();

1
src/comm/MAVLinkSimulationLink.h

@ -98,6 +98,7 @@ protected:
QTimer* timer; QTimer* timer;
/** File which contains the input data (simulated robot messages) **/ /** File which contains the input data (simulated robot messages) **/
QFile* simulationFile; QFile* simulationFile;
QFile* mavlinkLogFile;
QString simulationHeader; QString simulationHeader;
/** File where the commands sent by the groundstation are stored **/ /** File where the commands sent by the groundstation are stored **/
QFile* receiveFile; QFile* receiveFile;

Loading…
Cancel
Save