Exemplo n.º 1
0
 def UdsNegRequest(self, *cmd, desc=None):
     req_raw = list(cmd)
     self.diag.UpdateRawValue(req_raw)
     resp = PyUds.DiagResponse([0x7F, 0x11, 0x31])
     step_desc = 'Send Neg Request '
     ReportTest.UdsRawRequest.desc = step_desc
     return resp
Exemplo n.º 2
0
def main(args):
    global dtc_fault_config
    config = Scripts.UdsConfigParse('UdsConfig.json')
    bus = config.GetBus('CanBus1')
    diag = config.GetUdsDiag('CanUds', diag_cls='CmdUds')
    wake_msg = config.GetMessage('NMWeakUp')
    uds = TestUdsCom(diag, wake_msg, None)
    Cmds = {
        'uds': uds.UdsCmd,
    }
    with PyUds.ThreadSafety(bus):
        try:
            wake_msg.start()
            Cmds[args[0]](*args[1:])
        except UdsResponseError as ex:
            print(ex)
        except KeyError as ex:
            print(ex)
            print('Please input cmd in:', Cmds.keys())
        except TypeError as ex:
            print(ex)
            desc = '~~~~~~~~~~~~~~example~~~~~~~~~~~~~\n'
            desc += '  uds: enter diagnostic mode\n'
            print(desc)
        finally:
            wake_msg.stop()
Exemplo n.º 3
0
 def Frame_test(self):
     msg = PyUds.FrFrame(slot_id=77,
                         base_cycle=0,
                         repetition_cycle=2,
                         data=[0x00] * 32)
     step_desc = 'frmae send'
     __class__.Frame_test.desc = step_desc
     return msg
Exemplo n.º 4
0
def main(args):
    global dtc_fault_config
    global cdd_did_print
    try:
        config = Scripts.UdsConfigParse('UdsConfig.json')
        dtc_config_path = config.config['DTC'][0]['Path']
        cdd_did_path = config.config['Cdd']['Path']
        cdd_did_print = CddDidPrint(cdd_did_path)
        dtc_fault_config = DTCFaultConfigLoad(dtc_config_path)
        bus = config.GetBus('FrBus')
        bus_can = config.GetBus('CanBus')
        # diag = CmdUds(uds_client=config.GetUdsClient('CanPhy'))
        diag = config.GetUdsDiag('HX11', diag_cls='CmdUds')
        diag_can = config.GetUdsDiag('HX11_CAN', diag_cls='CmdUds')

        key_gen = config.GetKeyGens("HX11")
        wake_msg = config.GetMessage('NM_HX11')
        nm_can = config.GetMessage('NM_CAN')
        uds = GacUdsCom(diag, None, key_gen, bus=bus, diag_can=diag_can)
        Cmds = {
            "cleardtc": uds.GacClearDTC,
            'uds': uds.UdsCmdProcess,
            'dtc': uds.ReadDTCs,
            'fault': uds.ReadInternalFaults,
            'readalldid': uds.ReadAllDID
        }
    except Exception as e:
        cprint(e, fg='red', attrs='bold')
        return
    # bus.set_filters([0x14DA58F1,0x10DBFEF1,0x14DAF158])
    with PyUds.ThreadSafety(bus, bus_can):
        # PyUds.MessageLog.start(log_level=PyUds.log.LOG_WRITE_FILE_MASK)
        PyUds.MessageLog.start(log_level=0)
        try:
            wake_msg.start()
            nm_can.start()
            bus.wait(0.5)
            Cmds[args[0]](*args[1:])
        except UdsResponseError as ex:
            print(ex)
            traceback.print_exc()
        except KeyError as ex:
            print(ex)
            print('Please input cmd in:', Cmds.keys())
            traceback.print_exc()
        except TypeError as ex:
            print(ex)
            print('Please input cmd in:', Cmds.keys())
            traceback.print_exc()
        except KeyboardInterrupt:
            if uds.test_th is not None:
                uds.test_th.join()
            diag.StopTesterPresent()
        finally:
            pass
            # wake_msg.stop()
            PyUds.MessageLog.stop()
Exemplo n.º 5
0
def main(args):
    global dtc_fault_config
    config = Scripts.UdsConfigParse('UdsConfig.json')
    dtc_config_path = config.config['DTC'][0]['Path']
    dtc_fault_config = DTCFaultConfigLoad(dtc_config_path)
    bus = config.GetBus('CanBus1')
    # diag = CmdUds(uds_client=config.GetUdsClient('CanPhy'))
    # diag_internal = CmdUds(uds_client=config.GetUdsClient('CanInternal'))
    diag = config.GetUdsDiag('CanPhy', diag_cls='CmdUds')
    diag_internal = config.GetUdsDiag('CanInternal', diag_cls='CmdUds')
    key_gen = config.GetKeyGens("GAC_A39")
    ESP_Status = config.GetMessage('ESP_Status')
    ESP_Active_Status = config.GetMessage('ESP_Active_Status')
    uds = GacUdsCom(diag,
                    diag_internal,
                    key_gen,
                    ESP_Status=ESP_Status,
                    ESP_Active_Status=ESP_Active_Status)
    Cmds = {
        "eol": uds.EOL,
        "clearip": uds.ClearIP,
        "cleardtc": uds.GacClearDTC,
        "phase": uds.ChangePhase,
        "boot": uds.BootDownLoad,
        'uds': uds.GacUds,
        'internal': uds.GacInternalUds,
        'dtc': uds.ReadDTCs,
        'fault': uds.ReadInternalFaults,
        "imucal1": uds.ImuInternalCal,
        "imucal2": uds.ImuExternalCal,
    }
    with PyUds.ThreadSafety(bus):
        try:
            Cmds[args[0]](*args[1:])
        except UdsResponseError as ex:
            print(ex)
        except KeyError as ex:
            print(ex)
            print('Please input cmd in:', Cmds.keys())
        except TypeError as ex:
            print(ex)
            desc = '~~~~~~~~~~~~~~example~~~~~~~~~~~~~\n'
            desc += '  eol: gac eol configure\n'
            desc += '  clearip: clear ip fixedcal an alog3 fixedcal\n'
            desc += '  phase n: update to phase of life to 0,1,2\n'
            desc += '  boot "file1" "file2" ...: download files\n'
            desc += '  dtc [stauts]: read dtc information by stauts \n'
            desc += '  fault: read internal faults\n'
            desc += '  uds: enter diagnostic mode\n'
            desc += '  internal: enter internal diagnostic mode\n'
            print(desc)
Exemplo n.º 6
0
def main():
    config = Scripts.UdsConfigParse('UdsConfig.json')
    # dtc_fault_config = DTCFaultConfigLoad(dtc_config_path)
    bus = config.GetBus('CanBus1')
    # diag = CmdUds(uds_client=config.GetUdsClient('CanPhy'))
    # diag_internal = CmdUds(uds_client=config.GetUdsClient('CanInternal'))
    diag = config.GetUdsDiag('CanPhy', diag_cls='CmdUds')
    diag_internal = config.GetUdsDiag('CanInternal', diag_cls='CmdUds')
    key_gen = config.GetKeyGens("GAC_A39")
    uds = GacUdsCom(diag, diag_internal, key_gen)
    with PyUds.ThreadSafety(bus):
        uds.EnterBoot()
        #        bin_buf = uds.BootUpload(0xAF000000,0x18000)
        #        write_hex_buf(bin_buf, "nvm.hex")
        bin_buf = uds.BootUpload(0x80014000, 0x4000)
        write_hex_buf(bin_buf, "veh.hex")
        bin_buf = uds.BootUpload(0x80010000, 0x4000)
        write_hex_buf(bin_buf, "alog1.hex")
Exemplo n.º 7
0
 def Message_test(self):
     msg = PyUds.Message(arbitration_id=0x182, data=[0x00] * 8)
     step_desc = 'can message send'
     __class__.Message_test.desc = step_desc
     return msg
Exemplo n.º 8
0
 def SessionControl(self, session, desc=None):
     step_desc = 'SessionControl'
     resp = PyUds.DiagResponse([0x50, 0x01, 0x00, 0x0A, 0x00, 0x20])
     this = ReportTest.SessionControl
     this.desc = step_desc
     return resp
Exemplo n.º 9
0
            actual = 'Posistive Response'
        else:
            result = False
            actual = 'Negative Response %02X' % (resp.NRC)
        this = ReportTest.AssertNone
        this.desc = step_desc
        this.expect = expect
        this.actual = actual
        this.result = result
        return result


try:
    config = Scripts.UdsConfigParse('UdsConfig.json')
    start_time = time.time()
    bus = PyUds.BusBase()
    tp = PyUds.CanTp(
        phy_id=0x727,
        func_id=0x7DF,
        resp_id=0x7A7,
    )
    client = PyUds.DiagClient(tp_protocol=tp)
    diag = PyUds.BaseDiagnostic(uds_client=client)
    tester = ReportTest(diag=diag)
    tester.TestGroup2()
    tester.TestGroup1()

    test_list = UdsLoging.test_group
    test_result = UdsLoging.get_all_result()
    end_time = time.time()
    test_info = [