test: fix list-modems hang & simplify handling of Byte/Bool properties
PATCH 1/1 test: fix list-modems hang & simplify handling of Byte/Bool properties
From 690d6af7b672d883bd7d7b86435ddcfad5bdc15d Mon Sep 17 00:00:00 2001
From: Andres Salomon <[email protected]>
Date: Tue, 9 Dec 2025 22:36:16 -0500
Subject: [PATCH] test: fix list-modems hang & simplify handling of Byte/Bool
properties
Using list-modems with current phonesim (2.0) results in list-modems hanging while trying to print SimToolkit's IdleModeIcon property. No errors; it just silently hangs. The issue is that it's a dbus.Byte with the value b'0' (which python implicitly converts to something that makes its i/o and string handling deeply unhappy).
It's unpleasant to have to special-case every dbus.Byte property value, so instead let's display Bytes based on their type. That will help future-proof this script as new properties get added to interfaces.
While we're at it, also stop implicitly converting dbus.Boolean values to "1"/"0", and use "TRUE"/"FALSE" to make it clearer that they are bools.
A small sample of what list-modem's output looks like with phonesim:
task-0: [ org.ofono.SimToolkit ] task-0: IdleModeText = task-0: IdleModeIcon = 0 task-0: MainMenuTitle = task-0: MainMenuIcon = 0 task-0: MainMenu = task-0: [ org.ofono.MessageWaiting ] task-0: VoicemailWaiting = TRUE task-0: VoicemailMessageCount = 1 task-0: VoicemailMailboxNumber = 6789 task-0: [ org.ofono.SimAuthentication ] task-0: NetworkAccessIdentity = [email protected]
--- test/list-modems | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
test/list-modems +4 -8
@@ -50,14 +50,6 @@ for path, properties in modems: for i in properties[key]: val += "[" + i + "] = '" val += properties[key][i] + "' " - elif key in ["MobileNetworkCodeLength", - "VoicemailMessageCount", - "MicrophoneVolume", - "SpeakerVolume", - "Strength", - "DataStrength", - "BatteryChargeLevel"]: - val = int(properties[key]) elif key in ["MainMenu"]: val = ", ".join([ text + " (" + str(int(icon)) + ")" for text, icon in properties[key] ])
@@ -76,6 +68,10 @@ for path, properties in modems: else: val += properties[key][i] val += " }" + elif type(properties[key]) == dbus.Byte: + val = int(properties[key]) + elif type(properties[key]) == dbus.Boolean: + val = str(bool(properties[key])).upper() else: val = properties[key] print(" %s = %s" % (key, val))
Signature · 1 line
2.47.3