Esempio n. 1
0
    def __init__(self, name, model, eqt_params, bench_params):
        """
        Constructor

        :type name: str
        :param name: the bench name of the equipment

        :type model: str
        :param model: the model of the equipment

        :type eqt_params: dict
        :param eqt_params: the dictionary containing equipment catalog parameters
        """
        INFCTools.__init__(self)
        ExeRunner.__init__(self, name, model, eqt_params)

        self._handle = None

        # Retrieve parameters from BenchConfig for connection
        self._host = str(bench_params.get_param_value("HostIP"))
        self._port = str(bench_params.get_param_value("PortNumber"))
        self._mp300_device = str(bench_params.get_param_value("DeviceToUse"))
        self._connection_type = str(
            bench_params.get_param_value("ConnectionType"))
        self._script_path = str(bench_params.get_param_value("ScriptFolder"))
        self._log_path = str(bench_params.get_param_value("LogFolder"))

        self._mp_manager_thread = None
Esempio n. 2
0
    def __init__(self, name, model, eqt_params, bench_params):
        """
        Constructor
        :type name: str
        :param name: the bench name of the equipment
        :type model: str
        :param model: the model of the equipment
        :type eqt_params: dict
        :param eqt_params: the dictionary containing equipment catalog parameters
        :type bench_params: dict
        :param bench_params: the dictionary containing bench parameters of the equipment
        """
        INFCRobot.__init__(self)
        ExeRunner.__init__(self, name, model, eqt_params)
        self.__bench_params = bench_params
        # Get Serial parameters for connection
        self.serial_com_port = str(self.__bench_params.get_param_value("ComPort"))

        self.__retrieve = 3

        # current position (unfortunatly it's impossible to retrieve robot position)
        # so we move the robot to zero position in the init
        self.__current_position = {'x': 0, 'y': 0, 'z': 0}

        self.positioning(str(self.__current_position['x']), str(self.__current_position['y']), str(self.__current_position['z']), "null")
Esempio n. 3
0
    def ringtone_detection(self,
                           accessories_type=None):
        """
        launch a command to APx585 to detect ringtone
        :type accessories_type: str
        :param accessories_type: accessories type: earpiece, speaker, headset,
                                bluetootha2dp, bluetoothhsp

        :rtype: str
        :return: executable return code
        """

        waitendprocess = True

        cmd_line = "%s %s " % ("ringtonedetection", accessories_type)

        apx585_result = ExeRunner.start_exe(self, cmd_line, self.TIMEOUT, waitendprocess)

        exec_return_code = apx585_result[1]

        # if exception occured during execution => kill AudioPrecision application
        if exec_return_code == 3:
            self._logger.info("Apx executable timeout")
            subprocess.Popen("taskkill /F /IM AudioPrecision.APx500.exe /T", shell=True)

        return exec_return_code
Esempio n. 4
0
 def __init__(self, name, model, eqt_params, bench_params):
     """
     Constructor
     :type name: str
     :param name: the bench configuration name of the equipment
     :type model: str
     :param model: the model of the equipment
     :type eqt_params: dict
     :param eqt_params: the dictionary containing equipment parameters
     :type bench_params: dict
     :param bench_params: the dictionary containing equipment bench parameters
     """
     IAudioAnalyzer.__init__(self)
     ExeRunner.__init__(self, name, model, eqt_params)
     self.__bench_params = bench_params
     self._device = None
     self.__handle = None
     self.__pipeHandle = None
     self.__charBuffer = None
     self.__bNbrRead = None
Esempio n. 5
0
    def exchange_apdu(self, protocol_type, bitrate, data_size, apdu_case,
                      loop):
        """
        Exchange APDU with test applet installed on secure element

        :type protocol_type: str
        :param protocol_type: choose std 14443 type A or B

        :type bitrate : str
        :param bitrate: select communication bitrate

        :type data_size : str
        :param data_size: choose command and response data size

        :type apdu_case : str
        :param apdu_case : select the apdu case to send

        :type loop : int
        :param loop : number of apdu to send

        :rtype: bool
        :return: result: True if test passes
        """

        self._logger.info(
            "Protocol type and bitrate parameters cannot be configured with this tool"
        )

        # create temporary folder to store script
        script_folder = tempfile.mkdtemp()
        script_file = str(os.path.join(script_folder,
                                       "exchangeApduScript.txt"))
        self._logger.info("Script file location is " + script_file)

        self._build_apdu_exchange_script(apdu_case, data_size, loop,
                                         script_file)

        cmd_line = "%s" % script_file
        output = ExeRunner.start_exe(self, cmd_line)

        self._logger.debug("GPShell returnCode : " + str(output[1]))
        if output[1] is None or output[1] != 0:
            self._logger.error("Error during GPShell execution")
            raise TestEquipmentException(
                TestEquipmentException.SPECIFIC_EQT_ERROR,
                "Error during GPShell execution")

        result = self._get_apdu_exchange_result(output[0])

        # remove temporary folder where script is stored
        self._logger.info("Remove temporary script folder")
        shutil.rmtree(script_folder, ignore_errors=False)

        return result
Esempio n. 6
0
    def __init__(self, name, model, eqt_params):
        """
        Constructor

        :type name: str
        :param name: the bench name of the equipment

        :type model: str
        :param model: the model of the equipment

        :type eqt_params: dict
        :param eqt_params: the dictionary containing equipment catalog parameters
        """
        INFCTools.__init__(self)
        ExeRunner.__init__(self, name, model, eqt_params)

        # The logger instance to use
        self.__logger = logging.getLogger("%s.%s.%s" % (
            ACS_LOGGER_NAME,
            EQT_LOGGER_NAME,
            self.__class__.__name__,
        ))
Esempio n. 7
0
    def positioning(self, xCoordinate, yCoordinate, zCoordinate, timer):
        """
        Change robot position
        :type xCoordinate: str
        :param xCoordinate: X-axis coordinate. Use "null" to move along Z axis
        :type yCoordinate : str
        :param yCoordinate: Y-axis coordinate. Use "null" to move along Z axis
        :type zCoordinate : str
        :param zCoordinate: Z-axis coordinate. Use "null" to move in XY plan
        :type timer : str
        :param timer: time in seconds to stay in position before coming back at origin. Use "null" to keep the position
        """

        # make sure that the com interface is released
        self._serialtesting()

        cmd_line = "%s %s %s %s %s" % (xCoordinate, yCoordinate, zCoordinate, timer, self.serial_com_port)

        # try several time in case of unhandled exceptions
        for i in range(self.__retrieve):
            try:
                ExeRunner.start_exe(self, cmd_line)
                break
            except TestEquipmentException:
                # if we are in the last try, raise the test equipment exception
                if i == self.__retrieve-1:
                    raise (TestEquipmentException.CRITICAL_FAILURE, " Robot failed to move see log")
                # if robot failed, just wait and try again
                time.sleep(5)
                pass

        # save new position
        if is_number(xCoordinate) and is_number(yCoordinate) and is_number(zCoordinate):
            self.__current_position['x'] = int(xCoordinate)
            self.__current_position['y'] = int(yCoordinate)
            self.__current_position['z'] = int(zCoordinate)
Esempio n. 8
0
    def get_volume(self,
                   call_type=None,
                   accessories_type=None):
        """
        launch a command to APx585
        :type call_type: str
        :param call_type: 2G, 3G, VOIP
        :type accessories_type: str
        :param accessories_type: accessories type: earpiece, speaker, headset,
                                bluetootha2dp, bluetoothhsp

        :rtype: (str, str)
        :return: tuple of (executable return code, volume)
        """

        waitendprocess = False

        # Pipe handle creation
        self.create_pipe()

        cmd_line = "%s %s %s" % ("getvolume",
                                 call_type,
                                 accessories_type)

        apx585_result = ExeRunner.start_exe(self, cmd_line, self.TIMEOUT, waitendprocess)

        # Waiting message from APx
        l_volume = self.read_pipe()

        if not waitendprocess:
            exec_return_code = apx585_result[2].wait()
        else:
            exec_return_code = apx585_result[1]

        # if exception occured during execution => kill AudioPrecision application
        if exec_return_code == 3:
            self._logger.info("Apx executable timeout")
            subprocess.Popen("taskkill /F /IM AudioPrecision.APx500.exe /T", shell=True)

        self.close_pipe()

        return exec_return_code, l_volume
