Esempio n. 1
0
    def test(self):

        message = self.message
        colorprint(message[0], "YELLOW")
        flag = True

        # Switch OFF,
        res = CommandResult.parse(
            self.dut.execute_command("stack_nb_check", 5000)[1])
        if res.rc == 0 and res.data["value"] == "1":
            self.logger.info("CSVFILE stack_check_next_bike ok ok pass")
        else:
            self.logger.info("CSVFILE stack_check_next_bike ok ng fail")
            flag = False

        op_messager(message[2])
        # Switch ON,
        res = CommandResult.parse(
            self.dut.execute_command("stack_nb_check", 5000)[1])
        if res.rc == 0 and res.data["value"] == "0":
            self.logger.info("CSVFILE stack_check_next_bike ok ok pass")
        else:
            self.logger.info("CSVFILE stack_check_next_bike ok ng fail")
            flag = False

        colorprint(message[3], "GREEN")
        return flag
Esempio n. 2
0
    def measure_per(self,server, client, numpkt):
        client_ip = configget("RADIO_TEST","client_ip")
        server_ip = configget("RADIO_TEST","server_ip")

        per_results = list()
        client.execute_command('wifi pkt rx')
        rates = [   ('wifi rate -m 7', 'N'),## 65mbps
                    ('wifi rate -b 11', 'B')] ## 11mbps
        for rate in rates:
            server.execute_command(rate[0])
            # server.execute_command('wifi pkt tx %s 100 10 10' % (client_ip)) # close loop
            time.sleep(0.1) # wait all packets are transmitted
            client.execute_command('wifi pkt rst_cnt')
            server.execute_command('wifi pkt tx %s 1000 %d 10' % (client_ip, numpkt), timeout_ms=30*1000)
            time.sleep(1) # wait all packets are transmitted
            rt, text = client.execute_command('wifi pkt cnt')
            res = CommandResult.parse(text)
            pkt_cnt = int(res.data['pkt_cnt'])

            rt, text = client.execute_command('wifi get_rssi')
            res = CommandResult.parse(text)
            rssi = int(res.data['rssi'])

            client_mac = client.get_mac()
            per_results.append((rate[1], pkt_cnt,rssi))
        client.execute_command('wifi pkt stop')
        return per_results
Esempio n. 3
0
    def test(self):
        flag = False
        start_time = time.time()
        self.logger.info("----------Waiting for shell>>>>>")
        prompt = self.dut.get_name() + ">"
        key = self.dut.get_shell(prompt, self.timeout)
        if key:
            self.logger.info("Shell Found!")
            self.logger.info("CSVFILE wait_shell" + " shell_found shell_found pass")
            r,text_ = self.dut.execute_command("connect",10000)
            if r==0:
                flag = True
            else:
                self.logger.info("CSVFILE connect" + " 0 %d fail"%r)
        else:
            self.logger.info("No shell found, Timeout!")
            self.logger.info("CSVFILE wait_shell" + " shell_found no_uart_detected fail")

        if flag:
            res = CommandResult.parse(self.dut.execute_command("factory_mode_get",5000)[1])
            if int(res.data["main01_factory_mode"]) == 4 and int(res.data["controller01_factory_mode"]) == 4:
                self.logger.info("Factory Mode 4, correct! Continue...")
                self.logger.info("CSVFILE connect" + " 0 0 pass")
            else:
                self.dut.execute_command("factory_mode_set --mode 4",5000)
                self.dut.execute_command("reboot",3000)
                time.sleep(5)
                r,text_ = self.dut.execute_command("connect",self.timeout)
                if r == 0:
                    self.logger.info("CSVFILE connect" + " 0 0 pass")
                else:
                    self.logger.info("CSVFILE connect" + " 0 %d fail"%r)
                    flag = False
        return flag
 def test(self):
     '''This function is to set the MFGID, ws_target, Pubkey, for the DUT'''
     perso_dic = {
             "set_mfgid" : configget("PERSO","MFG_ID").upper(),
             "set_wstarget" : configget("PERSO","wstarget"),
              "set_pubkey"    : configget("PERSO","pubkey")
             }
     feuvert =  True
     for key,value in perso_dic.items():
         try:
             rt,text = self.dut.execute_command("perso %s %s"%(key,value),20000)
             res = CommandResult.parse(text)
             if res.rc !=0:
                 self.logger.info("CSVFILE Personalization ok %s fail"%key)
                 return False
         except:
             self.logger.info("Exception occurs during Personalization!!")
             self.logger.info("CSVFILE Personalization ok %s fail"%key)
             feuvert =  False
     if feuvert:
         self.logger.info("CSVFILE Personalization ok ok pass")
         return True
     else:
         self.logger.info("CSVFILE Personalization ok ng fail")
         return False
