Skip to content

Commit

Permalink
add acceptance filter configuration helpers
Browse files Browse the repository at this point in the history
Adds helper API functions for configuring CAN controller hardware
acceptance filters.
  • Loading branch information
coderkalyan committed Nov 11, 2021
1 parent 5bf4c3c commit 7d2d582
Show file tree
Hide file tree
Showing 3 changed files with 245 additions and 122 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,29 @@ else
}
```

A simple API for generating CAN hardware acceptance filter configurations is also provided.
Acceptance filters are generated in an extended 29-bit ID + mask scheme and can be used to minimize the number of irrelevant transfers processed in software.

```c
// Generate an acceptance filter to receive only uavcan.node.Heartbeat.1.0 messages (fixed port ID 7509):
CanardAcceptanceFilterConfig heartbeat_config = canardMakeAcceptanceFilterConfigForSubject(7509);
// And to receive only uavcan.register.Access.1.0 services (fixed port ID 384):
CanardAcceptanceFilterConfig register_access_config = canardMakeAcceptanceFilterConfigForService(384, ins.node_id);

// You can also combine the two filter configurations into one (may also accept in other messages).
// This allows consolidating a large set of configurations to fit the number of hardware filters.
// For more information on the optimal subset of configurations to consolidate to minimize wasted CPU,
// see the UAVCAN specification.
CanardAcceptanceFilterConfig combined_config = canardConsolidateAcceptanceFilterConfigs(&heartbeat_config, &register_access_config);
configureHardwareFilters(combined_config.extended_can_id, combined_config.extended_mask);
```
Full API specification is available in the documentation.
If you find the examples to be unclear or incorrect, please, open a ticket.
## Revisions
### v2.0

- Dedicated transmission queues per redundant CAN interface with depth limits.
The application is now expected to instantiate `CanardTxQueue` (or several in case of redundant transport) manually.
Expand All @@ -225,6 +244,8 @@ else
- Support build configuration headers via `CANARD_CONFIG_HEADER`.
- Add API for generating CAN hardware acceptance filter configurations
### v1.1
- Add new API function `canardRxAccept2()`, deprecate `canardRxAccept()`.
Expand Down
Loading

0 comments on commit 7d2d582

Please sign in to comment.