Exemplo n.º 1
0
    def zoov_login(self, timeout_ms=12000):
        station_name = configget("TEST_STATION", "station_name").lower()
        station_version = configget("TEST_STATION", "station_version").lower()

        time_start = time.time()
        self.uart.flushInput()
        while True:
            msg_returned = self.get_shell(self.name, 2000)
            if msg_returned[0]:
                return True
            if "test-station login" in msg_returned[1]:
                self.send_command("teststation")
                probe_result, text = self.get_result(4000, "Password")
                self.send_command("test")
                probe_result, text = self.get_result(4000, "station name")
            elif "station name" in msg_returned[1]:
                self.logger.info(
                    "======>>>>>>>>>>>>>> Login with station information")

            self.send_command("zoov01-%s" % station_name)
            time.sleep(0.5)
            self.send_command(station_version)
            probe_result, text = self.get_result(6000, station_name)
            if probe_result >= 0:
                return True
            elapsed_time = (time.time() - time_start) * 1000
            if elapsed_time > timeout_ms:
                self.logger.warn("-->timeout: %d ms", elapsed_time)
                colorprint("cmd timeout", "RED")
                return False
Exemplo n.º 2
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
Exemplo n.º 3
0
    def get_result(self, timeout_ms, prompt="shell>", displayRX=True):
        ''' This function returns the status and result of UART after sending the cmd
            rt =  0: good
            rt =  1: shell found, but rc is not 0
            rt = -1: time_out
            text: all the content
        '''
        text = ""
        text_pos = 0
        return_value = -1
        time_start = time.time()
        self.logger.debug("--------------- %s RX start ---------------",
                          self.name)
        while True:
            chunk = self.uart.read(512)
            elapsed_time = (time.time() - time_start) * 1000
            # Do we need to decode/encode !?
            # Replace non-ascii characters with '?' because we sometimes receive - because of a bad uart connection ? -
            # non-ascii characters from the DUT
            text += chunk.decode('ascii', 'replace')
            #### Display board RX in logs, in "realtime"
            if displayRX:
                while True:
                    cr_pos = text.find("\r", text_pos)
                    if cr_pos == -1:
                        break
                    stripped = text[text_pos:cr_pos].strip('\r\n')
                    if len(stripped) > 0:
                        self.logger.debug("  %s", stripped)
                    text_pos = cr_pos + 1

            ### Return on shell prompt, or timeout
            if text.find(prompt) != -1:
                return_value = 1 if text.find('rc=0') == -1 else 0
                break
            if elapsed_time > timeout_ms:
                self.logger.warn("-->timeout: %d ms", elapsed_time)
                colorprint("cmd timeout", "RED")
                break

        self.log(text)
        ## Flush Display RX in logs
        if displayRX:
            stripped = text[text_pos:].strip('\r\n')
            if len(stripped) > 0:
                self.logger.debug("  %s", stripped)
        if return_value == 0:
            resume = "==>> prompt found, and rc=0"
        elif return_value == 1:
            resume = "==>> prompt found, but no 'rc=0'"
        else:
            resume = None
        self.logger.debug(resume)
        self.logger.debug("--------------- %s RX end ---------------",
                          self.name)
        return (return_value, text)
Exemplo n.º 4
0
    def test(self):
        flag = False
        message = self.message
        colorprint(message[0], "YELLOW")
        op_messager(message[1])
        rc, text = self.dut.execute_command("play_sound", 10000)
        if rc == 0:
            flag = question_box(message[2])
        if flag:
            self.logger.info("CSVFILE play_sound ok ok pass")
        else:
            self.logger.info("CSVFILE play_sound ok fail fail")

        colorprint(message[3], "GREEN")
        return flag
Exemplo n.º 5
0
    def test(self): 
        msg = "                                                         \n" + \
              "Please Use Multimter to Bipbip check the Following Points\n" + \
              "CAN EXTERNAL HIGH    CAN EXTERNAL LOW\n"+ \
              "BRAKE LEFT and RIGHT\n" + \
              "STACK_NEXT_BIKE_DETECT\n" + \
              "                                                         \n"

        colorprint(msg,"YELLOW")
        input()

        msg = "Is all Right, Did you hear all the DiDi?? Yes/No? " 
        if question_box(msg):
            self.logger.info( "CSVFILE cable_soudering ok ok pass")
            return True
        self.logger.info( "CSVFILE cable_soldering ok fail fail")
        return False
Exemplo n.º 6
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
Exemplo 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
    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
Exemplo n.º 10
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
Exemplo n.º 11
0
    def test(self):
        if locale.getdefaultlocale()[0] == 'zh_CN':
            colorprint("请准备开始测试")
        else:
            colorprint("please press any key to begin the BUTTON TEST...",
                       "YELLOW")
        os.system("pause")

        if locale.getdefaultlocale()[0] == 'zh_CN':
            colorprint("请在6秒之内按下按键", "YELLOW")
        else:
            colorprint("please press the button within 10 seconds", "YELLOW")

        rc, text = self.dut.execute_command("push_button test 10", 11000)
        if rc == 0:
            self.logger.info("CSVFILE check_button ok ok pass")
            return True
        else:
            self.logger.info(
                "Error!! No Button pressing deteced, or Button Test failed")
            self.logger.info(showErrorCode("50301"))
            self.logger.info("CSVFILE check_button ok fail fail")
            return False