歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> ARM Llinux系統移植3G撥號上網收發短信

ARM Llinux系統移植3G撥號上網收發短信

日期:2017/2/28 13:53:43   编辑:Linux教程

一、 PPP移植

各項工作具體說明

向Linux內核添加3G模塊的驅動(USB轉串口驅動)和PPP協議的支持,然後編譯內核並下載到開發板。當然如果之前已經移植好內核,那麼只需要增加幾個選項就可以,然後在編譯內核就可以了,這個文檔默認內核已經移植過,所以只講與USB轉串口驅動和PPP協議支持的幾個選項。

[linuxidc@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

ppp協議介紹

/***********************轉載聲明*********************************/

二、 usb_modeswitch移植

下載usbmode庫:

[linuxidc@localhost fulinux]$ mkdir usbmode
[linuxidc@localhost fulinux]$ cd usbmode/

[linuxidc@localhost usbmode]$ wget http://pkgs.Fedoraproject.org/repo/pkgs/libusb1/libusb-1.0.0.tar.bz2/df2447c23750ef2b4a314200feacc2ee/libusb-1.0.0.tar.bz2

[linuxidc@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

[linuxidc@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

[linuxidc@localhost usbmode]$ wget http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-data-20130607.tar.bz2

以上這些下載地址如果有失效的,搜索相應的文件下載,即可下載。

解壓:

[linuxidc@localhost usbmode]$ tar xjf libusb-1.0.0.tar.bz2
[linuxidc@localhost usbmode]$ tar xjf libusb-compat-0.1.5.tar.bz2
[linuxidc@localhost usbmode]$ tar xjf usb-modeswitch-1.2.6.tar.bz2
[linuxidc@localhost usbmode]$ tar xjf usb-modeswitch-data-20130607.tar.bz2

編譯libusb:

[linuxidc@localhost usbmode]$ mkdir install
[linuxidc@localhost usbmode]$ cd libusb-1.0.0

[linuxidc@localhost libusb-1.0.0]$ ./configure --prefix=/home/linuxidc/fulinux/usbmode/install/ --build=i686 --host=arm-linux --disable-shared --enable-static (注意有兩--的前面有一個空格)

[linuxidc@localhost libusb-1.0.0]$ make

[linuxidc@localhost libusb-1.0.0]$ make install

[linuxidc@localhost libusb-1.0.0]$ ls ../install/
include lib
[linuxidc@localhost libusb-1.0.0]$

編譯usb_modeswitch:

[linuxidc@localhost usbmode]$ cd usb-modeswitch-1.2.6
[linuxidc@localhost usb-modeswitch-1.2.6]$ ls
[linuxidc@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

[linuxidc@localhost libusb-1.0.0]$ cd ..
[linuxidc@localhost usbmode]$ export PKG_CONFIG_PATH=/home/linuxidc/fulinux/usbmode/install/lib/pkgconfig:$PKG_CONFIG_PATH

[linuxidc@localhost usbmode]$ cd libusb-compat-0.1.5
[linuxidc@localhost libusb-compat-0.1.5]$

[linuxidc@localhost libusb-compat-0.1.5]$ ./configure --prefix=/home/linuxidc/fulinux/usbmode/install/ --build=i686 --host=arm-linux --disable-shared --enable-static

[linuxidc@localhost libusb-compat-0.1.5]$ make

[linuxidc@localhost libusb-compat-0.1.5]$ make install

[linuxidc@localhost libusb-compat-0.1.5]$ ls ../install/
bin include lib
[linuxidc@localhost libusb-compat-0.1.5]$

編譯usb_modeswitch:

[linuxidc@localhost libusb-compat-0.1.5]$ cd ../usb-modeswitch-1.2.4
[linuxidc@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

[linuxidc@localhost usb-modeswitch-1.2.4]$ make
[linuxidc@localhost usb-modeswitch-1.2.4]$ cp usb_modeswitch ../install/bin/

[linuxidc@localhost usb-modeswitch-1.2.4]$ cp usb_modeswitch /tftp/

上面用usb-modeswitch-1.2.6編譯時發現有問題,有如下

[linuxidc@localhost usb-modeswitch-1.2.6]$ make
cc -o usb_modeswitch usb_modeswitch.c -Wall -I../install/include -static -L /home/linuxidc/fulinux/usbmode/install/lib -l usb -l usb-1.0 -l pthread
/usr/bin/ld: skipping incompatible /home/linuxidc/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
[linuxidc@localhost usb-modeswitch-1.2.6]$

“incompatible”庫和這個有沖突。建議使用。1.2.6一下的版本。

把usb-modeswitch-data-20130607下的usb_modeswitch.d中的所有文件都拷貝到開發板的etc/usb_modeswitch.d/目錄:

[linuxidc@localhost usbmode]$ cd usb-modeswitch-data-20130607
[linuxidc@localhost usb-modeswitch-data-20130607]$ ls
40-usb_modeswitch.rules ChangeLog COPYING gen-rules.tcl Makefile README usb_modeswitch.d
[linuxidc@localhost usb-modeswitch-data-20130607]$ tar cjf usb_modeswitch.d.tar.bz2 usb_modeswitch.d/
[linuxidc@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
[linuxidc@localhost usb-modeswitch-data-20130607]$ cp usb_modeswitch.d.tar.bz2 /tftp/
[linuxidc@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,解壓源代碼包,進入目錄,進行交叉編譯:

[linuxidc@localhost fulinux]$ mkdir ppp
[linuxidc@localhost fulinux]$ cd ppp/
[linuxidc@localhost ppp]$ wget ftp://ftp.samba.org/pub/ppp/ppp-2.4.4.tar.gz

[linuxidc@localhost ppp]$ tar zxf ppp-2.4.4.tar.gz
[linuxidc@localhost ppp]$ cd ppp-2.4.4

[linuxidc@localhost ppp-2.4.4]$ ./configure

[linuxidc@localhost chat]$ linux
[linuxidc@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)

[linuxidc@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

[linuxidc@localhost chat]$ cd ../pppd
[linuxidc@localhost pppd]$ vim auth.c

1316 ao->neg_upap = !refuse_pap /*&& (passwd[0] != 0 || get_pap_passwd(NULL))*/; /* add by fulinux*/

[linuxidc@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

[linuxidc@localhost pppd]$ cd ..
[linuxidc@localhost ppp-2.4.4]$ make

make[1]: Leaving directory `/usr/local/src/linuxidc/fulinux/ppp/ppp-2.4.4/pppdump'
[linuxidc@localhost ppp-2.4.4]$ cd chat/
[linuxidc@localhost chat]$ ls
chat chat.8 chat.c chat.o Makefile Makefile.linux Makefile.sol2
[linuxidc@localhost chat]$ file chat
chat: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped

[linuxidc@localhost chat]$ cd ..

[linuxidc@localhost ppp-2.4.4]$ cd pppd
[linuxidc@localhost pppd]$ file pppd
pppd: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[linuxidc@localhost pppd]$

將交叉編譯出來的這兩個應用程序chat和pppd拷貝到開發板 /usr/sbin目錄下,更改其屬性為可執行文件。

[linuxidc@localhost chat]$ cp chat /tftp/

[linuxidc@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

Copyright © Linux教程網 All Rights Reserved