Skip to content

Commit

Permalink
[wpilib] ADIS164xx: report product ID on mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterJohnson committed Jan 18, 2025
1 parent 4caa16e commit d89662e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion wpilibc/src/main/native/cpp/ADIS16448_IMU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <numbers>
#include <utility>

#include <fmt/format.h>
#include <hal/HAL.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
Expand Down Expand Up @@ -374,7 +375,8 @@ bool ADIS16448_IMU::SwitchToStandardSPI() {
// Validate the product ID
uint16_t prod_id = ReadRegister(PROD_ID);
if (prod_id != 16448) {
REPORT_ERROR("Could not find ADIS16448!");
REPORT_ERROR(
fmt::format("Could not find ADIS16448; got product ID {}", prod_id));
Close();
return false;
}
Expand Down
4 changes: 3 additions & 1 deletion wpilibc/src/main/native/cpp/ADIS16470_IMU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <numbers>
#include <utility>

#include <fmt/format.h>
#include <hal/HAL.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
Expand Down Expand Up @@ -355,7 +356,8 @@ bool ADIS16470_IMU::SwitchToStandardSPI() {
// Validate the product ID
uint16_t prod_id = ReadRegister(PROD_ID);
if (prod_id != 16982 && prod_id != 16470) {
REPORT_ERROR("Could not find ADIS16470!");
REPORT_ERROR(
fmt::format("Could not find ADIS16470; got product ID {}", prod_id));
Close();
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,9 @@ private boolean switchToStandardSPI() {
}
readRegister(PROD_ID); // Dummy read
// Validate the product ID
if (readRegister(PROD_ID) != 16448) {
DriverStation.reportError("Could not find ADIS16448", false);
int prodId = readRegister(PROD_ID);
if (prodId != 16448) {
DriverStation.reportError("Could not find ADIS16448; got product ID " + prodId, false);
close();
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ private boolean switchToStandardSPI() {
// Validate the product ID
int prodId = readRegister(PROD_ID);
if (prodId != 16982 && prodId != 16470) {
DriverStation.reportError("Could not find an ADIS16470", false);
DriverStation.reportError("Could not find an ADIS16470; got product ID " + prodId, false);
close();
return false;
}
Expand Down

0 comments on commit d89662e

Please sign in to comment.