Exemplo n.º 1
0
# Interface for communication
CanSocket_communication = CANSocket(scan_interface)

# Keep ECU awake
if keep_awake:
    CanSocket_keep_awake = CANSocket(awake_interface)
    awake_thread = isotpscan.KeepAwakeThread(CanSocket_keep_awake, dummy_pkt)
    awake_thread.start()

# Listen for default messages on CAN-bus
print("Filtering background noise...")
CanSocket_communication.sniff(
    prn=get_background_noise_callback,
    timeout=noise_listen_time,
    started_callback=lambda: CanSocket_communication.send(dummy_pkt))

# delete duplicates
noise_IDs = list(set(noise_IDs))

# scan normal ID's
if not extended_only:
    # Build random ISOTP-FirstFrame Packet
    pkt = get_isotp_packet()

    print("Start scan (" + hex(min_ID) + " - " + hex(max_ID) + ")")

    isotpscan.scan(found_packets, CanSocket_communication,
                   range(min_ID, (max_ID + 1)), pkt, noise_IDs)

# scan extended ID's
Exemplo n.º 2
0
# Interface
CanSocket_communication = CANSocket("can1")

# Keep ECU awake
if awake_interface:
    CanSocket_keep_awake = CANSocket("can0")
    awake_thread = keep_awake_thread(dummy_pkt)
    awake_thread.start()

# Listen for default messages on CAN-bus
print("Filtering background noise...")
CanSocket_communication.sniff(prn=get_background_noise,
                              timeout=noise_listen_time,
                              started_callback=lambda:
                              CanSocket_communication.send(dummy_pkt))

# scan with normal ID's
if not extended_only:
    # Build random ISOTP-FirstFrame Packet
    pkt = ISOTPHeader() / ISOTP_FF()
    pkt.identifier = 0x0
    pkt.message_size = 100
    pkt.data = b'\x00\x00\x00\x00\x00\x00'
    print("Start scan (" + hex(min_ID) + " - " + hex(max_ID) + ")")

    scan(min_ID, max_ID, pkt)

# scan with extended ID's
if extended or extended_only:
    pkt = ISOTPHeaderEA() / ISOTP_FF()