Skip to content

Commit

Permalink
update changelog, improve docs and default values for #74
Browse files Browse the repository at this point in the history
  • Loading branch information
brainelectronics committed Jul 2, 2023
1 parent 443974d commit 324aa1a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
8 changes: 7 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- ## [Unreleased] -->

## Released
## [2.4.0] - 2023-07-02
### Added
- The following fixes were provided by @sandyscott
- UART signals can be inverted with the `invert` argument of the `Serial` and `ModbusRTU` class constructors

## [2.3.5] - 2023-07-01
### Fixed
- Time between RS485 control pin raise and UART transmission reduced by 80% from 1000us to 200us
Expand Down Expand Up @@ -290,8 +295,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)

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

[2.4.0]: https://github.com/brainelectronics/micropython-modbus/tree/2.4.0
[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
[2.3.3]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.3
Expand Down
8 changes: 7 additions & 1 deletion fakes/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class UART(object):
See https://docs.micropython.org/en/latest/library/machine.UART.html
"""
# ESP32: TX=32, RX=4
# RP2: TX=1, RX=2
INV_RX = 4
INV_TX = 32

def __init__(self,
uart_id: int,
baudrate: int = 9600,
Expand All @@ -35,7 +40,8 @@ def __init__(self,
stop: int = 1,
tx: int = 1,
rx: int = 2,
timeout: int = 0) -> None:
timeout: int = 0,
invert: int = 0) -> None:
self._uart_id = uart_id
if timeout == 0:
timeout = 5.0
Expand Down
16 changes: 10 additions & 6 deletions umodbus/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@


class ModbusRTU(Modbus):
INV_RX = UART.INV_RX # Include in class so they can be used when creating the object
# Include in class so they can be used when creating the object
INV_RX = UART.INV_RX
INV_TX = UART.INV_TX

"""
Modbus RTU client class
Expand Down Expand Up @@ -61,7 +62,7 @@ def __init__(self,
pins: List[Union[int, Pin], Union[int, Pin]] = None,
ctrl_pin: int = None,
uart_id: int = 1,
invert: int = None):
invert: int = 0):
super().__init__(
# set itf to Serial object, addr_list to [addr]
Serial(uart_id=uart_id,
Expand All @@ -77,9 +78,10 @@ def __init__(self,


class Serial(CommonModbusFunctions):
INV_RX = UART.INV_RX # Include in class so they can be used when creating the object
# Include in class so they can be used when creating the object
INV_RX = UART.INV_RX
INV_TX = UART.INV_TX

def __init__(self,
uart_id: int = 1,
baudrate: int = 9600,
Expand All @@ -88,7 +90,7 @@ def __init__(self,
parity=None,
pins: List[Union[int, Pin], Union[int, Pin]] = None,
ctrl_pin: int = None,
invert: int = None):
invert: int = 0):
"""
Setup Serial/RTU Modbus
Expand All @@ -106,6 +108,8 @@ def __init__(self,
:type pins: List[Union[int, Pin], Union[int, Pin]]
:param ctrl_pin: The control pin
:type ctrl_pin: int
:param invert: Invert TX and/or RX pins
:type invert: int
"""
# UART flush function is introduced in Micropython v1.20.0
self._has_uart_flush = callable(getattr(UART, "flush", None))
Expand Down

0 comments on commit 324aa1a

Please sign in to comment.