Add version # to window title, additional work on DBC stuff, removed a bunch of debug messages, removed more references to baud.
This commit is contained in:
@@ -14,6 +14,24 @@ CANFrameModel::CANFrameModel(QObject *parent)
|
|||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
{
|
{
|
||||||
frames.reserve(100000); //ask for at least 100,000 entries. This gives good performance up to this limit
|
frames.reserve(100000); //ask for at least 100,000 entries. This gives good performance up to this limit
|
||||||
|
dbcHandler = NULL;
|
||||||
|
interpretFrames = false;
|
||||||
|
overwriteDups = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CANFrameModel::setDBCHandler(DBCHandler *handler)
|
||||||
|
{
|
||||||
|
dbcHandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CANFrameModel::setInterpetMode(bool mode)
|
||||||
|
{
|
||||||
|
interpretFrames = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CANFrameModel::setOverwriteMode(bool mode)
|
||||||
|
{
|
||||||
|
overwriteDups = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||||
@@ -51,6 +69,18 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
|||||||
tempString.append(QString::number(thisFrame.data[i], 16).toUpper().rightJustified(2,'0'));
|
tempString.append(QString::number(thisFrame.data[i], 16).toUpper().rightJustified(2,'0'));
|
||||||
tempString.append(" ");
|
tempString.append(" ");
|
||||||
}
|
}
|
||||||
|
//now, if we're supposed to interpret the data and the DBC handler is loaded then use it
|
||||||
|
if (dbcHandler != NULL)
|
||||||
|
{
|
||||||
|
DBC_MESSAGE *msg = dbcHandler->findMsgByID(thisFrame.ID);
|
||||||
|
if (msg != NULL)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < msg->msgSignals.length(); j++)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return tempString;
|
return tempString;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "can_structs.h"
|
#include "can_structs.h"
|
||||||
|
#include "dbchandler.h"
|
||||||
|
|
||||||
class CANFrameModel: public QAbstractTableModel
|
class CANFrameModel: public QAbstractTableModel
|
||||||
{
|
{
|
||||||
@@ -22,11 +23,17 @@ public:
|
|||||||
void sendRefresh();
|
void sendRefresh();
|
||||||
void sendRefresh(int);
|
void sendRefresh(int);
|
||||||
void clearFrames();
|
void clearFrames();
|
||||||
|
void setDBCHandler(DBCHandler *);
|
||||||
|
void setInterpetMode(bool);
|
||||||
|
void setOverwriteMode(bool);
|
||||||
QList<CANFrame> *getListReference();
|
QList<CANFrame> *getListReference();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<CANFrame> frames;
|
QList<CANFrame> frames;
|
||||||
|
DBCHandler *dbcHandler;
|
||||||
|
bool interpretFrames; //should we use the dbcHandler?
|
||||||
|
bool overwriteDups; //should we display all frames or only the newest for each ID?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -318,3 +318,44 @@ void DBCHandler::listDebugging()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//DBC files use what I'd consider a completely stupid way to count bits. The lowest bit
|
||||||
|
//in a byte is 7 while the highest is 0. So, the counting for a byte goes like this:
|
||||||
|
//0 1 2 3 4 5 6 7. That only makes sense if you write it out like that. In reality bits are stored
|
||||||
|
//7 6 5 4 3 2 1 0. So, plan accordingly. It's confusing when you're used to bit 7 being the highest, not lowest
|
||||||
|
//But, bytes are still in order. Byte 0 is the first byte, byte 7 would be the last byte in a frame.
|
||||||
|
//So, the lowest bit of the last byte is 63. The upshot is that, if you took all the bytes in a canbus
|
||||||
|
//frame and started labeling from left to right you would really number 0 to 63 in complete order. It's
|
||||||
|
//just that computers don't store data like that. Have I mentioned that already? Screw Vector. Go away on a CANoe.
|
||||||
|
//0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Vector bit ordering
|
||||||
|
//7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 Bitwise ordering within bytes
|
||||||
|
//0 1 2 3 Byte ordering
|
||||||
|
//For intel format invert the starting bit within a byte.
|
||||||
|
//Otherwise, iterate over the bytes that it encompasses and
|
||||||
|
void DBCHandler::processSignal(CANFrame *frame, DBC_SIGNAL *sig)
|
||||||
|
{
|
||||||
|
int startBit, endBit, startByte, endByte, bitWithinByteStart, bitWithinByteEnd;
|
||||||
|
|
||||||
|
startBit = sig->startBit;
|
||||||
|
startByte = startBit / 8;
|
||||||
|
bitWithinByteStart = startBit % 8;
|
||||||
|
if (sig->intelByteOrder)
|
||||||
|
{
|
||||||
|
bitWithinByteStart = 7 - bitWithinByteStart;
|
||||||
|
startBit = (startByte * 8) + bitWithinByteStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
endBit = startBit + sig->signalSize - 1;
|
||||||
|
endByte = endBit / 8;
|
||||||
|
bitWithinByteEnd = endBit % 8;
|
||||||
|
|
||||||
|
if (sig->intelByteOrder) //little endian - startBit is least sig. bit
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else //motorola / big endian - startBit is most sig. bit
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+10
-3
@@ -3,6 +3,12 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "dbc_classes.h"
|
#include "dbc_classes.h"
|
||||||
|
#include "can_structs.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For ease of quick testing and development this is all run together.
|
||||||
|
* It should be decoupled once the functionality is confirmed.
|
||||||
|
*/
|
||||||
|
|
||||||
class DBCHandler : public QObject
|
class DBCHandler : public QObject
|
||||||
{
|
{
|
||||||
@@ -11,6 +17,10 @@ public:
|
|||||||
explicit DBCHandler(QObject *parent = 0);
|
explicit DBCHandler(QObject *parent = 0);
|
||||||
void loadDBCFile(QString);
|
void loadDBCFile(QString);
|
||||||
void listDebugging();
|
void listDebugging();
|
||||||
|
void processSignal(CANFrame *frame, DBC_SIGNAL *sig);
|
||||||
|
DBC_NODE *findNodeByName(QString name);
|
||||||
|
DBC_MESSAGE *findMsgByID(int id);
|
||||||
|
DBC_SIGNAL *findSignalByName(DBC_MESSAGE *msg, QString name);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
@@ -20,9 +30,6 @@ private:
|
|||||||
QList<DBC_NODE> dbc_nodes;
|
QList<DBC_NODE> dbc_nodes;
|
||||||
QList<DBC_MESSAGE> dbc_messages;
|
QList<DBC_MESSAGE> dbc_messages;
|
||||||
|
|
||||||
DBC_NODE *findNodeByName(QString name);
|
|
||||||
DBC_MESSAGE *findMsgByID(int id);
|
|
||||||
DBC_SIGNAL *findSignalByName(DBC_MESSAGE *msg, QString name);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DBCHANDLER_H
|
#endif // DBCHANDLER_H
|
||||||
|
|||||||
+10
-4
@@ -28,6 +28,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
this->setWindowTitle("Savvy CAN V" + QString::number(VERSION));
|
||||||
|
|
||||||
model = new CANFrameModel();
|
model = new CANFrameModel();
|
||||||
ui->canFramesView->setModel(model);
|
ui->canFramesView->setModel(model);
|
||||||
|
|
||||||
@@ -39,7 +41,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
ui->canFramesView->setColumnWidth(2, 40);
|
ui->canFramesView->setColumnWidth(2, 40);
|
||||||
ui->canFramesView->setColumnWidth(3, 40);
|
ui->canFramesView->setColumnWidth(3, 40);
|
||||||
ui->canFramesView->setColumnWidth(4, 40);
|
ui->canFramesView->setColumnWidth(4, 40);
|
||||||
ui->canFramesView->setColumnWidth(5, 300);
|
ui->canFramesView->setColumnWidth(5, 275);
|
||||||
|
QHeaderView *HorzHdr = ui->canFramesView->horizontalHeader();
|
||||||
|
HorzHdr->setStretchLastSection(true); //causes the data column to automatically fill the tableview
|
||||||
|
|
||||||
ports = QSerialPortInfo::availablePorts();
|
ports = QSerialPortInfo::availablePorts();
|
||||||
|
|
||||||
@@ -80,6 +84,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
frameSenderWindow = NULL;
|
frameSenderWindow = NULL;
|
||||||
dbcHandler = new DBCHandler;
|
dbcHandler = new DBCHandler;
|
||||||
|
|
||||||
|
model->setDBCHandler(dbcHandler);
|
||||||
|
|
||||||
connect(ui->btnConnect, SIGNAL(clicked(bool)), this, SLOT(connButtonPress()));
|
connect(ui->btnConnect, SIGNAL(clicked(bool)), this, SLOT(connButtonPress()));
|
||||||
connect(ui->actionOpen_Log_File, SIGNAL(triggered(bool)), this, SLOT(handleLoadFile()));
|
connect(ui->actionOpen_Log_File, SIGNAL(triggered(bool)), this, SLOT(handleLoadFile()));
|
||||||
connect(ui->actionGraph_Dta, SIGNAL(triggered(bool)), this, SLOT(showGraphingWindow()));
|
connect(ui->actionGraph_Dta, SIGNAL(triggered(bool)), this, SLOT(showGraphingWindow()));
|
||||||
@@ -120,10 +126,10 @@ MainWindow::~MainWindow()
|
|||||||
void MainWindow::updateBaudLabel(int baud0, int baud1)
|
void MainWindow::updateBaudLabel(int baud0, int baud1)
|
||||||
{
|
{
|
||||||
QString labelText;
|
QString labelText;
|
||||||
labelText = tr("Baud 0: ");
|
labelText = tr("CAN 0 Speed: ");
|
||||||
if (baud0 > 0) labelText += QString::number(baud0 / 1000.0) + "kbps";
|
if (baud0 > 0) labelText += QString::number(baud0 / 1000.0) + "kbps";
|
||||||
else labelText += tr("disabled");
|
else labelText += tr("disabled");
|
||||||
labelText += tr(" Baud 1: ");
|
labelText += tr(" CAN 1 Speed: ");
|
||||||
if (baud1 > 0) labelText += QString::number(baud1 / 1000.0) + "kbps";
|
if (baud1 > 0) labelText += QString::number(baud1 / 1000.0) + "kbps";
|
||||||
else labelText += tr("disabled");
|
else labelText += tr("disabled");
|
||||||
lbStatusBauds.setText(labelText);
|
lbStatusBauds.setText(labelText);
|
||||||
@@ -131,7 +137,7 @@ void MainWindow::updateBaudLabel(int baud0, int baud1)
|
|||||||
|
|
||||||
void MainWindow::gotFrame(CANFrame *frame)
|
void MainWindow::gotFrame(CANFrame *frame)
|
||||||
{
|
{
|
||||||
qDebug() << "got frame from serial side. ID was " << frame->ID;
|
//qDebug() << "got frame from serial side. ID was " << frame->ID;
|
||||||
addFrameToDisplay(*frame, true);
|
addFrameToDisplay(*frame, true);
|
||||||
ui->lbNumFrames->setText(QString::number(model->rowCount()));
|
ui->lbNumFrames->setText(QString::number(model->rowCount()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include "framesenderwindow.h"
|
#include "framesenderwindow.h"
|
||||||
#include "dbchandler.h"
|
#include "dbchandler.h"
|
||||||
|
|
||||||
|
#define VERSION 100
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-2
@@ -168,6 +168,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnClearFrames">
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear Frames</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="cbAutoScroll">
|
<widget class="QCheckBox" name="cbAutoScroll">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -176,9 +183,16 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnClearFrames">
|
<widget class="QCheckBox" name="cbInterpret">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Clear Frames</string>
|
<string>Interpret Frames</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cbOverwrite">
|
||||||
|
<property name="text">
|
||||||
|
<string>Overwrite Mode</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
+5
-3
@@ -77,7 +77,7 @@ void SerialWorker::readSerialData()
|
|||||||
{
|
{
|
||||||
QByteArray data = serial->readAll();
|
QByteArray data = serial->readAll();
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
qDebug() << (tr("Got data from serial. Len = %0").arg(data.length()));
|
//qDebug() << (tr("Got data from serial. Len = %0").arg(data.length()));
|
||||||
for (int i = 0; i < data.length(); i++)
|
for (int i = 0; i < data.length(); i++)
|
||||||
{
|
{
|
||||||
c = data.at(i);
|
c = data.at(i);
|
||||||
@@ -91,7 +91,9 @@ void SerialWorker::sendFrame(const CANFrame *frame, int bus = 0)
|
|||||||
int c;
|
int c;
|
||||||
int ID;
|
int ID;
|
||||||
|
|
||||||
qDebug() << "Sending out frame with id " << frame->ID;
|
if (!connected) return;
|
||||||
|
|
||||||
|
//qDebug() << "Sending out frame with id " << frame->ID;
|
||||||
|
|
||||||
ID = frame->ID;
|
ID = frame->ID;
|
||||||
if (frame->extended) ID |= 1 << 31;
|
if (frame->extended) ID |= 1 << 31;
|
||||||
@@ -223,7 +225,7 @@ void SerialWorker::procRXChar(unsigned char c)
|
|||||||
{
|
{
|
||||||
rx_state = IDLE;
|
rx_state = IDLE;
|
||||||
rx_step = 0;
|
rx_step = 0;
|
||||||
qDebug() << "emit from serial handler to main form id: " << buildFrame->ID;
|
//qDebug() << "emit from serial handler to main form id: " << buildFrame->ID;
|
||||||
emit receivedFrame(buildFrame);
|
emit receivedFrame(buildFrame);
|
||||||
buildFrame = new CANFrame;
|
buildFrame = new CANFrame;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user