Here's a local modification I have to the modemmanager.common script in OpenWrt.

Without it, the system will give up, if the readiness of the modem takes too long. This can happen with a number of cases, but in particular, this happens
on first boot, when OpenWrt is preparing the flash, as not all the system
is ready at that point, and this loop times out.  Without this change, the
recovery needs the modem unplugged and plugged in again.

This patch aside, my problem with the OpenWrt scripts is that they generate
a great deal of churn (or at least, a lot of debug), so in the near future,
I'd like to attempt some improvements, maybe trying to turn down some
of the repeated debug messages and being less reliant upon busy wait.

--- modemmanager.common 2020-12-09 11:35:28.865785946 -0500
+++ modemmanager.common 2020-11-12 16:19:22.721939593 -0500
@@ -158,36 +158,29 @@
        local n=45
        local step=5

-       while true; do
-               while [ $n -ge 0 ]; do
-                       [ -d "${sysfspath}" ] || {
-                               mm_log "error: ignoring modem detection request: no 
device at ${sysfspath}"
-                               proto_set_available "${cfg}" 0
-                               return 1
-                       }
+       while [ $n -ge 0 ]; do
+               [ -d "${sysfspath}" ] || {
+                       mm_log "error: ignoring modem detection request: no device 
at ${sysfspath}"
+                       proto_set_available "${cfg}" 0
+                       return 1
+               }
+
+               # Check if the modem exists at the given sysfs path
+               if ! mmcli -m "${sysfspath}" > /dev/null 2>&1
+               then
+                       mm_log "error: modem not detected at sysfs path"
+               else
+                       mm_log "modem exported successfully at ${sysfspath}"
+                       mm_log "setting interface '${cfg}' as available"
+                       proto_set_available "${cfg}" 1
+                       return 0
+               fi

-                       # Check if the modem exists at the given sysfs path
-                       if ! mmcli -m "${sysfspath}" > /dev/null 2>&1
-                       then
-                               mm_log "error: modem not detected at sysfs path"
-                       else
-                               mm_log "modem exported successfully at 
${sysfspath}"
-                               mm_log "setting interface '${cfg}' as available"
-                               proto_set_available "${cfg}" 1
-                               return 0
-                       fi
-
-                       sleep $step
-                       n=$((n-step))
-               done
-
-               mm_log "error: timed out waiting for the modem to get exported at 
${sysfspath}"
-                mm_log "Restarting detection"
-               sleep 5
-               n=45
+               sleep $step
+               n=$((n-step))
        done

-
+       mm_log "error: timed out waiting for the modem to get exported at 
${sysfspath}"
        proto_set_available "${cfg}" 0
        return 2
 }
_______________________________________________
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

Reply via email to