mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[hal] REVPH: Improve handling of disconnected CAN Bus (#4169)
Force the status to be 0 (no error) upon initialization of the REV PneumaticHub. This prevents a program crash in the case of a robot code restart with no CAN Bus present.
This commit is contained in:
@@ -233,9 +233,11 @@ void HAL_SetCTREPCMClosedLoopControl(HAL_CTREPCMHandle handle, HAL_Bool enabled,
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t can_status = 0;
|
||||
|
||||
std::scoped_lock lock{pcm->lock};
|
||||
pcm->control.bits.closedLoopEnable = enabled ? 1 : 0;
|
||||
SendControl(pcm.get(), status);
|
||||
SendControl(pcm.get(), &can_status);
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetCTREPCMClosedLoopControl(HAL_CTREPCMHandle handle,
|
||||
|
||||
@@ -228,20 +228,20 @@ HAL_REVPHHandle HAL_InitializeREVPH(int32_t module,
|
||||
sizeof(hph->desiredSolenoidsState));
|
||||
std::memset(&hph->versionInfo, 0, sizeof(hph->versionInfo));
|
||||
|
||||
int32_t can_status = 0;
|
||||
|
||||
// Start closed-loop compressor control by starting solenoid state updates
|
||||
HAL_SendREVPHSolenoidsState(hph.get(), status);
|
||||
HAL_SendREVPHSolenoidsState(hph.get(), &can_status);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void HAL_FreeREVPH(HAL_REVPHHandle handle) {
|
||||
auto hph = REVPHHandles->Get(handle);
|
||||
if (hph == nullptr) {
|
||||
return;
|
||||
if (hph) {
|
||||
HAL_CleanCAN(hph->hcan);
|
||||
}
|
||||
|
||||
HAL_CleanCAN(hph->hcan);
|
||||
|
||||
REVPHHandles->Free(handle);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user