AndyMark FRC CAN API (C++) v2026.0.4
Loading...
Searching...
No Matches
CanDevice Class Reference

Common base abstraction for AndyMark CAN devices. More...

#include <AMCanDevice.h>

Inheritance diagram for CanDevice:
AM_CANColorSensor AM_CANLidar AM_CAN_HexBoreEncoder AM_CAN_Mag_Switch CAN_Koors40

Public Member Functions

 CanDevice (int deviceID, int deviceManufacturer, int deviceType)
 Construct a CAN device wrapper.
virtual ~CanDevice ()=default
 Virtual destructor.
int getDeviceId ()
 Get this device's configured CAN ID.
void RestartDevice ()
 Request a device reboot via CAN command.

Protected Member Functions

void SendCANMessage (int apiID, const uint8_t *data, int length)
 Low-level helper to transmit a CAN packet.
bool ReceiveCANMessage (int apiID, frc::CANData *, int timeoutMs)
 Receive a packet with a specific API ID, optionally waiting up to timeout.

Protected Attributes

frc::CAN m_can
int m_deviceID
int deviceManufacturer
int deviceType

Detailed Description

Common base abstraction for AndyMark CAN devices.

Construct with a device ID, manufacturer, and device type. Provides protected helpers to send/receive raw CAN packets and public utility methods.

Constructor & Destructor Documentation

◆ CanDevice()

CanDevice::CanDevice ( int deviceID,
int deviceManufacturer,
int deviceType )
explicit

Construct a CAN device wrapper.

Parameters
deviceIDThe 6-bit/8-bit device ID on the CAN bus.
deviceManufacturer8-bit manufacturer code (e.g., 15 for AndyMark).
deviceTypeDevice type identifier (matches on-device firmware).

◆ ~CanDevice()

virtual CanDevice::~CanDevice ( )
virtualdefault

Virtual destructor.

Necessary for correct cleanup through base pointers.

Member Function Documentation

◆ getDeviceId()

int CanDevice::getDeviceId ( )

Get this device's configured CAN ID.

Returns
The numeric CAN device ID.

◆ ReceiveCANMessage()

bool CanDevice::ReceiveCANMessage ( int apiID,
frc::CANData * ,
int timeoutMs )
protected

Receive a packet with a specific API ID, optionally waiting up to timeout.

Wraps WPILib frc::CAN::ReadPacketTimeout.

Parameters
apiIDExpected API ID to match.
frc::CANData*Destination structure for received data.
timeoutMsMaximum time to wait for a packet (milliseconds).
Returns
True if a matching frame was received within the timeout; false otherwise.

◆ RestartDevice()

void CanDevice::RestartDevice ( )

Request a device reboot via CAN command.

Sends a vendor-specific API frame defined by RESTART_DEVICE_API.

◆ SendCANMessage()

void CanDevice::SendCANMessage ( int apiID,
const uint8_t * data,
int length )
protected

Low-level helper to transmit a CAN packet.

Parameters
apiIDVendor-specific API ID used to route the message.
dataPointer to payload bytes (may be nullptr when length==0).
lengthNumber of payload bytes (0..8).

Member Data Documentation

◆ deviceManufacturer

int CanDevice::deviceManufacturer
protected

Manufacturer code (8-bit).

◆ deviceType

int CanDevice::deviceType
protected

Device type identifier.

◆ m_can

frc::CAN CanDevice::m_can
protected

Underlying WPILib CAN endpoint.

◆ m_deviceID

int CanDevice::m_deviceID
protected

Configured CAN device ID.


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