args = parser.parse_args() try: check_output(["pidof", "boardd"]) print("boardd is running, please kill openpilot before running this script! (aborted)") sys.exit(1) except CalledProcessError as e: if e.returncode != 1: # 1 == no process found (boardd not running) raise e confirm = input("power on the vehicle keeping the engine off (press start button twice) then type OK to continue: ").upper().strip() if confirm != "OK": print("\nyou didn't type 'OK! (aborted)") sys.exit(0) panda = Panda() # type: ignore panda.set_safety_mode(Panda.SAFETY_ELM327) uds_client = UdsClient(panda, 0x7D0, bus=args.bus, debug=args.debug) print("\n[START DIAGNOSTIC SESSION]") session_type : SESSION_TYPE = 0x07 # type: ignore uds_client.diagnostic_session_control(session_type) print("[HARDWARE/SOFTWARE VERSION]") fw_version_data_id : DATA_IDENTIFIER_TYPE = 0xf100 # type: ignore fw_version = uds_client.read_data_by_identifier(fw_version_data_id) print(fw_version) if fw_version not in SUPPORTED_FW_VERSIONS.keys(): print("radar not supported! (aborted)") sys.exit(1)
print( "boardd is running, please kill openpilot before running this script! (aborted)" ) sys.exit(1) except CalledProcessError as e: if e.returncode != 1: # 1 == no process found (boardd not running) raise e confirm = input( "power on the vehicle keeping the engine off (press start button twice) then type OK to continue: " ).upper().strip() if confirm != "OK": print("\nyou didn't type 'OK! (aborted)") sys.exit(0) panda = Panda() panda.set_safety_mode(Panda.SAFETY_ELM327) uds_client = UdsClient(panda, 0x7D0, bus=args.bus, debug=args.debug) print("\n[START DIAGNOSTIC SESSION]") session_type: SESSION_TYPE = 0x07 # type: ignore uds_client.diagnostic_session_control(session_type) print("[HARDWARE/SOFTWARE VERSION]") fw_version_data_id: DATA_IDENTIFIER_TYPE = 0xf100 # type: ignore fw_version = uds_client.read_data_by_identifier(fw_version_data_id) print(fw_version) if fw_version not in SUPPORTED_FW_VERSIONS.keys(): print("radar not supported! (aborted)") sys.exit(1)
return max_num_bytes # max number of bytes per transfer data request def transfer_data(address, block_sequence_count, data=''): data = chr(block_sequence_count)+data resp = _uds_request(address, SERVICE_TYPE.TRANSFER_DATA, subfunction=None, data=data) resp_id = resp[0] if len(resp) > 0 else None if resp_id != block_sequence_count: raise ValueError('invalid block_sequence_count: {}'.format(resp_id)) return resp[1:] def request_transfer_exit(address): _uds_request(address, SERVICE_TYPE.REQUEST_TRANSFER_EXIT, subfunction=None) if __name__ == "__main__": from panda.python import Panda panda = Panda() bus = 1 tx_addr = 0x641 # tesla bosch radar RCM addr 0x18da30f1 # EPS tx_queue = Queue() rx_queue = Queue() can_reader_t = threading.Thread(target=_isotp_thread, args=(panda, bus, tx_addr, tx_queue, rx_queue)) can_reader_t.daemon = True can_reader_t.start() # examples print("tester present ...") tester_present(tx_addr) print("extended diagnostic session ...") diagnostic_session_control(tx_addr, SESSION_TYPE.EXTENDED_DIAGNOSTIC) print("reading VIN from radar...") vin = read_data_by_identifier(tx_addr, DATA_IDENTIFIER_TYPE.VIN)
#!/usr/bin/env python3 import time from panda.python import Panda from hyundai import HyundaiInputOutputController BUS = 0 # must be C-CAN bus for Honda p = Panda() ioc = HyundaiInputOutputController(lambda addr, dat: p.can_send(addr, dat, BUS)) print("surround view ...") ioc.surround_view_rear_wide(True) time.sleep(10) ioc.surround_view_rear_wide(False)