two spaces before inline comment

master
Adeeb Shihadeh 2020-05-31 14:07:01 -07:00
parent 49ffbe99f6
commit 9102c16118
14 changed files with 162 additions and 162 deletions

View File

@ -47,9 +47,9 @@ def tesla_tester():
can_recv = p.can_recv()
for address, _, dat, src in can_recv:
if src == body_bus_num:
if address == 1384: #0x568 is VIN
vin_index = int(binascii.hexlify(dat)[:2]) #first byte is the index, 00, 01, 02
vin_string = binascii.hexlify(dat)[2:] #rest of the string is the actual VIN data
if address == 1384: # 0x568 is VIN
vin_index = int(binascii.hexlify(dat)[:2]) # first byte is the index, 00, 01, 02
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])
#if we have all 3 parts of the VIN, print it and break out of our while loop

View File

@ -200,7 +200,7 @@ class Panda(object):
traceback.print_exc()
if wait == False or self._handle != None:
break
context = usb1.USBContext() #New context needed so new devices show up
context = usb1.USBContext() # New context needed so new devices show up
assert(self._handle != None)
print("connected")

View File

@ -41,7 +41,7 @@ def test_udp_doesnt_drop(serials=None):
sys.stdout.flush()
else:
print("UDP WIFI loopback %d messages at speed %d, comp speed is %.2f, percent %.2f" % (msg_count, speed, comp_kbps, saturation_pct))
assert_greater(saturation_pct, 20) #sometimes the wifi can be slow...
assert_greater(saturation_pct, 20) # sometimes the wifi can be slow...
assert_less(saturation_pct, 100)
saturation_pcts.append(saturation_pct)
if len(saturation_pcts) > 0:

View File

