How to restart the modem on Arch
#1
Hello everyone,

I am on arch+phosh, thank you @Danct12 for providing this for us!

So recently I had the modem not working on the road, switching 'mobile' off and back on did not help (it used to, I think).
Only solution: restarting the phone.

I -could- live with that, but wonder: Is there a faster way to get back online? (without wifi!)

I learned about the eg25-manager package (old thread here), available for Mobian, which seems to be a good workaround.
I found this here: https://github.com/dreemurrs-embedded/Pi...r/PKGBUILD
  -also by Danct12 -, but do not know how to go from there; for instance, why can't I find that in the AUR? ( https://aur.archlinux.org/ )

I installed (even compiled) stuff from the AUR before. I am willing to put some more effort in the pp, any help is highly welcome.


Thank you.
  Reply
#2
Arch uses eg25-manager already by default. Since it's already packaged in a repo I guess there is no need for it to be in the AUR.

Unfortunately restarting eg25-manager on Arch didn't restart the modem for me as it did on other distros. I read that on Manjaro they had been doing a lot of experimenting lately on how to handle the modem, so that way did not alwas work there either, but after some updates it did again. Arch doesn't change that much.
You could try restarting ModemManager, maybe that helps. Other than that I don't know of another way to restart the modem without rebooting (which doesn't mean that there isn't one though, I'd be happy to learn about it too).
  Reply
#3
(10-21-2021, 12:28 AM)kqlnut Wrote: You could try restarting ModemManager, maybe that helps.

OMG this actually worked, you are my hero Smile
It only takes a couple of seconds; now I try to make this workaround into a touch-able desktop icon which seems hard due to the sudo calls:

Code:
sudo --askpass killall ModemManager
sudo /usr/bin/ModemManager &
  Reply
#4
Glad it works! What I'm using, on Manjaro Phosh (where restarting eg25-manager works), is a systemd timer to check the modem every minute (as long as the phone is awake) and bring it back up when lost automatically. In my case the modem as /dev/ttyUSB2 disappears, so if that file is gone, eg25-manager is restarted. You could check if in your case /dev/ttyUSB2 disappears as well (or if you find other symptoms of it) and adapt the service unit to restart ModemManager:

/etc/systemd/system/modem-test.timer:
Code:
[Unit]
Description=Check presence of modem every minute

[Timer]
OnBootSec=60
OnUnitActiveSec=60

[Install]
WantedBy=timers.target

/etc/systemd/system/modem-test.service:
Code:
[Unit]
Description=Check if modem is present and restart eg25-manager if necessary
ConditionPathExists=!/dev/ttyUSB2

[Service]
Type=oneshot
ExecStart=systemctl restart eg25-manager.service
  Reply
#5
(10-21-2021, 02:40 AM)kqlnut Wrote: Glad it works! What I'm using, on Manjaro Phosh (where restarting eg25-manager works), is a systemd timer to check the modem every minute (as long as the phone is awake) and bring it back up when lost automatically. 

Thanks again for sharing Smile

For now I think I have to be content with this workflow:
1) notice I am offline
2) open terminal
3) ./remo

(remo is an executable file containing the script I posted above).

Reason:
Sometimes I have to run my script 2 times.
I wonder if systemd would even start a self-made script using your approach; if so + if I find out how to improve the script I would try your approach + my script
  Reply
#6
(10-21-2021, 03:30 AM)lacriz Wrote: Sometimes I have to run my script 2 times.
I wonder if systemd would even start a self-made script using your approach; if so + if I find out how to improve the script I would try your approach + my script

Yes, you can start any script on the ExecStart line. If you find an indicator for a non working modem that can be checked by code, you could for example also have the script check it, restart ModemManager, check again a couple of seconds later (however long it usually takes to get it back up) and if necessary restart it a second time.
  Reply
#7
(10-21-2021, 04:08 AM)kqlnut Wrote: If you find an indicator for a non working modem that can be checked by code, you could for example also have the script check it

I tried to do that from my bash script but no success so far:
Code:
sudo [ -d "/dev/ttyUSB2" ] echo "modem works" || "modem no worky"

This results in "modem no worky" even though:
1) it actually works
2) I can see that device e.g. using ls /dev/ttyUSB2

