mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpilib, hal] DigitalGlitchFilter: Fix sim crash and clean up construction (#6937)
Fixes error when >3 are constructed- in java, m_filterAllocated[index] would be evaluated before the bounds check and throw IndexOutOfBounds, in c++ a vague assertion error would be thrown. Makes DoAdd static in c++ Makes the error message when HAL_SetFilterSelect fails consistent with java
This commit is contained in:
@@ -277,8 +277,8 @@ void HAL_SetFilterSelect(HAL_DigitalHandle dioPortHandle, int32_t filterIndex,
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO(Thad) Figure this out
|
||||
// mimics athena HAL
|
||||
port->filterIndex = filterIndex % 4;
|
||||
}
|
||||
|
||||
int32_t HAL_GetFilterSelect(HAL_DigitalHandle dioPortHandle, int32_t* status) {
|
||||
@@ -287,8 +287,7 @@ int32_t HAL_GetFilterSelect(HAL_DigitalHandle dioPortHandle, int32_t* status) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
// TODO(Thad) Figure this out
|
||||
return port->filterIndex;
|
||||
}
|
||||
|
||||
void HAL_SetFilterPeriod(int32_t filterIndex, int64_t value, int32_t* status) {
|
||||
|
||||
Reference in New Issue
Block a user