libuav original

Dependents:   UAVCAN UAVCAN_Subscriber

Embed: (wiki syntax)

« Back to documentation index

CanAcceptanceFilterConfigurator Class Reference

CanAcceptanceFilterConfigurator Class Reference

This class configures hardware acceptance filters (if this feature is present on the particular CAN driver) to preclude reception of irrelevant CAN frames on the hardware level. More...

#include <can_acceptance_filter_configurator.hpp>

Public Types

enum  AnonymousMessages
 

These arguments defines whether acceptance filter configuration has anonymous messages or not.

More...

Public Member Functions

 CanAcceptanceFilterConfigurator (INode &node, uint16_t filters_number=0)
int computeConfiguration (AnonymousMessages mode=AcceptAnonymousMessages)
 This method invokes loadInputConfiguration() and mergeConfigurations() consequently in order to comute optimal filter configurations for the current hardware.
int addFilterConfig (const CanFilterConfig &config)
 Add an additional filter configuration.
int applyConfiguration ()
 This method loads the configuration computed with mergeConfigurations() or explicitly added by addFilterConfig() to the CAN driver.
const MultisetConfigContainergetConfiguration () const
 Returns the configuration computed with mergeConfigurations() or added by addFilterConfig().

Detailed Description

This class configures hardware acceptance filters (if this feature is present on the particular CAN driver) to preclude reception of irrelevant CAN frames on the hardware level.

Configuration starts by creating an object of class CanAcceptanceFilterConfigurator on the stack. By means of computeConfiguration() method the class determines the number of available HW filters and the number of listeners. In case if custom configuration required, it is possible to add it through addFilterConfig(). Subsequently obtained configurations are then loaded into the CAN driver by calling the applyConfiguration() method. If the cumulative number of configurations obtained by computeConfiguration() and addFilterConfig() is higher than the number of available HW filters, configurations will be merged automatically in the most efficient way.

Note that if the application adds additional server or subscriber objects after the filters have been configured, the configuration procedure will have to be performed again.

The maximum number of CAN acceptance filters is predefined in uavcan/build_config.hpp through a constant MaxCanAcceptanceFilters. The algorithm doesn't allow to have higher number of HW filters configurations than defined by MaxCanAcceptanceFilters. You can change this value according to the number specified in your CAN driver datasheet.

Definition at line 38 of file can_acceptance_filter_configurator.hpp.


Member Enumeration Documentation

These arguments defines whether acceptance filter configuration has anonymous messages or not.

Definition at line 44 of file can_acceptance_filter_configurator.hpp.


Constructor & Destructor Documentation

CanAcceptanceFilterConfigurator ( INode node,
uint16_t  filters_number = 0 
) [explicit]
Parameters:
nodeLibuavcan node whose subscribers/servers/etc will be used to configure the filters.
filters_numberAllows to override the maximum number of hardware filters to use. If set to zero (which is default), the class will obtain the number of available filters from the CAN driver via ICanIface::getNumFilters().

Definition at line 101 of file can_acceptance_filter_configurator.hpp.


Member Function Documentation

int addFilterConfig ( const CanFilterConfig config )

Add an additional filter configuration.

This method must not be invoked after computeConfiguration().

Returns:
0 = success, negative for error.

Definition at line 227 of file uc_can_acceptance_filter_configurator.cpp.

int applyConfiguration ( void   )

This method loads the configuration computed with mergeConfigurations() or explicitly added by addFilterConfig() to the CAN driver.

Must be called after computeConfiguration() and addFilterConfig().

Returns:
0 = success, negative for error.

Definition at line 105 of file uc_can_acceptance_filter_configurator.cpp.

int computeConfiguration ( AnonymousMessages  mode = AcceptAnonymousMessages )

This method invokes loadInputConfiguration() and mergeConfigurations() consequently in order to comute optimal filter configurations for the current hardware.

It can only be invoked when all of the subscriber and server objects are initialized. If new subscriber or server objects are added later, the filters will have to be reconfigured again.

Parameters:
modeEither: AcceptAnonymousMessages - the filters will accept all anonymous messages (this is default) IgnoreAnonymousMessages - anonymous messages will be ignored
Returns:
0 = success, negative for error.

Definition at line 169 of file uc_can_acceptance_filter_configurator.cpp.

const MultisetConfigContainer& getConfiguration (  ) const

Returns the configuration computed with mergeConfigurations() or added by addFilterConfig().

If mergeConfigurations() or addFilterConfig() have not been called yet, an empty configuration will be returned.

Definition at line 138 of file can_acceptance_filter_configurator.hpp.