Esempio n. 9
0
    def check_reader_connection(self):
        """
        Check APDU response returned to see if card is removed

        :rtype: boolean
        :return: True if APDU responses are OK, False if no
                                connection possible
        """
        # Create temporary folder to store script
        script_folder = tempfile.mkdtemp()
        script_file = str(
            os.path.join(script_folder, "checkConnectionApduScript.txt"))

        output = ""
        # Build script file
        script = open(script_file, 'w')
        try:
            script.write(
                'establish_context\nenable_trace\ncard_connect\ncard_disconnect\nrelease_context'
            )

            # Run program that sends APDU
            cmd_line = "%s" % script_file
            output = ExeRunner.start_exe(self, cmd_line)

        finally:
            script.close()

        # remove temporary folder where script is stored
        self._logger.debug("Remove temporary script folder")
        try:
            shutil.rmtree(script_folder, ignore_errors=False)
        except Exception as ex:  # pylint: disable=W0703
            self.__logger.error(" Error during removal of temp directory (" +
                                str(ex) + ")")

        if "card_connect() returns " in output[0]:
            return False

        return True
Esempio n. 10
0
    def __manage_apx585(self,
                        execution_type,
                        board_type=None,
                        test_type=None,
                        call_type=None,
                        accessories_type=None,
                        signal_tested_direction=None,
                        dut_bt_address=None):
        """
        launch a command to APx585.

        :type execution_type: str
        :param execution_type: Init, pair_bt, run or calibration

        :type board_type: str
        :param board_type: board_type from device_catalog

        :type test_type: str
        :param test_type: test executed on device

        :type call_type: str
        :param call_type: 2G, 3G, VOIP

        :type accessories_type: str
        :param accessories_type: accessories type: earpiece, speaker, headset,
                                bluetootha2dp, bluetoothhsp
        :type signal_tested_direction: str
        :param signal_tested_direction: UL, DL

        :type dut_bt_address: str
        :param dut_bt_address: dut mac bluetooth address

        :rtype: str
        :return: executable return code

        """
        waitendprocess = True

        if execution_type == "init":
            if board_type is not None and test_type is not None:
                cmd_line = "%s %s %s" % (execution_type, board_type, test_type)
            else:
                raise TestEquipmentException(TestEquipmentException.INVALID_PARAMETER)

        elif execution_type == "run":
            if accessories_type is not None and call_type is not None \
                    and signal_tested_direction is not None:
                cmd_line = "%s %s %s %s" % (execution_type, call_type,
                                            accessories_type, signal_tested_direction)
            else:
                raise TestEquipmentException(TestEquipmentException.INVALID_PARAMETER)

        elif execution_type == "pairbt":
            if dut_bt_address is not None:
                cmd_line = "%s %s" % (execution_type, dut_bt_address)
            else:
                raise TestEquipmentException(TestEquipmentException.INVALID_PARAMETER)

        elif execution_type == "connectbt":
            if dut_bt_address is not None:
                cmd_line = "%s %s %s" % (execution_type,
                                         accessories_type,
                                         dut_bt_address)
            else:
                raise TestEquipmentException(TestEquipmentException.INVALID_PARAMETER)

        elif execution_type == "calibration":
            if dut_bt_address is not None:
                cmd_line = "%s %s %s %s %s %s" % (execution_type,
                                                  board_type,
                                                  call_type,
                                                  accessories_type,
                                                  signal_tested_direction,
                                                  dut_bt_address)
            else:
                raise TestEquipmentException(TestEquipmentException.INVALID_PARAMETER)
        else:
            raise TestEquipmentException(TestEquipmentException.INVALID_PARAMETER)

        apx585_result = ExeRunner.start_exe(self, cmd_line, self.TIMEOUT, waitendprocess)

        if not waitendprocess:
            exec_return_code = apx585_result[2].wait()
        else:
            exec_return_code = apx585_result[1]

        # if exception occured during execution => kill AudioPrecision application
        if exec_return_code == ExeRunner.NOT_TERMINATED:
            self._logger.info("Apx executable timeout")
            subprocess.Popen("taskkill /F /IM AudioPrecision.APx500.exe /T", shell=True)
        return exec_return_code
