Installed the beta on our device and initial testing looks good. I'll do some more testing with it, but this seems to handle multiple modem mode switches, and resolves the issue I was having with modems attached to USB hubs chained 2 deep.
I did see another issue with multiple modems, but this has to do with creating the gsmmodem symlinks. Because usb_modeswitch checks if the symlink exists, and then passes the name back to udev, if udev then runs usb_modeswitch again it could return the same symlink because it hasn't been created yet for the other device. My initial though on how to fix this was to have usb_modeswitch_dispatcher create the symlink itself, but the jimsh version I have doesn't include the 'file link' command. Instead I just created a placeholder regular file where the symlink would be created, so then usb_modeswitch would know if that symlink is taken, and when udev got around to installing the symlink, it would just replace the regular file with the correct symlink.
Code: Select all
@@ -746,6 +764,9 @@
}
if {$idx == 256} {return ""}
+set placeholder [open /dev/$symlinkName w]
+close $placeholder
+
Log "Return symlink name \"$symlinkName\" and exit"
return $symlinkName
One other issue I noticed was with a modem I have at work: Sierra Wireless Aircard 250U. Now, I know this device isn't mode switched, but I use usb_modeswitch to detect which ttyUSB* port to attempt PPP on, using the gsmmodem symlinks. However, with the 250U, it has 4 ttyUSB* ports on the same USB interface 0.
Code: Select all
# ls /sys/bus/usb/devices/1-2.2.2:1.0/
bAlternateSetting ep_05 power
bInterfaceClass ep_08 subsystem
bInterfaceNumber ep_81 supports_autosuspend
bInterfaceProtocol ep_82 ttyUSB0
bInterfaceSubClass ep_84 ttyUSB1
bNumEndpoints ep_85 ttyUSB2
driver ep_88 ttyUSB3
ep_02 interface uevent
ep_04 modalias
In this case, the proper tty to use is ttyUSB0. However, the symlink creation in usb_modeswitch would assign the symlinks haphazardly (different ttys and different amount on each power cycle). The different number of symlinks created for this device is probably explained by the previous issue I noted, but when that is resolved then it would just create a symlink for every tty in that interface instead.
I wrote some code to check if there are any lower enumerated ttys in the same interface:
Code: Select all
@@ -727,6 +727,24 @@
}
}
}
+
+# Also, some devices have multiple TTYs assocated with a single
+# interface. Check for any lower indexed TTYs, and if found
+# don't return any name. ttyUSB0, of course, needn't worry.
+
+if { $rightPort && ![string equal $myPort "ttyUSB0"] } {
+ Log "\nLooking for lower TTYs in the same interface"
+ set ifDir $ifRoot.$ifNum
+ set otherPorts [glob -nocomplain $ifDir/ttyUSB\[0-9\]*]
+ foreach thisPort $otherPorts {
+ if { [string compare $myPort [file tail $thisPort]] > 0 } {
+ Log "\n--> found a port below me\n"
+ set rightPort 0
+ break
+ }
+ }
+}
+
if {$rightPort == 0} {
Log "Return empty name and exit"
return ""
Probably not super useful until there's a mode switched modem that exhibits the same interface, but I thought I'd throw it out there.
Thanks for the help. The less I have to patch the software packages I port to our device, the easier it is to upgrade and maintain them later.