From 2a8c2c21c41c21b99908635ba35927750e28cff2 Mon Sep 17 00:00:00 2001 From: AllWashedOut <40281893+AllWashedOut@users.noreply.github.com> Date: Thu, 14 Jun 2018 17:48:31 -0700 Subject: [PATCH 1/2] Strengthen VIN detection Replaces a counter with a check of the dictionary contents to work around a potential bug: if the same VIN piece were received twice, it would still have incremented the counter. --- examples/tesla_tester.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/tesla_tester.py b/examples/tesla_tester.py index b2cbb4d789e18d..f61d62845b308f 100644 --- a/examples/tesla_tester.py +++ b/examples/tesla_tester.py @@ -41,7 +41,6 @@ def tesla_tester(): print("Reading VIN from 0x568. This is painfully slow and can take up to 3 minutes (1 minute per message; 3 messages needed for full VIN)...") - cnt = 0 vin = {} while True: #Read the VIN @@ -53,11 +52,10 @@ def tesla_tester(): vin_string = binascii.hexlify(dat)[2:] #rest of the string is the actual VIN data vin[vin_index] = vin_string.decode("hex") print("Got VIN index " + str(vin_index) + " data " + vin[vin_index]) - cnt += 1 #if we have all 3 parts of the VIN, print it and break out of our while loop - if cnt == 3: + if 0 in vin and 1 in vin and 2 in vin: print("VIN: " + vin[0] + vin[1] + vin[2][:3]) break if __name__ == "__main__": - tesla_tester() \ No newline at end of file + tesla_tester() From d8fc9ff4e802b0ef55ced53c78c4aed355bf223f Mon Sep 17 00:00:00 2001 From: AllWashedOut <40281893+AllWashedOut@users.noreply.github.com> Date: Fri, 15 Jun 2018 12:54:37 -0700 Subject: [PATCH 2/2] Update tesla_tester.py --- examples/tesla_tester.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tesla_tester.py b/examples/tesla_tester.py index f61d62845b308f..99d8d92854423b 100644 --- a/examples/tesla_tester.py +++ b/examples/tesla_tester.py @@ -29,11 +29,11 @@ def tesla_tester(): # BDY 0x248 is the MCU_commands message, which includes folding mirrors, opening the trunk, frunk, setting the cars lock state and more. For our test, we will edit the 3rd byte, which is MCU_lockRequest. 0x01 will lock, 0x02 will unlock: print("Unlocking Tesla...") - p.can_send(0x248, "\x00\x00\x02\x00\x00\x00\x00\x00", bus_num) + p.can_send(0x248, "\x00\x00\x02\x00\x00\x00\x00\x00", body_bus_num) #Or, we can set the first byte, MCU_frontHoodCommand + MCU_liftgateSwitch, to 0x01 to pop the frunk, or 0x04 to open/close the trunk (0x05 should open both) print("Opening Frunk...") - p.can_send(0x248, "\x01\x00\x00\x00\x00\x00\x00\x00", bus_num) + p.can_send(0x248, "\x01\x00\x00\x00\x00\x00\x00\x00", body_bus_num) #Back to safety... print("Disabling output on Panda...")