mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilib] Write REV PH firmware version to roboRIO to display on driver station (#3977)
This commit is contained in:
committed by
GitHub
parent
9fde0110b6
commit
05401e2b81
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "frc/PneumaticHub.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <hal/REVPH.h>
|
||||
#include <wpi/NullDeleter.h>
|
||||
#include <wpi/StackTrace.h>
|
||||
@@ -11,6 +12,7 @@
|
||||
#include "frc/Compressor.h"
|
||||
#include "frc/DoubleSolenoid.h"
|
||||
#include "frc/Errors.h"
|
||||
#include "frc/RobotBase.h"
|
||||
#include "frc/SensorUtil.h"
|
||||
#include "frc/Solenoid.h"
|
||||
#include "frc/fmt/Units.h"
|
||||
@@ -56,6 +58,29 @@ class PneumaticHub::DataStore {
|
||||
std::shared_ptr<DataStore>{this, wpi::NullDeleter<DataStore>()};
|
||||
|
||||
auto version = m_moduleObject.GetVersion();
|
||||
|
||||
if (version.FirmwareMajor > 0 && RobotBase::IsReal()) {
|
||||
// Write PH firmware version to roboRIO
|
||||
std::FILE* file = nullptr;
|
||||
file = std::fopen(
|
||||
fmt::format("/tmp/frc_versions/REV_PH_{:0>2}_WPILib_Version.ini",
|
||||
module)
|
||||
.c_str(),
|
||||
"w");
|
||||
if (file != nullptr) {
|
||||
std::fputs("[Version]\n", file);
|
||||
std::fputs(fmt::format("model=REV PH\n").c_str(), file);
|
||||
std::fputs(fmt::format("deviceID={:x}\n", (0x9052600 | module)).c_str(),
|
||||
file);
|
||||
std::fputs(fmt::format("currentVersion={}.{}.{}", version.FirmwareMajor,
|
||||
version.FirmwareMinor, version.FirmwareFix)
|
||||
.c_str(),
|
||||
file);
|
||||
std::fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
// Check PH firmware version
|
||||
if (version.FirmwareMajor > 0 && version.FirmwareMajor < 22) {
|
||||
throw FRC_MakeError(
|
||||
err::AssertionFailure,
|
||||
|
||||
Reference in New Issue
Block a user