public inbox for ofono@lists.linux.dev
 help / color / mirror / Atom feed
From: Andres Salomon <dilinger@queued.net>
To: ofono@lists.linux.dev
Subject: [PATCH] test: fix list-modems hang & simplify handling of Byte/Bool properties
Date: Tue, 9 Dec 2025 22:59:59 -0500	[thread overview]
Message-ID: <20251209225959.2355f276@5400> (raw)

From 690d6af7b672d883bd7d7b86435ddcfad5bdc15d Mon Sep 17 00:00:00 2001
From: Andres Salomon <dilinger@queued.net>
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 = 12345678@phonesim.org

---
 test/list-modems | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/test/list-modems b/test/list-modems
index a163791e..1b262482 100755
--- a/test/list-modems
+++ b/test/list-modems
@@ -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))
-- 
2.47.3


                 reply	other threads:[~2025-12-10  4:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251209225959.2355f276@5400 \
    --to=dilinger@queued.net \
    --cc=ofono@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox