From 44486605a55372b20a1a7f939a6ff69dd0b4c741 Mon Sep 17 00:00:00 2001 From: travis-farmer Date: Mon, 25 Nov 2024 10:43:17 -0500 Subject: [PATCH] fix vpin numbers --- IO_Modbus.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IO_Modbus.h b/IO_Modbus.h index 6cd8271..004d82e 100644 --- a/IO_Modbus.h +++ b/IO_Modbus.h @@ -247,13 +247,13 @@ public: int _readAnalogue(VPIN vpin) override { // Return acquired data value, e.g. - int pin = vpin - _firstVpin; + int pin = vpin - _firstVpin - numDiscreteInputs; return inputRegisters[pin]; } void _write(VPIN vpin, int value) override { // Update current state for this device, in preparation the bus transmission - uint16_t pin = vpin - _firstVpin - numDiscreteInputs; + uint16_t pin = vpin - _firstVpin - numDiscreteInputs - numInputRegisters; if (pin < numCoils) { if (value) coils[pin] = value; @@ -263,7 +263,7 @@ public: } void writeAnalogue(VPIN vpin, int value) { - uint16_t pin = vpin - _firstVpin - numInputRegisters; + uint16_t pin = vpin - _firstVpin - numDiscreteInputs - numInputRegisters - numCoils; if (pin < numHoldingRegisters) { if (value) holdingRegisters[pin] = value;