2015-12-01 16:24:51 +00:00
|
|
|
#include <QDebug>
|
|
|
|
#include "binaryfile.h"
|
|
|
|
|
|
|
|
BinaryFile::BinaryFile(QByteArray data) : GenericFile(data)
|
|
|
|
{
|
|
|
|
m_length = 0;
|
|
|
|
m_address = 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);
|
|
|
|
m_address = (quint8) metadata[0] + ((quint8) metadata[1]*256);
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
qDebug() << QString("Address: %1 Length: %2").arg(m_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();
|
|
|
|
}
|