1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 15:46:14 +01:00

Correct display of high VPIN numbers in diagnostic output.

No functional change.
VPINs are unsigned integers in the range 0-65535 (although the highest values are special, 65535=VPIN_NONE).  Values above 32767 were erroneously being displayed as negative.  This has been fixed, which is a pre-requisite for allowing VPINs above 32767 to be used.
This commit is contained in:
Neil McKechnie 2023-03-27 13:08:14 +01:00
parent f348857ddb
commit 86c3020672
17 changed files with 32 additions and 32 deletions

View File

@ -967,7 +967,7 @@ bool DCCEXParser::parseD(Print *stream, int16_t params, int16_t p[])
break; break;
case HASH_KEYWORD_ANIN: // <D ANIN vpin> Display analogue input value case HASH_KEYWORD_ANIN: // <D ANIN vpin> Display analogue input value
DIAG(F("VPIN=%d value=%d"), p[1], IODevice::readAnalogue(p[1])); DIAG(F("VPIN=%u value=%d"), p[1], IODevice::readAnalogue(p[1]));
break; break;
#if !defined(IO_NO_HAL) #if !defined(IO_NO_HAL)

View File

@ -198,7 +198,7 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
case OPCODE_IFNOT: { case OPCODE_IFNOT: {
int16_t pin = (int16_t)operand; int16_t pin = (int16_t)operand;
if (pin<0) pin = -pin; if (pin<0) pin = -pin;
DIAG(F("EXRAIL input vpin %d"),pin); DIAG(F("EXRAIL input VPIN %u"),pin);
IODevice::configureInput((VPIN)pin,true); IODevice::configureInput((VPIN)pin,true);
break; break;
} }
@ -208,7 +208,7 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
case OPCODE_IFGTE: case OPCODE_IFGTE:
case OPCODE_IFLT: case OPCODE_IFLT:
case OPCODE_DRIVE: { case OPCODE_DRIVE: {
DIAG(F("EXRAIL analog input vpin %d"),(VPIN)operand); DIAG(F("EXRAIL analog input VPIN %u"),(VPIN)operand);
IODevice::configureAnalogIn((VPIN)operand); IODevice::configureAnalogIn((VPIN)operand);
break; break;
} }

View File

@ -329,7 +329,7 @@ bool IODevice::checkNoOverlap(VPIN firstPin, uint8_t nPins, I2CAddress i2cAddres
VPIN lastDevPin=firstDevPin+dev->_nPins-1; VPIN lastDevPin=firstDevPin+dev->_nPins-1;
bool noOverlap= firstPin>lastDevPin || lastPin<firstDevPin; bool noOverlap= firstPin>lastDevPin || lastPin<firstDevPin;
if (!noOverlap) { if (!noOverlap) {
DIAG(F("WARNING HAL Overlap, definition of Vpins %u to %u ignored."), DIAG(F("WARNING HAL Overlap, redefinition of Vpins %u to %u ignored."),
firstPin, lastPin); firstPin, lastPin);
return false; return false;
} }

View File

@ -119,7 +119,7 @@ private:
case STATE_GETVALUE: case STATE_GETVALUE:
_value[_currentPin] = ((uint16_t)_inBuffer[0] << 8) + (uint16_t)_inBuffer[1]; _value[_currentPin] = ((uint16_t)_inBuffer[0] << 8) + (uint16_t)_inBuffer[1];
#ifdef IO_ANALOGUE_SLOW #ifdef IO_ANALOGUE_SLOW
DIAG(F("ADS111x pin:%d value:%d"), _currentPin, _value[_currentPin]); DIAG(F("ADS111x VPIN:%u value:%d"), _currentPin, _value[_currentPin]);
#endif #endif
// Move to next pin // Move to next pin
@ -142,7 +142,7 @@ private:
} }
void _display() override { void _display() override {
DIAG(F("ADS111x I2C:%s Configured on Vpins:%d-%d %S"), _I2CAddress.toString(), _firstVpin, _firstVpin+_nPins-1, DIAG(F("ADS111x I2C:%s Configured on Vpins:%u-%u %S"), _I2CAddress.toString(), _firstVpin, _firstVpin+_nPins-1,
_deviceState == DEVSTATE_FAILED ? F("OFFLINE") : F("")); _deviceState == DEVSTATE_FAILED ? F("OFFLINE") : F(""));
} }

