[wpilib] Throw exception if the REV Pneumatic Hub firmware version is older than 22.0.0 (#3853)

This commit is contained in:
Noah Andrews
2022-01-03 13:09:30 -06:00
committed by GitHub
parent dae61226fa
commit c137569f91
4 changed files with 75 additions and 5 deletions

View File

@@ -54,6 +54,15 @@ class PneumaticHub::DataStore {
m_moduleObject = PneumaticHub{handle, module};
m_moduleObject.m_dataStore =
std::shared_ptr<DataStore>{this, wpi::NullDeleter<DataStore>()};
auto version = m_moduleObject.GetVersion();
if (version.FirmwareMajor > 0 && version.FirmwareMajor < 22) {
throw FRC_MakeError(
err::AssertionFailure,
"The Pneumatic Hub has firmware version {}.{}.{}, and must be "
"updated to version 2022.0.0 or later using the REV Hardware Client",
version.FirmwareMajor, version.FirmwareMinor, version.FirmwareFix);
}
}
~DataStore() noexcept { HAL_FreeREVPH(m_moduleObject.m_handle); }