@ -100,7 +100,7 @@ class ELMCarSimulator():
continue
if len(lin_buff) < msglen + 4: continue
if lin_checksum(lin_buff[:-1]) != lin_buff[-1]: continue
self.__lin_process_msg(lin_buff[0] & 0xF8, #Priority
self.__lin_process_msg(lin_buff[0] & 0xF8, # Priority
lin_buff[1], lin_buff[2], lin_buff[3:-1])
lin_buff = bytearray()
@ -261,9 +261,9 @@ class ELMCarSimulator():
def _process_obd(self, mode, pid):
if mode == 0x01: # Mode: Show current data
if pid == 0x00: #List supported things
return b"\xff\xff\xff\xfe"#b"\xBE\x1F\xB8\x10" #Bitfield, random features
return b"\xff\xff\xff\xfe" # b"\xBE\x1F\xB8\x10" #Bitfield, random features
elif pid == 0x01: # Monitor Status since DTC cleared
return b"\x00\x00\x00\x00" #Bitfield, random features
return b"\x00\x00\x00\x00" # Bitfield, random features
elif pid == 0x04: # Calculated engine load
return b"\x2f"
elif pid == 0x05: # Engine coolant temperature

View File

@ -35,7 +35,7 @@ def send_compare(s, dat, ret, timeout=4):
break;
res += s.recv(1000)
#print("final recv data: '%s'" % repr(res))
assert ret == res#, "Data does not agree (%s) (%s)"%(repr(ret), repr(res))
assert ret == res # , "Data does not agree (%s) (%s)"%(repr(ret), repr(res))
def sync_reset(s):
s.send("ATZ\r")
@ -63,7 +63,7 @@ def test_elm_cli():
#Test Echo Off
#Expected to be misimplimentation, but this is how the reference device behaved.
send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') #Here is the odd part
send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Here is the odd part
send_compare(s, b'ATE0\r', b'OK\r\r>') #Should prob show this immediately
send_compare(s, b'ATI\r', b'ELM327 v1.5\r\r>')
@ -73,17 +73,17 @@ def test_elm_cli():
send_compare(s, b'ATL0\r', b'OK\r\r>')
send_compare(s, b'ATI\r', b'ELM327 v1.5\r\r>')
send_compare(s, b'ATI\r', b'ELM327 v1.5\r\r>') #Test repeat command no echo
send_compare(s, b'ATI\r', b'ELM327 v1.5\r\r>') # Test repeat command no echo
send_compare(s, b'\r', b'ELM327 v1.5\r\r>')
send_compare(s, b'aTi\r', b'ELM327 v1.5\r\r>') #Test different case
send_compare(s, b'aTi\r', b'ELM327 v1.5\r\r>') # Test different case
send_compare(s, b' a T i\r', b'ELM327 v1.5\r\r>') #Test with white space
send_compare(s, b' a T i\r', b'ELM327 v1.5\r\r>') # Test with white space
send_compare(s, b'ATCATHAT\r', b'?\r\r>') #Test Invalid AT command
send_compare(s, b'ATCATHAT\r', b'?\r\r>') # Test Invalid AT command
send_compare(s, b'01 00 00 00 00 00 00 00\r', b'?\r\r>') #Test Invalid (too long) OBD command
send_compare(s, b'01 GZ\r', b'?\r\r>') #Test Invalid (Non hex chars) OBD command
send_compare(s, b'01 00 00 00 00 00 00 00\r', b'?\r\r>') # Test Invalid (too long) OBD command
send_compare(s, b'01 GZ\r', b'?\r\r>') # Test Invalid (Non hex chars) OBD command
finally:
s.close()
@ -108,7 +108,7 @@ def test_elm_setget_protocol():
send_compare(s, b'ATSP7\r', b"OK\r\r>")
send_compare(s, b'ATDP\r', b"ISO 15765-4 (CAN 29/500)\r\r>")
send_compare(s, b'ATDPN\r', b"7\r\r>") #Test Does not accept invalid protocols
send_compare(s, b'ATDPN\r', b"7\r\r>") # Test Does not accept invalid protocols
send_compare(s, b'ATSPD\r', b"?\r\r>")
send_compare(s, b'ATDP\r', b"ISO 15765-4 (CAN 29/500)\r\r>")
send_compare(s, b'ATDPN\r', b"7\r\r>")
@ -166,7 +166,7 @@ def test_elm_protocol_failure():
def test_elm_protocol_autodetect_ISO14230_KWP_FAST():
s = elm_connect()
serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None
sim = elm_car_simulator.ELMCarSimulator(serial, can=False)#, silent=True)
sim = elm_car_simulator.ELMCarSimulator(serial, can=False) # , silent=True)
sim.start()
try:
@ -186,7 +186,7 @@ def test_elm_protocol_autodetect_ISO14230_KWP_FAST():
def test_elm_basic_send_lin():
s = elm_connect()
serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None
sim = elm_car_simulator.ELMCarSimulator(serial, can=False)#, silent=True)
sim = elm_car_simulator.ELMCarSimulator(serial, can=False) # , silent=True)
sim.start()
try:
@ -332,13 +332,13 @@ def test_elm_panda_safety_mode_KWPFast():
return False
return timed_recv_check(p_car, bus, msgout)
assert not did_send(0xC0, 0x33, 0xF1, b'\x01\x0F', bus=3) #wrong bus
assert not did_send(0xC0, 0x33, 0xF1, b'') #wrong length
assert not did_send(0xB0, 0x33, 0xF1, b'\x01\x0E') #bad priority
assert not did_send(0xC0, 0x00, 0xF1, b'\x01\x0D') #bad addr
assert not did_send(0xC0, 0x33, 0x00, b'\x01\x0C') #bad addr
assert not did_send(0xC0, 0x33, 0xF1, b'\x01\x0F', bus=3) # wrong bus
assert not did_send(0xC0, 0x33, 0xF1, b'') # wrong length
assert not did_send(0xB0, 0x33, 0xF1, b'\x01\x0E') # bad priority
assert not did_send(0xC0, 0x00, 0xF1, b'\x01\x0D') # bad addr
assert not did_send(0xC0, 0x33, 0x00, b'\x01\x0C') # bad addr
assert did_send(0xC0, 0x33, 0xF1, b'\x01\x0B') #good! (obd func req)
assert did_send(0xC0, 0x33, 0xF1, b'\x01\x0B') # good! (obd func req)
def test_elm_lin_keepalive():
s = elm_connect()
@ -358,7 +358,7 @@ def test_elm_lin_keepalive():
time.sleep(6)
assert sim.lin_active
send_compare(s, b'ATPC\r', b"OK\r\r>") #STOP KEEPALIVE
send_compare(s, b'ATPC\r', b"OK\r\r>") # STOP KEEPALIVE
assert sim.lin_active
time.sleep(6)
assert not sim.lin_active
@ -456,7 +456,7 @@ def test_elm_send_can_multimsg():
send_compare(s, b'ATH1\r', b'OK\r\r>') # Headers ON
send_compare(s, b'ATSP6\r', b"OK\r\r>") # Set Proto ISO 15765-4 (CAN 11/500)
sim.can_add_extra_noise(b'\x03\x41\x0D\xFA', addr=0x7E9)# Inject message into the stream
sim.can_add_extra_noise(b'\x03\x41\x0D\xFA', addr=0x7E9) # Inject message into the stream
send_compare(s, b'010D\r',
b"7E8 03 41 0D 53 \r"
b"7E9 03 41 0D FA \r\r>") # Check it was ignored.
@ -480,7 +480,7 @@ def test_elm_can_check_mode_pid():
send_compare(s, b'ATH0\r', b'OK\r\r>') # Headers OFF
send_compare(s, b'ATSP6\r', b"OK\r\r>") # Set Proto ISO 15765-4 (CAN 11/500)
sim.can_add_extra_noise(b'\x03\x41\x0E\xFA')# Inject message into the stream
sim.can_add_extra_noise(b'\x03\x41\x0E\xFA') # Inject message into the stream
send_compare(s, b'010D\r', b"410D53\r\r>") # Check it was ignored.
send_compare(s, b'0100\r', b"4100FFFFFFFE\r\r>") # Check it was ignored again.
finally:
@ -643,25 +643,25 @@ def test_elm_panda_safety_mode_ISO15765():
sync_reset(s) # Reset elm (which requests the ELM327 safety mode)
#29 bit
assert not did_send(p_elm, 0x18DB33F1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 1) #wrong canid
assert not did_send(p_elm, 0x18DB33F1, b'\x02\x01\x00', 0) #wrong length
assert not did_send(p_elm, 0x10000000, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr
assert not did_send(p_elm, 0x18DAF133, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr (phy addr)
assert not did_send(p_elm, 0x18DAF000, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr
assert not did_send(p_elm, 0x18DAF1F3, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr! (phys rsp to elm)
assert not did_send(p_elm, 0x18DB33F1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 1) # wrong canid
assert not did_send(p_elm, 0x18DB33F1, b'\x02\x01\x00', 0) # wrong length
assert not did_send(p_elm, 0x10000000, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) # bad addr
assert not did_send(p_elm, 0x18DAF133, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) # bad addr (phy addr)
assert not did_send(p_elm, 0x18DAF000, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) # bad addr
assert not did_send(p_elm, 0x18DAF1F3, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) # bad addr! (phys rsp to elm)
assert did_send(p_elm, 0x18DB33F1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #good! (obd func req)
assert did_send(p_elm, 0x18DA10F1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #good! (phys response)
assert did_send(p_elm, 0x18DB33F1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) # good! (obd func req)
assert did_send(p_elm, 0x18DA10F1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) # good! (phys response)
#11 bit
assert not did_send(p_elm, 0X7DF, b'\x02\x01\x00\x00\x00\x00\x00\x00', 1) #wrong canid
assert not did_send(p_elm, 0X7DF, b'\x02\x01\x00', 0) #wrong length
assert not did_send(p_elm, 0xAA, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr
assert not did_send(p_elm, 0x7DA, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr (phy addr)
assert not did_send(p_elm, 0x7E8, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #bad addr (sending 'response')
assert not did_send(p_elm, 0X7DF, b'\x02\x01\x00\x00\x00\x00\x00\x00', 1) # wrong canid
assert not did_send(p_elm, 0X7DF, b'\x02\x01\x00', 0) # wrong length
assert not did_send(p_elm, 0xAA, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) # bad addr
assert not did_send(p_elm, 0x7DA, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) # bad addr (phy addr)
assert not did_send(p_elm, 0x7E8, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) # bad addr (sending 'response')
assert did_send(p_elm, 0x7DF, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #good! (obd func req)
assert did_send(p_elm, 0x7E1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) #good! (phys response)
assert did_send(p_elm, 0x7DF, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) # good! (obd func req)
assert did_send(p_elm, 0x7E1, b'\x02\x01\x00\x00\x00\x00\x00\x00', 0) # good! (phys response)
finally:
s.close()