Under Java (and probably C++), there's a distinction in the HAL between errors and warnings. In this case, this is a warning, and the Java WPILib would generally just log a warning instead of throwing an exception. Though, in reality, the Java implementation ignores all errors and warnings from the HAL about the PDP, possibly for this exact reason:
Code:
/**
* Query the current of a single channel of the PDP
* @return The current of one of the PDP channels (channels 0-15) in Amperes
*/
public double getCurrent(int channel) {
ByteBuffer status = ByteBuffer.allocateDirect(4);
status.order(ByteOrder.LITTLE_ENDIAN);
double current = PDPJNI.getPDPChannelCurrent((byte)channel, status.asIntBuffer());
checkPDPChannel(channel);
return current;
}
For those of you not well versed in the WPILibJ source, there is a conspicuous lack of a HALUtil status check:
Code:
HALUtil.checkStatus(status.asIntBuffer());
Without this check, warnings and errors from the PDP part of the HAL are not checked.
This may be a bug in the python implementation: it likely should log these as warnings, or ignore them altogether.
We ran into the same problem in Java with our custom wrappers (that would log warnings properly, even for PDP accesses) - randomly, the PDP would have chunks of time where it reported this warning on every access. Most of the time, it would work just fine. An example of this from our logs: (the time at the left is in milliseconds from startup)
Code:
[238266 WARNING] (Common.java:68) HAL Warning: CTRE CAN Recieve Timeout[1] in ccre.igneous.direct.DirectPDP.getCurrent(DirectPDP.java:42)
[238283 WARNING] (Common.java:68) HAL Warning: CTRE CAN Recieve Timeout[1] in ccre.igneous.direct.DirectPDP.getCurrent(DirectPDP.java:42)
[238285 WARNING] (Common.java:68) HAL Warning: CTRE CAN Recieve Timeout[1] in ccre.igneous.direct.DirectPDP.getCurrent(DirectPDP.java:42)
[238289 WARNING] (Common.java:68) HAL Warning: CTRE CAN Recieve Timeout[1] in ccre.igneous.direct.DirectPDP.getCurrent(DirectPDP.java:42)
[238304 WARNING] (Common.java:68) HAL Warning: CTRE CAN Recieve Timeout[1] in ccre.igneous.direct.DirectPDP.getCurrent(DirectPDP.java:42)
[238306 WARNING] (Common.java:68) HAL Warning: CTRE CAN Recieve Timeout[1] in ccre.igneous.direct.DirectPDP.getCurrent(DirectPDP.java:42)
[238311 WARNING] (Common.java:68) HAL Warning: CTRE CAN Recieve Timeout[1] in ccre.igneous.direct.DirectPDP.getCurrent(DirectPDP.java:42)
__________________
Software manager alumnus. Developer of
the CCRE, a powerful robot code framework based on dataflow and composibility.
Refer to as she/her/hers. Years of FRC: 2012, 2013, 2014, 2015, 2016. FLL for a few years beforehand.
Team 1540:
The Flaming Chickens | Portland, Oregon |
Twitter |
Facebook