Skip to content

Instantly share code, notes, and snippets.

@hericah
Forked from parrotmac/dbus-send-modem-command.sh
Last active September 18, 2021 23:13
Show Gist options
  • Save hericah/9c185552965676d909b2b0b678b3b691 to your computer and use it in GitHub Desktop.
Save hericah/9c185552965676d909b2b0b678b3b691 to your computer and use it in GitHub Desktop.
Send serial command to modem using ModemManager via DBus
#!/bin/sh
# Sends command 'ATI' to modem #3
# Get a list of modems by running `mmcli -L`
# Timeout is (probably) 2 seconds
# Also see https://www.freedesktop.org/software/ModemManager/api/latest/gdbus-org.freedesktop.ModemManager1.Modem.html#gdbus-method-org-freedesktop-ModemManager1-Modem.Command
dbus-send --system --dest=org.freedesktop.ModemManager1 --print-reply /org/freedesktop/ModemManager1/Modem/3 org.freedesktop.ModemManager1.Modem.Command string:'ATI' uint32:2000
#!/bin/sh
# Example caller, dbus-send-modem-command 3 'ATI'
# mean, sends command 'ATI' to modem #3
# Get a list of modems by running `mmcli -L`
# Timeout is (probably) 2 seconds
# Also see https://www.freedesktop.org/software/ModemManager/api/latest/gdbus-org.freedesktop.ModemManager1.Modem.html#gdbus-method-org-freedesktop-ModemManager1-Modem.Command
dbus-send --system --dest=org.freedesktop.ModemManager1 --print-reply /org/freedesktop/ModemManager1/Modem/{$1} org.freedesktop.ModemManager1.Modem.Command string:'{$2}' uint32:2000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment