Merge branch 'master' of github.com:collin80/SavvyCAN into WIP
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# SavvyCAN
|
||||
QT based cross platform canbus tool
|
||||
Qt based cross platform canbus tool
|
||||
(C) 2015-2017 EVTV and Collin Kidder
|
||||
|
||||
A QT5 based cross platform tool which can be used to load, save, and capture canbus frames.
|
||||
A Qt5 based cross platform tool which can be used to load, save, and capture canbus frames.
|
||||
This tool is designed to help with visualization, reverse engineering, debugging, and
|
||||
capturing of canbus frames.
|
||||
|
||||
@@ -37,7 +37,7 @@ of this program. It can load and save in several formats:
|
||||
## Dependencies
|
||||
|
||||
Now this code does not depend on anything other than what is in the source tree or available
|
||||
from the QT installer.
|
||||
from the Qt installer.
|
||||
|
||||
Uses QCustomPlot available at:
|
||||
|
||||
@@ -83,5 +83,5 @@ make
|
||||
```
|
||||
|
||||
Did that fix it? Great! If not, ensure that you selected SerialBUS support
|
||||
when you installed QT.
|
||||
when you installed Qt.
|
||||
|
||||
|
||||
+3
-5
@@ -4,9 +4,7 @@
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui serialbus
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets serialport printsupport qml
|
||||
QT = core gui printsupport qml serialbus serialport widgets
|
||||
|
||||
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
|
||||
|
||||
@@ -34,7 +32,7 @@ SOURCES += main.cpp\
|
||||
can_structs.cpp \
|
||||
motorcontrollerconfigwindow.cpp \
|
||||
connections/canconnection.cpp \
|
||||
connections/socketcan.cpp \
|
||||
connections/serialbusconnection.cpp \
|
||||
connections/canconfactory.cpp \
|
||||
connections/gvretserial.cpp \
|
||||
connections/canconmanager.cpp \
|
||||
@@ -86,7 +84,7 @@ HEADERS += mainwindow.h \
|
||||
utils/lfqueue.h \
|
||||
motorcontrollerconfigwindow.h \
|
||||
connections/canconnection.h \
|
||||
connections/socketcan.h \
|
||||
connections/serialbusconnection.h \
|
||||
connections/canconconst.h \
|
||||
connections/canconfactory.h \
|
||||
connections/gvretserial.h \
|
||||
|
||||
+2
-2
@@ -54,8 +54,8 @@ void BisectWindow::refreshIDList()
|
||||
std::sort(foundID.begin(), foundID.end());
|
||||
|
||||
foreach (int id, foundID) {
|
||||
ui->cbIDLower->addItem(Utility::formatNumber(id));
|
||||
ui->cbIDUpper->addItem(Utility::formatNumber(id));
|
||||
ui->cbIDLower->addItem(Utility::formatCANID(id));
|
||||
ui->cbIDUpper->addItem(Utility::formatCANID(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+28
-34
@@ -215,6 +215,16 @@ void CANFrameModel::recalcOverwrite()
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
enum class Column {
|
||||
TimeStamp = 0, ///< The timestamp when the frame was transmitted or received
|
||||
FrameId = 1, ///< The frames CAN identifier (Standard: 11 or Extended: 29 bit)
|
||||
Extended = 2, ///< True if the frames CAN identifier is 29 bit
|
||||
Direction = 3, ///< Whether the frame was transmitted or received
|
||||
Bus = 4, ///< The bus where the frame was transmitted or received
|
||||
Length = 5, ///< The frames payload data length
|
||||
Data = 6 ///< The frames payload data
|
||||
};
|
||||
|
||||
QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
int dLen;
|
||||
@@ -257,28 +267,22 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (index.column())
|
||||
switch (Column(index.column()))
|
||||
{
|
||||
case 0: //timestamp
|
||||
case Column::TimeStamp:
|
||||
return Utility::formatTimestamp(thisFrame.timestamp);
|
||||
break;
|
||||
case 1: //id
|
||||
return Utility::formatNumber(thisFrame.ID);
|
||||
break;
|
||||
case 2: //ext
|
||||
case Column::FrameId:
|
||||
return Utility::formatCANID(thisFrame.ID, thisFrame.extended);
|
||||
case Column::Extended:
|
||||
return QString::number(thisFrame.extended);
|
||||
break;
|
||||
case 3: //direction
|
||||
case Column::Direction:
|
||||
if (thisFrame.isReceived) return QString(tr("Rx"));
|
||||
else return QString(tr("Tx"));
|
||||
break;
|
||||
case 4: //bus
|
||||
return QString(tr("Tx"));
|
||||
case Column::Bus:
|
||||
return QString::number(thisFrame.bus);
|
||||
break;
|
||||
case 5: //len
|
||||
case Column::Length:
|
||||
return QString::number(thisFrame.len);
|
||||
break;
|
||||
case 6: //data
|
||||
case Column::Data:
|
||||
dLen = thisFrame.len;
|
||||
if (dLen < 0) dLen = 0;
|
||||
if (dLen > 8) dLen = 8;
|
||||
@@ -307,9 +311,6 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
return tempString;
|
||||
break;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,29 +325,22 @@ QVariant CANFrameModel::headerData(int section, Qt::Orientation orientation,
|
||||
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
switch (section)
|
||||
switch (Column(section))
|
||||
{
|
||||
case 0:
|
||||
case Column::TimeStamp:
|
||||
return QString(tr("Timestamp"));
|
||||
break;
|
||||
case 1:
|
||||
case Column::FrameId:
|
||||
return QString(tr("ID"));
|
||||
break;
|
||||
case 2:
|
||||
case Column::Extended:
|
||||
return QString(tr("Ext"));
|
||||
break;
|
||||
case 3:
|
||||
case Column::Direction:
|
||||
return QString(tr("Dir"));
|
||||
break;
|
||||
case 4:
|
||||
case Column::Bus:
|
||||
return QString(tr("Bus"));
|
||||
break;
|
||||
case 5:
|
||||
case Column::Length:
|
||||
return QString(tr("Len"));
|
||||
break;
|
||||
case 6:
|
||||
case Column::Data:
|
||||
return QString(tr("Data"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <QString>
|
||||
#include "canconfactory.h"
|
||||
#include "socketcan.h"
|
||||
#include "serialbusconnection.h"
|
||||
#include "gvretserial.h"
|
||||
|
||||
using namespace CANCon;
|
||||
@@ -9,7 +9,7 @@ CANConnection* CanConFactory::create(type pType, QString pPortName)
|
||||
{
|
||||
switch(pType) {
|
||||
case SOCKETCAN:
|
||||
return new SocketCan(pPortName);
|
||||
return new SerialBusConnection(pPortName);
|
||||
case GVRET_SERIAL:
|
||||
return new GVRetSerial(pPortName);
|
||||
default: {}
|
||||
|
||||
@@ -11,6 +11,16 @@ CANConnectionModel::~CANConnectionModel()
|
||||
{
|
||||
}
|
||||
|
||||
enum class Column {
|
||||
Bus = 0, ///< A sequential number describing the bus
|
||||
Type = 1, ///< The CAN driver/backend type, e.g. GVRET, peakcan, or socketcan
|
||||
Port = 2, ///< The CAN hardware port, e.g. can0 for socketcan
|
||||
Speed = 3, ///< The bus speed in bit/second
|
||||
ListenOnly = 4, ///< True if the bus is in listen-only mode
|
||||
SingleWire = 5, ///< True if the bus operates in single-wire mode
|
||||
Active = 6, ///< True if the bus is activated for sending and receiving
|
||||
Status = 7 ///< The bus status as text message
|
||||
};
|
||||
|
||||
QVariant CANConnectionModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
@@ -19,32 +29,24 @@ QVariant CANConnectionModel::headerData(int section, Qt::Orientation orientation
|
||||
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
switch (section)
|
||||
switch (Column(section))
|
||||
{
|
||||
case 0:
|
||||
case Column::Bus:
|
||||
return QString(tr("Bus"));
|
||||
break;
|
||||
case 1:
|
||||
case Column::Type:
|
||||
return QString(tr("Type"));
|
||||
break;
|
||||
case 2:
|
||||
case Column::Port:
|
||||
return QString(tr("Port"));
|
||||
break;
|
||||
case 3:
|
||||
case Column::Speed:
|
||||
return QString(tr("Speed"));
|
||||
break;
|
||||
case 4:
|
||||
case Column::ListenOnly:
|
||||
return QString(tr("Listen Only"));
|
||||
break;
|
||||
case 5:
|
||||
case Column::SingleWire:
|
||||
return QString(tr("Single Wire"));
|
||||
break;
|
||||
case 6:
|
||||
case Column::Active:
|
||||
return QString(tr("Active"));
|
||||
break;
|
||||
case 7:
|
||||
case Column::Status:
|
||||
return QString(tr("Status"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,23 +92,19 @@ Qt::ItemFlags CANConnectionModel::flags(const QModelIndex &index) const
|
||||
bool editParams = false;
|
||||
if (conn_p->getType() == CANCon::GVRET_SERIAL) editParams = true;
|
||||
|
||||
switch (index.column())
|
||||
switch (Column(index.column()))
|
||||
{
|
||||
case 3: //speed
|
||||
case Column::Speed:
|
||||
if (editParams) return Qt::ItemFlag::ItemIsEditable | Qt::ItemFlag::ItemIsEnabled;
|
||||
else return Qt::ItemFlag::NoItemFlags;
|
||||
break;
|
||||
case 4: //listen only
|
||||
case 5: //single wire
|
||||
return Qt::ItemFlag::NoItemFlags;
|
||||
case Column::ListenOnly:
|
||||
case Column::SingleWire:
|
||||
if (editParams) return Qt::ItemFlag::ItemIsEditable | Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsUserCheckable;
|
||||
else return Qt::ItemFlag::NoItemFlags;
|
||||
break;
|
||||
case 6: //enabled
|
||||
return Qt::ItemFlag::NoItemFlags;
|
||||
case Column::Active:
|
||||
return Qt::ItemFlag::ItemIsEditable | Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsUserCheckable;
|
||||
break;
|
||||
default:
|
||||
return Qt::ItemFlag::ItemIsEnabled;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,20 +120,21 @@ bool CANConnectionModel::setData(const QModelIndex &index, const QVariant &value
|
||||
ret = conn_p->getBusSettings(busId, bus);
|
||||
if (!ret) return false;
|
||||
|
||||
switch (index.column())
|
||||
switch (Column(index.column()))
|
||||
{
|
||||
case 3: //speed
|
||||
case Column::Speed:
|
||||
bus.speed = value.toInt();
|
||||
break;
|
||||
case 4: //listen only
|
||||
case Column::ListenOnly:
|
||||
bus.listenOnly = value.toBool();
|
||||
break;
|
||||
case 5: //single wire
|
||||
case Column::SingleWire:
|
||||
bus.singleWire = value.toBool();
|
||||
break;
|
||||
case 6: //active
|
||||
case Column::Active:
|
||||
bus.active = value.toBool();
|
||||
break;
|
||||
default: {}
|
||||
}
|
||||
conn_p->setBusSettings(busId, bus);
|
||||
return true;
|
||||
@@ -157,15 +156,14 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
//qDebug() << "ConnP: " << conn_p << " ret " << ret;
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (role == Qt::DisplayRole) {
|
||||
|
||||
switch (index.column())
|
||||
switch (Column(index.column()))
|
||||
{
|
||||
case 0: //bus
|
||||
case Column::Bus:
|
||||
//return QString::number(busId);
|
||||
return QString::number(index.row());
|
||||
break;
|
||||
case 1: //type
|
||||
case Column::Type:
|
||||
if (conn_p)
|
||||
switch (conn_p->getType()) {
|
||||
case CANCon::KVASER: return "KVASER";
|
||||
@@ -175,38 +173,35 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
else qDebug() << "Tried to show connection type but connection was NULL";
|
||||
break;
|
||||
case 2: //port
|
||||
case Column::Port:
|
||||
if (conn_p) return conn_p->getPort();
|
||||
else qDebug() << "Tried to show connection port but connection was NULL";
|
||||
break;
|
||||
case 3: //speed
|
||||
case Column::Speed:
|
||||
if(!ret) return QVariant();
|
||||
if (!isSocketCAN) return QString::number(bus.speed);
|
||||
else return QString("N/A");
|
||||
case 4: //Listen Only
|
||||
case Column::ListenOnly:
|
||||
return QVariant();
|
||||
case 5: //Single Wire
|
||||
case Column::SingleWire:
|
||||
return QVariant();
|
||||
case 6: //Status
|
||||
case Column::Active:
|
||||
return QVariant();
|
||||
case 7: //Active
|
||||
case Column::Status:
|
||||
return (conn_p->getStatus()==CANCon::CONNECTED) ? "Connected" : "Not Connected";
|
||||
default: {}
|
||||
}
|
||||
}
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
switch (index.column())
|
||||
switch (Column(index.column()))
|
||||
{
|
||||
case 4:
|
||||
case Column::ListenOnly:
|
||||
return (bus.listenOnly) ? Qt::Checked : Qt::Unchecked;
|
||||
break;
|
||||
case 5:
|
||||
case Column::SingleWire:
|
||||
return (bus.singleWire) ? Qt::Checked : Qt::Unchecked;
|
||||
break;
|
||||
case 6:
|
||||
case Column::Active:
|
||||
return (bus.active) ? Qt::Checked : Qt::Unchecked;
|
||||
break;
|
||||
default: {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
#include "canbus.h"
|
||||
#include "connections/canconnection.h"
|
||||
#include "connectionwindow.h"
|
||||
|
||||
class CANConnection;
|
||||
|
||||
class CANConnectionModel : public QAbstractTableModel
|
||||
{
|
||||
|
||||
@@ -1,31 +1,30 @@
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include "serialbusconnection.h"
|
||||
|
||||
#include "canconmanager.h"
|
||||
|
||||
#include <QCanBus>
|
||||
#include <QCanBusFrame>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "socketcan.h"
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
/***********************************/
|
||||
/**** class definition ****/
|
||||
/***********************************/
|
||||
|
||||
SocketCan::SocketCan(QString portName) :
|
||||
SerialBusConnection::SerialBusConnection(QString portName) :
|
||||
CANConnection(portName, CANCon::SOCKETCAN, 1, 4000, true),
|
||||
mDev_p(NULL),
|
||||
mTimer(this) /*NB: set connection as parent of timer to manage it from working thread */
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SocketCan::~SocketCan()
|
||||
SerialBusConnection::~SerialBusConnection()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
void SocketCan::piStarted()
|
||||
void SerialBusConnection::piStarted()
|
||||
{
|
||||
connect(&mTimer, SIGNAL(timeout()), this, SLOT(testConnection()));
|
||||
mTimer.setInterval(1000);
|
||||
@@ -36,7 +35,7 @@ void SocketCan::piStarted()
|
||||
}
|
||||
|
||||
|
||||
void SocketCan::piSuspend(bool pSuspend)
|
||||
void SerialBusConnection::piSuspend(bool pSuspend)
|
||||
{
|
||||
/* update capSuspended */
|
||||
setCapSuspended(pSuspend);
|
||||
@@ -47,19 +46,19 @@ void SocketCan::piSuspend(bool pSuspend)
|
||||
}
|
||||
|
||||
|
||||
void SocketCan::piStop() {
|
||||
void SerialBusConnection::piStop() {
|
||||
mTimer.stop();
|
||||
disconnectDevice();
|
||||
}
|
||||
|
||||
|
||||
bool SocketCan::piGetBusSettings(int pBusIdx, CANBus& pBus)
|
||||
bool SerialBusConnection::piGetBusSettings(int pBusIdx, CANBus& pBus)
|
||||
{
|
||||
return getBusConfig(pBusIdx, pBus);
|
||||
}
|
||||
|
||||
|
||||
void SocketCan::piSetBusSettings(int pBusIdx, CANBus bus)
|
||||
void SerialBusConnection::piSetBusSettings(int pBusIdx, CANBus bus)
|
||||
{
|
||||
CANConStatus stats;
|
||||
/* sanity checks */
|
||||
@@ -67,8 +66,7 @@ void SocketCan::piSetBusSettings(int pBusIdx, CANBus bus)
|
||||
return;
|
||||
|
||||
/* disconnect device if we have one connected */
|
||||
if(mDev_p)
|
||||
disconnectDevice();
|
||||
disconnectDevice();
|
||||
|
||||
/* copy bus config */
|
||||
setBusConfig(0, bus);
|
||||
@@ -78,17 +76,18 @@ void SocketCan::piSetBusSettings(int pBusIdx, CANBus bus)
|
||||
return;
|
||||
|
||||
/* create device */
|
||||
mDev_p = QCanBus::instance()->createDevice("socketcan", getPort());
|
||||
QString errorString;
|
||||
mDev_p = QCanBus::instance()->createDevice("socketcan", getPort(), &errorString);
|
||||
if (!mDev_p) {
|
||||
disconnectDevice();
|
||||
qDebug() << "can't create device";
|
||||
qDebug() << "Error: createDevice(" << getType() << getPort() << "):" << errorString;
|
||||
return;
|
||||
}
|
||||
|
||||
/* connect slots */
|
||||
connect(mDev_p, &QCanBusDevice::errorOccurred, this, &SocketCan::errorReceived);
|
||||
connect(mDev_p, &QCanBusDevice::framesWritten, this, &SocketCan::framesWritten);
|
||||
connect(mDev_p, &QCanBusDevice::framesReceived, this, &SocketCan::framesReceived);
|
||||
connect(mDev_p, &QCanBusDevice::errorOccurred, this, &SerialBusConnection::errorReceived);
|
||||
connect(mDev_p, &QCanBusDevice::framesWritten, this, &SerialBusConnection::framesWritten);
|
||||
connect(mDev_p, &QCanBusDevice::framesReceived, this, &SerialBusConnection::framesReceived);
|
||||
|
||||
/* set configuration */
|
||||
/*if (p.useConfigurationEnabled) {
|
||||
@@ -107,7 +106,7 @@ void SocketCan::piSetBusSettings(int pBusIdx, CANBus bus)
|
||||
}
|
||||
|
||||
|
||||
bool SocketCan::piSendFrame(const CANFrame& pFrame)
|
||||
bool SerialBusConnection::piSendFrame(const CANFrame& pFrame)
|
||||
{
|
||||
/* sanity checks */
|
||||
if(0 != pFrame.bus || pFrame.len>8)
|
||||
@@ -131,16 +130,16 @@ bool SocketCan::piSendFrame(const CANFrame& pFrame)
|
||||
|
||||
|
||||
/* disconnect device */
|
||||
void SocketCan::disconnectDevice() {
|
||||
void SerialBusConnection::disconnectDevice() {
|
||||
if(mDev_p) {
|
||||
mDev_p->disconnectDevice();
|
||||
delete mDev_p;
|
||||
mDev_p = Q_NULLPTR;
|
||||
mDev_p = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SocketCan::errorReceived(QCanBusDevice::CanBusError error) const
|
||||
void SerialBusConnection::errorReceived(QCanBusDevice::CanBusError error) const
|
||||
{
|
||||
switch (error) {
|
||||
case QCanBusDevice::ReadError:
|
||||
@@ -155,13 +154,13 @@ void SocketCan::errorReceived(QCanBusDevice::CanBusError error) const
|
||||
}
|
||||
}
|
||||
|
||||
void SocketCan::framesWritten(qint64 count)
|
||||
void SerialBusConnection::framesWritten(qint64 count)
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
//qDebug() << "Number of frames written:" << count;
|
||||
}
|
||||
|
||||
void SocketCan::framesReceived()
|
||||
void SerialBusConnection::framesReceived()
|
||||
{
|
||||
uint64_t timeBasis = CANConManager::getInstance()->getTimeBasis();
|
||||
|
||||
@@ -211,7 +210,7 @@ void SocketCan::framesReceived()
|
||||
}
|
||||
|
||||
|
||||
void SocketCan::testConnection() {
|
||||
void SerialBusConnection::testConnection() {
|
||||
QCanBusDevice* dev_p = QCanBus::instance()->createDevice("socketcan", getPort());
|
||||
CANConStatus stats;
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
#ifndef SocketCan_H
|
||||
#define SocketCan_H
|
||||
#ifndef SERIALBUSCONNECTION_H
|
||||
#define SERIALBUSCONNECTION_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QCanBus>
|
||||
#include <QTimer>
|
||||
#include <qthread.h>
|
||||
|
||||
#include "canframemodel.h"
|
||||
#include "canconnection.h"
|
||||
#include "canconmanager.h"
|
||||
#include "canframemodel.h"
|
||||
|
||||
#include <QCanBusDevice>
|
||||
#include <QTimer>
|
||||
|
||||
class SocketCan : public CANConnection
|
||||
class SerialBusConnection : public CANConnection
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SocketCan(QString portName);
|
||||
virtual ~SocketCan();
|
||||
SerialBusConnection(QString portName);
|
||||
virtual ~SerialBusConnection();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -37,9 +33,9 @@ private slots:
|
||||
void testConnection();
|
||||
|
||||
protected:
|
||||
QCanBusDevice* mDev_p;
|
||||
QCanBusDevice *mDev_p = nullptr;
|
||||
QTimer mTimer;
|
||||
};
|
||||
|
||||
|
||||
#endif // SocketCan_H
|
||||
#endif // SERIALBUSCONNECTION_H
|
||||
@@ -276,7 +276,7 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
|
||||
|
||||
item = ui->MessagesTable->item(row, 0);
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
|
||||
item->setText(Utility::formatNumber(msgID));
|
||||
item->setText(Utility::formatCANID(msgID));
|
||||
|
||||
for(int i=1 ; i < ui->MessagesTable->columnCount(); i++)
|
||||
{
|
||||
@@ -486,7 +486,7 @@ void DBCMainEditor::refreshMessagesTable(const DBC_NODE *node)
|
||||
if (msg->sender == node)
|
||||
{
|
||||
//many of these are simplistic first versions just to test functionality.
|
||||
QTableWidgetItem *msgID = new QTableWidgetItem(Utility::formatNumber(msg->ID));
|
||||
QTableWidgetItem *msgID = new QTableWidgetItem(Utility::formatCANID(msg->ID));
|
||||
QTableWidgetItem *msgName = new QTableWidgetItem(msg->name);
|
||||
QTableWidgetItem *msgLen = new QTableWidgetItem(QString::number(msg->len));
|
||||
QTableWidgetItem *msgSignals = new QTableWidgetItem(QString::number(msg->sigHandler->getCount()));
|
||||
|
||||
@@ -248,7 +248,7 @@ void FramePlaybackWindow::refreshIDList()
|
||||
QHash<int, bool>::Iterator filterIter;
|
||||
for (filterIter = currentSeqItem->idFilters.begin(); filterIter != currentSeqItem->idFilters.end(); ++filterIter)
|
||||
{
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatNumber(filterIter.key()), ui->listID);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(filterIter.key()), ui->listID);
|
||||
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
||||
if (filterIter.value()) listItem->setCheckState(Qt::Checked);
|
||||
else listItem->setCheckState(Qt::Unchecked);
|
||||
|
||||
+4
-3
@@ -5,6 +5,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
#include "connections/canconmanager.h"
|
||||
#include "connections/connectionwindow.h"
|
||||
#include "utility.h"
|
||||
|
||||
/*
|
||||
@@ -352,7 +353,7 @@ void MainWindow::updateFilterList()
|
||||
for (filterIter = filters->begin(); filterIter != filters->end(); ++filterIter)
|
||||
{
|
||||
QListWidgetItem *thisItem = new QListWidgetItem();
|
||||
thisItem->setText(Utility::formatNumber(filterIter.key()));
|
||||
thisItem->setText(Utility::formatCANID(filterIter.key()));
|
||||
thisItem->setFlags(thisItem->flags() | Qt::ItemIsUserCheckable);
|
||||
if (filterIter.value()) thisItem->setCheckState(Qt::Checked);
|
||||
else thisItem->setCheckState(Qt::Unchecked);
|
||||
@@ -408,7 +409,7 @@ void MainWindow::tickGUIUpdate()
|
||||
framesPerSec = 0;
|
||||
|
||||
ui->lbNumFrames->setText(QString::number(model->rowCount()));
|
||||
if (ui->cbAutoScroll->isChecked()) ui->canFramesView->scrollToBottom();
|
||||
if (allowCapture && ui->cbAutoScroll->isChecked()) ui->canFramesView->scrollToBottom();
|
||||
ui->lbFPS->setText(QString::number(framesPerSec));
|
||||
if (rxFrames > 0)
|
||||
{
|
||||
@@ -631,7 +632,7 @@ Data Bytes: 88 10 00 13 BB 00 06 00
|
||||
CANFrame thisFrame = frames->at(c);
|
||||
QString builderString;
|
||||
builderString += tr("Time: ") + QString::number((thisFrame.timestamp / 1000000.0), 'f', 6);
|
||||
builderString += tr(" ID: ") + Utility::formatNumber(thisFrame.ID);
|
||||
builderString += tr(" ID: ") + Utility::formatCANID(thisFrame.ID, thisFrame.extended);
|
||||
if (thisFrame.extended) builderString += tr(" Ext ");
|
||||
else builderString += tr(" Std ");
|
||||
builderString += tr("Bus: ") + QString::number(thisFrame.bus);
|
||||
|
||||
+1
-1
@@ -22,7 +22,6 @@
|
||||
#include "mainsettingsdialog.h"
|
||||
#include "firmwareuploaderwindow.h"
|
||||
#include "re/discretestatewindow.h"
|
||||
#include "connections/connectionwindow.h"
|
||||
#include "scriptingwindow.h"
|
||||
#include "re/rangestatewindow.h"
|
||||
#include "dbc/dbcloadsavewindow.h"
|
||||
@@ -33,6 +32,7 @@
|
||||
#include "motorcontrollerconfigwindow.h"
|
||||
#include "signalviewerwindow.h"
|
||||
|
||||
class CANConnection;
|
||||
class ConnectionWindow;
|
||||
class ISOTP_InterpreterWindow;
|
||||
class ScriptingWindow;
|
||||
|
||||
@@ -121,7 +121,7 @@ void DiscreteStateWindow::updatedFrames(int numFrames)
|
||||
if (!idFilters.contains(thisFrame.ID))
|
||||
{
|
||||
idFilters.insert(thisFrame.ID, true);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatNumber(thisFrame.ID), ui->listID);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(thisFrame.ID, thisFrame.extended), ui->listID);
|
||||
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
||||
listItem->setCheckState(Qt::Checked); //default all filters to be set active
|
||||
}
|
||||
@@ -141,11 +141,12 @@ void DiscreteStateWindow::refreshFilterList()
|
||||
|
||||
for (int i = 0; i < modelFrames->length(); i++)
|
||||
{
|
||||
id = modelFrames->at(i).ID;
|
||||
CANFrame thisFrame = modelFrames->at(i);
|
||||
id = thisFrame.ID;
|
||||
if (!idFilters.contains(id))
|
||||
{
|
||||
idFilters.insert(id, true);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatNumber(id), ui->listID);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(id, thisFrame.extended), ui->listID);
|
||||
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
||||
listItem->setCheckState(Qt::Checked); //default all filters to be set active
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ void FlowViewWindow::updatedFrames(int numFrames)
|
||||
if (!foundID.contains(thisFrame.ID))
|
||||
{
|
||||
foundID.append(thisFrame.ID);
|
||||
/*QListWidgetItem* item =*/ new QListWidgetItem(Utility::formatNumber(thisFrame.ID), ui->listFrameID);
|
||||
/*QListWidgetItem* item =*/ new QListWidgetItem(Utility::formatCANID(thisFrame.ID, thisFrame.extended), ui->listFrameID);
|
||||
}
|
||||
|
||||
if (thisFrame.ID == refID)
|
||||
@@ -506,11 +506,12 @@ void FlowViewWindow::refreshIDList()
|
||||
int id;
|
||||
for (int i = 0; i < modelFrames->count(); i++)
|
||||
{
|
||||
id = modelFrames->at(i).ID;
|
||||
CANFrame thisFrame = modelFrames->at(i);
|
||||
id = thisFrame.ID;
|
||||
if (!foundID.contains(id))
|
||||
{
|
||||
foundID.append(id);
|
||||
/*QListWidgetItem* item = */ new QListWidgetItem(Utility::formatNumber(id), ui->listFrameID);
|
||||
/*QListWidgetItem* item = */ new QListWidgetItem(Utility::formatCANID(id, thisFrame.extended), ui->listFrameID);
|
||||
}
|
||||
}
|
||||
//default is to sort in ascending order
|
||||
|
||||
@@ -124,11 +124,12 @@ void FrameInfoWindow::updatedFrames(int numFrames)
|
||||
bool thisID = false;
|
||||
for (int x = modelFrames->count() - numFrames; x < modelFrames->count(); x++)
|
||||
{
|
||||
unsigned int id = modelFrames->at(x).ID;
|
||||
CANFrame thisFrame = modelFrames->at(x);
|
||||
unsigned int id = thisFrame.ID;
|
||||
if (!foundID.contains(id))
|
||||
{
|
||||
foundID.append(id);
|
||||
ui->listFrameID->addItem(Utility::formatNumber(id));
|
||||
ui->listFrameID->addItem(Utility::formatCANID(id, thisFrame.extended));
|
||||
}
|
||||
|
||||
if (currID == modelFrames->at(x).ID)
|
||||
@@ -394,11 +395,12 @@ void FrameInfoWindow::refreshIDList()
|
||||
int id;
|
||||
for (int i = 0; i < modelFrames->count(); i++)
|
||||
{
|
||||
id = (int)modelFrames->at(i).ID;
|
||||
CANFrame thisFrame = modelFrames->at(i);
|
||||
id = (int)thisFrame.ID;
|
||||
if (!foundID.contains(id))
|
||||
{
|
||||
foundID.append(id);
|
||||
ui->listFrameID->addItem(Utility::formatNumber(id));
|
||||
ui->listFrameID->addItem(Utility::formatCANID(id, thisFrame.extended));
|
||||
}
|
||||
}
|
||||
//default is to sort in ascending order
|
||||
|
||||
@@ -74,7 +74,7 @@ void FuzzingWindow::updatedFrames(int numFrames)
|
||||
foundIDs.append(id);
|
||||
selectedIDs.append(id);
|
||||
QListWidgetItem *thisItem = new QListWidgetItem();
|
||||
thisItem->setText(Utility::formatNumber(id));
|
||||
thisItem->setText(Utility::formatCANID(id, modelFrames->at(i).extended));
|
||||
thisItem->setFlags(thisItem->flags() | Qt::ItemIsUserCheckable);
|
||||
thisItem->setCheckState(Qt::Checked);
|
||||
ui->listID->addItem(thisItem);
|
||||
@@ -346,14 +346,15 @@ void FuzzingWindow::refreshIDList()
|
||||
|
||||
int id;
|
||||
for (int i = 0; i < modelFrames->count(); i++)
|
||||
{
|
||||
id = modelFrames->at(i).ID;
|
||||
{
|
||||
CANFrame thisFrame = modelFrames->at(i);
|
||||
id = thisFrame.ID;
|
||||
if (!foundIDs.contains(id))
|
||||
{
|
||||
foundIDs.append(id);
|
||||
selectedIDs.append(id);
|
||||
QListWidgetItem *thisItem = new QListWidgetItem();
|
||||
thisItem->setText(Utility::formatNumber(id));
|
||||
thisItem->setText(Utility::formatCANID(id, thisFrame.extended));
|
||||
thisItem->setFlags(thisItem->flags() | Qt::ItemIsUserCheckable);
|
||||
thisItem->setCheckState(Qt::Checked);
|
||||
ui->listID->addItem(thisItem);
|
||||
|
||||
@@ -231,7 +231,7 @@ void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE msg)
|
||||
{
|
||||
idFilters.insert(msg.ID, true);
|
||||
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatNumber(msg.ID), ui->listFilter);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(msg.ID, msg.extended), ui->listFilter);
|
||||
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
||||
listItem->setCheckState(Qt::Checked);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ void NewGraphDialog::setParams(GraphParams ¶ms)
|
||||
startBit = params.startBit;
|
||||
dataLen = params.numBits;
|
||||
ui->txtDataLen->setText(QString::number(dataLen));
|
||||
ui->txtID->setText(Utility::formatNumber(params.ID));
|
||||
ui->txtID->setText(Utility::formatCANID(params.ID));
|
||||
ui->txtName->setText(params.graphName);
|
||||
QPalette p = ui->colorSwatch->palette();
|
||||
p.setColor(QPalette::Button, params.color);
|
||||
@@ -211,7 +211,7 @@ void NewGraphDialog::copySignalToParamsUI()
|
||||
startBit = sig->startBit;
|
||||
ui->txtBias->setText(QString::number(sig->bias));
|
||||
ui->txtDataLen->setText(QString::number(sig->signalSize));
|
||||
ui->txtID->setText(Utility::formatNumber(msg->ID));
|
||||
ui->txtID->setText(Utility::formatCANID(msg->ID));
|
||||
ui->txtMask->setText("0xFFFFFFFF");
|
||||
ui->txtName->setText(sig->name);
|
||||
ui->txtScale->setText(QString::number(sig->factor));
|
||||
|
||||
@@ -138,7 +138,7 @@ void RangeStateWindow::updatedFrames(int numFrames)
|
||||
if (!idFilters.contains(thisFrame.ID))
|
||||
{
|
||||
idFilters.insert(thisFrame.ID, true);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatNumber(thisFrame.ID), ui->listFilter);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatCANID(thisFrame.ID, thisFrame.extended), ui->listFilter);
|
||||
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
||||
listItem->setCheckState(Qt::Checked); //default all filters to be set active
|
||||
}
|
||||
@@ -159,7 +159,9 @@ void RangeStateWindow::refreshFilterList()
|
||||
if (!idFilters.contains(id))
|
||||
{
|
||||
idFilters.insert(id, true);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatNumber(id), ui->listFilter);
|
||||
QListWidgetItem* listItem;
|
||||
if (id < 0x800) listItem = new QListWidgetItem(Utility::formatCANID(id, false), ui->listFilter);
|
||||
else listItem = new QListWidgetItem(Utility::formatCANID(id, true), ui->listFilter);
|
||||
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
||||
listItem->setCheckState(Qt::Checked); //default all filters to be set active
|
||||
}
|
||||
|
||||
@@ -96,6 +96,27 @@ public:
|
||||
else return formatHexNum(value);
|
||||
}
|
||||
|
||||
static QString formatCANID(uint64_t id, bool extended)
|
||||
{
|
||||
if (decimalMode) return QString::number(id, 10);
|
||||
|
||||
if (extended)
|
||||
{
|
||||
return "0x" + QString::number(id, 16).toUpper().rightJustified(8,'0');
|
||||
}
|
||||
else
|
||||
{
|
||||
id = id & 0x7FF;
|
||||
return "0x" + QString::number(id, 16).toUpper().rightJustified(3,'0');
|
||||
}
|
||||
}
|
||||
|
||||
static QString formatCANID(uint64_t id)
|
||||
{
|
||||
if (id < 0x800) return formatCANID(id, false);
|
||||
return formatCANID(id, true);
|
||||
}
|
||||
|
||||
static QString formatByteAsBinary(uint8_t value)
|
||||
{
|
||||
QString output;
|
||||
|
||||
Reference in New Issue
Block a user