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

runs but does not work yet

This commit is contained in:
travis-farmer 2024-11-24 15:31:55 -05:00
parent e01de49d36
commit 406c057335
No known key found for this signature in database
GPG Key ID: 0BC296791D14CB35
2 changed files with 7 additions and 12 deletions

View File

@ -493,11 +493,11 @@ Modbus::Modbus(uint8_t busNo, HardwareSerial serial, unsigned long baud, uint16_
_serial = &serial; _serial = &serial;
_cycleTime = cycleTimeMS * 1000UL; // convert from milliseconds to microseconds. _cycleTime = cycleTimeMS * 1000UL; // convert from milliseconds to microseconds.
_transmitEnablePin = transmitEnablePin; _transmitEnablePin = transmitEnablePin;
if (_transmitEnablePin != VPIN_NONE) { //if (_transmitEnablePin != VPIN_NONE) {
pinMode(_transmitEnablePin, OUTPUT); //pinMode(_transmitEnablePin, OUTPUT);
ArduinoPins::fastWriteDigital(_transmitEnablePin, 0); // transmitter initially off //ArduinoPins::fastWriteDigital(_transmitEnablePin, 0); // transmitter initially off
} //}
ModbusRTUMaster modbusmaster(*_serial, _transmitEnablePin);
// Add device to HAL device chain // Add device to HAL device chain
IODevice::addDevice(this); IODevice::addDevice(this);
@ -521,12 +521,6 @@ 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;
// ... 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; if (_currentNode == NULL) return;

View File

@ -322,8 +322,9 @@ public:
const char* errorStrings[]; const char* errorStrings[];
// Device-specific initialisation // Device-specific initialisation
void _begin() override { void _begin() override {
ModbusRTUMaster modbusmaster(*_serial, _transmitEnablePin);
_serial->begin(_baud, SERIAL_8N1); _serial->begin(_baud, SERIAL_8N1);
modbusmaster->begin(_baud); modbusmaster.begin(_baud);
#if defined(DIAG_IO) #if defined(DIAG_IO)
_display(); _display();
#endif #endif