So now I have 2 more questions to be able to automate the whole workaround on Arch:
1) How can I find out which device in /dev is actually representing my eg25 modem? (I could not see any such path mentioned in ModemManager's output and also no command when entering ModemManager -h)
2) How can I check in bash if a /dev/BLABLA path exists / is working?

Cheers

  lacriz
  Reply
#8
I think a lot of the issues I see are coming from the Deep Sleep. I used to have the modem disconnecting, clock drifting, calls taking to long to ring...
So, I disabled the deep sleep in the settings. Settings >> Power >> Automatic Suspend >> OFF

I have not seen my modem disconnect in a long time. The time is always right. I get every phone call. I just charge the phone every 3-4 hours.

OS - Arch rolling release with Phosh
  Reply
#9
(10-21-2021, 05:36 AM)lacriz Wrote:
Code:
sudo [ -d "/dev/ttyUSB2" ] echo "modem works" || "modem no worky"

This results in "modem no worky" even though:
1) it actually works
2) I can see that device e.g. using ls /dev/ttyUSB2

So now I have 2 more questions to be able to automate the whole workaround on Arch:
1) How can I find out which device in /dev is actually representing my eg25 modem? (I could not see any such path mentioned in ModemManager's output and also no command when entering ModemManager -h)
2) How can I check in bash if a /dev/BLABLA path exists / is working?

Modem will always be showing no worky because you are testing for a directory with the -d flag. You would have to test for a file in general with the -e flag or for a character device with the -c flag.
I don't know the details, but the modem always connects at /dev/ttyUSB2 as for example mentioned on megi's website.
  Reply
#10
You are right, thanks again! This is my improved script.
As soon as I get it more field-tested I will set it up as a systemd service:

Code:
if [ -e /dev/ttyUSB2 ]
   echo "modem works"
else
   echo "modem does not work, restarting now ..."
   sudo killall ModemManager
   sudo /usr/bin/ModemManager &
fi

(10-21-2021, 09:02 AM)mikehenson Wrote: I think a lot of the issues I see are coming from the Deep Sleep. I used to have the modem disconnecting, clock drifting, calls taking to long to ring...
So, I disabled the deep sleep in the settings. Settings >> Power >> Automatic Suspend >> OFF

I have not seen my modem disconnect in a long time. The time is always right. I get every phone call. I just charge the phone every 3-4 hours.

Hi Mike,

you know what: Your approach is far easier than mine Smile
Seeing that deep sleep is not even working for me (at all, not ever) I will try that out.
First I will investigate if these 2 take about the same time:
a) Manually shutting down the pp + starting it up again
vs
b) Letting the pp go to deep sleep, failing at it; then timing how long it takes the pp to 'wake up' again (it seems to restart but I dunno)

While writing this I think there may be a valid reason to let the pp go to 'sleep', even if it fails to actually suspend the OS + apps: It wakes up when being called / when receiving a text message. This I want, it is the least the pp can do imho. I will investigate if that works when I shut down the pp.

Just when I thought I finished setting up my first Linux phone.. I should've known better Smile Such fun!
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Updating Arch Linux _radv_ 8 759 02-20-2024, 09:35 AM
Last Post: _radv_
  PinePhone AND/OR PinePhone Pro Arch Complete Install and Setup mikehenson 2 2,214 01-14-2024, 08:43 AM
Last Post: shifras
  How to install arch with FDE user641 3 748 01-11-2024, 10:18 PM
Last Post: Kevin Kofler
  How to find software app, on Arch Phosh? general_lee 5 1,895 10-15-2023, 10:12 PM
Last Post: Kevin Kofler
  Arch auto mount usb example Lazy_one 2 2,827 10-06-2023, 09:36 AM
Last Post: luppivega
  Modem Issues SchizoPinePhone225 2 807 08-31-2023, 08:23 PM
Last Post: SchizoPinePhone225
  Remove modem firmware aular 10 1,868 08-23-2023, 05:53 PM
Last Post: aular
  Arch with FDE user641 1 891 07-29-2023, 08:27 AM
Last Post: alpineduck
  No keyboard on Arch Plasma when entering password on document Chief 0 836 12-03-2022, 08:35 PM
Last Post: Chief
  Curious About Arch Ferriah 2 2,115 11-07-2022, 04:38 PM
Last Post: Ferriah

Forum Jump:


Users browsing this thread: 1 Guest(s)