Skip to content

Commit 324aa1a

Browse files
update changelog, improve docs and default values for brainelectronics#74
1 parent 443974d commit 324aa1a

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

changelog.md

Lines changed: 7 additions & 1 deletion
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-02
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.5] - 2023-07-01
1924
### Fixed
2025
- Time between RS485 control pin raise and UART transmission reduced by 80% from 1000us to 200us
@@ -290,8 +295,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
290295
- PEP8 style issues on all files of [`lib/uModbus`](lib/uModbus)
291296

292297
<!-- Links -->
293-
[Unreleased]: https://github.com/brainelectronics/micropython-modbus/compare/2.3.5...develop
298+
[Unreleased]: https://github.com/brainelectronics/micropython-modbus/compare/2.4.0...develop
294299

300+
[2.4.0]: https://github.com/brainelectronics/micropython-modbus/tree/2.4.0
295301
[2.3.5]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.5
296302
[2.3.4]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.4
297303
[2.3.3]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.3

fakes/machine.py

Lines changed: 7 additions & 1 deletion
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

umodbus/serial.py

Lines changed: 10 additions & 6 deletions
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))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy