MIRA
Protected Member Functions | List of all members
CANDriverInterface Class Reference

A common interface to the CAN bus. More...

#include <can/CANDriverInterface.h>

Inheritance diagram for CANDriverInterface:
Inheritance graph
[legend]

Public Member Functions

Construtor and destructor
 CANDriverInterface (const std::string &driver)
 Construct a new CAN interface. More...
 
virtual ~CANDriverInterface ()
 The destructor. More...
 
Operations on the CAN interface
void open (const std::string &deviceName, CANBaudRate baudRate=CAN_BAUDRATE_250K)
 Open the CAN interface. More...
 
void close ()
 Close the CAN interface. More...
 
uint8 getBusLoad () const
 Returns the current load of the CAN bus. More...
 
General methods
CANDriverPtr getDriver () const
 Returns a pointer to CAN driver. More...
 
Overloaded methods from CANInterface
virtual void sendMessage (const CANMessage &pMsg)
 Send a new message over the CAN bus. More...
 
Outgoing messages
uint32 addMessageSentListener (CANMessageCallback pFunc, uint32 pMask=0x00000000, uint32 pFilter=0xFFFFFFFF)
 Register a new message listener for outgoing messages. More...
 
void removeMessageSentListener (uint32 pFuncID)
 Unregister an outgoing message listener. More...
 
Incoming messages
uint32 addMessageRecvListener (CANMessageCallback pFunc, uint32 pMask=0x00000000, uint32 pFilter=0xFFFFFFFF)
 Register a new CAN message listener. More...
 
void removeMessageRecvListener (uint32 pFuncID)
 Unregister a message listener. More...
 
Interface to the PDO listener
uint32 addPDOListener (PDOCallback pFunc, uint32 pPDO)
 Add a callback for a specific PDO. More...
 
void removePDOListener (uint32 pFuncID)
 Remove a PDO callback. More...
 

Protected Member Functions

void onMessageSend (const CANMessage &message, const Time &time)
 
void onMessageReceived (const CANMessage &message, const Time &time)
 

Detailed Description

A common interface to the CAN bus.

This class is able to handle different CAN drivers.

Constructor & Destructor Documentation

◆ CANDriverInterface()

CANDriverInterface ( const std::string &  driver)

Construct a new CAN interface.

Parameters
[in]driverThe requested driver type.

◆ ~CANDriverInterface()

virtual ~CANDriverInterface ( )
virtual

The destructor.

Member Function Documentation

◆ open()

void open ( const std::string &  deviceName,
CANBaudRate  baudRate = CAN_BAUDRATE_250K 
)

Open the CAN interface.

Parameters
[in]deviceNameThe device name.
[in]baudRateThe baud rate.

◆ close()

void close ( )

Close the CAN interface.

◆ getBusLoad()

uint8 getBusLoad ( ) const

Returns the current load of the CAN bus.

The computation of the bus load is based on the number of received bits in a certain time interval. The current implementation uses a time interval of about one second.

Returns
The approximate bus load in percent.

◆ getDriver()

CANDriverPtr getDriver ( ) const
inline

Returns a pointer to CAN driver.

◆ sendMessage()

virtual void sendMessage ( const CANMessage msg)
virtual

Send a new message over the CAN bus.

Parameters
[in]msgThe CAN message.
Returns
Error code.

Implements CANInterface.

◆ addMessageSentListener()

uint32 addMessageSentListener ( CANMessageCallback  pFunc,
uint32  pMask = 0x00000000,
uint32  pFilter = 0xFFFFFFFF 
)
inherited

Register a new message listener for outgoing messages.

This method adds a new listener for outgoing messages on the CAN bus. For each listener a message filter can be defined. Therefore the mask pMask defines the relevant bits and the filter is defined in pFilter.

Parameters
[in]pFuncThe listener function.
[in]pMaskThe filter mask.
[in]pFilterThe filter itself.
Returns
An unique ID for the registered function.

◆ removeMessageSentListener()

void removeMessageSentListener ( uint32  pFuncID)
inherited

Unregister an outgoing message listener.

Parameters
[in]pFuncIDThe ID of the listener function, which should be removed.

◆ addMessageRecvListener()

uint32 addMessageRecvListener ( CANMessageCallback  pFunc,
uint32  pMask = 0x00000000,
uint32  pFilter = 0xFFFFFFFF 
)
inherited

Register a new CAN message listener.

This method adds a new listener for incoming messages on the CAN bus. For each listener a message filter can be defined. Therefore the mask pMask defines the relevant bits and the filter is defined in pFilter.

Parameters
[in]pFuncThe listener function.
[in]pMaskThe filter mask.
[in]pFilterThe filter itself.
Returns
An unique ID for the registered function.

◆ removeMessageRecvListener()

void removeMessageRecvListener ( uint32  pFuncID)
inherited

Unregister a message listener.

Parameters
[in]pFuncIDThe ID of the listener function, which should be removed.

◆ addPDOListener()

uint32 addPDOListener ( PDOCallback  pFunc,
uint32  pPDO 
)
inherited

Add a callback for a specific PDO.

Parameters
[in]pFuncThe callback function.
[in]pPDOThe desired PDO ID.
Returns
An unique ID of the registered function.

◆ removePDOListener()

void removePDOListener ( uint32  pFuncID)
inherited

Remove a PDO callback.

Parameters
[in]pFuncIDThe ID of the callback, which should be removed.

◆ onMessageSend()

void onMessageSend ( const CANMessage message,
const Time time 
)
protectedinherited

◆ onMessageReceived()

void onMessageReceived ( const CANMessage message,
const Time time 
)
protectedinherited

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