Esempio n. 1
0
def LEDTest(item):

    env.print_warn("\n>> LED show {}<<".format(item))

    # ser.write('ml_led.sh cpld all {} 3'.format(item) + '\n')
    if item == 'red':
        ser.write('isaset -y -f 0x2ac 0x3f' + '\n')
    if item == 'green':
        ser.write('isaset -y -f 0x2ad 0x3f' + '\n')
    if item == 'both':
        ser.write('isaset -y -f 0x2ac 0x3f' + '\n')
        ser.write('isaset -y -f 0x2ad 0x3f' + '\n')

    proc_command = 'python gui_pass_fail.py "{} LED Test"'.format(item)
    result = env.subprocess_execute(proc_command, 600)

    # current_folder -->> Results
    if not os.path.exists(env.tester_results_folder):
        os.makedirs(env.tester_results_folder)

    result_filename = os.path.join(env.tester_results_folder,
                                   'LED_' + item + '.cmd')
    env.touch(result_filename)
    with open(result_filename, 'w') as f_output_file:
        #       f_output_file.write('HDMI_STAT={}'.format(hdmiStatus))
        f_output_file.write('SET LED_{}={}'.format(item, result.strip()))
        f_output_file.close()

    time.sleep(1)
    ser.write('isaset -y -f 0x2ac 0x00' + '\n')
    ser.write('isaset -y -f 0x2ad 0x00' + '\n')
    ser.write('cd /home/root/' + '\n')
Esempio n. 2
0
def wifi_ap_rssi(AccessPoint=[]):
    print('>> Scanning wifi access point... please wait. <<')

    # initialization
    send_cmd("ifconfig mlan0 up")
    time.sleep(0.5)
    send_cmd("ifconfig mlan0 up")
    time.sleep(0.5)

    # run commands
    results = send_cmd('iw dev mlan0 scan | egrep "signal|SSID|freq"').split(
        '\n')
    index = 0
    while index < len(results):
        '''
        todo Delete: 
        * center freq segment 1: 0
        * center freq segment 2: 0
        '''
        if results[index].find("center freq segment") != -1:
            print("[%d] %s" % (index, results[index]))
            del results[index]
            continue
        index += 1

    scan_dict = {}
    #    scan_list = []
    for idx in range(0, (len(results) / 3)):
        '''
        todo Parse:
        [0] freq: 2xxx OR 5xxx
        [1] signal: -53.00 dBm
        [2] SSID: CM512-68503d
        '''
        ssid = results[(idx * 3) + 2].replace("SSID:", "").strip()
        if ssid != "\\x00":
            freq = results[(idx * 3)].replace("freq:", "").strip()
            signal = results[(idx * 3) + 1].replace("signal:",
                                                    "").replace("dBm",
                                                                "").strip()
            env.print_warn("{:<30}: {:<5}: {} dBm".format(ssid, freq, signal))
            scan_dict[ssid] = signal
#            scan_list.append({ ssid : float(signal), })
#    env.print_warn( scan_dict )

    rssi_list = []
    for find_ap in AccessPoint:
        if find_ap in scan_dict:
            #            print find_ap + " : " + scan_dict[find_ap]
            rssi_list.append(scan_dict[find_ap])
        else:
            rssi_list.append('-None.None')


#    print rssi_list

    if AccessPoint == []:
        return ' '.join(scan_dict)
    else:
        return ' '.join(rssi_list)
Esempio n. 3
0
def bios_update(BIOS_IMG='', FOLDER='', RETRY='3'):
    if BIOS_IMG != '':
        RETRY = int(RETRY)
        retry = RETRY
        while (retry > 0):
            env.print_warn(">> run bios_update : retry %d <<" %
                           (RETRY - retry + 1))
            sticks = send_cmd('ls /run/media/').split()
            #            print sticks
            if len(sticks):
                for dev_name in sticks:
                    full_path = '/run/media/{}/{}/{}'.format(
                        dev_name, FOLDER, BIOS_IMG)
                    exist_fv = send_cmd('ls {} | wc -l'.format(full_path))
                    if len(exist_fv.split('\n')) == 1 and int(exist_fv) == 1:
                        env.print_pass("'{}' Found.".format(full_path))
                        send_cmd('mount -o remount, rw /esp')
                        send_cmd('cp {} /esp/BIOSUPDATE.fv'.format(full_path))
                        time.sleep(1)
                        exist_esp = send_cmd('ls /esp/BIOSUPDATE.fv | wc -l')
                        if len(exist_esp.split('\n')) == 1 and int(
                                exist_esp) == 1:
                            #                            print len(exist_esp.split('\n'))
                            #                            return machine_reboot(DISPLAY_ENABLE=False, DISPLAY_ENABLE=False, TIMEOUT=60)
                            return True
                        else:
                            return False
                    else:
                        env.print_fail("'{}' Not Found.".format(full_path))
            retry -= 1
    return False
Esempio n. 4
0
def wifi_mac():
    # https://askubuntu.com/questions/628383/output-only-mac-address-on-ubuntu
    results = send_cmd(
        "ifconfig mlan0 | perl -lane 'if(/^\w/&&$#F==4){print $F[$#F]}'")
    #    sleep(1)
    #    results = ser_read(1025)
    env.print_warn(results)
    return results
Esempio n. 5
0
def run_manufacturing_mode(CMD='', PARA='', SLEEP='0', RETRY='3', SERACH=''):
    # initialize
    CreateFile = "/tmp/{}.sh".format(CMD)
    LogFile = "/tmp/{}.log".format(CMD)
    send_cmd("rm /tmp/%s*" % CMD)

    RETRY = int(RETRY)
    retry = RETRY
    results = ''
    while (retry > 0):
        # create run config: parameter
        if PARA:
            send_cmd('echo "echo -e %s %s" > %s' % (CMD, PARA, CreateFile))
        else:
            send_cmd('echo "echo -e %s" > %s' % (CMD, CreateFile))
        time.sleep(0.1)

        if int(SLEEP) > 0:
            send_cmd('echo "sleep %d" >> %s' % (SLEEP, CreateFile))

        send_cmd('echo "echo -e exit" >> %s' % CreateFile)
        time.sleep(0.1)

        # run commands
        results = send_cmd("sh %s | MFMStart > %s ; cat %s" %
                           (CreateFile, LogFile, LogFile))
        env.print_log("\nResults=[{}], lenght={}\n".format(
            results, len(results.split('\n'))))

        # check error
        if (len(results.split('\n')) < 2 or results.count(': ') <
                2  # or results.find("Manufacturing mode: On") == -1
                #                or results.find("command not found")!=-1 or results.find("command failed")!=-1 or results.find("Unknown Command")!=-1
                or results.lower().find("error") != -1 or
                results.lower().find("command") != -1 or
                results.find("Read-only") != -1 or
                results.find("No such file or directory") != -1):
            env.print_warn(">> run %s : retry %d <<" % (CMD,
                                                        (RETRY - retry + 1)))
            env.print_error(results)
            retry -= 1
        else:
            if (SERACH != ''):
                if (results.lower().find(SERACH.lower()) != -1):
                    env.print_warn("\nSearch=[{}], lenght={}\n".format(
                        SERACH, results))
                    return results
                else:
                    retry -= 1
            else:
                return results
        time.sleep(0.1)
    if len(results.split('\n')) <= 1 or results.find(
            "No such file or directory") != -1 or results.find(
                "command not found") != -1:
        results = "%s: ERROR" % CMD
    return results
Esempio n. 6
0
def bluetooth_device_rssi(Device=[], ScanTime='15'):
    print('>> Scanning bluetooth devices... please wait. <<')

    # initialization
    CreateFile = '/tmp/bluetoothconfig.sh'
    send_cmd("rm %s" % CreateFile)

    # create run config
    #    send_cmd('echo "#!/bin/bash" >> %s' % CreateFile)
    send_cmd('echo "echo -e \"power on\"" >> %s' % CreateFile)
    send_cmd('echo "sleep 2" >> %s' % CreateFile)
    send_cmd('echo "echo -e \"scan on\"" >> %s' % CreateFile)
    send_cmd('echo "sleep %s" >> %s' % (ScanTime, CreateFile))
    send_cmd('echo "echo -e \"quit\"" >> %s' % CreateFile)
    send_cmd('chmod a+x %s' % CreateFile)

    # run commands
    results = send_cmd(
        'sh %s | bluetoothctl | grep RSSI | awk \'{print $4 \" \" $6}\'' %
        CreateFile).split('\n')

    # organize run commands results
    if results[0][:3] == 'sh ':
        del results[0]

    scan_dict = {}
    for line in results:
        items = line.strip().split(' ')
        env.print_warn("{} : {}".format(items[0], items[1]))
        scan_dict[items[0]] = items[1]
#    env.print_warn( scan_dict )

    rssi_list = []
    for find_dev in Device:
        if find_dev in scan_dict:
            #            print find_dev + " : " + scan_dict[find_dev]
            rssi_list.append(scan_dict[find_dev])
        else:
            rssi_list.append('-None')


#    print rssi_list

    if Device == []:
        return ' '.join(scan_dict)
    else:
        return ' '.join(rssi_list)
Esempio n. 7
0
def WriteMacAddress(item):
    mac = settings[item]
    env.print_warn("\n>> Write {} Mac Address <<".format(item))

    ser.write('ml_mac_write.sh OVERWRITE_MAC {} {}'.format(item, mac) + '\n')
    results = ''
    found = False
    initial = time.time()
    TIMEOUT = 60

    # if item == 'fpga':
    #     return 'PASS'

    while True:
        results += ser_read()
        duration = time.time() - initial

        sys.stdout.write('\rElapsed Time: %#.8f seconds' % duration)
        sys.stdout.flush()

        if not found:
            if duration > TIMEOUT:
                env.print_fail("\n>> Boot Failed <<")
                env.print_info('\rElapsed elapsed time: %#.8f seconds' %
                               duration)
                return "FAIL"
                break

            #if len(results) == 0 and duration > 3:
            #    results = send_cmd( "\n" )

            if 'wrote 0xff to register 0x00 31' in results:
                # if DISPLAY_ENABLE:
                #     env.print_log("\n\n{}".format(results))
                found = True

            if 'wrote 0xff to register 0x00 15' in results:
                found = True

        if found:
            env.print_warn("\n>> Write {} mac Success <<".format(item))
            env.print_info('\rElapsed elapsed time: %#.8f seconds' % duration)
            return "PASS"
            break

    return found
Esempio n. 8
0
def machine_wait_for_boot(DISPLAY_ENABLE=False, TIMEOUT=120):
    env.print_warn("\n>> Waiting for Boot <<")
    results = ''
    found = False
    initial = time.time()

    while True:
        results += ser_read()
        duration = time.time() - initial
        if waitForLogin in results:
            print "\n", waitForLogin
            ser.write('root' + '\n')

        sys.stdout.write('\rElapsed Time: %#.8f seconds' % duration)
        sys.stdout.flush()

        if not found:
            if duration > TIMEOUT:
                env.print_fail("\n>> Boot Failed <<")
                env.print_info('\rElapsed elapsed time: %#.8f seconds' %
                               duration)
                return "FAIL"
                break

            #if len(results) == 0 and duration > 3:
            #    results = send_cmd( "\n" )

            if DefaultBootPrompt in results:
                if DISPLAY_ENABLE:
                    env.print_log("\n\n{}".format(results))
                found = True

        if found and (DefaultShellPrompt in results):
            env.print_warn("\n>> Boot Success <<")
            env.print_info('\rElapsed elapsed time: %#.8f seconds' % duration)
            return "PASS"
            time.sleep(5)
            ser.write('cd /home/root/' + '\n')
            time.sleep(5)
            break
    return found
Esempio n. 9
0
def DisplayTest(item):

    env.print_warn("\n>> Waiting display show <<")

    # ser.write('./ml_stress/stress_full.sh DVT {} 1khz'.format(item) + '\n')
    if item != 'SDI':
        ser.write('VideoCaptureTest RGB' + '\n')
    else:
        ser.write('VideoCaptureTest YUV' + '\n')

    time.sleep(3)

    proc_command = 'python gui_pass_fail.py "{} Signal Test"'.format(item)
    result = env.subprocess_execute(proc_command, 120)

    # current_folder -->> Results
    if not os.path.exists(env.tester_results_folder):
        os.makedirs(env.tester_results_folder)

    result_filename = os.path.join(env.tester_results_folder, item + '.cmd')
    env.touch(result_filename)
    with open(result_filename, 'w') as f_output_file:
        #       f_output_file.write('HDMI_STAT={}'.format(hdmiStatus))
        f_output_file.write('SET {}={}'.format(item, result.strip()))
        f_output_file.close()

    ser.write('\x03' + '\n')
    ser.write('killall gst-launch-1.0' + '\n')
    ser.write('cd /home/root/' + '\n')

    ln = ''
    found = False
    while True:
        ln += ser_read()
        if not found and (DefaultBootPrompt in ln):
            found = True
        if found and (DefaultShellPrompt in ln):
            print(">> boot success... <<")
            break
Esempio n. 10
0
def machine_wait_for_boot(DISPLAY_ENABLE=False, DISPLAY_TIME=1):
    env.print_warn("\n>> Waiting for Boot <<")
    results = ''
    found = False
    initial = time.time()
    while True:
        results += ser_read()

        duration = time.time() - initial
        if duration >= DISPLAY_TIME:
            if DISPLAY_ENABLE:
                print results
            else:
                sys.stdout.write('\rElapsed Time: %#.8f seconds' % duration)
                sys.stdout.flush()

        if not found and (DefaultBootPrompt in results):
            if DISPLAY_ENABLE:
                print results
            found = True
        if found and (DefaultShellPrompt in results):
            env.print_warn("\n>> Boot Success ... <<")
            break
    return found
Esempio n. 11
0
    if do_RunStatus and do_Result:
        print('\n')
        if RunStatus == 'FAIL':
            #            env.print_fail('\nFAIL')
            env.print_fail('    *****    *    *****  *')
            env.print_fail('    *       * *     *    *')
            env.print_fail('    ****   *****    *    *')
            env.print_fail('    *      *   *    *    *')
            env.print_fail('    *     *     * *****  *****')
        else:
            #            env.print_pass('\nPASS')
            env.print_pass('    ****     *     ****   ****')
            env.print_pass('    *   *   * *   *      *')
            env.print_pass('    ****   *****   ****   ****')
            env.print_pass('    *      *   *       *      *')
            env.print_pass('    *     *     *  ****   ****')

    print('\nGUI Runner Done.')


if __name__ == '__main__':
    while True:
        # run
        main()

        user_continue = 'y'
        env.print_warn('\nPress enter y to continue, n for stop...')
        user_continue = raw_input(
        )  #('\nPress enter y to continue, n for stop...')
        if user_continue == 'n' or user_continue == 'N':
            break
Esempio n. 12
0
    display_enable = 'False'
    if len(sys.argv) > 1:
        display_enable = sys.argv[1]

    if len(sys.argv) <= 2:
        #        print 'no argument'
        ResultDirectory = ''
        if os.path.exists(env.tester_results_folder):
            ResultDirectory = env.tester_results_folder
        else:
            SN = GetSerialNumber()
            ResultDirectory = os.path.join(env.ws_storage_folder, SN,
                                           env.result_folder_name)
        if not os.path.exists(ResultDirectory):
            print(">> Sorry, can not find folder %s <<" % ResultDirectory)
            env.print_warn("FAIL")
            quit()
    else:
        ResultDirectory = sys.argv[2]

    Title = Entry(
        root,  # justify='center',
        font="Times 16 bold",
        fg="black",
        bg="#48a9f2")
    Title.pack(side=TOP, padx=5, pady=5, expand=YES, fill=X)
    Title.insert(10, ResultDirectory)

    if not os.path.exists(env.criteria_file_full_path):
        print(">> Sorry, Can not find file %s <<" %
              env.criteria_file_full_path)
Esempio n. 13
0
def bsp_version():
    #    results = send_cmd("getprop | grep ro.custom.build.version")
    #    results = send_cmd('dmesg | grep "Linux version"')
    results = send_cmd('uname -n')
    env.print_warn(results)
    return results