WPILibC++ 2023.4.3-108-ge5452e3
|
Enumerations | |
enum | HAL_CANDeviceType : int32_t { HAL_CAN_Dev_kBroadcast = 0 , HAL_CAN_Dev_kRobotController = 1 , HAL_CAN_Dev_kMotorController = 2 , HAL_CAN_Dev_kRelayController = 3 , HAL_CAN_Dev_kGyroSensor = 4 , HAL_CAN_Dev_kAccelerometer = 5 , HAL_CAN_Dev_kUltrasonicSensor = 6 , HAL_CAN_Dev_kGearToothSensor = 7 , HAL_CAN_Dev_kPowerDistribution = 8 , HAL_CAN_Dev_kPneumatics = 9 , HAL_CAN_Dev_kMiscellaneous = 10 , HAL_CAN_Dev_kIOBreakout = 11 , HAL_CAN_Dev_kFirmwareUpdate = 31 } |
The CAN device type. More... | |
enum | HAL_CANManufacturer : int32_t { HAL_CAN_Man_kBroadcast = 0 , HAL_CAN_Man_kNI = 1 , HAL_CAN_Man_kLM = 2 , HAL_CAN_Man_kDEKA = 3 , HAL_CAN_Man_kCTRE = 4 , HAL_CAN_Man_kREV = 5 , HAL_CAN_Man_kGrapple = 6 , HAL_CAN_Man_kMS = 7 , HAL_CAN_Man_kTeamUse = 8 , HAL_CAN_Man_kKauaiLabs = 9 , HAL_CAN_Man_kCopperforge = 10 , HAL_CAN_Man_kPWF = 11 , HAL_CAN_Man_kStudica = 12 , HAL_CAN_Man_kTheThriftyBot = 13 , HAL_CAN_Man_kReduxRobotics = 14 } |
The CAN manufacturer ID. More... | |
Functions | |
uint32_t | HAL_GetCANPacketBaseTime (void) |
Reads the current value of the millisecond-resolution timer that the CAN API functions use as a time base. More... | |
HAL_CANHandle | HAL_InitializeCAN (HAL_CANManufacturer manufacturer, int32_t deviceId, HAL_CANDeviceType deviceType, int32_t *status) |
Initializes a CAN device. More... | |
void | HAL_CleanCAN (HAL_CANHandle handle) |
Frees a CAN device. More... | |
void | HAL_WriteCANPacket (HAL_CANHandle handle, const uint8_t *data, int32_t length, int32_t apiId, int32_t *status) |
Writes a packet to the CAN device with a specific ID. More... | |
void | HAL_WriteCANPacketRepeating (HAL_CANHandle handle, const uint8_t *data, int32_t length, int32_t apiId, int32_t repeatMs, int32_t *status) |
Writes a repeating packet to the CAN device with a specific ID. More... | |
void | HAL_WriteCANRTRFrame (HAL_CANHandle handle, int32_t length, int32_t apiId, int32_t *status) |
Writes an RTR frame of the specified length to the CAN device with the specific ID. More... | |
void | HAL_StopCANPacketRepeating (HAL_CANHandle handle, int32_t apiId, int32_t *status) |
Stops a repeating packet with a specific ID. More... | |
void | HAL_ReadCANPacketNew (HAL_CANHandle handle, int32_t apiId, uint8_t *data, int32_t *length, uint64_t *receivedTimestamp, int32_t *status) |
Reads a new CAN packet. More... | |
void | HAL_ReadCANPacketLatest (HAL_CANHandle handle, int32_t apiId, uint8_t *data, int32_t *length, uint64_t *receivedTimestamp, int32_t *status) |
Reads a CAN packet. More... | |
void | HAL_ReadCANPacketTimeout (HAL_CANHandle handle, int32_t apiId, uint8_t *data, int32_t *length, uint64_t *receivedTimestamp, int32_t timeoutMs, int32_t *status) |
Reads a CAN packet. More... | |
enum HAL_CANDeviceType : int32_t |
The CAN device type.
Teams should use HAL_CAN_Dev_kMiscellaneous
enum HAL_CANManufacturer : int32_t |
The CAN manufacturer ID.
Teams should use HAL_CAN_Man_kTeamUse.
void HAL_CleanCAN | ( | HAL_CANHandle | handle | ) |
Frees a CAN device.
[in,out] | handle | the CAN handle |
uint32_t HAL_GetCANPacketBaseTime | ( | void | ) |
Reads the current value of the millisecond-resolution timer that the CAN API functions use as a time base.
HAL_CANHandle HAL_InitializeCAN | ( | HAL_CANManufacturer | manufacturer, |
int32_t | deviceId, | ||
HAL_CANDeviceType | deviceType, | ||
int32_t * | status | ||
) |
Initializes a CAN device.
These follow the FIRST standard CAN layout. https://docs.wpilib.org/en/stable/docs/software/can-devices/can-addressing.html
[in] | manufacturer | the can manufacturer |
[in] | deviceId | the device ID (0-63) |
[in] | deviceType | the device type |
[out] | status | Error status variable. 0 on success. |
void HAL_ReadCANPacketLatest | ( | HAL_CANHandle | handle, |
int32_t | apiId, | ||
uint8_t * | data, | ||
int32_t * | length, | ||
uint64_t * | receivedTimestamp, | ||
int32_t * | status | ||
) |
Reads a CAN packet.
The will continuously return the last packet received, without accounting for packet age.
[in] | handle | the CAN handle |
[in] | apiId | the ID to read (0-1023) |
[out] | data | the packet data (8 bytes) |
[out] | length | the received length (0-8 bytes) |
[out] | receivedTimestamp | the packet received timestamp in ms (based off of CLOCK_MONOTONIC) |
[out] | status | Error status variable. 0 on success. |
void HAL_ReadCANPacketNew | ( | HAL_CANHandle | handle, |
int32_t | apiId, | ||
uint8_t * | data, | ||
int32_t * | length, | ||
uint64_t * | receivedTimestamp, | ||
int32_t * | status | ||
) |
Reads a new CAN packet.
This will only return properly once per packet received. Multiple calls without receiving another packet will return an error code.
[in] | handle | the CAN handle |
[in] | apiId | the ID to read (0-1023) |
[out] | data | the packet data (8 bytes) |
[out] | length | the received length (0-8 bytes) |
[out] | receivedTimestamp | the packet received timestamp in ms (based off of CLOCK_MONOTONIC) |
[out] | status | Error status variable. 0 on success. |
void HAL_ReadCANPacketTimeout | ( | HAL_CANHandle | handle, |
int32_t | apiId, | ||
uint8_t * | data, | ||
int32_t * | length, | ||
uint64_t * | receivedTimestamp, | ||
int32_t | timeoutMs, | ||
int32_t * | status | ||
) |
Reads a CAN packet.
The will return the last packet received until the packet is older then the requested timeout. Then it will return an error code.
[in] | handle | the CAN handle |
[in] | apiId | the ID to read (0-1023) |
[out] | data | the packet data (8 bytes) |
[out] | length | the received length (0-8 bytes) |
[out] | receivedTimestamp | the packet received timestamp in ms (based off of CLOCK_MONOTONIC) |
[out] | timeoutMs | the timeout time for the packet |
[out] | status | Error status variable. 0 on success. |
void HAL_StopCANPacketRepeating | ( | HAL_CANHandle | handle, |
int32_t | apiId, | ||
int32_t * | status | ||
) |
Stops a repeating packet with a specific ID.
This ID is 10 bits.
[in] | handle | the CAN handle |
[in] | apiId | the ID to stop repeating (0-1023) |
[out] | status | Error status variable. 0 on success. |
void HAL_WriteCANPacket | ( | HAL_CANHandle | handle, |
const uint8_t * | data, | ||
int32_t | length, | ||
int32_t | apiId, | ||
int32_t * | status | ||
) |
Writes a packet to the CAN device with a specific ID.
This ID is 10 bits.
[in] | handle | the CAN handle |
[in] | data | the data to write (0-8 bytes) |
[in] | length | the length of data (0-8) |
[in] | apiId | the ID to write (0-1023 bits) |
[out] | status | Error status variable. 0 on success. |
void HAL_WriteCANPacketRepeating | ( | HAL_CANHandle | handle, |
const uint8_t * | data, | ||
int32_t | length, | ||
int32_t | apiId, | ||
int32_t | repeatMs, | ||
int32_t * | status | ||
) |
Writes a repeating packet to the CAN device with a specific ID.
This ID is 10 bits.
The RoboRIO will automatically repeat the packet at the specified interval
[in] | handle | the CAN handle |
[in] | data | the data to write (0-8 bytes) |
[in] | length | the length of data (0-8) |
[in] | apiId | the ID to write (0-1023) |
[in] | repeatMs | the period to repeat in ms |
[out] | status | Error status variable. 0 on success. |
void HAL_WriteCANRTRFrame | ( | HAL_CANHandle | handle, |
int32_t | length, | ||
int32_t | apiId, | ||
int32_t * | status | ||
) |
Writes an RTR frame of the specified length to the CAN device with the specific ID.
By spec, the length must be equal to the length sent by the other device, otherwise behavior is unspecified.
[in] | handle | the CAN handle |
[in] | length | the length of data to request (0-8) |
[in] | apiId | the ID to write (0-1023) |
[out] | status | Error status variable. 0 on success. |