![]() |
WPILibC++ 2027.0.0-alpha-2
|
High level class for interfacing with CAN devices conforming to the standard CAN spec. More...
#include <frc/CAN.h>
Public Member Functions | |
CAN (int busId, int deviceId) | |
Create a new CAN communication interface with the specific device ID. | |
CAN (int busId, int deviceId, int deviceManufacturer, int deviceType) | |
Create a new CAN communication interface with a specific device ID, manufacturer and device type. | |
CAN (CAN &&)=default | |
CAN & | operator= (CAN &&)=default |
void | WritePacket (int apiId, const HAL_CANMessage &message) |
Write a packet to the CAN device with a specific ID. | |
void | WritePacketRepeating (int apiId, const HAL_CANMessage &message, int repeatMs) |
Write a repeating packet to the CAN device with a specific ID. | |
void | WriteRTRFrame (int apiId, const HAL_CANMessage &message) |
Write an RTR frame to the CAN device with a specific ID. | |
int | WritePacketNoError (int apiId, const HAL_CANMessage &message) |
Write a packet to the CAN device with a specific ID. | |
int | WritePacketRepeatingNoError (int apiId, const HAL_CANMessage &message, int repeatMs) |
Write a repeating packet to the CAN device with a specific ID. | |
int | WriteRTRFrameNoError (int apiId, const HAL_CANMessage &message) |
Write an RTR frame to the CAN device with a specific ID. | |
void | StopPacketRepeating (int apiId) |
Stop a repeating packet with a specific ID. | |
bool | ReadPacketNew (int apiId, HAL_CANReceiveMessage *data) |
Read a new CAN packet. | |
bool | ReadPacketLatest (int apiId, HAL_CANReceiveMessage *data) |
Read a CAN packet. | |
bool | ReadPacketTimeout (int apiId, int timeoutMs, HAL_CANReceiveMessage *data) |
Read a CAN packet. | |
Static Public Attributes | |
static constexpr HAL_CANManufacturer | kTeamManufacturer = HAL_CAN_Man_kTeamUse |
Team manufacturer. | |
static constexpr HAL_CANDeviceType | kTeamDeviceType |
Team device type. | |
High level class for interfacing with CAN devices conforming to the standard CAN spec.
No packets that can be sent gets blocked by the RoboRIO, so all methods work identically in all robot modes.
All methods are thread save, however the buffer objects passed in by the user need to not be modified for the duration of their calls.
frc::CAN::CAN | ( | int | busId, |
int | deviceId ) |
Create a new CAN communication interface with the specific device ID.
This uses the team manufacturer and device types. The device ID is 6 bits (0-63)
busId | The bus id |
deviceId | The device id |
frc::CAN::CAN | ( | int | busId, |
int | deviceId, | ||
int | deviceManufacturer, | ||
int | deviceType ) |
Create a new CAN communication interface with a specific device ID, manufacturer and device type.
The device ID is 6 bits, the manufacturer is 8 bits, and the device type is 5 bits.
busId | The bus id |
deviceId | The device ID |
deviceManufacturer | The device manufacturer |
deviceType | The device type |
|
default |
bool frc::CAN::ReadPacketLatest | ( | int | apiId, |
HAL_CANReceiveMessage * | data ) |
Read a CAN packet.
The will continuously return the last packet received, without accounting for packet age.
apiId | The API ID to read. |
data | Storage for the received data. |
bool frc::CAN::ReadPacketNew | ( | int | apiId, |
HAL_CANReceiveMessage * | data ) |
Read a new CAN packet.
This will only return properly once per packet received. Multiple calls without receiving another packet will return false.
apiId | The API ID to read. |
data | Storage for the received data. |
bool frc::CAN::ReadPacketTimeout | ( | int | apiId, |
int | timeoutMs, | ||
HAL_CANReceiveMessage * | data ) |
Read a CAN packet.
The will return the last packet received until the packet is older then the requested timeout. Then it will return false.
apiId | The API ID to read. |
timeoutMs | The timeout time for the packet |
data | Storage for the received data. |
void frc::CAN::StopPacketRepeating | ( | int | apiId | ) |
Stop a repeating packet with a specific ID.
This ID is 10 bits.
apiId | The API ID to stop repeating |
void frc::CAN::WritePacket | ( | int | apiId, |
const HAL_CANMessage & | message ) |
int frc::CAN::WritePacketNoError | ( | int | apiId, |
const HAL_CANMessage & | message ) |
void frc::CAN::WritePacketRepeating | ( | int | apiId, |
const HAL_CANMessage & | message, | ||
int | repeatMs ) |
int frc::CAN::WritePacketRepeatingNoError | ( | int | apiId, |
const HAL_CANMessage & | message, | ||
int | repeatMs ) |
void frc::CAN::WriteRTRFrame | ( | int | apiId, |
const HAL_CANMessage & | message ) |
int frc::CAN::WriteRTRFrameNoError | ( | int | apiId, |
const HAL_CANMessage & | message ) |
|
staticconstexpr |
Team device type.
|
staticconstexpr |
Team manufacturer.