Esempio n. 5
0
    def test(self):
        rc, text = self.dut.execute_command("probe")
        res_data = CommandResult.parse(text)
        list_check = [
            "mfg_id", "bl_version", "soft_version", "mac", "mcu_id", "secret"
        ]

        for item in list_check:
            try:
                oitem = configget("PERSO", item).strip()
            except:
                oitem = None
            if item in res_data.data:
                item_value = res_data.data[item]
                self.dut.prop[item] = item_value
                if oitem:
                    if item_value.lower() == oitem.lower():
                        self.logger.info("CSVFILE probe_%s_checking " % item +
                                         oitem + " " + item_value + " pass")
                    else:
                        self.logger.info("CSVFILE probe_%s_checking " % item +
                                         oitem + " " + item_value + " fail")
                        return False  # value unexpected
                else:
                    self.logger.info(
                        "CSVFILE probe_%s_checking not_in_config " % item +
                        item_value + " pass")
            else:
                self.logger.info(
                    "CSVFILE probe_%s_checking not_in_probe_data " % item +
                    "not_in_probe_data" + " fail")
                return False

        return True
 def test(self):
     rc, text = self.dut.execute_command("light_sensor request", 2000)
     if rc != 0:
         self.logger.info("CSVFILE LIGHT_SENSOR_REQUEST 0 -1 FAIL")
         return False
     else:
         self.logger.info("CSVFILE LIGHT_SENSOR_REQUEST 0 0 PASS")
         rc, text = self.dut.execute_command("light_sensor get", 2000)
         if rc != 0:
             self.logger.info("CSVFILE VALUE_LIGHT_OFF 0 -1 FAIL")
             return False
         else:
             res = CommandResult.parse(text)
             light_value = str(res.data["value"])
             self.logger.info("CSVFILE VALUE_LIGHT_OFF " + light_value +
                              " [0;4000] PASS")
             while True:
                 answer = input(
                     "Please switch on the light and press ENTER when done:"
                 )
                 if not answer:
                     break
             time.sleep(2)
             rc, text = self.dut.execute_command("light_sensor get", 2000)
             if rc != 0:
                 self.logger.info("CSVFILE VALUE_LIGHT_ON 0 -1 FAIL")
                 return False
             else:
                 res_on = CommandResult.parse(text)
                 light_value_on = str(res.data["value"])
                 self.logger.info("CSVFILE VALUE_LIGHT_ON " +
                                  light_value_on + " [0;4000] PASS")
                 rc, text = self.dut.execute_command(
                     "light_sensor release", 2000)
                 if rc != 0:
                     self.logger.info(
                         "CSVFILE LIGHT_SENSOR_RELEASE 0 -1 FAIL")
                     return False
                 else:
                     self.logger.info(
                         "CSVFILE LIGHT_SENSOR_RELEASE 0 0 PASS")
                     print("Please switch of the light")
                     time.sleep(2)
                     return True
Esempio n. 7
0
    def test(self):
        flag = True
        message = self.message
        colorprint(message[0], "YELLOW")
        input()

        # No Brake OFF,
        res = CommandResult.parse(
            self.dut.execute_command("brake_check", 5000)[1])
        if res.rc == 0 and res.data["left_brake"] == "0" and res.data[
                "right_brake"] == "0":
            self.logger.info("CSVFILE left_brake_off ok ok pass")
            self.logger.info("CSVFILE right_brake_off ok ok pass")
        else:
            self.logger.info("CSVFILE left_brake_off ok ng fail")
            self.logger.info("CSVFILE right_brake_off ok ng fail")
            flag = False

        # Left Brake ON,
        op_messager(message[1])
        res = CommandResult.parse(
            self.dut.execute_command("brake_check", 5000)[1])
        if res.rc == 0 and res.data["left_brake"] == "1" and res.data[
                "right_brake"] == "0":
            self.logger.info("CSVFILE left_brake_on ok ok pass")
        else:
            self.logger.info("CSVFILE left_brake_on ok ng fail")
            flag = False

        # Right Brake ON,
        op_messager(message[2])
        res = CommandResult.parse(
            self.dut.execute_command("brake_check", 5000)[1])
        if res.rc == 0 and res.data["left_brake"] == "0" and res.data[
                "right_brake"] == "1":
            self.logger.info("CSVFILE right_brake_on ok ok pass")
        else:
            self.logger.info("CSVFILE right_brake_on ok ng fail")
            flag = False

        colorprint(message[3], "GREEN")
        return flag
