From 9fb326c92bdbe45d2ab7076dc67e24e111fefac0 Mon Sep 17 00:00:00 2001 From: Jonas Scharpf Date: Wed, 19 Jul 2023 22:47:47 +0200 Subject: [PATCH] Add single char wait time after flush to avoid RTU control pin timing issue, see #68 and #72 --- changelog.md | 7 ++++++- package.json | 2 +- umodbus/serial.py | 2 ++ umodbus/version.py | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index e64a3ce..6377292 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Released +## [2.3.7] - 2023-07-19 +### Fixed +- Add a single character wait time after flush to avoid timing issues with RTU control pin, see #68 and #72 + ## [2.3.6] - 2023-07-19 ### Added - Add contribution guideline, see #67 @@ -303,8 +307,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - PEP8 style issues on all files of [`lib/uModbus`](lib/uModbus) -[Unreleased]: https://github.com/brainelectronics/micropython-modbus/compare/2.3.6...develop +[Unreleased]: https://github.com/brainelectronics/micropython-modbus/compare/2.3.7...develop +[2.3.7]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.7 [2.3.6]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.6 [2.3.5]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.5 [2.3.4]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.4 diff --git a/package.json b/package.json index ffac8a7..a34361d 100644 --- a/package.json +++ b/package.json @@ -38,5 +38,5 @@ ] ], "deps": [], - "version": "2.3.6" + "version": "2.3.7" } \ No newline at end of file diff --git a/umodbus/serial.py b/umodbus/serial.py index 5f60896..11b8bee 100644 --- a/umodbus/serial.py +++ b/umodbus/serial.py @@ -274,8 +274,10 @@ def _send(self, modbus_pdu: bytes, slave_addr: int) -> None: # 360-400us @ 9600-115200 baud (measured) (ESP32 @ 160/240MHz) self._uart.write(modbus_adu) send_finish_time = time.ticks_us() + if self._has_uart_flush: self._uart.flush() + time.sleep_us(self._t1char) else: sleep_time_us = ( self._t1char * len(modbus_adu) - # total frame time in us diff --git a/umodbus/version.py b/umodbus/version.py index 1b69b57..e6b8ffa 100644 --- a/umodbus/version.py +++ b/umodbus/version.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 # -*- coding: UTF-8 -*- -__version_info__ = ("2", "3", "6") +__version_info__ = ("2", "3", "7") __version__ = '.'.join(__version_info__)