@@ -18,41 +18,42 @@ def test_query():
1818 # forge our own command, to control the output
1919 cmd = OBDCommand ("" , "" , "01" , "23" , 2 , noop )
2020
21- # forge IO from the car by overwriting the get/send functions
21+ # forge IO from the car by overwriting the read/write functions
2222
2323 # buffers
2424 toCar = ["" ] # needs to be inside mutable object to allow assignment in closure
2525 fromCar = ""
2626
27- def send (cmd ):
27+ def write (cmd ):
2828 toCar [0 ] = cmd
2929
3030 o .is_connected = lambda * args : True
31- o .port .send = send
32- o .port .get = lambda * args : fromCar
31+ o .port .port = True
32+ o .port ._OBDPort__write = write
33+ o .port ._OBDPort__read = lambda * args : fromCar
3334
34- # make sure unsupported commands don't send
35- fromCar = "41 23 AB CD\r \r "
35+ # make sure unsupported commands don't write
36+ fromCar = "48 6B 10 41 23 AB CD\r \r "
3637 r = o .query (cmd )
3738 assert toCar [0 ] == ""
3839 assert r .is_null ()
3940
4041 # a correct command transaction
41- fromCar = "41 23 AB CD\r \r " # preset the response
42+ fromCar = "48 6B 10 41 23 AB CD\r \r " # preset the response
4243 r = o .query (cmd , force = True ) # run
4344 assert toCar [0 ] == "0123" # verify that the command was sent correctly
4445 assert r .raw_data == fromCar # verify that raw_data was stored in the Response
4546 assert r .value == "ABCD" # verify that the response was parsed correctly
4647
4748 # response of greater length
48- fromCar = "41 23 AB CD EF\r \r "
49+ fromCar = "48 6B 10 41 23 AB CD EF\r \r "
4950 r = o .query (cmd , force = True )
5051 assert toCar [0 ] == "0123"
5152 assert r .raw_data == fromCar
5253 assert r .value == "ABCD"
5354
5455 # response of greater length
55- fromCar = "41 23 AB\r \r "
56+ fromCar = "48 6B 10 41 23 AB\r \r "
5657 r = o .query (cmd , force = True )
5758 assert toCar [0 ] == "0123"
5859 assert r .raw_data == fromCar
0 commit comments