Skip to content

Commit b1c8aa2

Browse files
update changelog, improve docs and default values for #74
1 parent 13463a0 commit b1c8aa2

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

Diff for: changelog.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
<!-- ## [Unreleased] -->
1616

1717
## Released
18+
## [2.4.0] - 2023-07-20
19+
### Added
20+
- The following fixes were provided by @sandyscott
21+
- UART signals can be inverted with the `invert` argument of the `Serial` and `ModbusRTU` class constructors
22+
1823
## [2.3.7] - 2023-07-19
1924
### Fixed
2025
- Add a single character wait time after flush to avoid timing issues with RTU control pin, see #68 and #72
@@ -307,8 +312,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
307312
- PEP8 style issues on all files of [`lib/uModbus`](lib/uModbus)
308313

309314
<!-- Links -->
310-
[Unreleased]: https://github.com/brainelectronics/micropython-modbus/compare/2.3.7...develop
315+
[Unreleased]: https://github.com/brainelectronics/micropython-modbus/compare/2.4.0...develop
311316

317+
[2.4.0]: https://github.com/brainelectronics/micropython-modbus/tree/2.4.0
312318
[2.3.7]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.7
313319
[2.3.6]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.6
314320
[2.3.5]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.5

Diff for: fakes/machine.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class UART(object):
2727
2828
See https://docs.micropython.org/en/latest/library/machine.UART.html
2929
"""
30+
# ESP32: TX=32, RX=4
31+
# RP2: TX=1, RX=2
32+
INV_RX = 4
33+
INV_TX = 32
34+
3035
def __init__(self,
3136
uart_id: int,
3237
baudrate: int = 9600,
@@ -35,7 +40,8 @@ def __init__(self,
3540
stop: int = 1,
3641
tx: int = 1,
3742
rx: int = 2,
38-
timeout: int = 0) -> None:
43+
timeout: int = 0,
44+
invert: int = 0) -> None:
3945
self._uart_id = uart_id
4046
if timeout == 0:
4147
timeout = 5.0

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@
3838
]
3939
],
4040
"deps": [],
41-
"version": "2.3.7"
41+
"version": "2.4.0"
4242
}

Diff for: umodbus/serial.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626

2727

2828
class ModbusRTU(Modbus):
29-
INV_RX = UART.INV_RX # Include in class so they can be used when creating the object
29+
# Include in class so they can be used when creating the object
30+
INV_RX = UART.INV_RX
3031
INV_TX = UART.INV_TX
31-
32+
3233
"""
3334
Modbus RTU client class
3435
@@ -61,7 +62,7 @@ def __init__(self,
6162
pins: List[Union[int, Pin], Union[int, Pin]] = None,
6263
ctrl_pin: int = None,
6364
uart_id: int = 1,
64-
invert: int = None):
65+
invert: int = 0):
6566
super().__init__(
6667
# set itf to Serial object, addr_list to [addr]
6768
Serial(uart_id=uart_id,
@@ -77,9 +78,10 @@ def __init__(self,
7778

7879

7980
class Serial(CommonModbusFunctions):
80-
INV_RX = UART.INV_RX # Include in class so they can be used when creating the object
81+
# Include in class so they can be used when creating the object
82+
INV_RX = UART.INV_RX
8183
INV_TX = UART.INV_TX
82-
84+
8385
def __init__(self,
8486
uart_id: int = 1,
8587
baudrate: int = 9600,
@@ -88,7 +90,7 @@ def __init__(self,
8890
parity=None,
8991
pins: List[Union[int, Pin], Union[int, Pin]] = None,
9092
ctrl_pin: int = None,
91-
invert: int = None):
93+
invert: int = 0):
9294
"""
9395
Setup Serial/RTU Modbus
9496
@@ -106,6 +108,8 @@ def __init__(self,
106108
:type pins: List[Union[int, Pin], Union[int, Pin]]
107109
:param ctrl_pin: The control pin
108110
:type ctrl_pin: int
111+
:param invert: Invert TX and/or RX pins
112+
:type invert: int
109113
"""
110114
# UART flush function is introduced in Micropython v1.20.0
111115
self._has_uart_flush = callable(getattr(UART, "flush", None))

Diff for: umodbus/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
22
# -*- coding: UTF-8 -*-
33

4-
__version_info__ = ("2", "3", "7")
4+
__version_info__ = ("2", "4", "0")
55
__version__ = '.'.join(__version_info__)

0 commit comments

Comments
 (0)