Esempio n. 11
0
    def glitch_detection_before_switch(self,
                                       test_type,
                                       board_type,
                                       call_type,
                                       accessories_type,
                                       signal_tested_direction):
        """
        Run Apx585 glitch detection in call.

        :type test_type: str
        :param test_type: glitch detection type glitchdetectiononswitch or glitchdetectiononswap

        :type board_type: str
        :param board_type: board_type from device_catalog

        :type call_type: str
        :param call_type: 2G, 3G, VOIP

        :type accessories_type: str
        :param accessories_type: accessories type: earpiece, speaker, headset, bluetootha2dp, bluetoothhsp

        :type signal_tested_direction: str
        :param signal_tested_direction: UL, DL

        :rtype: tuple
        :return: A tuple containing

        ::
            - stdout as C{in}: 0 if ready -1 else
            - return code as C{Popen}: the executable process
        """

        waitendprocess = False

        if signal_tested_direction == "UL":
            self._device = DeviceManager().get_device("PHONE1")
        else:
            self._device = DeviceManager().get_device("PHONE2")

        # Pipe handle creation
        l_create_pipe = self.create_pipe()
        time.sleep(0.5)
        self._logger.info("Create pipe => " + str(l_create_pipe))

        cmd_line = "%s %s %s %s %s" % (test_type, board_type, call_type,
                                       accessories_type, signal_tested_direction)

        apx585_result = ExeRunner.start_exe(self, cmd_line, self.TIMEOUT_PIPE, waitendprocess)
        self._logger.info("Create pipe => " + str(self.__pipeHandle))

        # Waiting message from APx
        self._logger.info("Start read pipe")
        l_ready = self.read_pipe()
        self._logger.info("End read pipe => " + str(l_ready))
        time.sleep(0.5)

        if l_ready == "READY":
            self.write_pipe("GO")
            return 0, apx585_result[2]
        else:
            apx585_result[2].terminate()
            return -1, None
Esempio n. 12
0
    def get_dtmf(self,
                 accessories_type=None,
                 signal_tested_direction=None,
                 key_touch=None):
        """
        launch a command to APx585
        :type accessories_type: str
        :param accessories_type: accessories type: earpiece, speaker, headset,
                                bluetootha2dp, bluetoothhsp
        :type signal_tested_direction: str
        :param signal_tested_direction: UL, DL

        :rtype: str
        :return: executable return code

        """

        waitendprocess = False
        exec_return_code = 3
        l_touch_press2 = -1

        if signal_tested_direction == "UL":
            self._device = DeviceManager().get_device("PHONE1")
        else:
            self._device = DeviceManager().get_device("PHONE2")

        # Pipe handle creation
        l_create_pipe = self.create_pipe()
        time.sleep(0.5)
        self._logger.info("Create pipe => " + str(l_create_pipe))

        cmd_line = "%s %s %s" % ("getdtmf", accessories_type, signal_tested_direction)

        apx585_result = ExeRunner.start_exe(self, cmd_line, self.TIMEOUT_PIPE, waitendprocess)
        self._logger.info("Create pipe => " + str(self.__pipeHandle))

        # Waiting message from APx
        self._logger.info("Start read pipe")
        l_ready = self.read_pipe()
        self._logger.info("End read pipe => " + str(l_ready))
        time.sleep(0.5)

        if l_ready == "READY":
            self.write_pipe("GO")
            time.sleep(1)
            # Key press
            self._logger.info("DTMF press touch " + key_touch)
            self._device.run_cmd("adb shell input text " + key_touch, 1)
            self._logger.info("End press touch")
            self._logger.info("Read pipe")
            l_touch_press = self.read_pipe()
            self._logger.info("End read pipe (touch press) => " + str(l_touch_press))
            exec_return_code = apx585_result[2].wait()
            self._logger.info("End wait pipe (exec_return_code) => " + str(exec_return_code))
            if l_touch_press != "READY":
                l_touch_press2 = int(l_touch_press) - 48
        else:
            apx585_result[2].terminate()

        self._logger.info("Start close pipe")
        self.close_pipe()
        self._logger.info("End close pipe")

        # if exception occured during execution => kill AudioPrecision application
        if exec_return_code == 3:
            self._logger.info("Apx executable timeout")
            subprocess.Popen("taskkill /F /IM AudioPrecision.APx500.exe /T", shell=True)

        return exec_return_code, str(l_touch_press2)
Esempio n. 13
0
 def _launch_in_server_mode(self):
     """
     Launch MP manager in server mode
     """
     cmd_line = "/s:%s:%s" % (self._port, self._host)
     ExeRunner.start_exe(self, cmd_line)