[PATCH] osmo-gsm-tester[master]: modem: Identify modems by sysfs path instead of ofono dbus path

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Fri Feb 23 16:14:41 UTC 2018


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/6858

to look at the new patch set (#4).

modem: Identify modems by sysfs path instead of ofono dbus path

ofono dbus paths are non-deterministic and can change over time for a
given modem. For instance when ofono is restartd or if a modem crashes
and the object is destroyed and re-announced by udev.

Requires at least ofono 1df92289d4e09a1e2db0b189b5153a4c238f98f1, which
implemented the feature to export the sysfs path to modem properties.

Related: OS#2509

Change-Id: Ibc45a196abadded2706dc9d57b6a3a796b43a201
---
M example/resources.conf
M src/osmo_gsm_tester/modem.py
2 files changed, 19 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/58/6858/4

diff --git a/example/resources.conf b/example/resources.conf
index ce370a6..fb2ac9f 100644
--- a/example/resources.conf
+++ b/example/resources.conf
@@ -67,16 +67,16 @@
     band: GSM-1900
 
 modem:
-- label: sierra_1
-  path: '/sierra_1'
+- label: sierra_1st
+  path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.2'
   imsi: '901700000009031'
   ki: '80A37E6FDEA931EAC92FFA5F671EFEAD'
   auth_algo: 'comp128v1'
   ciphers: [a5_0, a5_1]
   features: ['sms', 'voice', 'ussd', 'gprs']
 
-- label: sierra_2
-  path: '/sierra_2'
+- label: sierra_2nd
+  path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.3'
   imsi: '901700000009029'
   ki: '00969E283349D354A8239E877F2E0866'
   auth_algo: 'comp128v1'
@@ -84,7 +84,7 @@
   features: ['sms', 'voice', 'ussd', 'gprs']
 
 - label: ec20
-  path: '/gobi_0'
+  path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.6'
   imsi: '901700000009030'
   ki: 'BB70807226393CDBAC8DD3439FF54252'
   auth_algo: 'comp128v1'
@@ -92,7 +92,7 @@
   features: ['sms', 'ussd', 'gprs']
 
 - label: gobi2k
-  path: '/gobi_3'
+  path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.5'
   imsi: '901700000009032'
   ki: '2F70DCA43C45ACB97E947FDD0C7CA30A'
   auth_algo: 'comp128v1'
diff --git a/src/osmo_gsm_tester/modem.py b/src/osmo_gsm_tester/modem.py
index 5afd2d1..96b65d8 100644
--- a/src/osmo_gsm_tester/modem.py
+++ b/src/osmo_gsm_tester/modem.py
@@ -92,6 +92,14 @@
     root = systembus_get('/')
     return sorted(root.GetModems())
 
+def get_dbuspath_from_syspath(syspath):
+    modems = list_modems()
+    for dbuspath, props in modems:
+        if props.get('SystemPath', '') == syspath:
+            return dbuspath
+    raise ValueError('could not find %s in modem list: %s' % (syspath, modems))
+
+
 def _async_result_handler(obj, result, user_data):
     '''Generic callback dispatcher called from glib loop when an async method
     call has returned. This callback is set up by method dbus_async_call.'''
@@ -341,10 +349,12 @@
 
     def __init__(self, conf):
         self.conf = conf
-        self.path = conf.get('path')
-        super().__init__(log.C_TST, self.path)
+        self.syspath = conf.get('path')
+        self.dbuspath = get_dbuspath_from_syspath(self.syspath)
+        super().__init__(log.C_TST, self.dbuspath)
+        self.dbg('creating from syspath %s', self.syspath)
         self.sms_received_list = []
-        self.dbus = ModemDbusInteraction(self.path)
+        self.dbus = ModemDbusInteraction(self.dbuspath)
         self.register_attempts = 0
         self.call_list = []
         # one Cancellable can handle several concurrent methods.

-- 
To view, visit https://gerrit.osmocom.org/6858
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ibc45a196abadded2706dc9d57b6a3a796b43a201
Gerrit-PatchSet: 4
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list