Add dlcOnWire to CAN
parent
0f703f494f
commit
12451def11
|
|
@ -40,6 +40,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
|
|
||||||
// DLC
|
// DLC
|
||||||
uint8_t length = data->dlc.DLC;
|
uint8_t length = data->dlc.DLC;
|
||||||
|
msg->dlcOnWire = length; // This will hold the real DLC on wire 0x0 - 0xF
|
||||||
if(data->header.EDL && data->timestamp.IsExtended) { // CAN FD
|
if(data->header.EDL && data->timestamp.IsExtended) { // CAN FD
|
||||||
msg->isCANFD = true;
|
msg->isCANFD = true;
|
||||||
msg->baudrateSwitch = data->header.BRS; // CAN FD Baudrate Switch
|
msg->baudrateSwitch = data->header.BRS; // CAN FD Baudrate Switch
|
||||||
|
|
@ -70,6 +71,10 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(length > 8) { // This is a standard CAN frame with a length of more than 8
|
||||||
|
// Yes, this is possible. On the wire, the length field is a nibble, and we do want to return an accurate value
|
||||||
|
// We don't want to overread our buffer, though, so make sure we cap the length
|
||||||
|
length = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ namespace icsneo {
|
||||||
class CANMessage : public Message {
|
class CANMessage : public Message {
|
||||||
public:
|
public:
|
||||||
uint32_t arbid;
|
uint32_t arbid;
|
||||||
|
uint8_t dlcOnWire;
|
||||||
bool isRemote = false;
|
bool isRemote = false;
|
||||||
bool isExtended = false;
|
bool isExtended = false;
|
||||||
bool isCANFD = false;
|
bool isCANFD = false;
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,8 @@ typedef struct {
|
||||||
uint32_t arbid;
|
uint32_t arbid;
|
||||||
uint16_t netid;
|
uint16_t netid;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
char reserved[9];
|
uint8_t dlcOnWire;
|
||||||
|
char reserved[8];
|
||||||
} neomessage_can_t;
|
} neomessage_can_t;
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr<Message> message) {
|
||||||
neomessage_can_t& can = *(neomessage_can_t*)&neomsg;
|
neomessage_can_t& can = *(neomessage_can_t*)&neomsg;
|
||||||
auto canmsg = std::static_pointer_cast<CANMessage>(message);
|
auto canmsg = std::static_pointer_cast<CANMessage>(message);
|
||||||
can.arbid = canmsg->arbid;
|
can.arbid = canmsg->arbid;
|
||||||
|
can.dlcOnWire = canmsg->dlcOnWire;
|
||||||
can.status.extendedFrame = canmsg->isExtended;
|
can.status.extendedFrame = canmsg->isExtended;
|
||||||
can.status.remoteFrame = canmsg->isRemote;
|
can.status.remoteFrame = canmsg->isRemote;
|
||||||
can.status.canfdRTR = canmsg->isRemote;
|
can.status.canfdRTR = canmsg->isRemote;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue