示例#1
0
    def init(self):
        """
        Initializes the equipment. The equipment is ready to use.
            - Load equipment driver
            - Connection to the equipment is established
            - Show equipment informations
            - Reset equipment
        """
        self.get_logger().info("Initialization")
        # Loads the driver
        self.load_driver()

        serial_number = self.get_bench_params().get_param_value(
            "serialNumber", "")
        if serial_number not in [None, ""]:
            serial_number = int(
                self.get_bench_params().get_param_value("serialNumber"))

        # get if we use external power supply as charger
        self._use_ext_ps = self.get_bench_params().get_param_value(
            "ExtPowerSupplyAsCharger", False)
        if type(self._use_ext_ps) is str:
            self._use_ext_ps = Util.str_to_bool(self._use_ext_ps)

        # Tries to connect to equipment
        self.__device_index = W.Connect(self, serial_number)
        if self.__device_index == -1:
            raise TestEquipmentException(
                TestEquipmentException.CONNECTION_ERROR,
                "Failed to connect to %s" % self.get_name())
        W.ShowInfo(self)
        W.Reset(self)
        self.battery_connector(False, self.BAT_INVALID)
示例#2
0
    def press_key_combo(self, button_list, press_duration):
        """
        push on the following button

        :type button_list: list of str
        :param button_list: list of button to press on. defined by  PHONE_BUTTON key

        :type press_duration: int
        :param press_duration: time to keep button on.
        """
        missing_btn = set(button_list) - set(self.PHONE_BUTTON)

        if len(missing_btn) > 0:
            self.get_logger().error(
                "missing unlinked to relay button found :" + str(missing_btn))
            raise TestEquipmentException(
                TestEquipmentException.INVALID_PARAMETER,
                "Unknown or not configured button : %s" % str(missing_btn))

        self.get_logger().info("pressing button %s during %ss" %
                               (str(button_list), press_duration))
        # push button
        for button_name in button_list:
            W.Enable(self, self.PHONE_BUTTON[button_name])  # press button
            time.sleep(0.2)
        # wait a while
        time.sleep(press_duration)
        # release button
        for button_name in button_list:
            W.Disable(self, self.PHONE_BUTTON[button_name])  # release button
            time.sleep(0.2)
示例#3
0
def select_resistance(resistance, feature, usb_dio):
    """
    This function select the resistance to program on the wanted feature
    :type resistance: int
    :param resistance: the value of the resistor in ohm
    :type feature: str
    :param feature: can be "bptherm" or "battid"
    :type usb_dio: An Ariane board equipment
    :param usb_dio: the equipment that uses the ProgResistance
    :rtype: none
    """

    usb_dio.get_logger().info("select a %s ohm resistor on %s" %
                              (str(resistance), feature))
    # check the validity of the resistance
    if resistance > 400000 or resistance < 200:
        raise TestEquipmentException(
            TestEquipmentException.INVALID_PARAMETER,
            "the resistance should be between 200 and 400000 Ohm")
    # as the resistance is two serial resistance programmable
    # we have to compute the exact resistance value to each
    rdac0 = min(resistance, 250000)
    rdac1 = max(0, resistance - rdac0)
    # write the resistance
    write_resistance(rdac0, feature, 0, usb_dio)
    write_resistance(rdac1, feature, 1, usb_dio)
    # check the feature to enable
    if feature == "bptherm":
        W.Enable(usb_dio, usb_dio.LINES.bptherm_1m)  # ctrl07
        W.Enable(usb_dio, usb_dio.LINES.bptherm_connect)  # ctrl16
    else:
        raise TestEquipmentException(
            TestEquipmentException.FEATURE_NOT_AVAILABLE,
            "the ProgResistance are available only for 'bptherm' and 'battid'")
