mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-25 05:31:24 +01:00
i don't know what was fixed
This commit is contained in:
parent
44486605a5
commit
efdc14539b
@ -520,22 +520,24 @@ void Modbus::_loop(unsigned long currentMicros) {
|
|||||||
if (_currentNode == NULL) {
|
if (_currentNode == NULL) {
|
||||||
// If we're between read/write cycles then don't do anything else.
|
// If we're between read/write cycles then don't do anything else.
|
||||||
if (_currentMicros - _cycleStartTime < _cycleTime) return;
|
if (_currentMicros - _cycleStartTime < _cycleTime) return;
|
||||||
|
_currentNode = _nodeListStart;
|
||||||
}
|
}
|
||||||
_cycleStartTime = _currentMicros;
|
_cycleStartTime = _currentMicros;
|
||||||
if (_currentNode == NULL) return;
|
if (_currentNode == NULL) return;
|
||||||
const char* errorStrings[] = {"success", "invalid id", "invalid buffer", "invalid quantity", "response timeout", "frame error", "crc error", "unknown comm error", "unexpected id", "exception response", "unexpected function code", "unexpected response length", "unexpected byte count", "unexpected address", "unexpected value", "unexpected quantity"};
|
const char* errorStrings[16] = { "success", "invalid id", "invalid buffer", "invalid quantity", "response timeout", "frame error", "crc error", "unknown comm error", "unexpected id", "exception response", "unexpected function code", "unexpected response length", "unexpected byte count", "unexpected address", "unexpected value", "unexpected quantity" };
|
||||||
|
|
||||||
uint8_t error;
|
uint8_t error;
|
||||||
error = modbusmaster->writeMultipleHoldingRegisters(_currentNode->getNodeID(), 0, _currentNode->holdingRegisters, _currentNode->getNumHoldingRegisters());
|
error = modbusmaster->writeMultipleHoldingRegisters(_currentNode->getNodeID(), 0, _currentNode->holdingRegisters, _currentNode->getNumHoldingRegisters());
|
||||||
if (error != 0) DIAG(F("ModbusHR: %02d %04d %04d %s"), _currentNode->getNodeID(), 0, _currentNode->getNumHoldingRegisters(), &errorStrings[error]);
|
if (error != 0) DIAG(F("ModbusHR: %d %d %d %s"), _currentNode->getNodeID(), 0, _currentNode->getNumHoldingRegisters(), errorStrings[error]);
|
||||||
|
|
||||||
error = modbusmaster->writeMultipleCoils(_currentNode->getNodeID(), 0, _currentNode->coils, _currentNode->getNumCoils());
|
error = modbusmaster->writeMultipleCoils(_currentNode->getNodeID(), 0, _currentNode->coils, _currentNode->getNumCoils());
|
||||||
if (error != 0) DIAG(F("ModbusMC: %02d %04d %04d %s"), _currentNode->getNodeID(), 0, _currentNode->getNumCoils(), &errorStrings[error]);
|
if (error != 0) DIAG(F("ModbusMC: %d %d %d %s"), _currentNode->getNodeID(), 0, _currentNode->getNumCoils(), errorStrings[error]);
|
||||||
|
|
||||||
error = modbusmaster->readDiscreteInputs(_currentNode->getNodeID(), 0, _currentNode->discreteInputs, _currentNode->getNumDiscreteInputs());
|
error = modbusmaster->readDiscreteInputs(_currentNode->getNodeID(), 0, _currentNode->discreteInputs, _currentNode->getNumDiscreteInputs());
|
||||||
if (error != 0) DIAG(F("ModbusDI: %02d %04d %04d %s"), _currentNode->getNodeID(), 0, _currentNode->getNumDiscreteInputs(), &errorStrings[error]);
|
if (error != 0) DIAG(F("ModbusDI: %d %d %d %s"), _currentNode->getNodeID(), 0, _currentNode->getNumDiscreteInputs(), errorStrings[error]);
|
||||||
|
|
||||||
error = modbusmaster->readInputRegisters(_currentNode->getNodeID(), 0, _currentNode->inputRegisters, _currentNode->getNumInputRegisters());
|
error = modbusmaster->readInputRegisters(_currentNode->getNodeID(), 0, _currentNode->inputRegisters, _currentNode->getNumInputRegisters());
|
||||||
if (error != 0) DIAG(F("ModbusIR: %02d %04d %04d %s"), _currentNode->getNodeID(), 0, _currentNode->getNumInputRegisters(), &errorStrings[error]);
|
if (error != 0) DIAG(F("ModbusIR: %d %d %d %s"), _currentNode->getNodeID(), 0, _currentNode->getNumInputRegisters(), errorStrings[error]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link to chain of Modbus instances
|
// Link to chain of Modbus instances
|
||||||
|
@ -345,7 +345,6 @@ public:
|
|||||||
HardwareSerial *_serial;
|
HardwareSerial *_serial;
|
||||||
ModbusRTUMaster *modbusmaster;
|
ModbusRTUMaster *modbusmaster;
|
||||||
|
|
||||||
const char* errorStrings[];
|
|
||||||
// Device-specific initialisation
|
// Device-specific initialisation
|
||||||
void _begin() override {
|
void _begin() override {
|
||||||
ModbusRTUMaster modbusmaster(*_serial, _transmitEnablePin);
|
ModbusRTUMaster modbusmaster(*_serial, _transmitEnablePin);
|
||||||
|
Loading…
Reference in New Issue
Block a user