mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Communication: Add missing CAN error types
This commit is contained in:
committed by
Kyle Schwarz
parent
a22791c9e0
commit
c5ba2d8d32
@@ -1,25 +0,0 @@
|
||||
#ifndef __CANERRORCOUNTMESSAGE_H_
|
||||
#define __CANERRORCOUNTMESSAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/message.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class CANErrorCountMessage : public Message {
|
||||
public:
|
||||
CANErrorCountMessage(uint8_t tec, uint8_t rec, bool busOffFlag)
|
||||
: Message(Message::Type::CANErrorCount), transmitErrorCount(tec), receiveErrorCount(rec), busOff(busOffFlag){}
|
||||
|
||||
Network network;
|
||||
uint8_t transmitErrorCount;
|
||||
uint8_t receiveErrorCount;
|
||||
bool busOff;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef __CANERRORMESSAGE_H_
|
||||
#define __CANERRORMESSAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/message.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
enum class CANErrorCode : uint8_t
|
||||
{
|
||||
NoError = 0,
|
||||
StuffError = 1,
|
||||
FormError = 2,
|
||||
AckError = 3,
|
||||
Bit1Error = 4,
|
||||
Bit0Error = 5,
|
||||
CRCError = 6,
|
||||
NoChange = 7
|
||||
};
|
||||
class CANErrorMessage : public Message {
|
||||
public:
|
||||
CANErrorMessage() : Message(Type::CANError) {}
|
||||
Network network;
|
||||
uint8_t transmitErrorCount;
|
||||
uint8_t receiveErrorCount;
|
||||
bool busOff;
|
||||
bool errorPassive;
|
||||
bool errorWarn;
|
||||
CANErrorCode dataErrorCode;
|
||||
CANErrorCode errorCode;
|
||||
};
|
||||
|
||||
using CANErrorCountMessage = CANErrorMessage;
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
Frame = 0,
|
||||
|
||||
CANErrorCount = 0x100,
|
||||
CANError = 0x100,
|
||||
|
||||
LINHeaderOnly = 0x200,
|
||||
LINBreak = 0x201,
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace icsneo {
|
||||
|
||||
typedef uint16_t icscm_bitfield;
|
||||
|
||||
#pragma pack(push,2)
|
||||
struct HardwareCANPacket {
|
||||
static std::shared_ptr<Message> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
static bool EncodeFromMessage(const CANMessage& message, std::vector<uint8_t>& bytestream, const device_eventhandler_t& report);
|
||||
@@ -50,6 +51,28 @@ struct HardwareCANPacket {
|
||||
uint64_t IsExtended : 1;
|
||||
} timestamp;
|
||||
};
|
||||
struct HardwareCANErrorPacket {
|
||||
uint8_t error_code;
|
||||
uint8_t brs_data_error_code;
|
||||
|
||||
uint16_t reserved;
|
||||
|
||||
uint16_t DLC : 4;
|
||||
uint16_t : 4;
|
||||
uint16_t ERROR_INDICATOR : 1;
|
||||
uint16_t : 7;
|
||||
|
||||
uint8_t flags;
|
||||
uint8_t REC;
|
||||
uint8_t TEC;
|
||||
|
||||
static bool GetErrorWarn(uint8_t flags) { return flags & 0b0000'0001; }
|
||||
static bool GetErrorPassive(uint8_t flags) { return flags & 0b0000'1000; }
|
||||
static bool GetBusOff(uint8_t flags) { return flags & 0b0010'0000; }
|
||||
};
|
||||
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "icsneo/communication/message/ethernetmessage.h"
|
||||
#include "icsneo/communication/message/flexray/flexraymessage.h"
|
||||
#include "icsneo/communication/message/iso9141message.h"
|
||||
#include "icsneo/communication/message/canerrorcountmessage.h"
|
||||
#include "icsneo/communication/message/canerrormessage.h"
|
||||
#include "icsneo/communication/message/ethphymessage.h"
|
||||
#include "icsneo/communication/message/i2cmessage.h"
|
||||
#include "icsneo/communication/message/a2bmessage.h"
|
||||
|
||||
Reference in New Issue
Block a user