Skip to content

Commit

Permalink
Merge branch 'master' of github.com:collin80/SavvyCAN into QT6WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
collin80 committed Sep 5, 2024
2 parents 9ed478f + 2836977 commit 06bed25
Show file tree
Hide file tree
Showing 19 changed files with 535 additions and 215 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
chmod a+x linuxdeployqt-continuous-x86_64.AppImage
./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/SavvyCAN.desktop -appimage -extra-plugins=iconengines,platformthemes/libqgtk3.so,canbus
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: SavvyCAN-Linux_x64.AppImage
path: SavvyCAN-*x86_64.AppImage
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
cp /usr/local/share/qt/plugins/canbus/* SavvyCAN.app/Frameworks
macdeployqt SavvyCAN.app -dmg
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: SavvyCAN-macOS_x64.dmg
path: SavvyCAN.dmg
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
mkdir package/canbus
copy "${Env:Qt6_Dir}/plugins/canbus/*.*" package/canbus/
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: SavvyCAN-Windows_x64
path: package
Expand All @@ -135,7 +135,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4.1.7

- name: Display structure of downloaded files
run: zip -r SavvyCAN-Windows_x64_CIBuild.zip SavvyCAN-Windows_x64
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ of this program. It can load and save in several formats:
9. Vehicle Spy log files
10. CANDump / Kayak (Read only)
11. PCAN Viewer (Read Only)
12. Wireshark socketcan PCAP file (Read only)

## Dependencies

Expand All @@ -47,9 +48,9 @@ to download it separately.

This project requires 5.14.0 or higher because of a dependency on QtSerialBus and other new additions to Qt.

NOTE: As the code in this master branch sits, it will not properly compile with QT6.
However, there is a QT6WIP branch that should successfully compile. The QT6WIP branch may not
function entirely properly yet.
NOTE: As the code in this master branch sits, it does compile with QT6. Support for QT6 is approximately "beta" quality. Most all functions should work, please send issues if found.

It appears that the current binary build for MacOS requires at least MacOS 10.15

## Instructions for compiling:

Expand Down
9 changes: 8 additions & 1 deletion SavvyCAN.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#
#-------------------------------------------------

!versionAtLeast(QT_VERSION, 6.5.0) {
error("Current version of Qt ($${QT_VERSION}) is too old, this project requires Qt 6.5 or newer")
}

QT = core gui printsupport qml serialbus serialport widgets help network opengl dbus

CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
Expand Down Expand Up @@ -257,6 +261,10 @@ unix {
DISTFILES += SavvyCAN.desktop
}

windows {
RC_ICONS=icons/SavvyIcon.ico
}

examplefiles.files=examples
examplefiles.path = $$PREFIX/share/savvycan/examples
INSTALLS += examplefiles
Expand All @@ -270,4 +278,3 @@ helpfiles.path = $$PREFIX/bin/help
INSTALLS += helpfiles

INSTALLS += target

35 changes: 29 additions & 6 deletions bus_protocols/uds_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ UDS_HANDLER::~UDS_HANDLER()
delete isoHandler;
}

void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
UDS_MESSAGE UDS_HANDLER::tryISOtoUDS(ISOTP_MESSAGE msg, bool *result)
{
qDebug() << "UDS handler got ISOTP frame";
const unsigned char *data = reinterpret_cast<const unsigned char *>(msg.payload().constData());
int dataLen = msg.payload().length();
*result = true;
UDS_MESSAGE udsMsg;
udsMsg.bus = msg.bus;
udsMsg.setExtendedFrameFormat(msg.hasExtendedFrameFormat());
Expand All @@ -207,9 +207,17 @@ void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
{
udsMsg.service = data[1];
if (dataLen > 2) udsMsg.subFunc = data[2];
else return;
else
{
*result = false;
return udsMsg;
};
}
else return;
else
{
*result = false;
return udsMsg;
};
udsMsg.payload().remove(0, 2);
}
else
Expand All @@ -218,8 +226,23 @@ void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
if (dataLen > 1) udsMsg.subFunc = data[1];
udsMsg.payload().remove(0, 1);
}
emit newUDSMessage(udsMsg);
}
else
{
*result = false;
};
return udsMsg;
}

void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
{
qDebug() << "UDS handler got ISOTP frame";
UDS_MESSAGE udsMsg;

bool result;
udsMsg = tryISOtoUDS(msg, &result);

if (result) emit newUDSMessage(udsMsg);
}

void UDS_HANDLER::setFlowCtrl(bool state)
Expand Down Expand Up @@ -486,7 +509,7 @@ QString UDS_HANDLER::getDetailedMessageAnalysis(const UDS_MESSAGE &msg)
buildString.append(Utility::formatHexNum(data[i]) + " ");
}
break;
case UDS_SERVICES::WRITE_BY_ID:
case UDS_SERVICES::WRITE_BY_ID:
if (dataLen > 3)
{
int writeID = (data[1] * 256 + data[2]);
Expand Down
1 change: 1 addition & 0 deletions bus_protocols/uds_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class UDS_HANDLER : public QObject
QString getShortDesc(QVector<CODE_STRUCT> &codeVector, int code);
QString getLongDesc(QVector<CODE_STRUCT> &codeVector, int code);
QString getDetailedMessageAnalysis(const UDS_MESSAGE &msg);
UDS_MESSAGE tryISOtoUDS(ISOTP_MESSAGE msg, bool *result);

public slots:
void gotISOTPFrame(ISOTP_MESSAGE msg);
Expand Down
21 changes: 20 additions & 1 deletion connections/lawicel_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,26 @@ void LAWICELSerial::readSerialData()
{
qDebug() << "Got CR!";

buildFrame.setTimeStamp(QDateTime::currentMSecsSinceEpoch() * 1000l);
if (useSystemTime)
{
buildTimestamp = QDateTime::currentMSecsSinceEpoch() * 1000l;
}
else
{
//If total length is greater than command, header and data, timestamps must be enabled.
if (data.length() > (5 + mBuildLine.mid(4, 1).toInt() * 2 + 1))
{
//Four bytes after the end of the data bytes.
buildTimestamp = mBuildLine.mid(5 + mBuildLine.mid(4, 1).toInt() * 2, 4).toInt(nullptr, 16) * 1000l;
}
else
{
//Default to system time if timestamps are disabled.
buildTimestamp = QDateTime::currentMSecsSinceEpoch() * 1000l;
}
}
buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, buildTimestamp));

switch (mBuildLine[0].toLatin1())
{
case 't': //standard frame
Expand Down
1 change: 1 addition & 0 deletions connections/lawicel_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private slots:
QSerialPort *serial;
int framesRapid;
CANFrame buildFrame;
qint64 buildTimestamp;
bool can0Enabled;
bool can0ListenOnly;
bool canFd;
Expand Down
4 changes: 2 additions & 2 deletions dbc/dbc_classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ QString DBC_SIGNAL::makePrettyOutput(double floatVal, int64_t intVal, bool outpu
}
}
if (!foundVal) outputString += QString::number(intVal);
if (outputUnit) outputString += unitName;
if (outputUnit) outputString += " " + unitName;
}
else //otherwise display the actual number and unit (if it exists)
{
outputString += (isInteger ? QString::number(intVal) : QString::number(floatVal));
if (outputUnit) outputString += unitName;
if (outputUnit) outputString += " " + unitName;
}
return outputString;
}
Expand Down
43 changes: 43 additions & 0 deletions dbc/dbchandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,44 @@ bool DBCFile::parseSignalMultiplexValueLine(QString line)
return false;
}

bool DBCFile::parseSignalValueTypeLine(QString line)
{
QRegularExpression regex;
QRegularExpressionMatch match;
qDebug() << "Found a signal valtype line";
regex.setPattern("^SIG\\_VALTYPE\\_ *(\\d+) *([-\\w]+) *: *(\\d+);");
match = regex.match(line);

// captured 1 is the message id
// captured 2 is the signal name
// captured 3 is the valtype
if (!match.hasMatch()) { return false; }
uint32_t id = match.captured(1).toULong() & 0x1FFFFFFFUL;

DBC_MESSAGE *msg = messageHandler->findMsgByID(match.captured(1).toULong() & 0x1FFFFFFFUL);
if (msg == nullptr) { return false; }

DBC_SIGNAL *thisSignal = msg->sigHandler->findSignalByName(match.captured(2));
if (thisSignal == nullptr) { return false; }
int valType = match.captured(3).toInt();

switch (valType) {
case 1: {
thisSignal->valType = SP_FLOAT;
break;
}
case 2: {
thisSignal->valType = DP_FLOAT;
break;
}
default: {
return false;
}
}
return true;
}


bool DBCFile::parseValueLine(QString line)
{
QRegularExpression regex;
Expand Down Expand Up @@ -891,6 +929,11 @@ bool DBCFile::loadFile(QString fileName)
if (!parseSignalMultiplexValueLine(line)) numSigFaults++;
}

if (line.startsWith("SIG_VALTYPE_ ")) //defines a signal value type
{
if (!parseSignalValueTypeLine(line)) numSigFaults++;
}

if (line.startsWith("BU_:")) //line specifies the nodes on this canbus
{
qDebug() << "Found a BU line";
Expand Down
1 change: 1 addition & 0 deletions dbc/dbchandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class DBCFile: public QObject
bool parseSignalMultiplexValueLine(QString line);
DBC_MESSAGE* parseMessageLine(QString line);
bool parseValueLine(QString line);
bool parseSignalValueTypeLine(QString line);
bool parseAttributeLine(QString line);
bool parseDefaultAttrLine(QString line);
};
Expand Down
Loading

0 comments on commit 06bed25

Please sign in to comment.