1
- """ A basic client demonstrating how to use the async version of pysolarmanv5."""
1
+ """A basic client demonstrating how to use the async version of pysolarmanv5."""
2
+
2
3
from pysolarmanv5 import PySolarmanV5Async
3
4
import asyncio
4
5
@@ -11,7 +12,12 @@ async def main():
11
12
respectively.
12
13
"""
13
14
modbus = PySolarmanV5Async (
14
- '192.168.1.121' , 1234567890 , port = 8899 , mb_slave_id = 1 , verbose = False , auto_reconnect = True
15
+ "192.168.1.121" ,
16
+ 1234567890 ,
17
+ port = 8899 ,
18
+ mb_slave_id = 1 ,
19
+ verbose = False ,
20
+ auto_reconnect = True ,
15
21
)
16
22
await modbus .connect ()
17
23
@@ -27,15 +33,18 @@ async def main():
27
33
"""Query single input register, apply scaling, result as a float"""
28
34
29
35
print (
30
- await modbus .read_input_register_formatted (register_addr = 33035 , quantity = 1 , scale = 0.1 )
36
+ await modbus .read_input_register_formatted (
37
+ register_addr = 33035 , quantity = 1 , scale = 0.1
38
+ )
31
39
)
32
40
33
41
"""Query two input registers, shift first register up by 16 bits, result as a signed int, """
34
42
print (
35
- await modbus .read_input_register_formatted (register_addr = 33079 , quantity = 2 , signed = 1 )
43
+ await modbus .read_input_register_formatted (
44
+ register_addr = 33079 , quantity = 2 , signed = 1
45
+ )
36
46
)
37
47
38
-
39
48
"""Query single holding register, apply bitmask and bitshift left (extract bit1 from register)"""
40
49
print (
41
50
await modbus .read_holding_register_formatted (
@@ -45,5 +54,6 @@ async def main():
45
54
46
55
await modbus .disconnect ()
47
56
57
+
48
58
if __name__ == "__main__" :
49
59
asyncio .run (main ())
0 commit comments