#cyphal #uavcan #uav #can

no-std bin+lib canadensis_filter_config

Cyphal 自动接收过滤器配置

4 个版本

0.2.2 2022年10月18日
0.2.1 2022年4月12日
0.2.0 2021年10月31日
0.1.0 2021年7月11日

#2194嵌入式开发

Download history 16/week @ 2024-03-24 36/week @ 2024-03-31 13/week @ 2024-04-07 32/week @ 2024-04-14 22/week @ 2024-04-21 6/week @ 2024-04-28 8/week @ 2024-05-05 8/week @ 2024-05-12 12/week @ 2024-05-19 5/week @ 2024-05-26 10/week @ 2024-06-02 11/week @ 2024-06-09 17/week @ 2024-06-16 22/week @ 2024-06-23 3/week @ 2024-06-30 7/week @ 2024-07-07

每月 51 次下载
5 个crate中(4 个直接) 使用

MIT/Apache

17KB
327

Cyphal 接受过滤器配置

该库实现了Cyphal规范第4.2.4.4节中描述的自动硬件接受过滤器配置。

为了减少处理消息所花费的CPU时间,Cyphal设备可以使用硬件接受过滤器来忽略它不感兴趣的消息。当应用程序感兴趣的消息ID数量超过硬件支持的过滤器数量时,该库可以找到一组近似最优的过滤器,这些过滤器接受所有感兴趣的消息ID和尽可能少的不感兴趣的消息ID。

基本操作

  1. 根据应用程序想要接收的主题、请求和响应,找到感兴趣的消息ID集合
  2. 对于每个感兴趣的消息ID,创建一个与该ID完全匹配的过滤器。将这些过滤器优化到硬件支持的过滤器数量
use canadensis_filter_config::{optimize, Filter};

let interesting_message_ids = [0x107d552a, 0x11733775, 0x136b957b, 0x126bbdaa, 0x1073373b];
let mut ideal_filters = [
    Filter::exact_match(interesting_message_ids[0]),
    Filter::exact_match(interesting_message_ids[1]),
    Filter::exact_match(interesting_message_ids[2]),
    Filter::exact_match(interesting_message_ids[3]),
    Filter::exact_match(interesting_message_ids[4]),
];
// Using an imaginary CAN peripheral that supports only 2 receive filters
let max_hardware_filters = 2;
let optimized_filters = optimize(&mut ideal_filters, max_hardware_filters);
assert_eq!(optimized_filters.len(), 2);

// Each interesting message ID will be accepted by at least one of the optimized filters
for &id in interesting_message_ids.iter() {
    assert!(optimized_filters.iter().any(|filter| filter.accepts(id)));
}
  1. 将生成的过滤器应用于CAN硬件

无运行时依赖