4G模块使用pppd拨号调试记录 您所在的位置:网站首页 pppd拨号失败 4G模块使用pppd拨号调试记录

4G模块使用pppd拨号调试记录

2023-10-25 04:45| 来源: 网络整理| 查看: 265

4G模块使用pppd拨号调试记录 1、配置linux内核2、交叉编译移植ppp拨号程序3、编写pppd配置脚本

1、配置linux内核

执行make menuconfig

使能USB GSM配置 在这里插入图片描述使能所有ppp协议相关配置

在这里插入图片描述在这里插入图片描述 然后编译后的内核烧到板子中。

2、交叉编译移植ppp拨号程序

下载路径:https://download.samba.org/pub/ppp/ 下载最新版本的源码。解压后进入目录 使用交叉编译工具编译:make CC=XXX/arm-linux-gcc (xxx为交叉编译工具的路径)。编译后将./pppd/pppd 、./chat/chat 和 ./pppdump/pppdump拷贝到linux板子的/bin路径下。

3、编写pppd配置脚本

新建/etc/ppp/peers 目录。 在/etc/ppp 目录下新建gprs-chat-connect文件: TIMEOUT 15 ABORT ‘\nDELAYED\r’ //有以下几条命令出现 中断连接 (ABORT) ABORT ‘\nBUSY\r’ ABORT ‘\nERROR\r’ ABORT ‘\nNO DIALTONE\r’ ABORT ‘\nNO CARRIER\r’ TIMEOUT 40 ‘’ \rAT OK AT+CPIN? OK AT+CSQ OK AT+COPS? OK AT+CGATT? OK ATS0=0 OK AT+CREG? OK ATE0V1 OK AT+CGDCONT=1,“IP”,“CMNET” OK ATD99**1# CONNECT 在/etc/ppp/peers目录下新建gprsdial文件: /dev/ttyUSB0 // 根据实际情况写上相应的设备名 115200 nocrtscts modem debug nodetach local usepeerdns noipdefault defaultroute user “cmnet” 0.0.0.0:0.0.0.0 connect ‘/bin/chat -s -v -f /etc/ppp/gprs-chat-connect’

然后执行pppd call gprsdial & 结果如下: timeout set to 15 seconds abort on (\nDELAYED\r) abort on (\nBUSY\r) abort on (\nERROR\r) abort on (\nNO DIALTONE\r) abort on (\nNO CARRIER\r) timeout set to 40 seconds send (MATM) expect (OK) ^M OK – got it send (AT+CPIN?^M) expect (OK) ^M ^M +CPIN: READY^M ^M OK – got it send (AT+CSQ^M) expect (OK) ^M ^M +CSQ: 30,99^M ^M OK – got it send (AT+COPS?^M) expect (OK) ^M ^M +COPS: 0,0,“CHINA MOBILE”,7^M ^M OK – got it send (AT+CGATT?^M) expect (OK) ^M ^M +CGATT: 1^M ^M OK – got it send (ATS0=0^M) expect (OK) ^M ^M OK – got it send (AT+CREG?^M) expect (OK) ^M ^M +CREG: 0,1^M ^M OK – got it send (ATE0V1^M) expect (OK) ^M ^M OK – got it send (AT+CGDCONT=1,“IP”,“CMNET”^M) expect (OK) ^M ^M OK – got it send (ATD99**1#^M) expect (CONNECT) ^M ^M CONNECT – got it Script /bin/chat -s -v -f /etc/ppp/gprs-chat-connect finished (pid 1137), status = 0x0 Serial connection established. using channel 5 Using interface ppp0 Connect: ppp0 /dev/ttyUSB0 Warning - secret file /etc/ppp/pap-secrets has world and/or group access sent [LCP ConfReq id=0x1 ] rcvd [LCP ConfReq id=0xc ] sent [LCP ConfAck id=0xc ] rcvd [LCP ConfAck id=0x1 ] rcvd [LCP DiscReq id=0xd magic=0x15f10999] rcvd [CHAP Challenge id=0x1 , name = “UMTS_CHAP_SRVR”] Warning - secret file /etc/ppp/chap-secrets has world and/or group access sent [CHAP Response id=0x1 , name = “cmnet”] rcvd [CHAP Success id=0x1 “”] CHAP authentication succeeded CHAP authentication succeeded sent [CCP ConfReq id=0x1 ] sent [IPCP ConfReq id=0x1 ] rcvd [LCP ProtRej id=0xe 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15 03 2f] Protocol-Reject for ‘Compression Control Protocol’ (0x80fd) received rcvd [IPCP ConfReq id=0x0] sent [IPCP ConfNak id=0x0 ] rcvd [IPCP ConfRej id=0x1 ] sent [IPCP ConfReq id=0x2 ] rcvd [IPCP ConfReq id=0x1] sent [IPCP ConfAck id=0x1] rcvd [IPCP ConfNak id=0x2 ] sent [IPCP ConfReq id=0x3 ] rcvd [IPCP ConfAck id=0x3 ] Could not determine remote IP address: defaulting to 10.64.64.64 not replacing existing default route via 192.168.0.1 local IP address 10.83.11.4 remote IP address 10.64.64.64 primary DNS address 211.136.17.107 secondary DNS address 211.136.20.203 Script /etc/ppp/ip-up started (pid 1142) Script /etc/ppp/ip-up finished (pid 1142), status = 0x0

看到分配到IP地址就说明拨号成功。 这时候只能ping通127.0.0.1本地ip,无法ping通外网(如:114.114.114.114)。这是没有将ppp0的网关地址添加到路由中。执行命令: route add default gw 10.64.64.64就可将其添加到路由中。IP地址可从ifconfig中获得: 在这里插入图片描述 此时还需再添加dns就可ping通公网域名了。 在这里插入图片描述 至此可算告一段落。PPP协议以及拨号相关的流程后续再慢慢学习。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有