From 406c0573353a9fd0a7be5d58c832460eea10f8fa Mon Sep 17 00:00:00 2001 From: travis-farmer Date: Sun, 24 Nov 2024 15:31:55 -0500 Subject: [PATCH] runs but does not work yet --- IO_Modbus.cpp | 16 +++++----------- IO_Modbus.h | 3 ++- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/IO_Modbus.cpp b/IO_Modbus.cpp index 91891d1..8abe4d8 100644 --- a/IO_Modbus.cpp +++ b/IO_Modbus.cpp @@ -493,11 +493,11 @@ Modbus::Modbus(uint8_t busNo, HardwareSerial serial, unsigned long baud, uint16_ _serial = &serial; _cycleTime = cycleTimeMS * 1000UL; // convert from milliseconds to microseconds. _transmitEnablePin = transmitEnablePin; - if (_transmitEnablePin != VPIN_NONE) { - pinMode(_transmitEnablePin, OUTPUT); - ArduinoPins::fastWriteDigital(_transmitEnablePin, 0); // transmitter initially off - } - ModbusRTUMaster modbusmaster(*_serial, _transmitEnablePin); + //if (_transmitEnablePin != VPIN_NONE) { + //pinMode(_transmitEnablePin, OUTPUT); + //ArduinoPins::fastWriteDigital(_transmitEnablePin, 0); // transmitter initially off + //} + // Add device to HAL device chain IODevice::addDevice(this); @@ -521,12 +521,6 @@ void Modbus::_loop(unsigned long currentMicros) { if (_currentNode == NULL) { // If we're between read/write cycles then don't do anything else. if (_currentMicros - _cycleStartTime < _cycleTime) return; - // ... otherwise start processing the first node in the list - DIAG(F("Modbusnode: End _nodeListEnd:%d "), _nodeListEnd); - DIAG(F("Modbusnode: Cur _currentNode:%d "), _currentNode); - _currentNode = _nodeListStart; - DIAG(F("Modbusnode: 141 _currentNode:%d "), _currentNode); - _cycleStartTime = _currentMicros; } if (_currentNode == NULL) return; diff --git a/IO_Modbus.h b/IO_Modbus.h index 2e929f2..165225e 100644 --- a/IO_Modbus.h +++ b/IO_Modbus.h @@ -322,8 +322,9 @@ public: const char* errorStrings[]; // Device-specific initialisation void _begin() override { + ModbusRTUMaster modbusmaster(*_serial, _transmitEnablePin); _serial->begin(_baud, SERIAL_8N1); - modbusmaster->begin(_baud); + modbusmaster.begin(_baud); #if defined(DIAG_IO) _display(); #endif