[Python] python-can Notifier with PCAN-USB drops frames, causing UDS (udsoncan/isotp) requests...

Discussão em 'Python' iniciado por Stack, Agosto 19, 2025.

  1. Stack

    Stack Membro Participativo

    I’m trying to run UDS over CAN using python-can, isotp, and udsoncan with a PCAN-USB interface. When I add a Notifier to log traffic to a BLF file, most of my UDS requests time out, even though the ECU responds (verified in an external CAN trace). Without the Notifier, everything works consistently.

    Expected behavior


    UDS requests (for example, tester_present) should succeed whether or not I use Notifier for BLF logging.

    Actual behavior


    • With Notifier: ~90% of requests time out.


    • Without Notifier: all requests succeed.


    • External CAN trace shows ECU always responds promptly → frames are sent but not delivered through Notifier to the UDS client.
    What I’ve tried


    • Adjusted udsoncan request timeout and Notifier timeout


    • Verified PCAN channel, bitrate, and filters


    • Tried BufferedReader, AsyncBufferedReader, and a custom polling loop → same issue


    • Manually polling with bus.recv() works consistently

    import can
    import isotp
    import udsoncan
    from udsoncan.connections import PythonIsoTpConnection
    from udsoncan.client import Client
    from udsoncan.exceptions import TimeoutException
    from udsoncan.configs import default_client_config

    bus = can.interface.Bus(
    bustype="pcan",
    channel="PCAN_USBBUS1",
    bitrate=500000
    )

    isotp_params = {
    'stmin': 5,
    'blocksize': 40,
    'wftmax': 0,
    'tx_data_length': 8,
    'tx_padding': 0x55,
    'rx_flowcontrol_timeout': 5000,
    'rx_consecutive_frame_timeout': 1000,
    'max_frame_size': 4095,
    'can_fd': False
    }

    addr = isotp.Address(isotp.AddressingMode.Normal_11bits, txid=0x7E0, rxid=0x7E8)
    stack = isotp.CanStack(bus=bus, address=addr, error_handler=None, params=isotp_params)

    final_filename = "log_file.blf"
    logger = can.BLFWriter(final_filename)
    notifier = can.Notifier(bus, [logger])

    conn = PythonIsoTpConnection(stack)
    with Client(conn, request_timeout=2, config=default_client_config) as client:
    try:
    response = client.tester_present() # 3E 00
    print("Response:", response)
    except TimeoutException:
    print("UDS request timed out!")

    Continue reading...

Compartilhe esta Página