Veethree D7 SDK
Loading...
Searching...
No Matches
vsdk::comms::can_adapter_interface Class Referenceabstract

Detailed Description

Class for abstracting lower level interactions with the CAN interfaces. A concrete implementation may "talk" to the underlying OS to query the current state of a CAN interface, request a configuration change for a CAN interface or list all available CAN interfaces.

#include <can_adapter_interface.h>

Public Member Functions

 can_adapter_interface (std::string_view if_name)
 Constructor that uses the device interface name.
 can_adapter_interface ()=default
 Default constructor. Allows calling can_adapter_interface::list_adapters without requiring an interface name.
std::string if_name () const
 The name of the interface that this instance refers to.
virtual can_type type ()=0
 The type of the interface: physical or virtual.
virtual void get_config (can_parameters &param)=0
 Get the config for the interface.
virtual bool set_config (const can_parameters &param)=0
 Modify the config for the interface.
virtual bool restart_adapter ()=0
 Restart the CAN interface.
virtual std::vector< std::tuple< std::string, can_type > > list_adapters ()=0
 List all available CAN adapters' names.

Detailed Description

Class for abstracting lower level interactions with the CAN interfaces. A concrete implementation may "talk" to the underlying OS to query the current state of a CAN interface, request a configuration change for a CAN interface or list all available CAN interfaces.

Constructor & Destructor Documentation

◆ can_adapter_interface()

vsdk::comms::can_adapter_interface::can_adapter_interface ( std::string_view if_name)
inlineexplicit

Constructor that uses the device interface name.

Parameters
if_nameThe name of the interface (as reported by ip link show type can).

Member Function Documentation

◆ get_config()

virtual void vsdk::comms::can_adapter_interface::get_config ( can_parameters & param)
pure virtual

Get the config for the interface.

Parameters
[out]paramThe structure containing the current configuration for this interface.
Exceptions
std::system_errorif the interface does not exist on the system or problem occurred within the OS

◆ list_adapters()

virtual std::vector< std::tuple< std::string, can_type > > vsdk::comms::can_adapter_interface::list_adapters ( )
pure virtual

List all available CAN adapters' names.

Note
: This method is not static to allow concrete implementations to override the way the interfaces are retrieved. Except for mock implementations, it should not use the instance's if_name() at all.

◆ restart_adapter()

virtual bool vsdk::comms::can_adapter_interface::restart_adapter ( )
pure virtual

Restart the CAN interface.

Returns
true if successfully restarted, false otherwise.

◆ set_config()

virtual bool vsdk::comms::can_adapter_interface::set_config ( const can_parameters & param)
pure virtual

Modify the config for the interface.

Parameters
[in]paramThe structure containing the configurations to modify.
Returns
true if configuration was modified successfully, false otherwise
Note
: Only set the fields that should be modified. Fields which aren't set won't be affected.

◆ type()

virtual can_type vsdk::comms::can_adapter_interface::type ( )
pure virtual

The type of the interface: physical or virtual.

Returns
can_type

The documentation for this class was generated from the following file: