Esempio n. 1
0
        def fun_info(*args, **kwargs):
            try:

                #Process=os.path.basename(__file__)
                #Phase=func.__name__
                VS.VARIABLE = {}
                VS.RM_VARIABLE = {}
                VS.SV("Process", process)
                VS.init_test_value()
                VS.RM("Process", process, "CAR_INFO")

                func(*args, **kwargs)
                SeqComplete = "True"
                VS.RM("SeqComplete", SeqComplete, "CAR_INFO")
            except Exception as err:
                SeqComplete = "False"
                VS.RE("ERROR", err, "CAR_INFO")
                VS.RM("SeqComplete", "Fail", "CAR_INFO")
                VS.m_message(str(err))
                return (1)
            try:
                logname = VS.GV('LOG_NAME')
                VS.RM("SeqComplete", SeqComplete, "CAR_INFO")
                FinishTime = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
                VS.RM("FinishTime", FinishTime, "CAR_INFO")
                VS.save_all_result(logname)
                creat_vcats_xml(VS.RM_VARIABLE)
            except Exception as err:
                VS.m_message(str(err))
                return (1)
Esempio n. 2
0
def in_active_mode(doip):
    vs.m_message("set car into inactive mode")
    #doip=PyDoIP.DoIP_Client(logname)
    #doip.Connect()
    #vs.SV("car_address",doip._targetIPAddr)
    #doip.keep_Routing_task()
    try:
        ret = doip.send(b"\x10\x03", tx_address='1A01')
        ret = doip.send(b"\x27\x03", tx_address='1A01')
        Seed = doip.re_msg.payload[-6:]
        key = Security_Access('43454D3033', Seed)
        message = '2704' + key
        ret = doip.send(message, tx_address='1A01')
        if ret > 0: ret = doip.send(b"\x2F\xDD\x0A", tx_address='1A01')
        if ret > 0 and doip.re_msg.payload[-2:] != "01":
            ret = doip.send(b"\x2F\xDD\x0A\x03\x01", tx_address='1A01')
            ret = doip.send(b"\x22\xDD\x0A", tx_address='1A01')
            if ret < 0 or doip.re_msg.payload[-2:] != "01":
                doip.error_set("error active CEM")
                vs.RM("Active CEM", "NOK", testname="Active CEM")
            else:
                vs.RM("Active CEM", "OK", testname="Active CEM")
    except Exception as err:
        doip.log_message("error active CEM %s" % err)
        vs.RE("inActive CEM", "NOK", testname="inActive CEM")
        vs.RE("inActive CEM error", str(err), testname="inActive CEM")
    time.sleep(5)
    try:
        vs.m_message("Send 1FFF MESSAGE")
        vs.m_message("Wait 15s")
        try:
            ret = doip.send(b"\x31\x01\x02\x06", tx_address='1FFF')
        except Exception as err:
            pass
        try:
            ret = doip.send(b"\x10\x02", tx_address='1FFF')
        except Exception as err:
            pass

    except Exception as err:
        doip.log_message("error send IFFF message %s" % err)
        vs.RE("SEND 1FFF MESSAGE", "NOK", testname="inActive CEM")
Esempio n. 3
0
def active_mode(doip):
    vs.m_message("set car into active mode")
    try:
        ret = doip.send(b"\x10\x03", tx_address='1A01')
        ret = doip.send(b"\x27\x03", tx_address='1A01')
        Seed = doip.re_msg.payload[-6:]
        key = Security_Access('43454D3033', Seed)
        message = '2704' + key
        ret = doip.send(message, tx_address='1A01')
        if ret > 0: ret = doip.send(b"\x2F\xDD\x0A", tx_address='1A01')
        if ret > 0 and doip.re_msg.payload[-2:] != "0B":
            ret = doip.send(b"\x2F\xDD\x0A", tx_address='1A01')
            ret = doip.send(b"\x22\xDD\x0A", tx_address='1A01')
            if ret < 0 or doip.re_msg.payload[-2:] != "0B":
                doip.error_set("error active CEM")
        vs.RM("Active CEM", "OK", testname="Active CEM")
    except Exception as err:
        doip.log_message("error active CEM %s" % str(err))
        vs.RE("Active CEM", "NOK", testname="Active CEM")
        vs.RE("Active CEM MESSAGE", str(err), testname="Active CEM")
    time.sleep(5)
    try:
        vs.m_message("Send 1FFF MESSAGE")
        vs.m_message("Wait 15s")
        try:
            ret = doip.send(b"\x31\x01\x02\x06", tx_address='1FFF')
        except Exception as err:
            pass
        try:
            ret = doip.send(b"\x10\x02", tx_address='1FFF')
        except Exception as err:
            pass

    except Exception as err:
        doip.log_message("error send IFFF message %s" % err)
        vs.RE("SEND 1FFF MESSAGE", "NOK", testname="inActive CEM")
