分类: LINUX
2013-07-08 17:24:57
添加如下内核选项:(这一步一般是不用做的,因为mini2440其实已经添加了此功能了)
Device Drivers ---> Network device support --->
<*> PPP (point-to-point protocol) support
[*] PPP multilink support
<*> PPP support for async serial ports
<*> PPP support for sync tty ports
<*> SLIP (serial line) support
[*] CSLIP compressed headers
添加完成后保存并退出,编译出完整的内核文件再烧到开发板中
2.下载ppp-2.4.4.tar.gz 或其他版本PPP 拨号程序源码,可以上网搜索下载
解压文件,进入目录ppp-2.4.4中,执行配置命令
#./configure
再执行
#make
CC=/opt/arm-2007q3/bin/arm-none-linux-gnueabi-gcc (后面的CC表示你的交叉编译器目录,要是你添加PATH路径,直接CC=arm-linux-gcc)
有些开发板会有两个交叉编译器,一个是编译内核,驱动等用的编译器,另一个是编译上层应用的,此处应该用编译上层应用的编译器。
3.复制相关文件到开发板
在编译完成之后的ppp中的script 目录复制ppp-on 、ppp-off 到/bin中,将ppp-dial-on 复制到/etc下。
再将pppd目录中的pppd ,chat目录中的chat 两个可执行文件复制到 /bin 中。
4.修改相关拨号脚本
ppp-on脚本为配置gprs提供的usb转串口的接口
=================================================================================================================================
#!/bin/sh
#
# Script to initiate a ppp connection. This is the first part of the
# pair of scripts. This is not a secure pair of scripts as the codes
# are visible with the 'ps' command. However, it is simple.
#
# These are the parameters. Change as needed.
TELEPHONE=*99# # The telephone number for the connection
ACCOUNT=3gnet # The account name for logon (as in 'George Burns')
#PASSWORD=gracie # The password for this account (and 'Gracie Allen')
LOCAL_IP=0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0
REMOTE_IP=0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0
NETMASK=255.255.255.0 # The proper netmask if needed
#
# Export them so that they will be available at 'ppp-on-dialer' time.
export TELEPHONE ACCOUNT PASSWORD
#
# This is the location of the script which dials the phone and logs
# in. Please use the absolute file name as the $PATH variable is not
# used on the connect option. (To do so on a 'root' account would be
# a security hole so don't ask.)
#
DIALER_SCRIPT=/etc/ppp-on-dialer
#
# Initiate the connection
#
# I put most of the common options on this command. Please, don't
# forget the 'lock' option or some programs such as mgetty will not
# work. The asyncmap and escape will permit the PPP link to work with
# a telnet or rlogin connection. You are welcome to make any changes
# as desired. Don't use the 'defaultroute' option if you currently
# have a default route to an ethernet gateway.
#
exec /bin/pppd debug nodetach lock modem crtscts /dev/ttyUSB2 115200 \
asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP \
noipdefault netmask $NETMASK defaultroute connect $DIALER_SCRIPT
**********************************************************************************************************************************
其中一些参数的说明:
TELEPHONE、 ACCOUNT、 PASSWORD分别运营商的拨号号码,账号,密码。三大运营商的设置如下
中国联通(WCDMA) 拨号号码:*99# 账号和密码为空
中国电信(CDMA2000) 拨号号码 #777 账号:ctnet@mycdma.cn 密码:vnet.mobi 1x网络的账号和密码为:card(CARD)
中国移动 拨号号码 *98*1#(TD-SCDMA)*99***1#(GSM) 账号和密码为空。
DIALER_SCRIPT=/etc/ppp-on-dialer 实际拨号连接网络的脚本位置。
在执行pppd的一些参数含义:
debug 输出调试信息;
nodetach 不后台运行,默认是后台运行的;
modem 这个参数使得pppd进程将等待模块发回的CD (Carrier Detect)信号,与local 真好相反;
crtscts 接口带硬件流控 ;
dev/ttyUSB2 接口;
115200 接口波特率;
defaultroute 本地和远端的ip 都设为0使得接入的isp 分配本地的ip 地址;
connect $DIALER_SCRIPT 调用连接chat脚本;
==================================================================================================================================
ppp-dial-on为实际拨号联网的脚本:
==================================================================================================================================
#!/bin/sh
#
# This is part 2 of the ppp-on script. It will perform the connection
# protocol for the desired connection.
#
exec chat -v \
TIMEOUT 3 \
ABORT '\nBUSY\r' \
ABORT '\nNO ANSWER\r' \
ABORT '\nRINGING\r\n\r\nRINGING\r' \
'' \rAT \
'OK-+++\c-OK' ATH0 \
TIMEOUT 30 \
OK ATDT$TELEPHONE \
CONNECT '' \
# ogin:--ogin: $ACCOUNT \
# assword: $PASSWORD
**********************************************************************************************************************************
联通、移动的可以注释掉最后两行,不输入账号密码,登陆。
TIMEOUT 3 为超时设置,超过3s超时,退出
ABORT 指定了AT指令交互时,出了什么样的错误chat将退出。
AT 指令交互是”接收”“发送”的形式。
比如: '' \rAT
表示不接收任何信息,直接发送AT
OK ATDT$TELEPHONE
表示等待接收OK,如果OK,发送ATD$TELEPHONE 这个命令
==================================================================================================================================
ppp-off 为关闭ppp连接脚本
#!/bin/sh
######################################################################
#
# Determine the device to be terminated.
#
if [ "$1" = "" ]; then
DEVICE=ppp0
else
DEVICE=$1
fi
######################################################################
#
# If the ppp0 pid file is present then the program is running. Stop it.
if [ -r /var/run/$DEVICE.pid ]; then
kill -INT `cat /var/run/$DEVICE.pid`
#
# If the kill did not work then there is no process running for this
# pid. It may also mean that the lock file will be left. You may wish
# to delete the lock file at the same time.
if [ ! "$?" = "0" ]; then
rm -f /var/run/$DEVICE.pid
echo "ERROR: Removed stale pid file"
exit 1
fi
#
# Success. Let pppd clean up its own junk.
echo "PPP link to $DEVICE terminated."
exit 0
fi
#
# The ppp process is not running for ppp0
echo "ERROR: PPP link is not active on $DEVICE"
exit 1
mihoutao13142013-08-23 11:24:47
招聘 c++软件工程师 有通信行业工作经验 精通linux c++ 男士 工作3年 qq2352113842 工作地点北京 薪资 15w左右