Veethree D7 SDK
Loading...
Searching...
No Matches
vsdk::comms::can_socket_interface Class Referenceabstract

Detailed Description

The can_socket_interface lists the expected interface for a CAN socket implementation that can be used by vsdk::comms::can_socket.

Note
The can_socket class is hardcoded to use one of a few private implementations and cannot be modified to use a user-provided one.

#include <can_socket_interface.h>

Public Member Functions

virtual std::errc open ()=0
 Native handle for a socket.
virtual std::errc close ()=0
 Close this socket.
virtual bool is_open ()=0
 Check if the socket is open and bound to an interface.
virtual std::errc bind (const can_adapter &adapter)=0
 Bind this socket to an adapter.
virtual std::optional< can_adapter > adapter () const =0
 Get the adapter this socket is bound to, if any.
virtual std::errc send (const can_msg_frame &frame)=0
 Send a CAN frame on this socket.
virtual receive_result receive (can_msg_frame &frame, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero())=0
 Receive a CAN frame on this socket.
virtual std::errc set_nonblocking ()=0
 Make reads and writes on this socket non-blocking.
virtual std::errc set_blocking ()=0
 Make reads and writes on this socket blocking.
virtual std::errc enable_error_frames ()=0
 Enable receiving CAN Error Frames on this socket.
virtual std::errc disable_error_frames ()=0
 Disable receiving CAN Error Frames on this socket.
virtual void set_receive_callback (const can_socket_recv_callback &cb)=0
 Set a callback to be run when a CAN frame is received.
virtual void clear_receive_callback ()=0
 Remove the receive callback.
virtual bool has_receive_callback ()=0
 Does the socket have a receive callback set.
virtual select_result_can select_receive_timeout (const std::vector< can_socket > &sockets, std::chrono::milliseconds timeout) const =0
 Listen on multiple sockets at the same time for a CAN frame. Returns after receiving a single CAN frame or timing out.

Detailed Description

The can_socket_interface lists the expected interface for a CAN socket implementation that can be used by vsdk::comms::can_socket.

Note
The can_socket class is hardcoded to use one of a few private implementations and cannot be modified to use a user-provided one.

Member Function Documentation

◆ bind()

virtual std::errc vsdk::comms::can_socket_interface::bind ( const can_adapter & adapter)
pure virtual

Bind this socket to an adapter.

Parameters
adapterThe adapter to bind this socket to.

◆ close()

virtual std::errc vsdk::comms::can_socket_interface::close ( )
pure virtual

Close this socket.

Note
It is usually okay to ignore the return value of this method.

◆ open()

virtual std::errc vsdk::comms::can_socket_interface::open ( )
pure virtual

Native handle for a socket.

Open a new OS-level socket.

◆ receive()

virtual receive_result vsdk::comms::can_socket_interface::receive ( can_msg_frame & frame,
std::chrono::milliseconds timeout = std::chrono::milliseconds::zero() )
pure virtual

Receive a CAN frame on this socket.

Parameters
[out]frameThe frame that was read. Not modified if any errors occur.
timeoutOptional. Time in millisecods after which to stop waiting. Default to 0ms. Setting it to 0ms will wait indefinitely.
Returns
receive_result::recv_err will be std::errc{} (i.e. error code 0) if a CAN frame was successfully received. std::errc::timed_out if a timeout is set and it elapsed. In every other case, the error code describing the error. If there is a callback set, receive_result::callback_err will contain the result of the callback

◆ select_receive_timeout()

virtual select_result_can vsdk::comms::can_socket_interface::select_receive_timeout ( const std::vector< can_socket > & sockets,
std::chrono::milliseconds timeout ) const
pure virtual

Listen on multiple sockets at the same time for a CAN frame. Returns after receiving a single CAN frame or timing out.

Parameters
socketsThe sockets to listen on.
timeoutThe timeout for the select call.
Returns
select_result_can

◆ send()

virtual std::errc vsdk::comms::can_socket_interface::send ( const can_msg_frame & frame)
pure virtual

Send a CAN frame on this socket.

Parameters
frameThe frame to send.

◆ set_receive_callback()

virtual void vsdk::comms::can_socket_interface::set_receive_callback ( const can_socket_recv_callback & cb)
pure virtual

Set a callback to be run when a CAN frame is received.

Parameters
cbThe callback.

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