当前位置: 技术问答>linux和unix
Linux下实现GPRS上网的问题
来源: 互联网 发布时间:2016-05-08
本文导语: 我用一个GPRS模块实现拨号上网,在网上参照了各位大虾的建议使用ppp-on脚本启动pppd并拨号。 串口是ttyS0,波特率115200 但每当建立连接之后总是显示modem hangup。但kppp拨号并没有问题,可以上网。 几天的努力几乎试过...
我用一个GPRS模块实现拨号上网,在网上参照了各位大虾的建议使用ppp-on脚本启动pppd并拨号。
串口是ttyS0,波特率115200
但每当建立连接之后总是显示modem hangup。但kppp拨号并没有问题,可以上网。
几天的努力几乎试过了所有pppd的选项还是没见成效,百思不得其解。
这是我的log:
Mar 20 09:34:40 localhost pppd[3081]: pppd 2.4.4 started by root, uid 0
Mar 20 09:34:41 localhost chat[3082]: timeout set to 3 seconds
Mar 20 09:34:41 localhost chat[3082]: abort on (nBUSYr)
Mar 20 09:34:41 localhost chat[3082]: abort on (nNO ANSWERr)
Mar 20 09:34:41 localhost chat[3082]: abort on (nRINGINGrnrnRINGINGr)
Mar 20 09:34:41 localhost chat[3082]: send (ATZ^M)
Mar 20 09:34:41 localhost chat[3082]: expect (OK)
Mar 20 09:34:41 localhost chat[3082]:
Mar 20 09:34:41 localhost chat[3082]: NO CARRIER^M
Mar 20 09:34:41 localhost chat[3082]: ^M
Mar 20 09:34:41 localhost chat[3082]: OK
Mar 20 09:34:41 localhost chat[3082]: -- got it
Mar 20 09:34:41 localhost chat[3082]: send (ATE0v1^M)
Mar 20 09:34:41 localhost chat[3082]: expect (OK)
Mar 20 09:34:41 localhost chat[3082]: ^M
Mar 20 09:34:41 localhost chat[3082]: ATE0v1^M^M
Mar 20 09:34:41 localhost chat[3082]: OK
Mar 20 09:34:41 localhost chat[3082]: -- got it
Mar 20 09:34:41 localhost chat[3082]: send (AT+FCLASS=0^M)
Mar 20 09:34:41 localhost chat[3082]: expect (OK)
Mar 20 09:34:41 localhost chat[3082]: ^M
Mar 20 09:34:41 localhost chat[3082]: ^M
Mar 20 09:34:41 localhost chat[3082]: OK
Mar 20 09:34:41 localhost chat[3082]: -- got it
Mar 20 09:34:41 localhost chat[3082]: send (AT+CGDCONT=1,"ip","cment"^M)
Mar 20 09:34:42 localhost chat[3082]: timeout set to 30 seconds
Mar 20 09:34:42 localhost chat[3082]: expect (OK)
Mar 20 09:34:42 localhost chat[3082]: ^M
Mar 20 09:34:42 localhost chat[3082]: ^M
Mar 20 09:34:42 localhost chat[3082]: OK
Mar 20 09:34:42 localhost chat[3082]: -- got it
Mar 20 09:34:42 localhost chat[3082]: send (ATDT*99***1#^M)
Mar 20 09:34:42 localhost chat[3082]: expect (CONNECT)
Mar 20 09:34:42 localhost chat[3082]: ^M
Mar 20 09:34:42 localhost chat[3082]: ^M
Mar 20 09:34:42 localhost chat[3082]: CONNECT
Mar 20 09:34:42 localhost chat[3082]: -- got it
Mar 20 09:34:42 localhost chat[3082]: send (^M)
Mar 20 09:34:42 localhost pppd[3081]: Serial connection established.
Mar 20 09:34:42 localhost pppd[3081]: Using interface ppp0
Mar 20 09:34:42 localhost pppd[3081]: Connect: ppp0 /dev/ttyS0
Mar 20 09:34:43 localhost pppd[3081]: Hangup (SIGHUP)
Mar 20 09:34:43 localhost pppd[3081]: Modem hangup
Mar 20 09:34:43 localhost pppd[3081]: Connection terminated.
Mar 20 09:34:44 localhost pppd[3081]: Exit.
不知道是什么原因导致总是接收到sighup信号modem就huangup。
如果我在脚本中加入demand选项可以显示已经获取的IP地址。并且可以用ifconfig读到ppp0的信息。
Mar 20 10:00:36 localhost pppd[3338]: pppd 2.4.4 started by root, uid 0
Mar 20 10:00:36 localhost pppd[3338]: Using interface ppp0
Mar 20 10:00:37 localhost pppd[3338]: local IP address 10.64.64.64
Mar 20 10:00:37 localhost pppd[3338]: remote IP address 10.112.112.112
但是当我试图用ping启动连接的时候,错误还是和上面一样。
但有一点需要指出的是我用kppp可以成功连接并拿到IP地址,更改默认路由后可以上网,硬件流控设置与否都没关系。
Mar 20 10:05:13 localhost pppd[3382]: pppd 2.4.4 started by root, uid 0
Mar 20 10:05:13 localhost pppd[3382]: Using interface ppp1
Mar 20 10:05:13 localhost pppd[3382]: Connect: ppp0 /dev/ttyS0
Mar 20 10:05:13 localhost pppd[3382]: Remote message: Welcome!
Mar 20 10:05:13 localhost pppd[3382]: PAP authentication succeeded
Mar 20 10:05:14 localhost pppd[3382]: not replacing existing default route via 192.168.1.1
Mar 20 10:05:14 localhost pppd[3382]: local IP address 10.71.70.84
Mar 20 10:05:14 localhost pppd[3382]: remote IP address 10.71.59.78
Mar 20 10:05:14 localhost pppd[3382]: primary DNS address 211.136.112.50
Mar 20 10:05:14 localhost pppd[3382]: secondary DNS address 211.136.20.203
通过打印调试信息我发现即使用kppp拨号的时候也会受到sighup信号,但它并不会让modem挂起。
谢谢指教!
串口是ttyS0,波特率115200
但每当建立连接之后总是显示modem hangup。但kppp拨号并没有问题,可以上网。
几天的努力几乎试过了所有pppd的选项还是没见成效,百思不得其解。
这是我的log:
Mar 20 09:34:40 localhost pppd[3081]: pppd 2.4.4 started by root, uid 0
Mar 20 09:34:41 localhost chat[3082]: timeout set to 3 seconds
Mar 20 09:34:41 localhost chat[3082]: abort on (nBUSYr)
Mar 20 09:34:41 localhost chat[3082]: abort on (nNO ANSWERr)
Mar 20 09:34:41 localhost chat[3082]: abort on (nRINGINGrnrnRINGINGr)
Mar 20 09:34:41 localhost chat[3082]: send (ATZ^M)
Mar 20 09:34:41 localhost chat[3082]: expect (OK)
Mar 20 09:34:41 localhost chat[3082]:
Mar 20 09:34:41 localhost chat[3082]: NO CARRIER^M
Mar 20 09:34:41 localhost chat[3082]: ^M
Mar 20 09:34:41 localhost chat[3082]: OK
Mar 20 09:34:41 localhost chat[3082]: -- got it
Mar 20 09:34:41 localhost chat[3082]: send (ATE0v1^M)
Mar 20 09:34:41 localhost chat[3082]: expect (OK)
Mar 20 09:34:41 localhost chat[3082]: ^M
Mar 20 09:34:41 localhost chat[3082]: ATE0v1^M^M
Mar 20 09:34:41 localhost chat[3082]: OK
Mar 20 09:34:41 localhost chat[3082]: -- got it
Mar 20 09:34:41 localhost chat[3082]: send (AT+FCLASS=0^M)
Mar 20 09:34:41 localhost chat[3082]: expect (OK)
Mar 20 09:34:41 localhost chat[3082]: ^M
Mar 20 09:34:41 localhost chat[3082]: ^M
Mar 20 09:34:41 localhost chat[3082]: OK
Mar 20 09:34:41 localhost chat[3082]: -- got it
Mar 20 09:34:41 localhost chat[3082]: send (AT+CGDCONT=1,"ip","cment"^M)
Mar 20 09:34:42 localhost chat[3082]: timeout set to 30 seconds
Mar 20 09:34:42 localhost chat[3082]: expect (OK)
Mar 20 09:34:42 localhost chat[3082]: ^M
Mar 20 09:34:42 localhost chat[3082]: ^M
Mar 20 09:34:42 localhost chat[3082]: OK
Mar 20 09:34:42 localhost chat[3082]: -- got it
Mar 20 09:34:42 localhost chat[3082]: send (ATDT*99***1#^M)
Mar 20 09:34:42 localhost chat[3082]: expect (CONNECT)
Mar 20 09:34:42 localhost chat[3082]: ^M
Mar 20 09:34:42 localhost chat[3082]: ^M
Mar 20 09:34:42 localhost chat[3082]: CONNECT
Mar 20 09:34:42 localhost chat[3082]: -- got it
Mar 20 09:34:42 localhost chat[3082]: send (^M)
Mar 20 09:34:42 localhost pppd[3081]: Serial connection established.
Mar 20 09:34:42 localhost pppd[3081]: Using interface ppp0
Mar 20 09:34:42 localhost pppd[3081]: Connect: ppp0 /dev/ttyS0
Mar 20 09:34:43 localhost pppd[3081]: Hangup (SIGHUP)
Mar 20 09:34:43 localhost pppd[3081]: Modem hangup
Mar 20 09:34:43 localhost pppd[3081]: Connection terminated.
Mar 20 09:34:44 localhost pppd[3081]: Exit.
不知道是什么原因导致总是接收到sighup信号modem就huangup。
如果我在脚本中加入demand选项可以显示已经获取的IP地址。并且可以用ifconfig读到ppp0的信息。
Mar 20 10:00:36 localhost pppd[3338]: pppd 2.4.4 started by root, uid 0
Mar 20 10:00:36 localhost pppd[3338]: Using interface ppp0
Mar 20 10:00:37 localhost pppd[3338]: local IP address 10.64.64.64
Mar 20 10:00:37 localhost pppd[3338]: remote IP address 10.112.112.112
但是当我试图用ping启动连接的时候,错误还是和上面一样。
但有一点需要指出的是我用kppp可以成功连接并拿到IP地址,更改默认路由后可以上网,硬件流控设置与否都没关系。
Mar 20 10:05:13 localhost pppd[3382]: pppd 2.4.4 started by root, uid 0
Mar 20 10:05:13 localhost pppd[3382]: Using interface ppp1
Mar 20 10:05:13 localhost pppd[3382]: Connect: ppp0 /dev/ttyS0
Mar 20 10:05:13 localhost pppd[3382]: Remote message: Welcome!
Mar 20 10:05:13 localhost pppd[3382]: PAP authentication succeeded
Mar 20 10:05:14 localhost pppd[3382]: not replacing existing default route via 192.168.1.1
Mar 20 10:05:14 localhost pppd[3382]: local IP address 10.71.70.84
Mar 20 10:05:14 localhost pppd[3382]: remote IP address 10.71.59.78
Mar 20 10:05:14 localhost pppd[3382]: primary DNS address 211.136.112.50
Mar 20 10:05:14 localhost pppd[3382]: secondary DNS address 211.136.20.203
通过打印调试信息我发现即使用kppp拨号的时候也会受到sighup信号,但它并不会让modem挂起。
谢谢指教!
|
http://topic.csdn.net/u/20071226/22/8da2effa-0bc9-4f45-8b15-d2c585844c6e.html
去看看, 也许有帮助.
去看看, 也许有帮助.