From 4b1c1b3879aa348e63a61e65aa0b57ab7aefdbb0 Mon Sep 17 00:00:00 2001 From: Florian Mickler Date: Thu, 31 Oct 2024 15:57:58 +0100 Subject: [PATCH 1/2] unconditionally enable canfd this should be compatible with can; as long as your hw supports this -> maybe autodetect canfd? -> or add a checkbox to the configuration --- DataStreamCAN/datastream_can.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DataStreamCAN/datastream_can.cpp b/DataStreamCAN/datastream_can.cpp index 0d62764..45859dc 100644 --- a/DataStreamCAN/datastream_can.cpp +++ b/DataStreamCAN/datastream_can.cpp @@ -38,6 +38,7 @@ void DataStreamCAN::connectCanInterface() for (const ConnectDialog::ConfigurationItem& item : p.configurations) can_interface_->setConfigurationParameter(item.first, item.second); } + can_interface_->setConfigurationParameter(QCanBusDevice::CanFdKey, true); if (!can_interface_->connectDevice()) { From 5e7d3b9feb4133e695335feb2680d7440480707a Mon Sep 17 00:00:00 2001 From: Florian Mickler Date: Thu, 31 Oct 2024 15:58:13 +0100 Subject: [PATCH 2/2] fix frame id processing for extended can id's at least my dbc (-> generated with cantools from an autosar xml) did set the highest bit for can-ids that were bigger then 0x1FF. QCanBus Frame hasExtendedFrameFormat would return true for both cases. --- DataStreamCAN/datastream_can.cpp | 8 +++++++- PluginsCommonCAN/CanFrameProcessor.cpp | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/DataStreamCAN/datastream_can.cpp b/DataStreamCAN/datastream_can.cpp index 45859dc..5542bd5 100644 --- a/DataStreamCAN/datastream_can.cpp +++ b/DataStreamCAN/datastream_can.cpp @@ -118,8 +118,14 @@ void DataStreamCAN::pushSingleCycle() for (int i = 0; i < n_frames; i++) { auto frame = can_interface_->readFrame(); + auto id = frame.frameId(); double timestamp = frame.timeStamp().seconds() + frame.timeStamp().microSeconds() * 1e-6; - frame_processor_->ProcessCanFrame(frame.frameId(), (const uint8_t*)frame.payload().data(), 8, timestamp); + + //set bit 31 if extended, so that it is found in the dbc + if (id > 0x7FF) + id = id | (1<<31); + frame_processor_->ProcessCanFrame(id, (const uint8_t*)frame.payload().data(), frame.payload().length(), timestamp); + //qDebug() << tr("Processed Single Frame with id:%2 (length: %1)").arg(frame.payload().length()).arg(id); } } diff --git a/PluginsCommonCAN/CanFrameProcessor.cpp b/PluginsCommonCAN/CanFrameProcessor.cpp index 4186c64..e06b178 100644 --- a/PluginsCommonCAN/CanFrameProcessor.cpp +++ b/PluginsCommonCAN/CanFrameProcessor.cpp @@ -1,3 +1,4 @@ +#include #include "CanFrameProcessor.h" #include "N2kMsg/GenericFastPacket.h" @@ -91,6 +92,7 @@ bool CanFrameProcessor::ProcessCanFrameRaw(const uint32_t frame_id, const uint8_ } else { + //qDebug() << "Unknown FrameID!"; return false; } }