RTU rework
Changes
Serial handling
This release brings a major rework of the ModbusRTU handling. The arduino-esp32 core has integrated some more ESP-IDF modifications for UART handling from version 2.0.x on that we have adopted for eModbus.
Problem was, we fixedly required a HardwareSerial as the communication object for our RTU classes. This prevented other channels like SoftwareSerial to be used instead.
Now the RTU calls will accept any object that is derived from Stream - including a HardwareSerial. Moreover the Stream object now will be passed in the begin() calls of ModbusClientRTU and ModbusServerRTU and is not needed any more in the definition of these objects..
Minor: the start/stop calls of ModbusServerRTU have been moved to begin/end for consistency with ModbusClientRTU.
Pro:
- there is no more fiddling with UART configurations inside the library any more
- other channels, like
SoftwareSerialare possible now - no more dependencies from ESP32 varieties having different UART configurations
- Channels may be switched at run time - a fresh
begin()with a differentStreamobject will be sufficient
Con:
- This is breaking the previous interface
- There is a service call
RTUutils::prepareHardwareSerial(HardwareSerial& interface);, that must be called before you will do aHardwareSerial::begin(). It will set up the required buffer sizes in the UART for Modbus to work correctly. If you will omit this call, you may encounter CRC and packet length errors. - it will be more difficult to tell where a certain issue may be originating
Async TCP
The asynchronous TCP client currently is being rewritten for a more stable operation on ESP8266. Things already have improved a lot, but there is some more to come in a later release.
What's Changed Else
- Matching serial output to snippet at base by @PapaBeans in https://github.com/eModbus/eModbus/pull/217
- stop Async server only if it's running by @dsilletti in https://github.com/eModbus/eModbus/pull/246
- Fix compiler warnings by @bertmelis in https://github.com/eModbus/eModbus/pull/259
- Prevent
ModbusClientorModbusServerobjects to be copied or assigned
New Contributors
- @PapaBeans made their first contribution in https://github.com/eModbus/eModbus/pull/217
- @dsilletti made their first contribution in https://github.com/eModbus/eModbus/pull/246
Full Changelog: https://github.com/eModbus/eModbus/compare/v1.6-stable...v1.7-stable