Veethree D7 SDK
Loading...
Searching...
No Matches
vsdk::ct2klib_compat::ct2klib Class Reference

Detailed Description

Class that contains the required functions for initializing CT2KLib.

To initialize CT2KLib, provide these functions to CT2KLibInitEx.

#include <CT2KLib.h>
#include <ct2klib_compat/ct2klib_compat.h>
void init_ct2klib()
{
using namespace vsdk::ct2klib_compat;
// Setup INPUT_PARAMS_T input_maximums;
// Setup PORTS_CONFIG_T cfg;
CT2KLibInitEx(&input_maximums,
&cfg,
{ .canOpen = ct2klib::can_open,
.canClose = ct2klib::can_close,
.transmitFrame = ct2klib::can_transmit_frame,
.receiveFrameWait = ct2klib::can_select_wait,
.bitRateSet = ct2klib::can_set_bitrate,
.userData = nullptr });
// Use CT2KLib.
}
static BUS_STATE_T can_get_bus_state(CAN_PORT_T can_port, void *user_data)
Get the CAN Bus state for a port.
static int32_t can_set_bitrate(CAN_PORT_T can_port, uint32_t bitrate, void *user_data)
Set the bitrate for a CAN port.
static int32_t can_select_wait(CAN_PORT_T *p_can_ports, uint32_t p_can_ports_length, CAN_FRAME_T *p_can_frame, CAN_PORT_T *p_can_from_port, uint32_t timeout_ms, void *user_data)
Wait to read one of multiple CAN ports.
static int32_t can_transmit_frame(CAN_PORT_T can_port, CAN_FRAME_T *p_frame, void *user_data)
Transmit a CAN frame on a specified port.
static constexpr int NUM_CAN_PORTS
Define the number of CAN ports.
Definition ct2klib-compat.h:58
static int32_t can_close(CAN_PORT_T port, void *user_data)
Close a CAN port.
static int32_t can_open(CAN_PORT_T port, void *user_data)
Open a CAN port.
Functions necessary to initialize CT2KLib.
Definition ct2klib-compat.h:11

#include <ct2klib-compat.h>

Static Public Member Functions

static std::shared_ptr< ct2klib > instance ()
 Get the ct2klib compatibility library singleton.
static int32_t can_open (CAN_PORT_T port, void *user_data)
 Open a CAN port.
static int32_t can_close (CAN_PORT_T port, void *user_data)
 Close a CAN port.
static BUS_STATE_T can_get_bus_state (CAN_PORT_T can_port, void *user_data)
 Get the CAN Bus state for a port.
static int32_t can_transmit_frame (CAN_PORT_T can_port, CAN_FRAME_T *p_frame, void *user_data)
 Transmit a CAN frame on a specified port.
static int32_t can_select_wait (CAN_PORT_T *p_can_ports, uint32_t p_can_ports_length, CAN_FRAME_T *p_can_frame, CAN_PORT_T *p_can_from_port, uint32_t timeout_ms, void *user_data)
 Wait to read one of multiple CAN ports.
static int32_t can_set_bitrate (CAN_PORT_T can_port, uint32_t bitrate, void *user_data)
 Set the bitrate for a CAN port.

Static Public Attributes

static constexpr int NUM_CAN_PORTS = 2
 Define the number of CAN ports.

Detailed Description

Class that contains the required functions for initializing CT2KLib.

To initialize CT2KLib, provide these functions to CT2KLibInitEx.

#include <CT2KLib.h>
#include <ct2klib_compat/ct2klib_compat.h>
void init_ct2klib()
{
using namespace vsdk::ct2klib_compat;
// Setup INPUT_PARAMS_T input_maximums;
// Setup PORTS_CONFIG_T cfg;
CT2KLibInitEx(&input_maximums,
&cfg,
{ .canOpen = ct2klib::can_open,
.canClose = ct2klib::can_close,
.transmitFrame = ct2klib::can_transmit_frame,
.receiveFrameWait = ct2klib::can_select_wait,
.bitRateSet = ct2klib::can_set_bitrate,
.userData = nullptr });
// Use CT2KLib.
}

Member Function Documentation

◆ can_close()

int32_t vsdk::ct2klib_compat::ct2klib::can_close ( CAN_PORT_T port,
void * user_data )
static

Close a CAN port.

Note
This closes any open socket on the port, so any pending reads or writes will error out.
Parameters
portThe port to close.
user_dataThe pointer specified in CT2KLibInitEx in CAN_DRIVER_FUNCTIONS_T.
Returns
0 on success, -1 on failure.

◆ can_get_bus_state()

BUS_STATE_T vsdk::ct2klib_compat::ct2klib::can_get_bus_state ( CAN_PORT_T can_port,
void * user_data )
static

Get the CAN Bus state for a port.

Parameters
can_portThe port for which to check the bus state.
user_dataThe pointer specified in CT2KLibInitEx in CAN_DRIVER_FUNCTIONS_T.
Returns
BUS_STATE_T reflecting the state of the Bus.

◆ can_open()

int32_t vsdk::ct2klib_compat::ct2klib::can_open ( CAN_PORT_T port,
void * user_data )
static

Open a CAN port.

Note
This also opens a non-blocking socket on the port. If the port is already open, this is a noop.
Parameters
portThe port to open.
user_dataThe pointer specified in CT2KLibInitEx in CAN_DRIVER_FUNCTIONS_T.
Returns
0 on success, -1 on failure.

◆ can_select_wait()

int32_t vsdk::ct2klib_compat::ct2klib::can_select_wait ( CAN_PORT_T * p_can_ports,
uint32_t p_can_ports_length,
CAN_FRAME_T * p_can_frame,
CAN_PORT_T * p_can_from_port,
uint32_t timeout_ms,
void * user_data )
static

Wait to read one of multiple CAN ports.

Parameters
p_can_portsPointer to the beginning of a C-array of CAN_PORT_T
p_can_ports_lengthThe length of the C-array pointed to by p_can_ports.
[out]p_can_frameThe frame that was read. nullptr if any errors occurr.
[out]p_can_from_portThe port that the frame was read on. nullptr if any errors occurr.
timeout_msThe time to wait for a CAN frame.
user_dataThe pointer specified in CT2KLibInitEx in CAN_DRIVER_FUNCTIONS_T.
Returns
0 on success, -1 on failure.

◆ can_set_bitrate()

int32_t vsdk::ct2klib_compat::ct2klib::can_set_bitrate ( CAN_PORT_T can_port,
uint32_t bitrate,
void * user_data )
static

Set the bitrate for a CAN port.

Parameters
can_portThe port for which to set the bitrate.
bitrateThe bitrate to set.
user_dataThe pointer specified in CT2KLibInitEx in CAN_DRIVER_FUNCTIONS_T.
Returns
0 on success, -1 on failure.

◆ can_transmit_frame()

int32_t vsdk::ct2klib_compat::ct2klib::can_transmit_frame ( CAN_PORT_T can_port,
CAN_FRAME_T * p_frame,
void * user_data )
static

Transmit a CAN frame on a specified port.

Parameters
can_portThe port on which to send the frame.
p_frameThe frame to send.
user_dataThe pointer specified in CT2KLibInitEx in CAN_DRIVER_FUNCTIONS_T.
Returns
0 on success, -1 on failure.

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