View File

@ -62,7 +62,7 @@ void DCCAccessoryDecoder::_write(VPIN id, int state) {
void DCCAccessoryDecoder::_display() { void DCCAccessoryDecoder::_display() {
int endAddress = _packedAddress + _nPins - 1; int endAddress = _packedAddress + _nPins - 1;
DIAG(F("DCCAccessoryDecoder Configured on Vpins:%d-%d Addresses %d/%d-%d/%d)"), _firstVpin, _firstVpin+_nPins-1, DIAG(F("DCCAccessoryDecoder Configured on Vpins:%u-%u Addresses %d/%d-%d/%d)"), _firstVpin, _firstVpin+_nPins-1,
ADDRESS(_packedAddress), SUBADDRESS(_packedAddress), ADDRESS(endAddress), SUBADDRESS(endAddress)); ADDRESS(_packedAddress), SUBADDRESS(_packedAddress), ADDRESS(endAddress), SUBADDRESS(endAddress));
} }

View File

@ -203,7 +203,7 @@ protected:
uint8_t pin = vpin - _firstVpin; uint8_t pin = vpin - _firstVpin;
#ifdef DIAG_IO #ifdef DIAG_IO
DIAG(F("DFPlayer: VPIN:%d FileNo:%d Volume:%d"), vpin, value, volume); DIAG(F("DFPlayer: VPIN:%u FileNo:%d Volume:%d"), vpin, value, volume);
#endif #endif
// Validate parameter. // Validate parameter.
@ -232,7 +232,7 @@ protected:
} }
void _display() override { void _display() override {
DIAG(F("DFPlayer Configured on Vpins:%d-%d %S"), _firstVpin, _firstVpin+_nPins-1, DIAG(F("DFPlayer Configured on Vpins:%u-%u %S"), _firstVpin, _firstVpin+_nPins-1,
(_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F(""));
} }

View File

@ -103,7 +103,7 @@ void EXTurntable::_writeAnalogue(VPIN vpin, int value, uint8_t activity, uint16_
uint8_t stepsMSB = value >> 8; uint8_t stepsMSB = value >> 8;
uint8_t stepsLSB = value & 0xFF; uint8_t stepsLSB = value & 0xFF;
#ifdef DIAG_IO #ifdef DIAG_IO
DIAG(F("EX-Turntable WriteAnalogue Vpin:%d Value:%d Activity:%d Duration:%d"), DIAG(F("EX-Turntable WriteAnalogue VPIN:%u Value:%d Activity:%d Duration:%d"),
vpin, value, activity, duration); vpin, value, activity, duration);
DIAG(F("I2CManager write I2C Address:%d stepsMSB:%d stepsLSB:%d activity:%d"), DIAG(F("I2CManager write I2C Address:%d stepsMSB:%d stepsLSB:%d activity:%d"),
_I2CAddress.toString(), stepsMSB, stepsLSB, activity); _I2CAddress.toString(), stepsMSB, stepsLSB, activity);
@ -114,7 +114,7 @@ void EXTurntable::_writeAnalogue(VPIN vpin, int value, uint8_t activity, uint16_
// Display Turnetable-EX device driver info. // Display Turnetable-EX device driver info.
void EXTurntable::_display() { void EXTurntable::_display() {
DIAG(F("EX-Turntable I2C:%s Configured on Vpins:%d-%d %S"), _I2CAddress.toString(), (int)_firstVpin, DIAG(F("EX-Turntable I2C:%s Configured on Vpins:%u-%u %S"), _I2CAddress.toString(), (int)_firstVpin,
(int)_firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); (int)_firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F(""));
} }

View File

@ -84,7 +84,7 @@ protected:
void _write(VPIN vpin, int value) { void _write(VPIN vpin, int value) {
int pin = vpin -_firstVpin; int pin = vpin -_firstVpin;
#ifdef DIAG_IO #ifdef DIAG_IO
DIAG(F("IO_ExampleSerial::_write Pin:%d Value:%d"), (int)vpin, value); DIAG(F("IO_ExampleSerial::_write VPIN:%u Value:%d"), (int)vpin, value);
#endif #endif
// Send a command string over the serial line // Send a command string over the serial line
_serial->print('#'); _serial->print('#');
@ -153,10 +153,10 @@ protected:
// Display information about the device, and perhaps its current condition (e.g. active, disabled etc). // Display information about the device, and perhaps its current condition (e.g. active, disabled etc).
// Here we display the current values held for the pins. // Here we display the current values held for the pins.
void _display() { void _display() {
DIAG(F("IO_ExampleSerial Configured on VPins:%d-%d"), (int)_firstVpin, DIAG(F("IO_ExampleSerial Configured on Vpins:%u-%u"), (int)_firstVpin,
(int)_firstVpin+_nPins-1); (int)_firstVpin+_nPins-1);
for (int i=0; i<_nPins; i++) for (int i=0; i<_nPins; i++)
DIAG(F(" VPin %2d: %d"), _firstVpin+i, _pinValues[i]); DIAG(F(" VPin %2u: %d"), _firstVpin+i, _pinValues[i]);
} }

View File

@ -196,7 +196,7 @@ void GPIOBase<T>::_loop(unsigned long currentMicros) {
template <class T> template <class T>
void GPIOBase<T>::_display() { void GPIOBase<T>::_display() {
DIAG(F("%S I2C:%s Configured on Vpins:%d-%d %S"), _deviceName, _I2CAddress.toString(), DIAG(F("%S I2C:%s Configured on Vpins:%u-%u %S"), _deviceName, _I2CAddress.toString(),
_firstVpin, _firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); _firstVpin, _firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F(""));
} }

View File

@ -234,7 +234,7 @@ protected:
} }
void _display() override { void _display() override {
DIAG(F("HCSR04 Configured on Vpin:%d TrigPin:%d EchoPin:%d On:%dcm Off:%dcm"), DIAG(F("HCSR04 Configured on VPIN:%u TrigPin:%d EchoPin:%d On:%dcm Off:%dcm"),
_firstVpin, _trigPin, _echoPin, _onThreshold, _offThreshold); _firstVpin, _trigPin, _echoPin, _onThreshold, _offThreshold);
} }

View File

@ -46,7 +46,7 @@ bool PCA9685::_configure(VPIN vpin, ConfigTypeEnum configType, int paramCount, i
if (configType != CONFIGURE_SERVO) return false; if (configType != CONFIGURE_SERVO) return false;
if (paramCount != 5) return false; if (paramCount != 5) return false;
#ifdef DIAG_IO #ifdef DIAG_IO
DIAG(F("PCA9685 Configure VPIN:%d Apos:%d Ipos:%d Profile:%d Duration:%d state:%d"), DIAG(F("PCA9685 Configure VPIN:%u Apos:%d Ipos:%d Profile:%d Duration:%d state:%d"),
vpin, params[0], params[1], params[2], params[3], params[4]); vpin, params[0], params[1], params[2], params[3], params[4]);
#endif #endif
@ -118,7 +118,7 @@ void PCA9685::_begin() {
// For this function, the configured profile is used. // For this function, the configured profile is used.
void PCA9685::_write(VPIN vpin, int value) { void PCA9685::_write(VPIN vpin, int value) {
#ifdef DIAG_IO #ifdef DIAG_IO
DIAG(F("PCA9685 Write Vpin:%d Value:%d"), vpin, value); DIAG(F("PCA9685 Write VPIN:%u Value:%d"), vpin, value);
#endif #endif
int pin = vpin - _firstVpin; int pin = vpin - _firstVpin;
if (value) value = 1; if (value) value = 1;
@ -145,7 +145,7 @@ void PCA9685::_write(VPIN vpin, int value) {
// //
void PCA9685::_writeAnalogue(VPIN vpin, int value, uint8_t profile, uint16_t duration) { void PCA9685::_writeAnalogue(VPIN vpin, int value, uint8_t profile, uint16_t duration) {
#ifdef DIAG_IO #ifdef DIAG_IO
DIAG(F("PCA9685 WriteAnalogue Vpin:%d Value:%d Profile:%d Duration:%d %S"), DIAG(F("PCA9685 WriteAnalogue VPIN:%u Value:%d Profile:%d Duration:%d %S"),
vpin, value, profile, duration, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F("")); vpin, value, profile, duration, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F(""));
#endif #endif
if (_deviceState == DEVSTATE_FAILED) return; if (_deviceState == DEVSTATE_FAILED) return;
@ -262,7 +262,7 @@ void PCA9685::writeDevice(uint8_t pin, int value) {
// Display details of this device. // Display details of this device.
void PCA9685::_display() { void PCA9685::_display() {
DIAG(F("PCA9685 I2C:%s Configured on Vpins:%d-%d %S"), _I2CAddress.toString(), (int)_firstVpin, DIAG(F("PCA9685 I2C:%s Configured on Vpins:%u-%u %S"), _I2CAddress.toString(), (int)_firstVpin,
(int)_firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); (int)_firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F(""));
} }

View File

@ -121,7 +121,7 @@ private:
void _writeAnalogue(VPIN vpin, int value, uint8_t param1, uint16_t param2) override { void _writeAnalogue(VPIN vpin, int value, uint8_t param1, uint16_t param2) override {
(void)param1; (void)param2; // suppress compiler warning (void)param1; (void)param2; // suppress compiler warning
#ifdef DIAG_IO #ifdef DIAG_IO
DIAG(F("PCA9685pwm WriteAnalogue Vpin:%d Value:%d %S"), DIAG(F("PCA9685pwm WriteAnalogue VPIN:%u Value:%d %S"),
vpin, value, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F("")); vpin, value, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F(""));
#endif #endif
if (_deviceState == DEVSTATE_FAILED) return; if (_deviceState == DEVSTATE_FAILED) return;
@ -134,7 +134,7 @@ private:
// Display details of this device. // Display details of this device.
void _display() override { void _display() override {
DIAG(F("PCA9685pwm I2C:%s Configured on Vpins:%d-%d %S"), _I2CAddress.toString(), (int)_firstVpin, DIAG(F("PCA9685pwm I2C:%s Configured on Vpins:%u-%u %S"), _I2CAddress.toString(), (int)_firstVpin,
(int)_firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); (int)_firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F(""));
} }

View File

@ -104,7 +104,7 @@ private:
} }
void _display() override { void _display() override {
DIAG(F("Rotary Encoder I2C:%s v%d.%d.%d Configured on Vpin:%d-%d %S"), _I2CAddress.toString(), _majorVer, _minorVer, _patchVer, DIAG(F("Rotary Encoder I2C:%s v%d.%d.%d Configured on VPIN:%u-%d %S"), _I2CAddress.toString(), _majorVer, _minorVer, _patchVer,
(int)_firstVpin, _firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); (int)_firstVpin, _firstVpin+_nPins-1, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F(""));
} }

View File

@ -98,7 +98,7 @@ private:
if (configType != CONFIGURE_SERVO) return false; if (configType != CONFIGURE_SERVO) return false;
if (paramCount != 5) return false; if (paramCount != 5) return false;
#ifdef DIAG_IO #ifdef DIAG_IO
DIAG(F("Servo: Configure VPIN:%d Apos:%d Ipos:%d Profile:%d Duration:%d state:%d"), DIAG(F("Servo: Configure VPIN:%u Apos:%d Ipos:%d Profile:%d Duration:%d state:%d"),
vpin, params[0], params[1], params[2], params[3], params[4]); vpin, params[0], params[1], params[2], params[3], params[4]);
#endif #endif
@ -140,12 +140,12 @@ private:
// Get reference to slave device. // Get reference to slave device.
_slaveDevice = findDevice(_firstSlavePin); _slaveDevice = findDevice(_firstSlavePin);
if (!_slaveDevice) { if (!_slaveDevice) {
DIAG(F("Servo: Slave device not found on pins %d-%d"), DIAG(F("Servo: Slave device not found on Vpins %u-%u"),
_firstSlavePin, _firstSlavePin+_nPins-1); _firstSlavePin, _firstSlavePin+_nPins-1);
_deviceState = DEVSTATE_FAILED; _deviceState = DEVSTATE_FAILED;
} }
if (_slaveDevice != findDevice(_firstSlavePin+_nPins-1)) { if (_slaveDevice != findDevice(_firstSlavePin+_nPins-1)) {
DIAG(F("Servo: Slave device does not cover all pins %d-%d"), DIAG(F("Servo: Slave device does not cover all Vpins %u-%u"),
_firstSlavePin, _firstSlavePin+_nPins-1); _firstSlavePin, _firstSlavePin+_nPins-1);
_deviceState = DEVSTATE_FAILED; _deviceState = DEVSTATE_FAILED;
} }
@ -165,7 +165,7 @@ private:
void _write(VPIN vpin, int value) override { void _write(VPIN vpin, int value) override {
if (_deviceState == DEVSTATE_FAILED) return; if (_deviceState == DEVSTATE_FAILED) return;
#ifdef DIAG_IO #ifdef DIAG_IO
DIAG(F("Servo Write Vpin:%d Value:%d"), vpin, value); DIAG(F("Servo Write VPIN:%u Value:%d"), vpin, value);
#endif #endif
int pin = vpin - _firstVpin; int pin = vpin - _firstVpin;
if (value) value = 1; if (value) value = 1;
@ -193,7 +193,7 @@ private:
// //
void _writeAnalogue(VPIN vpin, int value, uint8_t profile, uint16_t duration) override { void _writeAnalogue(VPIN vpin, int value, uint8_t profile, uint16_t duration) override {
#ifdef DIAG_IO #ifdef DIAG_IO
DIAG(F("Servo: WriteAnalogue Vpin:%d Value:%d Profile:%d Duration:%d %S"), DIAG(F("Servo: WriteAnalogue VPIN:%u Value:%d Profile:%d Duration:%d %S"),
vpin, value, profile, duration, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F("")); vpin, value, profile, duration, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F(""));
#endif #endif
if (_deviceState == DEVSTATE_FAILED) return; if (_deviceState == DEVSTATE_FAILED) return;
@ -288,7 +288,7 @@ private:
// Display details of this device. // Display details of this device.
void _display() override { void _display() override {
DIAG(F("Servo Configured on Vpins:%d-%d, slave pins:%d-%d %S"), DIAG(F("Servo Configured on Vpins:%u-%u, slave pins:%d-%d %S"),
(int)_firstVpin, (int)_firstVpin+_nPins-1, (int)_firstVpin, (int)_firstVpin+_nPins-1,
(int)_firstSlavePin, (int)_firstSlavePin+_nPins-1, (int)_firstSlavePin, (int)_firstSlavePin+_nPins-1,
(_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F(""));

View File

@ -124,7 +124,7 @@ protected:
// Display information about the device, and perhaps its current condition (e.g. active, disabled etc). // Display information about the device, and perhaps its current condition (e.g. active, disabled etc).
void _display() { void _display() {
DIAG(F("TouchKeypad Configured on VPins:%d-%d SCL=%d SDO=%d"), (int)_firstVpin, DIAG(F("TouchKeypad Configured on Vpins:%u-%u SCL=%d SDO=%d"), (int)_firstVpin,
(int)_firstVpin+_nPins-1, _clockPin, _dataPin); (int)_firstVpin+_nPins-1, _clockPin, _dataPin);
} }

View File

@ -319,7 +319,7 @@ protected:
} }
void _display() override { void _display() override {
DIAG(F("VL53L0X I2C:%s Configured on Vpins:%d-%d On:%dmm Off:%dmm %S"), DIAG(F("VL53L0X I2C:%s Configured on Vpins:%u-%u On:%dmm Off:%dmm %S"),
_I2CAddress.toString(), _firstVpin, _firstVpin+_nPins-1, _onThreshold, _offThreshold, _I2CAddress.toString(), _firstVpin, _firstVpin+_nPins-1, _onThreshold, _offThreshold,
(_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F("")); (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F(""));
} }

View File

@ -121,7 +121,7 @@ void _loopOutput() {
} }
void _display() override { void _display() override {
DIAG(F("IO_duinoNodes %SPUT Configured on VPins:%d-%d shift=%d"), DIAG(F("IO_duinoNodes %SPUT Configured on Vpins:%u-%u shift=%d"),
_pinMap?F("IN"):F("OUT"), _pinMap?F("IN"):F("OUT"),
(int)_firstVpin, (int)_firstVpin,
(int)_firstVpin+_nPins-1, _nShiftBytes*8); (int)_firstVpin+_nPins-1, _nShiftBytes*8);