diff --git a/hal/src/main/native/athena/CTREPCM.cpp b/hal/src/main/native/athena/CTREPCM.cpp index 5f42322325..79c1ae3983 100644 --- a/hal/src/main/native/athena/CTREPCM.cpp +++ b/hal/src/main/native/athena/CTREPCM.cpp @@ -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, diff --git a/hal/src/main/native/athena/REVPH.cpp b/hal/src/main/native/athena/REVPH.cpp index a3790cc606..ae3f460cc8 100644 --- a/hal/src/main/native/athena/REVPH.cpp +++ b/hal/src/main/native/athena/REVPH.cpp @@ -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); }