Ejemplo n.º 1
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()
Ejemplo n.º 2
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()
Ejemplo n.º 3
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)
Ejemplo n.º 4
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")
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
"""
Created on Thu Jun  6 10:44:04 2019

@author: levy.he
"""

from pyuds import Scripts
if __name__ == '__main__':
    config = Scripts.UdsConfigParse('UdsConfig.json')
    fr_sample = config.GetMessage('FrSample')
    print(fr_sample)