Author Message

<  Setup Discussion  ~  Huawei ME906s-158 cannot connect

PostPosted: Mon Jul 03, 2017 5:32 am Reply with quote
Posts: 1246 Joined: Wed Jul 11, 2012 3:14 pm Location: Koh Samui, TH
tore wrote:
LOM wrote:
What can be done in usb_modeswitch internally is always select config #0 first before selecting the final config. No need to check for active connection after having selected config #0, just send the final select directly after.


Yes, having the option to deconfigure the device before switching to the final config would be very helpful to support the Huawei ME906s-158 / HP lt4132. If such functionality is added, it might be wise to also make it possible to insert a configurable delay between deconfiguring it (selecting config #0) and entering the final configuration. I have a suspicion that the lt4132 might sometimes need a little bit of time to settle.


A user configurable delay might not be needed, just make it long enough.
Half a second for instance, it's not like a user would notice that as a longer startup time and it is a one-time-only thingy.

There is a modemmanager mailing list thread about this problem and I'm linking to the post where Björn Mork explains that Windows always goes via config #0 when selecting a new config.

https://lists.freedesktop.org/archives/ ... 02840.html

Josh?


Offline
PostPosted: Mon Jul 03, 2017 6:50 pm Reply with quote
Site Admin Posts: 6496 Joined: Sat Nov 03, 2007 12:30 am
I'll check it out. My main problem is that to test with, I have only one single modem that provides multiple configurations ...


Offline
PostPosted: Sun Jul 30, 2017 1:56 pm Reply with quote
Site Admin Posts: 6496 Joined: Sat Nov 03, 2007 12:30 am
Yes, I know, it did take long ...

Anyway, here is a test version of the usb_modeswitch core program. Just drop it into the source folder of the current release and re-make.

Two issues are addressed in this version:

- Driver detachment is now much more thorough, for every interface of the current configuration

- The device is set to initial configuration before applying the actual target configuration.

It runs quite well with my Alcatel X602d. I can switch configurations back and forth, without any complaints by the kernel about claimed interfaces. Note that " -u 0 " will still be ignored.
Attachments:
usb-modeswitch.test.tgz [16.77 KiB]
Downloaded 210 times

Offline
PostPosted: Mon Jul 31, 2017 2:12 am Reply with quote
Posts: 6 Joined: Sun Jul 02, 2017 11:03 am
Hi Josh,

I tested with your updated files plus the attached patch to add support for the HP lt4132. I tried rebooting my laptop approx. a dozen times, and it worked all but once. The one time it didn't work, the config had been switched to #3, but the modem was still inoperable (as if it had been switched directly from #2 to #3).

I can't be sure but I have a suspicion that it might be because you didn't add any delay between the libusb_set_configuration(devh, -1); and libusb_set_configuration(devh, Configuration); calls.

Tore
Attachments:
File comment: Patch to add HP lt4132 to usb_modeswitch-data-20170205.
hp-lt4132.patch [1001 Bytes]
Downloaded 219 times

Offline
PostPosted: Mon Jul 31, 2017 8:06 am Reply with quote
Site Admin Posts: 6496 Joined: Sat Nov 03, 2007 12:30 am
tore wrote:
delay between the libusb_set_configuration(devh, -1); and libusb_set_configuration(devh, Configuration);

I had thought about that but the testing with my modem didn't show any problems so I left it out.

If you want to try for yourself, just insert a wait in between:
Code:
    usleep(100000);

The waiting time is entered as microseconds, so here you have 100 milliseconds.

You should also be able to change the configuration cleanly on the command line now:
Code:
# usb_modeswitch -v 0x03f0 -p 0xa31d -W -u 2

If all goes according to plan (as it does here), usb_modeswitch should be triggered again immediately and set config #3 automatically. Repeat as often as you like - in theory the modem should be operative all the time.


Offline
PostPosted: Mon Jul 31, 2017 8:55 am Reply with quote
Posts: 1246 Joined: Wed Jul 11, 2012 3:14 pm Location: Koh Samui, TH
tore wrote:
Hi Josh,

I tested with your updated files plus the attached patch to add support for the HP lt4132. I tried rebooting my laptop approx. a dozen times, and it worked all but once. The one time it didn't work, the config had been switched to #3, but the modem was still inoperable (as if it had been switched directly from #2 to #3).

I can't be sure but I have a suspicion that it might be because you didn't add any delay between the libusb_set_configuration(devh, -1); and libusb_set_configuration(devh, Configuration); calls.

Tore


If it works 11 times out of 12 then you should not need much of delay so I retract my earlier suggestion of 500mS, I think you'll find that Josh suggestion of 100mS (or even less) is enough.
It is so far only this Huawei card of all devices needing a configuration change that has the problem.

@Josh
If you are about to release a new build then also consider a Android switch message under HuaweiNewMode with a switch between them in the global config file.


Offline
PostPosted: Mon Jul 31, 2017 2:56 pm Reply with quote
Posts: 6 Joined: Sun Jul 02, 2017 11:03 am
It doesn't automatically switch back after selecting config #2, because changing the config doesn't trigger any udev events for the parent device, which in turn means usb_modeswitch doesn't get invoked.

Instead, I cooked up the following simple script to do some repetitive testing:

Code:
#!/bin/sh -e
echo -ne "\rSuccessful iterations: 0";
for i in {1..1000}; do
        echo 0 > /sys/bus/usb/devices/1-3/bConfigurationValue
        sleep 1
        echo 2 > /sys/bus/usb/devices/1-3/bConfigurationValue
        sleep 1
        udevadm trigger /sys/bus/usb/devices/1-3
        timeout 35 sh -c 'until mmcli -L | grep -q MBIM; do sleep 0.1; done'
        sleep 1
        echo -ne "\rSuccessful iterations: $i";
done


Using an usb_modeswitch without any added delay, I got the following reference results:

Code:
$ for i in {1..20}; do sudo ./test.sh; echo; done
Successful iterations: 3
Successful iterations: 2
Successful iterations: 0
Successful iterations: 2
Successful iterations: 26
Successful iterations: 3
Successful iterations: 11
Successful iterations: 10
Successful iterations: 2
Successful iterations: 40
Successful iterations: 2
Successful iterations: 6
Successful iterations: 2
Successful iterations: 11
Successful iterations: 3
Successful iterations: 1
Successful iterations: 11
Successful iterations: 2
Successful iterations: 7
Successful iterations: 6


I then added usleep(100000); immediately after ret = libusb_set_configuration(devh, -1);, recompiled usb_modeswitch, and tried again. The first round has now passed 250 successful iterations, and it's still going strong.

The conclusion is clear as day: a delay is obviously necessary for reliable switching, and 100ms seems sufficient.


Offline
PostPosted: Mon Jul 31, 2017 3:25 pm Reply with quote
Posts: 1 Joined: Mon Jul 31, 2017 2:30 pm
tore wrote:
I then added usleep(100000); immediately after ret = libusb_set_configuration(devh, -1);, recompiled usb_modeswitch, and tried again. The first round has now passed 250 successful iterations, and it's still going strong.

The conclusion is clear as day: a delay is obviously necessary for reliable switching, and 100ms seems sufficient.

I agree. Tried with a test version of usb_modeswitch without any delay. Only on 6th reboot modem started to work.
Added 100ms delay, recompiled. Now it works every time.


Offline
PostPosted: Sun Nov 25, 2018 12:20 pm Reply with quote
Posts: 6 Joined: Sun Jul 02, 2017 11:03 am
tore wrote:
I tested with your updated files plus the attached patch to add support for the HP lt4132.


I'm reviving this old thread, as it would appear that the patch I sent to add support for the HP lt4132 has only been partially applied as of usb-modeswitch-data-20170806. The new file usb_modeswitch.d/03f0:a31d has been included, however, the corresponding udev rule in 40-usb_modeswitch.rules has not been. The result is that the HP lt4132 does not Just Work™ as intended.

Note that running gen-rules.tcl generates a new 40-usb_modeswitch.rules that does include the necessary udev rule:

Code:
# HP lt4132
ATTR{idVendor}=="03f0", ATTR{idProduct}=="a31d", RUN+="usb_modeswitch '/%k'"


Presumably this is an accidental omission, and ought to be included in the next release?

Tore


Offline
PostPosted: Thu Nov 29, 2018 12:06 am Reply with quote
Site Admin Posts: 6496 Joined: Sat Nov 03, 2007 12:30 am
I'll have a look, thanks!


Offline

Display posts from previous:  Sort by:

All times are UTC+02:00
Page 2 of 3
32 posts
Go to page   Previous 1 2 3 Next
Users browsing this forum: No registered users and 1 guest
Search for:
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum