1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-01-11 13:21:01 +01:00

Maybe fix?

This commit is contained in:
travis-farmer 2024-11-28 08:06:01 -05:00
parent 6551ce7b50
commit 367b86cd09
No known key found for this signature in database
GPG Key ID: 0BC296791D14CB35
2 changed files with 7 additions and 22 deletions

View File

@ -317,7 +317,7 @@ ModbusRTUMasterError Modbus::writeMultipleCoils(uint8_t id, uint16_t startAddres
adu.setDataRegister(2, quantity);
adu.data[4] = byteCount;
for (uint16_t i = 0; i < quantity; i++) {
bitWrite(adu.data[5 + (i >> 3)], i & 7, (bool) buf[i]);
bitWrite(adu.data[5 + (i >> 3)], i & 7, buf[i]);
}
for (uint16_t i = quantity; i < (byteCount * 8); i++) {
bitClear(adu.data[5 + (i >> 3)], i & 7);

View File

@ -208,41 +208,26 @@ public:
int _read(VPIN vpin) override {
// Return current state from this device
uint16_t pin = vpin - _firstVpin;
if (pin < _numDiscreteInputs) {
return (int) discreteInputs[pin];
} else
return 0;
return (int) discreteInputs[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;
if (pin < _numCoils) {
if (value){
if (value == 1) coils[pin] = (char*) 0x1;
if (value == 0) coils[pin] = (char*) 0x0;
//coils[pin] = value;
}
else
coils[pin];
}
if (value == 1) coils[pin] = (char*) 0x1;
if (value == 0) coils[pin] = (char*) 0x0;
}
int _readAnalogue(VPIN vpin) override {
int _readAnalogue(VPIN vpin) {
// Return acquired data value, e.g.
int pin = vpin - _firstVpin - _numDiscreteInputs - _numCoils;
return (int) inputRegisters[pin-1];
return (int) inputRegisters[pin];
}
void _writeAnalogue(VPIN vpin, int value, uint8_t param1=0, uint16_t param2=0) override {
uint16_t pin = vpin - _firstVpin - _numDiscreteInputs - _numCoils - _numInputRegisters;
if (pin < _numHoldingRegisters) {
if (value)
holdingRegisters[pin-1] = (uint16_t*) value;
else
holdingRegisters[pin-1];
}
holdingRegisters[pin] = (uint16_t*) value;
}
uint8_t getBusNumber() {