A partial commit that changes CANFrame over to be based on

QCanBusFrame so that things are more compatible with other Qt based
CAN bus code. Not complete yet but getting there.
This commit is contained in:
Collin Kidder
2019-12-11 21:17:33 -05:00
parent 29b635a009
commit 0baffa300f
22 changed files with 272 additions and 278 deletions
+2 -2
View File
@@ -66,7 +66,7 @@ void BisectWindow::refreshIDList()
int id; int id;
for (int i = 0; i < modelFrames->count(); i++) for (int i = 0; i < modelFrames->count(); i++)
{ {
id = modelFrames->at(i).ID; id = modelFrames->at(i).frameId();
if (!foundID.contains(id)) if (!foundID.contains(id))
{ {
foundID.append(id); foundID.append(id);
@@ -129,7 +129,7 @@ void BisectWindow::handleCalculateButton()
uint32_t upperID = Utility::ParseStringToNum2(ui->cbIDUpper->currentText()); uint32_t upperID = Utility::ParseStringToNum2(ui->cbIDUpper->currentText());
for (int i = 0; i < modelFrames->count(); i++) for (int i = 0; i < modelFrames->count(); i++)
{ {
if (modelFrames->at(i).ID >= lowerID && modelFrames->at(i).ID <= upperID) splitFrames.append(modelFrames->at(i)); if (modelFrames->at(i).frameId() >= lowerID && modelFrames->at(i).frameId() <= upperID) splitFrames.append(modelFrames->at(i));
} }
} }
refreshFrameNumbers(); refreshFrameNumbers();
+58 -57
View File
@@ -50,7 +50,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, QVector<unsigned char> data)
{ {
CANFrame frame; CANFrame frame;
frame.remote = false; frame.setFrameType(QCanBusFrame::DataFrame);
int currByte = 0; int currByte = 0;
int index = 0; int index = 0;
if (bus < 0) return; if (bus < 0) return;
@@ -61,27 +61,28 @@ void ISOTP_HANDLER::sendISOTPFrame(int bus, int ID, QVector<unsigned char> data)
if (data.length() < 8) if (data.length() < 8)
{ {
frame.bus = bus; frame.bus = bus;
frame.ID = ID; frame.setFrameId(ID);
if (ID > 0x7FF) frame.extended = true; if (ID > 0x7FF) frame.setExtendedFrameFormat(true);
else frame.extended = false; else frame.setExtendedFrameFormat(false);
frame.len = 8; QByteArray bytes(8,0);
for (int b = 0; b < 8; b++) frame.data[b] = 0x00; bytes.resize(8);
frame.data[0] = data.length(); bytes[0] = data.length();
for (int i = 0; i < frame.data[0]; i++) frame.data[i + 1] = data[i]; for (int i = 0; i < data.length(); i++) bytes[i + 1] = data[i];
frame.setPayload(bytes);
CANConManager::getInstance()->sendFrame(frame); CANConManager::getInstance()->sendFrame(frame);
} }
else //need to send a multi-part ISO_TP message - Respects timing and frame number based flow control else //need to send a multi-part ISO_TP message - Respects timing and frame number based flow control
{ {
frame.bus = bus; frame.bus = bus;
frame.ID = ID; frame.setFrameId(ID);
if (ID > 0x7FF) frame.extended = true; if (ID > 0x7FF) frame.setExtendedFrameFormat(true);
else frame.extended = false; else frame.setExtendedFrameFormat(false);
frame.len = 8; QByteArray bytes(8, 0);
for (int b = 0; b < 8; b++) frame.data[b] = 0x00; bytes[0] = 0x10 + (data.length() / 256);
frame.data[0] = 0x10 + (data.length() / 256); bytes[1] = data.length() & 0xFF;
frame.data[1] = data.length() & 0xFF; for (int i = 0; i < 6; i++) bytes[2 + i] = data[currByte++];
for (int i = 0; i < 6; i++) frame.data[2 + i] = data[currByte++]; frame.setPayload(bytes);
CANConManager::getInstance()->sendFrame(frame); CANConManager::getInstance()->sendFrame(frame);
//Queue up the rest of the frames //Queue up the rest of the frames
waitingForFlow = true; waitingForFlow = true;
@@ -90,13 +91,13 @@ void ISOTP_HANDLER::sendISOTPFrame(int bus, int ID, QVector<unsigned char> data)
frameTimer.start(); frameTimer.start();
while (currByte < data.length()) while (currByte < data.length())
{ {
for (int b = 0; b < 8; b++) frame.data[b] = 0x00; for (int b = 0; b < 8; b++) bytes[b] = 0x00;
frame.data[0] = 0x20 + index; bytes[0] = 0x20 + index;
index = (index + 1) & 0xF; index = (index + 1) & 0xF;
int bytesToGo = data.length() - currByte; int bytesToGo = data.length() - currByte;
if (bytesToGo > 7) bytesToGo = 7; if (bytesToGo > 7) bytesToGo = 7;
for (int i = 0; i < bytesToGo; i++) frame.data[1 + i] = data[currByte++]; for (int i = 0; i < bytesToGo; i++) bytes[1 + i] = data[currByte++];
frame.len = 8; frame.setPayload(bytes);
sendingFrames.append(frame); sendingFrames.append(frame);
//CANConManager::getInstance()->sendFrame(frame); //CANConManager::getInstance()->sendFrame(frame);
} }
@@ -138,7 +139,7 @@ void ISOTP_HANDLER::rapidFrames(const CANConnection* conn, const QVector<CANFram
{ {
for (int i = 0; i < filters.count(); i++) for (int i = 0; i < filters.count(); i++)
{ {
if ((thisFrame.bus == filters[i].bus) && ((thisFrame.ID & filters[i].mask) == filters[i].ID)) if ((thisFrame.bus == filters[i].bus) && ((thisFrame.frameId() & filters[i].mask) == filters[i].ID))
{ {
processFrame(thisFrame); processFrame(thisFrame);
break; break;
@@ -151,7 +152,7 @@ void ISOTP_HANDLER::rapidFrames(const CANConnection* conn, const QVector<CANFram
void ISOTP_HANDLER::processFrame(const CANFrame &frame) void ISOTP_HANDLER::processFrame(const CANFrame &frame)
{ {
uint64_t ID = frame.ID; uint64_t ID = frame.frameId();
int frameType; int frameType;
int frameLen; int frameLen;
int ln; int ln;
@@ -165,14 +166,14 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
if (useExtendedAddressing) if (useExtendedAddressing)
{ {
ID = ID << 8; ID = ID << 8;
ID += frame.data[0]; ID += frame.payload()[0];
frameType = frame.data[1] >> 4; frameType = frame.payload()[1] >> 4;
frameLen = frame.data[1] & 0xF; frameLen = frame.payload()[1] & 0xF;
} }
else else
{ {
frameType = frame.data[0] >> 4; frameType = frame.payload()[0] >> 4;
frameLen = frame.data[0] & 0xF; frameLen = frame.payload()[0] & 0xF;
} }
switch(frameType) switch(frameType)
@@ -185,42 +186,42 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
if (frameLen > 7) return; if (frameLen > 7) return;
msg.bus = frame.bus; msg.bus = frame.bus;
msg.extended = frame.extended; msg.extended = frame.hasExtendedFrameFormat();
msg.ID = ID; msg.ID = ID;
msg.isReceived = frame.isReceived; msg.isReceived = frame.isReceived;
msg.len = frameLen; msg.len = frameLen;
msg.data.reserve(frameLen); msg.data.reserve(frameLen);
msg.timestamp = frame.timestamp; msg.timestamp = frame.timeStamp().microSeconds();
msg.isMultiframe = false; msg.isMultiframe = false;
if (useExtendedAddressing) for (int j = 0; j < frameLen; j++) msg.data.append(frame.data[j+2]); 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.data[j+1]); else for (int j = 0; j < frameLen; j++) msg.data.append(frame.payload()[j+1]);
//qDebug() << "Emitting single frame ISOTP message"; //qDebug() << "Emitting single frame ISOTP message";
emit newISOMessage(msg); emit newISOMessage(msg);
break; break;
case 1: //first frame of a multi-frame message case 1: //first frame of a multi-frame message
checkNeedFlush(ID); checkNeedFlush(ID);
msg.bus = frame.bus; msg.bus = frame.bus;
msg.extended = frame.extended; msg.extended = frame.hasExtendedFrameFormat();
msg.ID = ID; msg.ID = ID;
msg.timestamp = frame.timestamp; msg.timestamp = frame.timeStamp().microSeconds();
msg.isReceived = frame.isReceived; msg.isReceived = frame.isReceived;
msg.isMultiframe = true; msg.isMultiframe = true;
frameLen = frameLen << 8; frameLen = frameLen << 8;
if (useExtendedAddressing) if (useExtendedAddressing)
{ {
frameLen += frame.data[2]; frameLen += frame.payload()[2];
frameLen = frameLen & 0xFFF; frameLen = frameLen & 0xFFF;
msg.len = frameLen; msg.len = frameLen;
msg.data.reserve(frameLen); msg.data.reserve(frameLen);
for (int j = 0; j < 5; j++) msg.data.append(frame.data[3 + j]); for (int j = 0; j < 5; j++) msg.data.append(frame.payload()[3 + j]);
} }
else else
{ {
frameLen += frame.data[1]; frameLen += frame.payload()[1];
frameLen = frameLen & 0xFFF; frameLen = frameLen & 0xFFF;
msg.len = frameLen; msg.len = frameLen;
msg.data.reserve(frameLen); msg.data.reserve(frameLen);
for (int j = 0; j < 6; j++) msg.data.append(frame.data[2 + j]); for (int j = 0; j < 6; j++) msg.data.append(frame.payload()[2 + j]);
} }
msg.lastSequence = -1; msg.lastSequence = -1;
messageBuffer.append(msg); messageBuffer.append(msg);
@@ -230,13 +231,13 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
{ {
CANFrame outFrame; CANFrame outFrame;
outFrame.bus = lastSenderBus; outFrame.bus = lastSenderBus;
outFrame.extended = false; outFrame.setExtendedFrameFormat(false);
outFrame.ID = lastSenderID; outFrame.setFrameId(lastSenderID);
outFrame.len = 8; QByteArray bytes(8, 0);
for (int b = 0; b < 8; b++) outFrame.data[b] = 0x00; bytes[0] = 0x30; //flow control, go ahead and send
outFrame.data[0] = 0x30; //flow control, go ahead and send bytes[1] = 0; //dont ask again about flow control
outFrame.data[1] = 0; //dont ask again about flow control bytes[2] = 3; //separation time in milliseconds between messages.
outFrame.data[2] = 3; //separation time in milliseconds between messages. outFrame.setPayload(bytes);
CANConManager::getInstance()->sendFrame(outFrame); CANConManager::getInstance()->sendFrame(outFrame);
} }
break; break;
@@ -257,12 +258,12 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
if (useExtendedAddressing) if (useExtendedAddressing)
{ {
if (ln > 6) ln = 6; if (ln > 6) ln = 6;
for (int j = 0; j < ln; j++) pMsg->data.append(frame.data[j+2]); for (int j = 0; j < ln; j++) pMsg->data.append(frame.payload()[j+2]);
} }
else else
{ {
if (ln > 7) ln = 7; if (ln > 7) ln = 7;
for (int j = 0; j < ln; j++) pMsg->data.append(frame.data[j+1]); for (int j = 0; j < ln; j++) pMsg->data.append(frame.payload()[j+1]);
} }
if (pMsg->len <= pMsg->data.count()) if (pMsg->len <= pMsg->data.count())
{ {
@@ -276,10 +277,10 @@ void ISOTP_HANDLER::processFrame(const CANFrame &frame)
case 0: //continue to send frames but maybe change inter-frame delay case 0: //continue to send frames but maybe change inter-frame delay
waitingForFlow = false; waitingForFlow = false;
//data[1] contains number of frames to send before waiting for next flow control //data[1] contains number of frames to send before waiting for next flow control
framesUntilFlow = frame.data[1]; framesUntilFlow = frame.payload()[1];
if (framesUntilFlow == 0) framesUntilFlow = -1; //-1 means don't count frames and just keep going 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) //data[2] contains the interframe delay to use (0xF1 through 0xF9 are special through)
if (frame.data[2] < 0xF1) frameTimer.start(frame.data[2]); //set proper delay between frames if (frame.payload()[2] < (char)0xF1) frameTimer.start(frame.payload()[2]); //set proper delay between frames
else frameTimer.start(1); //can't do sub-millisecond sending with this code so just use 1ms timing else frameTimer.start(1); //can't do sub-millisecond sending with this code so just use 1ms timing
break; break;
case 1: //wait - do not send any more frames until other side says so case 1: //wait - do not send any more frames until other side says so
@@ -307,14 +308,14 @@ void ISOTP_HANDLER::checkNeedFlush(uint64_t ID)
//used to pass by reference but now newISOMessage should pass by value which makes it easier to use cross thread //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].ID > 0x600 && messageBuffer[i].ID < 0x630)
{ {
if (messageBuffer[i].len <= messageBuffer[i].data.count()) if (messageBuffer[i].len <= messageBuffer[i].data.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].ID, 16) << " " << messageBuffer[i].len << " " << messageBuffer[i].data.count();
} }
else 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].ID, 16) << " " << messageBuffer[i].len << " " << messageBuffer[i].data.count();
} }
} }
emit newISOMessage(messageBuffer[i]); emit newISOMessage(messageBuffer[i]);
messageBuffer.removeAt(i); messageBuffer.removeAt(i);
+1 -4
View File
@@ -1,5 +1,4 @@
#ifndef ISOTP_HANDLER_H #pragma once
#define ISOTP_HANDLER_H
#include <Qt> #include <Qt>
#include <QObject> #include <QObject>
@@ -53,5 +52,3 @@ private:
void processFrame(const CANFrame &frame); void processFrame(const CANFrame &frame);
void checkNeedFlush(uint64_t ID); void checkNeedFlush(uint64_t ID);
}; };
#endif // ISOTP_HANDLER_H
+3
View File
@@ -1,6 +1,9 @@
#ifndef ISOTP_MESSAGE_H #ifndef ISOTP_MESSAGE_H
#define ISOTP_MESSAGE_H #define ISOTP_MESSAGE_H
#include <Qt>
#include <QVector>
//the same as the CANFrame struct but with arbitrary data size. //the same as the CANFrame struct but with arbitrary data size.
class ISOTP_MESSAGE class ISOTP_MESSAGE
{ {
+10 -13
View File
@@ -4,35 +4,32 @@
#include <QObject> #include <QObject>
#include <QVector> #include <QVector>
#include <stdint.h> #include <stdint.h>
#include <QCanBusFrame>
struct CANFrame //Now inherits from the built-in CAN frame class from Qt. This should be more future proof and easier to integrate with other code
struct CANFrame : public QCanBusFrame
{ {
public: public:
uint32_t ID;
int bus; int bus;
bool extended;
bool remote;
bool isReceived; //did we receive this or send it? bool isReceived; //did we receive this or send it?
int len;
unsigned char data[8];
uint64_t timestamp;
uint64_t timedelta; uint64_t timedelta;
uint32_t frameCount; //used in overwrite mode uint32_t frameCount; //used in overwrite mode
friend bool operator<(const CANFrame& l, const CANFrame& r) friend bool operator<(const CANFrame& l, const CANFrame& r)
{ {
return l.timestamp < r.timestamp; qint64 lStamp = l.timeStamp().seconds() * 1000000 + l.timeStamp().microSeconds();
qint64 rStamp = r.timeStamp().seconds() * 1000000 + r.timeStamp().microSeconds();
return lStamp < rStamp;
} }
CANFrame() CANFrame()
{ {
ID = 0; setFrameId(0);
bus = 0; bus = 0;
extended = false; setExtendedFrameFormat(false);
remote = false; setFrameType(QCanBusFrame::DataFrame);
isReceived = true; isReceived = true;
len = 0;
timestamp = 0;
timedelta = 0; timedelta = 0;
frameCount = 1; frameCount = 1;
} }
+2 -2
View File
@@ -220,11 +220,11 @@ bool CANConManager::sendFrame(const CANFrame& pFrame)
workingFrame.isReceived = false; workingFrame.isReceived = false;
if (useSystemTime) if (useSystemTime)
{ {
workingFrame.timestamp = (QDateTime::currentMSecsSinceEpoch() * 1000); workingFrame.setTimeStamp(QCanBusFrame::TimeStamp(0,QDateTime::currentMSecsSinceEpoch() * 1000));
} }
else else
{ {
workingFrame.timestamp = mElapsedTimer.nsecsElapsed() / 1000; workingFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, mElapsedTimer.nsecsElapsed() / 1000));
//workingFrame.timestamp -= mTimestampBasis; //workingFrame.timestamp -= mTimestampBasis;
} }
txFrame = conn->getQueue().get(); txFrame = conn->getQueue().get();
+41 -40
View File
@@ -246,11 +246,11 @@ bool GVRetSerial::piSendFrame(const CANFrame& frame)
// Doesn't make sense to send an error frame // Doesn't make sense to send an error frame
// to an adapter // to an adapter
if (frame.ID & 0x20000000) { if (frame.frameId() & 0x20000000) {
return true; return true;
} }
ID = frame.ID; ID = frame.frameId();
if (frame.extended) ID |= 1 << 31; if (frame.hasExtendedFrameFormat()) ID |= 1 << 31;
buffer[0] = (unsigned char)0xF1; //start of a command over serial buffer[0] = (unsigned char)0xF1; //start of a command over serial
buffer[1] = 0; //command ID for sending a CANBUS frame buffer[1] = 0; //command ID for sending a CANBUS frame
@@ -259,12 +259,12 @@ bool GVRetSerial::piSendFrame(const CANFrame& frame)
buffer[4] = (unsigned char)(ID >> 16); buffer[4] = (unsigned char)(ID >> 16);
buffer[5] = (unsigned char)(ID >> 24); buffer[5] = (unsigned char)(ID >> 24);
buffer[6] = (unsigned char)((frame.bus) & 3); buffer[6] = (unsigned char)((frame.bus) & 3);
buffer[7] = (unsigned char)frame.len; buffer[7] = (unsigned char)frame.payload().length();
for (c = 0; c < frame.len; c++) for (c = 0; c < frame.payload().length(); c++)
{ {
buffer[8 + c] = frame.data[c]; buffer[8 + c] = frame.payload()[c];
} }
buffer[8 + frame.len] = 0; buffer[8 + frame.payload().length()] = 0;
sendToSerial(buffer); sendToSerial(buffer);
@@ -375,18 +375,18 @@ void GVRetSerial::deviceConnected()
{ {
sendDebug("Connecting to GVRET Device!"); sendDebug("Connecting to GVRET Device!");
QByteArray output; QByteArray output;
output.append((unsigned char)0xE7); //this puts the device into binary comm mode output.append((char)0xE7); //this puts the device into binary comm mode
output.append((unsigned char)0xE7); output.append((char)0xE7);
output.append((unsigned char)0xF1); output.append((char)0xF1);
output.append((unsigned char)0x0C); //get number of actually implemented buses. Not implemented except on M2RET output.append((char)0x0C); //get number of actually implemented buses. Not implemented except on M2RET
mNumBuses = 2; //the proper number if C/12 is not implemented mNumBuses = 2; //the proper number if C/12 is not implemented
output.append((unsigned char)0xF1); //signal we want to issue a command output.append((char)0xF1); //signal we want to issue a command
output.append((unsigned char)0x06); //request canbus stats from the board output.append((char)0x06); //request canbus stats from the board
output.append((unsigned char)0xF1); //another command to the GVRET output.append((char)0xF1); //another command to the GVRET
output.append((unsigned char)0x07); //request device information output.append((char)0x07); //request device information
/*output.append((char)0xF1); /*output.append((char)0xF1);
output.append((char)0x08); //setting singlewire mode output.append((char)0x08); //setting singlewire mode
@@ -399,11 +399,11 @@ void GVRetSerial::deviceConnected()
output.append((char)0xFF); //signal we don't want single wire mode output.append((char)0xFF); //signal we don't want single wire mode
}*/ }*/
output.append((unsigned char)0xF1); //and another command output.append((char)0xF1); //and another command
output.append((unsigned char)0x01); //Time Sync - Not implemented until 333 but we can try output.append((char)0x01); //Time Sync - Not implemented until 333 but we can try
output.append((unsigned char)0xF1); //yet another command output.append((char)0xF1); //yet another command
output.append((unsigned char)0x09); //comm validation command output.append((char)0x09); //comm validation command
continuousTimeSync = true; continuousTimeSync = true;
@@ -659,57 +659,59 @@ void GVRetSerial::procRXChar(unsigned char c)
switch (rx_step) switch (rx_step)
{ {
case 0: case 0:
buildFrame.timestamp = c; buildTimestamp = c;
break; break;
case 1: case 1:
buildFrame.timestamp |= (uint)(c << 8); buildTimestamp |= (uint)(c << 8);
break; break;
case 2: case 2:
buildFrame.timestamp |= (uint)c << 16; buildTimestamp |= (uint)c << 16;
break; break;
case 3: case 3:
buildFrame.timestamp |= (uint)c << 24; buildTimestamp |= (uint)c << 24;
buildFrame.timestamp += timeBasis; buildTimestamp += timeBasis;
if (useSystemTime) if (useSystemTime)
{ {
buildFrame.timestamp = QDateTime::currentMSecsSinceEpoch() * 1000l; buildTimestamp = QDateTime::currentMSecsSinceEpoch() * 1000l;
} }
buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, buildTimestamp));
break; break;
case 4: case 4:
buildFrame.ID = c; buildId = c;
break; break;
case 5: case 5:
buildFrame.ID |= c << 8; buildId |= c << 8;
break; break;
case 6: case 6:
buildFrame.ID |= c << 16; buildId |= c << 16;
break; break;
case 7: case 7:
buildFrame.ID |= c << 24; buildId |= c << 24;
if ((buildFrame.ID & 1 << 31) == 1u << 31) if ((buildId & 1 << 31) == 1u << 31)
{ {
buildFrame.ID &= 0x7FFFFFFF; buildId &= 0x7FFFFFFF;
buildFrame.extended = true; buildFrame.setExtendedFrameFormat(true);
} }
else buildFrame.extended = false; else buildFrame.setExtendedFrameFormat(false);
buildFrame.setFrameId(buildId);
break; break;
case 8: case 8:
buildFrame.len = c & 0xF; buildData.resize(c & 0xF);
if (buildFrame.len > 8) buildFrame.len = 8;
buildFrame.bus = (c & 0xF0) >> 4; buildFrame.bus = (c & 0xF0) >> 4;
break; break;
default: default:
if (rx_step < buildFrame.len + 9) if (rx_step < buildData.length() + 9)
{ {
buildFrame.data[rx_step - 9] = c; buildData[rx_step - 9] = c;
} }
else else
{ {
rx_state = IDLE; rx_state = IDLE;
rx_step = 0; rx_step = 0;
buildFrame.isReceived = true; buildFrame.isReceived = true;
buildFrame.setPayload(buildData);
buildFrame.setFrameType(QCanBusFrame::FrameType::DataFrame);
if (!isCapSuspended()) if (!isCapSuspended())
{ {
/* get frame from queue */ /* get frame from queue */
@@ -717,8 +719,7 @@ void GVRetSerial::procRXChar(unsigned char c)
if(frame_p) { if(frame_p) {
//qDebug() << "GVRET got frame on bus " << frame_p->bus; //qDebug() << "GVRET got frame on bus " << frame_p->bus;
/* copy frame */ /* copy frame */
*frame_p = buildFrame; *frame_p = buildFrame;
frame_p->remote = false;
checkTargettedFrame(buildFrame); checkTargettedFrame(buildFrame);
/* enqueue frame */ /* enqueue frame */
getQueue().queue(); getQueue().queue();
+3
View File
@@ -93,6 +93,9 @@ protected:
STATE rx_state; STATE rx_state;
uint32_t rx_step; uint32_t rx_step;
CANFrame buildFrame; CANFrame buildFrame;
qint64 buildTimestamp;
quint32 buildId;
QByteArray buildData;
int can0Baud, can1Baud, swcanBaud, lin1Baud, lin2Baud; int can0Baud, can1Baud, swcanBaud, lin1Baud, lin2Baud;
bool can0Enabled, can1Enabled, swcanEnabled, lin1Enabled, lin2Enabled; bool can0Enabled, can1Enabled, swcanEnabled, lin1Enabled, lin2Enabled;
bool can0ListenOnly, can1ListenOnly, swcanListenOnly; bool can0ListenOnly, can1ListenOnly, swcanListenOnly;
+15 -22
View File
@@ -115,22 +115,11 @@ void SerialBusConnection::piSetBusSettings(int pBusIdx, CANBus bus)
bool SerialBusConnection::piSendFrame(const CANFrame& pFrame) bool SerialBusConnection::piSendFrame(const CANFrame& pFrame)
{ {
/* sanity checks */ /* sanity checks */
if(0 != pFrame.bus || pFrame.len>8) if(0 != pFrame.bus /*|| pFrame.len>8*/)
return false; return false;
if (!mDev_p) return false; if (!mDev_p) return false;
/* fill frame */ return mDev_p->writeFrame(pFrame);
QCanBusFrame frame;
frame.setExtendedFrameFormat(pFrame.extended);
frame.setFrameId(pFrame.ID);
if (pFrame.remote) {
frame.setFrameType(QCanBusFrame::FrameType::RemoteRequestFrame);
} else {
frame.setFrameType(QCanBusFrame::FrameType::DataFrame);
}
frame.setPayload(QByteArray(reinterpret_cast<const char *>(pFrame.data),
static_cast<int>(pFrame.len)));
return mDev_p->writeFrame(frame);
} }
@@ -193,14 +182,16 @@ void SerialBusConnection::framesReceived()
if (recFrame.payload().length() <= 8) { if (recFrame.payload().length() <= 8) {
CANFrame* frame_p = getQueue().get(); CANFrame* frame_p = getQueue().get();
if(frame_p) { if(frame_p) {
frame_p->len = static_cast<uint32_t>(recFrame.payload().length()); frame_p->setPayload(recFrame.payload());
frame_p->bus = 0; frame_p->bus = 0;
if (recFrame.frameType() == QCanBusFrame::ErrorFrame) { if (recFrame.frameType() == QCanBusFrame::ErrorFrame) {
// Constants defined in include/uapi/linux/can/error.h // Constants defined in include/uapi/linux/can/error.h
//since the whole program uses QCanBusFrame now we can just grab errors directly out of the proper place from now on
/*
switch (recFrame.error()) { switch (recFrame.error()) {
case QCanBusFrame::TransmissionTimeoutError: case QCanBusFrame::TransmissionTimeoutError:
frame_p->ID = 0x20000001; frame_p->setFrameId(0x20000001);
break; break;
case QCanBusFrame::LostArbitrationError: case QCanBusFrame::LostArbitrationError:
frame_p->ID = 0x20000002; frame_p->ID = 0x20000002;
@@ -230,19 +221,21 @@ void SerialBusConnection::framesReceived()
break; break;
} }
frame_p->extended = true; frame_p->extended = true;
*/
} else { } else {
frame_p->extended = recFrame.hasExtendedFrameFormat(); frame_p->setExtendedFrameFormat(recFrame.hasExtendedFrameFormat());
frame_p->ID = recFrame.frameId(); frame_p->setFrameId(recFrame.frameId());
frame_p->remote = (recFrame.frameType() == recFrame.RemoteRequestFrame); frame_p->setTimeStamp(recFrame.timeStamp());
memcpy(frame_p->data, recFrame.payload().data(), frame_p->len); frame_p->setFrameType(recFrame.frameType());
frame_p->setError(recFrame.error());
frame_p->isReceived = true; frame_p->isReceived = true;
} }
frame_p->isReceived = true; frame_p->isReceived = true;
if (useSystemTime) { if (useSystemTime) {
frame_p->timestamp = QDateTime::currentMSecsSinceEpoch() * 1000ul; frame_p->setTimeStamp(QCanBusFrame::TimeStamp(0, QDateTime::currentMSecsSinceEpoch() * 1000ul));
} }
else frame_p->timestamp = (recFrame.timeStamp().seconds() * 1000000ul + recFrame.timeStamp().microSeconds()) - timeBasis; else frame_p->setTimeStamp(QCanBusFrame::TimeStamp(0, (recFrame.timeStamp().seconds() * 1000000ul + recFrame.timeStamp().microSeconds()) - timeBasis));
checkTargettedFrame(*frame_p); checkTargettedFrame(*frame_p);
+13 -13
View File
@@ -47,7 +47,7 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o
QString buildString; QString buildString;
int startByte = startBit / 8; int startByte = startBit / 8;
int bytes = signalSize / 8; int bytes = signalSize / 8;
for (int x = 0; x < bytes; x++) buildString.append(frame.data[startByte + x]); for (int x = 0; x < bytes; x++) buildString.append((char)frame.payload()[startByte + x]);
outString = buildString; outString = buildString;
cachedValue = outString; cachedValue = outString;
return true; return true;
@@ -68,7 +68,7 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o
if (valType == SIGNED_INT) isSigned = true; if (valType == SIGNED_INT) isSigned = true;
if (valType == SIGNED_INT || valType == UNSIGNED_INT) if (valType == SIGNED_INT || valType == UNSIGNED_INT)
{ {
result = Utility::processIntegerSignal(frame.data, startBit, signalSize, intelByteOrder, isSigned); result = Utility::processIntegerSignal(frame.payload(), startBit, signalSize, intelByteOrder, isSigned);
endResult = ((double)result * factor) + bias; endResult = ((double)result * factor) + bias;
result = (int64_t)endResult; result = (int64_t)endResult;
} }
@@ -79,19 +79,19 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o
//that the bytes that make up the integer are instead treated as having made up //that the bytes that make up the integer are instead treated as having made up
//a 32 bit single precision float. That's evil incarnate but it is very fast and small //a 32 bit single precision float. That's evil incarnate but it is very fast and small
//in terms of new code. //in terms of new code.
result = Utility::processIntegerSignal(frame.data, startBit, 32, intelByteOrder, false); result = Utility::processIntegerSignal(frame.payload(), startBit, 32, intelByteOrder, false);
endResult = (*((float *)(&result)) * factor) + bias; endResult = (*((float *)(&result)) * factor) + bias;
} }
else //double precision float else //double precision float
{ {
if ( frame.len < 8 ) if ( frame.payload().length() < 8 )
{ {
result = 0; result = 0;
return false; return false;
} }
//like the above, this is rotten and evil and wrong in so many ways. Force //like the above, this is rotten and evil and wrong in so many ways. Force
//calculation of a 64 bit integer and then cast it into a double. //calculation of a 64 bit integer and then cast it into a double.
result = Utility::processIntegerSignal(frame.data, 0, 64, intelByteOrder, false); result = Utility::processIntegerSignal(frame.payload(), 0, 64, intelByteOrder, false);
endResult = (*((double *)(&result)) * factor) + bias; endResult = (*((double *)(&result)) * factor) + bias;
} }
@@ -155,13 +155,13 @@ bool DBC_SIGNAL::processAsInt(const CANFrame &frame, int32_t &outValue)
} }
if (valType == SIGNED_INT) isSigned = true; if (valType == SIGNED_INT) isSigned = true;
if ( static_cast<int>(frame.len * 8) < (startBit + signalSize) ) if ( static_cast<int>(frame.payload().length() * 8) < (startBit + signalSize) )
{ {
result = 0; result = 0;
return false; return false;
} }
result = static_cast<int32_t>(Utility::processIntegerSignal(frame.data, startBit, signalSize, intelByteOrder, isSigned)); result = static_cast<int32_t>(Utility::processIntegerSignal(frame.payload(), startBit, signalSize, intelByteOrder, isSigned));
double endResult = (result * factor) + bias; double endResult = (result * factor) + bias;
result = static_cast<int32_t>(endResult); result = static_cast<int32_t>(endResult);
@@ -200,19 +200,19 @@ bool DBC_SIGNAL::processAsDouble(const CANFrame &frame, double &outValue)
if (valType == SIGNED_INT) isSigned = true; if (valType == SIGNED_INT) isSigned = true;
if (valType == SIGNED_INT || valType == UNSIGNED_INT) if (valType == SIGNED_INT || valType == UNSIGNED_INT)
{ {
if ( frame.len*8 < (startBit+signalSize) ) if ( frame.payload().length() * 8 < (startBit+signalSize) )
{ {
result = 0; result = 0;
return false; return false;
} }
result = Utility::processIntegerSignal(frame.data, startBit, signalSize, intelByteOrder, isSigned); result = Utility::processIntegerSignal(frame.payload(), startBit, signalSize, intelByteOrder, isSigned);
endResult = ((double)result * factor) + bias; endResult = ((double)result * factor) + bias;
result = (int64_t)endResult; result = (int64_t)endResult;
} }
/*TODO: It should be noted that the below floating point has not even been tested. For shame! Test it!*/ /*TODO: It should be noted that the below floating point has not even been tested. For shame! Test it!*/
else if (valType == SP_FLOAT) else if (valType == SP_FLOAT)
{ {
if ( frame.len*8 < (startBit+32) ) if ( frame.payload().length() * 8 < (startBit + 32) )
{ {
result = 0; result = 0;
return false; return false;
@@ -222,19 +222,19 @@ bool DBC_SIGNAL::processAsDouble(const CANFrame &frame, double &outValue)
//that the bytes that make up the integer are instead treated as having made up //that the bytes that make up the integer are instead treated as having made up
//a 32 bit single precision float. That's evil incarnate but it is very fast and small //a 32 bit single precision float. That's evil incarnate but it is very fast and small
//in terms of new code. //in terms of new code.
result = Utility::processIntegerSignal(frame.data, startBit, 32, false, false); result = Utility::processIntegerSignal(frame.payload(), startBit, 32, false, false);
endResult = (*((float *)(&result)) * factor) + bias; endResult = (*((float *)(&result)) * factor) + bias;
} }
else //double precision float else //double precision float
{ {
if ( frame.len < 8 ) if ( frame.payload().length() < 8 )
{ {
result = 0; result = 0;
return false; return false;
} }
//like the above, this is rotten and evil and wrong in so many ways. Force //like the above, this is rotten and evil and wrong in so many ways. Force
//calculation of a 64 bit integer and then cast it into a double. //calculation of a 64 bit integer and then cast it into a double.
result = Utility::processIntegerSignal(frame.data, 0, 64, false, false); result = Utility::processIntegerSignal(frame.payload(), 0, 64, false, false);
endResult = (*((double *)(&result)) * factor) + bias; endResult = (*((double *)(&result)) * factor) + bias;
} }
cachedValue = endResult; cachedValue = endResult;
+2 -2
View File
@@ -294,9 +294,9 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
for (int i = 0; i < referenceFrames->length(); i++) for (int i = 0; i < referenceFrames->length(); i++)
{ {
if ((uint) referenceFrames->at(i).ID == msgID) if ((uint) referenceFrames->at(i).frameId() == msgID)
{ {
newMsg.len = referenceFrames->at(i).len; newMsg.len = referenceFrames->at(i).payload().length();
break; break;
} }
} }
+6 -6
View File
@@ -140,10 +140,10 @@ void DiscreteStateWindow::updatedFrames(int numFrames)
{ {
thisFrame = modelFrames->at(i); thisFrame = modelFrames->at(i);
if (!idFilters.contains(thisFrame.ID)) if (!idFilters.contains(thisFrame.frameId()))
{ {
idFilters.insert(thisFrame.ID, true); idFilters.insert(thisFrame.frameId(), true);
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(thisFrame.ID, thisFrame.extended), ui->listID); QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(thisFrame.frameId(), thisFrame.hasExtendedFrameFormat()), ui->listID);
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
listItem->setCheckState(Qt::Checked); //default all filters to be set active listItem->setCheckState(Qt::Checked); //default all filters to be set active
} }
@@ -164,11 +164,11 @@ void DiscreteStateWindow::refreshFilterList()
for (int i = 0; i < modelFrames->length(); i++) for (int i = 0; i < modelFrames->length(); i++)
{ {
CANFrame thisFrame = modelFrames->at(i); CANFrame thisFrame = modelFrames->at(i);
id = thisFrame.ID; id = thisFrame.frameId();
if (!idFilters.contains(id)) if (!idFilters.contains(id))
{ {
idFilters.insert(id, true); idFilters.insert(id, true);
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(id, thisFrame.extended), ui->listID); QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(id, thisFrame.hasExtendedFrameFormat()), ui->listID);
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
listItem->setCheckState(Qt::Checked); //default all filters to be set active listItem->setCheckState(Qt::Checked); //default all filters to be set active
} }
@@ -359,7 +359,7 @@ void DiscreteStateWindow::calculateResults()
frameCache.clear(); frameCache.clear();
for (int i = 0; i < modelFrames->count(); i++) for (int i = 0; i < modelFrames->count(); i++)
{ {
if (modelFrames->at(i).ID == (unsigned int)it.key()) frameCache.append(modelFrames->at(i)); if (modelFrames->at(i).frameId() == (unsigned int)it.key()) frameCache.append(modelFrames->at(i));
} }
for (int bits = maxBits; bits >= minBits; bits--) for (int bits = maxBits; bits >= minBits; bits--)
{ {
+24 -24
View File
@@ -152,22 +152,22 @@ void FileComparatorWindow::calculateDetails()
for (int x = 0; x < interestedFrames.count(); x++) for (int x = 0; x < interestedFrames.count(); x++)
{ {
CANFrame frame = interestedFrames.at(x); CANFrame frame = interestedFrames.at(x);
if (interestedIDs.contains(frame.ID)) //if we saw this ID before then add to the QList in there if (interestedIDs.contains(frame.frameId())) //if we saw this ID before then add to the QList in there
{ {
for (unsigned int y = 0; y < frame.len; y++) for (unsigned int y = 0; y < frame.payload().length(); y++)
{ {
interestedIDs[frame.ID].values[y][frame.data[y]]++; interestedIDs[frame.frameId()].values[y][frame.payload()[y]]++;
tmp = frame.data[y]; tmp = frame.payload()[y];
tmp = tmp << (8 * y); tmp = tmp << (8 * y);
interestedIDs[frame.ID].bitmap |= tmp; interestedIDs[frame.frameId()].bitmap |= tmp;
//qDebug() << "bitmap: " << QString::number(interestedIDs[frame.ID].bitmap, 16); //qDebug() << "bitmap: " << QString::number(interestedIDs[frame.frameId()].bitmap, 16);
} }
} }
else //never seen this ID before so add one else //never seen this ID before so add one
{ {
FrameData *newData = new FrameData(); FrameData *newData = new FrameData();
newData->ID = frame.ID; newData->ID = frame.frameId();
newData->dataLen = frame.len; newData->dataLen = frame.payload().length();
//it would be possible to implement a constructor for FrameData //it would be possible to implement a constructor for FrameData
//that sets the bitmap and values to zero. That would be cleaner and better. //that sets the bitmap and values to zero. That would be cleaner and better.
newData->bitmap = 0; newData->bitmap = 0;
@@ -179,15 +179,15 @@ void FileComparatorWindow::calculateDetails()
} }
} }
//memset(newData->values, 0, 256 * 8); //memset(newData->values, 0, 256 * 8);
for (unsigned int y = 0; y < frame.len; y++) for (unsigned int y = 0; y < frame.payload().length(); y++)
{ {
newData->values[y][frame.data[y]] = 1; newData->values[y][frame.payload()[y]] = 1;
tmp = frame.data[y]; tmp = frame.payload()[y];
tmp = tmp << (8 * y); tmp = tmp << (8 * y);
newData->bitmap |= tmp; newData->bitmap |= tmp;
//qDebug() << "bitmap: " << QString::number(newData->bitmap, 16); //qDebug() << "bitmap: " << QString::number(newData->bitmap, 16);
} }
interestedIDs.insert(frame.ID, *newData); interestedIDs.insert(frame.frameId(), *newData);
} }
} }
@@ -196,22 +196,22 @@ void FileComparatorWindow::calculateDetails()
for (int x = 0; x < referenceFrames.count(); x++) for (int x = 0; x < referenceFrames.count(); x++)
{ {
CANFrame frame = referenceFrames.at(x); CANFrame frame = referenceFrames.at(x);
if (referenceIDs.contains(frame.ID)) //if we saw this ID before then add to the QList in there if (referenceIDs.contains(frame.frameId())) //if we saw this ID before then add to the QList in there
{ {
for (unsigned int y = 0; y < frame.len; y++) for (unsigned int y = 0; y < frame.payload().length(); y++)
{ {
referenceIDs[frame.ID].values[y][frame.data[y]]++; referenceIDs[frame.frameId()].values[y][frame.payload()[y]]++;
tmp = frame.data[y]; tmp = frame.payload()[y];
tmp = tmp << (8 * y); tmp = tmp << (8 * y);
referenceIDs[frame.ID].bitmap |= tmp; referenceIDs[frame.frameId()].bitmap |= tmp;
//qDebug() << "bitmap: " << QString::number(referenceIDs[frame.ID].bitmap, 16); //qDebug() << "bitmap: " << QString::number(referenceIDs[frame.frameId()].bitmap, 16);
} }
} }
else //never seen this ID before so add one else //never seen this ID before so add one
{ {
FrameData *newData = new FrameData(); FrameData *newData = new FrameData();
newData->ID = frame.ID; newData->ID = frame.frameId();
newData->dataLen = frame.len; newData->dataLen = frame.payload().length();
newData->bitmap = 0; newData->bitmap = 0;
for (int x = 0; x < 8; x++) for (int x = 0; x < 8; x++)
{ {
@@ -221,15 +221,15 @@ void FileComparatorWindow::calculateDetails()
} }
} }
//memset(newData->values, 0, 256 * 8); //memset(newData->values, 0, 256 * 8);
for (unsigned int y = 0; y < frame.len; y++) for (unsigned int y = 0; y < frame.payload().length(); y++)
{ {
newData->values[y][frame.data[y]] = 1; newData->values[y][frame.payload()[y]] = 1;
tmp = frame.data[y]; tmp = frame.payload()[y];
tmp = tmp << (8 * y); tmp = tmp << (8 * y);
newData->bitmap |= tmp; newData->bitmap |= tmp;
//qDebug() << "bitmap: " << QString::number(newData->bitmap, 16); //qDebug() << "bitmap: " << QString::number(newData->bitmap, 16);
} }
referenceIDs.insert(frame.ID, *newData); referenceIDs.insert(frame.frameId(), *newData);
} }
} }
+28 -27
View File
@@ -250,7 +250,7 @@ void FlowViewWindow::plottableDoubleClick(QCPAbstractPlottable* plottable, QMous
int id = 0; int id = 0;
//apply transforms to get the X axis value where we double clicked //apply transforms to get the X axis value where we double clicked
double coord = plottable->keyAxis()->pixelToCoord(event->localPos().x()); double coord = plottable->keyAxis()->pixelToCoord(event->localPos().x());
if (frameCache.count() > 0) id = frameCache[0].ID; if (frameCache.count() > 0) id = frameCache[0].frameId();
if (secondsMode) emit sendCenterTimeID(id, coord); if (secondsMode) emit sendCenterTimeID(id, coord);
else emit sendCenterTimeID(id, coord / 1000000.0); else emit sendCenterTimeID(id, coord / 1000000.0);
} }
@@ -278,7 +278,7 @@ void FlowViewWindow::gotCenterTimeID(int32_t ID, double timestamp)
int bestIdx = -1; int bestIdx = -1;
for (int i = 0; i < frameCache.count(); i++) for (int i = 0; i < frameCache.count(); i++)
{ {
if (frameCache[i].timestamp > t_stamp) if (frameCache[i].timeStamp().microSeconds() > t_stamp)
{ {
bestIdx = i - 1; bestIdx = i - 1;
break; break;
@@ -428,20 +428,20 @@ void FlowViewWindow::updatedFrames(int numFrames)
{ {
if (numFrames > modelFrames->count()) return; if (numFrames > modelFrames->count()) return;
unsigned int refID; unsigned int refID;
if (frameCache.count() > 0) refID = frameCache[0].ID; if (frameCache.count() > 0) refID = frameCache[0].frameId();
else refID = 0; else refID = 0;
bool needRefresh = false; bool needRefresh = false;
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++) for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
{ {
thisFrame = modelFrames->at(i); thisFrame = modelFrames->at(i);
if (!foundID.contains(thisFrame.ID)) if (!foundID.contains(thisFrame.frameId()))
{ {
foundID.append(thisFrame.ID); foundID.append(thisFrame.frameId());
FilterUtility::createFilterItem(thisFrame.ID, ui->listFrameID); FilterUtility::createFilterItem(thisFrame.frameId(), ui->listFrameID);
} }
if (thisFrame.ID == refID) if (thisFrame.frameId() == refID)
{ {
frameCache.append(thisFrame); frameCache.append(thisFrame);
@@ -450,18 +450,18 @@ void FlowViewWindow::updatedFrames(int numFrames)
if (ui->cbTimeGraph->isChecked()) if (ui->cbTimeGraph->isChecked())
{ {
if (secondsMode){ if (secondsMode){
newX[k].append((double)(thisFrame.timestamp) / 1000000.0); newX[k].append((double)(thisFrame.timeStamp().microSeconds()) / 1000000.0);
} }
else else
{ {
newX[k].append(thisFrame.timestamp); newX[k].append(thisFrame.timeStamp().microSeconds());
} }
} }
else else
{ {
newX[k].append(x[k].count()); newX[k].append(x[k].count());
} }
newY[k].append(thisFrame.data[k]); newY[k].append(thisFrame.payload()[k]);
needRefresh = true; needRefresh = true;
} }
} }
@@ -469,7 +469,7 @@ void FlowViewWindow::updatedFrames(int numFrames)
if (ui->cbLiveMode->checkState() == Qt::Checked) if (ui->cbLiveMode->checkState() == Qt::Checked)
{ {
currentPosition = frameCache.count() - 1; currentPosition = frameCache.count() - 1;
memcpy(currBytes, frameCache.at(currentPosition).data, 8); memcpy(currBytes, frameCache.at(currentPosition).payload(), 8);
memcpy(refBytes, currBytes, 8); memcpy(refBytes, currBytes, 8);
} }
@@ -482,7 +482,7 @@ void FlowViewWindow::updatedFrames(int numFrames)
} }
ui->graphView->replot(); ui->graphView->replot();
updateDataView(); updateDataView();
if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].ID, frameCache[currentPosition].timestamp / 1000000.0); if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].frameId(), frameCache[currentPosition].timeStamp().microSeconds() / 1000000.0);
} }
} }
updateFrameLabel(); updateFrameLabel();
@@ -512,16 +512,16 @@ void FlowViewWindow::createGraph(int byteNum)
for (int j = 0; j < numEntries; j++) for (int j = 0; j < numEntries; j++)
{ {
tempVal = frameCache[j].data[byteNum]; tempVal = frameCache[j].payload()[byteNum];
if (graphByTime) if (graphByTime)
{ {
if (secondsMode){ if (secondsMode){
x[byteNum][j] = (double)(frameCache[j].timestamp) / 1000000.0; x[byteNum][j] = (double)(frameCache[j].timeStamp().microSeconds()) / 1000000.0;
} }
else else
{ {
x[byteNum][j] = frameCache[j].timestamp; x[byteNum][j] = frameCache[j].timeStamp().microSeconds();
} }
} }
else else
@@ -551,7 +551,7 @@ void FlowViewWindow::refreshIDList()
for (int i = 0; i < modelFrames->count(); i++) for (int i = 0; i < modelFrames->count(); i++)
{ {
CANFrame thisFrame = modelFrames->at(i); CANFrame thisFrame = modelFrames->at(i);
id = thisFrame.ID; id = thisFrame.frameId();
if (!foundID.contains(id)) if (!foundID.contains(id))
{ {
foundID.append(id); foundID.append(id);
@@ -581,9 +581,9 @@ void FlowViewWindow::changeID(QString newID)
for (int x = 0; x < modelFrames->count(); x++) for (int x = 0; x < modelFrames->count(); x++)
{ {
CANFrame thisFrame = modelFrames->at(x); CANFrame thisFrame = modelFrames->at(x);
if (thisFrame.ID == id) if (thisFrame.frameId() == id)
{ {
for (int j = thisFrame.len; j < 8; j++) thisFrame.data[j] = 0; thisFrame.payload().clear();
frameCache.append(thisFrame); frameCache.append(thisFrame);
} }
} }
@@ -600,7 +600,7 @@ void FlowViewWindow::changeID(QString newID)
updateGraphLocation(); updateGraphLocation();
memcpy(currBytes, frameCache.at(currentPosition).data, 8); memcpy(currBytes, frameCache.at(currentPosition).payload(), 8);
memcpy(refBytes, currBytes, 8); memcpy(refBytes, currBytes, 8);
updateDataView(); updateDataView();
@@ -635,7 +635,8 @@ void FlowViewWindow::btnStopClick()
playbackActive = false; playbackActive = false;
currentPosition = 0; currentPosition = 0;
memcpy(currBytes, frameCache.at(currentPosition).data, 8);
memcpy(currBytes, frameCache.at(currentPosition).payload().data_ptr(), 8);
memcpy(refBytes, currBytes, 8); memcpy(refBytes, currBytes, 8);
updateFrameLabel(); updateFrameLabel();
@@ -757,7 +758,7 @@ void FlowViewWindow::updatePosition(bool forward)
uint8_t cngByte; uint8_t cngByte;
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
cngByte = currBytes[i] ^ frameCache.at(currentPosition).data[i]; cngByte = currBytes[i] ^ frameCache.at(currentPosition).payload()[i];
changedBits |= (uint64_t)cngByte << (8ull * i); changedBits |= (uint64_t)cngByte << (8ull * i);
} }
@@ -771,9 +772,9 @@ void FlowViewWindow::updatePosition(bool forward)
playbackTimer->stop(); playbackTimer->stop();
} }
memcpy(currBytes, frameCache.at(currentPosition).data, 8); memcpy(currBytes, frameCache.at(currentPosition).payload().data(), 8);
if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].ID, frameCache[currentPosition].timestamp / 1000000.0); if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].frameId(), frameCache[currentPosition].timeStamp().microSeconds() / 1000000.0);
} }
void FlowViewWindow::updateGraphLocation() void FlowViewWindow::updateGraphLocation()
@@ -787,9 +788,9 @@ void FlowViewWindow::updateGraphLocation()
{ {
if (secondsMode) if (secondsMode)
{ {
ui->graphView->xAxis->setRange(frameCache[start].timestamp / 1000000.0, frameCache[end].timestamp / 1000000.0); ui->graphView->xAxis->setRange(frameCache[start].timeStamp().microSeconds() / 1000000.0, frameCache[end].timeStamp().microSeconds() / 1000000.0);
/* /*
ui->graphView->xAxis->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3000000.0); ui->graphView->xAxis->setTickStep((frameCache[end].timeStamp().microSeconds() - frameCache[start].timeStamp().microSeconds())/ 3000000.0);
ui->graphView->xAxis->setSubTickCount(0); ui->graphView->xAxis->setSubTickCount(0);
ui->graphView->xAxis->setNumberFormat("f"); ui->graphView->xAxis->setNumberFormat("f");
ui->graphView->xAxis->setNumberPrecision(6); ui->graphView->xAxis->setNumberPrecision(6);
@@ -797,9 +798,9 @@ void FlowViewWindow::updateGraphLocation()
} }
else else
{ {
ui->graphView->xAxis->setRange(frameCache[start].timestamp, frameCache[end].timestamp); ui->graphView->xAxis->setRange(frameCache[start].timeStamp().microSeconds(), frameCache[end].timeStamp().microSeconds());
/* /*
ui->graphView->xAxis->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3.0); ui->graphView->xAxis->setTickStep((frameCache[end].timeStamp().microSeconds() - frameCache[start].timeStamp().microSeconds())/ 3.0);
ui->graphView->xAxis->setSubTickCount(0); ui->graphView->xAxis->setSubTickCount(0);
ui->graphView->xAxis->setNumberFormat("f"); ui->graphView->xAxis->setNumberFormat("f");
ui->graphView->xAxis->setNumberPrecision(0); */ ui->graphView->xAxis->setNumberPrecision(0); */
+13 -13
View File
@@ -211,14 +211,14 @@ void FrameInfoWindow::updatedFrames(int numFrames)
for (int x = modelFrames->count() - numFrames; x < modelFrames->count(); x++) for (int x = modelFrames->count() - numFrames; x < modelFrames->count(); x++)
{ {
CANFrame thisFrame = modelFrames->at(x); CANFrame thisFrame = modelFrames->at(x);
int32_t id = static_cast<int32_t>(thisFrame.ID); int32_t id = static_cast<int32_t>(thisFrame.frameId());
if (!foundID.contains(id)) if (!foundID.contains(id))
{ {
foundID.append(id); foundID.append(id);
FilterUtility::createFilterItem(id, ui->listFrameID); FilterUtility::createFilterItem(id, ui->listFrameID);
} }
if (currID == modelFrames->at(x).ID) if (currID == modelFrames->at(x).frameId())
{ {
thisID = true; thisID = true;
break; break;
@@ -275,7 +275,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
for (int i = 0; i < modelFrames->count(); i++) for (int i = 0; i < modelFrames->count(); i++)
{ {
CANFrame thisFrame = modelFrames->at(i); CANFrame thisFrame = modelFrames->at(i);
if (thisFrame.ID == static_cast<uint32_t>(targettedID)) frameCache.append(thisFrame); if (thisFrame.frameId() == static_cast<uint32_t>(targettedID)) frameCache.append(thisFrame);
} }
ui->treeDetails->clear(); ui->treeDetails->clear();
@@ -285,7 +285,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
baseNode = new QTreeWidgetItem(); baseNode = new QTreeWidgetItem();
baseNode->setText(0, QString("ID: ") + newID ); baseNode->setText(0, QString("ID: ") + newID );
if (frameCache[0].extended) //if these frames seem to be extended then try for J1939 decoding if (frameCache[0].hasExtendedFrameFormat()) //if these frames seem to be extended then try for J1939 decoding
{ {
// ------- J1939 decoding ---------- // ------- J1939 decoding ----------
J1939ID jid; J1939ID jid;
@@ -367,7 +367,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
for (int c = 0; c < 8; c++) for (int c = 0; c < 8; c++)
{ {
changedBits[c] = 0; changedBits[c] = 0;
referenceBits[c] = frameCache.at(0).data[c]; referenceBits[c] = frameCache.at(0).payload()[c];
//qDebug() << referenceBits[c]; //qDebug() << referenceBits[c];
} }
@@ -378,19 +378,19 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
for (int j = 0; j < frameCache.count(); j++) for (int j = 0; j < frameCache.count(); j++)
{ {
byteGraphX.append(j); byteGraphX.append(j);
for (uint32_t bytcnt = 0; bytcnt < frameCache[j].len; bytcnt++) for (uint32_t bytcnt = 0; bytcnt < frameCache[j].payload().length(); bytcnt++)
{ {
byteGraphY[bytcnt].append(frameCache[j].data[bytcnt]); byteGraphY[bytcnt].append(frameCache[j].payload()[bytcnt]);
} }
if (j != 0) if (j != 0)
{ {
//TODO - we try the interval whichever way doesn't go negative. But, we should probably sort the frame list before //TODO - we try the interval whichever way doesn't go negative. But, we should probably sort the frame list before
//starting so that the intervals are all correct. //starting so that the intervals are all correct.
if (frameCache[j].timestamp > frameCache[j-1].timestamp) if (frameCache[j].timeStamp().microSeconds() > frameCache[j-1].timeStamp().microSeconds())
thisInterval = (frameCache[j].timestamp - frameCache[j-1].timestamp); thisInterval = (frameCache[j].timeStamp().microSeconds() - frameCache[j-1].timeStamp().microSeconds());
else else
thisInterval = (frameCache[j-1].timestamp - frameCache[j].timestamp); thisInterval = (frameCache[j-1].timeStamp().microSeconds() - frameCache[j].timeStamp().microSeconds());
sortedIntervals.push_back(thisInterval); sortedIntervals.push_back(thisInterval);
intervalSum += thisInterval; intervalSum += thisInterval;
@@ -398,12 +398,12 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
if (thisInterval < minInterval) minInterval = thisInterval; if (thisInterval < minInterval) minInterval = thisInterval;
avgInterval += thisInterval; avgInterval += thisInterval;
} }
thisLen = frameCache.at(j).len; thisLen = frameCache.at(j).payload().length();
if (thisLen > maxLen) maxLen = thisLen; if (thisLen > maxLen) maxLen = thisLen;
if (thisLen < minLen) minLen = thisLen; if (thisLen < minLen) minLen = thisLen;
for (int c = 0; c < thisLen; c++) for (int c = 0; c < thisLen; c++)
{ {
unsigned char dat = frameCache.at(j).data[c]; unsigned char dat = frameCache.at(j).payload()[c];
if (minData[c] > dat) minData[c] = dat; if (minData[c] > dat) minData[c] = dat;
if (maxData[c] < dat) maxData[c] = dat; if (maxData[c] < dat) maxData[c] = dat;
dataHistogram[dat][c]++; //add one to count for this dataHistogram[dat][c]++; //add one to count for this
@@ -600,7 +600,7 @@ void FrameInfoWindow::refreshIDList()
for (int i = 0; i < modelFrames->count(); i++) for (int i = 0; i < modelFrames->count(); i++)
{ {
CANFrame thisFrame = modelFrames->at(i); CANFrame thisFrame = modelFrames->at(i);
id = (int)thisFrame.ID; id = (int)thisFrame.frameId();
if (!foundID.contains(id)) if (!foundID.contains(id))
{ {
foundID.append(id); foundID.append(id);
+9 -9
View File
@@ -94,7 +94,7 @@ void FuzzingWindow::updatedFrames(int numFrames)
if (numFrames > modelFrames->count()) return; if (numFrames > modelFrames->count()) return;
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++) for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
{ {
id = modelFrames->at(i).ID; id = modelFrames->at(i).frameId();
if (!foundIDs.contains(id)) if (!foundIDs.contains(id))
{ {
foundIDs.append(id); foundIDs.append(id);
@@ -133,17 +133,17 @@ void FuzzingWindow::changedNumDataBytes(int newVal)
void FuzzingWindow::timerTriggered() void FuzzingWindow::timerTriggered()
{ {
CANFrame thisFrame; CANFrame thisFrame;
thisFrame.remote = false;
sendingBuffer.clear(); sendingBuffer.clear();
int buses = ui->cbBuses->currentIndex(); int buses = ui->cbBuses->currentIndex();
for (int count = 0; count < ui->spinBurst->value(); count++) for (int count = 0; count < ui->spinBurst->value(); count++)
{ {
thisFrame.ID = currentID; thisFrame.setFrameId(currentID);
for (int i = 0; i < 8; i++) thisFrame.data[i] = currentBytes[i]; QByteArray bytes(ui->spinBytes->value(), 0);
if (currentID > 0x7FF) thisFrame.extended = true; for (int i = 0; i < bytes.length(); i++) bytes[i] = currentBytes[i];
else thisFrame.extended = false; thisFrame.setPayload(bytes);
thisFrame.bus = 0; //hard coded for now. TODO: do not hard code if (currentID > 0x7FF) thisFrame.setExtendedFrameFormat(true);
thisFrame.len = ui->spinBytes->value(); else thisFrame.setExtendedFrameFormat(false);
thisFrame.bus = 0; //hard coded for now. TODO: do not hard code
if (buses < (ui->cbBuses->count() - 1)) if (buses < (ui->cbBuses->count() - 1))
{ {
@@ -371,7 +371,7 @@ void FuzzingWindow::refreshIDList()
for (int i = 0; i < modelFrames->count(); i++) for (int i = 0; i < modelFrames->count(); i++)
{ {
CANFrame thisFrame = modelFrames->at(i); CANFrame thisFrame = modelFrames->at(i);
id = thisFrame.ID; id = thisFrame.frameId();
if (!foundIDs.contains(id)) if (!foundIDs.contains(id))
{ {
foundIDs.append(id); foundIDs.append(id);
+11 -13
View File
@@ -186,7 +186,7 @@ void GraphingWindow::updatedFrames(int numFrames)
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++) for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
{ {
thisFrame = modelFrames->at(i); thisFrame = modelFrames->at(i);
if (graphParams[j].ID == thisFrame.ID) if (graphParams[j].ID == thisFrame.frameId())
{ {
appendToGraph(graphParams[j], thisFrame, x, y); appendToGraph(graphParams[j], thisFrame, x, y);
appendedToGraph = true; appendedToGraph = true;
@@ -1075,15 +1075,15 @@ void GraphingWindow::appendToGraph(GraphParams &params, CANFrame &frame, QVector
{ {
params.strideSoFar = 0; params.strideSoFar = 0;
int64_t tempVal; //64 bit temp value. int64_t tempVal; //64 bit temp value.
tempVal = Utility::processIntegerSignal(frame.data, params.startBit, params.numBits, params.intelFormat, params.isSigned); //& params.mask; tempVal = Utility::processIntegerSignal(frame.payload(), params.startBit, params.numBits, params.intelFormat, params.isSigned); //& params.mask;
double xVal, yVal; double xVal, yVal;
if (secondsMode) if (secondsMode)
{ {
xVal = ((double)(frame.timestamp) / 1000000.0 - params.xbias); xVal = ((double)(frame.timeStamp().microSeconds()) / 1000000.0 - params.xbias);
} }
else else
{ {
xVal = (frame.timestamp - params.xbias); xVal = (frame.timeStamp().microSeconds() - params.xbias);
} }
yVal = (tempVal * params.scale) + params.bias; yVal = (tempVal * params.scale) + params.bias;
params.x.append(xVal); params.x.append(xVal);
@@ -1113,7 +1113,7 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
for (int i = 0; i < modelFrames->count(); i++) for (int i = 0; i < modelFrames->count(); i++)
{ {
CANFrame thisFrame = modelFrames->at(i); CANFrame thisFrame = modelFrames->at(i);
if (thisFrame.ID == params.ID && thisFrame.remote == false) frameCache.append(thisFrame); if (thisFrame.frameId() == params.ID && thisFrame.frameType() == QCanBusFrame::DataFrame) frameCache.append(thisFrame);
} }
//to fix weirdness where a graph that has no data won't be able to be edited, selected, or deleted properly //to fix weirdness where a graph that has no data won't be able to be edited, selected, or deleted properly
@@ -1122,12 +1122,10 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
if (frameCache.count() == 0) if (frameCache.count() == 0)
{ {
CANFrame dummy; CANFrame dummy;
dummy.ID = params.ID; dummy.setFrameId(params.ID);
dummy.bus = 0; dummy.bus = 0;
dummy.len = 8; dummy.setPayload(QByteArray(8, 0));
dummy.remote = false; dummy.setFrameType(QCanBusFrame::DataFrame);
dummy.timestamp = 0;
for (int i = 0; i < 8; i++) dummy.data[i] = 0;
frameCache.append(dummy); frameCache.append(dummy);
} }
@@ -1147,15 +1145,15 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
for (int j = 0; j < numEntries; j++) for (int j = 0; j < numEntries; j++)
{ {
int k = j * params.stride; int k = j * params.stride;
tempVal = Utility::processIntegerSignal(frameCache[k].data, sBit, bits, intelFormat, isSigned); //& params.mask; tempVal = Utility::processIntegerSignal(frameCache[k].payload(), sBit, bits, intelFormat, isSigned); //& params.mask;
//qDebug() << tempVal; //qDebug() << tempVal;
if (secondsMode) if (secondsMode)
{ {
params.x[j] = (frameCache[k].timestamp) / 1000000.0; params.x[j] = (frameCache[k].timeStamp().microSeconds()) / 1000000.0;
} }
else else
{ {
params.x[j] = frameCache[k].timestamp; params.x[j] = frameCache[k].timeStamp.microSeconds();
} }
params.y[j] = (tempVal * params.scale) + params.bias; params.y[j] = (tempVal * params.scale) + params.bias;
if (params.y[j] < yminval) yminval = params.y[j]; if (params.y[j] < yminval) yminval = params.y[j];
+12 -12
View File
@@ -158,10 +158,10 @@ void RangeStateWindow::updatedFrames(int numFrames)
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++) for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
{ {
thisFrame = modelFrames->at(i); thisFrame = modelFrames->at(i);
if (!idFilters.contains(thisFrame.ID)) if (!idFilters.contains(thisFrame.frameId()))
{ {
idFilters.insert(thisFrame.ID, true); idFilters.insert(thisFrame.frameId(), true);
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(thisFrame.ID, thisFrame.extended), ui->listFilter); QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(thisFrame.frameId(), thisFrame.hasExtendedFrameFormat()), ui->listFilter);
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
listItem->setCheckState(Qt::Checked); //default all filters to be set active listItem->setCheckState(Qt::Checked); //default all filters to be set active
} }
@@ -178,7 +178,7 @@ void RangeStateWindow::refreshFilterList()
for (int i = 0; i < modelFrames->length(); i++) for (int i = 0; i < modelFrames->length(); i++)
{ {
id = modelFrames->at(i).ID; id = modelFrames->at(i).frameId();
if (!idFilters.contains(id)) if (!idFilters.contains(id))
{ {
idFilters.insert(id, true); idFilters.insert(id, true);
@@ -223,7 +223,7 @@ void RangeStateWindow::recalcButton()
id = iter.key(); id = iter.key();
for (int j = 0; j < modelFrames->count(); j++) for (int j = 0; j < modelFrames->count(); j++)
{ {
if (modelFrames->at(j).ID == id) frameCache.append(modelFrames->at(j)); if (modelFrames->at(j).frameId() == id) frameCache.append(modelFrames->at(j));
} }
//now we've got a list with all the same ID. Time to send it off for processing //now we've got a list with all the same ID. Time to send it off for processing
signalsFactory(); signalsFactory();
@@ -247,7 +247,7 @@ void RangeStateWindow::signalsFactory()
int granularity = ui->spinGranularity->value(); int granularity = ui->spinGranularity->value();
int sigType = ui->cbSignalMode->currentIndex() + 1; int sigType = ui->cbSignalMode->currentIndex() + 1;
int signedType = ui->cbSignedMode->currentIndex() + 1; int signedType = ui->cbSignedMode->currentIndex() + 1;
int maxBits = frameCache.at(0).len * 8; int maxBits = frameCache.at(0).payload().length() * 8;
int sens = ui->slideSensitivity->value(); int sens = ui->slideSensitivity->value();
for (int sigSize = maxSig; sigSize >= minSig; sigSize -= granularity) for (int sigSize = maxSig; sigSize >= minSig; sigSize -= granularity)
@@ -297,7 +297,7 @@ bool RangeStateWindow::processSignal(int startBit, int bitLength, int sensitivit
for (i = 0; i < numFrames; i++) for (i = 0; i < numFrames; i++)
{ {
valu = Utility::processIntegerSignal(frameCache.at(i).data, startBit, bitLength, !bigEndian, isSigned); valu = Utility::processIntegerSignal(frameCache.at(i).payload(), startBit, bitLength, !bigEndian, isSigned);
if (valu < lowestValue) lowestValue = valu; if (valu < lowestValue) lowestValue = valu;
if (valu > highestValue) highestValue = valu; if (valu > highestValue) highestValue = valu;
} }
@@ -316,7 +316,7 @@ bool RangeStateWindow::processSignal(int startBit, int bitLength, int sensitivit
return false; //doesn't range enough. return false; //doesn't range enough.
for (i = 0; i < numFrames; i++) for (i = 0; i < numFrames; i++)
scaledVals.append((int)((Utility::processIntegerSignal(frameCache.at(i).data, startBit, bitLength, !bigEndian, isSigned) - lowestValue))); scaledVals.append((int)((Utility::processIntegerSignal(frameCache.at(i).payload(), startBit, bitLength, !bigEndian, isSigned) - lowestValue)));
for (i = 1; i < numFrames; i++) for (i = 1; i < numFrames; i++)
{ {
@@ -365,9 +365,9 @@ bool RangeStateWindow::processSignal(int startBit, int bitLength, int sensitivit
{ {
//createGraph(scaledVals); //createGraph(scaledVals);
QString temp; QString temp;
temp = "ID: " + QString::number(frameCache.at(0).ID, 16) + " startBit: " + QString::number(startBit) + " len: " + QString::number(bitLength); temp = "ID: " + QString::number(frameCache.at(0).frameId(), 16) + " startBit: " + QString::number(startBit) + " len: " + QString::number(bitLength);
int64_t foundSig; int64_t foundSig;
foundSig = frameCache.at(0).ID; foundSig = frameCache.at(0).frameId();
foundSig += (int64_t)startBit << 32; foundSig += (int64_t)startBit << 32;
foundSig += (int64_t)bitLength << 40; foundSig += (int64_t)bitLength << 40;
@@ -474,12 +474,12 @@ void RangeStateWindow::clickedSignalList(int idx)
for (int j = 0; j < modelFrames->count(); j++) for (int j = 0; j < modelFrames->count(); j++)
{ {
if (modelFrames->at(j).ID == id) frameCache.append(modelFrames->at(j)); if (modelFrames->at(j).frameId() == id) frameCache.append(modelFrames->at(j));
} }
int numFrames = frameCache.count(); int numFrames = frameCache.count();
QVector<int> values; QVector<int> values;
values.reserve(numFrames); values.reserve(numFrames);
for (int i = 0; i < numFrames; i++) values.append((int)((Utility::processIntegerSignal(frameCache.at(i).data, startBit, bitLength, !isBigEndian, isSigned)))); for (int i = 0; i < numFrames; i++) values.append((int)((Utility::processIntegerSignal(frameCache.at(i).payload(), startBit, bitLength, !isBigEndian, isSigned))));
createGraph(values); createGraph(values);
} }
+6 -6
View File
@@ -10,11 +10,11 @@ SnifferItem::SnifferItem(const CANFrame& pFrame, quint32 seq):
mNotch[i] =0; mNotch[i] =0;
mMarker.data[i] = 0; mMarker.data[i] = 0;
mMarker.dataTimestamp[i] = 0; mMarker.dataTimestamp[i] = 0;
mCurrent.data[i] = pFrame.data[i]; mCurrent.data[i] = pFrame.payload()[i];
mCurrent.dataTimestamp[i] = seq; mCurrent.dataTimestamp[i] = seq;
} }
mLastMarker = mMarker; mLastMarker = mMarker;
mCurrent.len = pFrame.len; mCurrent.len = pFrame.payload().length();
/* that's dirty */ /* that's dirty */
update(pFrame, seq, false); update(pFrame, seq, false);
update(pFrame, seq, false); update(pFrame, seq, false);
@@ -115,18 +115,18 @@ void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq, bool mute)
/* copy new value */ /* copy new value */
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
maskedData = pFrame.data[i]; maskedData = pFrame.payload()[i];
if (mute) maskedData &= ~mNotch[i]; if (mute) maskedData &= ~mNotch[i];
maskedCurr = mCurrent.data[i]; maskedCurr = mCurrent.data[i];
if (mute) maskedCurr &= ~mNotch[i]; if (mute) maskedCurr &= ~mNotch[i];
if (maskedCurr != maskedData) if (maskedCurr != maskedData)
{ {
mCurrent.data[i] = pFrame.data[i]; mCurrent.data[i] = pFrame.payload()[i];
mCurrent.dataTimestamp[i] = timeSeq; mCurrent.dataTimestamp[i] = timeSeq;
} }
} }
mCurrent.len = pFrame.len; mCurrent.len = pFrame.payload().length();
mCurrentTime = pFrame.timestamp; mCurrentTime = pFrame.timeStamp().microSeconds();
/* update marker */ /* update marker */
//We "OR" our stored marker with the changed bits. //We "OR" our stored marker with the changed bits.
+6 -6
View File
@@ -300,20 +300,20 @@ void SnifferModel::update(CANConnection*, QVector<CANFrame>& pFrames)
{ {
foreach(const CANFrame& frame, pFrames) foreach(const CANFrame& frame, pFrames)
{ {
if(!mMap.contains(frame.ID)) if(!mMap.contains(frame.frameId()))
{ {
int index = std::distance(mMap.begin(), mMap.lowerBound(frame.ID)); int index = std::distance(mMap.begin(), mMap.lowerBound(frame.frameId()));
/* add the frame */ /* add the frame */
beginInsertRows(QModelIndex(), index, index); beginInsertRows(QModelIndex(), index, index);
mMap[frame.ID] = new SnifferItem(frame, mTimeSequence); mMap[frame.frameId()] = new SnifferItem(frame, mTimeSequence);
mMap[frame.ID]->update(frame, mTimeSequence, mMuteNotched); mMap[frame.frameId()]->update(frame, mTimeSequence, mMuteNotched);
endInsertRows(); endInsertRows();
emit idChange(frame.ID, true); emit idChange(frame.frameId(), true);
} }
else else
//updateData //updateData
mMap[frame.ID]->update(frame, mTimeSequence, mMuteNotched); mMap[frame.frameId()]->update(frame, mTimeSequence, mMuteNotched);
} }
} }
+6 -6
View File
@@ -196,13 +196,13 @@ void TemporalGraphWindow::generateGraph()
x.reserve(frameCount); x.reserve(frameCount);
y.reserve(frameCount); y.reserve(frameCount);
xminval = xmaxval = modelFrames->at(0).timestamp / 1000000.0; xminval = xmaxval = modelFrames->at(0).timeStamp().microSeconds() / 1000000.0;
yminval = ymaxval = modelFrames->at(0).ID; yminval = ymaxval = modelFrames->at(0).frameId();
for (int i = 0; i < frameCount; i++) for (int i = 0; i < frameCount; i++)
{ {
x.append(modelFrames->at(i).timestamp / 1000000.0); x.append(modelFrames->at(i).timeStamp().microSeconds() / 1000000.0);
y.append(modelFrames->at(i).ID); y.append(modelFrames->at(i).frameId());
if (x[i] > xmaxval) xmaxval = x[i]; if (x[i] > xmaxval) xmaxval = x[i];
if (x[i] < xminval) xminval = x[i]; if (x[i] < xminval) xminval = x[i];
if (y[i] > ymaxval) ymaxval = y[i]; if (y[i] > ymaxval) ymaxval = y[i];
@@ -246,8 +246,8 @@ void TemporalGraphWindow::generateGraph()
for (int i = 0; i < frameCount; i++) for (int i = 0; i < frameCount; i++)
{ {
int x = static_cast<int>(((modelFrames->at(i).timestamp / 1000000.0) - xminval) * 4.0); int x = static_cast<int>(((modelFrames->at(i).timeStamp().microSeconds() / 1000000.0) - xminval) * 4.0);
int y = static_cast<int>(modelFrames->at(i).ID - yminval) / 30; int y = static_cast<int>(modelFrames->at(i).frameId() - yminval) / 30;
double val = colorMap->data()->cell(x, y); double val = colorMap->data()->cell(x, y);
double inc; double inc;
inc = 1 / (val + 1); //logarithmic decay inc = 1 / (val + 1); //logarithmic decay
+1 -1
View File
@@ -179,7 +179,7 @@ public:
return (value1 * (1.0 - samplePoint)) + (value2 * samplePoint); return (value1 * (1.0 - samplePoint)) + (value2 * samplePoint);
} }
static int64_t processIntegerSignal(const uint8_t *data, int startBit, int sigSize, bool littleEndian, bool isSigned) static int64_t processIntegerSignal(const QByteArray data, int startBit, int sigSize, bool littleEndian, bool isSigned)
{ {
int64_t result = 0; int64_t result = 0;