Esempio n. 4
0
def LL(vin):
    vs.read_broadcast(vin)
    read_vbf_info()
    sbl_name_list = vs.Config['image']['sbl_type'].split(',')
    logname = vs.GV('LOG_NAME')
    swdl_vf_path_dic = vs.GV('swdl_vf_path_dic')
    try:
        doip1 = PyDoIP.DoIP_Client(logname)
        doip1._mode = 0
        doip1.Connect()
    except Exception as err:
        vs.m_message(str(err))
        vs.RE("connect_car", str(err), testname="connect_car")
        try:
            doip1.close()
        except Exception as err:
            pass
        return 1

    if vs.PML("AA31") or vs.PML("AAC7") or vs.PML("AAB9"):
        in_active_mode(doip1)
    else:
        active_mode(doip1)
    doip1.close()

    time.sleep(10)

    doip = PyDoIP.DoIP_Client(logname)
    doip._mode = 0
    #doip.Connect(car_address='169.254.19.1')
    doip.Connect()
    #doip.Re_connect()

    try:
        doip.keep_Routing_task()
    except Exception as err:
        vs.m_message(str(err))
        vs.RE("keep_Routing_task", str(err), testname="keep_Routing_task")
        try:
            doip.close()
        except Exception as err:
            pass
        return 1

    for ecu in swdl_vf_path_dic:
        vs.m_message('Flashing  soft in  %s ' % (ecu))
        try:
            doip._tx_address = vs.Car_Config['ecu_info'][ecu]['address'][2:]
            try:
                ret = doip.send(b"\x10\x02")
                ret = doip.send(b"\x22\xF1\x86")
            except Exception as err:
                vs.m_message(str(err))
        except Exception as err:
            message = "error get %s address info in json info" % ecu
            vs.m_message(message)
            vs.RE("", str(message), testname=ecu + "_SWDL")
            continue
        if get_ecu_security_access(doip, ecu) < 0:
            continue
        for path in swdl_vf_path_dic[ecu]:
            try:
                set_str = 'OK'
                vbf_info_dic = br_vbf_info_dic[path]
                ecuaddress = vbf_info_dic[b'ecu_address'].decode().upper()
                vbf_name = (vbf_info_dic[b'sw_part_number'] +
                            vbf_info_dic[b'sw_version']).decode().upper()
                vbf_type = vbf_info_dic[b'sw_part_type'].decode().upper()
                data_format = binascii.unhexlify(
                    vbf_info_dic[b'data_format_identifier'][2:])
                vs.m_message('Flashing  vbf:  %s ,type: %s ,to : %s ' %
                             (vbf_name, vbf_type, ecu))
                doip.log_message('Flashing  vbf:  %s ,type: %s ,to : %s ' %
                                 (vbf_name, vbf_type, ecu))

                #if vbf_type in sbl_name_list:
                #	doip.send(b'\x22\xf1\x86')
                if b'erase' in vbf_info_dic:
                    erase_datastr = vbf_info_dic[b'erase']
                    erase_data_dic = set_erase_ad(erase_datastr)
                    for address in erase_data_dic:
                        sendstr = b'\x31\x01\xff\x00' + erase_data_dic[
                            address]['start_address'] + erase_data_dic[
                                address]['end_address']
                        try:
                            doip.send(sendstr, timeout=120)
                            if doip.re_msg.payload[0:8] == 71010212:
                                ret = doip.receive_uds_msg(message=sendstr,
                                                           timeout=120)
                        except Exception as err:
                            if doip.re_msg.payload[0:6] != '7101FF':
                                raise Exception('error erase momory')
                flag = 1
                star_pose = 0
                end_pose = 0
                for key in vbf_info_dic[b'hex_data']:
                    hex_length = vbf_info_dic[b'hex_data'][key][b'length']
                    hex_data = vbf_info_dic[b'hex_data'][key][b'data']
                    hex_address = key
                    sendstr = b'\x34' + data_format + b'\x44' + hex_address + hex_length
                    ret = doip.send(sendstr)
                    if ret > 0:
                        myResponse = doip.re_msg.payload
                        sendlength = int.from_bytes(bytes.fromhex(
                            myResponse[-4:]),
                                                    byteorder='big',
                                                    signed=False)
                    else:
                        continue
                    while (star_pose <= len(hex_data)):
                        b_flag = flag.to_bytes(1,
                                               byteorder='little',
                                               signed=False)
                        if end_pose > 0: star_pose = end_pose
                        else: star_pose = end_pose
                        end_pose = star_pose + sendlength - 2
                        if star_pose > len(hex_data):
                            ret = doip.send(b'\x37')
                            #print("end_sending",key)
                            flag = 1
                            star_pose = 0
                            end_pose = 0
                            break
                        else:
                            send_data = hex_data[star_pose:end_pose]
                            aa = b'\x36' + b_flag + send_data
                            re_ret = doip.send(b'\x36' + b_flag + send_data)
                            if re_ret < 0: break
                            flag = flag + 1
                            if (flag > 255): flag = 0
                    if re_ret < 0:
                        re_ret = 0
                        continue
                    if key == list(vbf_info_dic[b'hex_data'])[-1]:
                        if (b'sw_signature' in vbf_info_dic
                                or b'sw_signature_dev' in vbf_info_dic):
                            if b'sw_signature' in vbf_info_dic:
                                send_str = vbf_info_dic[b'sw_signature']
                            else:
                                send_str = vbf_info_dic[b'sw_signature_dev']
                            send_str = b'\x31\x01\x02\x12' + binascii.unhexlify(
                                send_str[2:])
                            try:
                                ret = doip.send(send_str, timeout=10)
                            except Exception as err:
                                ret = doip.send(send_str, timeout=10)
                        if vbf_type in sbl_name_list:
                            call_address = binascii.unhexlify(
                                vbf_info_dic[b'call'][2:])
                            send_str = b'\x31\x01\x03\x01' + call_address
                            doip.send(send_str)
                        else:
                            lastvf = vs.GV('BROADCAST.$' + ecu + '.-1')
                            #if vbf_name==lastvf and key==list(vbf_info_dic[b'hex_data'])[-1]:
                            if path.find(lastvf) > 0 and key == list(
                                    vbf_info_dic[b'hex_data'])[-1]:
                                #send_str=b'\x31\x01\x02\x05'+hex_address
                                send_str = b'\x31\x01\x02\x05'
                                ret = doip.send(send_str)
                                myResponse = doip.re_msg.payload
                                if myResponse[-8:] == '00000000':
                                    doip.log_message(
                                        "download %s vbf files ok" % ecu)
                                    set_str = 'OK'
                                    #print("download %s vbf files ok" %ecu)
                                else:
                                    doip.log_message(
                                        "download %s vbf files Nok" % ecu)
                                    set_str = 'NOK'
                                    #print("download %s vbf files Nok" %ecu)

                time.sleep(0.05)
                vs.RM(vbf_name, set_str, testname=ecu + "_SWDL")
            except Exception as err:
                errorstr = "%s" % err
                vs.RM(vbf_name, "NOK", testname=ecu + "_SWDL")
                vs.RE(vbf_name, str(errorstr), testname=ecu + "_SWDL")
                if doip._mode == 0: continue
                else: break
    try:
        ret = doip.send_message(b"\x11\x01", tx_address='1FFF')
    except Exception as err:
        vs.RE("RESET_ECU", str(err), testname="RESET_ECU")
    finally:
        doip.close()
