@@ -49,9 +49,9 @@ async def start_async_test(client):
4949 # which defaults to `0x00`
5050 # ----------------------------------------------------------------------- #
5151 try :
52- # ----------------------------------------------------------------------- #
52+ # ----------------------------------------------------------------------- #
5353 # example requests
54- # ----------------------------------------------------------------------- #
54+ # ----------------------------------------------------------------------- #
5555 # simply call the methods that you would like to use.
5656 # An example session is displayed below along with some assert checks.
5757 # Note that some modbus implementations differentiate holding/
@@ -61,32 +61,32 @@ async def start_async_test(client):
6161 # so a change to one is a change to the other.
6262 # Keep both of these cases in mind when testing as the following will
6363 # _only_ pass with the supplied asynchronous modbus server (script supplied).
64- # ----------------------------------------------------------------------- #
64+ # ----------------------------------------------------------------------- #
6565 log .debug ("Write to a Coil and read back" )
6666 rq = await client .write_coil (0 , True , unit = UNIT )
6767 rr = await client .read_coils (0 , 1 , unit = UNIT )
6868 assert (rq .function_code < 0x80 ) # test that we are not an error
69- assert (rr .bits [0 ] == True ) # test the expected value
69+ assert (rr .bits [0 ]) # test the expected value
7070
7171 log .debug ("Write to multiple coils and read back- test 1" )
72- rq = await client .write_coils (1 , [True ]* 8 , unit = UNIT )
72+ rq = await client .write_coils (1 , [True ] * 8 , unit = UNIT )
7373 assert (rq .function_code < 0x80 ) # test that we are not an error
7474 rr = await client .read_coils (1 , 21 , unit = UNIT )
7575 assert (rr .function_code < 0x80 ) # test that we are not an error
76- resp = [True ]* 21
76+ resp = [True ] * 21
7777
7878 # If the returned output quantity is not a multiple of eight,
7979 # the remaining bits in the final data byte will be padded with zeros
8080 # (toward the high order end of the byte).
8181
82- resp .extend ([False ]* 3 )
82+ resp .extend ([False ] * 3 )
8383 assert (rr .bits == resp ) # test the expected value
8484
8585 log .debug ("Write to multiple coils and read back - test 2" )
86- rq = await client .write_coils (1 , [False ]* 8 , unit = UNIT )
86+ rq = await client .write_coils (1 , [False ] * 8 , unit = UNIT )
8787 rr = await client .read_coils (1 , 8 , unit = UNIT )
8888 assert (rq .function_code < 0x80 ) # test that we are not an error
89- assert (rr .bits == [False ]* 8 ) # test the expected value
89+ assert (rr .bits == [False ] * 8 ) # test the expected value
9090
9191 log .debug ("Read discrete inputs" )
9292 rr = await client .read_discrete_inputs (0 , 8 , unit = UNIT )
@@ -99,27 +99,27 @@ async def start_async_test(client):
9999 assert (rr .registers [0 ] == 10 ) # test the expected value
100100
101101 log .debug ("Write to multiple holding registers and read back" )
102- rq = await client .write_registers (1 , [10 ]* 8 , unit = UNIT )
102+ rq = await client .write_registers (1 , [10 ] * 8 , unit = UNIT )
103103 rr = await client .read_holding_registers (1 , 8 , unit = UNIT )
104104 assert (rq .function_code < 0x80 ) # test that we are not an error
105- assert (rr .registers == [10 ]* 8 ) # test the expected value
105+ assert (rr .registers == [10 ] * 8 ) # test the expected value
106106
107107 log .debug ("Read input registers" )
108108 rr = await client .read_input_registers (1 , 8 , unit = UNIT )
109109 assert (rq .function_code < 0x80 ) # test that we are not an error
110110
111111 arguments = {
112- 'read_address' : 1 ,
113- 'read_count' : 8 ,
114- 'write_address' : 1 ,
115- 'write_registers' : [20 ]* 8 ,
112+ 'read_address' : 1 ,
113+ 'read_count' : 8 ,
114+ 'write_address' : 1 ,
115+ 'write_registers' : [20 ] * 8 ,
116116 }
117117 log .debug ("Read write registers simulataneously" )
118118 rq = await client .readwrite_registers (unit = UNIT , ** arguments )
119119 rr = await client .read_holding_registers (1 , 8 , unit = UNIT )
120120 assert (rq .function_code < 0x80 ) # test that we are not an error
121- assert (rq .registers == [20 ]* 8 ) # test the expected value
122- assert (rr .registers == [20 ]* 8 ) # test the expected value
121+ assert (rq .registers == [20 ] * 8 ) # test the expected value
122+ assert (rr .registers == [20 ] * 8 ) # test the expected value
123123 except Exception as e :
124124 log .exception (e )
125125 client .transport .close ()
@@ -137,4 +137,3 @@ async def start_async_test(client):
137137 baudrate = 9600 , method = "rtu" )
138138 loop .run_until_complete (start_async_test (client .protocol ))
139139 loop .close ()
140-
0 commit comments