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()
{
CT2KLibInitEx(&input_maximums,
&cfg,
.userData = nullptr });
}
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 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 constexpr int | NUM_CAN_PORTS = 2 |
| | Define the number of CAN ports.
|
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()
{
CT2KLibInitEx(&input_maximums,
&cfg,
.userData = nullptr });
}
◆ 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
-
| port | The port to close. |
| user_data | The 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_port | The port for which to check the bus state. |
| user_data | The 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
-
| port | The port to open. |
| user_data | The 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_ports | Pointer to the beginning of a C-array of CAN_PORT_T |
| p_can_ports_length | The length of the C-array pointed to by p_can_ports. |
| [out] | p_can_frame | The frame that was read. nullptr if any errors occurr. |
| [out] | p_can_from_port | The port that the frame was read on. nullptr if any errors occurr. |
| timeout_ms | The time to wait for a CAN frame. |
| user_data | The 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_port | The port for which to set the bitrate. |
| bitrate | The bitrate to set. |
| user_data | The 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_port | The port on which to send the frame. |
| p_frame | The frame to send. |
| user_data | The 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: