libxr
1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
can.hpp
1
#pragma once
2
3
#include "libxr.hpp"
4
#include "message.hpp"
5
6
namespace
LibXR
7
{
8
13
class
CAN
14
{
15
public
:
19
enum class
Type
:
uint8_t
20
{
21
STANDARD
= 0,
22
EXTENDED
= 1,
23
REMOTE_STANDARD
= 2,
24
REMOTE_EXTENDED
= 3
25
};
26
33
CAN
(
const
char
*
name_tp
=
"can"
,
Topic::Domain
*
domain
=
nullptr
)
34
:
classic_tp_
(
name_tp
,
sizeof
(ClassicPack),
domain
,
false
,
true
)
35
{
36
}
37
41
typedef
struct
__attribute__
((
packed
))
42
{
43
uint32_t
id;
44
Type
type;
45
uint8_t
data[8];
46
} ClassicPack;
47
48
Topic
classic_tp_
;
49
55
virtual
ErrorCode
AddMessage
(
const
ClassicPack &pack) = 0;
56
};
57
63
class
FDCAN
:
public
CAN
64
{
65
public
:
73
FDCAN
(
const
char
*
name_tp
=
"can"
,
const
char
*
name_fd_tp
=
"fdcan"
,
74
Topic::Domain
*
domain
=
nullptr
)
75
:
CAN
(
name_tp
,
domain
),
fd_tp_
(
name_fd_tp
,
sizeof
(FDPack),
domain
,
false
,
false
)
76
{
77
}
78
82
typedef
struct
__attribute__
((
packed
))
83
{
84
uint32_t
id;
85
Type
type;
86
uint8_t
len
;
87
uint8_t
data[64];
88
} FDPack;
89
90
using
CAN::AddMessage
;
91
97
virtual
ErrorCode
AddMessage
(
const
FDPack &pack) = 0;
98
99
Topic
fd_tp_
;
100
};
101
102
}
// namespace LibXR
LibXR::CAN
CAN通信接口,定义标准CAN通信结构,支持不同类型的消息 (CAN communication interface that defines a standard CAN structure supp...
Definition
can.hpp:14
LibXR::CAN::Type
Type
CAN 消息类型 (Enumeration of CAN message types).
Definition
can.hpp:20
LibXR::CAN::Type::EXTENDED
@ EXTENDED
扩展 CAN 消息 (Extended CAN message).
LibXR::CAN::Type::REMOTE_EXTENDED
@ REMOTE_EXTENDED
远程扩展 CAN 消息 (Remote extended CAN message).
LibXR::CAN::Type::STANDARD
@ STANDARD
标准 CAN 消息 (Standard CAN message).
LibXR::CAN::Type::REMOTE_STANDARD
@ REMOTE_STANDARD
远程标准 CAN 消息 (Remote standard CAN message).
LibXR::CAN::AddMessage
virtual ErrorCode AddMessage(const ClassicPack &pack)=0
添加 CAN 消息到系统 (Adds a CAN message to the system).
LibXR::CAN::__attribute__
struct __attribute__((packed))
经典 CAN 消息结构 (Structure representing a classic CAN message).
Definition
can.hpp:41
LibXR::CAN::classic_tp_
Topic classic_tp_
经典 CAN 消息的主题 (Topic for classic CAN messages).
Definition
can.hpp:48
LibXR::FDCAN
FDCAN 通信接口,扩展 CAN 功能,支持灵活数据速率(FD)CAN 消息 (FDCAN communication interface that extends CAN functionality...
Definition
can.hpp:64
LibXR::FDCAN::__attribute__
struct __attribute__((packed))
FD CAN 消息结构 (Structure representing an FD CAN message).
Definition
can.hpp:82
LibXR::FDCAN::fd_tp_
Topic fd_tp_
FD CAN 消息的主题 (Topic for FD CAN messages).
Definition
can.hpp:99
LibXR::FDCAN::AddMessage
virtual ErrorCode AddMessage(const FDPack &pack)=0
添加 FD CAN 消息到系统 (Adds an FD CAN message to the system).
LibXR::Topic::Domain
主题域(Domain)管理器,用于组织多个主题。Domain manager for organizing multiple topics.
Definition
message.hpp:133
LibXR::Topic
主题(Topic)管理类 / Topic management class
Definition
message.hpp:29
LibXR
LibXR Color Control Library / LibXR终端颜色控制库
Definition
linux_flash.hpp:15
LibXR::min
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值
Definition
libxr_def.hpp:161
src
driver
can.hpp
Generated by
1.9.8