mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
LIN: Network support
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
#ifndef __LINMESSAGE_H_
|
||||
#define __LINMESSAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/message.h"
|
||||
#include "icsneo/communication/network.h"
|
||||
#include <vector>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
struct LINErrorFlags {
|
||||
bool ErrRxBreakOnly = false;
|
||||
bool ErrRxBreakSyncOnly = false;
|
||||
bool ErrTxRxMismatch = false;
|
||||
bool ErrRxBreakNotZero = false;
|
||||
bool ErrRxBreakTooShort = false;
|
||||
bool ErrRxSyncNot55 = false;
|
||||
bool ErrRxDataLenOver8 = false;
|
||||
bool ErrFrameSync = false;
|
||||
bool ErrFrameMessageID = false;
|
||||
bool ErrFrameResponderData = false;
|
||||
bool ErrChecksumMatch = false;
|
||||
};
|
||||
|
||||
struct LINStatusFlags {
|
||||
bool TxChecksumEnhanced = false;
|
||||
bool TxCommander = false;
|
||||
bool TxResponder = false;
|
||||
bool TxAborted = false;
|
||||
bool UpdateResponderOnce = false;
|
||||
bool HasUpdatedResponderOnce = false;
|
||||
bool BusRecovered = false;
|
||||
bool BreakOnly = false;
|
||||
};
|
||||
|
||||
class LINMessage : public Frame {
|
||||
public:
|
||||
static void calcChecksum(LINMessage& message);
|
||||
|
||||
enum class Type {
|
||||
NOT_SET,
|
||||
LIN_COMMANDER_MSG,
|
||||
LIN_HEADER_ONLY,
|
||||
LIN_BREAK_ONLY,
|
||||
LIN_SYNC_ONLY,
|
||||
LIN_UPDATE_RESPONDER,
|
||||
LIN_ERROR
|
||||
};
|
||||
|
||||
uint8_t ID = 0;
|
||||
uint8_t protectedID = 0;
|
||||
uint8_t checksum = 0;
|
||||
LINMessage::Type type = Type::NOT_SET;
|
||||
bool isEnhancedChecksum = false;
|
||||
bool isLINStd2x = true;
|
||||
LINErrorFlags errFlags;
|
||||
LINStatusFlags statusFlags;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -18,6 +18,9 @@ public:
|
||||
|
||||
CANErrorCount = 0x100,
|
||||
|
||||
LINHeaderOnly = 0x200,
|
||||
LINBreak = 0x201,
|
||||
|
||||
// Past 0x8000 are all for internal use only
|
||||
Invalid = 0x8000,
|
||||
RawMessage = 0x8001,
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#ifndef __LINPACKET_H__
|
||||
#define __LINPACKET_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/linmessage.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include "icsneo/communication/packetizer.h"
|
||||
#include "icsneo/communication/network.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
#pragma pack(push, 2)
|
||||
|
||||
struct HardwareLINPacket {
|
||||
static std::shared_ptr<Message> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
static bool EncodeFromMessage(LINMessage& message, std::vector<uint8_t>& bytestream, const device_eventhandler_t& report);
|
||||
struct {
|
||||
//CxLIN3
|
||||
uint16_t ErrRxOnlyBreak : 1;
|
||||
uint16_t ErrRxOnlyBreakSync : 1;
|
||||
uint16_t ID : 11;
|
||||
uint16_t NETWORKINDEX : 3;//DO NOT CLOBBER THIS
|
||||
|
||||
// CxLIN
|
||||
uint8_t LINByte9;
|
||||
uint8_t ErrTxRxMismatch : 1;
|
||||
uint8_t TxChkSumEnhanced : 1;
|
||||
uint8_t TXCommander : 1;
|
||||
uint8_t TXResponder : 1;
|
||||
uint8_t ErrRxBreakNotZero : 1;
|
||||
uint8_t ErrRxBreakTooShort : 1;
|
||||
uint8_t ErrRxSyncNot55 : 1;
|
||||
uint8_t ErrRxDataGreater8 : 1;
|
||||
|
||||
// CxLIN2
|
||||
uint16_t len : 4;
|
||||
uint16_t ExtendedNetworkIndexBit2 : 1;//DO NOT CLOBBER THIS
|
||||
uint16_t UpdateResponderOnce : 1;
|
||||
uint16_t HasUpdatedResponderOnce : 1;
|
||||
uint16_t ExtendedNetworkIndexBit : 1;//DO NOT CLOBBER THIS
|
||||
uint16_t BusRecovered : 1;
|
||||
uint16_t SyncFerr : 1; //Framing error in sync byte
|
||||
uint16_t MidFerr : 1; // Framing error in message id
|
||||
uint16_t ResponderByteFerr : 1; //Framing error in one of our responder bytes.
|
||||
uint16_t TxAborted : 1;//!< This transmit was aborted.
|
||||
uint16_t BreakOnly : 1;
|
||||
uint16_t : 2;
|
||||
} CoreMiniBitsLIN;
|
||||
|
||||
uint8_t data[8];
|
||||
|
||||
uint16_t stats; //CxTRB0STAT
|
||||
uint64_t timestamp; //Large timestamp
|
||||
//CoreMiniMsgExtendedHdr
|
||||
uint16_t networkID;
|
||||
uint16_t length;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
} //namespace libicsneo
|
||||
#endif //_cplusplus
|
||||
#endif
|
||||
Reference in New Issue
Block a user