def do_test(filename=None):
    elm = create_test_elm(filename)
    try:
        elm.open()
        elm.set_protocol(None)
        elm.connect_to_vehicle()
    except Exception as e:
        unexpected_error(e)
        # if the connection fails, everything else will too
        return

    global dtc_count
    dtc_count = 0

    read_all_supported_pids(elm, 0x01)

    if dtc_count:
        try:
            responses = elm.send_request(OBDRequest(sid=0x03))
            for r in responses:
                print "%s: %s" % (r.bus_message.header, str(r))
        except obd.exception.DataError:
            pass
        except Exception as e:
            unexpected_error(e)

    read_all_supported_pids(elm, 0x09)

    return
示例#2
0
def read_all_supported_pids(elm, sid):

    for pid_support in range(0x00, 0x100, 0x20):
        time.sleep(DELAY)
        supported_pids = get_supported_pids(elm, sid, pid_support)

        # issue individual requests
        for pid in supported_pids:
            if pid == pid_support + 0x20:
                # fetched next time through outer loop
                break

            try:
                time.sleep(DELAY)
                responses = elm.send_request(OBDRequest(sid=sid, pid=pid))
                #print "got response for sid=$%02X pid=$%02X" % (sid, pid)
            except obd.exception.DataError:
                print "no response to sid=$%02X pid=$%02X" % (sid, pid)
                continue
            except Exception as e:
                unexpected_error(e)
                continue

            for r in responses:
                print "%s: %s" % (r.bus_message.header, str(r))

        if pid_support + 0x20 not in supported_pids:
            # stop if no higher pid_support queries are supported
            break
    return
def do_test(filename=None):
    elm = create_test_elm(filename)
    try:
        elm.open()
        elm.set_protocol(None)
        elm.connect_to_vehicle()
    except Exception as e:
        unexpected_error(e)
        # if the connection fails, everything else will too
        return

    global dtc_count
    dtc_count = 0

    read_all_supported_pids(elm, 0x01)

    if dtc_count:
        try:
            responses = elm.send_request(OBDRequest(sid=0x03))
            for r in responses:
                print "%s: %s" % (r.bus_message.header, str(r))
        except obd.exception.DataError:
            pass
        except Exception as e:
            unexpected_error(e)

    read_all_supported_pids(elm, 0x09)

    return
示例#4
0
def do_test(filename=None):
    elm = create_test_elm(filename)
    try:
        query_vehicle(elm)
    except obd.exception.ConnectionError as e:
        unexpected_error(e)
    return
示例#5
0
def read_all_supported_pids(elm, sid):

    for pid_support in range(0x00, 0x100, 0x20):
        time.sleep(DELAY)
        supported_pids = get_supported_pids(elm, sid, pid_support)

        # issue individual requests
        for pid in supported_pids:
            if pid == pid_support + 0x20:
                # fetched next time through outer loop
                break

            try:
                time.sleep(DELAY)
                responses = elm.send_request(OBDRequest(sid=sid, pid=pid))
                #print "got response for sid=$%02X pid=$%02X" % (sid, pid)
            except obd.exception.DataError:
                print "no response to sid=$%02X pid=$%02X" % (sid, pid)
                continue
            except Exception as e:
                unexpected_error(e)
                continue

            for r in responses:
                print "%s: %s" % (r.bus_message.header, str(r))

        if pid_support + 0x20 not in supported_pids:
            # stop if no higher pid_support queries are supported
            break
    return
def do_test(filename=None):
    elm = create_test_elm(filename)
    try:
        query_vehicle(elm)
    except obd.exception.ConnectionError as e:
        unexpected_error(e)
    return
示例#7
0
def read_dtcs(elm, sid):
    try:
        responses = elm.send_request(OBDRequest(sid=sid))
        for r in responses:
            print "%s: %s" % (r.bus_message.header, str(r))
    except obd.exception.DataError:
        pass
    except Exception as e:
        unexpected_error(e)
    return
