예제 #1
0
def FactoryResetModem(modem_pattern, spc='000000'):
    """Factory resets modem, returns DBus pathname of modem after reset."""
    manager, modem_path = mm.PickOneModem(modem_pattern)
    preexisting_modems = _EnumerateModems(manager)
    modem = manager.GetModem(modem_path).Modem()
    modem.FactoryReset(spc)
    return _WaitForModemToReturn(manager, preexisting_modems, modem_path)
예제 #2
0
def ClearGobiModemFaultInjection():
    """If a Gobi modem is present, try to clear its fault-injection state."""
    try:
        modem_manager, modem_path = mm.PickOneModem('Gobi')
    except error.TestError:
        # Did not find a Gobi modem. Simply return.
        return

    modem = modem_manager.GetModem(modem_path).GobiModem()
    if modem:
        modem.InjectFault('ClearFaults', 1)
예제 #3
0
    def StartIfReady(self, condition_to_remove=None):
        """Call StartTest when remaining_start_conditions have been met."""
        if condition_to_remove:
            self.remaining_start_conditions.discard(condition_to_remove)

        try:
            if (START_DEVICE_PRESENT in self.remaining_start_conditions
                    and mm.PickOneModem('Gobi')):
                self.remaining_start_conditions.discard(START_DEVICE_PRESENT)
        except dbus.exceptions.DBusException, e:
            if e.get_dbus_name() != 'org.freedesktop.DBus.Error.NoReply':
                raise
    def _initialize_modem_components(self):
        """Reset the modem and get access to modem components."""
        # Enable modem first so shill initializes the modemmanager proxies so
        # we can call reset on it.
        self._enable_modem()
        self._reset_modem()

        # PickOneModem() makes sure there's a modem manager and that there is
        # one and only one modem.
        self.modem_manager, self.modem_path = \
                mm.PickOneModem(self._modem_pattern)
        self.modem = self.modem_manager.GetModem(self.modem_path)
        if self.modem is None:
            raise error.TestError('Cannot get modem object at %s.' %
                                  self.modem_path)
예제 #5
0
def PrepareModemForTechnology(modem_path, target_technology):
    """Prepare modem for the technology: Sets things like firmware, PRL."""

    manager, modem_path = mm.PickOneModem(modem_path)

    logger.info('Found modem %s' % modem_path)

    # todo(byronk) : This returns TechnologyFamily:UMTS on a Pixel. ????
    current_family = manager.GetModem(modem_path).GetCurrentTechnologyFamily()
    target_family = cellular.TechnologyToFamily[target_technology]

    if current_family != target_family:
        logger.debug('Modem Current Family: %s ' % current_family)
        logger.debug('Modem Target Family : %s ' % target_family)
        modem_path = SetFirmwareForTechnologyFamily(manager, modem_path,
                                                    target_family)

    if target_family == cellular.TechnologyFamily.CDMA:
        modem_path = PrepareCdmaModem(manager, modem_path)
        # Force the modem to report that is has been activated since we
        # use a custom PRL and have already manually activated it.
        manager.GetModem(modem_path).GobiModem().ForceModemActivatedStatus()

    # When testing EVDO, we need to force the modem to register with EVDO
    # directly (bypassing CDMA 1x RTT) else the modem will not register
    # properly because it looks for CDMA 1x RTT first but can't find it
    # because the call box can only emulate one technology at a time (EVDO).
    try:
        if target_technology == cellular.Technology.EVDO_1X:
            network_preference = modem.Modem.NETWORK_PREFERENCE_EVDO_1X
        else:
            network_preference = modem.Modem.NETWORK_PREFERENCE_AUTOMATIC
        gobi = manager.GetModem(modem_path).GobiModem()
        gobi.SetNetworkPreference(network_preference)
    except AttributeError:
        # Not a Gobi modem
        pass

    return modem_path
    def run_once(self, config, technologies, wait_for_disc, verify_set_power):

        # This test only works if all the technologies are in the same
        # family. Check that before doing anything else.
        families = set(
            cellular.TechnologyToFamily[tech] for tech in technologies)
        if len(families) > 1:
            raise error.TestError('Specify only one family not: %s' % families)

        # choose a technology other than the one we plan to start with
        technology = technologies[-1]
        with environment.DefaultCellularTestContext(config) as c:
            env = c.env
            flim = flimflam.FlimFlam()
            flim.SetDebugTags('manager+device+modem')
            env.StartDefault(technology)
            network.ResetAllModems(flim)
            logging.info('Preparing for %s' % technology)
            cell_tools.PrepareModemForTechnology('', technology)

            # TODO(jglasgow) Need to figure out what isn't settling here.
            # Going to wait 'til after ResetAllModems changes land.
            time.sleep(10)

            # Clear all errors before we start.
            # Resetting the modem above may have caused some errors on the
            # 8960 (eg. lost connection, etc).
            env.emulator.ClearErrors()

            service = env.CheckedConnectToCellular(timeout=CELLULAR_TIMEOUT)

            # Step through all technologies, forcing a transition
            failed_technologies = []
            manager, modem_path = mm.PickOneModem('')
            cell_modem = manager.GetModem(modem_path)
            for tech in technologies:
                tname = str(tech).replace('Technology:', '')
                if verify_set_power:
                    logging.info('Powering off basestation')
                    env.emulator.SetPower(cellular.Power.OFF)
                    self.TimedPollForCondition(
                        'Power.OFF.%s.deregister_time' % tname,
                        lambda: not cell_modem.ModemIsRegistered(),
                        timeout=CELLULAR_TIMEOUT,
                        exception=_STILL_REGISTERED_ERROR)

                    logging.info('Powering on basestation')
                    env.emulator.SetPower(cellular.Power.DEFAULT)
                    self.TimedPollForCondition(
                        'Power.DEFAULT.%s.register_time' % tname,
                        lambda: cell_modem.ModemIsRegistered(),
                        timeout=CELLULAR_TIMEOUT,
                        exception=_NOT_REGISTERED_ERROR)

                logging.info('Stopping basestation')
                env.emulator.Stop()
                if wait_for_disc:
                    self.TimedPollForCondition(
                        'Stop.%s.deregister_time' % tname,
                        lambda: not cell_modem.ModemIsRegistered(),
                        timeout=CELLULAR_TIMEOUT,
                        exception=_STILL_REGISTERED_ERROR)

                logging.info('Reconfiguring for %s' % tech)
                env.emulator.SetTechnology(tech)
                env.emulator.Start()

                try:
                    self.TimedPollForCondition(
                        'Start.%s.register_time' % tname,
                        lambda: cell_modem.ModemIsRegisteredUsing(tech),
                        timeout=CELLULAR_TIMEOUT,
                        exception=_WrongTech(tech))
                except _WrongTech, wt:
                    failed_technologies.append(
                        (wt.technology, cell_modem.GetAccessTechnology()))