From 5ab0409c15d70cb97ebc2fec7398057dccee82a8 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 17 Jan 2025 19:14:20 -0700 Subject: [PATCH] [wpilib] ADIS164xx: report product ID on mismatch (#7706) --- wpilibc/src/main/native/cpp/ADIS16448_IMU.cpp | 4 +++- wpilibc/src/main/native/cpp/ADIS16470_IMU.cpp | 4 +++- .../src/main/java/edu/wpi/first/wpilibj/ADIS16448_IMU.java | 5 +++-- .../src/main/java/edu/wpi/first/wpilibj/ADIS16470_IMU.java | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/wpilibc/src/main/native/cpp/ADIS16448_IMU.cpp b/wpilibc/src/main/native/cpp/ADIS16448_IMU.cpp index 7d42876c01..bc1b3a244b 100644 --- a/wpilibc/src/main/native/cpp/ADIS16448_IMU.cpp +++ b/wpilibc/src/main/native/cpp/ADIS16448_IMU.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -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; } diff --git a/wpilibc/src/main/native/cpp/ADIS16470_IMU.cpp b/wpilibc/src/main/native/cpp/ADIS16470_IMU.cpp index 3fef9505a5..2ff191376e 100644 --- a/wpilibc/src/main/native/cpp/ADIS16470_IMU.cpp +++ b/wpilibc/src/main/native/cpp/ADIS16470_IMU.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -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; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADIS16448_IMU.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADIS16448_IMU.java index 7ef4c17eb2..008b17864f 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADIS16448_IMU.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADIS16448_IMU.java @@ -425,8 +425,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable { } 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; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADIS16470_IMU.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADIS16470_IMU.java index 169f13dd46..0a957e3d65 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADIS16470_IMU.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADIS16470_IMU.java @@ -485,7 +485,7 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable { // 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; }