Esempio n. 8
0
    def test(self):
        ''' This function is to set the gat eway the bike'''
        gateway = configget("PERSO", "gateway_url")

        cmd_text = "gateway_get"
        res = CommandResult.parse(self.dut.execute_command(cmd_text, 5000)[1])
        if res.rc == 0 and gateway == res.data['gateway']:
            self.logger.info("CSVFILE Set_Gateway ok ok pass")
            return True
        self.logger.info("CSVFILE Set_Gateway ok ng fail")
        return False
Esempio n. 9
0
    def test(self):
        ''' This function is to set Serial ID to the bike'''
        ''' Global MAC_label must be valide'''

        res = CommandResult.parse(
            self.dut.execute_command("bike_serial_number_get", 5000)[1])
        if res.rc == 0 and res.data["serial number"] == self.dut.serial_id:
            self.logger.info("CSVFILE Check_Serial_ID ok ok pass")
            return True
        else:
            self.logger.info("CSVFILE Check_Serial_ID ok ng fail")
            return False
Esempio n. 10
0
    def test(self):
        main01_config = configget("PERSO", "main_build_version")
        controller01_config = configget("PERSO", "controller_build_version")

        cmd_set = "get_firmware_version"
        res = CommandResult.parse(self.dut.execute_command(cmd_set, 10000)[1])
        main01 = res.data['main_version']
        controller01 = res.data['controller_version']

        if res.rc != 0:
            self.logger.info("CSVFILE Check_Firmware ok ng fail")
            return False
        else:
            self.logger.info("CSVFILE Check_Firmware ok ok pass")
            return True
Esempio n. 11
0
    def test(self):
        '''This function is to check the previous utc is set, then set the current station pls to 0'''
        cur_station = configget("PLS_INFO", "current_station_id")
        pre_station = configget("PLS_INFO", "pre_station_id")

        if cur_station == "10":
            self.logger.info("Current station is T10, only set to zero!")
            rt, text_ = self.dut.execute_command(
                "pls set %s 0" % (cur_station), 1000)
            if rt == 0:
                self.logger.info("CSVFILE set_current_pls_0 ok ok pass")
                return True
            else:
                self.logger.info("CSVFILE set_current_pls_0 ok ng fail")
                self.logger.info("set current station utc to 0 fail.")
                return False

        # Check Prestation UTC
        rc, text = self.dut.execute_command("pls list", 3000)
        if rc != 0:
            self.logger.info("CSVFILE pls_list ok ng fail")
            return False
        res = CommandResult.parse(text)
        self.logger.info("CSVFILE pls_list ok ok pass")

        pre_key = "station[00%s].utc" % pre_station
        if (pre_key in res.data and len(res.data[pre_key]) == 10
                and int(res.data[pre_key]) < int(time.time())):
            self.logger.info(
                "CSVFILE pls_prestation_utc [1470636488;[ %s pass" %
                res.data[pre_key])
            rt, text_ = self.dut.execute_command(
                "pls set %s 0" % (cur_station), 1000)
            if rt == 0:
                self.logger.info("CSVFILE set_current_pls_0 ok ok pass")
                self.logger.info("Current station utc set to 0")
                return True
            else:
                self.logger.info("CSVFILE set_current_pls_0 ok ng fail")
                self.logger.info("set Current station utc to 0 fail.")
                return False

        else:
            self.logger.info(
                "CSVFILE pls_prestation_utc [1470636488;[ no_data fail")
            self.logger.info("PLS set to 0 failed!!!")
            return False
