系 统:Ubuntu 10.04
3G模块:华为E1750
1 安装usb-modeswitch软件
E1750 无线上网卡并没有提供linux环境下的驱动程序,但我们可以通过USB模式转换来让linux系统能识别并能使用E1750无线模块。USB_ModeSwitch是一个用来控制“flip flop”(多重设备)USB装置的USB模块转换工具,USB_ModeSwitch 从配置文件中读取重要的参数并实现所有初始化以及通讯,其中还需要来自"libusb"的重量级支持。具体信息可参看网页:http://www.draisberghof.de/usb_modeswitch/ 。
在网页http://www.draisberghof.de/usb_modeswitch/上下载USB模式转换的软件安装包:
usb-modeswitch-1.1.7.tar.bz2
usb-modeswitch-data-20110227.tar.bz2 //可以不用
libusb-dev //可不用下载,直接使用apt-get命令来安装
1>安装libusb-dev库文件
$ sudo apt-get install libusb-dev
2>安装usb-modeswitch-data
$tar jxvf usb-modeswitch-data-20110227.tar.bz2
$cd usb-modeswitch-data-20110227
$ sudo make install //将会在etc/usb_modeswitch.d中安装一个配置文件,并且在/lib/udev/rules.d中安装udev规则文件
3>安装usb-modeswitch
$ tar jxvf usb-modeswitch-1.1.7.tar.bz2
$ cd usb-modeswitch-1.1.7
$ sudo make install //此时将会在udev中安装一个shell脚本,一个大包装脚本,一个配置文件,man手册和新的二进制编译文件usb_modeswitch。
使用usb-modeswitch调试一个未知的新设备,有两种方式进行调试:
u 使用配置文件
使用配置文件,需要编写一个与自己硬件相关的配置文件,可参看usb-modeswitch-1.1.7下的device_reference.txt文件中,查找与自己硬件相关的部分,用做配置信息。如对于E1750无线网卡,在device_reference.txt文件中可查找到如下内容:
########################################################
# Huawei E1550
# Huawei E1750
#
# Contributor: Anders Blomdell, Ahmed Soliman
DefaultVendor= 0x12d1
DefaultProduct= 0x1446
TargetVendor= 0x12d1
TargetProduct= 0x1001
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
即可将此部分内容复制用来编写自己的配置文件(usb-modeswitch.setup,叫什么名字无所谓,只要在使用usb-modeswitch命令的时候,用“-c”来指定该文件即可),不过可能还需要根据实际检测到得ID信息来编写DefaultVendor,DefaultProduct,TargetVendor,TargetProduct等值。
u 使用命令行
使用命令行之前,需要usb_modeswitch –h来查看相应的usb_modeswitch命令,在根据
device_reference.txt文件中的相应信息,即可使用。
$ sudo usb_modeswitch -W -v 12d1 -p 1001 -V 12d1 -P 1001 -M
"55534243123456780000000000000011060000000000000000000000000000"
/*此命令行的作用相当于使用sudo usb_modeswitch -W –c usb_modeswitch.setu。
usb_modeswitch.setup文件内容如下:
DefaultVendor= 0x12d1
DefaultProduct= 0x1001
TargetVendor= 0x12d1
TargetProduct= 0x1001
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
*/
2 Ubuntu中识别E1750设备
以下是我的系统上的做法,因为Windows系统中的设置已将VMware的自动USB检测给禁用了,提示Host USB disable,虚拟机右下角没有USB设备的标识。
解决方法:
1>在windows系统中启动VM USB设备
在开始——>运行中执行services.msc命令,找到Vmware USB Arbitration Service项,并启动。
2>重启虚拟机系统
关闭虚拟机,重新启动虚拟机系统。启动虚拟机系统后,系统右下角出现了USB连接的标识。
3>连接windows中的E1750模块到虚拟机系统
点击右下角的USB标识,选择连接(从主机断开) ,弹出所示提示信息,选择OK。
选择OK后,激活虚拟机中的USB设备,此时USB标识成激活状态,并且在虚拟机系统桌面上自动挂在WCDMA的标识。
4>使用lsusb命令查看E1750设备ID等信息
$ lsusb //显示当前挂在的USB模块信息
Bus 002 Device 002: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 036: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
3 设置usb-modeswitch配置文件
1>创建usb_modeswitch.setup配置文件
$ sudo gedit usb_modeswitch.setup //新建usb_modeswitch.setup,写入如下器件模块信息
########################################################
# Huawei E1750
DefaultVendor=0x12d1
DefaultProduct=0x1446
TargetVendor=0x12d1
TargetProduct=0x1001
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
注:usb_modeswitch.setup中保存了要进行USB模式转换的设备ID的信息,可参考usb-modeswitch-1.1.7文件夹下的device_reference.txt文件来选择相应的设备信息。
2>加载usb_modeswitch.setup配置文件
$ sudo usb_modeswitch -c usb_modeswitch.setup
[sudo] password for user:
Looking for target devices ...
Found devices in target mode or class (1)
Looking for default devices ...
No devices in default mode found. Nothing to do. Bye. //器件默认的模块类型错误
user@Ubuntu1004:/etc$
3>修改usb_modeswitch.setup配置文件
在虚拟终端中执行lsusb命令,打印当前挂在的USB设备,可看出3G模块的默认模块类型为0x12d1:0x1001。
$ lsusb
Bus 002 Device 002: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ sudo gedit usb_modeswitch.setup //修改usb_modeswitch.setup文件
########################################################
# Huawei E1750
DefaultVendor=0x12d1
DefaultProduct=0x1001
TargetVendor=0x12d1
TargetProduct=0x1001
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
4>加载usb_modeswitch.setup配置文件
$ sudo usb_modeswitch -W -c usb_modeswitch.setup
Reading config file: usb_modeswitch.setup
* usb_modeswitch: handle USB devices with multiple modes
* Version 1.1.6 (C) Josua Dietze 2010
* Based on libusb0 (0.1.12 and above)
! PLEASE REPORT NEW CONFIGURATIONS !
DefaultVendor= 0x12d1 //这个ID号是在usb-switch转换之前看到的ID信息
DefaultProduct= 0x1001 //这个ID号是在usb-switch转换之前看到的ID信息
TargetVendor= 0x12d1 //这个ID号是在usb-switch转换之后看到的ID信息
TargetProduct= 0x1001 //这个ID号是在usb-switch转换之后看到的ID信息
TargetClass= not set
TargetProductList=""
DetachStorageOnly=0
HuaweiMode=0
SierraMode=0
SonyMode=0
GCTMode=0
KobilMode=0
MessageEndpoint= not set
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
NeedResponse=0
ResponseEndpoint= not set
Interface=0x00
InquireDevice enabled (default)
Success check disabled
System integration mode disabled
usb_set_debug: Setting debugging level to 15 (on)
usb_os_find_busses: Found 002
usb_os_find_busses: Found 001
usb_os_find_devices: Found 002 on 002
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 005 on 001
usb_os_find_devices: Found 001 on 001
error obtaining child information: Inappropriate ioctl for device
Looking for target devices ...
searching devices, found USB ID 0e0f:0002
searching devices, found USB ID 1d6b:0001
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID
adding device
searching devices, found USB ID 1d6b:0002
Found devices in target mode or class (1)
Looking for default devices ...
searching devices, found USB ID 0e0f:0002
searching devices, found USB ID 1d6b:0001
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID
adding device
searching devices, found USB ID 1d6b:0002
Found devices in default mode, class or configuration (1)
Accessing device 005 on bus 001 ...
Getting the current device configuration ...
OK, got current device configuration (1)
Using endpoints 0x01 (out) and 0x82 (in)
Using endpoints 0x01 (out) and 0x82 (in)
Not a storage device, skipping SCSI inquiry
USB description data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
Product: HUAWEI Mobile
Serial No.: not provided
-------------------------
Looking for active driver ...
OK, driver found ("option")
OK, driver "option" detached
Setting up communication with interface 0 ...
Using endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
OK, message successfully sent
Resetting response endpoint 0x82
Resetting message endpoint 0x01
-> Run lsusb to note any changes. Bye.
4 安装wvdial拨号软件
Wvdial是linux下的一款智能化拨号工具,利用wvdial和ppp可以实现linux下的轻松上网。在整个过程中,wvdial的作用是拨号并等待提示,并根据提示输入相应的用户名和密码等认证信息;ppp的作用是与拨入放协商传输数据的方法并维持该链接。使用wvdial时,需要使用/etc/wvdial.conf配置文件,这个配置文件可以自动生成,但是可能需要进行一点修改。Wvdial载入wvdial.conf配置文件后,会对modem进行初始化并拨号,拨号后等待拨入方的响应,收到拨入方响应后则启动pppd。注:pppd在ubuntu10.04上已经安装了,所以这里就不需要管它。
1>下载安装wvdail
$ sudo apt-get install wvdial
2>配置wvdail,创建/etc/wvdial.conf文件
$ sudo wvdialconf /etc/wvdial.conf
Editing `/etc/wvdial.conf'.
Scanning your serial ports for a modem. //自动扫描外部硬件模块生成相应的配置文件
ttyS0<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyS0<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud
ttyS0<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
ttyS1<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyS1<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud
ttyS1<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
Modem Port Scan<*1>: S2 S3
WvModem<*1>: Cannot get information for serial port.
ttyUSB_utps_diag<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB_utps_diag<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB_utps_diag<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
WvModem<*1>: Cannot get information for serial port.
ttyUSB_utps_modem<*1>: ATQ0 V1 E1 -- OK
ttyUSB_utps_modem<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB_utps_modem<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyUSB_utps_modem<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB_utps_modem<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB_utps_modem<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB_utps_modem<*1>: Modem Identifier: ATI -- Manufacturer: huawei
ttyUSB_utps_modem<*1>: Speed 9600: AT -- OK
ttyUSB_utps_modem<*1>: Max speed is 9600; that should be safe.
ttyUSB_utps_modem<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
WvModem<*1>: Cannot get information for serial port.
ttyUSB_utps_pcui<*1>: ATQ0 V1 E1 -- OK
ttyUSB_utps_pcui<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB_utps_pcui<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyUSB_utps_pcui<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB_utps_pcui<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB_utps_pcui<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB_utps_pcui<*1>: Modem Identifier: ATI -- Manufacturer: huawei
ttyUSB_utps_pcui<*1>: Speed 9600: AT -- OK
ttyUSB_utps_pcui<*1>: Max speed is 9600; that should be safe.
ttyUSB_utps_pcui<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
Found a modem on /dev/ttyUSB_utps_modem. //找到E1750经过usb转换后的linux设备文件
Modem configuration written to /etc/wvdial.conf. //创建/etc/wvdial.conf配置文件
ttyUSB_utps_modem<Info>: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
ttyUSB_utps_pcui<Info>: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
3>检查etc/wvdial.conf文件
$ sudo gedit /etc/wvdial.conf
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
; Phone = <Target Phone Number>
ISDN = 0
; Password = <Your Password>
New PPPD = yes
; Username = <Your Login Name>
Modem = /dev/ttyUSB_utps_modem
Baud = 9600
/*添加Phone,Username和Password信息*/
Phone = *99# //设置联通WCDMA接入点
Username = a //注意,无线上网卡上网是没有用户及密码的,这里可以随便写个就行
Password = a
/*生成的/etc/wvdial.conf文件默认是没有设置Phone,Username和Password的,如果不设置这些,在使用wvdial时会出现如下错误
--> Modem initialized.
--> Configuration does not specify a valid phone number.
--> Configuration does not specify a valid login name.
--> Configuration does not specify a valid password.
*/
4>拨号入网
$ sudo wvdial //使用wvdial拨号程序
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT 7200000
--> Carrier detected. Waiting for prompt.
--> Don't know what to do! Starting pppd and hoping for the best.
--> Starting pppd at Thu Apr 14 21:22:35 2011
--> Pid of pppd: 2539
--> Using interface ppp0
--> pppd: (U{[08]@S{[08]
--> pppd: (U{[08]@S{[08]
--> pppd: (U{[08]@S{[08]
--> pppd: (U{[08]@S{[08]
--> pppd: (U{[08]@S{[08]
--> pppd: (U{[08]@S{[08]
--> local IP address 172.17.79.184
--> pppd: (U{[08]@S{[08]
--> remote IP address 10.64.64.64
--> pppd: (U{[08]@S{[08]
--> primary DNS address 210.21.196.6
--> pppd: (U{[08]@S{[08]
--> secondary DNS address 221.5.88.88
--> pppd: (U{[08]@S{[08] //有pppd设置好IP地址和DNS地址后,wvdial程序停在这里,这时已经接入了internet。
如果要停止网络,使用ctrl+C命令,可以中断连接。
--> Disconnecting at Thu Apr 14 21:34:12 2011
5>网络测试
$ sudo ifconfig //查看系统中的网络连接
[sudo] password for user:
eth6 Link encap:Ethernet HWaddr 00:0c:29:96:62:c4
inet6 addr: fe80::20c:29ff:fe96:62c4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9465 errors:0 dropped:0 overruns:0 frame:0
TX packets:5312 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14096309 (14.0 MB) TX bytes:307928 (307.9 KB)
Interrupt:19 Base address:0x2024
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:116 errors:0 dropped:0 overruns:0 frame:0
TX packets:116 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:9624 (9.6 KB) TX bytes:9624 (9.6 KB)
ppp0 Link encap:Point-to-Point Protocol //使用3G模块接入的PPP0节点
inet addr:172.17.79.184 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:118 (118.0 B) TX bytes:157 (157.0 B)
$ sudo ifconfig eth6 down //将接入的有线网卡ethx关闭,使用3G模块接入的PPP0节点
$ sudo ifconfig //
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:116 errors:0 dropped:0 overruns:0 frame:0
TX packets:116 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:9624 (9.6 KB) TX bytes:9624 (9.6 KB)
ppp0 Link encap:Point-to-Point Protocol
inet addr:172.17.79.184 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:118 (118.0 B) TX bytes:157 (157.0 B)
$ ping www.baidu.com //使用ping命令来测试网络
PING www.a.shifen.com (61.135.169.105) 56(84) bytes of data.
64 bytes from 61.135.169.105: icmp_seq=1 ttl=50 time=140 ms
64 bytes from 61.135.169.105: icmp_seq=2 ttl=50 time=156 ms
--- www.a.shifen.com ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 31656ms
rtt min/avg/max/mdev = 124.525/154.563/171.575/15.575 ms
如上,能够ping通baidu等网络站点,说明3G模块在ubuntu系统中已经能够接入网络了。
注:在ubuntu下wvdial连入网络后,在使用浏览器打开网页时,主页在浏览器的file->work offline,我之前就是不知道,这项被选上了,死活都不能使用浏览器,还以为是哪里有问题呢!最后把file->work offline前的勾去掉,就能浏览internet了。(*^__^*) 嘻嘻……