rm_control
Loading...
Searching...
No Matches
can::SocketCAN Class Reference

#include <socketcan.h>

Public Member Functions

 SocketCAN ()=default
 
 ~SocketCAN ()
 
bool open (const std::string &interface, boost::function< void(const can_frame &frame)> handler, int thread_priority)
 Open and bind socket.
 
void close ()
 Close and unbind socket.
 
bool isOpen () const
 Returns whether the socket is open or closed.
 
void write (can_frame *frame) const
 Sends the referenced frame to the bus.
 
bool startReceiverThread (int thread_priority)
 Starts a new thread, that will wait for socket events.
 

Public Attributes

int sock_fd_ = -1
 
bool terminate_receiver_thread_ = false
 
bool receiver_thread_running_ = false
 
boost::function< void(const can_frame &frame)> reception_handler
 

Constructor & Destructor Documentation

◆ SocketCAN()

can::SocketCAN::SocketCAN ( )
default

◆ ~SocketCAN()

can::SocketCAN::~SocketCAN ( )

Member Function Documentation

◆ close()

void can::SocketCAN::close ( )

Close and unbind socket.

◆ isOpen()

bool can::SocketCAN::isOpen ( ) const

Returns whether the socket is open or closed.

Returns
True if socket has opened.

◆ open()

bool can::SocketCAN::open ( const std::string & interface,
boost::function< void(const can_frame &frame)> handler,
int thread_priority )

Open and bind socket.

Parameters
interfacebus's name(example: can0).
handlerPointer to a function which shall be called when frames are being received from the CAN bus.
Returns
true if it successfully open and bind socket.

◆ startReceiverThread()

bool can::SocketCAN::startReceiverThread ( int thread_priority)

Starts a new thread, that will wait for socket events.

◆ write()

void can::SocketCAN::write ( can_frame * frame) const

Sends the referenced frame to the bus.

Parameters
framereferenced frame which you want to send.

Member Data Documentation

◆ receiver_thread_running_

bool can::SocketCAN::receiver_thread_running_ = false

◆ reception_handler

boost::function<void(const can_frame& frame)> can::SocketCAN::reception_handler

Pointer to a function which shall be called when frames are being received from the CAN bus

◆ sock_fd_

int can::SocketCAN::sock_fd_ = -1

CAN socket file descriptor

◆ terminate_receiver_thread_

bool can::SocketCAN::terminate_receiver_thread_ = false

Request for the child thread to terminate


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