// Check if the correct number of bytes could be read
if(startBytes.length()!=timeLen)
// First check initialization
if(startTime==0)
{
ui->logStatsLabel->setText(tr("Error reading first %1 bytes").arg(timeLen));
MainWindow::instance()->showCriticalMessage(tr("Failed loading MAVLink Logfile"),tr("Error reading first %1 bytes from logfile. Got %2 instead of %1 bytes. Is the logfile readable?").arg(timeLen).arg(startBytes.length()));
reset();
return;
}
QByteArraystartBytes=logFile.read(timeLen);
// Convert data to timestamp
startTime=*((quint64*)(startBytes.constData()));
currentStartTime=QGC::groundTimeUsecs();
ok=true;
// Check if the correct number of bytes could be read
if(startBytes.length()!=timeLen)
{
ui->logStatsLabel->setText(tr("Error reading first %1 bytes").arg(timeLen));
MainWindow::instance()->showCriticalMessage(tr("Failed loading MAVLink Logfile"),tr("Error reading first %1 bytes from logfile. Got %2 instead of %1 bytes. Is the logfile readable?").arg(timeLen).arg(startBytes.length()));
reset();
return;
}
//qDebug() << "START TIME: " << startTime;
// Convert data to timestamp
startTime=*((quint64*)(startBytes.constData()));
currentStartTime=QGC::groundTimeUsecs();
ok=true;
// Check if these bytes could be correctly decoded
if(!ok)
{
ui->logStatsLabel->setText(tr("Error decoding first timestamp, aborting."));
MainWindow::instance()->showCriticalMessage(tr("Failed loading MAVLink Logfile"),tr("Could not load initial timestamp from file %1. Is the file corrupted?").arg(logFile.fileName()));
reset();
return;
}
}
//qDebug() << "START TIME: " << startTime;
// Check if these bytes could be correctly decoded
if(!ok)
{
ui->logStatsLabel->setText(tr("Error decoding first timestamp, aborting."));
MainWindow::instance()->showCriticalMessage(tr("Failed loading MAVLink Logfile"),tr("Could not load initial timestamp from file %1. Is the file corrupted?").arg(logFile.fileName()));
reset();
return;
}
}
// Initialization seems fine, load next chunk
QByteArraychunk=logFile.read(timeLen+packetLen);
QByteArraypacket=chunk.mid(0,packetLen);
// Emit this packet
emitbytesReady(logLink,packet);
// Initialization seems fine, load next chunk
QByteArraychunk=logFile.read(timeLen+packetLen);
QByteArraypacket=chunk.mid(0,packetLen);
// Check if reached end of file before reading next timestamp