mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[hal] Refactor C++ handle closing; check for invalid handle before closing (#7016)
Adds a close function pointer template parameter to hal::Handle. This allows default destructors in many places. The status parameter has been removed from close functions; in most places it was not used. Where it was, an error is printed instead.
This commit is contained in:
@@ -35,13 +35,6 @@ CAN::CAN(int deviceId, int deviceManufacturer, int deviceType) {
|
||||
HAL_Report(HALUsageReporting::kResourceType_CAN, deviceId + 1);
|
||||
}
|
||||
|
||||
CAN::~CAN() {
|
||||
if (m_handle != HAL_kInvalidHandle) {
|
||||
HAL_CleanCAN(m_handle);
|
||||
m_handle = HAL_kInvalidHandle;
|
||||
}
|
||||
}
|
||||
|
||||
void CAN::WritePacket(const uint8_t* data, int length, int apiId) {
|
||||
int32_t status = 0;
|
||||
HAL_WriteCANPacket(m_handle, data, length, apiId, &status);
|
||||
|
||||
Reference in New Issue
Block a user