Esempio n. 12
0
    def test(self):
        '''This function is to check Customization ID , very important for iOS installation.'''
        comm_hw_rev_target = configget("PERSO", "comm_hw_rev")
        self.logger.info("Comm_ID_check:")

        cmd_set = "get_comm_id"
        rc, text = self.dut.execute_command(cmd_set, 2000)
        if rc != 0:
            self.logger.info("CSVFILE COMM_ID xxxx -1 FAIL")
            self.logger.info("CSVFILE COMM_HW_REV_ID xxxx -1 FAIL")
            return False
        COMM_dic = CommandResult.parse(text)
        COMM_id = COMM_dic.data["comm_id"]
        COMM_hw_rev_id = COMM_dic.data["comm_hw_rev"]
        self.logger.info("CSVFILE COMM_ID xxxx %s PASS" % COMM_id)
        self.logger.info("CSVFILE COMM_HW_REV_ID %s %s PASS" %
                         (comm_hw_rev_target, COMM_hw_rev_id))
        return True
        """   
Esempio n. 13
0
    def test(self):

        flag = False
        message = self.message
        op_messager(message[1])
        # Turn on light
        res = CommandResult.parse(
            self.dut.execute_command("frontlight on", 4000)[1])
        # op_messager(message[1])
        if res.rc == 0:
            if question_box(message[2]):
                self.logger.info("CSVFILE check_light ok ok pass")
                flag = True

        self.dut.execute_command("frontlight off", 4000)
        if not flag:
            self.logger.info("CSVFILE check_light ok ng fail")
        colorprint(message[3], "GREEN")
        return flag
    def test(self):
        ENCODING = get_encoding()
        if ENCODING == 1 or ENCODING == 2:
            op_messager("動力電池檢測,按Enter鍵繼續 >>> ")
        else:
            op_messager(
                "Battery Detect, please put the personal battery on the holder, or Turn on 36V power supply, Then press ENTER..."
            )
        flag = True

        res = CommandResult.parse(
            self.dut.execute_command("batt_detect", 5000)[1])
        if res.rc == 0 and res.data["value"] == "0":
            self.logger.info("CSVFILE Battery_detect ok ok pass")
        else:
            self.logger.info("CSVFILE Battery_detect ok ng fail")
            flag = False

        colorprint("Test finished, Press ENTER...", "GREEN")
        return flag
    def test(self):
        flag = False
        timeout = 60
        message = self.message
        colorprint(message[0], "YELLOW")
        op_messager(message[1])
        # Turn on electromagnet
        res = CommandResult.parse(
            self.dut.execute_command("electromagnet on", 4000)[1])
        if res.rc == 0:
            # op_messager(message[2])
            if question_box(message[3]):
                self.logger.info("CSVFILE check_electromagnet ok ok pass")
                flag = True

        self.dut.execute_command("electromagnet off", 4000)
        if not flag:
            self.logger.info("CSVFILE check_electromagnet ok ng fail")
        colorprint(message[4], "GREEN")
        return flag
Esempio n. 16
0
    def test(self):

        message = self.message
        flag = False
        colorprint(message[0], "YELLOW")

        # Turn on light
        res = CommandResult.parse(
            self.dut.execute_command("power_led on", 4000)[1])
        if res.rc == 0:
            op_messager(message[1])
            if question_box(message[2]):
                self.logger.info("CSVFILE check_power_led ok ok pass")
                flag = True

        self.dut.execute_command("power_led off", 4000)
        if not flag:
            self.logger.info("CSVFILE check_power_led ok ng fail")
        colorprint(message[3], "GREEN")
        return flag
Esempio n. 17
0
    def test(self):
        #get limit from config.ini
        battery_mv_min = int(configget("TEST_ITEMS", "BATTERY_MV_MIN"))
        battery_mv_max = int(configget("TEST_ITEMS", "BATTERY_MV_MAX"))

        #get battery level value
        rc, text = self.dut.execute_command("get_battery", 2000)
        if rc != 0:
            self.logger.info("CSVFILE get_battery ok   fail")
            self.logger.info("CSVFILE get_battery_mv [0;6000] -1 fail")
            self.logger.info("CSVFILE get_battery_percent [0;100] -1 fail")
            return False
        else:
            self.logger.info("CSVFILE get_battery ok ok pass")
            res = CommandResult.parse(text)
            voltage_mv = int(res.data["voltage_mv"])
            percent = res.data["percent"]
            self.logger.info("CSVFILE get_battery_percent [0;100] " + percent +
                             " pass")
            rt = compare_value("get_battery_voltage", voltage_mv,
                               battery_mv_min, battery_mv_max)
            return True if rt == 0 else False
Esempio n. 18
0
    def test(self):

        #power up adxl
        rc, text = self.dut.execute_command("power up adxl", 2000)

        if rc != 0:
            self.logger.info("CSVFILE POWER_UP_ADXL 0 -1 FAIL")
            return False
        else:
            self.logger.info("CSVFILE POWER_UP_ADXL 0 0 PASS")
            rc, text = self.dut.execute_command("adxl init", 2000)
            if rc != 0:
                self.logger.info("CSVFILE ADXL_INIT 0 -1 FAIL")
                return False
            else:
                self.logger.info("CSVFILE ADXL_INIT 0 0 PASS")
                rc, text = self.dut.execute_command("adxl reset", 2000)
                if rc != 0:
                    self.logger.info("CSVFILE ADXL_RESET 0 -1 FAIL")
                    return False
                else:
                    self.logger.info("CSVFILE ADXL_RESET 0 0 PASS")
                    rc, text = self.dut.execute_command("adxl init", 2000)
                    if rc != 0:
                        self.logger.info("CSVFILE CHECK_ADXL_INIT 0 -1 FAIL")
                        return False
                    else:
                        res = CommandResult.parse(text, ':')
                        adxl_id_01 = str(res.data["[ADXL] ID_1"])
                        self.logger.info("CSVFILE CHECK_ADXL_ID_01 " +
                                         adxl_id_01 + " 0xAD PASS")
                        adxl_id_02 = str(res.data["[ADXL] ID_2"])
                        self.logger.info("CSVFILE CHECK_ADXL_ID_02 " +
                                         adxl_id_02 + " 0x1D PASS")
                        adxl_id_03 = str(res.data["[ADXL] ID_3"])
                        self.logger.info("CSVFILE CHECK_ADXL_ID_03 " +
                                         adxl_id_03 + " 0xF2 PASS")
                        rc, text = self.dut.execute_command(
                            "adxl get_values", 2000)
                        if rc != 0:
                            self.logger.info(
                                "CSVFILE CHECK_ADXL_VALUES 0 -1 FAIL")
                            return False
                        else:
                            res = CommandResult.parse(text)
                            adxl_id_x = str(res.data["Acceleration on axe X"])
                            self.logger.info("CSVFILE CHECK_ADXL_VALUE_X " +
                                             adxl_id_x + " [-250;250] PASS")
                            adxl_id_y = str(res.data["Acceleration on axe Y"])
                            self.logger.info(
                                "CSVFILE CHECK_ADXL_VALUE_Y [-250;250] " +
                                adxl_id_y + " [-250;250] PASS")
                            adxl_id_z = str(res.data["Acceleration on axe Z"])
                            self.logger.info("CSVFILE CHECK_ADXL_VALUE_Y " +
                                             adxl_id_z +
                                             " [-750;250]U[250;750] PASS")
                            rc, text = self.dut.execute_command(
                                "adxl int_1", 2000)
                            if rc != 0:
                                self.logger.info(
                                    "CSVFILE CHECK_ADXL_CONFIG_1 0 -1 FAIL")
                                return False
                            else:
                                self.logger.info(
                                    "CSVFILE CHECK_ADXL_INT_1 0 0 PASS")
                                rc, text = self.dut.execute_command(
                                    "adxl int_2", 2000)
                                if rc != 0:
                                    self.logger.info(
                                        "CSVFILE CHECK_ADXL_CONFIG_2 0 -1 FAIL"
                                    )
                                    return False
                                else:
                                    self.logger.info(
                                        "CSVFILE CHECK_ADXL_INT_1 0 0 PASS")
                                    rc, text = self.dut.execute_command(
                                        "adxl fifo", 2000)
                                    if rc != 0:
                                        self.logger.info(
                                            "CSVFILE CHECK_ADXL_FIFO  FAIL")
                                        return False
                                    else:
                                        res = CommandResult.parse(text, ':')
                                        adxl_fifo_x = str(res.data["x_mean"])
                                        self.logger.info(
                                            "CSVFILE CHECK_ADXL_FIFO_X_MEAN " +
                                            adxl_fifo_x + " [-250;750] PASS")
                                        adxl_fifo_y = str(res.data["y_mean"])
                                        self.logger.info(
                                            "CSVFILE CHECK_ADXL_FIFO_Y_MEAN " +
                                            adxl_fifo_y + " [-250;750] PASS")
                                        adxl_fifo_z = str(res.data["z_mean"])
                                        self.logger.info(
                                            "CSVFILE CHECK_ADXL_FIFO_Z_MEAN " +
                                            adxl_fifo_z + " [-250;750] PASS")
                                        return True