Page 1 of 1

Problems with usb_modeswitch

Posted: Mon Nov 10, 2014 12:11 pm
by NicoVanDerDussen
Hi,

I want to connect via a 3G modem to the internet.

I installed via apt-get install ppp wvdial usb-modeswitch

When I POWERUP, with the modem in a 4-port hub (with keyboard), the mode does not switch.

If I remove the modem from the hub for 10 seconds and place it back, it appears correctly - and /dev/gsmmodem appears.

Connecting with wvdial works perfectly.

With rebooting the 3G modem mode switch happens perfectly, and with the root crontab @reboot wvdial connects perfectly to the internet

But, when going down with sudo shutdown -h now and removing power after a minute and then again plugging in the power, the switching does not happen.

I need to unplug the modem from the hub again, and the replace it. Then the mode switching happens and wvdial works like a charm again.

What am I doing wrong? :)

The Raspberry Pi must eventually operate without human intervention and connect to 3G on every reboot.


Thanks
Nico

Re: Problems with usb_modeswitch

Posted: Mon Nov 10, 2014 2:33 pm
by NicoVanDerDussen
As usual, I could not find any solution to the issue on Google before posting.

So I post the issue.

Next Google hits the problem spot on :)

Here is my solution:
(beware - newbie swimming among crocodiles!)

See http://www.raspberrypi.org/forums/viewt ... 7&p=285871 for a discussion on the issue.

The script below solves the problem - must be run with sudo

Code: Select all

#!/bin/bash
sleep 10
udevadm trigger
sleep 2m
wvdial

I'm very keen to learn from the experts - is there a better way of doing this?

Re: Problems with usb_modeswitch

Posted: Mon Nov 10, 2014 4:08 pm
by Douglas6
I'm guessing that usb-modeswitch requires parts of the file system that are not ready when the udev rules run at boot time, hence the need to re-trigger them once the OS is all set up. So that script I think would be the way to go. I'd add it to the end of /etc/rc.local (see here), if you haven't already. Those commands will be run as root, so no need for sudo, but do use full path names.

Re: Problems with usb_modeswitch

Posted: Tue Nov 11, 2014 9:26 am
by NicoVanDerDussen
Hi Douglas,

thanks for your comments.

I added the script to the init.d sequence - and it did not work as expected.

After removing it from there, I added it to the rc.local file, like /root/3GModem.sh & and it worked like a charm.

Question: It seems as if udevadm trigger is a bit of a sledge hammer approach. Is there a way to trigger only the modem?

Thanks
Nico

I'm busy documenting my learning as a blog.

Re: Problems with usb_modeswitch

Posted: Tue Nov 11, 2014 9:52 am
by DirkS
Question: It seems as if udevadm trigger is a bit of a sledge hammer approach. Is there a way to trigger only the modem?
There are additional options for 'trigger' that should make it possible to be more specific. See e.g. http://linux.die.net/man/8/udevadm

Re: Problems with usb_modeswitch

Posted: Tue Nov 11, 2014 2:30 pm
by Douglas6
And udevmonitor is useful for seeing what goes on when the dongle is discovered (run it and hotswap the modem)

Re: Problems with usb_modeswitch

Posted: Wed Nov 12, 2014 8:06 am
by NicoVanDerDussen
See my blog post on this at http://nvdd.info/11gKrsZ

Many thanks to all for the inputs!