AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
socket_can_interface.hpp
Go to the documentation of this file.
1//================================================================================================
9//================================================================================================
10#ifndef SOCKET_CAN_INTERFACE_HPP
11#define SOCKET_CAN_INTERFACE_HPP
12
13#include <string>
14
18
19struct sockaddr_can;
20
21namespace isobus
22{
23 //================================================================================================
27 //================================================================================================
29 {
30 public:
33 explicit SocketCANInterface(const std::string deviceName);
34
36 virtual ~SocketCANInterface();
37
40 bool get_is_valid() const override;
41
44 std::string get_device_name() const;
45
47 void close() override;
48
50 void open() override;
51
55 bool read_frame(isobus::CANMessageFrame &canFrame) override;
56
60 bool write_frame(const isobus::CANMessageFrame &canFrame) override;
61
65 bool set_name(const std::string &newName);
66
67 private:
68 struct sockaddr_can *pCANDevice;
69 std::string name;
71 };
72}
73#endif // SOCKET_CAN_INTERFACE_HPP
An abstraction between this CAN stack and any hardware layer.
A base class for a CAN driver. Can be derived into your platform's required interface.
A classical CAN frame, with 8 data bytes.
An abstract base class for a CAN driver.
A CAN frame for interfacing with a hardware layer, like socket CAN or other interface.
A CAN Driver for Linux socket CAN.
std::string name
The device name.
int fileDescriptor
File descriptor for the socket.
bool write_frame(const isobus::CANMessageFrame &canFrame) override
Writes a frame to the bus (synchronous)
SocketCANInterface(const std::string deviceName)
Constructor for the socket CAN driver.
std::string get_device_name() const
Returns the device name the driver is using.
bool read_frame(isobus::CANMessageFrame &canFrame) override
Returns a frame from the hardware (synchronous), or false if no frame can be read.
void close() override
Closes the socket.
bool get_is_valid() const override
Returns if the socket connection is valid.
void open() override
Connects to the socket.
virtual ~SocketCANInterface()
The destructor for SocketCANInterface.
struct sockaddr_can * pCANDevice
The structure for CAN sockets.
bool set_name(const std::string &newName)
Changes the name of the device to use, which only works if the device is not open.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...