blmc_drivers
blmc_drivers::CanBus Class Reference

CanBus is the implementation of the CanBusInterface. More...

#include <can_bus.hpp>

Inheritance diagram for blmc_drivers::CanBus:
Collaboration diagram for blmc_drivers::CanBus:

Public Member Functions

 CanBus (const std::string &can_interface_name, const size_t &history_length=1000)
 Construct a new CanBus object. More...
 
virtual ~CanBus ()
 Destroy the CanBus object.
 
std::shared_ptr< const CanframeTimeseriesget_output_frame () const
 Getters. More...
 
virtual std::shared_ptr< const CanframeTimeseriesget_input_frame ()
 Get the input frame. More...
 
virtual std::shared_ptr< const CanframeTimeseriesget_sent_input_frame ()
 Get the input frame thas has been sent. More...
 
virtual void set_input_frame (const CanBusFrame &input_frame)
 Setters. More...
 
virtual void send_if_input_changed ()
 Sender. More...
 
- Public Member Functions inherited from blmc_drivers::CanBusInterface
virtual ~CanBusInterface ()
 Destroy the CanBusInterface object.
 

Private Member Functions

void loop ()
 Execute the communication loop with the can bus.
 
void send_frame (const CanBusFrame &unstamped_can_frame)
 Send input data. More...
 
CanBusFrame receive_frame ()
 Get the output frame from the bus. More...
 
CanBusConnection setup_can (std::string name, uint32_t err_mask)
 Setup and initialize the CanBus object. More...
 

Static Private Member Functions

static THREAD_FUNCTION_RETURN_TYPE loop (void *instance_pointer)
 private attributes and methods More...
 

Private Attributes

real_time_tools::SingletypeThreadsafeObject< CanBusConnection, 1 > can_connection_
 Attributes. More...
 
std::shared_ptr< real_time_tools::ThreadsafeTimeseries< CanBusFrame > > input_
 input_ is a list of time stamped frame to be send to the can network.
 
std::shared_ptr< real_time_tools::ThreadsafeTimeseries< CanBusFrame > > sent_input_
 sent_inupt_ is the list of the input already sent to the network.
 
std::shared_ptr< real_time_tools::ThreadsafeTimeseries< CanBusFrame > > output_
 output_ is the list of the frames received from the can network.
 
bool is_loop_active_
 This boolean makes sure that the loop is not active upon destruction of the current object.
 
real_time_tools::RealTimeThread rt_thread_
 rt_thread_ is the thread object allowing us to spawn real-time threads.
 
std::string log_dir_
 Log directory.
 
std::string name_
 time_log_name is the name of the loggin
 

Additional Inherited Members

- Public Types inherited from blmc_drivers::CanBusInterface
typedef real_time_tools::ThreadsafeTimeseries< CanBusFrameCanframeTimeseries
 CanframeTimeseries is a simple sohortcut.
 

Detailed Description

CanBus is the implementation of the CanBusInterface.

Constructor & Destructor Documentation

◆ CanBus()

blmc_drivers::CanBus::CanBus ( const std::string &  can_interface_name,
const size_t &  history_length = 1000 
)

Construct a new CanBus object.

Parameters
can_interface_name
history_length

Member Function Documentation

◆ get_input_frame()

virtual std::shared_ptr<const CanframeTimeseries> blmc_drivers::CanBus::get_input_frame ( )
inlinevirtual

Get the input frame.

Returns
std::shared_ptr<const CanframeTimeseries>

Implements blmc_drivers::CanBusInterface.

◆ get_output_frame()

std::shared_ptr<const CanframeTimeseries> blmc_drivers::CanBus::get_output_frame ( ) const
inlinevirtual

Getters.

Get the output frame

Returns
std::shared_ptr<const CanframeTimeseries>

Implements blmc_drivers::CanBusInterface.

◆ get_sent_input_frame()

virtual std::shared_ptr<const CanframeTimeseries> blmc_drivers::CanBus::get_sent_input_frame ( )
inlinevirtual

Get the input frame thas has been sent.

Returns
std::shared_ptr<const CanframeTimeseries>

Implements blmc_drivers::CanBusInterface.

◆ loop()

static THREAD_FUNCTION_RETURN_TYPE blmc_drivers::CanBus::loop ( void *  instance_pointer)
inlinestaticprivate

private attributes and methods

This function is an helper that allows us to launch real-time thread in xenaomai, ubunt, or rt-preempt seemlessly.

Parameters
instance_pointer
Returns
THREAD_FUNCTION_RETURN_TYPE (is void or void* depending on the OS.

◆ receive_frame()

CanBusFrame blmc_drivers::CanBus::receive_frame ( )
private

Get the output frame from the bus.

Returns
CanBusFrame is the output frame data.

◆ send_frame()

void blmc_drivers::CanBus::send_frame ( const CanBusFrame unstamped_can_frame)
private

Send input data.

Parameters
unstamped_can_frameis a frame without id nor time.

◆ send_if_input_changed()

void blmc_drivers::CanBus::send_if_input_changed ( )
virtual

Sender.

Send the queue of message to the can network

Implements blmc_drivers::CanBusInterface.

◆ set_input_frame()

virtual void blmc_drivers::CanBus::set_input_frame ( const CanBusFrame input_frame)
inlinevirtual

Setters.

Set the input frame

Parameters
input_frame

Implements blmc_drivers::CanBusInterface.

◆ setup_can()

CanBusConnection blmc_drivers::CanBus::setup_can ( std::string  name,
uint32_t  err_mask 
)
private

Setup and initialize the CanBus object.

It connects to the can bus. This method is used once in the constructor.

Parameters
nameis the can card name.
err_mask,alwaysused with "0" so far (TODO: Manuel explain)
Returns
CanBusConnection

Member Data Documentation

◆ can_connection_

real_time_tools::SingletypeThreadsafeObject<CanBusConnection, 1> blmc_drivers::CanBus::can_connection_
private

Attributes.

can_connection_ is the communication object allowing to send or receive can frames.


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