linux - Python sdbus ModemManager : unable to ut the simple interface - Stack Overflow

admin2025-04-24  2

I've gone through an issue with SDBus and it's ModemManager add-on.

first off, the example in the github repo is working as intended:

.py

the part where I can't wrap my head around is the "Simple Interface" of this module.

So in the example referenced, if you take the "modem" variable and use modem.simple.connect() the function expects a Dict[str, Tuple[str, Any]] arguments.

As there no documentation on that part I'm trying to pass an apn and ip-type.

On the command line, I would use this line :

mmcli -m 0 --simple-connect='apn=myapn,ip-type=ipv4v6'

so I'm expecting that the simple.connect() would take the same.

I've tried numerous way to pass these parameters but I always get the same error

>>> modem.simple.connect({'apn':('s','myapn')})

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3.12/site-packages/sdbus/dbus_proxy_sync_method.py", line 93, in __call__
        rebuilt_args = self.dbus_method._rebuild_args(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.12/site-packages/sdbus/dbus_common_elements.py", line 199, in _rebuild_args
        raise TypeError('Could not flatten the args')
    TypeError: Could not flatten the args

This is the easiest way to reproduce is this code :

import sdbus
from sdbus_block.modemmanager import MM, MMModems
sdbus.set_default_bus(sdbus.sd_bus_open_system())
mm = MM()
mms = MMModems()
modem = mms.get_first()
modem.simple.connect({'apn':('s','myapn')})

Can someone guide me on how to pass arguments to this function ?

Thank you in advance

I'm dropping few information on the environment :

  • ModemManager 1.22
  • Python 3.12
  • python3-sdbus 0.11.1
  • python3-sdbus-modemmanager 1.0.2
  • Yocto Scarthgap (6.6.23 Kernel)
转载请注明原文地址:http://anycun.com/QandA/1745453907a90653.html