ARM+llinux系统移植3G拨号上网收发短信(一)【转】
本文转载自:http://blog.csdn.net/hanmengaidudu/article/details/17099737
一、 PPP移植
各项工作具体说明
向Linux内核添加3G模块的驱动(USB转串口驱动)和PPP协议的支持,然后编译内核并下载到开发板。当然如果之前已经移植好内核,那么只需要增加几个选项就可以,然后在编译内核就可以了,这个文档默认内核已经移植过,所以只讲与USB转串口驱动和PPP协议支持的几个选项。
[lingyun@localhost linux-3.0]$ make menuconfig
1、USB的驱动要选这几个:
DeviceDrivers---→
USBsupport---→
<*>USB SerialConverter support--→
[*]USBGeneric Serial Driver
<*>USBdriver for GSM and CDMA modems
2、到此3G模块驱动添加完成,下面进行ppp协议支持的添加(下面所示的几个选项必选):
DeviceDrivers--→
Network devicesupport---→
<*> PPP (point-to-point protocol) support
[*] PPP multilink support (EXPERIMENTAL)
<*> PPP support for async serial ports
<*> PPP support for sync tty ports
<*> PPP Deflate compression
<*> PPP BSD-Compress compression
完成了这些步骤以后就可以退出make menuconfig进行make编译内核了。然后再把生成的镜像文件下载到板子上重启开发板即可。然后就会发现在/dev/目录下生成ppp设备节点:
~ >: ls -l dev/ppp
crw-rw---- 1 root root 108, 0 Mar 27 17:35 dev/ppp
/***********************转载声明*********************************/
二、 usb_modeswitch移植
下载usbmode库:
[lingyun@localhost fulinux]$ mkdir usbmode
[lingyun@localhost fulinux]$ cd usbmode/
[lingyun@localhost usbmode]$ wget http://pkgs.fedoraproject.org/repo/pkgs/libusb1/libusb-1.0.0.tar.bz2/df2447c23750ef2b4a314200feacc2ee/libusb-1.0.0.tar.bz2
[lingyun@localhost usbmode]$ wget http://jaist.dl.sourceforge.NET/project/libusb/libusb-compat-0.1/libusb-compat-0.1.5/libusb-compat-0.1.5.tar.bz2
[lingyun@localhost usbmode]$wget http://pkgs.fedoraproject.org/repo/pkgs/usb_modeswitch/usb-modeswitch-1.2.4.tar.bz2/dbd4ce7966d7b4a5a0604a8280f7164d/usb-modeswitch-1.2.4.tar.bz2
[lingyun@localhost usbmode]$ wget http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-data-20130607.tar.bz2
以上这些下载地址如果有失效的,搜索相应的文件下载,即可下载。
解压:
[lingyun@localhost usbmode]$ tar xjf libusb-1.0.0.tar.bz2
[lingyun@localhost usbmode]$ tar xjf libusb-compat-0.1.5.tar.bz2
[lingyun@localhost usbmode]$ tar xjf usb-modeswitch-1.2.6.tar.bz2
[lingyun@localhost usbmode]$ tar xjf usb-modeswitch-data-20130607.tar.bz2
编译libusb:
[lingyun@localhost usbmode]$ mkdir install
[lingyun@localhost usbmode]$ cd libusb-1.0.0
[lingyun@localhost libusb-1.0.0]$ ./configure --prefix=/home/lingyun/fulinux/usbmode/install/ --build=i686 --host=arm-linux --disable-shared --enable-static (注意有两--的前面有一个空格)
[lingyun@localhost libusb-1.0.0]$ make
[lingyun@localhost libusb-1.0.0]$ make install
[lingyun@localhost libusb-1.0.0]$ ls ../install/
include lib
[lingyun@localhost libusb-1.0.0]$
编译usb_modeswitch:
[lingyun@localhost usbmode]$ cd usb-modeswitch-1.2.6
[lingyun@localhost usb-modeswitch-1.2.6]$ ls
[lingyun@localhost usb-modeswitch-1.2.6]$ vim Makefile
CC ?=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc #addr fulinux
CFLAGS += -Wall -l ../install/include-static #add by fulinux
LIBS = -L ../install/lib/ -l usb -l usb-1.0-l pthread #add by fulinux
[lingyun@localhost libusb-1.0.0]$ cd ..
[lingyun@localhost usbmode]$ export PKG_CONFIG_PATH=/home/lingyun/fulinux/usbmode/install/lib/pkgconfig:$PKG_CONFIG_PATH
[lingyun@localhost usbmode]$ cd libusb-compat-0.1.5
[lingyun@localhost libusb-compat-0.1.5]$
[lingyun@localhost libusb-compat-0.1.5]$ ./configure --prefix=/home/lingyun/fulinux/usbmode/install/ --build=i686 --host=arm-linux --disable-shared --enable-static
[lingyun@localhost libusb-compat-0.1.5]$ make
[lingyun@localhost libusb-compat-0.1.5]$ make install
[lingyun@localhost libusb-compat-0.1.5]$ ls ../install/
bin include lib
[lingyun@localhost libusb-compat-0.1.5]$
编译usb_modeswitch:
[lingyun@localhost libusb-compat-0.1.5]$ cd ../usb-modeswitch-1.2.4
[lingyun@localhost usb-modeswitch-1.2.6]$ vim Makefile
CC = /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc
CFLAGS += -Wall -I ../install/include -static
LIBS = -L ../install/lib -l usb -l usb-1.0 -l pthread
[lingyun@localhost usb-modeswitch-1.2.4]$ make
[lingyun@localhost usb-modeswitch-1.2.4]$ cp usb_modeswitch ../install/bin/
[lingyun@localhost usb-modeswitch-1.2.4]$ cp usb_modeswitch /tftp/
上面用usb-modeswitch-1.2.6编译时发现有问题,有如下
[lingyun@localhost usb-modeswitch-1.2.6]$ make
cc -o usb_modeswitch usb_modeswitch.c -Wall -I../install/include -static -L /home/lingyun/fulinux/usbmode/install/lib -l usb -l usb-1.0 -l pthread
/usr/bin/ld: skipping incompatible /home/lingyun/fulinux/usbmode/install/lib/libusb.a when searching for -lusb
/usr/bin/ld: cannot find -lusb
collect2: ld returned 1 exit status
make: *** [usb_modeswitch] Error 1
[lingyun@localhost usb-modeswitch-1.2.6]$
“incompatible”库和这个有冲突。建议使用。1.2.6一下的版本。
把usb-modeswitch-data-20130607下的usb_modeswitch.d中的所有文件都拷贝到开发板的etc/usb_modeswitch.d/目录:
[lingyun@localhost usbmode]$ cd usb-modeswitch-data-20130607
[lingyun@localhost usb-modeswitch-data-20130607]$ ls
40-usb_modeswitch.rules ChangeLog COPYING gen-rules.tcl Makefile README usb_modeswitch.d
[lingyun@localhost usb-modeswitch-data-20130607]$ tar cjf usb_modeswitch.d.tar.bz2 usb_modeswitch.d/
[lingyun@localhost usb-modeswitch-data-20130607]$ ls
40-usb_modeswitch.rules ChangeLog COPYING gen-rules.tcl Makefile README usb_modeswitch.d usb_modeswitch.d.tar.bz2
[lingyun@localhost usb-modeswitch-data-20130607]$ cp usb_modeswitch.d.tar.bz2 /tftp/
[lingyun@localhost usb-modeswitch-data-20130607]$
把usb_modeswitch下载到开发板的/usr/sbin目录下,把usb_modeswitch.d下载开发板到/etc/目录下:
/usr/sbin >: tftp -gr usb_modeswitch 192.168.1.3
usb_modeswitch 100% |*******************************| 390k 0:00:00 ETA
/etc >: tftp -gr usb_modeswitch.d.tar.bz2 192.168.1.3
usb_modeswitch.d.tar 100% |*******************************| 8741 0:00:00 ETA
/etc >: tar xjf usb_modeswitch.d.tar.bz2
三、pppd和chat
交叉编译好工作源代码ppp-2.4.4,得到pppd和chat,解压源代码包,进入目录,进行交叉编译:
[lingyun@localhost fulinux]$ mkdir ppp
[lingyun@localhost fulinux]$ cd ppp/
[lingyun@localhost ppp]$ wget ftp://ftp.samba.org/pub/ppp/ppp-2.4.4.tar.gz
[lingyun@localhost ppp]$ tar zxf ppp-2.4.4.tar.gz
[lingyun@localhost ppp]$ cd ppp-2.4.4
[lingyun@localhost ppp-2.4.4]$ ./configure
[lingyun@localhost chat]$ linux
[lingyun@localhost chat]$ vim chat.c
1168 if (timeout_next) {
1169 timeout_next = 0;
1170
1171 s = clean(s,0); /* add by fulinux */
1172
1173 timeout = atoi(s);
1174
1175 free(s); /* add by fulinux */
1176
1177 if (timeout <= 0)
[lingyun@localhost chat]$ vim Makefile
INSTALL= install
CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc #add by fulinux
all: chat
chat: chat.o
$(CC) -static -o chat chat.o #add by fulinux
[lingyun@localhost chat]$ cd ../pppd
[lingyun@localhost pppd]$ vim auth.c
1316 ao->neg_upap = !refuse_pap /*&& (passwd[0] != 0 || get_pap_passwd(NULL))*/; /* add by fulinux*/
[lingyun@localhost pppd]$ vim Makefile
33 CC = /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc # add by fulinux
46#MPPE=y
51#FILTER=y
68#PLUGIN=y
[lingyun@localhost pppd]$ cd ..
[lingyun@localhost ppp-2.4.4]$ make
make[1]: Leaving directory `/usr/local/src/lingyun/fulinux/ppp/ppp-2.4.4/pppdump'
[lingyun@localhost ppp-2.4.4]$ cd chat/
[lingyun@localhost chat]$ ls
chat chat.8 chat.c chat.o Makefile Makefile.linux Makefile.sol2
[lingyun@localhost chat]$ file chat
chat: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped
[lingyun@localhost chat]$ cd ..
[lingyun@localhost ppp-2.4.4]$ cd pppd
[lingyun@localhost pppd]$ file pppd
pppd: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[lingyun@localhost pppd]$
将交叉编译出来的这两个应用程序chat和pppd拷贝到开发板 /usr/sbin目录下,更改其属性为可执行文件。
[lingyun@localhost chat]$ cp chat /tftp/
[lingyun@localhost pppd]$ cp pppd /tftp/
在开发板中操作:
~ >: cd usr/sbin/
/usr/sbin >: tftp -gr chat 192.168.1.3
chat 100% |*******************************| 147k 0:00:00 ETA
/usr/sbin >: tftp -gr pppd 192.168.1.3
pppd 100% |*******************************| 621k 0:00:00 ETA
/usr/sbin >: chmod a+x chat
/usr/sbin >: chmod a+x pppd
配置拨号的脚文件
拨号上网需要的配置文件有3个:
wcdma,wcdma-chat-connect,wcdma-chat-disconnect(存放位置是开发板的/etc/ppp/peers)。
~ >: mkdir -p /etc/ppp/peers/
wcdma配置文件内容
# /etc/ppp/peers/wcdma
# This is pppd script for China liantong
# Usage: root>pppd call cdma
hide-password
noauth
connect '/usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-connect'
disconnect '/usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-disconnect'
debug
/dev/ttyUSB2
115200
defaultroute
noipdefault
novj
novjccomp
noccp
ipcp-accept-local
ipcp-accept-remote
local
lock
dump
nodetach
user"card"
password"card"
crtscts
remotename 3gppp
ipparam 3gppp
usepeerdns
wcdma-chat-connect配置文件内容
ABORT "BUSY"
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "ERROR"
ABORT "NO ANSWER"
TIMEOUT 120
"" AT
OK \rATZ
OK \rAT+CGDCONT=1,"IP","3gnet",,0,0
OK-AT-OK ATDT*99#
CONNECT \d\c
wcdma-chat-disconnect配置文件内容
ABORT "ERROR"
ABORT "NO DIALTONE"
SAY "INSending break to the modem\n"
""\k"
""+++ATH"
SAY "\nGood bye\n"
还要添加一个域名解析的文件:
nameserver 4.2.2.2
nameserver 8.8.8.8
将上面的四个文件拷贝到/tftp目录下。
并下载到开发板相应的目录中去:
因为
lrwxrwxrwx 1 root root 29 Apr 21 2013 resolv.conf -> /apps/etc/network/resolv.conf
所以:
/apps/etc/network >: tftp -gr resolv.conf 192.168.1.3
~ >: cd etc/ppp/peers/
/etc/ppp/peers >: ls
/etc/ppp/peers >: tftp -gr wcdma 192.168.1.3
/etc/ppp/peers >: tftp -gr wcdma-chat-disconnect 192.168.1.3
/etc/ppp/peers >: tftp -gr wcdma-chat-connect 192.168.1.3
/etc/ppp/peers >: ls
wcdma wcdma-chat-connect wcdma-chat-disconnect
到这里PPP 移植就完成了。
到了这里大部分工作已经完成了,但是我们的开发板依然不能拨号,还需进一步修改和添加配置文件。
当我们的MF626插件中兴WCDMA USB调制解调器,Linux内核识别作为一个cd – rom。
scsi0 :usb-storage 1-1.4:1.0
scsi 0:0:0:0: CD-ROM ZTE USB SCSI CD-ROM 2.31 PQ: 0 ANSI: 2
现在我们需要使用usb_modeswitch切换3 g USB调制解调器来调制解调器(USB转换为seiral),对于usb_modeswitch使用libusb,libusb依赖于USB文件系统。所以我们在使用usb_modeswitch之前必须挂在usbfs,否则它不能检测USB设备。
添加中兴WCDMA现代usb_modeswitchMF626配置文件:
~ >: cd apps/
/apps >: vi zte_mf626.conf
#ZTE devices
DefaultVendor = 0x19d2
DefaultProduct= 0x2000
TargetVendor = 0x19d2
TargetProdduct= "0001,0002,0015,0016,0017,0031,0052,0055,0063,0064,0066,0091,0108,0117,0128,0157,2002,2003"
MessageContent = "5553424312345678000000000000061e000000000000000000000000000000"
MessageContent2 = "5553424312345679000000000000061b000000020000000000000000000000"
MessageContent3 = "55534243123456702000000080000c85010101180101010101000000000000"
NeedResponse=1
~
/apps >: ls
etc zte_mf626.conf
/apps >: usb_modeswitch -c /apps/zte_mf626.conf
Looking for target devices ...
No devices in target mode or class found
Looking for default devices ...
No devices in default mode found. Nothing to do. Bye.
这是因为usbfs文件系统没有挂在起来,所以使用usb_modeswitch之前要挂载它:
/apps >: mount -tusbfs usbfs /proc/bus/usb/
/apps >: mount
rootfs on / type rootfs (rw)
/dev/root on / type jffs2 (rw,relatime)
proc on /proc type proc (rw,relatime)
usbfs on /proc/bus/usb type usbfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime)
ramfs on /tmp type ramfs (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
ubi7:apps on /apps type ubifs (rw,sync,noatime)
/dev/mtdblock8 on /data type jffs2 (rw,sync,noatime)
/apps >:
~ >: ls proc/bus/usb/
001 devices
这样我usbfs就挂载起来了,但是如果重启开发板后,还得重新挂载,为了每次启动系统都能自动挂载,我们进行如下修改:
~ >: cd etc/
/etc >: vim fstab
# /etc/fstab: static file system information.
#
# <file system> <mount pt> <type> <options> <dump> <pass>
/dev/root / ext2 rw,noauto 0 1
proc /proc proc defaults 0 0
usbfs /proc/bus/usb usbfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0
ramfs /tmp ramfs defaults 0 0
sysfs /sys sysfs defaults 0 0
~
现在的话就可以看到如下信息了:
~ >: usb_modeswitch -c /apps/zte_mf626.conf
Looking for target devices ...
No devices in target mode or class found
Looking for default devices ...
found matching product ID
adding device
Found device 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 interface number 0
Using endpoints 0x01 (out) and 0x81 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
OK, driver found; name unknown, limitation of libusb1
OK, driver "unkown" detached
SCSI inquiry data (for identification)
-------------------------
Vendor String: ZTE
Model String: USB SCSI CD-ROM
Revision String: 2.31
-------------------------
USB description data (for identification)
usb 1-1.1: usbfs: process 688 (usb_modeswitch) did not claim interface 0 before use
-------------------------
Manufacturer: ZTE,Incorporated
Product: ZTE CDMA Technologies MSM
Serial No.: 1234567890ABCDEF
-------------------------
Setting up communication with interface 0
Using endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
OK, message successfully sent
Reading the response to message 1 (CSW) ...
OK, response successfully read (13 bytes).
Trying to send message 2 to endpoint 0x01 ...
OK, message successfully sent
Reading the response to message 2 (CSW) ...
OK, response successfully read (13 bytes).
Trying to send message 3 to endpoint 0x01 ...
OK, message successfully sent
Reading the response to message 3 (CSW) ...
OK, response successfully read (0 bytes).
Resetting response endpoint 0x81
Resetting message endpoint 0x01
Device is gone, skipping any further commands
-> Run lsusb to note any changes. Bye.
~ >: usb 1-1.1: USB disconnect, device number 5
usb 1-1.1: new full speed USB device number 6 using s3c2410-ohci
usb 1-1.1: New USB device found, idVendor=19d2, idProduct=0031
usb 1-1.1: New USB device strings: Mfr=2, Product=1, SerialNumber=3
usb 1-1.1: Product: ZTE CDMA Technologies MSM
usb 1-1.1: Manufacturer: ZTE,Incorporated
usb 1-1.1: SerialNumber: 1234567890ABCDEF
option 1-1.1:1.0: GSM modem (1-port) converter detected
usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB0
option 1-1.1:1.1: GSM modem (1-port) converter detected
usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB1
scsi3 : usb-storage 1-1.1:1.2
option 1-1.1:1.3: GSM modem (1-port) converter detected
usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB2
scsi 3:0:0:0: Direct-Access ZTE MMC Storage 2.31 PQ: 0 ANSI: 2
sd 3:0:0:0: Attached scsi generic sg0 type 0
sd 3:0:0:0: [sda] Attached SCSI removable disk
发送at命令:
~ >: microcom -s 115200 dev/ttyUSB2 (或者~ >: microcom -s 115200 dev/ttyUSB1)
at
OK
1, 查模块制造商:
at+cgmi
ZTE INCORPORATED
OK
2, 查GPRS模块型号:
at+cgmm
MF626
OK
3, 查模块版本:
at+cgmr
BD_TMOP673M3V1.0.1B07
OK
3, 查SIM卡是否在位:
at+cpin?
+CPIN: READY
OK
4,查GPRS模块信号强度,其中”,”前的数字为信号强度,如下面示例中的12为信号强度。
at+csq
+CSQ: 12,99
OK
若信号强度为99,则无效。我这里信号强度一般在20左右。
5,查SIM卡是否注册上网络,其中”,”后的值为SIM卡的注册状态,如下面示例中的1.
OK
at+creg?
+CREG: 0,5
OK
如果状态值为0,表示未注册;如果为1表示本地号码注册上;如果为2,表示正在搜索运营商注册,但没注册上;3表示拒绝注册;4,未知状态; 5, 漫游号码注册上。
6,查SIM卡运营商,如下面显示的”CHN-CUGSM”为中国联通的号码:
at+cops?
+COPS: 0,0,"China Mobile Communication Corp.",0
OK
在UC864E模块上,使用AT+COPS?查询,则联通的号码将显示为”cmnet”,但在GTM900B/C, SIM5215上显示的是”CHN-CUGSM”. 中国移动的则为”China Mobile”,在现实的时候也有一些区别,例如在UC864E上中国移动显示为” China Mobile”,当中只有一个空格;而在GTM900B上则显示” China Mobile”,当中有两个空格。但是这上面是China Mobile Communication Corp.
8, AT命令打电话,注意在拨的号码后面有个分号;
atd10086;
OK
我不知道怎么通电话。
9,如果有电话到来时,则是串口上将收到RING字符串,这时我们可以使用ATA命令摘机,如果不想接听,可以使用ATH挂断;
但是我没有接到RING。
10,在进行PPP拨号上网前,我们必须使用下面命令来设置APN:
中国移动:
AT+CGDCONT=1,"IP","cmnet"
OK
中国联通有两个APN: uninet和3gnet, 如果给3G卡的话,可以设置APN为3gnet
AT+CGDCONT=1,"IP","uninet"
OK
AT+CGDCONT?
+CGDCONT:1,"IP","uninet","0.0.0.0",0,0
OK
或设置APN为3gnet:
AT+CGDCONT=1,"IP","3gnet"
OK
AT+CGDCONT?
+CGDCONT:1,"IP","3gnet","0.0.0.0",0,0
OK
短信相关命令:
设置短信格式为Text模式:
AT+CMGF=1
OK
设置短信格式为PDU模式:
AT+CMGF=0
OK
设置短信中心号,一般不需要我们手动设置。
湖北联通的短信中心号设置如下:
AT+CSCA="+8613010360500"
OK
湖北移动的短信中心号为:
AT+CSCA?
+CSCA: "+8613800270500",145
OK
现在就可以进行拨号了:
如果遇到下面问题
/etc/ppp/peers >: pppd call wcdma
pppd: In file /etc/ppp/peers/wcdma: unrecognized option 'user"card"'
在文件wcdma中user和“card"中间有一个空格。
>:pppd call wcdma
pppdoptions in effect:
debug # (from /etc/ppp/peers/wcdma)
nodetach # (from /etc/ppp/peers/wcdma)
dump # (from /etc/ppp/peers/wcdma)
noauth # (from /etc/ppp/peers/wcdma)
usercard # (from/etc/ppp/peers/wcdma)
password?????? # (from/etc/ppp/peers/wcdma)
remotename3gppp # (from/etc/ppp/peers/wcdma)
/dev/ttyUSB2 # (from /etc/ppp/peers/wcdma)
115200 # (from /etc/ppp/peers/wcdma)
lock # (from /etc/ppp/peers/wcdma)
connect/usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-connect # (from /etc/ppp/peers/wcdma)
disconnect/usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-disconnect # (from /etc/ppp/peers/wcdma)
crtscts # (from /etc/ppp/peers/wcdma)
local # (from /etc/ppp/peers/wcdma)
hide-password # (from /etc/ppp/peers/wcdma)
novj # (from /etc/ppp/peers/wcdma)
novjccomp # (from /etc/ppp/peers/wcdma)
ipcp-accept-local # (from /etc/ppp/peers/wcdma)
ipcp-accept-remote # (from /etc/ppp/peers/wcdma)
ipparam3gppp # (from/etc/ppp/peers/wcdma)
noipdefault # (from /etc/ppp/peers/wcdma)
defaultroute # (from /etc/ppp/peers/wcdma)
usepeerdns # (from /etc/ppp/peers/wcdma)
noccp # (from /etc/ppp/peers/wcdma)
abort on(BUSY)
abort on(NO CARRIER)
abort on(NO DIALTONE)
abort on(ERROR)
abort on(NO ANSWER)
timeoutset to 120 seconds
send(AT^M)
expect(OK)
AT^M^M
OK
-- got it
send(^MATZ^M)
expect(OK)
^M
ATZ^M^M
OK
-- got it
send(^MAT+CGDCONT=1,"IP","cmnet",,0,0^M)
expect(OK)
^M
AT+CGDCONT=1,"IP","cmnet",,0,0^M^M
OK
-- got it
send(ATDT*99#^M)
expect(CONNECT)
^M
ATDT*99#^M^M
CONNECT
-- got it
send (\d)
Serialconnection established.
usingchannel 1
Usinginterface ppp0
Connect:ppp0 <--> /dev/ttyUSB2
sent [LCPConfReq id=0x1 <asyncmap 0x0> <magic 0xfb2b5aaa> <pcomp><accomp>]
rcvd [LCPConfReq id=0x0 <asyncmap 0x0> <auth chap MD5> <magic0x172b914> <pcomp> <accomp>]
sent [LCPConfAck id=0x0 <asyncmap 0x0> <auth chap MD5> <magic0x172b914> <pcomp> <accomp>]
rcvd [LCPConfAck id=0x1 <asyncmap 0x0> <magic 0xfb2b5aaa> <pcomp><accomp>]
rcvd [LCPDiscReq id=0x1 magic=0x172b914]
rcvd[CHAP Challenge id=0x1 <bcbf3cbe363150861c15cffae8617331>, name ="UMTS_CHAP_SRVR"]
sent[CHAP Response id=0x1 <6fcce180826b52be7803fc7a4b601de5>, name = "card"]
rcvd[CHAP Success id=0x1 ""]
CHAPauthentication succeeded
CHAPauthentication succeeded
sent[IPCP ConfReq id=0x1 <addr 0.0.0.0><ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd[IPCP ConfNak id=0x1 <ms-dns1 10.11.12.13><ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins10.11.12.14>]
sent[IPCP ConfReq id=0x2 <addr 0.0.0.0><ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
rcvd[IPCP ConfReq id=0x0]
sent[IPCP ConfNak id=0x0 <addr 0.0.0.0>]
rcvd[IPCP ConfNak id=0x2 <addr 10.218.148.212> <ms-dns1 211.137.58.20><ms-dns3 211.136.20.203>]
sent[IPCP ConfReq id=0x3 <addr 10.218.148.212> <ms-dns1 211.137.58.20><ms-dns3 211.136.20.203>]
rcvd[IPCP ConfReq id=0x1]
sent[IPCP ConfAck id=0x1]
rcvd[IPCP ConfAck id=0x3 <addr 10.218.148.212> <ms-dns1 211.137.58.20><ms-dns3 211.136.20.203>]
Could notdetermine remote IP address: defaulting to 10.64.64.64
local IP address 10.218.148.212
remote IPaddress 10.64.64.64
primary DNS address 211.137.58.20
secondaryDNS address 211.136.20.203
这样虽然拨号成功,但是它是在前台运行的,现在我们不能进行其他的任何操作,以前前台被它占领了,所以我们用pppd call wcdma $这个命令让它在后台运行,这样我们就可以在前台进行其他的操作了。
/etc/ppp/peers >: pppd call wcdma &
pppd options in effect:
debug # (from /etc/ppp/peers/wcdma)
nodetach # (from /etc/ppp/peers/wcdma)
dump # (from /etc/ppp/peers/wcdma)
noauth # (from /etc/ppp/peers/wcdma)
user card # (from /etc/ppp/peers/wcdma)
password ?????? # (from /etc/ppp/peers/wcdma)
remotename 3gppp # (from /etc/ppp/peers/wcdma)
/dev/ttyUSB2 # (from /etc/ppp/peers/wcdma)
115200 # (from /etc/ppp/peers/wcdma)
lock # (from /etc/ppp/peers/wcdma)
connect /usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-connect # (from /etc/ppp/peers/wcdma)
disconnect /usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-disconnect # (from /etc/ppp/peers/wcdma)
crtscts # (from /etc/ppp/peers/wcdma)
local # (from /etc/ppp/peers/wcdma)
hide-password # (from /etc/ppp/peers/wcdma)
novj # (from /etc/ppp/peers/wcdma)
novjccomp # (from /etc/ppp/peers/wcdma)
ipcp-accept-local # (from /etc/ppp/peers/wcdma)
ipcp-accept-remote # (from /etc/ppp/peers/wcdma)
ipparam 3gppp # (from /etc/ppp/peers/wcdma)
noipdefault # (from /etc/ppp/peers/wcdma)
defaultroute # (from /etc/ppp/peers/wcdma)
usepeerdns # (from /etc/ppp/peers/wcdma)
noccp # (from /etc/ppp/peers/wcdma)
abort on (BUSY)
abort on (NO CARRIER)
abort on (NO DIALTONE)
abort on (ERROR)
abort on (NO ANSWER)
timeout set to 120 seconds
send (AT^M)
expect (OK)
AT^M^M
OK
-- got it
send (^MATZ^M)
expect (OK)
^M
ATZ^M^M
OK
-- got it
send (^MAT+CGDCONT=1,"IP","cmnet",,0,0^M)
expect (OK)
^M
AT+CGDCONT=1,"IP","cmnet",,0,0^M^M
OK
-- got it
send (ATDT*99#^M)
expect (CONNECT)
^M
ATDT*99#^M^M
CONNECT
-- got it
send (\d)
Serial connection established.
using channel 4
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB2
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xa913b970> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0x159ffde> <pcomp> <accomp>]
sent [LCP ConfAck id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0x159ffde> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xa913b970> <pcomp> <accomp>]
rcvd [LCP DiscReq id=0x1 magic=0x159ffde]
rcvd [CHAP Challenge id=0x1 <3a9d31cd14b44974b0c8cd921ce63204>, name = "UMTS_CHAP_SRVR"]
sent [CHAP Response id=0x1 <1d26db27eacd007feabbdb56426234b6>, name = "card"]
rcvd [CHAP Success id=0x1 ""]
CHAP authentication succeeded
CHAP authentication succeeded
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
rcvd [IPCP ConfNak id=0x2 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x3 <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
rcvd [IPCP ConfNak id=0x3 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x4 <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
rcvd [IPCP ConfNak id=0x4 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x5 <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
rcvd [IPCP ConfNak id=0x5 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x6 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x6 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x7 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x7 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x8 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x8 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x9 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x9 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xa <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xa <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xb <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xb <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xc <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xc <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xd <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xd <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xe <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xe <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xf <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xf <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x10 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x10 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x11 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x11 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x12 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x12 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x13 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x13 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x14 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x14 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x15 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x15 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x16 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x16 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x17 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x17 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x18 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x18 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x19 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x19 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1a <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1a <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1b <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1b <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1c <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1c <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1d <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1d <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1e <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1e <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1f <addr 0.0.0.0>]
rcvd [IPCP ConfReq id=0x0]
sent [IPCP ConfNak id=0x0 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1f <addr 10.146.208.148>]
sent [IPCP ConfReq id=0x20]
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfAck id=0x1]
rcvd [IPCP ConfNak id=0x20 <addr 10.146.208.148>]
sent [IPCP ConfReq id=0x21 <addr 10.146.208.148>]
rcvd [IPCP ConfAck id=0x21 <addr 10.146.208.148>]
Could not determine remote IP address: defaulting to 10.64.64.64
local IP address 10.146.208.148
remote IP address 10.64.64.64
primary DNS address 10.11.12.13
secondary DNS address 10.11.12.14
/etc/ppp/peers >:
三、 现在我们就来测试一下,看看能不能上网
ping 域名服务器4.2.2.2
/etc/ppp/peers >: ping 4.2.2.2 -I ppp0
PING 4.2.2.2 (4.2.2.2): 56 data bytes
64 bytes from 4.2.2.2: seq=0 ttl=50 time=2524.370 ms
64 bytes from 4.2.2.2: seq=1 ttl=50 time=1520.146 ms
64 bytes from 4.2.2.2: seq=2 ttl=50 time=693.452 ms
64 bytes from 4.2.2.2: seq=3 ttl=50 time=629.477 ms
64 bytes from 4.2.2.2: seq=4 ttl=50 time=644.438 ms
64 bytes from 4.2.2.2: seq=5 ttl=50 time=640.548 ms
64 bytes from 4.2.2.2: seq=6 ttl=50 time=632.466 ms
64 bytes from 4.2.2.2: seq=7 ttl=50 time=587.508 ms
64 bytes from 4.2.2.2: seq=8 ttl=50 time=565.546 ms
64 bytes from 4.2.2.2: seq=9 ttl=50 time=557.537 ms
64 bytes from 4.2.2.2: seq=10 ttl=50 time=554.518 ms
--- 4.2.2.2 ping statistics ---
11 packets transmitted, 11 packets received, 0% packet loss
round-trip min/avg/max = 554.518/868.182/2524.370 ms
/etc/ppp/peers >:
可以。
再ping一下百度网:
/etc/ppp/peers >: ping www.baidu.com -I ppp0
PING www.baidu.com (220.181.111.148): 56 data bytes
64 bytes from 220.181.111.148: seq=0 ttl=49 time=934.383 ms
64 bytes from 220.181.111.148: seq=1 ttl=49 time=391.010 ms
64 bytes from 220.181.111.148: seq=2 ttl=49 time=345.984 ms
64 bytes from 220.181.111.148: seq=3 ttl=49 time=301.072 ms
64 bytes from 220.181.111.148: seq=4 ttl=49 time=915.210 ms
64 bytes from 220.181.111.148: seq=5 ttl=49 time=390.039 ms
64 bytes from 220.181.111.148: seq=6 ttl=49 time=585.136 ms
--- www.baidu.com ping statistics ---
8 packets transmitted, 7 packets received, 12% packet loss
round-trip min/avg/max = 301.072/551.833/934.383 ms
/etc/ppp/peers >:
略有丢包。
最后登录一下水木年华bbs