From 1d9ed8f4587e121dfb53b8f75d968c7e1b2e4166 Mon Sep 17 00:00:00 2001 From: Thad House Date: Sat, 28 Jul 2018 09:51:49 -0700 Subject: [PATCH] Fix SensorUtil issues (#1194) C++ PDP was missing module check, and channel check called module. Java docs said 1 based instead of 0 based. --- wpilibc/src/main/native/cpp/SensorUtil.cpp | 6 +++++- .../src/main/native/include/frc/SensorUtil.h | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/wpilibc/src/main/native/cpp/SensorUtil.cpp b/wpilibc/src/main/native/cpp/SensorUtil.cpp index 652244424d..2012da4f8d 100644 --- a/wpilibc/src/main/native/cpp/SensorUtil.cpp +++ b/wpilibc/src/main/native/cpp/SensorUtil.cpp @@ -58,5 +58,9 @@ bool SensorUtil::CheckSolenoidChannel(int channel) { } bool SensorUtil::CheckPDPChannel(int channel) { - return HAL_CheckPDPModule(channel); + return HAL_CheckPDPChannel(channel); +} + +bool SensorUtil::CheckPDPModule(int module) { + return HAL_CheckPDPModule(module); } diff --git a/wpilibc/src/main/native/include/frc/SensorUtil.h b/wpilibc/src/main/native/include/frc/SensorUtil.h index e0e10a071e..a38b5424e6 100644 --- a/wpilibc/src/main/native/include/frc/SensorUtil.h +++ b/wpilibc/src/main/native/include/frc/SensorUtil.h @@ -15,10 +15,15 @@ namespace frc { */ class SensorUtil final { public: + /** + * Get the number of the default solenoid module. + * + * @return The number of the default solenoid module. + */ static int GetDefaultSolenoidModule(); /** - * Check that the solenoid module number is valid. + * Check that the solenoid module number is valid. module numbers are 0-based * * @return Solenoid module is valid and present */ @@ -28,7 +33,7 @@ class SensorUtil final { * Check that the digital channel number is valid. * * Verify that the channel number is one of the legal channel numbers. Channel - * numbers are 1-based. + * numbers are 0-based. * * @return Digital channel is valid */ @@ -48,7 +53,7 @@ class SensorUtil final { * Check that the digital channel number is valid. * * Verify that the channel number is one of the legal channel numbers. Channel - * numbers are 1-based. + * numbers are 0-based. * * @return PWM channel is valid */ @@ -88,6 +93,14 @@ class SensorUtil final { */ static bool CheckPDPChannel(int channel); + /** + * Verify that the PDP module number is within limits. module numbers are + * 0-based + * + * @return PDP module is valid + */ + static bool CheckPDPModule(int module); + static const int kDigitalChannels; static const int kAnalogInputs; static const int kAnalogOutputs;