Solaris/OpenSolaris上使用3G -- Using 3G modems on Solaris
Monday Nov 16, 2009
跟华为EC1260 modem斗争了几天,终于能勉强上中国电信的3G网络了。从google出来的网上信息中,可以看到这个modem在插入主机后,需要主机发送几个USB命令将它的运行模式从存储设备转换到modem模式。通过某些方法,可以看到在windows上这个modem的driver都发送了哪些命令,也可以参考Linux上的专门针对这一系列2G/3G USB modem的软件:usb_modeswitch。这个软件与我的想法不谋而合 ---- 用libusb发送控制命令。
Having struggled with Huawei EC1260 USB modem for several days, finally and fortunately I make it work on Solaris. This device looks as a storage device. It has its own driver and dial-up applications in this storage device. When it is plugged into a Windows host for the first time, it will be self-extracted and ask for user's intervention to install the driver and application. Afterwards, whenever user plugs the modem into this Windows host, the driver will do some switch work for it.
I don't have too much knowledge of how Linux handles it. But it seems Linux kernel drivers(storage) do send some commands upon detecting a Huawei USB modem. From my experiments on Solaris, I don't think merely sending a SET_FEATURE request can switch this device. So, there's also a Linux specific application, usb_modeswitch. I happen to have the same idea with it, i.e. using libusb(3lib) to send control messages. It's much more flexible.
我写了一个简单的libusb(3lib)程序用于切换Huawei EC1260设备,如果你的设备也能用这个程序进行切换,请留言。下载、编译、并运行此程序(请仔细阅读程序注释中的信息):SwitchModem
I wrote a simple libusb application to switch EC1260. If you have a Huawei device, you can download it and have a try. But, please change the product ID to your device's before compiling it. Click on the above SwitchModem link to download the application. Compile and run it. It will switch Huawei modem from storage to modem mode. If it works for your device or you have questions, please leave a message or post to wwan-discuss AT opensolaris.org.
解决了最关键的设备问题,剩下的就是在Solaris上的配置了。
首先,为这个modem绑定一个driver。由于这个Modem不是USB CDC-ACM 标准设备(但是仍然可以使用usbsacm(7D) driver),我们必须手动添加此设备的alias,即:
On Solaris, we use usbsacm(7D) to drive USB CDC-ACM compliant and similar devices. You need to bind this driver to the Huawei USB modems. After switching, the product ID of EC1260 is changed from 0x1446 to 0x1001. The procedure is as the following:
#update_drv -a -i 'usb12d1,1001' usbsacm
注意:EC1260在完成switch后,不是原来的PID 0x1446了,而是使用了0x1001。
第二步,设置ppp拨号脚本。Set up dial-up configurations:
# cat /etc/ppp/peers/huawei
term/0
460800
connect "/usr/bin/chat -V -t60 -f /etc/ppp/huawei-chat"
asyncmap 00000000
crtscts
defaultroute
holdoff 1
lcp-echo-interval 0
noauth
noccp
novj
passive
updetach
usepeerdns
name CARD
password CARD
# cat /etc/ppp/huawei-chat
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
REPORT CONNECT
'' 'AT+CPIN?'
TIMEOUT 5
READY-AT+CPIN=????-OK 'AT&F'
OK ATE
OK 'ATZ Q0 V1 E1 S0=0 &C1 &D2 +FCLASS=0'
SAY '\nCalling ChinaTelcom'
OK 'ATDT#777'
TIMEOUT 60
CONNECT \n辅助脚本:
$ cat /etc/ppp/ip-up
#!/usr/bin/ksh
cp /etc/ppp/resolv.conf /etc
cp /etc/nsswitch.dns /etc/nsswitch.conf
$ cat /etc/ppp/ip-down
#!/usr/bin/ksh
cp /etc/nsswitch.nis /etc/nsswitch.conf
一切配置完成,那就开始拨号吧:
$ pppd call huawei
AT+CPIN?
+CPIN:READY
OK
AT&F
OK
Calling ChinaTelcom
AATZ Q0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
ATDT#777
CONNECTchat: Nov 16 13:58:09 CONNECT
Serial connection established.
Using interface sppp0
Connect: sppp0 <--> /dev/term/4
Remote message: ^@
local IP address 124.127.63.2
remote IP address 115.168.64.86
primary DNS address 219.141.136.10
secondary DNS address 219.141.140.10
如果你在使用USB 3G modem过程中遇到问题,可以给我留言,如果能够提供设备信息,我们就可以更快地解决问题。得到硬件信息,请运行mdb命令:
If you have trouble with your USB 3G modems, please use the following command to get the hardware information and post it to wwan-discuss AT opensolaris.org for help.
[root@~]$ mdb -k
Loading modules: [ unix genunix specfs dtrace mac cpu.generic uppc pcplusmp rootnex scsi_vhci ufs sockfs ip hook neti sctp arp usba uhci stmf fctl nca lofs zfs idm cpc random nfs fcip logindmux ptm sppp sd ]
> ::prtusbINDEX DRIVER INST NODE VID.PID PRODUCT
1 ehci 0 pci1028,151 0000.0000 No Product String
2 hubd 5 hub 050d.0234 No Product String
3 ehci 1 pci1735,e0 0000.0000 No Product String
4 uhci 0 pci1028,151 0000.0000 No Product String
5 uhci 1 pci1028,151 0000.0000 No Product String
6 uhci 2 pci1028,151 0000.0000 No Product String
7 uhci 3 pci1028,151 0000.0000 No Product String
8 ohci 0 pci1735,35 0000.0000 No Product String
9 hubd 0 hub 0451.2046 No Product String
a ohci 1 pci1735,35 0000.0000 No Product String
b hubd 1 hub 0451.2046 No Product String
c usb_mid 0 device 050d.0105 Belkin OmniView KVM Switch
d hid 2 mouse 413c.3010 No Product String
e usbsacm 4 device 12d1.1001 HUAWEI Mobile
> ::prtusb -i e -v
INDEX DRIVER INST NODE VID.PID PRODUCT
e usbsacm 4 device 12d1.1001 HUAWEI Mobile
Device Descriptor
{
bLength = 0x12
bDescriptorType = 0x1
bcdUSB = 0x110
bDeviceClass = 0
bDeviceSubClass = 0
bDeviceProtocol = 0
bMaxPacketSize0 = 0x40
idVendor = 0x12d1
idProduct = 0x1001
bcdDevice = 0
iManufacturer = 0x1
iProduct = 0x2
iSerialNumber = 0x4
bNumConfigurations = 0x1
}
-- Active Config Index 0
Configuration Descriptor
{
bLength = 0x9
bDescriptorType = 0x2
wTotalLength = 0x6c
bNumInterfaces = 0x4
bConfigurationValue = 0x1
iConfiguration = 0x0
bmAttributes = 0xa0
bMaxPower = 0xfa
}
Interface Descriptor
>> More [<space>, <cr>, q, n, c, a] ?











