26
26
27
27
28
28
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
30
31
INV_TX = UART .INV_TX
31
-
32
+
32
33
"""
33
34
Modbus RTU client class
34
35
@@ -61,7 +62,7 @@ def __init__(self,
61
62
pins : List [Union [int , Pin ], Union [int , Pin ]] = None ,
62
63
ctrl_pin : int = None ,
63
64
uart_id : int = 1 ,
64
- invert : int = None ):
65
+ invert : int = 0 ):
65
66
super ().__init__ (
66
67
# set itf to Serial object, addr_list to [addr]
67
68
Serial (uart_id = uart_id ,
@@ -77,9 +78,10 @@ def __init__(self,
77
78
78
79
79
80
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
81
83
INV_TX = UART .INV_TX
82
-
84
+
83
85
def __init__ (self ,
84
86
uart_id : int = 1 ,
85
87
baudrate : int = 9600 ,
@@ -88,7 +90,7 @@ def __init__(self,
88
90
parity = None ,
89
91
pins : List [Union [int , Pin ], Union [int , Pin ]] = None ,
90
92
ctrl_pin : int = None ,
91
- invert : int = None ):
93
+ invert : int = 0 ):
92
94
"""
93
95
Setup Serial/RTU Modbus
94
96
@@ -106,6 +108,8 @@ def __init__(self,
106
108
:type pins: List[Union[int, Pin], Union[int, Pin]]
107
109
:param ctrl_pin: The control pin
108
110
:type ctrl_pin: int
111
+ :param invert: Invert TX and/or RX pins
112
+ :type invert: int
109
113
"""
110
114
# UART flush function is introduced in Micropython v1.20.0
111
115
self ._has_uart_flush = callable (getattr (UART , "flush" , None ))
0 commit comments