libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::CAN Class Referenceabstract

CAN通信接口,定义标准CAN通信结构,支持不同类型的消息 (CAN communication interface that defines a standard CAN structure supporting different message types). More...

#include <can.hpp>

Inheritance diagram for LibXR::CAN:
Collaboration diagram for LibXR::CAN:

Public Types

enum class  Type : uint8_t { STANDARD = 0 , EXTENDED = 1 , REMOTE_STANDARD = 2 , REMOTE_EXTENDED = 3 }
 CAN 消息类型 (Enumeration of CAN message types). More...
 

Public Member Functions

 CAN (const char *name_tp="can", Topic::Domain *domain=nullptr)
 构造 CAN 对象,可指定主题名称和通信域 (Constructs a CAN object with an optional topic name and domain).
 
struct __attribute__ ((packed))
 经典 CAN 消息结构 (Structure representing a classic CAN message).
 
virtual ErrorCode AddMessage (const ClassicPack &pack)=0
 添加 CAN 消息到系统 (Adds a CAN message to the system).
 

Data Fields

 ClassicPack
 
Topic classic_tp_
 经典 CAN 消息的主题 (Topic for classic CAN messages).
 

Detailed Description

CAN通信接口,定义标准CAN通信结构,支持不同类型的消息 (CAN communication interface that defines a standard CAN structure supporting different message types).

Definition at line 13 of file can.hpp.

Member Enumeration Documentation

◆ Type

CAN 消息类型 (Enumeration of CAN message types).

Enumerator
STANDARD 

标准 CAN 消息 (Standard CAN message).

EXTENDED 

扩展 CAN 消息 (Extended CAN message).

REMOTE_STANDARD 

远程标准 CAN 消息 (Remote standard CAN message).

REMOTE_EXTENDED 

远程扩展 CAN 消息 (Remote extended CAN message).

Definition at line 19 of file can.hpp.

20 {
21 STANDARD = 0,
22 EXTENDED = 1,
23 REMOTE_STANDARD = 2,
25 };
@ EXTENDED
扩展 CAN 消息 (Extended CAN message).
@ REMOTE_EXTENDED
远程扩展 CAN 消息 (Remote extended CAN message).
@ STANDARD
标准 CAN 消息 (Standard CAN message).
@ REMOTE_STANDARD
远程标准 CAN 消息 (Remote standard CAN message).

Constructor & Destructor Documentation

◆ CAN()

LibXR::CAN::CAN ( const char name_tp = "can",
Topic::Domain domain = nullptr 
)
inline

构造 CAN 对象,可指定主题名称和通信域 (Constructs a CAN object with an optional topic name and domain).

Parameters
name_tpCAN 消息的主题名称 (Topic name for CAN messages).
domain可选的通信域 (Optional domain for message communication).

Definition at line 33 of file can.hpp.

34 : classic_tp_(name_tp, sizeof(ClassicPack), domain, false, true)
35 {
36 }
Topic classic_tp_
经典 CAN 消息的主题 (Topic for classic CAN messages).
Definition can.hpp:48
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

Member Function Documentation

◆ __attribute__()

struct LibXR::CAN::__attribute__ ( (packed )
inline

经典 CAN 消息结构 (Structure representing a classic CAN message).

< 消息 ID (Message ID).

< 消息类型 (Message type).

< 数据载荷,最大 8 字节 (Data payload, max 8 bytes).

Definition at line 33 of file can.hpp.

42 {
43 uint32_t id;
44 Type type;
45 uint8_t data[8];
46 } ClassicPack;
Type
CAN 消息类型 (Enumeration of CAN message types).
Definition can.hpp:20

◆ AddMessage()

virtual ErrorCode LibXR::CAN::AddMessage ( const ClassicPack &  pack)
pure virtual

添加 CAN 消息到系统 (Adds a CAN message to the system).

Parameters
pack经典 CAN 消息包 (The classic CAN message packet).
Returns
操作结果 (ErrorCode indicating success or failure).

Implemented in LibXR::STM32CAN, LibXR::STM32CANFD, and LibXR::FDCAN.

Field Documentation

◆ classic_tp_

Topic LibXR::CAN::classic_tp_

经典 CAN 消息的主题 (Topic for classic CAN messages).

Definition at line 48 of file can.hpp.

◆ ClassicPack

LibXR::CAN::ClassicPack

Definition at line 46 of file can.hpp.


The documentation for this class was generated from the following file: