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