gprs模块 代码 linux,arm开发板上gprs模块拨号上网

有了操作系统,开发板和宿主机就基本没有区别了,:-)。所以我直接就把在fedora下测试通过的三个脚本稍加修改搬到了开发板上,毫无疑问的一次拨通,:-),有了操作系统,就是爽呀。微处理器是at91rm9200,gprs模块是mc39i。

当然如果内核不支持ppp拨号,则要重新编译内核,添加对ppp的支持,

Network device support-->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

然后重新烧写新生成的内核映象。

再把我的脚本粘帖一遍吧。这样就不怕丢了,:-)。

/mnt/nfs/myppp/ppp-on

#!/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***1# # The telephone number for the connection

ACCOUNT=  # The account name for logon (as in 'George Burns')

PASSWORD=  # 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=/mnt/nfs/myppp/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 pppd debug lock modem /dev/ttyS2 115200 \

asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP \

noipdefault netmask $NETMASK defaultroute connect $DIALER_SCRIPT

/mnt/nfs/myppp/ppp-on-dialer

#!/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  AT+IPR=115200   \

OK  AT+CGDCONT=1,"IP","CMNET"   \

OK  AT+CGACT=1,1   \

OK  ATDT*99***1#   \

CONNECT  ''    \

# ogin:--ogin: $ACCOUNT   \

# assword: $PASSWORD

/mnt/nfs/myppp/ppp-off

#!/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

如果ping不通的话,配置一下network就ok了。:-)

/etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=yes

HOSTNAME=localhost.localdomain

GATEWAY=

GATWAYDEV=

关键是后边这两个要空着,这样就会使用ppp分配的网关了,也就可以ping通了。

rar.gif

文件:

myppp.rar

大小:

2KB

下载:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值