示例#4
0
    def init(self):
        """
        Initializes the equipment. The equipment is ready to use.
            - Load equipment driver
            - Connection to the equipment is established
            - Show equipment informations
            - Reset equipment
        """
        self.get_logger().info("Initialization")
        # Loads the driver
        self.load_driver()

        serial_number = None
        if self.get_bench_params().has_parameter("serialNumber"):
            serial_number = \
                int(self.get_bench_params().get_param_value("serialNumber"))

        # Tries to connect to equipment
        self.__device_index = W.Connect(self, serial_number)
        if self.__device_index == -1:
            raise TestEquipmentException(
                TestEquipmentException.CONNECTION_ERROR,
                "Failed to connect to %s" % self.get_name())
        W.ShowInfo(self)
        W.Reset(self)
示例#5
0
 def battery_connector(self, plug, battery_type="DEFAULT"):
     """
     Handles battery insertion / removal
     :type plug: boolean
     :param plug: action to be done:
         - True  => insert battery
         - False => remove battery
     :type battery_type: str
     :param battery_type: battery to plug
     """
     if plug:
         self.get_logger().info("Battery insertion")
         # work around for bench batt id bug
         self.set_battery_type(self.BAT_INVALID)
         # Insert battery
         W.Enable(self, self.LINES.battery)  # ctrl00
         W.Enable(self, self.LINES.supply1_switch)  # ctrl15
         # work around for bench batt id bug
         self.set_battery_type(battery_type)
     else:
         self.get_logger().info("Battery removal")
         # remove battery
         W.Disable(self, self.LINES.battery)  # ctrl00
         W.Enable(self, self.LINES.supply1_switch)  # ctrl15
         # work around for bench batt id bug
         self.set_battery_type(self.BAT_INVALID)
示例#6
0
    def battery_connector(self, plug, battery_type="DEFAULT"):
        """
        Handles battery insertion / removal
        :type plug: boolean
        :param plug: action to be done:
            - True  => insert battery
            - False => remove battery
        :type battery_type: str
        :param battery_type: battery to plug
        """
        if plug:
            self.get_logger().info("Battery insertion")
            # Insert battery
            W.Enable(self, self.LINES.vbatt_force_sens)  # ctrl28
            time.sleep(0.5)
            W.Enable(self, self.LINES.battery)  # ctrl00
            time.sleep(0.5)
            W.Disable(self, self.LINES.vbatt_force_sens)  # ctrl28
            # insert batt id action
            self.set_battery_type(battery_type)

        else:
            self.get_logger().info("Battery removal")
            # remove batt id action
            self.set_battery_type(self.BAT_REMOVED)
            W.Enable(self, self.LINES.vbatt_force_sens)  # ctrl28
            time.sleep(0.5)
            W.Disable(self, self.LINES.battery)  # ctrl00
示例#7
0
    def set_usb_otg_type(self, otg_type):
        """
        Sets the OTG type
        :type otg_type: str
        :param otg_type: OTG type to select:
            - "NORMAL"
            - "DUT_DEVICE"
            - "DUT_HOST"
        """
        self.get_logger().info("Set OTG type to : %s", otg_type)

        if otg_type == "NORMAL":
            W.Disable(self, self.LINES.OTG_ctrl28)  # ctrl28
            W.Enable(self, self.LINES.OTG_ctrl29)  # ctrl29
            W.Enable(self, self.LINES.OTG_ctrl30)  # ctrl30

        elif otg_type == "DUT_DEVICE":
            W.Enable(self, self.LINES.OTG_ctrl28)  # ctrl28
            W.Disable(self, self.LINES.OTG_ctrl29)  # ctrl29
            W.Enable(self, self.LINES.OTG_ctrl30)  # ctrl30

        elif otg_type == "DUT_HOST":
            W.Enable(self, self.LINES.OTG_ctrl28)  # ctrl28
            W.Disable(self, self.LINES.OTG_ctrl29)  # ctrl29
            W.Disable(self, self.LINES.OTG_ctrl30)  # ctrl30

        else:
            raise TestEquipmentException(
                TestEquipmentException.INVALID_PARAMETER,
                "Unknown OTG type : %s!" % otg_type)
