Converted more code to be easier to generalize to larger CAN payloads
for CAN-FD. Improved some code to be faster. Fixed up some compile time warnings.
This commit is contained in:
+3
-1
@@ -78,7 +78,7 @@ bool BLFHandler::loadBLF(QString filename, QVector<CANFrame>* frames)
|
||||
}
|
||||
qDebug() << "Uncompressed size: " << uncompressedData.count();
|
||||
pos = 0;
|
||||
bool foundHeader = false;
|
||||
//bool foundHeader = false;
|
||||
//first skip forward to find a header signature - usually not necessary
|
||||
while ( (int)(pos + sizeof(BLF_OBJ_HEADER)) < uncompressedData.count())
|
||||
{
|
||||
@@ -163,5 +163,7 @@ bool BLFHandler::loadBLF(QString filename, QVector<CANFrame>* frames)
|
||||
|
||||
bool BLFHandler::saveBLF(QString filename, QVector<CANFrame> *frames)
|
||||
{
|
||||
Q_UNUSED(filename)
|
||||
Q_UNUSED(frames)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ void ISOTP_HANDLER::setReception(bool mode)
|
||||
}
|
||||
}
|
||||
|
||||
void ISOTP_HANDLER::sendISOTPFrame(int bus, int ID, QVector<unsigned char> data)
|
||||
void ISOTP_HANDLER::sendISOTPFrame(int bus, int ID, QByteArray data)
|
||||
{
|
||||
CANFrame frame;
|
||||
frame.setFrameType(QCanBusFrame::DataFrame);
|
||||
@@ -159,6 +159,8 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
|
||||
//int offset;
|
||||
ISOTP_MESSAGE msg;
|
||||
ISOTP_MESSAGE *pMsg;
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(frame.payload().data());
|
||||
//int dataLen = frame.payload().count();
|
||||
|
||||
frameType = 0;
|
||||
frameLen = 0;
|
||||
@@ -166,14 +168,14 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
|
||||
if (useExtendedAddressing)
|
||||
{
|
||||
ID = ID << 8;
|
||||
ID += frame.payload()[0];
|
||||
frameType = frame.payload()[1] >> 4;
|
||||
frameLen = frame.payload()[1] & 0xF;
|
||||
ID += data[0];
|
||||
frameType = data[1] >> 4;
|
||||
frameLen = data[1] & 0xF;
|
||||
}
|
||||
else
|
||||
{
|
||||
frameType = frame.payload()[0] >> 4;
|
||||
frameLen = frame.payload()[0] & 0xF;
|
||||
frameType = data[0] >> 4;
|
||||
frameLen = data[0] & 0xF;
|
||||
}
|
||||
|
||||
switch(frameType)
|
||||
@@ -186,42 +188,42 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
|
||||
if (frameLen > 7) return;
|
||||
|
||||
msg.bus = frame.bus;
|
||||
msg.extended = frame.hasExtendedFrameFormat();
|
||||
msg.ID = ID;
|
||||
msg.setExtendedFrameFormat( frame.hasExtendedFrameFormat() );
|
||||
msg.setFrameId(ID);
|
||||
msg.isReceived = frame.isReceived;
|
||||
msg.len = frameLen;
|
||||
msg.data.reserve(frameLen);
|
||||
msg.timestamp = frame.timeStamp().microSeconds();
|
||||
msg.payload().reserve(frameLen);
|
||||
msg.reportedLength = frameLen;
|
||||
msg.setTimeStamp(frame.timeStamp());
|
||||
msg.isMultiframe = false;
|
||||
if (useExtendedAddressing) for (int j = 0; j < frameLen; j++) msg.data.append(frame.payload()[j+2]);
|
||||
else for (int j = 0; j < frameLen; j++) msg.data.append(frame.payload()[j+1]);
|
||||
if (useExtendedAddressing) for (int j = 0; j < frameLen; j++) msg.payload().append(frame.payload()[j+2]);
|
||||
else for (int j = 0; j < frameLen; j++) msg.payload().append(frame.payload()[j+1]);
|
||||
//qDebug() << "Emitting single frame ISOTP message";
|
||||
emit newISOMessage(msg);
|
||||
break;
|
||||
case 1: //first frame of a multi-frame message
|
||||
checkNeedFlush(ID);
|
||||
msg.bus = frame.bus;
|
||||
msg.extended = frame.hasExtendedFrameFormat();
|
||||
msg.ID = ID;
|
||||
msg.timestamp = frame.timeStamp().microSeconds();
|
||||
msg.setExtendedFrameFormat( frame.hasExtendedFrameFormat() );
|
||||
msg.setFrameId(ID);
|
||||
msg.setTimeStamp(frame.timeStamp());
|
||||
msg.isReceived = frame.isReceived;
|
||||
msg.isMultiframe = true;
|
||||
frameLen = frameLen << 8;
|
||||
if (useExtendedAddressing)
|
||||
{
|
||||
frameLen += frame.payload()[2];
|
||||
frameLen += data[2];
|
||||
frameLen = frameLen & 0xFFF;
|
||||
msg.len = frameLen;
|
||||
msg.data.reserve(frameLen);
|
||||
for (int j = 0; j < 5; j++) msg.data.append(frame.payload()[3 + j]);
|
||||
msg.payload().reserve(frameLen);
|
||||
msg.reportedLength = frameLen;
|
||||
for (int j = 0; j < 5; j++) msg.payload().append(frame.payload()[3 + j]);
|
||||
}
|
||||
else
|
||||
{
|
||||
frameLen += frame.payload()[1];
|
||||
frameLen += data[1];
|
||||
frameLen = frameLen & 0xFFF;
|
||||
msg.len = frameLen;
|
||||
msg.data.reserve(frameLen);
|
||||
for (int j = 0; j < 6; j++) msg.data.append(frame.payload()[2 + j]);
|
||||
msg.payload().reserve(frameLen);
|
||||
msg.reportedLength = frameLen;
|
||||
for (int j = 0; j < 6; j++) msg.payload().append(frame.payload()[2 + j]);
|
||||
}
|
||||
msg.lastSequence = -1;
|
||||
messageBuffer.append(msg);
|
||||
@@ -245,7 +247,7 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
|
||||
pMsg = nullptr;
|
||||
for (int i = 0; i < messageBuffer.length(); i++)
|
||||
{
|
||||
if (messageBuffer[i].ID == ID)
|
||||
if (messageBuffer[i].frameId() == ID)
|
||||
{
|
||||
pMsg = &messageBuffer[i];
|
||||
break;
|
||||
@@ -253,22 +255,22 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
|
||||
}
|
||||
if (!pMsg) return;
|
||||
if (!pMsg->isMultiframe) return; //if we didn't get a frame type 1 (start of multiframe) first then ignore this frame.
|
||||
ln = pMsg->len - pMsg->data.count();
|
||||
ln = pMsg->payload().length() - pMsg->payload().count();
|
||||
//offset = pMsg->data.count();
|
||||
if (useExtendedAddressing)
|
||||
{
|
||||
if (ln > 6) ln = 6;
|
||||
for (int j = 0; j < ln; j++) pMsg->data.append(frame.payload()[j+2]);
|
||||
for (int j = 0; j < ln; j++) pMsg->payload().append(frame.payload()[j+2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ln > 7) ln = 7;
|
||||
for (int j = 0; j < ln; j++) pMsg->data.append(frame.payload()[j+1]);
|
||||
for (int j = 0; j < ln; j++) pMsg->payload().append(frame.payload()[j+1]);
|
||||
}
|
||||
if (pMsg->len <= pMsg->data.count())
|
||||
if (pMsg->reportedLength <= pMsg->payload().count())
|
||||
{
|
||||
//qDebug() << "Emitting multiframe ISOTP message";
|
||||
checkNeedFlush(pMsg->ID);
|
||||
checkNeedFlush(pMsg->frameId());
|
||||
}
|
||||
break;
|
||||
case 3: //flow control messages
|
||||
@@ -277,10 +279,10 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
|
||||
case 0: //continue to send frames but maybe change inter-frame delay
|
||||
waitingForFlow = false;
|
||||
//data[1] contains number of frames to send before waiting for next flow control
|
||||
framesUntilFlow = frame.payload()[1];
|
||||
framesUntilFlow = data[1];
|
||||
if (framesUntilFlow == 0) framesUntilFlow = -1; //-1 means don't count frames and just keep going
|
||||
//data[2] contains the interframe delay to use (0xF1 through 0xF9 are special through)
|
||||
if (frame.payload()[2] < (char)0xF1) frameTimer.start(frame.payload()[2]); //set proper delay between frames
|
||||
if (data[2] < 0xF1) frameTimer.start(data[2]); //set proper delay between frames
|
||||
else frameTimer.start(1); //can't do sub-millisecond sending with this code so just use 1ms timing
|
||||
break;
|
||||
case 1: //wait - do not send any more frames until other side says so
|
||||
@@ -303,18 +305,18 @@ void ISOTP_HANDLER::checkNeedFlush(uint64_t ID)
|
||||
{
|
||||
for (int i = 0; i < messageBuffer.length(); i++)
|
||||
{
|
||||
if (messageBuffer[i].ID == ID)
|
||||
if (messageBuffer[i].frameId() == ID)
|
||||
{
|
||||
//used to pass by reference but now newISOMessage should pass by value which makes it easier to use cross thread
|
||||
if (messageBuffer[i].ID > 0x600 && messageBuffer[i].ID < 0x630)
|
||||
if (messageBuffer[i].frameId() > 0x600 && messageBuffer[i].frameId() < 0x630)
|
||||
{
|
||||
if (messageBuffer[i].len <= messageBuffer[i].data.count())
|
||||
if (messageBuffer[i].reportedLength <= messageBuffer[i].payload().count())
|
||||
{
|
||||
qDebug() << "Flushing full frame" << QString::number(messageBuffer[i].ID, 16) << " " << messageBuffer[i].len << " " << messageBuffer[i].data.count();
|
||||
qDebug() << "Flushing full frame" << QString::number(messageBuffer[i].frameId(), 16) << " " << messageBuffer[i].reportedLength << " " << messageBuffer[i].payload().count();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Flushing a partial frame " << QString::number(messageBuffer[i].ID, 16) << " " << messageBuffer[i].len << " " << messageBuffer[i].data.count();
|
||||
qDebug() << "Flushing a partial frame " << QString::number(messageBuffer[i].frameId(), 16) << " " << messageBuffer[i].reportedLength << " " << messageBuffer[i].payload().count();
|
||||
}
|
||||
}
|
||||
emit newISOMessage(messageBuffer[i]);
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
~ISOTP_HANDLER();
|
||||
void setExtendedAddressing(bool mode);
|
||||
void setReception(bool mode); //set whether to accept and forward frames or not
|
||||
void sendISOTPFrame(int bus, int ID, QVector<unsigned char> data);
|
||||
void sendISOTPFrame(int bus, int ID, QByteArray data);
|
||||
void setProcessAll(bool state);
|
||||
void setFlowCtrl(bool state);
|
||||
void addFilter(uint32_t pBusId, uint32_t ID, uint32_t mask);
|
||||
|
||||
@@ -3,21 +3,16 @@
|
||||
|
||||
#include <Qt>
|
||||
#include <QVector>
|
||||
#include <can_structs.h>
|
||||
|
||||
//the same as the CANFrame struct but with arbitrary data size.
|
||||
class ISOTP_MESSAGE
|
||||
//Now a child class of CANFrame. We just add the ability to track how long it was supposed to be and other
|
||||
//ISOTP related details. But, mostly just CANFrame.
|
||||
class ISOTP_MESSAGE : public CANFrame
|
||||
{
|
||||
public:
|
||||
uint32_t ID;
|
||||
int bus;
|
||||
bool extended;
|
||||
bool isReceived;
|
||||
int len; //# of bytes this message should have (as reported)
|
||||
int actualSize; //# we actually got
|
||||
int reportedLength;
|
||||
int lastSequence;
|
||||
bool isMultiframe;
|
||||
QVector<unsigned char> data;
|
||||
uint64_t timestamp;
|
||||
};
|
||||
|
||||
#endif // ISOTP_MESSAGE_H
|
||||
|
||||
@@ -158,7 +158,6 @@ UDS_MESSAGE::UDS_MESSAGE()
|
||||
subFunc = 0;
|
||||
service = 0;
|
||||
subFuncLen = 1;
|
||||
extended = false;
|
||||
isErrorReply = false;
|
||||
}
|
||||
|
||||
@@ -178,39 +177,39 @@ UDS_HANDLER::~UDS_HANDLER()
|
||||
void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
|
||||
{
|
||||
qDebug() << "UDS handler got ISOTP frame";
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(msg.payload().data());
|
||||
int dataLen = msg.payload().count();
|
||||
UDS_MESSAGE udsMsg;
|
||||
udsMsg.bus = msg.bus;
|
||||
udsMsg.extended = msg.extended;
|
||||
udsMsg.ID = msg.ID;
|
||||
udsMsg.setExtendedFrameFormat(msg.hasExtendedFrameFormat());
|
||||
udsMsg.setFrameId(msg.frameId());
|
||||
udsMsg.isReceived = msg.isReceived;
|
||||
udsMsg.timestamp = msg.timestamp;
|
||||
udsMsg.actualSize = msg.actualSize;
|
||||
udsMsg.setTimeStamp(msg.timeStamp());
|
||||
udsMsg.reportedLength = msg.reportedLength;
|
||||
udsMsg.service = 0;
|
||||
udsMsg.subFunc = 0;
|
||||
udsMsg.subFuncLen = 0;
|
||||
udsMsg.isErrorReply = false;
|
||||
udsMsg.len = msg.len;
|
||||
if (msg.data.length() > 0) {
|
||||
udsMsg.service = msg.data.at(0);
|
||||
udsMsg.setPayload(msg.payload());
|
||||
if (dataLen > 0) {
|
||||
udsMsg.service = data[0];
|
||||
if (udsMsg.service == 0x7F)
|
||||
{
|
||||
udsMsg.isErrorReply = true;
|
||||
if (msg.data.length() > 1)
|
||||
if (dataLen > 1)
|
||||
{
|
||||
udsMsg.service = msg.data.at(1);
|
||||
if (msg.data.length() > 2) udsMsg.subFunc = msg.data.at(2);
|
||||
udsMsg.service = data[1];
|
||||
if (dataLen > 2) udsMsg.subFunc = data[2];
|
||||
else return;
|
||||
}
|
||||
else return;
|
||||
udsMsg.data = msg.data.mid(2, -1); //don't copy error byte nor service byte
|
||||
udsMsg.len -= 2; //and remove those bytes from the length reported too.
|
||||
udsMsg.payload().remove(0, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
udsMsg.isErrorReply = false;
|
||||
if (msg.data.length() > 1) udsMsg.subFunc = msg.data.at(1);
|
||||
udsMsg.data = msg.data.mid(1, -1); //don't copy service byte
|
||||
udsMsg.len -= 1; //and remove service byte from length too.
|
||||
if (dataLen > 1) udsMsg.subFunc = data[1];
|
||||
udsMsg.payload().remove(0, 1);
|
||||
}
|
||||
}
|
||||
else return;
|
||||
@@ -245,7 +244,7 @@ void UDS_HANDLER::setReception(bool mode)
|
||||
|
||||
void UDS_HANDLER::sendUDSFrame(const UDS_MESSAGE &msg)
|
||||
{
|
||||
QVector<unsigned char> data;
|
||||
QByteArray data;
|
||||
if (msg.bus < 0) return;
|
||||
if (msg.bus >= CANConManager::getInstance()->getNumBuses()) return;
|
||||
if (msg.service > 0xFF) return;
|
||||
@@ -256,8 +255,8 @@ void UDS_HANDLER::sendUDSFrame(const UDS_MESSAGE &msg)
|
||||
data.append((msg.subFunc >> (8 * b)) & 0xFF);
|
||||
}
|
||||
|
||||
data.append(msg.data);
|
||||
isoHandler->sendISOTPFrame(msg.bus, msg.ID, data);
|
||||
data.append(msg.payload());
|
||||
isoHandler->sendISOTPFrame(msg.bus, msg.frameId(), data);
|
||||
|
||||
qDebug() << "Sent UDS service: " << getServiceShortDesc(msg.service) << " on bus " << msg.bus;
|
||||
}
|
||||
@@ -328,6 +327,8 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
|
||||
bool isResponse = true;
|
||||
int dataSize;
|
||||
int addrSize;
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(msg.payload().data());
|
||||
int dataLen = msg.payload().length();
|
||||
|
||||
if (msg.isErrorReply)
|
||||
{
|
||||
@@ -363,15 +364,15 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
|
||||
case UDS_SERVICES::DIAG_CONTROL + 0x40: //positive response
|
||||
buildString.append("Session Request: " + getLongDesc(UDS_DIAG_CTRL_SUB, msg.subFunc));
|
||||
//there should be four extra bytes now
|
||||
if (msg.data.length() < 5) //5 because subfunc codes are left in data so it starts with one subfunc byte
|
||||
if (dataLen < 5) //5 because subfunc codes are left in data so it starts with one subfunc byte
|
||||
{
|
||||
//buildString.append("\nReturned data payload wasn't at least \n4 bytes like it should have been");
|
||||
}
|
||||
else
|
||||
{
|
||||
int p2 = msg.data[1] * 256 + msg.data[2];
|
||||
int p2 = data[1] * 256 + data[2];
|
||||
buildString.append("\nP2MAX (Max Wait / Resp Time): " + QString::number(p2) + "ms");
|
||||
p2 = (msg.data[3] * 256 + msg.data[4]) * 10;
|
||||
p2 = (data[3] * 256 + data[4]) * 10;
|
||||
buildString.append("\nP2 Ext MAX: " + QString::number(p2) + "ms");
|
||||
}
|
||||
break;
|
||||
@@ -382,11 +383,11 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
|
||||
case UDS_SERVICES::ECU_RESET + 0x40:
|
||||
buildString.append("Reset Type: " + getLongDesc(UDS_ECU_RESET_SUB, msg.subFunc));
|
||||
//There should be one additional byte which encodes power down time
|
||||
if (msg.data.length() > 1)
|
||||
if (dataLen > 1)
|
||||
{
|
||||
if (msg.data[1] < 0xFF)
|
||||
if (data[1] < 0xFF)
|
||||
{
|
||||
buildString.append("\nMinimum powered down time: " + QString::number(msg.data[1]));
|
||||
buildString.append("\nMinimum powered down time: " + QString::number(data[1]));
|
||||
}
|
||||
else buildString.append("\nPowerdown time not available");
|
||||
}
|
||||
@@ -395,11 +396,11 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
|
||||
case UDS_SERVICES::COMM_CTRL:
|
||||
//Comm control has potentially a lot of parameters. control type, comm type, nodeID
|
||||
buildString.append("Control type: " + getLongDesc(UDS_COMM_CTRL_SUB, msg.subFunc));
|
||||
if (msg.data.length() > 1)
|
||||
buildString.append("\nComm Type: " + QString::number(msg.data[1])); //TODO: no attempt to interpret yet
|
||||
if (msg.data.length() > 3)
|
||||
if (dataLen > 1)
|
||||
buildString.append("\nComm Type: " + QString::number(data[1])); //TODO: no attempt to interpret yet
|
||||
if (dataLen > 3)
|
||||
{
|
||||
int nodeID = (msg.data[2] * 256 + msg.data[3]);
|
||||
int nodeID = (data[2] * 256 + data[3]);
|
||||
buildString.append("\nNode ID: " + Utility::formatHexNum(nodeID));
|
||||
}
|
||||
break;
|
||||
@@ -407,19 +408,19 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
|
||||
if ((msg.subFunc % 2) == 1)
|
||||
{
|
||||
buildString.append("Seed request for security level: " + QString::number(msg.subFunc) + "\n");
|
||||
if (msg.data.length()> 1)
|
||||
if (dataLen > 1)
|
||||
{
|
||||
buildString.append("Data payload: ");
|
||||
for (int j = 1; j < msg.data.length(); j++) buildString.append(Utility::formatHexNum(msg.data[j]) + " ");
|
||||
for (int j = 1; j < dataLen; j++) buildString.append(Utility::formatHexNum(data[j]) + " ");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buildString.append("Key sending for security level: " + QString::number(msg.subFunc - 1));
|
||||
if (msg.data.length()> 1) //and it sure as hell should be!
|
||||
if (dataLen > 1) //and it sure as hell should be!
|
||||
{
|
||||
buildString.append("KEY: ");
|
||||
for (int j = 1; j < msg.data.length(); j++) buildString.append(Utility::formatHexNum(msg.data[j]) + " ");
|
||||
for (int j = 1; j < dataLen; j++) buildString.append(Utility::formatHexNum(data[j]) + " ");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -427,10 +428,10 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
|
||||
if ((msg.subFunc % 2) == 1)
|
||||
{
|
||||
buildString.append("Seed response for security level: " + QString::number(msg.subFunc) + "\n");
|
||||
if (msg.data.length()> 1) //be kinda pointless if it weren't
|
||||
if (dataLen > 1) //be kinda pointless if it weren't
|
||||
{
|
||||
buildString.append("SEED: ");
|
||||
for (int j = 1; j < msg.data.length(); j++) buildString.append(Utility::formatHexNum(msg.data[j]) + " ");
|
||||
for (int j = 1; j < dataLen; j++) buildString.append(Utility::formatHexNum(data[j]) + " ");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -441,33 +442,33 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
|
||||
break;
|
||||
case UDS_SERVICES::READ_BY_ID:
|
||||
//parameter is groups of two bytes, each of which specify an ID to read
|
||||
if (msg.data.length() > 2)
|
||||
if (dataLen > 2)
|
||||
{
|
||||
uint32_t id;
|
||||
for (int i = 1; i < msg.data.length(); i = i + 2)
|
||||
for (int i = 1; i < dataLen; i = i + 2)
|
||||
{
|
||||
id = (msg.data[i] * 256) + msg.data[i+1];
|
||||
id = (data[i] * 256) + data[i+1];
|
||||
buildString.append("\nID to read: " + Utility::formatHexNum(id));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case UDS_SERVICES::READ_BY_ID + 0x40: //reply
|
||||
buildString.append("Reply is non-standard and so no decoding is done. The format is (ID) followed by how ever much data that ID returns, followed by more ID/data pairs if applicable.\nPayload: ");
|
||||
for (int i = 1; i < msg.data.length(); i++)
|
||||
for (int i = 1; i < dataLen; i++)
|
||||
{
|
||||
buildString.append(Utility::formatHexNum(msg.data[i]) + " ");
|
||||
buildString.append(Utility::formatHexNum(data[i]) + " ");
|
||||
}
|
||||
break;
|
||||
case UDS_SERVICES::READ_BY_ADDR:
|
||||
//subfunc byte specifies address and length format, then address, then size
|
||||
dataSize = msg.subFunc >> 4;
|
||||
addrSize = msg.subFunc & 0xF;
|
||||
if (msg.data.length() > (dataSize + addrSize))
|
||||
if (dataLen > (dataSize + addrSize))
|
||||
{
|
||||
buildString.append("Address: 0x");
|
||||
for (int i = 0; i < addrSize; i++) buildString.append(QString::number(msg.data[1+i], 16).toUpper().rightJustified(2,'0'));
|
||||
for (int i = 0; i < addrSize; i++) buildString.append(QString::number(data[1+i], 16).toUpper().rightJustified(2,'0'));
|
||||
buildString.append("\nSize: 0x");
|
||||
for (int i = 0; i < dataSize; i++) buildString.append(QString::number(msg.data[1+i+addrSize], 16).toUpper().rightJustified(2,'0'));
|
||||
for (int i = 0; i < dataSize; i++) buildString.append(QString::number(data[1+i+addrSize], 16).toUpper().rightJustified(2,'0'));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -476,44 +477,44 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
|
||||
break;
|
||||
case UDS_SERVICES::READ_BY_ADDR + 0x40:
|
||||
buildString.append("Reply is a raw packet of data of the size requested.\nPayload: ");
|
||||
for (int i = 1; i < msg.data.length(); i++)
|
||||
for (int i = 1; i < dataLen; i++)
|
||||
{
|
||||
buildString.append(Utility::formatHexNum(msg.data[i]) + " ");
|
||||
buildString.append(Utility::formatHexNum(data[i]) + " ");
|
||||
}
|
||||
break;
|
||||
case UDS_SERVICES::WRITE_BY_ID:
|
||||
break;
|
||||
case UDS_SERVICES::ROUTINE_CTRL:
|
||||
buildString.append("Routine Control: " + getLongDesc(UDS_ROUTINE_SUB, msg.subFunc));
|
||||
if (msg.data.length() > 2)
|
||||
if (dataLen > 2)
|
||||
{
|
||||
int routineID;
|
||||
routineID = (msg.data[1] * 256 + msg.data[2]);
|
||||
routineID = (data[1] * 256 + data[2]);
|
||||
buildString.append("\nRoutine ID: " + Utility::formatHexNum(routineID));
|
||||
}
|
||||
if (msg.data.length() > 3)
|
||||
if (dataLen > 3)
|
||||
{
|
||||
buildString.append("\nParameter bytes to routine: ");
|
||||
for (int i = 4; i < msg.data.length(); i++)
|
||||
for (int i = 4; i < dataLen; i++)
|
||||
{
|
||||
buildString.append(Utility::formatHexNum(msg.data[i]) + " ");
|
||||
buildString.append(Utility::formatHexNum(data[i]) + " ");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case UDS_SERVICES::ROUTINE_CTRL + 0x40:
|
||||
buildString.append("Routine Control: " + getLongDesc(UDS_ROUTINE_SUB, msg.subFunc));
|
||||
if (msg.data.length() > 2)
|
||||
if (dataLen > 2)
|
||||
{
|
||||
int routineID;
|
||||
routineID = (msg.data[1] * 256 + msg.data[2]);
|
||||
routineID = (data[1] * 256 + data[2]);
|
||||
buildString.append("\nRoutine ID: " + Utility::formatHexNum(routineID));
|
||||
}
|
||||
if (msg.data.length() > 3)
|
||||
if (dataLen > 3)
|
||||
{
|
||||
buildString.append("\nBytes returned by routine: ");
|
||||
for (int i = 4; i < msg.data.length(); i++)
|
||||
for (int i = 4; i < dataLen; i++)
|
||||
{
|
||||
buildString.append(Utility::formatHexNum(msg.data[i]) + " ");
|
||||
buildString.append(Utility::formatHexNum(data[i]) + " ");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
+15
-16
@@ -347,7 +347,6 @@ void CANFrameModel::recalcOverwrite()
|
||||
|
||||
QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
int dLen;
|
||||
QString tempString;
|
||||
CANFrame thisFrame;
|
||||
static bool rowFlip = false;
|
||||
@@ -361,6 +360,9 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
thisFrame = filteredFrames.at(index.row());
|
||||
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(thisFrame.payload().data());
|
||||
int dataLen = thisFrame.payload().count();
|
||||
|
||||
if (role == Qt::BackgroundColorRole)
|
||||
{
|
||||
if (dbcHandler != nullptr && interpretFrames)
|
||||
@@ -422,7 +424,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
case Column::Bus:
|
||||
return QString::number(thisFrame.bus);
|
||||
case Column::Length:
|
||||
return QString::number(thisFrame.payload().length());
|
||||
return QString::number(dataLen);
|
||||
case Column::ASCII:
|
||||
if (thisFrame.frameId() >= 0x7FFFFFF0ull)
|
||||
{
|
||||
@@ -430,32 +432,29 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
tempString.append(QString::number(thisFrame.frameId() & 0x7));
|
||||
return tempString;
|
||||
}
|
||||
dLen = thisFrame.payload().length();
|
||||
if (!thisFrame.frameType() != QCanBusFrame::RemoteRequestFrame) {
|
||||
if (dLen < 0) dLen = 0;
|
||||
if (dLen > 8) dLen = 8;
|
||||
for (int i = 0; i < dLen; i++)
|
||||
if (thisFrame.frameType() != QCanBusFrame::RemoteRequestFrame) {
|
||||
if (dataLen < 0) dataLen = 0;
|
||||
//if (dLen > 8) dLen = 8;
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
quint8 byt = thisFrame.payload()[i];
|
||||
char byt = thisFrame.payload()[i];
|
||||
//0x20 through 0x7E are printable characters. Outside of that range they aren't. So use dots instead
|
||||
if (byt < 0x20) byt = 0x2E; //dot character
|
||||
if (byt > 0x7E) byt = 0x2E;
|
||||
tempString.append(QString::fromUtf8((char *)&byt, 1));
|
||||
tempString.append(QString::fromUtf8(&byt, 1));
|
||||
}
|
||||
}
|
||||
return tempString;
|
||||
case Column::Data:
|
||||
dLen = thisFrame.payload().length();
|
||||
if (dLen < 0) dLen = 0;
|
||||
if (dLen > 8) dLen = 8;
|
||||
if (dataLen < 0) dataLen = 0;
|
||||
//if (useHexMode) tempString.append("0x ");
|
||||
if (thisFrame.frameType() == QCanBusFrame::RemoteRequestFrame) {
|
||||
return tempString;
|
||||
}
|
||||
for (int i = 0; i < dLen; i++)
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
if (useHexMode) tempString.append( QString::number((unsigned char)thisFrame.payload()[i], 16).toUpper().rightJustified(2, '0'));
|
||||
else tempString.append(QString::number(thisFrame.payload()[i], 10));
|
||||
if (useHexMode) tempString.append( QString::number(data[i], 16).toUpper().rightJustified(2, '0'));
|
||||
else tempString.append(QString::number(data[i], 10));
|
||||
tempString.append(" ");
|
||||
}
|
||||
//now, if we're supposed to interpret the data and the DBC handler is loaded then use it
|
||||
@@ -740,7 +739,7 @@ void CANFrameModel::insertFrames(const QVector<CANFrame> &newFrames)
|
||||
int CANFrameModel::getIndexFromTimeID(unsigned int ID, double timestamp)
|
||||
{
|
||||
int bestIndex = -1;
|
||||
uint64_t intTimeStamp = timestamp * 1000000l;
|
||||
int64_t intTimeStamp = static_cast<int64_t> (timestamp * 1000000l);
|
||||
for (int i = 0; i < frames.count(); i++)
|
||||
{
|
||||
if ((frames[i].frameId() == ID))
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ private:
|
||||
bool timeSeconds;
|
||||
bool useSystemTime;
|
||||
bool needFilterRefresh;
|
||||
uint64_t timeOffset;
|
||||
int64_t timeOffset;
|
||||
int lastUpdateNumFrames;
|
||||
uint32_t preallocSize;
|
||||
bool sortDirAsc;
|
||||
|
||||
@@ -70,10 +70,10 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const
|
||||
//qDebug() << "Row: " << index.row();
|
||||
|
||||
CANConnection *conn_p = getAtIdx(index.row());
|
||||
bool ret;
|
||||
|
||||
if (!conn_p) return QVariant();
|
||||
|
||||
bool isSocketCAN = (conn_p->getType() == CANCon::SERIALBUS) ? true: false;
|
||||
//bool isSocketCAN = (conn_p->getType() == CANCon::SERIALBUS) ? true: false;
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
|
||||
@@ -147,6 +147,8 @@ CANConnection* CANConnectionModel::getAtIdx(int pIdx) const
|
||||
|
||||
void CANConnectionModel::refresh(int pIndex)
|
||||
{
|
||||
Q_UNUSED(pIndex)
|
||||
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
/*
|
||||
|
||||
@@ -312,8 +312,8 @@ void ConnectionWindow::populateBusDetails(int offset)
|
||||
}
|
||||
else
|
||||
{
|
||||
bool ret;
|
||||
int numBuses;
|
||||
//bool ret;
|
||||
//int numBuses;
|
||||
|
||||
CANConnection* conn_p = connModel->getAtIdx(selIdx);
|
||||
CANBus bus;
|
||||
@@ -365,7 +365,7 @@ void ConnectionWindow::currentRowChanged(const QModelIndex ¤t, const QMode
|
||||
}
|
||||
else
|
||||
{
|
||||
bool ret;
|
||||
//bool ret;
|
||||
ui->groupBus->setEnabled(true);
|
||||
int numBuses;
|
||||
|
||||
|
||||
+30
-30
@@ -192,14 +192,14 @@ void GVRetSerial::piSetBusSettings(int pBusIdx, CANBus bus)
|
||||
sendDebug("Got signal to update bauds. 1: " + QString::number((can0Baud & 0xFFFFFFF)) + " 2: " + QString::number((can1Baud & 0xFFFFFFF)));
|
||||
buffer[0] = (char)0xF1; //start of a command over serial
|
||||
buffer[1] = 5; //setup canbus
|
||||
buffer[2] = (unsigned char)(can0Baud & 0xFF); //four bytes of ID LSB first
|
||||
buffer[3] = (unsigned char)(can0Baud >> 8);
|
||||
buffer[4] = (unsigned char)(can0Baud >> 16);
|
||||
buffer[5] = (unsigned char)(can0Baud >> 24);
|
||||
buffer[6] = (unsigned char)(can1Baud & 0xFF); //four bytes of ID LSB first
|
||||
buffer[7] = (unsigned char)(can1Baud >> 8);
|
||||
buffer[8] = (unsigned char)(can1Baud >> 16);
|
||||
buffer[9] = (unsigned char)(can1Baud >> 24);
|
||||
buffer[2] = (char)(can0Baud & 0xFF); //four bytes of ID LSB first
|
||||
buffer[3] = (char)(can0Baud >> 8);
|
||||
buffer[4] = (char)(can0Baud >> 16);
|
||||
buffer[5] = (char)(can0Baud >> 24);
|
||||
buffer[6] = (char)(can1Baud & 0xFF); //four bytes of ID LSB first
|
||||
buffer[7] = (char)(can1Baud >> 8);
|
||||
buffer[8] = (char)(can1Baud >> 16);
|
||||
buffer[9] = (char)(can1Baud >> 24);
|
||||
buffer[10] = 0;
|
||||
sendToSerial(buffer);
|
||||
}
|
||||
@@ -210,18 +210,18 @@ void GVRetSerial::piSetBusSettings(int pBusIdx, CANBus bus)
|
||||
sendDebug("Got signal to update extended bus speeds SWCAN: " + QString::number(swcanBaud) + " LIN1: " + QString::number(lin1Baud) + " LIN2: " + QString::number(lin2Baud));
|
||||
buffer[0] = (char)0xF1; //start of a command over serial
|
||||
buffer[1] = 14; //setup extended buses
|
||||
buffer[2] = (unsigned char)(swcanBaud & 0xFF); //four bytes of ID LSB first
|
||||
buffer[3] = (unsigned char)(swcanBaud >> 8);
|
||||
buffer[4] = (unsigned char)(swcanBaud >> 16);
|
||||
buffer[5] = (unsigned char)(swcanBaud >> 24);
|
||||
buffer[6] = (unsigned char)(lin1Baud & 0xFF); //four bytes of ID LSB first
|
||||
buffer[7] = (unsigned char)(lin1Baud >> 8);
|
||||
buffer[8] = (unsigned char)(lin1Baud >> 16);
|
||||
buffer[9] = (unsigned char)(lin1Baud >> 24);
|
||||
buffer[10] = (unsigned char)(lin2Baud & 0xFF); //four bytes of ID LSB first
|
||||
buffer[11] = (unsigned char)(lin2Baud >> 8);
|
||||
buffer[12] = (unsigned char)(lin2Baud >> 16);
|
||||
buffer[13] = (unsigned char)(lin2Baud >> 24);
|
||||
buffer[2] = (char)(swcanBaud & 0xFF); //four bytes of ID LSB first
|
||||
buffer[3] = (char)(swcanBaud >> 8);
|
||||
buffer[4] = (char)(swcanBaud >> 16);
|
||||
buffer[5] = (char)(swcanBaud >> 24);
|
||||
buffer[6] = (char)(lin1Baud & 0xFF); //four bytes of ID LSB first
|
||||
buffer[7] = (char)(lin1Baud >> 8);
|
||||
buffer[8] = (char)(lin1Baud >> 16);
|
||||
buffer[9] = (char)(lin1Baud >> 24);
|
||||
buffer[10] = (char)(lin2Baud & 0xFF); //four bytes of ID LSB first
|
||||
buffer[11] = (char)(lin2Baud >> 8);
|
||||
buffer[12] = (char)(lin2Baud >> 16);
|
||||
buffer[13] = (char)(lin2Baud >> 24);
|
||||
buffer[14] = 0;
|
||||
sendToSerial(buffer);
|
||||
}
|
||||
@@ -231,8 +231,8 @@ void GVRetSerial::piSetBusSettings(int pBusIdx, CANBus bus)
|
||||
bool GVRetSerial::piSendFrame(const CANFrame& frame)
|
||||
{
|
||||
QByteArray buffer;
|
||||
unsigned int c;
|
||||
int ID;
|
||||
int c;
|
||||
quint32 ID;
|
||||
|
||||
//qDebug() << "Sending out GVRET frame with id " << frame.ID << " on bus " << frame.bus;
|
||||
|
||||
@@ -250,16 +250,16 @@ bool GVRetSerial::piSendFrame(const CANFrame& frame)
|
||||
return true;
|
||||
}
|
||||
ID = frame.frameId();
|
||||
if (frame.hasExtendedFrameFormat()) ID |= 1 << 31;
|
||||
if (frame.hasExtendedFrameFormat()) ID |= 1u << 31;
|
||||
|
||||
buffer[0] = (unsigned char)0xF1; //start of a command over serial
|
||||
buffer[0] = (char)0xF1; //start of a command over serial
|
||||
buffer[1] = 0; //command ID for sending a CANBUS frame
|
||||
buffer[2] = (unsigned char)(ID & 0xFF); //four bytes of ID LSB first
|
||||
buffer[3] = (unsigned char)(ID >> 8);
|
||||
buffer[4] = (unsigned char)(ID >> 16);
|
||||
buffer[5] = (unsigned char)(ID >> 24);
|
||||
buffer[6] = (unsigned char)((frame.bus) & 3);
|
||||
buffer[7] = (unsigned char)frame.payload().length();
|
||||
buffer[2] = (char)(ID & 0xFF); //four bytes of ID LSB first
|
||||
buffer[3] = (char)(ID >> 8);
|
||||
buffer[4] = (char)(ID >> 16);
|
||||
buffer[5] = (char)(ID >> 24);
|
||||
buffer[6] = (char)((frame.bus) & 3);
|
||||
buffer[7] = (char)frame.payload().length();
|
||||
for (c = 0; c < frame.payload().length(); c++)
|
||||
{
|
||||
buffer[8 + c] = frame.payload()[c];
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o
|
||||
QString buildString;
|
||||
int startByte = startBit / 8;
|
||||
int bytes = signalSize / 8;
|
||||
for (int x = 0; x < bytes; x++) buildString.append((char)frame.payload()[startByte + x]);
|
||||
for (int x = 0; x < bytes; x++) buildString.append(frame.payload().data()[startByte + x]);
|
||||
outString = buildString;
|
||||
cachedValue = outString;
|
||||
return true;
|
||||
|
||||
+6
-6
@@ -22,22 +22,22 @@ QString FilterUtility::getId( QListWidgetItem * item )
|
||||
return getId(item->text());
|
||||
}
|
||||
|
||||
uint32_t FilterUtility::getGMLanArbitrationId(uint32_t id)
|
||||
uint32_t FilterUtility::getGMLanArbitrationId(int32_t id)
|
||||
{
|
||||
return (id >> 13) & 0x1FFF;
|
||||
}
|
||||
|
||||
uint32_t FilterUtility::getGMLanPriorityBits(uint32_t id)
|
||||
uint32_t FilterUtility::getGMLanPriorityBits(int32_t id)
|
||||
{
|
||||
return (id >> 26) & 0x7;
|
||||
}
|
||||
|
||||
uint32_t FilterUtility::getGMLanSenderId(uint32_t id)
|
||||
uint32_t FilterUtility::getGMLanSenderId(int32_t id)
|
||||
{
|
||||
return id & 0x1FFF;
|
||||
}
|
||||
|
||||
QListWidgetItem * FilterUtility::createCheckableFilterItem(uint32_t id, bool checked, QListWidget* parent)
|
||||
QListWidgetItem * FilterUtility::createCheckableFilterItem(int32_t id, bool checked, QListWidget* parent)
|
||||
{
|
||||
QListWidgetItem * thisItem = createFilterItem(id,parent);
|
||||
thisItem->setFlags(thisItem->flags() | Qt::ItemIsUserCheckable);
|
||||
@@ -48,7 +48,7 @@ QListWidgetItem * FilterUtility::createCheckableFilterItem(uint32_t id, bool che
|
||||
return thisItem;
|
||||
}
|
||||
|
||||
QListWidgetItem * FilterUtility::createFilterItem(uint32_t id, QListWidget* parent)
|
||||
QListWidgetItem * FilterUtility::createFilterItem(int32_t id, QListWidget* parent)
|
||||
{
|
||||
QSettings settings;
|
||||
DBCHandler * dbcHandler = DBCHandler::getReference();
|
||||
@@ -77,4 +77,4 @@ QListWidgetItem * FilterUtility::createFilterItem(uint32_t id, QListWidget* pare
|
||||
|
||||
thisItem->setText(filterItemName);
|
||||
return thisItem;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -8,16 +8,16 @@ class FilterUtility
|
||||
{
|
||||
|
||||
public:
|
||||
static QListWidgetItem * createFilterItem(uint32_t id, QListWidget* parent=NULL); // if parent is given, add item automatically to listwidget
|
||||
static QListWidgetItem * createCheckableFilterItem(uint32_t id, bool checked, QListWidget* parent=NULL);
|
||||
static QListWidgetItem * createFilterItem(int32_t id, QListWidget* parent=NULL); // if parent is given, add item automatically to listwidget
|
||||
static QListWidgetItem * createCheckableFilterItem(int32_t id, bool checked, QListWidget* parent=NULL);
|
||||
|
||||
static uint32_t getIdAsInt( QListWidgetItem * item );
|
||||
static QString getId( QListWidgetItem * item );
|
||||
static QString getId( QString itemText );
|
||||
|
||||
static uint32_t getGMLanArbitrationId(uint32_t id);
|
||||
static uint32_t getGMLanSenderId(uint32_t id);
|
||||
static uint32_t getGMLanPriorityBits(uint32_t id);
|
||||
static uint32_t getGMLanArbitrationId(int32_t id);
|
||||
static uint32_t getGMLanSenderId(int32_t id);
|
||||
static uint32_t getGMLanPriorityBits(int32_t id);
|
||||
};
|
||||
|
||||
#endif // DBCLOADSAVEWINDOW_H
|
||||
#endif // DBCLOADSAVEWINDOW_H
|
||||
|
||||
@@ -77,17 +77,20 @@ void FirmwareUploaderWindow::updatedFrames(int numFrames)
|
||||
|
||||
void FirmwareUploaderWindow::gotTargettedFrame(CANFrame frame)
|
||||
{
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(frame.payload().data());
|
||||
int dataLen = frame.payload().count();
|
||||
|
||||
qDebug() << "FUW: Got targetted frame with id " << frame.frameId();
|
||||
if (frame.frameId() == (uint32_t)(baseAddress + 0x10)) {
|
||||
if (frame.frameId() == (uint32_t)(baseAddress + 0x10) && (dataLen == 8) ) {
|
||||
qDebug() << "Start firmware reply";
|
||||
if (((char)frame.payload()[0] == (char)0xAD) && ((char)frame.payload()[1] == (char)0xDE))
|
||||
if ((data[0] == 0xAD) && (data[1] == 0xDE))
|
||||
{
|
||||
if (((char)frame.payload()[2] == (char)0xAF) && ((char)frame.payload()[3] == (char)0xDE))
|
||||
if ((data[2] == 0xAF) && (data[3] == 0xDE))
|
||||
{
|
||||
qDebug() << "There's dead beef here";
|
||||
if (((char)frame.payload()[4] == (char)(token & 0xFF)) && ((char)frame.payload()[5] == (char)((token >> 8) & 0xFF)))
|
||||
if ( (data[4] == (token & 0xFF)) && (data[5] == ((token >> 8) & 0xFF) ) )
|
||||
{
|
||||
if (((char)frame.payload()[6] == (char)((token >> 16) & 0xFF)) && ((char)frame.payload()[7] == (char)((token >> 24) & 0xFF)))
|
||||
if ((data[6] == ((token >> 16) & 0xFF)) && (data[7] == ((token >> 24) & 0xFF)))
|
||||
{
|
||||
qDebug() << "starting firmware process";
|
||||
//MainWindow::getReference()->setTargettedID(baseAddress + 0x20);
|
||||
@@ -101,7 +104,7 @@ void FirmwareUploaderWindow::gotTargettedFrame(CANFrame frame)
|
||||
|
||||
if (frame.frameId() == (uint32_t)(baseAddress + 0x20)) {
|
||||
qDebug() << "Firmware reception success reply";
|
||||
int seq = frame.payload()[0] + (256 * frame.payload()[1]);
|
||||
int seq = data[0] + (256 * data[1]);
|
||||
if (seq == currentSendingPosition)
|
||||
{
|
||||
currentSendingPosition++;
|
||||
@@ -143,7 +146,7 @@ void FirmwareUploaderWindow::sendFirmwareChunk()
|
||||
output->payload()[3] = firmwareData[firmwareLocation++];
|
||||
output->payload()[4] = firmwareData[firmwareLocation++];
|
||||
output->payload()[5] = firmwareData[firmwareLocation++];
|
||||
for (int i = 0; i < 6; i++) xorByte = xorByte ^ output->payload()[i];
|
||||
for (int i = 0; i < 6; i++) xorByte = xorByte ^ static_cast<unsigned char>(output->payload()[i]);
|
||||
output->payload()[6] = xorByte;
|
||||
output->setPayload(bytes);
|
||||
sendCANFrame(output);
|
||||
|
||||
+220
-121
@@ -809,7 +809,7 @@ bool FrameFileIO::loadCANHackerFile(QString filename, QVector<CANFrame>* frames)
|
||||
{
|
||||
if (tokens[d + 3] != "")
|
||||
{
|
||||
bytes[d] = static_cast<unsigned char>(tokens[d + 3].toInt(nullptr, 16));
|
||||
bytes[d] = static_cast<char>(tokens[d + 3].toInt(nullptr, 16));
|
||||
}
|
||||
else bytes[d] = 0;
|
||||
}
|
||||
@@ -927,7 +927,7 @@ bool FrameFileIO::loadCANOpenFile(QString filename, QVector<CANFrame>* frames)
|
||||
{
|
||||
if (dataTok[d] != "")
|
||||
{
|
||||
bytes[d] = static_cast<unsigned char>(dataTok[d].simplified().toInt(nullptr, 16));
|
||||
bytes[d] = static_cast<char>(dataTok[d].simplified().toInt(nullptr, 16));
|
||||
}
|
||||
else bytes[d] = 0;
|
||||
}
|
||||
@@ -947,6 +947,10 @@ bool FrameFileIO::saveCRTDFile(QString filename, const QVector<CANFrame>* frames
|
||||
QFile *outFile = new QFile(filename);
|
||||
int lineCounter = 0;
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
delete outFile;
|
||||
@@ -966,24 +970,28 @@ bool FrameFileIO::saveCRTDFile(QString filename, const QVector<CANFrame>* frames
|
||||
lineCounter = 0;
|
||||
}
|
||||
|
||||
outFile->write(QString::number(frames->at(c).timeStamp().microSeconds() / 1000000.0, 'f', 6).toUtf8());
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
outFile->write(QString::number(frame->timeStamp().microSeconds() / 1000000.0, 'f', 6).toUtf8());
|
||||
outFile->putChar(' ');
|
||||
|
||||
outFile->write(QString::number(frames->at(c).bus + 1).toUtf8());
|
||||
if (frames->at(c).isReceived) outFile->putChar('R');
|
||||
outFile->write(QString::number(frame->bus + 1).toUtf8());
|
||||
if (frame->isReceived) outFile->putChar('R');
|
||||
else outFile->putChar('T');
|
||||
|
||||
if (frames->at(c).hasExtendedFrameFormat())
|
||||
if (frame->hasExtendedFrameFormat())
|
||||
{
|
||||
outFile->write("29 ");
|
||||
}
|
||||
else outFile->write("11 ");
|
||||
outFile->write(QString::number(frames->at(c).frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
outFile->write(QString::number(frame->frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
outFile->putChar(' ');
|
||||
|
||||
for (int temp = 0; temp < frames->at(c).payload().length(); temp++)
|
||||
for (int temp = 0; temp < dataLen; temp++)
|
||||
{
|
||||
outFile->write(QString::number(frames->at(c).payload()[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->write(QString::number(data[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->putChar(' ');
|
||||
}
|
||||
|
||||
@@ -1136,7 +1144,7 @@ bool FrameFileIO::loadPCANFile(QString filename, QVector<CANFrame>* frames)
|
||||
{
|
||||
if (tokens[d] != "")
|
||||
{
|
||||
bytes[d] = static_cast<unsigned char>(tokens[d].toInt(nullptr, 16));
|
||||
bytes[d] = static_cast<char>(tokens[d].toInt(nullptr, 16));
|
||||
}
|
||||
else bytes[d] = 0;
|
||||
}
|
||||
@@ -1169,7 +1177,7 @@ bool FrameFileIO::loadPCANFile(QString filename, QVector<CANFrame>* frames)
|
||||
{
|
||||
if (tokens[d] != "")
|
||||
{
|
||||
bytes[d] = static_cast<unsigned char>(tokens[d].toInt(nullptr, 16));
|
||||
bytes[d] = static_cast<char>(tokens[d].toInt(nullptr, 16));
|
||||
}
|
||||
else bytes[d] = 0;
|
||||
}
|
||||
@@ -1313,7 +1321,7 @@ bool FrameFileIO::loadCanalyzerASC(QString filename, QVector<CANFrame>* frames)
|
||||
{
|
||||
if (tokens.count() > d)
|
||||
{
|
||||
bytes[d - 6] = static_cast<unsigned char>(tokens[d].toInt(nullptr, 16));
|
||||
bytes[d - 6] = static_cast<char>(tokens[d].toInt(nullptr, 16));
|
||||
}
|
||||
else //expected byte wasn't there to read. Set it zero and set error flag
|
||||
{
|
||||
@@ -1336,7 +1344,12 @@ bool FrameFileIO::saveCanalyzerASC(QString filename, const QVector<CANFrame>* fr
|
||||
{
|
||||
QFile *outFile = new QFile(filename);
|
||||
int lineCounter = 0;
|
||||
uint64_t offsetTime = frames->at(0).timeStamp().microSeconds();
|
||||
int64_t offsetTime = frames->at(0).timeStamp().microSeconds();
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
for (int c = 0; c < frames->count(); c++)
|
||||
{
|
||||
if (frames->at(c).timeStamp().microSeconds() < offsetTime) offsetTime = frames->at(c).timeStamp().microSeconds();
|
||||
@@ -1369,24 +1382,28 @@ bool FrameFileIO::saveCanalyzerASC(QString filename, const QVector<CANFrame>* fr
|
||||
lineCounter = 0;
|
||||
}
|
||||
|
||||
uint64_t timeStamp = (frames->at(c).timeStamp().microSeconds() - offsetTime) / 1000000ull;
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
uint64_t timeStamp = (frame->timeStamp().microSeconds() - offsetTime) / 1000000ull;
|
||||
int tsLen = QString::number(timeStamp).length();
|
||||
int precision = 6;
|
||||
//vector seems to keep 10 bytes at the start of the line for the timestamp. It should never exceed this
|
||||
//and there should never be a precision over 6 digits after the decimal
|
||||
if (tsLen > 3) precision = 9 - tsLen;
|
||||
outFile->write(QString::number((frames->at(c).timeStamp().microSeconds() - offsetTime) / 1000000.0, 'f', precision).rightJustified(10, ' ').toUtf8());
|
||||
outFile->write(QString::number((frame->timeStamp().microSeconds() - offsetTime) / 1000000.0, 'f', precision).rightJustified(10, ' ').toUtf8());
|
||||
outFile->putChar(' ');
|
||||
outFile->write(QString::number(frames->at(c).bus + 1).toUtf8());
|
||||
outFile->write(QString::number(frame->bus + 1).toUtf8());
|
||||
outFile->write(" ");
|
||||
if (frames->at(c).hasExtendedFrameFormat())
|
||||
{
|
||||
outFile->write(QString::number(frames->at(c).frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
outFile->write(QString::number(frame->frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
outFile->write("x");
|
||||
}
|
||||
else
|
||||
{
|
||||
outFile->write(QString::number(frames->at(c).frameId(), 16).toUpper().rightJustified(3, '0').toUtf8());
|
||||
outFile->write(QString::number(frame->frameId(), 16).toUpper().rightJustified(3, '0').toUtf8());
|
||||
outFile->write(" ");
|
||||
}
|
||||
outFile->write(" ");
|
||||
@@ -1397,12 +1414,12 @@ bool FrameFileIO::saveCanalyzerASC(QString filename, const QVector<CANFrame>* fr
|
||||
if (frames->at(c).frameType() == QCanBusFrame::RemoteRequestFrame) outFile->write("r ");
|
||||
else outFile->write("d ");
|
||||
|
||||
outFile->write(QString::number(frames->at(c).payload().length()).toUtf8());
|
||||
outFile->write(QString::number(dataLen).toUtf8());
|
||||
outFile->write(" ");
|
||||
|
||||
for (int temp = 0; temp < frames->at(c).payload().length(); temp++)
|
||||
for (int temp = 0; temp < dataLen; temp++)
|
||||
{
|
||||
outFile->write(QString::number((unsigned char)frames->at(c).payload()[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->write(QString::number(data[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->write(" ");
|
||||
}
|
||||
|
||||
@@ -1563,7 +1580,7 @@ bool FrameFileIO::loadNativeCSVFile(QString filename, QVector<CANFrame>* frames)
|
||||
QByteArray bytes(lng, 0);
|
||||
for (int c = 0; c < 8; c++) bytes[c] = 0;
|
||||
for (int d = 0; d < thisFrame.payload().length(); d++)
|
||||
bytes[d] = static_cast<unsigned char>(tokens[5 + d].toInt(nullptr, 16));
|
||||
bytes[d] = static_cast<char>(tokens[5 + d].toInt(nullptr, 16));
|
||||
thisFrame.setPayload(bytes);
|
||||
}
|
||||
else if (fileVersion == 2)
|
||||
@@ -1578,7 +1595,7 @@ bool FrameFileIO::loadNativeCSVFile(QString filename, QVector<CANFrame>* frames)
|
||||
QByteArray bytes(lng, 0);
|
||||
for (int c = 0; c < 8; c++) bytes[c] = 0;
|
||||
for (int d = 0; d < thisFrame.payload().length(); d++)
|
||||
bytes[d] = static_cast<unsigned char>(tokens[6 + d].toInt(nullptr, 16));
|
||||
bytes[d] = static_cast<char>(tokens[6 + d].toInt(nullptr, 16));
|
||||
thisFrame.setPayload(bytes);
|
||||
}
|
||||
|
||||
@@ -1597,6 +1614,10 @@ bool FrameFileIO::saveNativeCSVFile(QString filename, const QVector<CANFrame>* f
|
||||
QFile *outFile = new QFile(filename);
|
||||
int lineCounter = 0;
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
delete outFile;
|
||||
@@ -1615,28 +1636,32 @@ bool FrameFileIO::saveNativeCSVFile(QString filename, const QVector<CANFrame>* f
|
||||
lineCounter = 0;
|
||||
}
|
||||
|
||||
outFile->write(QString::number(frames->at(c).timeStamp().microSeconds()).toUtf8());
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
outFile->write(QString::number(frame->timeStamp().microSeconds()).toUtf8());
|
||||
outFile->putChar(44);
|
||||
|
||||
outFile->write(QString::number(frames->at(c).frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
outFile->write(QString::number(frame->frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
outFile->putChar(44);
|
||||
|
||||
if (frames->at(c).hasExtendedFrameFormat()) outFile->write("true,");
|
||||
if (frame->hasExtendedFrameFormat()) outFile->write("true,");
|
||||
else outFile->write("false,");
|
||||
|
||||
if (frames->at(c).isReceived) outFile->write("Rx,");
|
||||
if (frame->isReceived) outFile->write("Rx,");
|
||||
else outFile->write("Tx,");
|
||||
|
||||
outFile->write(QString::number(frames->at(c).bus).toUtf8());
|
||||
outFile->write(QString::number(frame->bus).toUtf8());
|
||||
outFile->putChar(44);
|
||||
|
||||
outFile->write(QString::number(frames->at(c).payload().length()).toUtf8());
|
||||
outFile->write(QString::number(dataLen).toUtf8());
|
||||
outFile->putChar(44);
|
||||
|
||||
for (int temp = 0; temp < 8; temp++)
|
||||
{
|
||||
if (temp < frames->at(c).payload().length())
|
||||
outFile->write(QString::number((unsigned char)frames->at(c).payload()[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
if (temp < dataLen)
|
||||
outFile->write(QString::number(data[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
else
|
||||
outFile->write("00");
|
||||
outFile->putChar(44);
|
||||
@@ -1694,32 +1719,41 @@ bool FrameFileIO::closeContinuousNative()
|
||||
|
||||
bool FrameFileIO::writeContinuousNative(const QVector<CANFrame>* frames, int beginningFrame)
|
||||
{
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
if (!continuousFile.isOpen()) return false;
|
||||
qDebug() << "Bgn: " << beginningFrame << " Count: " << frames->count();
|
||||
for (int c = beginningFrame; c < frames->count(); c++)
|
||||
{
|
||||
continuousFile.write(QString::number(frames->at(c).timeStamp().microSeconds()).toUtf8());
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
continuousFile.write(QString::number(frame->timeStamp().microSeconds()).toUtf8());
|
||||
continuousFile.putChar(44);
|
||||
|
||||
continuousFile.write(QString::number(frames->at(c).frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
continuousFile.write(QString::number(frame->frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
continuousFile.putChar(44);
|
||||
|
||||
if (frames->at(c).hasExtendedFrameFormat()) continuousFile.write("true,");
|
||||
if (frame->hasExtendedFrameFormat()) continuousFile.write("true,");
|
||||
else continuousFile.write("false,");
|
||||
|
||||
if (frames->at(c).isReceived) continuousFile.write("Rx,");
|
||||
if (frame->isReceived) continuousFile.write("Rx,");
|
||||
else continuousFile.write("Tx,");
|
||||
|
||||
continuousFile.write(QString::number(frames->at(c).bus).toUtf8());
|
||||
continuousFile.write(QString::number(frame->bus).toUtf8());
|
||||
continuousFile.putChar(44);
|
||||
|
||||
continuousFile.write(QString::number(frames->at(c).payload().length()).toUtf8());
|
||||
continuousFile.write(QString::number(dataLen).toUtf8());
|
||||
continuousFile.putChar(44);
|
||||
|
||||
for (int temp = 0; temp < 8; temp++)
|
||||
{
|
||||
if (temp < frames->at(c).payload().length())
|
||||
continuousFile.write(QString::number((unsigned char)frames->at(c).payload()[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
if (temp < dataLen)
|
||||
continuousFile.write(QString::number(data[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
else
|
||||
continuousFile.write("00");
|
||||
continuousFile.putChar(44);
|
||||
@@ -1829,7 +1863,7 @@ bool FrameFileIO::loadGenericCSVFile(QString filename, QVector<CANFrame>* frames
|
||||
thisFrame.setFrameType(QCanBusFrame::DataFrame);
|
||||
QList<QByteArray> dataTok = tokens[1].split(' ');
|
||||
QByteArray bytes(dataTok.length(), 0);
|
||||
for (int d = 0; d < thisFrame.payload().length(); d++) bytes[d] = static_cast<unsigned char>(dataTok[d].toInt(nullptr, 16));
|
||||
for (int d = 0; d < thisFrame.payload().length(); d++) bytes[d] = static_cast<char>(dataTok[d].toInt(nullptr, 16));
|
||||
thisFrame.setPayload(bytes);
|
||||
frames->append(thisFrame);
|
||||
}
|
||||
@@ -1846,6 +1880,10 @@ bool FrameFileIO::saveGenericCSVFile(QString filename, const QVector<CANFrame>*
|
||||
QFile *outFile = new QFile(filename);
|
||||
int lineCounter = 0;
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
delete outFile;
|
||||
@@ -1864,12 +1902,16 @@ bool FrameFileIO::saveGenericCSVFile(QString filename, const QVector<CANFrame>*
|
||||
lineCounter = 0;
|
||||
}
|
||||
|
||||
outFile->write(QString::number(frames->at(c).frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
outFile->write(QString::number(frame->frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
outFile->putChar(44);
|
||||
|
||||
for (int temp = 0; temp < frames->at(c).payload().length(); temp++)
|
||||
for (int temp = 0; temp < dataLen; temp++)
|
||||
{
|
||||
outFile->write(QString::number((unsigned char)frames->at(c).payload()[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->write(QString::number(data[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->putChar(' ');
|
||||
}
|
||||
|
||||
@@ -2025,7 +2067,7 @@ bool FrameFileIO::loadLogFile(QString filename, QVector<CANFrame>* frames)
|
||||
QByteArray bytes(lng, 0);
|
||||
if (thisFrame.frameType() != QCanBusFrame::RemoteRequestFrame) {
|
||||
for (int d = 0; d < thisFrame.payload().length(); d++)
|
||||
bytes[d] = static_cast<unsigned char>(tokens[d + 6].toInt(nullptr, 16));
|
||||
bytes[d] = static_cast<char>(tokens[d + 6].toInt(nullptr, 16));
|
||||
}
|
||||
thisFrame.setPayload(bytes);
|
||||
frames->append(thisFrame);
|
||||
@@ -2044,6 +2086,10 @@ bool FrameFileIO::saveLogFile(QString filename, const QVector<CANFrame>* frames)
|
||||
QDateTime timestamp, tempStamp;
|
||||
int lineCounter = 0;
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
//timestamp = QDateTime::currentDateTime();
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
@@ -2077,28 +2123,32 @@ bool FrameFileIO::saveLogFile(QString filename, const QVector<CANFrame>* frames)
|
||||
lineCounter = 0;
|
||||
}
|
||||
|
||||
tempStamp = QDateTime::fromMSecsSinceEpoch(frames->at(c).timeStamp().microSeconds() / 1000);
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
tempStamp = QDateTime::fromMSecsSinceEpoch(frame->timeStamp().microSeconds() / 1000);
|
||||
outFile->write(tempStamp.toString("hh:mm:ss:zzz").toUtf8());
|
||||
if (frames->at(c).isReceived) outFile->write(" Rx ");
|
||||
if (frame->isReceived) outFile->write(" Rx ");
|
||||
else outFile->write(" Tx ");
|
||||
// busmaster channel start at 1
|
||||
outFile->write(QString::number(frames->at(c).bus+1).toUtf8() + " ");
|
||||
outFile->write(QString::number(frame->bus + 1).toUtf8() + " ");
|
||||
outFile->write("0x");
|
||||
if (frames->at(c).hasExtendedFrameFormat() && frames->at(c).frameId() > 0x7FF) {
|
||||
outFile->write(QString::number(frames->at(c).frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
if (frame->hasExtendedFrameFormat() && frame->frameId() > 0x7FF) {
|
||||
outFile->write(QString::number(frame->frameId(), 16).toUpper().rightJustified(8, '0').toUtf8());
|
||||
} else {
|
||||
outFile->write(QString::number(frames->at(c).frameId(), 16).toUpper().rightJustified(3, '0').toUtf8());
|
||||
outFile->write(QString::number(frame->frameId(), 16).toUpper().rightJustified(3, '0').toUtf8());
|
||||
}
|
||||
if (frames->at(c).hasExtendedFrameFormat()) outFile->write(" x");
|
||||
if (frame->hasExtendedFrameFormat()) outFile->write(" x");
|
||||
else outFile->write(" s");
|
||||
if (frames->at(c).frameType() == QCanBusFrame::RemoteRequestFrame) outFile->write("r ");
|
||||
if (frame->frameType() == QCanBusFrame::RemoteRequestFrame) outFile->write("r ");
|
||||
else outFile->write(" ");
|
||||
outFile->write(QString::number(frames->at(c).payload().length()).toUtf8() + " ");
|
||||
outFile->write(QString::number(dataLen).toUtf8() + " ");
|
||||
|
||||
if (frames->at(c).frameType() != QCanBusFrame::RemoteRequestFrame) {
|
||||
for (int temp = 0; temp < frames->at(c).payload().length(); temp++)
|
||||
if (frame->frameType() != QCanBusFrame::RemoteRequestFrame) {
|
||||
for (int temp = 0; temp < dataLen; temp++)
|
||||
{
|
||||
outFile->write(QString::number((unsigned char)frames->at(c).payload()[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->write(QString::number(data[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->putChar(' ');
|
||||
}
|
||||
}
|
||||
@@ -2214,7 +2264,7 @@ bool FrameFileIO::loadIXXATFile(QString filename, QVector<CANFrame>* frames)
|
||||
QStringList dataToks = Utility::unQuote(tokens[4]).simplified().split(' ');
|
||||
QByteArray bytes(dataToks.length(), 0);
|
||||
if (thisFrame.payload().length() > 8) return false;
|
||||
for (int d = 0; d < thisFrame.payload().length(); d++) bytes[d] = static_cast<unsigned char>(dataToks[d].toInt(nullptr, 16));
|
||||
for (int d = 0; d < thisFrame.payload().length(); d++) bytes[d] = static_cast<char>(dataToks[d].toInt(nullptr, 16));
|
||||
thisFrame.setPayload(bytes);
|
||||
frames->append(thisFrame);
|
||||
}
|
||||
@@ -2232,6 +2282,10 @@ bool FrameFileIO::saveIXXATFile(QString filename, const QVector<CANFrame>* frame
|
||||
QDateTime timestamp, tempStamp;
|
||||
int lineCounter = 0;
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
timestamp = QDateTime::currentDateTime();
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
@@ -2257,17 +2311,22 @@ bool FrameFileIO::saveIXXATFile(QString filename, const QVector<CANFrame>* frame
|
||||
qApp->processEvents();
|
||||
lineCounter = 0;
|
||||
}
|
||||
tempStamp = QDateTime::fromMSecsSinceEpoch(frames->at(c).timeStamp().microSeconds() / 1000);
|
||||
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
tempStamp = QDateTime::fromMSecsSinceEpoch(frame->timeStamp().microSeconds() / 1000);
|
||||
outFile->write("\"" + tempStamp.toString("h:m:s.").toUtf8() + tempStamp.toString("z").rightJustified(3, '0').toUtf8() + "\"");
|
||||
|
||||
outFile->write(",\"" + QString::number(frames->at(c).frameId(), 16).toUpper().rightJustified(8, '0').toUtf8() + "\"");
|
||||
if (frames->at(c).hasExtendedFrameFormat()) outFile->write(",\"Ext\"");
|
||||
outFile->write(",\"" + QString::number(frame->frameId(), 16).toUpper().rightJustified(8, '0').toUtf8() + "\"");
|
||||
if (frame->hasExtendedFrameFormat()) outFile->write(",\"Ext\"");
|
||||
else outFile->write(",\"Std\"");
|
||||
outFile->write(",\"\",\"");
|
||||
|
||||
for (int temp = 0; temp < frames->at(c).payload().length(); temp++)
|
||||
for (int temp = 0; temp < dataLen; temp++)
|
||||
{
|
||||
outFile->write(QString::number((unsigned char)frames->at(c).payload()[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->write(QString::number(data[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->putChar(' ');
|
||||
}
|
||||
|
||||
@@ -2334,7 +2393,7 @@ bool FrameFileIO::loadCANDOFile(QString filename, QVector<CANFrame>* frames)
|
||||
int lineCounter = 0;
|
||||
QByteArray data;
|
||||
int timeOffset = 0;
|
||||
uint64_t lastTimeStamp = 0;
|
||||
int64_t lastTimeStamp = 0;
|
||||
bool foundErrors = false;
|
||||
thisFrame.setFrameType(QCanBusFrame::DataFrame);
|
||||
|
||||
@@ -2359,14 +2418,15 @@ bool FrameFileIO::loadCANDOFile(QString filename, QVector<CANFrame>* frames)
|
||||
}
|
||||
|
||||
data = inFile->read(12);
|
||||
unsigned char *uData = reinterpret_cast<unsigned char *>(data.data());
|
||||
|
||||
thisFrame.bus = 0;
|
||||
thisFrame.isReceived = true;
|
||||
thisFrame.setExtendedFrameFormat(false); //format is incapable of extended frames
|
||||
thisFrame.setFrameType(QCanBusFrame::DataFrame);
|
||||
qint64 tempStamp;
|
||||
tempStamp = 1000000ul * ((unsigned char)data[0] >> 2);
|
||||
tempStamp += (((data[0] & 3) << 8) + (unsigned char)data[1]) * 1000;
|
||||
tempStamp = 1000000ul * (uData[0] >> 2);
|
||||
tempStamp += (((uData[0] & 3) << 8) + uData[1]) * 1000;
|
||||
tempStamp += timeOffset;
|
||||
if (tempStamp < lastTimeStamp)
|
||||
{
|
||||
@@ -2374,12 +2434,12 @@ bool FrameFileIO::loadCANDOFile(QString filename, QVector<CANFrame>* frames)
|
||||
}
|
||||
lastTimeStamp = tempStamp;
|
||||
thisFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, tempStamp));
|
||||
thisFrame.setFrameId((((unsigned char)data[3] & 0x0F) * 256 + (unsigned char)data[2]) & 0x7FF);
|
||||
QByteArray bytes((unsigned char)data[3] >> 4, 0);
|
||||
thisFrame.setFrameId(((uData[3] & 0x0F) * 256 + uData[2]) & 0x7FF);
|
||||
QByteArray bytes(uData[3] >> 4, 0);
|
||||
|
||||
if (thisFrame.payload().length() <= 8 && thisFrame.frameId() <= 0x7FF)
|
||||
{
|
||||
for (unsigned int d = 0; d < thisFrame.payload().length(); d++) bytes[d] = (unsigned char)data[4 + d];
|
||||
for (int d = 0; d < thisFrame.payload().length(); d++) bytes[d] = data[4 + d];
|
||||
thisFrame.setPayload(bytes);
|
||||
frames->append(thisFrame);
|
||||
}
|
||||
@@ -2397,7 +2457,12 @@ bool FrameFileIO::saveCANDOFile(QString filename, const QVector<CANFrame>* frame
|
||||
int lineCounter = 0;
|
||||
QByteArray data;
|
||||
CANFrame thisFrame;
|
||||
int ms, id;
|
||||
int id;
|
||||
qint64 ms;
|
||||
|
||||
unsigned char *inData;
|
||||
int inDataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly))
|
||||
{
|
||||
@@ -2425,18 +2490,22 @@ bool FrameFileIO::saveCANDOFile(QString filename, const QVector<CANFrame>* frame
|
||||
qApp->processEvents();
|
||||
lineCounter = 0;
|
||||
}
|
||||
|
||||
frame = &frames->at(c);
|
||||
inData = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
inDataLen = frame->payload().count();
|
||||
|
||||
for (int j = 0; j < 8; j++) data[4 + j] = (char)0xFF;
|
||||
|
||||
thisFrame = frames->at(c);
|
||||
if (!thisFrame.hasExtendedFrameFormat())
|
||||
if (!frame->hasExtendedFrameFormat())
|
||||
{
|
||||
ms = (thisFrame.timeStamp().microSeconds() / 1000);
|
||||
id = thisFrame.frameId() & 0x7FF;
|
||||
ms = (frame->timeStamp().microSeconds() / 1000);
|
||||
id = frame->frameId() & 0x7FF;
|
||||
data[0] = (((ms / 1000) % 60) << 2) + ((ms % 1000) >> 8);
|
||||
data[1] = (char)(ms & 0xFF);
|
||||
data[2] = (char)(id & 0xFF);
|
||||
data[3] = (char)((id >> 8) + (thisFrame.payload().length() << 4));
|
||||
for (unsigned int d = 0; d < thisFrame.payload().length(); d++) data[4 + d] = (char)thisFrame.payload()[d];
|
||||
data[3] = (char)((id >> 8) + (inDataLen << 4));
|
||||
for (int d = 0; d < inDataLen; d++) data[4 + d] = (char)inData[d];
|
||||
outFile->write(data);
|
||||
}
|
||||
}
|
||||
@@ -2553,14 +2622,14 @@ bool FrameFileIO::loadMicrochipFile(QString filename, QVector<CANFrame>* frames)
|
||||
if (tokens[1].at(0) == 'R') thisFrame.isReceived = true;
|
||||
else thisFrame.isReceived = false;
|
||||
thisFrame.setFrameType(QCanBusFrame::DataFrame);
|
||||
thisFrame.setFrameId(Utility::ParseStringToNum(tokens[2]));
|
||||
thisFrame.setFrameId(static_cast<quint32>( Utility::ParseStringToNum(tokens[2])) );
|
||||
if (thisFrame.frameId() <= 0x7FF) thisFrame.setExtendedFrameFormat(false);
|
||||
else thisFrame.setExtendedFrameFormat(true);
|
||||
thisFrame.bus = 0;
|
||||
QByteArray bytes(tokens[3].toUInt(), 0);
|
||||
QByteArray bytes(tokens[3].toInt(), 0);
|
||||
if (thisFrame.payload().length() > 8) thisFrame.payload().resize(8);
|
||||
if (thisFrame.payload().length() + 4 > (unsigned int) tokens.length()) thisFrame.payload().resize( tokens.length() - 4 );
|
||||
for (unsigned int d = 0; d < thisFrame.payload().length(); d++) bytes[d] = (unsigned char)Utility::ParseStringToNum(tokens[4 + d]);
|
||||
if (thisFrame.payload().length() + 4 > tokens.length()) thisFrame.payload().resize( tokens.length() - 4 );
|
||||
for (int d = 0; d < thisFrame.payload().length(); d++) bytes[d] = static_cast<char>( Utility::ParseStringToNum(tokens[4 + d]) );
|
||||
thisFrame.setPayload(bytes);
|
||||
frames->append(thisFrame);
|
||||
}
|
||||
@@ -2591,6 +2660,10 @@ bool FrameFileIO::saveMicrochipFile(QString filename, const QVector<CANFrame>* f
|
||||
QDateTime timestamp, tempStamp;
|
||||
int lineCounter = 0;
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
timestamp = QDateTime::currentDateTime();
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
@@ -2617,15 +2690,19 @@ bool FrameFileIO::saveMicrochipFile(QString filename, const QVector<CANFrame>* f
|
||||
lineCounter = 0;
|
||||
}
|
||||
|
||||
outFile->write(QString::number((int)(frames->at(c).timeStamp().microSeconds() / 1000)).toUtf8());
|
||||
if (frames->at(c).isReceived) outFile->write(";RX;");
|
||||
else outFile->write(";TX;");
|
||||
outFile->write("0x" + QString::number(frames->at(c).frameId(), 16).toUpper().rightJustified(8, '0').toUtf8() + ";");
|
||||
outFile->write(QString::number(frames->at(c).payload().length()).toUtf8() + ";");
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
for (unsigned int temp = 0; temp < frames->at(c).payload().length(); temp++)
|
||||
outFile->write(QString::number((frame->timeStamp().microSeconds() / 1000)).toUtf8());
|
||||
if (frame->isReceived) outFile->write(";RX;");
|
||||
else outFile->write(";TX;");
|
||||
outFile->write("0x" + QString::number(frame->frameId(), 16).toUpper().rightJustified(8, '0').toUtf8() + ";");
|
||||
outFile->write(QString::number(dataLen).toUtf8() + ";");
|
||||
|
||||
for (int temp = 0; temp < dataLen; temp++)
|
||||
{
|
||||
outFile->write("0x" + QString::number((unsigned char)frames->at(c).payload()[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->write("0x" + QString::number(data[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->putChar(';');
|
||||
}
|
||||
|
||||
@@ -2773,11 +2850,11 @@ bool FrameFileIO::loadTraceFile(QString filename, QVector<CANFrame>* frames)
|
||||
else thisFrame.setExtendedFrameFormat(true);
|
||||
thisFrame.bus = 0;
|
||||
thisFrame.setFrameType(QCanBusFrame::DataFrame);
|
||||
QByteArray bytes(tokens[3].toUInt(), 0);
|
||||
QByteArray bytes(tokens[3].toInt(), 0);
|
||||
if (thisFrame.payload().length() > 8) thisFrame.payload().resize(8);
|
||||
QList<QByteArray> dataToks = tokens[4].split(' ');
|
||||
if (thisFrame.payload().length() > (unsigned int) dataToks.length()) thisFrame.payload().resize( static_cast<unsigned int>(dataToks.length()) );
|
||||
for (unsigned int d = 0; d < thisFrame.payload().length(); d++) bytes[d] = (unsigned char)dataToks[d].toInt(nullptr, 16);
|
||||
if (thisFrame.payload().length() > dataToks.length()) thisFrame.payload().resize(dataToks.length());
|
||||
for (int d = 0; d < thisFrame.payload().length(); d++) bytes[d] = static_cast<char>(dataToks[d].toInt(nullptr, 16));
|
||||
thisFrame.setPayload(bytes);
|
||||
frames->append(thisFrame);
|
||||
}
|
||||
@@ -2795,9 +2872,13 @@ bool FrameFileIO::saveTraceFile(QString filename, const QVector<CANFrame> * fram
|
||||
QFile *outFile = new QFile(filename);
|
||||
QDateTime timestamp;
|
||||
int lineCounter = 0;
|
||||
uint64_t tempTime;
|
||||
int64_t tempTime;
|
||||
int tempTimePiece;
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
timestamp = QDateTime::currentDateTime();
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
@@ -2836,38 +2917,41 @@ bool FrameFileIO::saveTraceFile(QString filename, const QVector<CANFrame> * fram
|
||||
//lineCounter = 0;
|
||||
}
|
||||
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
//1F D3 3F FF 08 FF E0 CB
|
||||
outFile->write(QString::number(lineCounter).rightJustified(10, ' ').toUtf8());
|
||||
outFile->write("\t");
|
||||
|
||||
tempTime = frames->at(c).timeStamp().microSeconds();
|
||||
tempTimePiece = tempTime / 1000000ul / 60 / 60;
|
||||
tempTime -= tempTimePiece * 1000000ul * 60 * 60;
|
||||
tempTime = frame->timeStamp().microSeconds();
|
||||
tempTimePiece = static_cast<int>(tempTime / 1000000l / 60 / 60);
|
||||
tempTime -= tempTimePiece * 1000000l * 60 * 60;
|
||||
outFile->write(QString::number(tempTimePiece).rightJustified(2, '0').toUtf8());
|
||||
outFile->write(":");
|
||||
|
||||
tempTimePiece = tempTime / 1000000ul / 60;
|
||||
tempTime -= tempTimePiece * 1000000ul * 60;
|
||||
tempTimePiece = static_cast<int>(tempTime / 1000000l / 60);
|
||||
tempTime -= tempTimePiece * 1000000l * 60;
|
||||
outFile->write(QString::number(tempTimePiece).rightJustified(2, '0').toUtf8());
|
||||
outFile->write(":");
|
||||
|
||||
tempTimePiece = tempTime / 1000000ul;
|
||||
tempTime -= tempTimePiece * 1000000ul;
|
||||
tempTimePiece = static_cast<int>(tempTime / 1000000l);
|
||||
tempTime -= tempTimePiece * 1000000l;
|
||||
outFile->write(QString::number(tempTimePiece).rightJustified(2, '0').toUtf8());
|
||||
outFile->write(":");
|
||||
|
||||
tempTimePiece = tempTime / 100;
|
||||
tempTimePiece = static_cast<int>(tempTime / 100);
|
||||
outFile->write(QString::number(tempTimePiece).rightJustified(4, '0').toUtf8());
|
||||
outFile->write("\t");
|
||||
|
||||
outFile->write(QString::number(frames->at(c).frameId(), 16).toUpper().rightJustified(8, '0').toUtf8() + "\t");
|
||||
outFile->write(QString::number(frame->frameId(), 16).toUpper().rightJustified(8, '0').toUtf8() + "\t");
|
||||
|
||||
outFile->write(QString::number(frames->at(c).payload().length()).toUtf8() + "\t");
|
||||
outFile->write(QString::number(dataLen).toUtf8() + "\t");
|
||||
|
||||
for (unsigned int temp = 0; temp < frames->at(c).payload().length(); temp++)
|
||||
for (int temp = 0; temp < dataLen; temp++)
|
||||
{
|
||||
outFile->write(QString::number((unsigned char)frames->at(c).payload()[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->write(QString::number(data[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
outFile->putChar(' ');
|
||||
}
|
||||
|
||||
@@ -2886,6 +2970,10 @@ bool FrameFileIO::saveCanDumpFile(QString filename, const QVector<CANFrame> * fr
|
||||
int lineCounter = 0;
|
||||
double tempTime;
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
timestamp = QDateTime::currentDateTime();
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
@@ -2902,27 +2990,31 @@ bool FrameFileIO::saveCanDumpFile(QString filename, const QVector<CANFrame> * fr
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
outFile->write("(");
|
||||
|
||||
tempTime = frames->at(c).timeStamp().microSeconds() / 1000000.0;
|
||||
tempTime = frame->timeStamp().microSeconds() / 1000000.0;
|
||||
outFile->write(QString::number(tempTime,'f', 6).rightJustified(17, '0').toUtf8());
|
||||
outFile->write(") vcan0 ");
|
||||
|
||||
if (frames->at(c).hasExtendedFrameFormat()) {
|
||||
outFile->write(QString::number(frames->at(c).frameId(), 16).rightJustified(8,'0').toUpper().toUtf8());
|
||||
if (frame->hasExtendedFrameFormat()) {
|
||||
outFile->write(QString::number(frame->frameId(), 16).rightJustified(8,'0').toUpper().toUtf8());
|
||||
} else {
|
||||
outFile->write(QString::number(frames->at(c).frameId(), 16).rightJustified(3,'0').toUpper().toUtf8());
|
||||
outFile->write(QString::number(frame->frameId(), 16).rightJustified(3,'0').toUpper().toUtf8());
|
||||
}
|
||||
|
||||
outFile->write("#");
|
||||
|
||||
if (frames->at(c).frameType() == QCanBusFrame::RemoteRequestFrame) {
|
||||
if (frame->frameType() == QCanBusFrame::RemoteRequestFrame) {
|
||||
outFile->write("R");
|
||||
outFile->write(QString::number(frames->at(c).payload().length()).toUtf8());
|
||||
outFile->write(QString::number(dataLen).toUtf8());
|
||||
} else {
|
||||
for (unsigned int temp = 0; temp < frames->at(c).payload().length(); temp++)
|
||||
for (int temp = 0; temp < dataLen; temp++)
|
||||
{
|
||||
outFile->write(QString::number((unsigned char)frames->at(c).payload()[temp], 16).rightJustified(2,'0').toUpper().toUtf8());
|
||||
outFile->write(QString::number(data[temp], 16).rightJustified(2,'0').toUpper().toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3102,14 +3194,14 @@ bool FrameFileIO::loadCanDumpFile(QString filename, QVector<CANFrame>* frames)
|
||||
{
|
||||
//(1551774790.942758) can1 7A8 [8] F4 DC D1 83 0E 02 00 00
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11
|
||||
thisFrame.setFrameId(tokens[2].toULong(nullptr, 16));
|
||||
thisFrame.setFrameId(tokens[2].toLong(nullptr, 16));
|
||||
if (thisFrame.frameId() > 0x7FF) thisFrame.setExtendedFrameFormat(true);
|
||||
else thisFrame.setExtendedFrameFormat(false);
|
||||
thisFrame.setFrameType(QCanBusFrame::DataFrame);
|
||||
QByteArray bytes(tokens[3].at(1) - '0', 0);
|
||||
for (uint32_t c = 0; c < thisFrame.payload().length(); c++)
|
||||
for (int c = 0; c < thisFrame.payload().length(); c++)
|
||||
{
|
||||
bytes[c] = static_cast<unsigned char>(tokens[4 + c].toInt(nullptr, 16));
|
||||
bytes[c] = static_cast<char>(tokens[4 + c].toInt(nullptr, 16));
|
||||
}
|
||||
thisFrame.setPayload(bytes);
|
||||
}
|
||||
@@ -3170,7 +3262,6 @@ bool FrameFileIO::isLawicelFile(QString filename)
|
||||
QByteArray line;
|
||||
int lineCounter = 0;
|
||||
bool isMatch = false;
|
||||
bool ret;
|
||||
|
||||
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
@@ -3245,7 +3336,7 @@ bool FrameFileIO::loadLawicelFile(QString filename, QVector<CANFrame>* frames)
|
||||
QByteArray bytes(line.length() / 2, 0);
|
||||
for (int d = 0; d < bytes.length(); d++)
|
||||
{
|
||||
bytes[d] = static_cast<unsigned char>(line.mid(d * 2, 2).toInt(nullptr, 16));
|
||||
bytes[d] = static_cast<char>(line.mid(d * 2, 2).toInt(nullptr, 16));
|
||||
}
|
||||
thisFrame.setPayload(bytes);
|
||||
frames->append(thisFrame);
|
||||
@@ -3508,6 +3599,10 @@ bool FrameFileIO::saveCabanaFile(QString filename, const QVector<CANFrame>* fram
|
||||
QFile *outFile = new QFile(filename);
|
||||
int lineCounter = 0;
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
delete outFile;
|
||||
@@ -3526,23 +3621,27 @@ bool FrameFileIO::saveCabanaFile(QString filename, const QVector<CANFrame>* fram
|
||||
lineCounter = 0;
|
||||
}
|
||||
|
||||
double tempTimeStamp = frames->at(c).timeStamp().microSeconds();
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
double tempTimeStamp = frame->timeStamp().microSeconds();
|
||||
tempTimeStamp /= 1000000;
|
||||
|
||||
outFile->write(QString::number(tempTimeStamp, 'f').toUtf8());
|
||||
outFile->write(".0");
|
||||
outFile->putChar(44);
|
||||
|
||||
outFile->write(QString::number(frames->at(c).frameId(), 10).toUpper().toUtf8());
|
||||
outFile->write(QString::number(frame->frameId(), 10).toUpper().toUtf8());
|
||||
outFile->putChar(44);
|
||||
|
||||
outFile->write(QString::number(frames->at(c).bus).toUtf8());
|
||||
outFile->write(QString::number(frame->bus).toUtf8());
|
||||
outFile->putChar(44);
|
||||
|
||||
for (unsigned int temp = 0; temp < 8; temp++)
|
||||
for (int temp = 0; temp < 8; temp++)
|
||||
{
|
||||
if (temp < frames->at(c).payload().length())
|
||||
outFile->write(QString::number(frames->at(c).payload()[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
if (temp < dataLen)
|
||||
outFile->write(QString::number(data[temp], 16).toUpper().rightJustified(2, '0').toUtf8());
|
||||
else
|
||||
outFile->write("00");
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ void FramePlaybackWindow::refreshIDList()
|
||||
QHash<int, bool>::Iterator filterIter;
|
||||
for (filterIter = currentSeqItem->idFilters.begin(); filterIter != currentSeqItem->idFilters.end(); ++filterIter)
|
||||
{
|
||||
QListWidgetItem* listItem = FilterUtility::createCheckableFilterItem(filterIter.key(), filterIter.value(), ui->listID);
|
||||
/*QListWidgetItem* listItem = */ FilterUtility::createCheckableFilterItem(filterIter.key(), filterIter.value(), ui->listID);
|
||||
}
|
||||
//default is to sort in ascending order
|
||||
ui->listID->sortItems();
|
||||
@@ -479,7 +479,7 @@ void FramePlaybackWindow::btnLoadFile()
|
||||
|
||||
if (FrameFileIO::loadFrameFile(filename, &item.data))
|
||||
{
|
||||
qSort(item.data); //sort by timestamp to be sure it's in order
|
||||
std::sort(item.data.begin(), item.data.end()); //sort by timestamp to be sure it's in order
|
||||
QStringList fileList = filename.split('/');
|
||||
item.filename = fileList[fileList.length() - 1];
|
||||
item.currentLoopCount = 0;
|
||||
@@ -513,7 +513,7 @@ void FramePlaybackWindow::btnLoadLive()
|
||||
item.currentLoopCount = 0;
|
||||
item.maxLoops = 1;
|
||||
item.data = QVector<CANFrame>(*modelFrames); //create a copy of the current frames from the main view
|
||||
qSort(item.data); //be sure it's all in time based order
|
||||
std::sort(item.data.begin(), item.data.end()); //be sure it's all in time based order
|
||||
fillIDHash(item);
|
||||
if (ui->tblSequence->currentRow() == -1)
|
||||
{
|
||||
|
||||
+12
-8
@@ -185,7 +185,7 @@ void FrameSenderWindow::processIncomingFrame(CANFrame *frame)
|
||||
qDebug() << "Frame ID: " << frame->frameId();
|
||||
if (thisTrigger->ID > 0 && (uint32_t)thisTrigger->ID == frame->frameId())
|
||||
{
|
||||
if ((uint32_t)thisTrigger->bus == frame->bus || thisTrigger->bus == -1)
|
||||
if (thisTrigger->bus == frame->bus || thisTrigger->bus == -1)
|
||||
{
|
||||
if (thisTrigger->currCount < thisTrigger->maxCount)
|
||||
{
|
||||
@@ -525,16 +525,16 @@ int FrameSenderWindow::fetchOperand(int idx, ModifierOperand op)
|
||||
}
|
||||
else if (op.ID == -2) //fetch data from a data byte within the output frame
|
||||
{
|
||||
if (op.notOper) return ~sendingData.at(idx).payload()[op.databyte];
|
||||
else return sendingData.at(idx).payload()[op.databyte];
|
||||
if (op.notOper) return ~((unsigned char)sendingData.at(idx).payload()[op.databyte]);
|
||||
else return (unsigned char)sendingData.at(idx).payload()[op.databyte];
|
||||
}
|
||||
else //look up external data byte
|
||||
{
|
||||
tempFrame = lookupFrame(op.ID, op.bus);
|
||||
if (tempFrame != nullptr)
|
||||
{
|
||||
if (op.notOper) return ~tempFrame->payload()[op.databyte];
|
||||
else return tempFrame->payload()[op.databyte];
|
||||
if (op.notOper) return ~((unsigned char)tempFrame->payload()[op.databyte]);
|
||||
else return (unsigned char)tempFrame->payload()[op.databyte];
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
@@ -550,7 +550,7 @@ CANFrame* FrameSenderWindow::lookupFrame(int ID, int bus)
|
||||
{
|
||||
if (!frameCache.contains(ID)) return nullptr;
|
||||
|
||||
if (bus == -1 || frameCache[ID].bus == (unsigned int)bus) return &frameCache[ID];
|
||||
if (bus == -1 || frameCache[ID].bus == bus) return &frameCache[ID];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -786,17 +786,21 @@ ModifierOperationType FrameSenderWindow::parseOperation(QString op)
|
||||
void FrameSenderWindow::updateGridRow(int idx)
|
||||
{
|
||||
qDebug() << "updateGridRow";
|
||||
|
||||
inhibitChanged = true;
|
||||
FrameSendData *temp = &sendingData[idx];
|
||||
int gridLine = idx;
|
||||
QString dataString;
|
||||
QTableWidgetItem *item = ui->tableSender->item(gridLine, 9);
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(temp->payload().data());
|
||||
int dataLen = temp->payload().length();
|
||||
|
||||
if (item == nullptr) item = new QTableWidgetItem();
|
||||
item->setText(QString::number(temp->count));
|
||||
if (temp->frameType() != QCanBusFrame::RemoteRequestFrame) {
|
||||
for (unsigned int i = 0; i < temp->payload().length(); i++)
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
dataString.append(Utility::formatNumber(temp->payload()[i]));
|
||||
dataString.append(Utility::formatNumber(data[i]));
|
||||
dataString.append(" ");
|
||||
}
|
||||
ui->tableSender->item(gridLine, 6)->setText(dataString);
|
||||
|
||||
+18
-11
@@ -444,7 +444,7 @@ void MainWindow::updateFilterList()
|
||||
QMap<int, bool>::const_iterator filterIter;
|
||||
for (filterIter = filters->begin(); filterIter != filters->end(); ++filterIter)
|
||||
{
|
||||
QListWidgetItem *thisItem = FilterUtility::createCheckableFilterItem(filterIter.key(), filterIter.value(), ui->listFilters);
|
||||
/*QListWidgetItem *thisItem = */FilterUtility::createCheckableFilterItem(filterIter.key(), filterIter.value(), ui->listFilters);
|
||||
}
|
||||
inhibitFilterUpdate = false;
|
||||
}
|
||||
@@ -729,6 +729,10 @@ void MainWindow::saveDecodedTextFile(QString filename)
|
||||
QFile *outFile = new QFile(filename);
|
||||
const QVector<CANFrame> *frames = model->getFilteredListReference();
|
||||
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
const CANFrame *frame;
|
||||
|
||||
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return;
|
||||
/*
|
||||
@@ -738,20 +742,23 @@ Data Bytes: 88 10 00 13 BB 00 06 00
|
||||
*/
|
||||
for (int c = 0; c < frames->count(); c++)
|
||||
{
|
||||
CANFrame thisFrame = frames->at(c);
|
||||
frame = &frames->at(c);
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().count();
|
||||
|
||||
QString builderString;
|
||||
builderString += tr("Time: ") + QString::number((thisFrame.timeStamp().microSeconds() / 1000000.0), 'f', 6);
|
||||
builderString += tr(" ID: ") + Utility::formatCANID(thisFrame.frameId(), thisFrame.hasExtendedFrameFormat());
|
||||
if (thisFrame.hasExtendedFrameFormat()) builderString += tr(" Ext ");
|
||||
builderString += tr("Time: ") + QString::number((frame->timeStamp().microSeconds() / 1000000.0), 'f', 6);
|
||||
builderString += tr(" ID: ") + Utility::formatCANID(frame->frameId(), frame->hasExtendedFrameFormat());
|
||||
if (frame->hasExtendedFrameFormat()) builderString += tr(" Ext ");
|
||||
else builderString += tr(" Std ");
|
||||
builderString += tr("Bus: ") + QString::number(thisFrame.bus);
|
||||
builderString += " Len: " + QString::number(thisFrame.payload().length()) + "\n";
|
||||
builderString += tr("Bus: ") + QString::number(frame->bus);
|
||||
builderString += " Len: " + QString::number(dataLen) + "\n";
|
||||
outFile->write(builderString.toUtf8());
|
||||
|
||||
builderString = tr("Data Bytes: ");
|
||||
for (unsigned int temp = 0; temp < thisFrame.payload().length(); temp++)
|
||||
for (int temp = 0; temp < dataLen; temp++)
|
||||
{
|
||||
builderString += Utility::formatNumber(thisFrame.payload()[temp]) + " ";
|
||||
builderString += Utility::formatNumber(data[temp]) + " ";
|
||||
}
|
||||
builderString += "\n";
|
||||
outFile->write(builderString.toUtf8());
|
||||
@@ -759,14 +766,14 @@ Data Bytes: 88 10 00 13 BB 00 06 00
|
||||
builderString = "";
|
||||
if (dbcHandler != nullptr)
|
||||
{
|
||||
DBC_MESSAGE *msg = dbcHandler->findMessage(thisFrame);
|
||||
DBC_MESSAGE *msg = dbcHandler->findMessage(*frame);
|
||||
if (msg != nullptr)
|
||||
{
|
||||
for (int j = 0; j < msg->sigHandler->getCount(); j++)
|
||||
{
|
||||
|
||||
QString temp;
|
||||
if (msg->sigHandler->findSignalByIdx(j)->processAsText(thisFrame, temp))
|
||||
if (msg->sigHandler->findSignalByIdx(j)->processAsText(*frame, temp))
|
||||
{
|
||||
builderString.append("\t" + temp);
|
||||
builderString.append("\n");
|
||||
|
||||
+22
-14
@@ -123,6 +123,8 @@ void FileComparatorWindow::calculateDetails()
|
||||
QTreeWidgetItem *interestedOnlyBase, *referenceOnlyBase = nullptr, *sharedBase, *bitmapBaseInterested, *bitmapBaseReference = nullptr;
|
||||
QTreeWidgetItem *valuesBase, *detail, *sharedItem, *valuesInterested, *valuesReference = nullptr;
|
||||
uint64_t tmp;
|
||||
unsigned char *data;
|
||||
int dataLen;
|
||||
|
||||
bool uniqueInterested = ui->ckUniqueToInterested->isChecked();
|
||||
|
||||
@@ -152,12 +154,15 @@ void FileComparatorWindow::calculateDetails()
|
||||
for (int x = 0; x < interestedFrames.count(); x++)
|
||||
{
|
||||
CANFrame frame = interestedFrames.at(x);
|
||||
data = reinterpret_cast<unsigned char *>(frame.payload().data());
|
||||
dataLen = frame.payload().count();
|
||||
|
||||
if (interestedIDs.contains(frame.frameId())) //if we saw this ID before then add to the QList in there
|
||||
{
|
||||
for (unsigned int y = 0; y < frame.payload().length(); y++)
|
||||
for (unsigned int y = 0; y < dataLen; y++)
|
||||
{
|
||||
interestedIDs[frame.frameId()].values[y][frame.payload()[y]]++;
|
||||
tmp = frame.payload()[y];
|
||||
interestedIDs[frame.frameId()].values[y][data[y]]++;
|
||||
tmp = data[y];
|
||||
tmp = tmp << (8 * y);
|
||||
interestedIDs[frame.frameId()].bitmap |= tmp;
|
||||
//qDebug() << "bitmap: " << QString::number(interestedIDs[frame.frameId()].bitmap, 16);
|
||||
@@ -167,7 +172,7 @@ void FileComparatorWindow::calculateDetails()
|
||||
{
|
||||
FrameData *newData = new FrameData();
|
||||
newData->ID = frame.frameId();
|
||||
newData->dataLen = frame.payload().length();
|
||||
newData->dataLen = dataLen;
|
||||
//it would be possible to implement a constructor for FrameData
|
||||
//that sets the bitmap and values to zero. That would be cleaner and better.
|
||||
newData->bitmap = 0;
|
||||
@@ -179,10 +184,10 @@ void FileComparatorWindow::calculateDetails()
|
||||
}
|
||||
}
|
||||
//memset(newData->values, 0, 256 * 8);
|
||||
for (unsigned int y = 0; y < frame.payload().length(); y++)
|
||||
for (unsigned int y = 0; y < dataLen; y++)
|
||||
{
|
||||
newData->values[y][frame.payload()[y]] = 1;
|
||||
tmp = frame.payload()[y];
|
||||
newData->values[y][data[y]] = 1;
|
||||
tmp = data[y];
|
||||
tmp = tmp << (8 * y);
|
||||
newData->bitmap |= tmp;
|
||||
//qDebug() << "bitmap: " << QString::number(newData->bitmap, 16);
|
||||
@@ -196,12 +201,15 @@ void FileComparatorWindow::calculateDetails()
|
||||
for (int x = 0; x < referenceFrames.count(); x++)
|
||||
{
|
||||
CANFrame frame = referenceFrames.at(x);
|
||||
data = reinterpret_cast<unsigned char *>(frame.payload().data());
|
||||
dataLen = frame.payload().count();
|
||||
|
||||
if (referenceIDs.contains(frame.frameId())) //if we saw this ID before then add to the QList in there
|
||||
{
|
||||
for (unsigned int y = 0; y < frame.payload().length(); y++)
|
||||
for (unsigned int y = 0; y < dataLen; y++)
|
||||
{
|
||||
referenceIDs[frame.frameId()].values[y][frame.payload()[y]]++;
|
||||
tmp = frame.payload()[y];
|
||||
referenceIDs[frame.frameId()].values[y][data[y]]++;
|
||||
tmp = data[y];
|
||||
tmp = tmp << (8 * y);
|
||||
referenceIDs[frame.frameId()].bitmap |= tmp;
|
||||
//qDebug() << "bitmap: " << QString::number(referenceIDs[frame.frameId()].bitmap, 16);
|
||||
@@ -211,7 +219,7 @@ void FileComparatorWindow::calculateDetails()
|
||||
{
|
||||
FrameData *newData = new FrameData();
|
||||
newData->ID = frame.frameId();
|
||||
newData->dataLen = frame.payload().length();
|
||||
newData->dataLen = dataLen;
|
||||
newData->bitmap = 0;
|
||||
for (int x = 0; x < 8; x++)
|
||||
{
|
||||
@@ -221,10 +229,10 @@ void FileComparatorWindow::calculateDetails()
|
||||
}
|
||||
}
|
||||
//memset(newData->values, 0, 256 * 8);
|
||||
for (unsigned int y = 0; y < frame.payload().length(); y++)
|
||||
for (unsigned int y = 0; y < dataLen; y++)
|
||||
{
|
||||
newData->values[y][frame.payload()[y]] = 1;
|
||||
tmp = frame.payload()[y];
|
||||
newData->values[y][data[y]] = 1;
|
||||
tmp = data[y];
|
||||
tmp = tmp << (8 * y);
|
||||
newData->bitmap |= tmp;
|
||||
//qDebug() << "bitmap: " << QString::number(newData->bitmap, 16);
|
||||
|
||||
+29
-17
@@ -257,7 +257,7 @@ void FlowViewWindow::plottableDoubleClick(QCPAbstractPlottable* plottable, QMous
|
||||
|
||||
void FlowViewWindow::gotCenterTimeID(int32_t ID, double timestamp)
|
||||
{
|
||||
uint64_t t_stamp;
|
||||
int64_t t_stamp;
|
||||
|
||||
t_stamp = timestamp * 1000000l;
|
||||
|
||||
@@ -397,8 +397,10 @@ void FlowViewWindow::updatedFrames(int numFrames)
|
||||
{
|
||||
QVector<double>newX[8];
|
||||
QVector<double>newY[8];
|
||||
unsigned char *data;
|
||||
int dataLen = 0;
|
||||
|
||||
CANFrame thisFrame;
|
||||
const CANFrame *thisFrame;
|
||||
if (numFrames == -1) //all frames deleted. Kill the display
|
||||
{
|
||||
ui->listFrameID->clear();
|
||||
@@ -433,35 +435,37 @@ void FlowViewWindow::updatedFrames(int numFrames)
|
||||
bool needRefresh = false;
|
||||
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());
|
||||
dataLen = thisFrame->payload().length();
|
||||
|
||||
if (!foundID.contains(thisFrame.frameId()))
|
||||
if (!foundID.contains(thisFrame->frameId()))
|
||||
{
|
||||
foundID.append(thisFrame.frameId());
|
||||
FilterUtility::createFilterItem(thisFrame.frameId(), ui->listFrameID);
|
||||
foundID.append(thisFrame->frameId());
|
||||
FilterUtility::createFilterItem(thisFrame->frameId(), ui->listFrameID);
|
||||
}
|
||||
|
||||
if (thisFrame.frameId() == refID)
|
||||
if (thisFrame->frameId() == refID)
|
||||
{
|
||||
frameCache.append(thisFrame);
|
||||
frameCache.append(*thisFrame);
|
||||
|
||||
for (int k = 0; k < 8; k++)
|
||||
for (int k = 0; k < dataLen; k++)
|
||||
{
|
||||
if (ui->cbTimeGraph->isChecked())
|
||||
{
|
||||
if (secondsMode){
|
||||
newX[k].append((double)(thisFrame.timeStamp().microSeconds()) / 1000000.0);
|
||||
newX[k].append((double)(thisFrame->timeStamp().microSeconds()) / 1000000.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
newX[k].append(thisFrame.timeStamp().microSeconds());
|
||||
newX[k].append(thisFrame->timeStamp().microSeconds());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newX[k].append(x[k].count());
|
||||
}
|
||||
newY[k].append(thisFrame.payload()[k]);
|
||||
newY[k].append(data[k]);
|
||||
needRefresh = true;
|
||||
}
|
||||
}
|
||||
@@ -475,7 +479,7 @@ void FlowViewWindow::updatedFrames(int numFrames)
|
||||
}
|
||||
if (needRefresh)
|
||||
{
|
||||
for (int k = 0; k < 8; k++)
|
||||
for (int k = 0; k < dataLen; k++)
|
||||
{
|
||||
if (graphRef[k] && graphRef[k]->data())
|
||||
graphRef[k]->addData(newX[k], newY[k]);
|
||||
@@ -498,6 +502,9 @@ void FlowViewWindow::createGraph(int byteNum)
|
||||
{
|
||||
int tempVal;
|
||||
float minval=1000000, maxval = -100000;
|
||||
unsigned char *data;
|
||||
int dataLen = 0;
|
||||
const CANFrame *frame;
|
||||
|
||||
qDebug() << "Create Graph " << byteNum;
|
||||
|
||||
@@ -512,16 +519,20 @@ void FlowViewWindow::createGraph(int byteNum)
|
||||
|
||||
for (int j = 0; j < numEntries; j++)
|
||||
{
|
||||
tempVal = frameCache[j].payload()[byteNum];
|
||||
frame = &frameCache[j];
|
||||
data = reinterpret_cast<unsigned char *>(frame->payload().data());
|
||||
dataLen = frame->payload().length();
|
||||
|
||||
tempVal = data[byteNum];
|
||||
|
||||
if (graphByTime)
|
||||
{
|
||||
if (secondsMode){
|
||||
x[byteNum][j] = (double)(frameCache[j].timeStamp().microSeconds()) / 1000000.0;
|
||||
x[byteNum][j] = (double)(frame->timeStamp().microSeconds()) / 1000000.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
x[byteNum][j] = frameCache[j].timeStamp().microSeconds();
|
||||
x[byteNum][j] = frame->timeStamp().microSeconds();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -758,7 +769,8 @@ void FlowViewWindow::updatePosition(bool forward)
|
||||
uint8_t cngByte;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
cngByte = currBytes[i] ^ frameCache.at(currentPosition).payload()[i];
|
||||
unsigned char thisByte = static_cast<unsigned char>(frameCache.at(currentPosition).payload().data()[i]);
|
||||
cngByte = currBytes[i] ^ thisByte;
|
||||
changedBits |= (uint64_t)cngByte << (8ull * i);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ signals:
|
||||
|
||||
private:
|
||||
Ui::FlowViewWindow *ui;
|
||||
QList<int> foundID;
|
||||
QList<quint32> foundID;
|
||||
QList<CANFrame> frameCache;
|
||||
const QVector<CANFrame> *modelFrames;
|
||||
unsigned char refBytes[8];
|
||||
|
||||
+18
-9
@@ -138,7 +138,7 @@ FrameInfoWindow::~FrameInfoWindow()
|
||||
|
||||
void FrameInfoWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
Q_UNUSED(event)
|
||||
writeSettings();
|
||||
}
|
||||
|
||||
@@ -260,10 +260,10 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
||||
uint8_t referenceBits[8];
|
||||
QTreeWidgetItem *baseNode, *dataBase, *histBase, *tempItem;
|
||||
|
||||
targettedID = static_cast<int>(Utility::ParseStringToNum(newID));
|
||||
|
||||
if (modelFrames->count() == 0) return;
|
||||
|
||||
targettedID = static_cast<int>(Utility::ParseStringToNum(newID));
|
||||
|
||||
qDebug() << "Started update details window with id " << targettedID;
|
||||
|
||||
avgInterval = 0;
|
||||
@@ -278,6 +278,9 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
||||
if (thisFrame.frameId() == static_cast<uint32_t>(targettedID)) frameCache.append(thisFrame);
|
||||
}
|
||||
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(frameCache.at(0).payload().data());
|
||||
int dataLen = frameCache.at(0).payload().length();
|
||||
|
||||
ui->treeDetails->clear();
|
||||
|
||||
if (frameCache.count() == 0) return;
|
||||
@@ -364,10 +367,13 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
||||
}
|
||||
for (int j = 0; j < 64; j++) bitfieldHistogram[j] = 0;
|
||||
|
||||
for (int c = 0; c < 8; c++)
|
||||
data = reinterpret_cast<unsigned char *>(frameCache.at(0).payload().data());
|
||||
dataLen = frameCache.at(0).payload().length();
|
||||
|
||||
for (int c = 0; c < dataLen; c++)
|
||||
{
|
||||
changedBits[c] = 0;
|
||||
referenceBits[c] = frameCache.at(0).payload()[c];
|
||||
referenceBits[c] = data[c];
|
||||
//qDebug() << referenceBits[c];
|
||||
}
|
||||
|
||||
@@ -377,10 +383,13 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
||||
//then find all data points
|
||||
for (int j = 0; j < frameCache.count(); j++)
|
||||
{
|
||||
data = reinterpret_cast<unsigned char *>(frameCache.at(j).payload().data());
|
||||
dataLen = frameCache.at(j).payload().length();
|
||||
|
||||
byteGraphX.append(j);
|
||||
for (uint32_t bytcnt = 0; bytcnt < frameCache[j].payload().length(); bytcnt++)
|
||||
for (uint32_t bytcnt = 0; bytcnt < dataLen; bytcnt++)
|
||||
{
|
||||
byteGraphY[bytcnt].append(frameCache[j].payload()[bytcnt]);
|
||||
byteGraphY[bytcnt].append(data[bytcnt]);
|
||||
}
|
||||
|
||||
if (j != 0)
|
||||
@@ -398,12 +407,12 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
||||
if (thisInterval < minInterval) minInterval = thisInterval;
|
||||
avgInterval += thisInterval;
|
||||
}
|
||||
thisLen = frameCache.at(j).payload().length();
|
||||
thisLen = dataLen;
|
||||
if (thisLen > maxLen) maxLen = thisLen;
|
||||
if (thisLen < minLen) minLen = thisLen;
|
||||
for (int c = 0; c < thisLen; c++)
|
||||
{
|
||||
unsigned char dat = frameCache.at(j).payload()[c];
|
||||
unsigned char dat = data[c];
|
||||
if (minData[c] > dat) minData[c] = dat;
|
||||
if (maxData[c] < dat) maxData[c] = dat;
|
||||
dataHistogram[dat][c]++; //add one to count for this
|
||||
|
||||
@@ -81,7 +81,7 @@ void ISOTP_InterpreterWindow::showEvent(QShowEvent* event)
|
||||
|
||||
void ISOTP_InterpreterWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
Q_UNUSED(event)
|
||||
removeEventFilter(this);
|
||||
writeSettings();
|
||||
}
|
||||
@@ -194,7 +194,7 @@ void ISOTP_InterpreterWindow::updatedFrames(int numFrames)
|
||||
void ISOTP_InterpreterWindow::headerClicked(int logicalIndex)
|
||||
{
|
||||
ui->tableIsoFrames->setSortingEnabled(false);
|
||||
ui->tableIsoFrames->sortByColumn(logicalIndex);
|
||||
ui->tableIsoFrames->sortByColumn(logicalIndex, Qt::SortOrder::AscendingOrder);
|
||||
}
|
||||
|
||||
void ISOTP_InterpreterWindow::showDetailView()
|
||||
@@ -208,17 +208,21 @@ void ISOTP_InterpreterWindow::showDetailView()
|
||||
|
||||
msg = &messages[rowNum];
|
||||
|
||||
if (msg->len != msg->data.length())
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(msg->payload().data());
|
||||
int dataLen = msg->payload().length();
|
||||
|
||||
if (msg->reportedLength != dataLen)
|
||||
{
|
||||
buildString.append("Message didn't have the correct number of bytes.\rExpected "
|
||||
+ QString::number(msg->len) + " got "
|
||||
+ QString::number(msg->data.length()) + "\r\r");
|
||||
+ QString::number(msg->reportedLength) + " got "
|
||||
+ QString::number(dataLen) + "\r\r");
|
||||
}
|
||||
|
||||
buildString.append(tr("Raw Payload: "));
|
||||
for (int i = 0; i < messages[rowNum].data.count(); i++)
|
||||
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
buildString.append(Utility::formatNumber((char)messages[rowNum].data[i]));
|
||||
buildString.append(Utility::formatNumber(data[i]));
|
||||
buildString.append(" ");
|
||||
}
|
||||
buildString.append("\r\r");
|
||||
@@ -262,17 +266,20 @@ void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE msg)
|
||||
int rowNum;
|
||||
QString tempString;
|
||||
|
||||
if ((msg.len != msg.data.count()) && !ui->cbShowIncomplete->isChecked()) return;
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(msg.payload().data());
|
||||
int dataLen = msg.payload().length();
|
||||
|
||||
if (idFilters.find(msg.ID) == idFilters.end())
|
||||
if ((msg.reportedLength != dataLen) && !ui->cbShowIncomplete->isChecked()) return;
|
||||
|
||||
if (idFilters.find(msg.frameId()) == idFilters.end())
|
||||
{
|
||||
idFilters.insert(msg.ID, true);
|
||||
idFilters.insert(msg.frameId(), true);
|
||||
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(msg.ID, msg.extended), ui->listFilter);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(msg.frameId(), msg.hasExtendedFrameFormat()), ui->listFilter);
|
||||
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
||||
listItem->setCheckState(Qt::Checked);
|
||||
}
|
||||
if (!idFilters[msg.ID]) return;
|
||||
if (!idFilters[msg.frameId()]) return;
|
||||
messages.append(msg);
|
||||
|
||||
rowNum = ui->tableIsoFrames->rowCount();
|
||||
@@ -280,22 +287,21 @@ void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE msg)
|
||||
ui->tableIsoFrames->insertRow(rowNum);
|
||||
|
||||
QTableWidgetItem *item = new QTableWidgetItem;
|
||||
item->setData(Qt::EditRole, Utility::formatTimestamp(msg.timestamp));
|
||||
item->setData(Qt::EditRole, Utility::formatTimestamp(msg.timeStamp().microSeconds()));
|
||||
//ui->tableIsoFrames->setItem(rowNum, 0, (double)msg.timestamp, Utility::formatTimestamp(msg.timestamp)));
|
||||
ui->tableIsoFrames->setItem(rowNum, 0, item);
|
||||
ui->tableIsoFrames->setItem(rowNum, 1, new QTableWidgetItem(QString::number(msg.ID, 16)));
|
||||
ui->tableIsoFrames->setItem(rowNum, 1, new QTableWidgetItem(QString::number(msg.frameId(), 16)));
|
||||
ui->tableIsoFrames->setItem(rowNum, 2, new QTableWidgetItem(QString::number(msg.bus)));
|
||||
if (msg.isReceived) ui->tableIsoFrames->setItem(rowNum, 3, new QTableWidgetItem("Rx"));
|
||||
else ui->tableIsoFrames->setItem(rowNum, 3, new QTableWidgetItem("Tx"));
|
||||
ui->tableIsoFrames->setItem(rowNum, 4, new QTableWidgetItem(QString::number(msg.len)));
|
||||
ui->tableIsoFrames->setItem(rowNum, 4, new QTableWidgetItem(QString::number(msg.payload().length())));
|
||||
|
||||
for (int i = 0; i < msg.data.count(); i++)
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
tempString.append(Utility::formatNumber((char)msg.data[i]));
|
||||
tempString.append(Utility::formatNumber(data[i]));
|
||||
tempString.append(" ");
|
||||
}
|
||||
ui->tableIsoFrames->setItem(rowNum, 5, new QTableWidgetItem(tempString));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,18 +6,23 @@
|
||||
SnifferItem::SnifferItem(const CANFrame& pFrame, quint32 seq):
|
||||
mID(pFrame.frameId())
|
||||
{
|
||||
for (int i = 0; i < 8; i++) {
|
||||
mNotch[i] =0;
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(pFrame.payload().data());
|
||||
int dataLen = pFrame.payload().length();
|
||||
|
||||
for (int i = 0; i < 0; i++) {
|
||||
mNotch[i] = 0;
|
||||
mMarker.data[i] = 0;
|
||||
mMarker.dataTimestamp[i] = 0;
|
||||
mCurrent.data[i] = pFrame.payload()[i];
|
||||
if (i < dataLen) mCurrent.data[i] = data[i];
|
||||
else mCurrent.data[i] = 0;
|
||||
mCurrent.dataTimestamp[i] = seq;
|
||||
}
|
||||
mLastMarker = mMarker;
|
||||
mCurrent.len = pFrame.payload().length();
|
||||
mCurrent.len = dataLen;
|
||||
|
||||
/* that's dirty */
|
||||
update(pFrame, seq, false);
|
||||
update(pFrame, seq, false);
|
||||
update(pFrame, seq, false); //anyone know why we're doing this twice?!
|
||||
}
|
||||
|
||||
|
||||
@@ -112,20 +117,23 @@ void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq, bool mute)
|
||||
mLastTime = mCurrentTime;
|
||||
mCurrSeqVal = timeSeq;
|
||||
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(pFrame.payload().data());
|
||||
int dataLen = pFrame.payload().length();
|
||||
|
||||
/* copy new value */
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
maskedData = pFrame.payload()[i];
|
||||
maskedData = data[i];
|
||||
if (mute) maskedData &= ~mNotch[i];
|
||||
maskedCurr = mCurrent.data[i];
|
||||
if (mute) maskedCurr &= ~mNotch[i];
|
||||
if (maskedCurr != maskedData)
|
||||
{
|
||||
mCurrent.data[i] = pFrame.payload()[i];
|
||||
mCurrent.data[i] = data[i];
|
||||
mCurrent.dataTimestamp[i] = timeSeq;
|
||||
}
|
||||
}
|
||||
mCurrent.len = pFrame.payload().length();
|
||||
mCurrent.len = dataLen;
|
||||
mCurrentTime = pFrame.timeStamp().microSeconds();
|
||||
|
||||
/* update marker */
|
||||
|
||||
+13
-11
@@ -237,8 +237,8 @@ void UDSScanWindow::scanUDS()
|
||||
|
||||
for (id = startID; id <= endID; id++)
|
||||
{
|
||||
test.ID = id;
|
||||
test.data.clear();
|
||||
test.setFrameId( id );
|
||||
test.payload().clear();
|
||||
|
||||
if (ui->ckTester->isChecked())
|
||||
{
|
||||
@@ -354,17 +354,19 @@ void UDSScanWindow::gotUDSReply(UDS_MESSAGE msg)
|
||||
int offset = ui->spinReplyOffset->value();
|
||||
UDS_MESSAGE sentFrame;
|
||||
bool gotReply = false;
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(msg.payload().data());
|
||||
int dataLen = msg.payload().length();
|
||||
|
||||
int numSending = sendingFrames.length();
|
||||
if (numSending == 0) return;
|
||||
if (currIdx >= numSending) return;
|
||||
sentFrame = sendingFrames[currIdx];
|
||||
|
||||
id = msg.ID;
|
||||
id = msg.frameId();
|
||||
|
||||
qDebug() << "UDS message ID " << QString::number(msg.ID,16) << " service: " << QString::number(msg.service, 16) << " subfunc: " << QString::number(msg.subFunc, 16);
|
||||
qDebug() << "UDS message ID " << QString::number(msg.frameId(),16) << " service: " << QString::number(msg.service, 16) << " subfunc: " << QString::number(msg.subFunc, 16);
|
||||
|
||||
if ((id == (uint32_t)(sentFrame.ID + offset)) || ui->cbAllowAdaptiveOffset->isChecked())
|
||||
if ((id == (uint32_t)(sentFrame.frameId() + offset)) || ui->cbAllowAdaptiveOffset->isChecked())
|
||||
{
|
||||
serviceShortName = udsHandler->getServiceShortDesc(sentFrame.service);
|
||||
if (serviceShortName.length() < 3) serviceShortName = QString::number(sentFrame.service, 16);
|
||||
@@ -374,10 +376,10 @@ void UDSScanWindow::gotUDSReply(UDS_MESSAGE msg)
|
||||
|
||||
QTreeWidgetItem *nodePositive = new QTreeWidgetItem();
|
||||
QString reply = "POSITIVE ";
|
||||
for (int i = 0; i < msg.data.length(); i++)
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
reply.append(" ");
|
||||
reply.append(Utility::formatHexNum(msg.data[i]));
|
||||
reply.append(Utility::formatHexNum(data[i]));
|
||||
}
|
||||
nodePositive->setText(0, reply);
|
||||
nodePositive->setForeground(0, QBrush(Qt::darkGreen));
|
||||
@@ -387,12 +389,12 @@ void UDSScanWindow::gotUDSReply(UDS_MESSAGE msg)
|
||||
}
|
||||
else if ( msg.isErrorReply && (msg.service == sendingFrames[currIdx].service) )
|
||||
{
|
||||
if (msg.data.length())
|
||||
if (dataLen)
|
||||
{
|
||||
setupNodes(id);
|
||||
QTreeWidgetItem *nodeNegative = new QTreeWidgetItem();
|
||||
qDebug() << ui->spinNumBytes->value();
|
||||
nodeNegative->setText(0, "NEGATIVE - " + udsHandler->getNegativeResponseShort(msg.data[0]));
|
||||
nodeNegative->setText(0, "NEGATIVE - " + udsHandler->getNegativeResponseShort(data[0]));
|
||||
nodeNegative->setForeground(0, QBrush(Qt::darkRed));
|
||||
nodeSubFunc->addChild(nodeNegative);
|
||||
nodeSubFunc->setForeground(0, QBrush(Qt::darkRed));
|
||||
@@ -413,10 +415,10 @@ void UDSScanWindow::setupNodes(uint32_t replyID)
|
||||
if (serviceShortName.length() < 3) serviceShortName = QString::number(sendingFrames[currIdx].service, 16);
|
||||
QTreeWidgetItem *replyNode = nullptr;
|
||||
|
||||
if (!nodeID || nodeID->text(0) != Utility::formatHexNum(sendingFrames[currIdx].ID))
|
||||
if (!nodeID || nodeID->text(0) != Utility::formatHexNum(sendingFrames[currIdx].frameId()))
|
||||
{
|
||||
nodeID = new QTreeWidgetItem();
|
||||
nodeID->setText(0, Utility::formatHexNum(sendingFrames[currIdx].ID));
|
||||
nodeID->setText(0, Utility::formatHexNum(sendingFrames[currIdx].frameId()));
|
||||
ui->treeResults->addTopLevelItem(nodeID);
|
||||
nodeService = nullptr;
|
||||
}
|
||||
|
||||
+32
-27
@@ -236,7 +236,7 @@ void CANScriptHelper::sendFrame(QJSValue bus, QJSValue id, QJSValue length, QJSV
|
||||
|
||||
if (!data.isArray()) qDebug() << "data isn't an array";
|
||||
|
||||
for (unsigned int i = 0; i < bytes.length(); i++)
|
||||
for (int i = 0; i < bytes.length(); i++)
|
||||
{
|
||||
bytes[i] = (uint8_t)data.property(i).toInt();
|
||||
}
|
||||
@@ -254,15 +254,19 @@ void CANScriptHelper::gotTargettedFrame(const CANFrame &frame)
|
||||
{
|
||||
if (!gotFrameFunction.isCallable()) return; //nothing to do if we can't even call the function
|
||||
//qDebug() << "Got frame in script interface";
|
||||
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(frame.payload().data());
|
||||
int dataLen = frame.payload().length();
|
||||
|
||||
for (int i = 0; i < filters.length(); i++)
|
||||
{
|
||||
if (filters[i].checkFilter(frame.frameId(), frame.bus))
|
||||
{
|
||||
QJSValueList args;
|
||||
args << frame.bus << frame.frameId() << frame.payload().length();
|
||||
QJSValue dataBytes = scriptEngine->newArray(frame.payload().length());
|
||||
QJSValue dataBytes = scriptEngine->newArray(dataLen);
|
||||
|
||||
for (unsigned int j = 0; j < frame.payload().length(); j++) dataBytes.setProperty(j, QJSValue((unsigned char)frame.payload()[j]));
|
||||
for (int j = 0; j < dataLen; j++) dataBytes.setProperty(j, QJSValue(data[j]));
|
||||
args.append(dataBytes);
|
||||
gotFrameFunction.call(args);
|
||||
return; //as soon as one filter matches we jump out
|
||||
@@ -299,26 +303,29 @@ void ISOTPScriptHelper::setFilter(QJSValue id, QJSValue mask, QJSValue bus)
|
||||
handler->addFilter(busVal, idVal, maskVal);
|
||||
}
|
||||
|
||||
void ISOTPScriptHelper::sendISOTP(QJSValue bus, QJSValue id, QJSValue length, QJSValue data)
|
||||
void ISOTPScriptHelper::sendISOTP(QJSValue bus, QJSValue id, QJSValue length, QJSValue dataBytes)
|
||||
{
|
||||
ISOTP_MESSAGE msg;
|
||||
msg.extended = false;
|
||||
msg.ID = id.toInt();
|
||||
msg.len = length.toUInt();
|
||||
msg.setExtendedFrameFormat(false);
|
||||
msg.setFrameId(id.toUInt());
|
||||
msg.payload().resize(length.toInt());
|
||||
|
||||
if (!data.isArray()) qDebug() << "data isn't an array";
|
||||
unsigned char *data = reinterpret_cast<unsigned char *>(msg.payload().data());
|
||||
int dataLen = msg.payload().length();
|
||||
|
||||
for (int i = 0; i < msg.len; i++)
|
||||
if (!dataBytes.isArray()) qDebug() << "data isn't an array";
|
||||
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
msg.data[i] = static_cast<uint8_t>(data.property(i).toInt());
|
||||
data[i] = static_cast<uint8_t>(dataBytes.property(i).toInt());
|
||||
}
|
||||
|
||||
msg.bus = bus.toInt();
|
||||
|
||||
if (msg.ID > 0x7FF) msg.extended = true;
|
||||
if (msg.frameId() > 0x7FF) msg.setExtendedFrameFormat(true);
|
||||
|
||||
qDebug() << "sending isotp message from script";
|
||||
handler->sendISOTPFrame(msg.bus, msg.ID, msg.data);
|
||||
handler->sendISOTPFrame(msg.bus, msg.frameId(), msg.payload());
|
||||
}
|
||||
|
||||
void ISOTPScriptHelper::setRxCallback(QJSValue cb)
|
||||
@@ -333,10 +340,10 @@ void ISOTPScriptHelper::newISOMessage(ISOTP_MESSAGE msg)
|
||||
//qDebug() << "Got frame in script interface";
|
||||
|
||||
QJSValueList args;
|
||||
args << msg.bus << msg.ID << msg.len;
|
||||
QJSValue dataBytes = scriptEngine->newArray(static_cast<uint>(msg.len));
|
||||
args << msg.bus << msg.frameId() << msg.payload().length();
|
||||
QJSValue dataBytes = scriptEngine->newArray(static_cast<uint>(msg.payload().length()));
|
||||
|
||||
for (int j = 0; j < msg.len; j++) dataBytes.setProperty(static_cast<quint32>(j), QJSValue(msg.data[j]));
|
||||
for (int j = 0; j < msg.payload().length(); j++) dataBytes.setProperty(static_cast<quint32>(j), QJSValue((unsigned char)msg.payload()[j]));
|
||||
args.append(dataBytes);
|
||||
gotFrameFunction.call(args);
|
||||
}
|
||||
@@ -373,25 +380,23 @@ void UDSScriptHelper::setFilter(QJSValue id, QJSValue mask, QJSValue bus)
|
||||
void UDSScriptHelper::sendUDS(QJSValue bus, QJSValue id, QJSValue service, QJSValue sublen, QJSValue subFunc, QJSValue length, QJSValue data)
|
||||
{
|
||||
UDS_MESSAGE msg;
|
||||
msg.extended = false;
|
||||
msg.ID = id.toUInt();
|
||||
msg.len = length.toUInt();
|
||||
msg.setExtendedFrameFormat(false);
|
||||
msg.setFrameId( id.toUInt() );
|
||||
msg.payload().resize(length.toUInt());
|
||||
msg.service = service.toUInt();
|
||||
msg.subFuncLen = sublen.toUInt();
|
||||
msg.subFunc = subFunc.toUInt();
|
||||
|
||||
if (!data.isArray()) qDebug() << "data isn't an array";
|
||||
|
||||
msg.data.reserve(msg.len);
|
||||
|
||||
for (int i = 0; i < msg.len; i++)
|
||||
for (int i = 0; i < msg.payload().length(); i++)
|
||||
{
|
||||
msg.data.append(static_cast<uint8_t>(data.property(static_cast<quint32>(i)).toInt()));
|
||||
msg.payload().append(static_cast<uint8_t>(data.property(static_cast<quint32>(i)).toInt()));
|
||||
}
|
||||
|
||||
msg.bus = bus.toInt();
|
||||
|
||||
if (msg.ID > 0x7FF) msg.extended = true;
|
||||
if (msg.frameId() > 0x7FF) msg.setExtendedFrameFormat( true );
|
||||
|
||||
qDebug() << "sending UDS message from script";
|
||||
|
||||
@@ -406,15 +411,15 @@ void UDSScriptHelper::setRxCallback(QJSValue cb)
|
||||
void UDSScriptHelper::newUDSMessage(UDS_MESSAGE msg)
|
||||
{
|
||||
//qDebug() << "udsScriptHelper got a UDS message";
|
||||
qDebug() << "UDS script helper. Msg data len: " << msg.len;
|
||||
qDebug() << "UDS script helper. Msg data len: " << msg.payload().length();
|
||||
if (!gotFrameFunction.isCallable()) return; //nothing to do if we can't even call the function
|
||||
qDebug() << "Got frame in script interface";
|
||||
|
||||
QJSValueList args;
|
||||
args << msg.bus << msg.ID << msg.service << msg.subFunc << msg.len;
|
||||
QJSValue dataBytes = scriptEngine->newArray(static_cast<unsigned int>(msg.len));
|
||||
args << msg.bus << msg.frameId() << msg.service << msg.subFunc << msg.payload().length();
|
||||
QJSValue dataBytes = scriptEngine->newArray(static_cast<unsigned int>(msg.payload().length()));
|
||||
|
||||
for (int j = 0; j < msg.data.length(); j++) dataBytes.setProperty(static_cast<quint32>(j), QJSValue(msg.data[j]));
|
||||
for (int j = 0; j < msg.payload().length(); j++) dataBytes.setProperty(static_cast<quint32>(j), QJSValue((unsigned char)msg.payload()[j]));
|
||||
args.append(dataBytes);
|
||||
gotFrameFunction.call(args);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ ScriptingWindow::ScriptingWindow(const QVector<CANFrame> *frames, QWidget *paren
|
||||
editor = new JSEdit();
|
||||
editor->setFrameShape(JSEdit::NoFrame);
|
||||
editor->setWordWrapMode(QTextOption::NoWrap);
|
||||
editor->setTabStopWidth(4);
|
||||
editor->setEnabled(false);
|
||||
editor->setFont(QFont("Monospace", 12));
|
||||
editor->show();
|
||||
|
||||
@@ -97,15 +97,6 @@ public:
|
||||
else return formatHexNum(value);
|
||||
}
|
||||
|
||||
static QString formatNumber(char value)
|
||||
{
|
||||
if (decimalMode)
|
||||
{
|
||||
return QString::number((unsigned char)value, 10);
|
||||
}
|
||||
else return formatHexNum((unsigned char)value);
|
||||
}
|
||||
|
||||
static QString formatCANID(uint64_t id, bool extended)
|
||||
{
|
||||
if (decimalMode) return QString::number(id, 10);
|
||||
|
||||
Reference in New Issue
Block a user