@@ -44,9 +44,9 @@ async def start_async_test(client):
4444 # which defaults to `0x00`
4545 # ----------------------------------------------------------------------- #
4646 try :
47- # ----------------------------------------------------------------------- #
47+ # ----------------------------------------------------------------------- #
4848 # example requests
49- # ----------------------------------------------------------------------- #
49+ # ----------------------------------------------------------------------- #
5050 # simply call the methods that you would like to use.
5151 # An example session is displayed below along with some assert checks.
5252 # Note that some modbus implementations differentiate holding/
@@ -56,32 +56,32 @@ async def start_async_test(client):
5656 # so a change to one is a change to the other.
5757 # Keep both of these cases in mind when testing as the following will
5858 # _only_ pass with the supplied asynchronous modbus server (script supplied).
59- # ----------------------------------------------------------------------- #
59+ # ----------------------------------------------------------------------- #
6060 log .debug ("Write to a Coil and read back" )
6161 rq = await client .write_coil (0 , True , unit = UNIT )
6262 rr = await client .read_coils (0 , 1 , unit = UNIT )
6363 assert (rq .function_code < 0x80 ) # test that we are not an error
64- assert (rr .bits [0 ] == True ) # test the expected value
64+ assert (rr .bits [0 ]) # test the expected value
6565
6666 log .debug ("Write to multiple coils and read back- test 1" )
67- rq = await client .write_coils (1 , [True ]* 8 , unit = UNIT )
67+ rq = await client .write_coils (1 , [True ] * 8 , unit = UNIT )
6868 assert (rq .function_code < 0x80 ) # test that we are not an error
6969 rr = await client .read_coils (1 , 21 , unit = UNIT )
7070 assert (rr .function_code < 0x80 ) # test that we are not an error
71- resp = [True ]* 21
71+ resp = [True ] * 21
7272
7373 # If the returned output quantity is not a multiple of eight,
7474 # the remaining bits in the final data byte will be padded with zeros
7575 # (toward the high order end of the byte).
7676
77- resp .extend ([False ]* 3 )
77+ resp .extend ([False ] * 3 )
7878 assert (rr .bits == resp ) # test the expected value
7979
8080 log .debug ("Write to multiple coils and read back - test 2" )
81- rq = await client .write_coils (1 , [False ]* 8 , unit = UNIT )
81+ rq = await client .write_coils (1 , [False ] * 8 , unit = UNIT )
8282 rr = await client .read_coils (1 , 8 , unit = UNIT )
8383 assert (rq .function_code < 0x80 ) # test that we are not an error
84- assert (rr .bits == [False ]* 8 ) # test the expected value
84+ assert (rr .bits == [False ] * 8 ) # test the expected value
8585
8686 log .debug ("Read discrete inputs" )
8787 rr = await client .read_discrete_inputs (0 , 8 , unit = UNIT )
@@ -94,27 +94,27 @@ async def start_async_test(client):
9494 assert (rr .registers [0 ] == 10 ) # test the expected value
9595
9696 log .debug ("Write to multiple holding registers and read back" )
97- rq = await client .write_registers (1 , [10 ]* 8 , unit = UNIT )
97+ rq = await client .write_registers (1 , [10 ] * 8 , unit = UNIT )
9898 rr = await client .read_holding_registers (1 , 8 , unit = UNIT )
9999 assert (rq .function_code < 0x80 ) # test that we are not an error
100- assert (rr .registers == [10 ]* 8 ) # test the expected value
100+ assert (rr .registers == [10 ] * 8 ) # test the expected value
101101
102102 log .debug ("Read input registers" )
103103 rr = await client .read_input_registers (1 , 8 , unit = UNIT )
104104 assert (rq .function_code < 0x80 ) # test that we are not an error
105105
106106 arguments = {
107- 'read_address' : 1 ,
108- 'read_count' : 8 ,
109- 'write_address' : 1 ,
110- 'write_registers' : [20 ]* 8 ,
107+ 'read_address' : 1 ,
108+ 'read_count' : 8 ,
109+ 'write_address' : 1 ,
110+ 'write_registers' : [20 ] * 8 ,
111111 }
112112 log .debug ("Read write registers simulataneously" )
113113 rq = await client .readwrite_registers (unit = UNIT , ** arguments )
114114 rr = await client .read_holding_registers (1 , 8 , unit = UNIT )
115115 assert (rq .function_code < 0x80 ) # test that we are not an error
116- assert (rq .registers == [20 ]* 8 ) # test the expected value
117- assert (rr .registers == [20 ]* 8 ) # test the expected value
116+ assert (rq .registers == [20 ] * 8 ) # test the expected value
117+ assert (rr .registers == [20 ] * 8 ) # test the expected value
118118 except Exception as e :
119119 log .exception (e )
120120 client .transport .close ()
@@ -132,4 +132,3 @@ async def start_async_test(client):
132132 baudrate = 9600 , method = "rtu" )
133133 loop .run_until_complete (start_async_test (client .protocol ))
134134 loop .close ()
135-
0 commit comments