mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
GCS/Logging: Added size information to GCS Log file so naieve parser can not fail. Also added a few comments.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1490 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
ec7d059de8
commit
06d281c2ba
@ -69,23 +69,24 @@ bool LoggingThread::openFile(QString file, LoggingPlugin * parent)
|
|||||||
/**
|
/**
|
||||||
* Logs an object update to the file. Data format is the
|
* Logs an object update to the file. Data format is the
|
||||||
* timestamp as a 32 bit uint counting ms from start of
|
* timestamp as a 32 bit uint counting ms from start of
|
||||||
* file writing (flight time will be embedded in stream)
|
* file writing (flight time will be embedded in stream),
|
||||||
* the UAVtalk packed object.
|
* then object packet size, then the packed UAVObject.
|
||||||
*/
|
*/
|
||||||
void LoggingThread::objectUpdated(UAVObject * obj)
|
void LoggingThread::objectUpdated(UAVObject * obj)
|
||||||
{
|
{
|
||||||
quint32 timeStamp = myTime.elapsed();
|
quint32 timeStamp = myTime.elapsed();
|
||||||
quint32 objSize = obj->getNumBytes();
|
quint32 objSize = obj->getNumBytes();
|
||||||
quint8 * buffer = new quint8[objSize+4];
|
quint8 * buffer = new quint8[objSize+8];
|
||||||
|
|
||||||
if(buffer == NULL)
|
if(buffer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
obj->pack(&buffer[4]);
|
obj->pack(&buffer[8]);
|
||||||
memcpy(buffer,&timeStamp,4);
|
memcpy(buffer,&timeStamp,4);
|
||||||
|
memcpy(buffer,&objSize,4);
|
||||||
|
|
||||||
QWriteLocker locker(&lock);
|
QWriteLocker locker(&lock);
|
||||||
qint64 written = logFile.write((char *) buffer,objSize+4);
|
qint64 written = logFile.write((char *) buffer,objSize+8);
|
||||||
|
|
||||||
delete(buffer);
|
delete(buffer);
|
||||||
|
|
||||||
@ -144,6 +145,9 @@ LoggingPlugin::~LoggingPlugin()
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add Logging plugin to File menu
|
||||||
|
*/
|
||||||
bool LoggingPlugin::initialize(const QStringList& args, QString *errMsg)
|
bool LoggingPlugin::initialize(const QStringList& args, QString *errMsg)
|
||||||
{
|
{
|
||||||
Q_UNUSED(args);
|
Q_UNUSED(args);
|
||||||
@ -208,11 +212,18 @@ void LoggingPlugin::startLogging(QString file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the stop logging signal to the LoggingThread
|
||||||
|
*/
|
||||||
void LoggingPlugin::stopLogging()
|
void LoggingPlugin::stopLogging()
|
||||||
{
|
{
|
||||||
emit stopLoggingSignal();
|
emit stopLoggingSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receive the logging stopped signal from the LoggingThread
|
||||||
|
* and change status to not logging
|
||||||
|
*/
|
||||||
void LoggingPlugin::loggingStopped()
|
void LoggingPlugin::loggingStopped()
|
||||||
{
|
{
|
||||||
state = IDLE;
|
state = IDLE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user