Esempio n. 1
0
 def FindModemPath(self):
     for modem in mm.EnumerateDevices():
         (obj, path) = modem
         try:
             if path.index('/org/chromium/ModemManager/Gobi') == 0:
                 return path
         except ValueError:
             pass
     return None
    def GetModemInfo(self):
        """Find all modems attached and return an dictionary of information.

        This returns a bunch of information for each modem attached to
        the system.  In practice collecting all this information
        sometimes fails if a modem is left in an odd state, so we
        collect as many things as we can to ensure that the modem is
        responding correctly.

        @return A dictionary of information for each modem path.
        """
        results = {}

        devices = mm.EnumerateDevices()
        print 'Devices: %s' % ', '.join([p for _, p in devices])
        for manager, path in devices:
            modem = manager.GetModem(path)
            results[path] = modem.GetModemProperties()
        return results
Esempio n. 3
0
def _EnumerateModems(manager):
    """Get a set of modem paths."""
    return set([x[1] for x in mm.EnumerateDevices(manager)])
    service = conn_mgr.FindCellularService()
    if not service:
        conn_mgr.EnableTechnology('cellular')
        service = conn_mgr.FindCellularService()

    logging.info('ResetAllModems: found service %s', service)

    try:
        if service:
            service.SetProperty('AutoConnect', False),
    except dbus.exceptions.DBusException, e:
        # The service object may disappear, we can safely ignore it.
        if e._dbus_error_name != 'org.freedesktop.DBus.Error.UnknownMethod':
            raise

    for manager, path in mm.EnumerateDevices():
        modem = manager.GetModem(path)
        version = modem.GetVersion()
        # Icera modems behave weirdly if we cancel the operation while the
        # modem is connecting or disconnecting. Work around the issue by waiting
        # until the connect/disconnect operation completes.
        # TODO(benchan): Remove this workaround once the issue is addressed
        # on the modem side.
        utils.poll_for_condition(
            lambda: not modem.IsConnectingOrDisconnecting(),
            exception=utils.TimeoutError('Timed out waiting for modem to ' +
                                         'finish connecting/disconnecting'),
            sleep_interval=1,
            timeout=30)
        modem.Enable(False)
        # Although we disable at the ModemManager level, we need to wait for
 def CountModems(self):
     count = len(mm.EnumerateDevices(''))
     logging.debug('Modem count is %d' % count)
     return count