示例#8
0
def read_dtcs(elm, sid):
    try:
        responses = elm.send_request(OBDRequest(sid=sid))
        for r in responses:
            print "%s: %s" % (r.bus_message.header, str(r))
    except obd.exception.DataError:
        pass
    except Exception as e:
        unexpected_error(e)
    return
def get_supported_pids(elm, sid, start_pid):
    # default to all in case the support query fails for some reason
    supported_pids = range(start_pid + 1, start_pid + 1 + 0x20)

    try:
        responses = elm.send_request(OBDRequest(sid=sid, pid=start_pid))
        support = responses[0]
        supported_pids = support.supported_pids
        pids = ",".join(["$%02X" % pid for pid in supported_pids])
        print "supported pids for sid=$%02X pid=$%02X: [%s]" % (sid, start_pid, pids)
        obd.util.debug(supported_pids)
    except obd.exception.DataError as e:
        print "unable to determine PID support for sid=$%02X pid=$%02X, assuming all supported" % (sid, start_pid)
        obd.util.debug(supported_pids)
    except Exception as e:
        unexpected_error(e)

    return supported_pids
示例#10
0
def get_supported_pids(elm, sid, start_pid):
    # default to all in case the support query fails for some reason
    supported_pids = range(start_pid + 1, start_pid + 1 + 0x20)

    try:
        responses = elm.send_request(OBDRequest(sid=sid, pid=start_pid))
        support = responses[0]
        supported_pids = support.supported_pids
        pids = ",".join(["$%02X" % pid for pid in supported_pids])
        print "supported pids for sid=$%02X pid=$%02X: [%s]" % (sid, start_pid, pids)
        obd.util.debug(supported_pids)
    except obd.exception.DataError as e:
        print "unable to determine PID support for sid=$%02X pid=$%02X, assuming none supported" % (sid, start_pid)
        supported_pids = []
        obd.util.debug(supported_pids)
    except Exception as e:
        unexpected_error(e)

    return supported_pids
示例#11
0
def do_test(filename=None):
    elm = create_test_elm(filename)
    try:
        elm.open()
        elm.set_protocol(None)
        elm.connect_to_vehicle()
    except Exception as e:
        unexpected_error(e)
        # if the connection fails, everything else will too
        return

    read_all_supported_pids(elm, 0x01)

    # Awaiting implementation of Service $02
    # frames = elm.get_frame_count()
    # for f in range(0, frames):
    #     elm.get_data(all_values, frame=f)

    read_dtcs(elm, 0x03)

    # skip Service $04 (resets DTCs)

    # Awaiting implementation of Service $05
    # O2 sensor locations appended to request
    # (legacy protocols only; not supported by ISO 15765)

    # Awaiting implementation of Service $06
    # legacy responses have a filler byte before the pid-supported
    # data
    read_all_supported_tests(elm, 0x06)

    read_dtcs(elm, 0x07)

    # Skip Service $08 (controls a physical test)

    read_all_supported_pids(elm, 0x09)

    read_dtcs(elm, 0x0A)
    return
示例#12
0
def do_test(filename=None):
    elm = create_test_elm(filename)
    try:
        elm.open()
        elm.set_protocol(None)
        elm.connect_to_vehicle()
    except Exception as e:
        unexpected_error(e)
        # if the connection fails, everything else will too
        return

    read_all_supported_pids(elm, 0x01)

    # Awaiting implementation of Service $02
    # frames = elm.get_frame_count()
    # for f in range(0, frames):
    #     elm.get_data(all_values, frame=f)

    read_dtcs(elm, 0x03)

    # skip Service $04 (resets DTCs)

    # Awaiting implementation of Service $05
    # O2 sensor locations appended to request
    # (legacy protocols only; not supported by ISO 15765)

    # Awaiting implementation of Service $06
    # legacy responses have a filler byte before the pid-supported
    # data
    read_all_supported_tests(elm, 0x06)

    read_dtcs(elm, 0x07)

    # Skip Service $08 (controls a physical test)

    read_all_supported_pids(elm, 0x09)

    read_dtcs(elm, 0x0A)
    return
示例#13
0
def test_enumerate():
    try:
        interfaces = obd.interface.enumerate()
    except Exception as e:
        unexpected_error(e)
    return