AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
|
A CAN Driver for Linux socket CAN. More...
#include <socket_can_interface.hpp>
Public Member Functions | |
SocketCANInterface (const std::string deviceName) | |
Constructor for the socket CAN driver. | |
virtual | ~SocketCANInterface () |
The destructor for SocketCANInterface. | |
bool | get_is_valid () const override |
Returns if the socket connection is valid. | |
std::string | get_device_name () const |
Returns the device name the driver is using. | |
void | close () override |
Closes the socket. | |
void | open () override |
Connects to the socket. | |
bool | read_frame (isobus::CANMessageFrame &canFrame) override |
Returns a frame from the hardware (synchronous), or false if no frame can be read. | |
bool | write_frame (const isobus::CANMessageFrame &canFrame) override |
Writes a frame to the bus (synchronous) | |
bool | set_name (const std::string &newName) |
Changes the name of the device to use, which only works if the device is not open. | |
Private Attributes | |
struct sockaddr_can * | pCANDevice |
The structure for CAN sockets. | |
std::string | name |
The device name. | |
int | fileDescriptor |
File descriptor for the socket. | |
A CAN Driver for Linux socket CAN.
Definition at line 28 of file socket_can_interface.hpp.
|
explicit |
Constructor for the socket CAN driver.
[in] | deviceName | The device name to use, like "can0" or "vcan0" |
Definition at line 28 of file socket_can_interface.cpp.
|
virtual |
The destructor for SocketCANInterface.
Definition at line 39 of file socket_can_interface.cpp.
|
overridevirtual |
Closes the socket.
Implements isobus::CANHardwarePlugin.
Definition at line 60 of file socket_can_interface.cpp.
std::string isobus::SocketCANInterface::get_device_name | ( | ) | const |
Returns the device name the driver is using.
Definition at line 55 of file socket_can_interface.cpp.
|
overridevirtual |
Returns if the socket connection is valid.
true
if connected, false
if not connected Implements isobus::CANHardwarePlugin.
Definition at line 50 of file socket_can_interface.cpp.
|
overridevirtual |
Connects to the socket.
Implements isobus::CANHardwarePlugin.
Definition at line 66 of file socket_can_interface.cpp.
|
overridevirtual |
Returns a frame from the hardware (synchronous), or false
if no frame can be read.
[in,out] | canFrame | The CAN frame that was read |
true
if a CAN frame was read, otherwise false
Implements isobus::CANHardwarePlugin.
Definition at line 109 of file socket_can_interface.cpp.
bool isobus::SocketCANInterface::set_name | ( | const std::string & | newName | ) |
Changes the name of the device to use, which only works if the device is not open.
[in] | newName | The new name for the device (such as "can0" or "vcan0") |
true
if the name was changed, otherwise false
(if the device is open this will return false) Definition at line 220 of file socket_can_interface.cpp.
|
overridevirtual |
Writes a frame to the bus (synchronous)
[in] | canFrame | The frame to write to the bus |
true
if the frame was written, otherwise false
Implements isobus::CANHardwarePlugin.
Definition at line 194 of file socket_can_interface.cpp.
|
private |
File descriptor for the socket.
Definition at line 70 of file socket_can_interface.hpp.
|
private |
The device name.
Definition at line 69 of file socket_can_interface.hpp.
|
private |
The structure for CAN sockets.
Definition at line 68 of file socket_can_interface.hpp.