乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      arm中實現(xiàn)pppd連接GPRS上網(wǎng)的相關筆記,含GPRS自動撥號腳本(真正的實時監(jiān)控,斷線自動重撥)

       漢江秋月夜 2016-07-13

      分類: 嵌入式

      在嵌入式Linux下GPRS上網(wǎng)方案

      筆記1

      硬/軟件環(huán)境

      基于S3C2410的嵌入式系統(tǒng),COM1連接PC,COM2連接SIM300 GPRS模塊。
      該系統(tǒng)運行在Linux 2.6.14操作系統(tǒng)下,使用ppp套件通過SIM300進行PPP撥號。

      一。讓Linux內(nèi)核支持PPP

      進入Linux內(nèi)核目錄,執(zhí)行#make menuconfig
      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

      二:ppp套件安裝

               下載ppp:ftp://ftp.samba.org/pub/ppp ×最新版本為2.4.4
               將ppp-2.4.4.tar.gz解壓至目錄
      ×這里默認ppp源碼目錄為$(PPP)
                    #tar zxvf ppp-2.4.4.tar.gz
               然后交叉編譯ppp:
                    #cd $(PPP)
      #./configure
      #make CC=/usr/local/arm/3.4.1/bin/arm-linux-gcc ×這里指定交叉編譯器
               將ppp套件安裝至嵌入式系統(tǒng)中:
      ×這里默認可執(zhí)行文件在嵌入式系統(tǒng)下的目錄為$(EMB_BIN)
      #cp $(PPP)/chat/chat $(EMB_BIN)
      #cp $(PPP)/pppd/pppd $(EMB_BIN)
      #cp $(PPP)/pppdump/pppdump $(EMB_BIN)
      #cp $(PPP)/pppstats/pppstats $(EMB_BIN)
                    ×這里默認嵌入式系統(tǒng)的etc目錄為$(EMB_ETC)
                    #mkdir $(EMB_ETC)/ppp
                    #cp $(PPP)/etc.ppp/* $(EMB_ETC)/ppp

      三:ppp套件配置

      $(EMB_BIN)/dial-on.sh (GPRS啟動腳本)

      1. #!/bin/sh
      2. #define dial_on function
      3. dial_on()
      4. {
      5.        #test if pppd is running
      6.        pppd_stat=`ifconfig|grep ppp|wc -l|cut -b 7-7`
      7.        if [ $pppd_stat -gt 0 ]
      8.        then
      9.               echo "ppp connection's already started."
      10.        else
      11.               #close ethernet interface
      12.               ifconfig eth0 down
      13.               
      14.               #ppp start
      15.               pppd modem /dev/ttyS1 57600 nocrtscts lock connect "chat -v -f /etc/ppp/gprs-connect" user "" noauth debug defaultroute
      16.               # pppd配置說明:
      17.               # ttyS1:連接GPRS模塊SIM300的串口
      18.               # 57600:GPRS的撥號速率
      19.               # nocrtscts:無流控
      20.               # lock:鎖定設備
      21.               # connect “chat –v –f /etc/ppp/gprs-connect”:GPRS連接腳本文件
      22.               # user “”:用戶名,這里是無
      23.               # noauth:無需認證
      24.               # debug:輸出調(diào)試信息
      25.               # defaultroute:此撥號連接作為默認路由
      26.               echo "ppp is starting..."
      27.        fi
      28. }
      29.  
      30. #dial on gprs
      31. dial_on
      32. #wait for ppp's init
      33. sleep 5
      34. pppd_stat=`ifconfig|grep ppp|wc -l|cut -b 7-7`
      35. if [ $pppd_stat -eq 0 ]
      36. then
      37.        echo "trying 2nd time to call ppp"
      38.        dial_on
      39.        sleep 5
      40. fi
      41. pppd_stat=`ifconfig|grep ppp|wc -l|cut -b 7-7`
      42. if [ $pppd_stat -eq 0 ]
      43. then
      44.        echo "pppd error!"
      45.        echo "please check pppd's config files

      $(EMB_BIN)/dial-off.sh (關閉GPRS連接腳本)

      1. #!/bin/sh

      2. #get pppd's pid
      3. pid=`pidof pppd`
      4.  
      5. #if pppd process is running
      6. if [ -n $pid ]
      7. then
      8.        #kill pppd
      9.        kill $pid
      10.        
      11.        #open the ethernet interface
      12.        ifconfig eth0 up
      13.        
      14.        echo "ppp connection is closed."
      15. else
      16.        echo "ppp connection isn't existed.

      $(EMB_ETC)/ppp/gprs-connect (GPRS連接配置文件)

      1. #GPRS連接超時設置
      2. TIMEOUT 60
      3. #若MODEM遇到BUSY、ERROR、NO CARRIER等信息時,停止撥號
      4. ABORT "BUSY"
      5. ABORT "ERROR"
      6. ABORT "NO CARRIER"
      7. #外送“AT”指令
      8. '' AT
      9. #當?shù)玫健癘K”回應時,外送AT+CGDCONT=1,"IP","CMNET"命令
      10. "OK" "AT+CGDCONT=1,/042IP/042,/042CMNET/042"
      11. #當?shù)玫健癘K”回應時,外送ATDT*99***1#命令
      12. "OK" "ATDT*99***1#"
      13. #當?shù)玫健癈ONNECT”回應時,撥號結束,程序退出
      14. "CONNECT"

      $(EMB_ETC)/ppp/pap-secrets (GPRS認證配置文件)

      1. # Secrets for authentication using PAP
      2. # client server secret IP addresses
      3. '' * '' *

      說明

      (1)還需要在$(EMB_ETC)/ppp目錄下創(chuàng)建指向$(EMB_ETC)/resolv.conf的鏈接,用于指定PPP連接的DNS。
      (2)在ppp連接時,需要關閉eth連接。在腳本中已經(jīng)設置好了,首先關閉eth連接,然后進行ppp連接,在ppp連接完成時,再開啟eth連接。
      (3)最好在系統(tǒng)中開啟syslogd進程,這樣在/var/log/messages文件中會記錄GPRS進行撥號的DEBUG信息,便于調(diào)試。
      (4)運行撥號腳本后,可以使用#ifconfig查看PPP連接信息。

      筆記2:

      arm上成功實現(xiàn)ppp撥號的腳本:

      ppp-on:

      1. #!/bin/sh
      2. pppd modem -d -detach lock /dev/ttySAC0 19200 kdebug 4 file /etc/ppp/options crtscts noipdefault netmask 255.255.255.0 defaultroute connect /etc/ppp/chat-script

      ppp-off:

      1. #!/bin/sh
      2. ######################################################################
      3. #
      4. # Determine the device to be terminated.
      5. #
      6. if [ "$1" = "" ]; then
      7.  DEVICE=ppp0
      8. else
      9.  DEVICE=$1
      10. fi

      11. ######################################################################
      12. #
      13. # If the ppp0 pid file is present then the program is running. Stop it.
      14. if [ -r /var/run/$DEVICE.pid ]; then
      15.         kill -INT `cat /var/run/$DEVICE.pid`
      16. #
      17. # If the kill did not work then there is no process running for this
      18. # pid. It may also mean that the lock file will be left. You may wish
      19. # to delete the lock file at the same time.
      20.         if [ ! "$?" = "0" ]; then
      21.                 rm -f /var/run/$DEVICE.pid
      22.                 echo "ERROR: Removed stale pid file"
      23.                 exit 1
      24.         fi
      25. #
      26. # Success. Let pppd clean up its own junk.
      27.         echo "PPP link to $DEVICE terminated."
      28.         exit 0
      29. fi
      30. #
      31. # The ppp process is not running for ppp0
      32. echo "ERROR: PPP link is not active on $DEVICE"
      33. exit 1

      chat-script:

      1. #!/bin/sh
      2. exec chat -v /
      3. TIMEOUT 5 /
      4. ABORT "BUSY" /
      5. ABORT "ERROR" /
      6. ABORT "NO CARRIER" /
      7. '' /rAT /
      8. OK 'AT+CGDCONT=1,"IP","CMNET"' /
      9. OK 'ATDT*99***1#' /
      10. CONNECT '' /

      設置DNS的resove.conf:

      1. nameserver 211.136.20.203
      2. nameserver 211.136.17.107

      筆記3:

      GPRS自動撥號腳本(真正的實時監(jiān)控,斷線自動重撥):

      http://www./viewthread.php?tid=8117&extra=&page=1

      開機自動運行,實時監(jiān)控,斷線自動重撥
      把文件傳到DM里,設置文件屬性為755,然后把啟動路徑加到init文件里即可 
      原設置為5秒去檢測一次,是以1字節(jié)去PING

      1. #!/bin/sh
      2. #請把dns1,dns2修改成拼得通的DNS,開機自動運行,實時監(jiān)控,斷線自動重撥
      3. dns1="211.95.193.97"
      4. dns2="211.136.20.203"
      5. sleep 8
      6. #/bin/pppd call gprs-siem &
      7. sleep 12
      8. while true
      9. do
      10.        ping -s 1 -c 1 $dns1 #去PING第一個DNS
      11.        if [ "$?" != "0" ] #假如PING不通
      12.        then

      13.            ping -s 1 -c 2 $dns2 #去PING第二個DNS
      14.            if [ "$?" != "0" ] #假如PING不通
      15.            then
      16.               killall pppd #結束PPPD進程
      17.               pppd call gprs-siem & #再去撥號
      18.               sleep 12 #等待12秒
      19.               sleep 5 #如果是PING DNS2通的話就直接等待5秒
      20.            fi
      21.        else
      22.               sleep 5 #如果是PING DNS1通的話就直接等待5秒(一般要設置多長時間去PING請改這里)
      23.        fi
      24. done

      代碼簡明?。∷喈斢谠诤笈_時時去PING一個DNS發(fā)現(xiàn)真正地掉線,它才會去重新?lián)芴枺?!此版本?jīng)測試通過才發(fā)表。

      1.  
      2. **************************
      3. * *
      4. * The Gemini Project *
      5. * *
      6. **************************
      7. www.! \' v1 Y# R2 P2 h: K
      8. welcome on your dreambox! - Kernel 2.6.9 (08:14:21).

      9. dreambox login: root

      10. BusyBox v1.01 (2007.10.23-19:23+0000) Built-in shell (ash)
      11. Enter 'help' for a list of built-in commands.

      12. root@dreambox:~> /bin/sh /var/etc/ppp/aa
      13. root@dreambox:~> AT 
      14. OK
      15. ATZ
      16. OK
      17. ATH
      18. OK
      19. ATE1
      20. OK
      21. AT+CGDCONT=1,"IP","cmnet"( f$ m0 V3 U' o
      22. OK
      23. ATD*99***1#
      24. CONNECT
      25. Serial connection established.
      26. using channel 2
      27. Using interface ppp0
      28. Connect: ppp0 <--> /dev/tts/0
      29. Warning - secret file /etc/ppp/pap-secrets has world and/or group access
      30. sent [LCP ConfReq id=0x1
      31. ]
      32. rcvd [LCP ConfAck id=0x1
      33. rcvd [LCP ConfReq id=0x3 <asyncmap 0xa0000> <pcomp> <accomp> <magic 0x2ab30537>
      34. <auth chap MD5>]
      35. sent [LCP ConfNak id=0x3 <auth pap>]
      36. rcvd [LCP ConfReq id=0x5 <asyncmap 0xa0000> <pcomp> <accomp>
      37. ]
      38. sent [LCP ConfAck id=0x5
      39. <auth pap>]
      40. Warning - secret file /etc/ppp/pap-secrets has world and/or group access
      41. sent [PAP AuthReq id=0x1 user="beeline" password=<hidden>]
      42. rcvd [PAP AuthAck id=0x1 ""]
      43. PAP authentication succeeded
      44. sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
      45. sent [IPCP ConfReq id=0x1 ]
      46. rcvd [LCP ProtRej id=0x6 80 fd 01 01 00 0f 1a 04 78 00 18 04 78]
      47. sent [IPCP ConfReq id=0x1 ]
      48. sent [IPCP ConfReq id=0x1 ]
      49. PING 211.95.193.97 (211.95.193.97): 1 data bytes
      50. 9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275420253.8 ms

      51. --- 211.95.193.97 ping statistics ---
      52. 1 packets transmitted, 1 packets received, 0% packet loss

      53. round-trip min/avg/max = 275420253.8/275420253.8/275420253.8 ms
      54. sent [IPCP ConfReq id=0x1 ]
      55. sent [IPCP ConfReq id=0x1 ]
      56. PING 211.95.193.97 (211.95.193.97): 1 data bytes
      57. 9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275425386.3 ms

      58. --- 211.95.193.97 ping statistics ---
      59. 1 packets transmitted, 1 packets received, 0% packet loss9
      60. round-trip min/avg/max = 275425386.3/275425386.3/275425386.3 ms
      61. sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
      62. PING 211.95.193.97 (211.95.193.97): 1 data bytes
      63. 9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275430517.7 ms

      64. --- 211.95.193.97 ping statistics ---
      65. 1 packets transmitted, 1 packets received, 0% packet loss
      66. round-trip min/avg/max = 275430517.7/275430517.7/275430517.7 ms
      67. sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
      68. sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
      69. PING 211.95.193.97 (211.95.193.97): 1 data bytes
      70. 9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275435653.2 ms

      71. --- 211.95.193.97 ping statistics ---
      72. 1 packets transmitted, 1 packets received, 0% packet loss
      73. round-trip min/avg/max = 275435653.2/275435653.2/275435653.2 ms
      74. sent [IPCP ConfReq id=0x1 ]
      75. sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
      76. PING 211.95.193.97 (211.95.193.97): 1 data bytes
      77. 9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275440784.9 ms

      78. --- 211.95.193.97 ping statistics ---
      79. 1 packets transmitted, 1 packets received, 0% packet loss
      80. round-trip min/avg/max = 275440784.9/275440784.9/275440784.9 ms
      81. IPCP: timeout sending Config-Requests
      82. sent [LCP TermReq id=0x2 "No network protocols running"]
      83. rcvd [LCP TermAck id=0x2 "No network protocols running"]
      84. Connection terminated.

      85. Sending break to the modem

      86. PDP context detached
      87. Serial link disconnected.
      88. PING 211.95.193.97 (211.95.193.97): 1 data bytes
      89. 9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275445915.2 ms

      90. --- 211.95.193.97 ping statistics ---
      91. 1 packets transmitted, 1 packets received, 0% packet loss
      92. round-trip min/avg/max = 275445915.2/275445915.2/275445915.2 ms
      93. PING 211.95.193.97 (211.95.193.97): 1 data bytes
      94. 9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275451048.9 ms

      95. --- 211.95.193.97 ping statistics ---
      96. 1 packets transmitted, 1 packets received, 0% packet loss
      97. round-trip min/avg/max = 275451048.9/275451048.9/275451048.9 ms
      98. PING 211.95.193.97 (211.95.193.97): 1 data bytes
      99. 9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275456180.4 ms

      100. --- 211.95.193.97 ping statistics ---
      101. 1 packets transmitted, 1 packets received, 0% packet loss
      102. round-trip min/avg/max = 275456180.4/275456180.4/275456180.4 ms
      103. PING 211.95.193.97 (211.95.193.97): 1 data bytes
      104. 9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275461314.4 ms

      105. --- 211.95.193.97 ping statistics ---
      106. 1 packets transmitted, 1 packets received, 0% packet loss
      107. round-trip min/avg/max = 275461314.4/275461314.4/275461314.4 m
      108. PING 211.95.193.97 (211.95.193.97): 1 data bytes
      109. 9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275466446.2 ms
      110. --- 211.95.193.97 ping statistics ---
      111. 1 packets transmitted, 1 packets received, 0% packet loss
      112. round-trip min/avg/max = 275466446.2/275466446.2/275466446.2 ms
      113. PING 211.95.193.97 (211.95.193.97): 1 data bytes
      114. 9 bytes from 211.95.193.97: icmp_seq=0 ttl=244 time=275471577.9 ms

      115. --- 211.95.193.97 ping statistics ---
      116. 1 packets transmitted, 1 packets received, 0% packet loss
      117. round-trip min/avg/max = 275471577.9/275471577.9/275471577.9 ms
      118. PING 211.95.193.97 (211.95.193.97): 1 data bytes

      大家會問這樣一直PING下去擔心流量問題,浪費一些流量是墾定的,
      不過我們是以1個字節(jié)去PING 加上返回的值一共是9個字節(jié),也就是說5秒用9個字節(jié)
      D1 U% ]& i
      一個小時用9*12*60是一個小時6480字節(jié)=6。328125K
      也就是說這樣一個小時加6.33K的流量
      大家還是擔心的話可以改一下腳本,比如改60秒去PING一次啦,等等,都能有效去省流量?。?/p>

      FROM:http://blog.csdn.net/seven407/article/details/4904877

      閱讀(2361) | 評論(0) | 轉發(fā)(0) |
      相關熱門文章

        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多