Esempio n. 5
0
def set_process_test(save_json):
    Tickcount = 1
    VS.RM("Status", "Pass", "CAR_INFO")
    process_tests_list = []
    process_test = {}
    for phase_info in save_json:
        if phase_info == 'System': continue
        for key in save_json[phase_info]:
            Tickcount = Tickcount + 1
            process_test = {}
            ###need  add Phase TestTime
            process_test["@Phase"] = phase_info
            process_test["@Test"] = key
            ###MABY update later
            process_test["@InCycleRetestNum"] = 1
            process_test["@StratRev"] = ""
            process_test["@TestTime"] = save_json[phase_info][key]["TestTime"]
            if "error_att" in save_json[phase_info][key]:
                process_test["@Status"] = "Fail"
                VS.RM("Status", "Fail", "CAR_INFO")
                process_test["FAULT_CODES"] = {}
                process_test["FAULT_CODES"]["FAULT_CODE"] = []
                for error_infos in save_json[phase_info][key]["error_att"]:
                    error_info_dic = {}
                    error_info_dic["@Status"] = "Fail"
                    error_info_dic["@Faultmode"] = "D"
                    error_info_dic["@FaultCode"] = "VC001"
                    error_info_dic["@CMID"] = "VCATS"
                    #aa=list(error_infos.keys())[0]
                    error_info_dic["@ShortDesc"] = error_infos + ' Nok'
                    error_info_dic["@Testtime"] = save_json[phase_info][key][
                        "error_att"][error_infos]['save_time']
                    error_info_dic["FAULT_ATTRIBUTES"] = {}
                    error_info_dic["FAULT_ATTRIBUTES"]["FAULT_ATTRIBUTE"] = {}
                    error_info_dic["FAULT_ATTRIBUTES"]["FAULT_ATTRIBUTE"][
                        "@Att"] = error_infos
                    error_info_dic["FAULT_ATTRIBUTES"]["FAULT_ATTRIBUTE"][
                        "@Val"] = save_json[phase_info][key]["error_att"][
                            error_infos][error_infos]
                    error_info_dic["FAULT_ATTRIBUTES"]["FAULT_ATTRIBUTE"][
                        "@Tickcount"] = str(Tickcount)
                    process_test["FAULT_CODES"]["FAULT_CODE"].append(
                        error_info_dic)
                    Tickcount = Tickcount + 1
            else:
                process_test["@Status"] = "Pass"
            process_test["@Latest"] = "1"
            if "save_att" in save_json[phase_info][key]:
                process_test["TEST_ATTRIBUTES"] = {}
                process_test["TEST_ATTRIBUTES"]["TEST_ATTRIBUTE"] = []
                for save_att in save_json[phase_info][key]["save_att"]:
                    save_att_dic = {}
                    save_att_dic["@Att"] = save_att
                    save_att_dic["@Val"] = save_json[phase_info][key][
                        "save_att"][save_att][save_att]
                    save_att_dic["@Tickcount"] = Tickcount
                    Tickcount = Tickcount + 1
                    process_test["TEST_ATTRIBUTES"]["TEST_ATTRIBUTE"].append(
                        save_att_dic)
            process_tests_list.append(process_test)
    return process_tests_list