AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
isobus::SocketCANdNetworkInterface Class Reference

A CAN Driver for using socket CAN remotely over TCP socket. More...

#include <socketcand_windows_network_client.hpp>

Inheritance diagram for isobus::SocketCANdNetworkInterface:
[legend]
Collaboration diagram for isobus::SocketCANdNetworkInterface:
[legend]

Public Member Functions

 SocketCANdNetworkInterface (std::string deviceName)
 Constructor for the socket CAN driver.
 
 SocketCANdNetworkInterface (std::string deviceName, const std::string ipAddress, std::uint16_t port=29536)
 Constructor for the socket CAN driver.
 
virtual ~SocketCANdNetworkInterface ()
 The destructor for SocketCANdNetworkInterface.
 
bool get_is_valid () const override
 Returns if the connection is valid.
 
std::string get_device_name () const
 Returns the device name the driver is using.
 
const std::string get_connected_ip_address () const
 Returns the IP that the plugin is connected to.
 
void close () override
 Closes the connection.
 
void open () override
 Connects to the server.
 
bool read_frame (isobus::HardwareInterfaceCANFrame &canFrame) override
 Returns a frame from the hardware (synchronous), or false if no frame can be read.
 
bool write_frame (const isobus::HardwareInterfaceCANFrame &canFrame) override
 Writes a frame to the bus (synchronous)
 
- Public Member Functions inherited from isobus::CANHardwarePlugin
virtual bool read_frame (isobus::CANMessageFrame &canFrame)=0
 Reads one frame from the bus synchronously.
 
virtual bool write_frame (const isobus::CANMessageFrame &canFrame)=0
 Writes a frame to the bus (synchronous)
 

Private Member Functions

void initialize ()
 Initializes some class variables.
 

Static Private Attributes

static constexpr std::uint32_t MAX_RECV_LENGTH = 1024
 

Detailed Description

A CAN Driver for using socket CAN remotely over TCP socket.

Definition at line 29 of file socketcand_windows_network_client.hpp.

Constructor & Destructor Documentation

◆ SocketCANdNetworkInterface() [1/2]

isobus::SocketCANdNetworkInterface::SocketCANdNetworkInterface ( std::string deviceName)
explicit

Constructor for the socket CAN driver.

This constructor will attempt to automatically detect a socketcand server and connect to it using its UDP beacon.

Parameters
[in]deviceNameThe CAN device to connect to on the server, such as "can0"

Definition at line 15 of file socketcand_windows_network_client.cpp.

Here is the call graph for this function:

◆ SocketCANdNetworkInterface() [2/2]

isobus::SocketCANdNetworkInterface::SocketCANdNetworkInterface ( std::string deviceName,
const std::string ipAddress,
std::uint16_t port = 29536 )

Constructor for the socket CAN driver.

This constructor explicitly sets a target IP address.

Parameters
[in]deviceNameThe CAN device to connect to on the server, such as "can0"
[in]ipAddressThe ip address of the server to connect to (IPv4)
[in]portThe TCP port to connect to. By default it's 29536

Definition at line 21 of file socketcand_windows_network_client.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ close()

void isobus::SocketCANdNetworkInterface::close ( )
overridevirtual

Closes the connection.

Implements isobus::CANHardwarePlugin.

Definition at line 54 of file socketcand_windows_network_client.cpp.

◆ get_connected_ip_address()

const std::string isobus::SocketCANdNetworkInterface::get_connected_ip_address ( ) const

Returns the IP that the plugin is connected to.

Returns
The IP address that the plugin is connected to, or an empty string if not connected.

Definition at line 49 of file socketcand_windows_network_client.cpp.

◆ get_device_name()

std::string isobus::SocketCANdNetworkInterface::get_device_name ( ) const

Returns the device name the driver is using.

Returns
The device name the driver is using, such as "can0" or "vcan0"

Definition at line 44 of file socketcand_windows_network_client.cpp.

◆ get_is_valid()

bool isobus::SocketCANdNetworkInterface::get_is_valid ( ) const
overridevirtual

Returns if the connection is valid.

Returns
true if connected, false if not connected

Implements isobus::CANHardwarePlugin.

Definition at line 39 of file socketcand_windows_network_client.cpp.

◆ initialize()

void isobus::SocketCANdNetworkInterface::initialize ( )
private

Initializes some class variables.

Definition at line 29 of file socketcand_windows_network_client.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open()

void isobus::SocketCANdNetworkInterface::open ( )
overridevirtual

Connects to the server.

Implements isobus::CANHardwarePlugin.

Definition at line 58 of file socketcand_windows_network_client.cpp.

Here is the call graph for this function:

◆ read_frame()

bool isobus::SocketCANdNetworkInterface::read_frame ( isobus::HardwareInterfaceCANFrame & canFrame)
override

Returns a frame from the hardware (synchronous), or false if no frame can be read.

Parameters
[in,out]canFrameThe CAN frame that was read
Returns
true if a CAN frame was read, otherwise false

Definition at line 85 of file socketcand_windows_network_client.cpp.

◆ write_frame()

bool isobus::SocketCANdNetworkInterface::write_frame ( const isobus::HardwareInterfaceCANFrame & canFrame)
override

Writes a frame to the bus (synchronous)

Parameters
[in]canFrameThe frame to write to the bus
Returns
true if the frame was written, otherwise false

Definition at line 92 of file socketcand_windows_network_client.cpp.

Member Data Documentation

◆ MAX_RECV_LENGTH

constexpr std::uint32_t isobus::SocketCANdNetworkInterface::MAX_RECV_LENGTH = 1024
staticconstexprprivate

Definition at line 80 of file socketcand_windows_network_client.hpp.


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