mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Add CAN API constructor that takes explicit manufacturer and device type (#1311)
Useful for vendors wanting to use the API and make their own device parameters
This commit is contained in:
committed by
Peter Johnson
parent
a846ed062f
commit
59386635e7
@@ -24,6 +24,20 @@ CAN::CAN(int deviceId) {
|
||||
HAL_Report(HALUsageReporting::kResourceType_CAN, deviceId);
|
||||
}
|
||||
|
||||
CAN::CAN(int deviceId, int deviceManufacturer, int deviceType) {
|
||||
int32_t status = 0;
|
||||
m_handle = HAL_InitializeCAN(
|
||||
static_cast<HAL_CANManufacturer>(deviceManufacturer), deviceId,
|
||||
static_cast<HAL_CANDeviceType>(deviceType), &status);
|
||||
if (status != 0) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
m_handle = HAL_kInvalidHandle;
|
||||
return;
|
||||
}
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_CAN, deviceId);
|
||||
}
|
||||
|
||||
CAN::~CAN() {
|
||||
if (StatusIsFatal()) return;
|
||||
if (m_handle != HAL_kInvalidHandle) {
|
||||
|
||||
Reference in New Issue
Block a user