WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
CAN Functions

Macros

#define HAL_CAN_SEND_PERIOD_NO_REPEAT   0
 Flag for sending a CAN message once.
 
#define HAL_CAN_SEND_PERIOD_STOP_REPEATING   -1
 Flag for stopping periodic CAN message sends.
 
#define HAL_CAN_IS_FRAME_REMOTE   0x80000000
 Mask for "is frame remote" in message ID.
 
#define HAL_CAN_IS_FRAME_11BIT   0x40000000
 Mask for "is frame 11 bits" in message ID.
 
#define HAL_ERR_CANSessionMux_InvalidBuffer   -44086
 
#define HAL_ERR_CANSessionMux_MessageNotFound   -44087
 
#define HAL_WARN_CANSessionMux_NoToken   44087
 
#define HAL_ERR_CANSessionMux_NotAllowed   -44088
 
#define HAL_ERR_CANSessionMux_NotInitialized   -44089
 
#define HAL_ERR_CANSessionMux_SessionOverrun   44050
 
void HAL_CAN_SendMessage (uint32_t messageID, const uint8_t *data, uint8_t dataSize, int32_t periodMs, int32_t *status)
 Sends a CAN message.
 
void HAL_CAN_ReceiveMessage (uint32_t *messageID, uint32_t messageIDMask, uint8_t *data, uint8_t *dataSize, uint32_t *timeStamp, int32_t *status)
 Receives a CAN message.
 
void HAL_CAN_GetCANStatus (float *percentBusUtilization, uint32_t *busOffCount, uint32_t *txFullCount, uint32_t *receiveErrorCount, uint32_t *transmitErrorCount, int32_t *status)
 Gets CAN status information.
 

Detailed Description

Macro Definition Documentation

◆ HAL_CAN_IS_FRAME_11BIT

#define HAL_CAN_IS_FRAME_11BIT   0x40000000

Mask for "is frame 11 bits" in message ID.

◆ HAL_CAN_IS_FRAME_REMOTE

#define HAL_CAN_IS_FRAME_REMOTE   0x80000000

Mask for "is frame remote" in message ID.

◆ HAL_CAN_SEND_PERIOD_NO_REPEAT

#define HAL_CAN_SEND_PERIOD_NO_REPEAT   0

Flag for sending a CAN message once.

◆ HAL_CAN_SEND_PERIOD_STOP_REPEATING

#define HAL_CAN_SEND_PERIOD_STOP_REPEATING   -1

Flag for stopping periodic CAN message sends.

◆ HAL_ERR_CANSessionMux_InvalidBuffer

#define HAL_ERR_CANSessionMux_InvalidBuffer   -44086

◆ HAL_ERR_CANSessionMux_MessageNotFound

#define HAL_ERR_CANSessionMux_MessageNotFound   -44087

◆ HAL_ERR_CANSessionMux_NotAllowed

#define HAL_ERR_CANSessionMux_NotAllowed   -44088

◆ HAL_ERR_CANSessionMux_NotInitialized

#define HAL_ERR_CANSessionMux_NotInitialized   -44089

◆ HAL_ERR_CANSessionMux_SessionOverrun

#define HAL_ERR_CANSessionMux_SessionOverrun   44050

◆ HAL_WARN_CANSessionMux_NoToken

#define HAL_WARN_CANSessionMux_NoToken   44087

Function Documentation

◆ HAL_CAN_GetCANStatus()

void HAL_CAN_GetCANStatus ( float * percentBusUtilization,
uint32_t * busOffCount,
uint32_t * txFullCount,
uint32_t * receiveErrorCount,
uint32_t * transmitErrorCount,
int32_t * status )

Gets CAN status information.

Parameters
[out]percentBusUtilizationthe bus utilization
[out]busOffCountthe number of bus off errors
[out]txFullCountthe number of tx full errors
[out]receiveErrorCountthe number of receive errors
[out]transmitErrorCountthe number of transmit errors
[out]statusError status variable. 0 on success.

◆ HAL_CAN_ReceiveMessage()

void HAL_CAN_ReceiveMessage ( uint32_t * messageID,
uint32_t messageIDMask,
uint8_t * data,
uint8_t * dataSize,
uint32_t * timeStamp,
int32_t * status )

Receives a CAN message.

Parameters
[out]messageIDstore for the received message ID
[in]messageIDMaskthe message ID mask to look for
[out]datadata output (8 bytes)
[out]dataSizedata length (0-8 bytes)
[out]timeStampthe packet received timestamp (based off of CLOCK_MONOTONIC)
[out]statusError status variable. 0 on success.

◆ HAL_CAN_SendMessage()

void HAL_CAN_SendMessage ( uint32_t messageID,
const uint8_t * data,
uint8_t dataSize,
int32_t periodMs,
int32_t * status )

Sends a CAN message.

Parameters
[in]messageIDthe CAN ID to send
[in]datathe data to send (0-8 bytes)
[in]dataSizethe size of the data to send (0-8 bytes)
[in]periodMsthe period to repeat the packet at. Use HAL_CAN_SEND_PERIOD_NO_REPEAT to not repeat.
[out]statusError status variable. 0 on success.