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:
Thad House
2018-09-19 21:40:47 -07:00
committed by Peter Johnson
parent a846ed062f
commit 59386635e7
3 changed files with 46 additions and 1 deletions

View File

@@ -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) {