GKD.RoboCtrl
载入中...
搜索中...
未找到
can.h
浏览该文件的文档.
1
6
#pragma once
7
8
#include <cstdint>
9
#include <string_view>
10
#include <asio.hpp>
11
#include <linux/can.h>
12
13
#include "
base.hpp
"
14
#include "
core/async.hpp
"
15
#include "
core/logger.h
"
16
17
namespace
roboctrl::io{
18
19
using
can_id_type =
uint32_t
;
20
24
class
can
:
public
keyed_io_base
<std::uint32_t>,
public
logable
<can>{
25
public
:
29
struct
info_type
{
30
std::string_view can_name;
31
32
using
key_type = std::string_view;
33
using
owner_type
=
can
;
34
35
std::string_view key()
const
{
return
can_name;}
36
};
37
38
using
key_type = std::uint32_t;
39
43
can
(
const
info_type
& info);
44
45
~can
();
46
50
awaitable<void>
send
(
byte_span
data);
51
55
awaitable<void>
send
(can_id_type
id
,
byte_span
data);
56
60
awaitable<void>
task
();
61
62
std::string desc()
const
{
63
return
std::format(
"bare can({})"
,info_.can_name);
64
}
65
66
private
:
67
asio::posix::stream_descriptor stream_;
68
info_type info_;
69
std::array<std::byte,20> buffer_;
70
::can_frame
*cf_;
71
std::string can_name_;
72
};
73
}
async.hpp
异步任务上下文组件。
roboctrl::io::can
CAN 设备对象,支持根据 ID 分发回调。
Definition
can.h:24
roboctrl::io::can::task
awaitable< void > task()
接收循环任务。
Definition
can.cpp:74
roboctrl::io::can::send
awaitable< void > send(byte_span data)
发送裸帧。
Definition
can.cpp:88
roboctrl::io::keyed_io_base
带 key 的 IO 基类,根据键值派发数据。
Definition
base.hpp:120
roboctrl::log::logable
用于提供日志功能的辅助基类 通过CRTP模式实现,要求派生类实现desc()方法以提供描述信息,在继承时传入派生类自身类型作为模板参数。 继承这个类后,派生类可以方便地使用log_debug、log_i...
Definition
logger.h:178
base.hpp
IO的基础组件。
roboctrl::io::byte_span
std::span< std::byte > byte_span
byte span,实际上就是一个std::span<std::byte>;
Definition
base.hpp:42
logger.h
用于日志输出的组件。
roboctrl::async::awaitable
asio::awaitable< T > awaitable
协程任务类型。
Definition
async.hpp:42
roboctrl::io::can::info_type
CAN 初始化参数。
Definition
can.h:29
include
io
can.h
制作者
1.9.8