示例#8
0
 def reset(self):
     """
     Reset the IO card to default states
     """
     ACBN.reset(self)
     self.ac_charger_connector(False)
     self.glitch(False, "short")
     W.Disable(self, self.LINES.prog_res_rdy)  # ctrl08
     W.Enable(self, self.LINES.prog_res_cs)  # ctrl23
     W.Disable(self, self.LINES.prog_res_clk)  # ctrl24
     W.Disable(self, self.LINES.prog_res_sdi)  # ctrl25
示例#9
0
 def press_power_button(self, duration):
     """
     Presses power button.
     Allow to simulate special behavior on the board like S3 mode.
     :type duration: float
     :param duration: time while the power button is pressed
         The value should be superior than 0 seconds
     """
     self.get_logger().info("Press power button during %s second(s)",
                            str(duration))
     W.Enable(self, self.LINES.button_ctrl12)
     time.sleep(duration)
     W.Disable(self, self.LINES.button_ctrl12)
示例#10
0
    def usb_device_selector(self, usb_device):
        """
        Handles USB device selection
        :param usb_device: USB device to select:
            - "USB_HOST_PC" -> USB Host PC (ACS, FW/SW Updates)
        """
        self.get_logger().info("Select USB device: %s", usb_device)

        if usb_device == ACBP.USB_HOST_PC:
            W.Enable(self, self.LINES.usb_switch_select)
            W.Disable(self, self.LINES.usb_switch_select2)
        else:
            raise TestEquipmentException(
                TestEquipmentException.INVALID_PARAMETER,
                "Unknown USB device: %s!" % usb_device)
示例#11
0
    def __acb_com_cmd_list(self, cmd_list, check_relay_position=False):
        """
        execute sequentially a list of action on relays

        :type cmd_list: list
        :param cmd_list: list of (action,relay where to apply action)

        :type check_relay_position: boolean
        :param check_relay_position: if True then will check all the relay state before doing
                                    the relay activation and if all is already in the wanted state
                                    then no action will be taken

        :rtype: boolean
        :return: True if actions have been taken on relay, False otherwise
        """
        if check_relay_position:
            is_relay_position_ok = True
            # check all relay in given command
            for action, relay in cmd_list:
                # exit if at least one relay is not in the wanted position
                if action != W.GetState(self, relay):
                    is_relay_position_ok = False
                    break

            # if all relay are already positioned then skip any action
            if is_relay_position_ok:
                return False

        for action, relay in cmd_list:
            self.__acb_com_cmd(action, relay)

        return True
示例#12
0
 def sim_card_connector(self, plug):
     """
     Handles SIM card insertion / removal
     :type plug: boolean
     :param plug: action to be done:
         - True  => insert SIM card
         - False => remove SIM card
     """
     if plug:
         self.get_logger().info("SIM card insertion")
         # Insert battery
         W.Enable(self, self.LINES.sim_card)  # ctrl11
     else:
         self.get_logger().info("SIM card removal")
         # remove battery
         W.Disable(self, self.LINES.sim_card)  # ctrl11
示例#13
0
 def usb_connector_data(self, plug):
     """
     Handles USB connector connection and disconnection
     :type plug: boolean
     :param plug: action to be done:
         - True  => plug data cable
         - False => unplug data cable
     """
     if plug:
         self.get_logger().info("Plug Datas USB")
         W.Enable(self, self.LINES.usb_dp_dm_id)
         # Waiting for enumeration
         time.sleep(3)
     else:
         self.get_logger().info("Unplug datas USB")
         W.Disable(self, self.LINES.usb_dp_dm_id)
         time.sleep(1)
示例#14
0
 def init(self):
     """
     Initializes the equipment. The equipment is ready to use.
         - connect sense & force of the alim in order to avoid
         overprotection
     """
     ACBE.init(self)
     W.Enable(self, self.LINES.usb_charger_select)  # ctrl13
     self.usb_connector(False)
示例#15
0
    def usb_connector(self, plug):
        """
        Handles USB connector connection and disconnection
        :type plug: boolean
        :param plug: action to be done:
            - True  => plug currently selected USB device
            - False => unplug currently selected USB device
        """
        if plug:
            self.get_logger().info("Plug USB")
            W.Enable(self, self.LINES.usb_5v_gnd)
        else:
            self.get_logger().info("Unplug USB")
            W.Disable(self, self.LINES.usb_dp_dm_id)

        time.sleep(0.2)

        if plug:
            W.Enable(self, self.LINES.usb_dp_dm_id)
            # Waiting for enumeration
            time.sleep(3)
        else:
            W.Disable(self, self.LINES.usb_5v_gnd)
示例#16
0
    def set_battery_temperature(self, temperature):
        """
        Sets battery temperature
        :type temperature: integer
        :param temperature: temperature in C to set, possible values:
        {95; 70; 50; 25; 10; 5; 0; -15}
        """
        temperature = int(temperature)
        self.get_logger().info("Set battery temperature: %d C", temperature)

        codes = {
            95: [False, False, True],
            70: [True, False, True],
            50: [False, True, True],
            25: [True, True, True],
            10: [False, False, False],
            5: [True, False, False],
            0: [False, True, False],
            -15: [True, True, False]
        }

        lines = [
            self.LINES.temp_value_ctrl6, self.LINES.temp_value_ctrl7,
            self.LINES.temp_value_ctrl16
        ]

        if temperature in codes.keys():
            code = codes[temperature]
            for num in range(len(code)):
                if code[num]:
                    W.Enable(self, lines[num])
                else:
                    W.Disable(self, lines[num])
        else:
            raise TestEquipmentException(
                TestEquipmentException.INVALID_PARAMETER,
                "Unsupported battery temperature: %d!" % temperature)
示例#17
0
    def _is_relay_already_positioned(self, cmd_list):
        """
        Check if an array of relay is already well positioned
        according of expecting state given by the array.

        :type cmd_list: list
        :param cmd_list: list of (action,relay where to apply action)
                        or you can add a 3rd element like following (action, relay,time_to_wait)

        :rtype: boolean
        :return: True if relays are well positioned, False otherwise
        """
        is_relay_position_ok = True
        # check all relay in given command
        for element in cmd_list:
            action = element[0]
            relay = element[1]
            # exit if at least one relay is not in the wanted position
            if action != W.GetState(self, relay):
                is_relay_position_ok = False
                break

        return is_relay_position_ok
示例#18
0
def spi_stop(feature, usb_dio):
    """
    This function generate a invalid sequence in order to
    disable the spi communication
    :type feature: str
    :param feature: can be "bptherm" or "battid"
    :type usb_dio: An Ariane board equipment
    :param usb_dio: the equipment that uses the ProgResistance
    :return: none
    """
    # check the selected feature (bptherm or battid)
    if feature == "bptherm":
        W.Enable(usb_dio, usb_dio.LINES.prog_res_rdy, log=False)  # ctrl08
        W.Disable(usb_dio, usb_dio.LINES.prog_res_cs, log=False)  # ctrl23

        W.Enable(usb_dio, usb_dio.LINES.prog_res_rdy, log=False)  # ctrl08
        W.Enable(usb_dio, usb_dio.LINES.prog_res_cs, log=False)  # ctrl23

        W.Disable(usb_dio, usb_dio.LINES.prog_res_rdy, log=False)  # ctrl08
        W.Enable(usb_dio, usb_dio.LINES.prog_res_cs, log=False)  # ctrl23
示例#19
0
 def glitch(self, start, behavior):
     """
     Start or stop a short or a long Glitch
     :type start: boolean
     :param start: 'True' for starting or 'False' for stopping a glitch
     :type behavior: str
     :param behavior: can be "short" or "long
     """
     if start:
         self.get_logger().info("Start a %s Glitch", behavior)
         if behavior == "short":
             # long glitch
             W.Disable(self, self.LINES.batt_id_glitch)  # ctrl09
             W.Enable(self, self.LINES.batt_id_glitch_duration)  # ctrl10
             W.Disable(self, self.LINES.digital_battery_protocol)  # ctrl14
         elif behavior == "long":
             # short glitch
             W.Disable(self, self.LINES.batt_id_glitch)  # ctrl09
             W.Disable(self, self.LINES.batt_id_glitch_duration)  # ctrl10
             W.Disable(self, self.LINES.digital_battery_protocol)  # ctrl14
         else:
             raise TestEquipmentException(
                 TestEquipmentException.INVALID_PARAMETER,
                 "Unsupported behavior: %d!" % behavior)
     else:
         self.get_logger().info("Stop a %s Glitch", behavior)
         if behavior == "short":
             # long glitch
             W.Enable(self, self.LINES.batt_id_glitch)  # ctrl09
             W.Enable(self, self.LINES.batt_id_glitch_duration)  # ctrl10
             W.Disable(self, self.LINES.digital_battery_protocol)  # ctrl14
         elif behavior == "long":
             # short glitch
             W.Enable(self, self.LINES.batt_id_glitch)  # ctrl09
             W.Disable(self, self.LINES.batt_id_glitch_duration)  # ctrl10
             W.Disable(self, self.LINES.digital_battery_protocol)  # ctrl14
         else:
             raise TestEquipmentException(
                 TestEquipmentException.INVALID_PARAMETER,
                 "Unsupported behavior: %d!" % behavior)
示例#20
0
def spi_data(data, usb_dio):
    """
    This function generate a valid clock during 5 half period
    and a data pulse of 3 half period
    :type data: integer
    :param data: this interger is the bit data (1 or 0)
    :type usb_dio: An Ariane board equipment
    :param usb_dio: the equipment that uses the ProgResistance
    :return: none
    """

    # 1 half period
    time.sleep(0.001)
    W.Disable(usb_dio, usb_dio.LINES.prog_res_sdi, log=False)  # ctrl25
    W.Disable(usb_dio, usb_dio.LINES.prog_res_clk, log=False)  # ctrl24

    # 2 half period
    time.sleep(0.001)
    if data == 1:
        W.Enable(usb_dio, usb_dio.LINES.prog_res_sdi, log=False)  # ctrl25
    elif data == 0:
        W.Disable(usb_dio, usb_dio.LINES.prog_res_sdi, log=False)  # ctrl25
    W.Disable(usb_dio, usb_dio.LINES.prog_res_clk, log=False)  # ctrl24

    # 3 half period
    time.sleep(0.001)
    if data == 1:
        W.Enable(usb_dio, usb_dio.LINES.prog_res_sdi, log=False)  # ctrl25
    elif data == 0:
        W.Disable(usb_dio, usb_dio.LINES.prog_res_sdi, log=False)  # ctrl25
    W.Enable(usb_dio, usb_dio.LINES.prog_res_clk, log=False)  # ctrl24

    # 4 half period
    time.sleep(0.001)
    if data == 1:
        W.Enable(usb_dio, usb_dio.LINES.prog_res_sdi, log=False)  # ctrl25
    elif data == 0:
        W.Disable(usb_dio, usb_dio.LINES.prog_res_sdi, log=False)  # ctrl25
    W.Disable(usb_dio, usb_dio.LINES.prog_res_clk, log=False)  # ctrl24

    # 5 half period
    time.sleep(0.001)
    W.Disable(usb_dio, usb_dio.LINES.prog_res_sdi, log=False)  # ctrl25
    W.Disable(usb_dio, usb_dio.LINES.prog_res_clk, log=False)  # ctrl24