Changes to hopefully handle error frames better over the socketcan
interface
This commit is contained in:
+23
-2
@@ -311,6 +311,8 @@ void CANFrameModel::recalcOverwrite()
|
||||
uint64_t idAugmented; //id in lower 29 bits, bus number shifted up 29 bits
|
||||
foreach(CANFrame frame, frames)
|
||||
{
|
||||
if (frame.frameType() != frame.DataFrame) continue;
|
||||
|
||||
idAugmented = frame.frameId();
|
||||
idAugmented = idAugmented + (frame.bus << 29ull);
|
||||
if (!overWriteFrames.contains(idAugmented))
|
||||
@@ -445,7 +447,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
tempString.append(QString::number(thisFrame.frameId() & 0x7));
|
||||
return tempString;
|
||||
}
|
||||
if (thisFrame.frameType() != QCanBusFrame::RemoteRequestFrame) {
|
||||
if (thisFrame.frameType() == QCanBusFrame::DataFrame) {
|
||||
if (dataLen < 0) dataLen = 0;
|
||||
//if (dLen > 8) dLen = 8;
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
@@ -457,6 +459,10 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
tempString.append(QString::fromUtf8(&byt, 1));
|
||||
}
|
||||
}
|
||||
if (thisFrame.frameType() == QCanBusFrame::ErrorFrame)
|
||||
{
|
||||
tempString = "ERROR";
|
||||
}
|
||||
return tempString;
|
||||
case Column::Data:
|
||||
if (dataLen < 0) dataLen = 0;
|
||||
@@ -470,8 +476,23 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
else tempString.append(QString::number(data[i], 10));
|
||||
tempString.append(" ");
|
||||
}
|
||||
if (thisFrame.frameType() == thisFrame.ErrorFrame)
|
||||
{
|
||||
if (thisFrame.error() & thisFrame.TransmissionTimeoutError) tempString.append("\nTX Timeout");
|
||||
if (thisFrame.error() & thisFrame.LostArbitrationError) tempString.append("\nLost Arbitration");
|
||||
if (thisFrame.error() & thisFrame.ControllerError) tempString.append("\nController Error");
|
||||
if (thisFrame.error() & thisFrame.ProtocolViolationError) tempString.append("\nProtocol Violation");
|
||||
if (thisFrame.error() & thisFrame.TransceiverError) tempString.append("\nTransceiver Error");
|
||||
if (thisFrame.error() & thisFrame.MissingAcknowledgmentError) tempString.append("\nMissing ACK");
|
||||
if (thisFrame.error() & thisFrame.BusOffError) tempString.append("\nBus OFF");
|
||||
if (thisFrame.error() & thisFrame.BusError) tempString.append("\nBus ERR");
|
||||
if (thisFrame.error() & thisFrame.ControllerRestartError) tempString.append("\nController restart err");
|
||||
if (thisFrame.error() & thisFrame.UnknownError) tempString.append("\nUnknown error type");
|
||||
}
|
||||
//TODO: technically the actual returned bytes for an error frame encode some more info. Not interpreting it yet.
|
||||
|
||||
//now, if we're supposed to interpret the data and the DBC handler is loaded then use it
|
||||
if (dbcHandler != nullptr && interpretFrames)
|
||||
if ( (dbcHandler != nullptr) && interpretFrames && (thisFrame.frameType() == thisFrame.DataFrame) )
|
||||
{
|
||||
DBC_MESSAGE *msg = dbcHandler->findMessage(thisFrame);
|
||||
if (msg != nullptr)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef CONFIG
|
||||
#define CONFIG
|
||||
|
||||
#define VERSION 200
|
||||
#define VERSION 201
|
||||
|
||||
//try to keep this in sync.
|
||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||
|
||||
@@ -184,54 +184,21 @@ void SerialBusConnection::framesReceived()
|
||||
if(frame_p) {
|
||||
frame_p->setPayload(recFrame.payload());
|
||||
frame_p->bus = 0;
|
||||
|
||||
if (recFrame.frameType() == QCanBusFrame::ErrorFrame) {
|
||||
// Constants defined in include/uapi/linux/can/error.h
|
||||
//since the whole program uses QCanBusFrame now we can just grab errors directly out of the proper place from now on
|
||||
/*
|
||||
switch (recFrame.error()) {
|
||||
case QCanBusFrame::TransmissionTimeoutError:
|
||||
frame_p->setFrameId(0x20000001);
|
||||
break;
|
||||
case QCanBusFrame::LostArbitrationError:
|
||||
frame_p->ID = 0x20000002;
|
||||
break;
|
||||
case QCanBusFrame::ControllerError:
|
||||
frame_p->ID = 0x20000004;
|
||||
break;
|
||||
case QCanBusFrame::ProtocolViolationError:
|
||||
frame_p->ID = 0x20000008;
|
||||
break;
|
||||
case QCanBusFrame::TransceiverError:
|
||||
frame_p->ID = 0x20000010;
|
||||
break;
|
||||
case QCanBusFrame::MissingAcknowledgmentError:
|
||||
frame_p->ID = 0x20000020;
|
||||
break;
|
||||
case QCanBusFrame::BusOffError:
|
||||
frame_p->ID = 0x20000040;
|
||||
break;
|
||||
case QCanBusFrame::BusError:
|
||||
frame_p->ID = 0x20000080;
|
||||
break;
|
||||
case QCanBusFrame::ControllerRestartError:
|
||||
frame_p->ID = 0x20000100;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (recFrame.frameType() == recFrame.ErrorFrame)
|
||||
{
|
||||
frame_p->setExtendedFrameFormat(recFrame.hasExtendedFrameFormat());
|
||||
frame_p->setFrameId(recFrame.frameId() + 0x20000000ull);
|
||||
}
|
||||
frame_p->extended = true;
|
||||
*/
|
||||
} else {
|
||||
else
|
||||
{
|
||||
frame_p->setExtendedFrameFormat(recFrame.hasExtendedFrameFormat());
|
||||
frame_p->setFrameId(recFrame.frameId());
|
||||
}
|
||||
frame_p->setTimeStamp(recFrame.timeStamp());
|
||||
frame_p->setFrameType(recFrame.frameType());
|
||||
frame_p->setError(recFrame.error());
|
||||
frame_p->isReceived = true;
|
||||
}
|
||||
|
||||
frame_p->isReceived = true;
|
||||
if (useSystemTime) {
|
||||
frame_p->setTimeStamp(QCanBusFrame::TimeStamp(0, QDateTime::currentMSecsSinceEpoch() * 1000ul));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user