Classes | Public Member Functions | Private Attributes | List of all members
uavcan_linux::SocketCanDriver Class Reference

#include <socketcan.hpp>

Inheritance diagram for uavcan_linux::SocketCanDriver:
Inheritance graph
[legend]

Classes

class  IfaceWrapper
 

Public Member Functions

int addIface (const std::string &iface_name)
 
SocketCanIfacegetIface (std::uint8_t iface_index) override
 
std::uint8_t getNumIfaces () const override
 
bool isIfaceDown (std::uint8_t iface_index) const
 
std::int16_t select (uavcan::CanSelectMasks &inout_masks, const uavcan::CanFrame *(&)[uavcan::MaxCanIfaces], uavcan::MonotonicTime blocking_deadline) override
 
 SocketCanDriver (const SystemClock &clock)
 
- Public Member Functions inherited from uavcan::ICanDriver
virtual const ICanIfacegetIface (uint8_t iface_index) const
 
virtual int16_t select (CanSelectMasks &inout_masks, const CanFrame *(&pending_tx)[MaxCanIfaces], MonotonicTime blocking_deadline)=0
 
virtual ~ICanDriver ()
 

Private Attributes

const SystemClockclock_
 
std::vector< std::unique_ptr< IfaceWrapper > > ifaces_
 

Detailed Description

Multiplexing container for multiple SocketCAN sockets. Uses ppoll() for multiplexing.

When an interface becomes down/disconnected while the node is running, the driver will silently exclude it from the IO loop and continue to run on the remaining interfaces. When all interfaces become down/disconnected, the driver will throw AllIfacesDownException from SocketCanDriver::select(). Whether a certain interface is down can be checked with SocketCanDriver::isIfaceDown().

Definition at line 618 of file socketcan.hpp.

Constructor & Destructor Documentation

◆ SocketCanDriver()

uavcan_linux::SocketCanDriver::SocketCanDriver ( const SystemClock clock)
inlineexplicit

Reference to the clock object shall remain valid.

Definition at line 652 of file socketcan.hpp.

Member Function Documentation

◆ addIface()

int uavcan_linux::SocketCanDriver::addIface ( const std::string &  iface_name)
inline

Adds one iface by name. Will fail if there are MaxIfaces ifaces registered already.

Parameters
iface_nameE.g. "can0", "vcan1"
Returns
Negative on error, interface index on success.
Exceptions
uavcan_linux::Exception.

Definition at line 765 of file socketcan.hpp.

◆ getIface()

SocketCanIface* uavcan_linux::SocketCanDriver::getIface ( std::uint8_t  iface_index)
inlineoverridevirtual

Returns an interface by index, or null pointer if the index is out of range.

Implements uavcan::ICanDriver.

Definition at line 752 of file socketcan.hpp.

◆ getNumIfaces()

std::uint8_t uavcan_linux::SocketCanDriver::getNumIfaces ( ) const
inlineoverridevirtual

Total number of available CAN interfaces. This value shall not change after initialization.

Implements uavcan::ICanDriver.

Definition at line 757 of file socketcan.hpp.

◆ isIfaceDown()

bool uavcan_linux::SocketCanDriver::isIfaceDown ( std::uint8_t  iface_index) const
inline

Returns false if the specified interface is functioning, true if it became unavailable.

Definition at line 798 of file socketcan.hpp.

◆ select()

std::int16_t uavcan_linux::SocketCanDriver::select ( uavcan::CanSelectMasks inout_masks,
const uavcan::CanFrame (&)[uavcan::MaxCanIfaces],
uavcan::MonotonicTime  blocking_deadline 
)
inlineoverride

This function may return before deadline expiration even if no requested IO operations become possible. This behavior makes implementation way simpler, and it is OK since libuavcan can properly handle such early returns. Also it can return more events than were originally requested by uavcan, which is also acceptable.

Definition at line 664 of file socketcan.hpp.

Member Data Documentation

◆ clock_

const SystemClock& uavcan_linux::SocketCanDriver::clock_
private

Definition at line 645 of file socketcan.hpp.

◆ ifaces_

std::vector<std::unique_ptr<IfaceWrapper> > uavcan_linux::SocketCanDriver::ifaces_
private

Definition at line 646 of file socketcan.hpp.


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


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:05