Changed a lot of pointer references to const (it's more correct and

fixes a weird problem), fixed a problem with JSON to DBC, a few other
fixes
This commit is contained in:
Collin Kidder
2020-02-13 22:01:06 -05:00
parent 1a5d67d09e
commit d550fa79a0
18 changed files with 76 additions and 62 deletions
+6 -9
View File
@@ -59,12 +59,13 @@ void ISOTP_HANDLER::sendISOTPFrame(int bus, int ID, QByteArray data)
lastSenderID = ID; lastSenderID = ID;
lastSenderBus = bus; lastSenderBus = bus;
frame.bus = bus;
frame.setFrameId(ID);
if (ID > 0x7FF) frame.setExtendedFrameFormat(true);
else frame.setExtendedFrameFormat(false);
if (data.length() < 8) if (data.length() < 8)
{ {
frame.bus = bus;
frame.setFrameId(ID);
if (ID > 0x7FF) frame.setExtendedFrameFormat(true);
else frame.setExtendedFrameFormat(false);
QByteArray bytes(8,0); QByteArray bytes(8,0);
bytes.resize(8); bytes.resize(8);
bytes[0] = data.length(); bytes[0] = data.length();
@@ -74,10 +75,6 @@ void ISOTP_HANDLER::sendISOTPFrame(int bus, int ID, QByteArray data)
} }
else //need to send a multi-part ISO_TP message - Respects timing and frame number based flow control else //need to send a multi-part ISO_TP message - Respects timing and frame number based flow control
{ {
frame.bus = bus;
frame.setFrameId(ID);
if (ID > 0x7FF) frame.setExtendedFrameFormat(true);
else frame.setExtendedFrameFormat(false);
QByteArray bytes(8, 0); QByteArray bytes(8, 0);
bytes[0] = 0x10 + (data.length() / 256); bytes[0] = 0x10 + (data.length() / 256);
bytes[1] = data.length() & 0xFF; bytes[1] = data.length() & 0xFF;
@@ -159,7 +156,7 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
//int offset; //int offset;
ISOTP_MESSAGE msg; ISOTP_MESSAGE msg;
ISOTP_MESSAGE *pMsg; ISOTP_MESSAGE *pMsg;
unsigned char *data = reinterpret_cast<unsigned char *>(frame.payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(frame.payload().constData());
//int dataLen = frame.payload().count(); //int dataLen = frame.payload().count();
frameType = 0; frameType = 0;
+4 -2
View File
@@ -177,7 +177,7 @@ UDS_HANDLER::~UDS_HANDLER()
void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg) void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
{ {
qDebug() << "UDS handler got ISOTP frame"; qDebug() << "UDS handler got ISOTP frame";
unsigned char *data = reinterpret_cast<unsigned char *>(msg.payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(msg.payload().constData());
int dataLen = msg.payload().count(); int dataLen = msg.payload().count();
UDS_MESSAGE udsMsg; UDS_MESSAGE udsMsg;
udsMsg.bus = msg.bus; udsMsg.bus = msg.bus;
@@ -258,6 +258,8 @@ void UDS_HANDLER::sendUDSFrame(const UDS_MESSAGE &msg)
data.append(msg.payload()); data.append(msg.payload());
isoHandler->sendISOTPFrame(msg.bus, msg.frameId(), data); isoHandler->sendISOTPFrame(msg.bus, msg.frameId(), data);
//qDebug() << "Data sending: " << data;
qDebug() << "Sent UDS service: " << getServiceShortDesc(msg.service) << " on bus " << msg.bus; qDebug() << "Sent UDS service: " << getServiceShortDesc(msg.service) << " on bus " << msg.bus;
} }
@@ -327,7 +329,7 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
bool isResponse = true; bool isResponse = true;
int dataSize; int dataSize;
int addrSize; int addrSize;
unsigned char *data = reinterpret_cast<unsigned char *>(msg.payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(msg.payload().constData());
int dataLen = msg.payload().length(); int dataLen = msg.payload().length();
if (msg.isErrorReply) if (msg.isErrorReply)
+2 -1
View File
@@ -360,7 +360,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
thisFrame = filteredFrames.at(index.row()); thisFrame = filteredFrames.at(index.row());
unsigned char *data = reinterpret_cast<unsigned char *>(thisFrame.payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(thisFrame.payload().constData());
int dataLen = thisFrame.payload().count(); int dataLen = thisFrame.payload().count();
if (role == Qt::BackgroundColorRole) if (role == Qt::BackgroundColorRole)
@@ -551,6 +551,7 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false)
mutex.lock(); mutex.lock();
CANFrame tempFrame; CANFrame tempFrame;
tempFrame = frame; tempFrame = frame;
tempFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, tempFrame.timeStamp().microSeconds() - timeOffset)); tempFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, tempFrame.timeStamp().microSeconds() - timeOffset));
lastUpdateNumFrames++; lastUpdateNumFrames++;
+7
View File
@@ -77,6 +77,12 @@ public:
*/ */
CANCon::status getStatus(); CANCon::status getStatus();
/**
* @brief setConsoleOutput
* @param state - set whether to send debugging info to the console or not
*/
void setConsoleOutput(bool state);
signals: signals:
/*not implemented yet */ /*not implemented yet */
@@ -194,6 +200,7 @@ public slots:
protected: protected:
int mNumBuses; //protected to allow connected device to figure out how many buses are available int mNumBuses; //protected to allow connected device to figure out how many buses are available
QVector<BusData> mBusData; QVector<BusData> mBusData;
bool mConsoleOutput; //send debugging info to the console?
//determine if the passed frame is part of a filter or not. //determine if the passed frame is part of a filter or not.
void checkTargettedFrame(CANFrame &frame); void checkTargettedFrame(CANFrame &frame);
+4 -2
View File
@@ -119,6 +119,8 @@ bool SerialBusConnection::piSendFrame(const CANFrame& pFrame)
return false; return false;
if (!mDev_p) return false; if (!mDev_p) return false;
qDebug() << "Data bytes at lowlevel: " << pFrame.payload().toBase64();
return mDev_p->writeFrame(pFrame); return mDev_p->writeFrame(pFrame);
} }
@@ -179,7 +181,7 @@ void SerialBusConnection::framesReceived()
continue; continue;
/* check frame */ /* check frame */
if (recFrame.payload().length() <= 8) { //if (recFrame.payload().length() <= 8) {
CANFrame* frame_p = getQueue().get(); CANFrame* frame_p = getQueue().get();
if(frame_p) { if(frame_p) {
frame_p->setPayload(recFrame.payload()); frame_p->setPayload(recFrame.payload());
@@ -241,7 +243,7 @@ void SerialBusConnection::framesReceived()
/* enqueue frame */ /* enqueue frame */
getQueue().queue(); getQueue().queue();
} //}
#if 0 #if 0
else else
qDebug() << "can't get a frame, ERROR"; qDebug() << "can't get a frame, ERROR";
+1 -1
View File
@@ -1556,7 +1556,7 @@ DBCFile* DBCHandler::loadJSONFile(int idx)
{ {
qDebug() << iter.key(); qDebug() << iter.key();
DBC_MESSAGE msg; DBC_MESSAGE msg;
msg.ID = static_cast<uint32_t>(iter->toObject().find("origin_id").value().toInt()); msg.ID = static_cast<uint32_t>(iter->toObject().find("message_id").value().toInt());
msg.name = QString(iter.key().toUtf8()); msg.name = QString(iter.key().toUtf8());
msg.len = static_cast<unsigned int>(iter->toObject().find("length_bytes").value().toInt()); msg.len = static_cast<unsigned int>(iter->toObject().find("length_bytes").value().toInt());
msg.sender = thisFile->findNodeByIdx(0); msg.sender = thisFile->findNodeByIdx(0);
+1 -1
View File
@@ -77,7 +77,7 @@ void FirmwareUploaderWindow::updatedFrames(int numFrames)
void FirmwareUploaderWindow::gotTargettedFrame(CANFrame frame) void FirmwareUploaderWindow::gotTargettedFrame(CANFrame frame)
{ {
unsigned char *data = reinterpret_cast<unsigned char *>(frame.payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(frame.payload().constData());
int dataLen = frame.payload().count(); int dataLen = frame.payload().count();
qDebug() << "FUW: Got targetted frame with id " << frame.frameId(); qDebug() << "FUW: Got targetted frame with id " << frame.frameId();
+25 -25
View File
@@ -947,7 +947,7 @@ bool FrameFileIO::saveCRTDFile(QString filename, const QVector<CANFrame>* frames
QFile *outFile = new QFile(filename); QFile *outFile = new QFile(filename);
int lineCounter = 0; int lineCounter = 0;
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -971,7 +971,7 @@ bool FrameFileIO::saveCRTDFile(QString filename, const QVector<CANFrame>* frames
} }
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
outFile->write(QString::number(frame->timeStamp().microSeconds() / 1000000.0, 'f', 6).toUtf8()); outFile->write(QString::number(frame->timeStamp().microSeconds() / 1000000.0, 'f', 6).toUtf8());
@@ -1346,7 +1346,7 @@ bool FrameFileIO::saveCanalyzerASC(QString filename, const QVector<CANFrame>* fr
int lineCounter = 0; int lineCounter = 0;
int64_t offsetTime = frames->at(0).timeStamp().microSeconds(); int64_t offsetTime = frames->at(0).timeStamp().microSeconds();
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -1383,7 +1383,7 @@ bool FrameFileIO::saveCanalyzerASC(QString filename, const QVector<CANFrame>* fr
} }
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
uint64_t timeStamp = (frame->timeStamp().microSeconds() - offsetTime) / 1000000ull; uint64_t timeStamp = (frame->timeStamp().microSeconds() - offsetTime) / 1000000ull;
@@ -1614,7 +1614,7 @@ bool FrameFileIO::saveNativeCSVFile(QString filename, const QVector<CANFrame>* f
QFile *outFile = new QFile(filename); QFile *outFile = new QFile(filename);
int lineCounter = 0; int lineCounter = 0;
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -1637,7 +1637,7 @@ bool FrameFileIO::saveNativeCSVFile(QString filename, const QVector<CANFrame>* f
} }
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
outFile->write(QString::number(frame->timeStamp().microSeconds()).toUtf8()); outFile->write(QString::number(frame->timeStamp().microSeconds()).toUtf8());
@@ -1720,7 +1720,7 @@ bool FrameFileIO::closeContinuousNative()
bool FrameFileIO::writeContinuousNative(const QVector<CANFrame>* frames, int beginningFrame) bool FrameFileIO::writeContinuousNative(const QVector<CANFrame>* frames, int beginningFrame)
{ {
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -1729,7 +1729,7 @@ bool FrameFileIO::writeContinuousNative(const QVector<CANFrame>* frames, int beg
for (int c = beginningFrame; c < frames->count(); c++) for (int c = beginningFrame; c < frames->count(); c++)
{ {
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
continuousFile.write(QString::number(frame->timeStamp().microSeconds()).toUtf8()); continuousFile.write(QString::number(frame->timeStamp().microSeconds()).toUtf8());
@@ -1880,7 +1880,7 @@ bool FrameFileIO::saveGenericCSVFile(QString filename, const QVector<CANFrame>*
QFile *outFile = new QFile(filename); QFile *outFile = new QFile(filename);
int lineCounter = 0; int lineCounter = 0;
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -1903,7 +1903,7 @@ bool FrameFileIO::saveGenericCSVFile(QString filename, const QVector<CANFrame>*
} }
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
outFile->write(QString::number(frame->frameId(), 16).toUpper().rightJustified(8, '0').toUtf8()); outFile->write(QString::number(frame->frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
@@ -2086,7 +2086,7 @@ bool FrameFileIO::saveLogFile(QString filename, const QVector<CANFrame>* frames)
QDateTime timestamp, tempStamp; QDateTime timestamp, tempStamp;
int lineCounter = 0; int lineCounter = 0;
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -2124,7 +2124,7 @@ bool FrameFileIO::saveLogFile(QString filename, const QVector<CANFrame>* frames)
} }
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
tempStamp = QDateTime::fromMSecsSinceEpoch(frame->timeStamp().microSeconds() / 1000); tempStamp = QDateTime::fromMSecsSinceEpoch(frame->timeStamp().microSeconds() / 1000);
@@ -2282,7 +2282,7 @@ bool FrameFileIO::saveIXXATFile(QString filename, const QVector<CANFrame>* frame
QDateTime timestamp, tempStamp; QDateTime timestamp, tempStamp;
int lineCounter = 0; int lineCounter = 0;
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -2313,7 +2313,7 @@ bool FrameFileIO::saveIXXATFile(QString filename, const QVector<CANFrame>* frame
} }
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
tempStamp = QDateTime::fromMSecsSinceEpoch(frame->timeStamp().microSeconds() / 1000); tempStamp = QDateTime::fromMSecsSinceEpoch(frame->timeStamp().microSeconds() / 1000);
@@ -2418,7 +2418,7 @@ bool FrameFileIO::loadCANDOFile(QString filename, QVector<CANFrame>* frames)
} }
data = inFile->read(12); data = inFile->read(12);
unsigned char *uData = reinterpret_cast<unsigned char *>(data.data()); const unsigned char *uData = reinterpret_cast<const unsigned char *>(data.constData());
thisFrame.bus = 0; thisFrame.bus = 0;
thisFrame.isReceived = true; thisFrame.isReceived = true;
@@ -2460,7 +2460,7 @@ bool FrameFileIO::saveCANDOFile(QString filename, const QVector<CANFrame>* frame
int id; int id;
qint64 ms; qint64 ms;
unsigned char *inData; const unsigned char *inData;
int inDataLen; int inDataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -2492,7 +2492,7 @@ bool FrameFileIO::saveCANDOFile(QString filename, const QVector<CANFrame>* frame
} }
frame = &frames->at(c); frame = &frames->at(c);
inData = reinterpret_cast<unsigned char *>(frame->payload().data()); inData = reinterpret_cast<const unsigned char *>(frame->payload().constData());
inDataLen = frame->payload().count(); inDataLen = frame->payload().count();
for (int j = 0; j < 8; j++) data[4 + j] = (char)0xFF; for (int j = 0; j < 8; j++) data[4 + j] = (char)0xFF;
@@ -2660,7 +2660,7 @@ bool FrameFileIO::saveMicrochipFile(QString filename, const QVector<CANFrame>* f
QDateTime timestamp, tempStamp; QDateTime timestamp, tempStamp;
int lineCounter = 0; int lineCounter = 0;
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -2691,7 +2691,7 @@ bool FrameFileIO::saveMicrochipFile(QString filename, const QVector<CANFrame>* f
} }
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
outFile->write(QString::number((frame->timeStamp().microSeconds() / 1000)).toUtf8()); outFile->write(QString::number((frame->timeStamp().microSeconds() / 1000)).toUtf8());
@@ -2875,7 +2875,7 @@ bool FrameFileIO::saveTraceFile(QString filename, const QVector<CANFrame> * fram
int64_t tempTime; int64_t tempTime;
int tempTimePiece; int tempTimePiece;
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -2918,7 +2918,7 @@ bool FrameFileIO::saveTraceFile(QString filename, const QVector<CANFrame> * fram
} }
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
//1F D3 3F FF 08 FF E0 CB //1F D3 3F FF 08 FF E0 CB
@@ -2970,7 +2970,7 @@ bool FrameFileIO::saveCanDumpFile(QString filename, const QVector<CANFrame> * fr
int lineCounter = 0; int lineCounter = 0;
double tempTime; double tempTime;
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -2991,7 +2991,7 @@ bool FrameFileIO::saveCanDumpFile(QString filename, const QVector<CANFrame> * fr
} }
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
outFile->write("("); outFile->write("(");
@@ -3599,7 +3599,7 @@ bool FrameFileIO::saveCabanaFile(QString filename, const QVector<CANFrame>* fram
QFile *outFile = new QFile(filename); QFile *outFile = new QFile(filename);
int lineCounter = 0; int lineCounter = 0;
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -3622,7 +3622,7 @@ bool FrameFileIO::saveCabanaFile(QString filename, const QVector<CANFrame>* fram
} }
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
double tempTimeStamp = frame->timeStamp().microSeconds(); double tempTimeStamp = frame->timeStamp().microSeconds();
+1 -1
View File
@@ -792,7 +792,7 @@ void FrameSenderWindow::updateGridRow(int idx)
int gridLine = idx; int gridLine = idx;
QString dataString; QString dataString;
QTableWidgetItem *item = ui->tableSender->item(gridLine, 9); QTableWidgetItem *item = ui->tableSender->item(gridLine, 9);
unsigned char *data = reinterpret_cast<unsigned char *>(temp->payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(temp->payload().constData());
int dataLen = temp->payload().length(); int dataLen = temp->payload().length();
if (item == nullptr) item = new QTableWidgetItem(); if (item == nullptr) item = new QTableWidgetItem();
+2 -2
View File
@@ -729,7 +729,7 @@ void MainWindow::saveDecodedTextFile(QString filename)
QFile *outFile = new QFile(filename); QFile *outFile = new QFile(filename);
const QVector<CANFrame> *frames = model->getFilteredListReference(); const QVector<CANFrame> *frames = model->getFilteredListReference();
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
const CANFrame *frame; const CANFrame *frame;
@@ -743,7 +743,7 @@ Data Bytes: 88 10 00 13 BB 00 06 00
for (int c = 0; c < frames->count(); c++) for (int c = 0; c < frames->count(); c++)
{ {
frame = &frames->at(c); frame = &frames->at(c);
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().count(); dataLen = frame->payload().count();
QString builderString; QString builderString;
+3 -3
View File
@@ -123,7 +123,7 @@ void FileComparatorWindow::calculateDetails()
QTreeWidgetItem *interestedOnlyBase, *referenceOnlyBase = nullptr, *sharedBase, *bitmapBaseInterested, *bitmapBaseReference = nullptr; QTreeWidgetItem *interestedOnlyBase, *referenceOnlyBase = nullptr, *sharedBase, *bitmapBaseInterested, *bitmapBaseReference = nullptr;
QTreeWidgetItem *valuesBase, *detail, *sharedItem, *valuesInterested, *valuesReference = nullptr; QTreeWidgetItem *valuesBase, *detail, *sharedItem, *valuesInterested, *valuesReference = nullptr;
uint64_t tmp; uint64_t tmp;
unsigned char *data; const unsigned char *data;
int dataLen; int dataLen;
bool uniqueInterested = ui->ckUniqueToInterested->isChecked(); bool uniqueInterested = ui->ckUniqueToInterested->isChecked();
@@ -154,7 +154,7 @@ void FileComparatorWindow::calculateDetails()
for (int x = 0; x < interestedFrames.count(); x++) for (int x = 0; x < interestedFrames.count(); x++)
{ {
CANFrame frame = interestedFrames.at(x); CANFrame frame = interestedFrames.at(x);
data = reinterpret_cast<unsigned char *>(frame.payload().data()); data = reinterpret_cast<const unsigned char *>(frame.payload().constData());
dataLen = frame.payload().count(); dataLen = frame.payload().count();
if (interestedIDs.contains(frame.frameId())) //if we saw this ID before then add to the QList in there if (interestedIDs.contains(frame.frameId())) //if we saw this ID before then add to the QList in there
@@ -201,7 +201,7 @@ void FileComparatorWindow::calculateDetails()
for (int x = 0; x < referenceFrames.count(); x++) for (int x = 0; x < referenceFrames.count(); x++)
{ {
CANFrame frame = referenceFrames.at(x); CANFrame frame = referenceFrames.at(x);
data = reinterpret_cast<unsigned char *>(frame.payload().data()); data = reinterpret_cast<const unsigned char *>(frame.payload().constData());
dataLen = frame.payload().count(); dataLen = frame.payload().count();
if (referenceIDs.contains(frame.frameId())) //if we saw this ID before then add to the QList in there if (referenceIDs.contains(frame.frameId())) //if we saw this ID before then add to the QList in there
+4 -4
View File
@@ -397,7 +397,7 @@ void FlowViewWindow::updatedFrames(int numFrames)
{ {
QVector<double>newX[8]; QVector<double>newX[8];
QVector<double>newY[8]; QVector<double>newY[8];
unsigned char *data; const unsigned char *data;
int dataLen = 0; int dataLen = 0;
const CANFrame *thisFrame; const CANFrame *thisFrame;
@@ -436,7 +436,7 @@ void FlowViewWindow::updatedFrames(int numFrames)
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++) for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
{ {
thisFrame = &modelFrames->at(i); thisFrame = &modelFrames->at(i);
data = reinterpret_cast<unsigned char *>(thisFrame->payload().data()); data = reinterpret_cast<const unsigned char *>(thisFrame->payload().constData());
dataLen = thisFrame->payload().length(); dataLen = thisFrame->payload().length();
if (!foundID.contains(thisFrame->frameId())) if (!foundID.contains(thisFrame->frameId()))
@@ -502,7 +502,7 @@ void FlowViewWindow::createGraph(int byteNum)
{ {
int tempVal; int tempVal;
float minval=1000000, maxval = -100000; float minval=1000000, maxval = -100000;
unsigned char *data; const unsigned char *data;
int dataLen = 0; int dataLen = 0;
const CANFrame *frame; const CANFrame *frame;
@@ -520,7 +520,7 @@ void FlowViewWindow::createGraph(int byteNum)
for (int j = 0; j < numEntries; j++) for (int j = 0; j < numEntries; j++)
{ {
frame = &frameCache[j]; frame = &frameCache[j];
data = reinterpret_cast<unsigned char *>(frame->payload().data()); data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
dataLen = frame->payload().length(); dataLen = frame->payload().length();
tempVal = data[byteNum]; tempVal = data[byteNum];
+3 -3
View File
@@ -278,7 +278,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
if (thisFrame.frameId() == static_cast<uint32_t>(targettedID)) frameCache.append(thisFrame); if (thisFrame.frameId() == static_cast<uint32_t>(targettedID)) frameCache.append(thisFrame);
} }
unsigned char *data = reinterpret_cast<unsigned char *>(frameCache.at(0).payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(frameCache.at(0).payload().constData());
int dataLen = frameCache.at(0).payload().length(); int dataLen = frameCache.at(0).payload().length();
ui->treeDetails->clear(); ui->treeDetails->clear();
@@ -367,7 +367,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
} }
for (int j = 0; j < 64; j++) bitfieldHistogram[j] = 0; for (int j = 0; j < 64; j++) bitfieldHistogram[j] = 0;
data = reinterpret_cast<unsigned char *>(frameCache.at(0).payload().data()); data = reinterpret_cast<const unsigned char *>(frameCache.at(0).payload().constData());
dataLen = frameCache.at(0).payload().length(); dataLen = frameCache.at(0).payload().length();
for (int c = 0; c < dataLen; c++) for (int c = 0; c < dataLen; c++)
@@ -383,7 +383,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
//then find all data points //then find all data points
for (int j = 0; j < frameCache.count(); j++) for (int j = 0; j < frameCache.count(); j++)
{ {
data = reinterpret_cast<unsigned char *>(frameCache.at(j).payload().data()); data = reinterpret_cast<const unsigned char *>(frameCache.at(j).payload().constData());
dataLen = frameCache.at(j).payload().length(); dataLen = frameCache.at(j).payload().length();
byteGraphX.append(j); byteGraphX.append(j);
+2 -2
View File
@@ -208,7 +208,7 @@ void ISOTP_InterpreterWindow::showDetailView()
msg = &messages[rowNum]; msg = &messages[rowNum];
unsigned char *data = reinterpret_cast<unsigned char *>(msg->payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(msg->payload().constData());
int dataLen = msg->payload().length(); int dataLen = msg->payload().length();
if (msg->reportedLength != dataLen) if (msg->reportedLength != dataLen)
@@ -266,7 +266,7 @@ void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE msg)
int rowNum; int rowNum;
QString tempString; QString tempString;
unsigned char *data = reinterpret_cast<unsigned char *>(msg.payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(msg.payload().constData());
int dataLen = msg.payload().length(); int dataLen = msg.payload().length();
if ((msg.reportedLength != dataLen) && !ui->cbShowIncomplete->isChecked()) return; if ((msg.reportedLength != dataLen) && !ui->cbShowIncomplete->isChecked()) return;
+2 -2
View File
@@ -6,7 +6,7 @@
SnifferItem::SnifferItem(const CANFrame& pFrame, quint32 seq): SnifferItem::SnifferItem(const CANFrame& pFrame, quint32 seq):
mID(pFrame.frameId()) mID(pFrame.frameId())
{ {
unsigned char *data = reinterpret_cast<unsigned char *>(pFrame.payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(pFrame.payload().constData());
int dataLen = pFrame.payload().length(); int dataLen = pFrame.payload().length();
for (int i = 0; i < 0; i++) { for (int i = 0; i < 0; i++) {
@@ -117,7 +117,7 @@ void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq, bool mute)
mLastTime = mCurrentTime; mLastTime = mCurrentTime;
mCurrSeqVal = timeSeq; mCurrSeqVal = timeSeq;
unsigned char *data = reinterpret_cast<unsigned char *>(pFrame.payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(pFrame.payload().constData());
int dataLen = pFrame.payload().length(); int dataLen = pFrame.payload().length();
/* copy new value */ /* copy new value */
+4 -1
View File
@@ -354,7 +354,7 @@ void UDSScanWindow::gotUDSReply(UDS_MESSAGE msg)
int offset = ui->spinReplyOffset->value(); int offset = ui->spinReplyOffset->value();
UDS_MESSAGE sentFrame; UDS_MESSAGE sentFrame;
bool gotReply = false; bool gotReply = false;
unsigned char *data = reinterpret_cast<unsigned char *>(msg.payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(msg.payload().constData());
int dataLen = msg.payload().length(); int dataLen = msg.payload().length();
int numSending = sendingFrames.length(); int numSending = sendingFrames.length();
@@ -488,6 +488,9 @@ void UDSScanWindow::sendNextMsg()
else else
{ {
waitTimer->stop(); waitTimer->stop();
udsHandler->setReception(false);
udsHandler->setProcessAllIDs(false);
udsHandler->setFlowCtrl(false);
ui->btnScan->setText("Start Scan"); ui->btnScan->setText("Start Scan");
currentlyRunning = false; currentlyRunning = false;
} }
+2 -3
View File
@@ -255,7 +255,7 @@ void CANScriptHelper::gotTargettedFrame(const CANFrame &frame)
if (!gotFrameFunction.isCallable()) return; //nothing to do if we can't even call the function if (!gotFrameFunction.isCallable()) return; //nothing to do if we can't even call the function
//qDebug() << "Got frame in script interface"; //qDebug() << "Got frame in script interface";
unsigned char *data = reinterpret_cast<unsigned char *>(frame.payload().data()); const unsigned char *data = reinterpret_cast<const unsigned char *>(frame.payload().constData());
int dataLen = frame.payload().length(); int dataLen = frame.payload().length();
for (int i = 0; i < filters.length(); i++) for (int i = 0; i < filters.length(); i++)
@@ -310,14 +310,13 @@ void ISOTPScriptHelper::sendISOTP(QJSValue bus, QJSValue id, QJSValue length, QJ
msg.setFrameId(id.toUInt()); msg.setFrameId(id.toUInt());
msg.payload().resize(length.toInt()); msg.payload().resize(length.toInt());
unsigned char *data = reinterpret_cast<unsigned char *>(msg.payload().data());
int dataLen = msg.payload().length(); int dataLen = msg.payload().length();
if (!dataBytes.isArray()) qDebug() << "data isn't an array"; if (!dataBytes.isArray()) qDebug() << "data isn't an array";
for (int i = 0; i < dataLen; i++) for (int i = 0; i < dataLen; i++)
{ {
data[i] = static_cast<uint8_t>(dataBytes.property(i).toInt()); msg.payload()[i] = static_cast<int8_t>(dataBytes.property(i).toInt());
} }
msg.bus = bus.toInt(); msg.bus = bus.toInt();
+3
View File
@@ -185,6 +185,9 @@ public:
int64_t result = 0; int64_t result = 0;
int bit; int bit;
int maxBytes = (startBit + sigSize) / 8;
if (data.size() < maxBytes) return 0;
if (littleEndian) if (littleEndian)
{ {
bit = startBit; bit = startBit;