#include <socketcan.h>
Public Member Functions | |
| void | close () |
| Close and unbind socket. More... | |
| bool | isOpen () const |
| Returns whether the socket is open or closed. More... | |
| bool | open (const std::string &interface, boost::function< void(const can_frame &frame)> handler, int thread_priority) |
| Open and bind socket. More... | |
| SocketCAN ()=default | |
| bool | startReceiverThread (int thread_priority) |
| Starts a new thread, that will wait for socket events. More... | |
| void | write (can_frame *frame) const |
| Sends the referenced frame to the bus. More... | |
| ~SocketCAN () | |
Public Attributes | |
| bool | receiver_thread_running_ = false |
| boost::function< void(const can_frame &frame)> | reception_handler |
| int | sock_fd_ = -1 |
| bool | terminate_receiver_thread_ = false |
Private Attributes | |
| sockaddr_can | address_ {} |
| ifreq | interface_request_ {} |
| pthread_t | receiver_thread_id_ {} |
Definition at line 79 of file socketcan.h.
|
default |
| can::SocketCAN::~SocketCAN | ( | ) |
Definition at line 82 of file socketcan.cpp.
| void can::SocketCAN::close | ( | ) |
Close and unbind socket.
Definition at line 124 of file socketcan.cpp.
| bool can::SocketCAN::isOpen | ( | ) | const |
Returns whether the socket is open or closed.
True if socket has opened. Definition at line 137 of file socketcan.cpp.
| bool can::SocketCAN::open | ( | const std::string & | interface, |
| boost::function< void(const can_frame &frame)> | handler, | ||
| int | thread_priority | ||
| ) |
Open and bind socket.
| interface | bus's name(example: can0). |
| handler | Pointer to a function which shall be called when frames are being received from the CAN bus. |
true if it successfully open and bind socket. Definition at line 88 of file socketcan.cpp.
| bool can::SocketCAN::startReceiverThread | ( | int | thread_priority | ) |
Starts a new thread, that will wait for socket events.
Definition at line 193 of file socketcan.cpp.
| void can::SocketCAN::write | ( | can_frame * | frame | ) | const |
Sends the referenced frame to the bus.
| frame | referenced frame which you want to send. |
Definition at line 142 of file socketcan.cpp.
|
private |
Definition at line 114 of file socketcan.h.
|
private |
Definition at line 113 of file socketcan.h.
|
private |
Definition at line 115 of file socketcan.h.
| bool can::SocketCAN::receiver_thread_running_ = false |
Definition at line 126 of file socketcan.h.
| 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
Definition at line 161 of file socketcan.h.
| int can::SocketCAN::sock_fd_ = -1 |
CAN socket file descriptor
Definition at line 121 of file socketcan.h.
| bool can::SocketCAN::terminate_receiver_thread_ = false |
Request for the child thread to terminate
Definition at line 125 of file socketcan.h.