test: make it obvious which branch we're testing
[barry.git] / contrib / modemtest.rb
blob6ce742bd59c8da4ed3fc4c158c826376bbb4a6b5
1 #!/usr/bin/env ruby
4 #    Copyright (C) 2008, Andy Herkey <a.herkey@comcast.net>
6 #    This program is free software; you can redistribute it and/or modify
7 #    it under the terms of the GNU General Public License as published by
8 #    the Free Software Foundation; either version 2 of the License, or
9 #    (at your option) any later version.
11 #    This program is distributed in the hope that it will be useful,
12 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 #    See the GNU General Public License in the COPYING file at the
16 #    root directory of this project for more details.
21 # The purpose of this script is to try a large batch of known AT
22 # commands, and report which ones work with your Blackberry
23 # modem / provider.  There will be output written to stdout
24 # as well as a file created in /tmp/modemtest.log which holds
25 # the raw pppob traffic log.
28 #Change the $PPP variable to point to where pppob is installed.
29 $PPP="/usr/local/sbin/pppob -vP xxxxx -l /tmp/modemtest.log"
31 class IPmodem
33    def initialize
34       @connecting = true
35       @connectionHandle = IO.popen( $PPP,"w+" )
36       sleep 2
37       authAtempts = 0
38       timeout = 0
39    end
41    def write( data )
42       @connectionHandle.write( data )
43    end
45    def read()
46       timeout = 0
47       return nil if @connectionHandle.closed?
48          @ioBuffer = ""
49          while input = IO.select([@connectionHandle],nil,nil,1)
50             c = @connectionHandle.getc
51             @ioBuffer <<  c if c != nil
52             return if ! @connecting
53             if c == nil
54                timeout+=1
55                break if timeout >= 9000
56             else
57                timeout = 0
58             end
59          end
60       return @ioBuffer
61    end
62 end
65 # Note: AT+CLAC should list all available commands
67 commands = [
68         "+++AT",
69         "AT",
70         "AT&F",
71         "ATZ",
72         "ATS0=0",
73         "ATE0",
74         "ATE0V1",
75         "ATE0V1Q0X4",
76         "AT+CRC=1",
77         "AT+SPSERVICE",
78         "AT+SPSERVICE",
79         "AT$QCMIPP?",
80         "AT$QCMIPP=?",
81         "AT+CSQ",
82         "AT+CSQ?",
83         "AT+CSQ=?",
84         "AT+CSS",
85         "AT+CSS?",
86         "AT+CSS=?",
87         "ATI1",
88         "ATI2",
89         "ATI3",
90         "AT+CAD?",
91         "AT+CIMI",
92         "AT+CGMI",
93         "AT+CGMR",
94         "AT+CGDCONT?",
95         "AT+GMI",
96         "AT+GMM",
97         "AT+GMR",
98         "AT+GSN",
99         "AT+CBC",
100         "AT+CBIP",
101         "AT+CCED?",
102         "AT+ESR",
103         "AT+CIND=?",
104         "AT+FCLASS=?",
105         "AT+GCAP=?",
106         "AT$SPMDN?",
107         "AT$QCMIPGETP=1",
108         "AT&V",
109         "ATH"
112 modem = IPmodem.new
113 puts("Testing the Blackberry Modem by sending AT commands through pppob.")
114 printf("Starting %s: %s",$PPP,modem.read())
115 puts("--------------------------------------------")
117 commands.each {|c|
118          modem.write(c+"\r")
119          printf("Command: %s \nResult: %s",c,modem.read())
120          puts("--------------------------------------------")
122          }