2015-12-01 16:24:51 +00:00
|
|
|
#include <QDebug>
|
|
|
|
#include "binaryfile.h"
|
|
|
|
|
|
|
|
BinaryFile::BinaryFile(QByteArray data) : GenericFile(data)
|
|
|
|
{
|
|
|
|
m_length = 0;
|
|
|
|
|
|
|
|
if (!data.isEmpty()) {
|
|
|
|
setData(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BinaryFile::setData(QByteArray data)
|
|
|
|
{
|
|
|
|
if (data.length() >= 4) {
|
|
|
|
QByteArray metadata = data.left(4);
|
|
|
|
m_data = data.mid(4);
|
2016-02-11 23:46:10 +00:00
|
|
|
setAddress((quint8) metadata[0] + ((quint8) metadata[1]*256));
|
2015-12-01 16:24:51 +00:00
|
|
|
m_length = (quint8) metadata[2] + ((quint8) metadata[3]*256);
|
2016-02-08 22:56:25 +00:00
|
|
|
}
|
2015-12-01 16:24:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BinaryFile::dump()
|
|
|
|
{
|
2016-02-16 22:42:02 +00:00
|
|
|
qDebug() << QString("Address: %1 Length: %2")
|
|
|
|
.arg((quint16) address(),4,16,QChar('0'))
|
|
|
|
.arg(m_length,4,16,QChar('0')).toUpper();
|
|
|
|
qDebug() << QString("Data Length Recorded: %1")
|
|
|
|
.arg(m_data.length(),4,16,QChar('0')).toUpper();
|
2015-12-01 16:24:51 +00:00
|
|
|
}
|