Mercurial > templog
annotate server/ts.py @ 160:256505f98c4d
uploader works
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 03 Jan 2013 22:37:33 +0800 |
parents | 94330d90f11f |
children |
rev | line source |
---|---|
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1 #!/usr/bin/env python2.7 |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2 |
23
b5925cb4f264
Fix bugs in server code (try actually running it)
Matt Johnston <matt@ucc.asn.au>
parents:
22
diff
changeset
|
3 # time that the bluetooth takes to get going? |
96 | 4 EXTRA_WAKEUP = -3 |
23
b5925cb4f264
Fix bugs in server code (try actually running it)
Matt Johnston <matt@ucc.asn.au>
parents:
22
diff
changeset
|
5 |
24
44c5ab5ea879
- some fixes for server code
Matt Johnston <matt@ucc.asn.au>
parents:
23
diff
changeset
|
6 FETCH_TRIES = 3 |
44c5ab5ea879
- some fixes for server code
Matt Johnston <matt@ucc.asn.au>
parents:
23
diff
changeset
|
7 |
23
b5925cb4f264
Fix bugs in server code (try actually running it)
Matt Johnston <matt@ucc.asn.au>
parents:
22
diff
changeset
|
8 # avoid turning off the bluetooth etc. |
42 | 9 TESTING = False |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
10 |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
11 import sys |
27
dbbd503119ba
Add some web server handling
Matt Johnston <matt@ucc.asn.au>
parents:
26
diff
changeset
|
12 # for wrt |
dbbd503119ba
Add some web server handling
Matt Johnston <matt@ucc.asn.au>
parents:
26
diff
changeset
|
13 sys.path.append('/root/python') |
dbbd503119ba
Add some web server handling
Matt Johnston <matt@ucc.asn.au>
parents:
26
diff
changeset
|
14 import httplib |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
15 import time |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
16 import traceback |
28 | 17 import binascii |
18 import hmac | |
34 | 19 import zlib |
35 | 20 import urllib |
21 import urllib2 | |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
22 import logging |
139 | 23 import socket |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
24 |
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
25 L = logging.info |
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
26 W = logging.warning |
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
27 E = logging.error |
28 | 28 |
29 import config | |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
30 |
26
d3e5934fe55c
- Move crc16 to utils and fix it
Matt Johnston <matt@ucc.asn.au>
parents:
25
diff
changeset
|
31 from utils import monotonic_time, retry, readline, crc16 |
66 | 32 import utils |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
33 |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
34 import bluetooth |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
35 |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
36 def get_socket(addr): |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
37 s = bluetooth.BluetoothSocket( bluetooth.RFCOMM ) |
96 | 38 L("connecting") |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
39 s.connect((addr, 1)) |
91 | 40 s.setblocking(False) |
96 | 41 s.settimeout(1) |
91 | 42 |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
43 return s |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
44 |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
45 |
119 | 46 def flush(sock): |
129 | 47 ret = [] |
48 while True: | |
49 l = readline(sock) | |
50 if l: | |
51 ret.append(l) | |
52 else: | |
53 break | |
54 return ret | |
55 | |
56 def encode_extra(extra_lines): | |
57 return ['extra%d=%s' % (n, l.strip()) for (n,l) in enumerate(extra_lines)] | |
119 | 58 |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
59 @retry() |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
60 def fetch(sock): |
129 | 61 extra_lines = flush(sock) |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
62 sock.send("fetch\n") |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
63 |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
64 crc = 0 |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
65 |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
66 lines = [] |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
67 l = readline(sock) |
129 | 68 if not l: |
69 return None | |
70 | |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
71 if l != 'START\n': |
129 | 72 W("Bad expected START line '%s'\n" % l.rstrip('\n')) |
73 extra_lines.append(l) | |
74 return encode_extra(extra_lines) | |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
75 crc = crc16(l, crc) |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
76 |
24
44c5ab5ea879
- some fixes for server code
Matt Johnston <matt@ucc.asn.au>
parents:
23
diff
changeset
|
77 while True: |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
78 l = readline(sock) |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
79 |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
80 crc = crc16(l, crc) |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
81 |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
82 if l == 'END\n': |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
83 break |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
84 |
27
dbbd503119ba
Add some web server handling
Matt Johnston <matt@ucc.asn.au>
parents:
26
diff
changeset
|
85 lines.append(l.rstrip('\n')) |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
86 |
129 | 87 lines += encode_extra(extra_lines) |
88 | |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
89 for d in lines: |
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
90 L("Received: %s" % d) |
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
91 |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
92 l = readline(sock) |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
93 recv_crc = None |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
94 try: |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
95 k, v = l.rstrip('\n').split('=') |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
96 if k == 'CRC': |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
97 recv_crc = int(v) |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
98 if recv_crc < 0 or recv_crc > 0xffff: |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
99 recv_crc = None |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
100 except ValueError: |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
101 pass |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
102 |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
103 if recv_crc is None: |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
104 W("Bad expected CRC line '%s'\n" % l.rstrip('\n')) |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
105 return None |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
106 |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
107 if recv_crc != crc: |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
108 W("Bad CRC: calculated 0x%x vs received 0x%x\n" % (crc, recv_crc)) |
21
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
109 return None |
2029633912c2
untested simple server proxy code
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
110 |
27
dbbd503119ba
Add some web server handling
Matt Johnston <matt@ucc.asn.au>
parents:
26
diff
changeset
|
111 return lines |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
112 |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
113 @retry() |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
114 def turn_off(sock): |
23
b5925cb4f264
Fix bugs in server code (try actually running it)
Matt Johnston <matt@ucc.asn.au>
parents:
22
diff
changeset
|
115 if TESTING: |
42 | 116 return 99 |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
117 L("Sending btoff") |
119 | 118 flush(sock) |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
119 sock.send("btoff\n"); |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
120 # read newline |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
121 l = readline(sock) |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
122 if not l: |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
123 W("Bad response to btoff") |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
124 return None |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
125 |
91 | 126 if not l.startswith('next_wake'): |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
127 W("Bad response to btoff '%s'" % l) |
42 | 128 return None |
91 | 129 L("Next wake line %s" % l) |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
130 |
91 | 131 toks = dict(v.split('=') for v in l.split(',')) |
132 | |
92 | 133 rem = int(toks['rem']) |
134 tick_secs = int(toks['tick_secs']) | |
99
1a88bb989afb
fix off-by-one in remainder code
Matt Johnston <matt@ucc.asn.au>
parents:
94
diff
changeset
|
135 tick_wake = int(toks['tick_wake']) + 1 |
92 | 136 next_wake = int(toks['next_wake']) |
137 | |
138 rem_secs = float(rem) / tick_wake * tick_secs | |
139 | |
140 next_wake_secs = next_wake - rem_secs | |
141 L("next_wake_secs %f\n", next_wake_secs) | |
142 return next_wake_secs | |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
143 |
32 | 144 @retry() |
145 def clear_meas(sock): | |
119 | 146 flush(sock) |
32 | 147 sock.send("clear\n"); |
148 l = readline(sock) | |
149 if l and l.rstrip() == 'cleared': | |
150 return True | |
151 | |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
152 E("Bad response to clear '%s'" % str(l)) |
32 | 153 return False |
154 | |
28 | 155 def send_results(lines): |
29 | 156 enc_lines = binascii.b2a_base64(zlib.compress('\n'.join(lines))) |
35 | 157 mac = hmac.new(config.HMAC_KEY, enc_lines).hexdigest() |
28 | 158 |
35 | 159 url_data = urllib.urlencode( {'lines': enc_lines, 'hmac': mac} ) |
28 | 160 con = urllib2.urlopen(config.UPDATE_URL, url_data) |
32 | 161 result = con.read(100) |
162 if result == 'OK': | |
163 return True | |
164 else: | |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
165 W("Bad result '%s'" % result) |
32 | 166 return False |
28 | 167 |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
168 def do_comms(sock): |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
169 L("do_comms") |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
170 d = None |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
171 # serial could be unreliable, try a few times |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
172 d = fetch(sock) |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
173 if not d: |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
174 return |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
175 |
27
dbbd503119ba
Add some web server handling
Matt Johnston <matt@ucc.asn.au>
parents:
26
diff
changeset
|
176 res = send_results(d) |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
177 if not res: |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
178 return |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
179 |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
180 clear_meas(sock) |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
181 |
117 | 182 next_wake = 600 |
183 #next_wake = turn_off(sock) | |
139 | 184 #sock.close() |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
185 return next_wake |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
186 |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
187 testcount = 0 |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
188 |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
189 def sleep_for(secs): |
23
b5925cb4f264
Fix bugs in server code (try actually running it)
Matt Johnston <matt@ucc.asn.au>
parents:
22
diff
changeset
|
190 until = monotonic_time() + secs |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
191 while True: |
24
44c5ab5ea879
- some fixes for server code
Matt Johnston <matt@ucc.asn.au>
parents:
23
diff
changeset
|
192 length = until - monotonic_time() |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
193 if length <= 0: |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
194 return |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
195 time.sleep(length) |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
196 |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
197 def setup_logging(): |
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
198 logging.basicConfig(format='%(asctime)s %(message)s', |
91 | 199 datefmt='%m/%d/%Y %I:%M:%S %p', |
200 level=logging.INFO) | |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
201 |
139 | 202 def get_net_socket(host, port): |
203 s = socket.create_connection((host, port)) | |
204 s.setblocking(False) | |
205 s.settimeout(1) | |
206 return s | |
207 | |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
208 def main(): |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
209 setup_logging() |
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
210 |
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
211 L("Running templog rfcomm server") |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
212 |
65 | 213 if '--daemon' in sys.argv: |
214 utils.cheap_daemon() | |
215 | |
96 | 216 next_wake_time = 0 |
139 | 217 |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
218 while True: |
23
b5925cb4f264
Fix bugs in server code (try actually running it)
Matt Johnston <matt@ucc.asn.au>
parents:
22
diff
changeset
|
219 sock = None |
b5925cb4f264
Fix bugs in server code (try actually running it)
Matt Johnston <matt@ucc.asn.au>
parents:
22
diff
changeset
|
220 try: |
139 | 221 sock = get_net_socket(config.SERIAL_HOST, config.SERIAL_PORT) |
23
b5925cb4f264
Fix bugs in server code (try actually running it)
Matt Johnston <matt@ucc.asn.au>
parents:
22
diff
changeset
|
222 except Exception, e: |
94 | 223 #logging.exception("Error connecting") |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
224 pass |
139 | 225 |
226 if not sock: | |
227 sleep_for(config.SLEEP_TIME) | |
228 continue | |
229 | |
230 while True: | |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
231 try: |
139 | 232 do_comms(sock) |
233 sleep_for(config.SLEEP_TIME) | |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
234 except Exception, e: |
89
51d889ad39a3
main.c : add a delay before turning on uart
Matt Johnston <matt@ucc.asn.au>
parents:
82
diff
changeset
|
235 logging.exception("Error in do_comms") |
139 | 236 break |
22
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
237 |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
238 if __name__ == '__main__': |
885532437100
A bit of work on the server python
Matt Johnston <matt@ucc.asn.au>
parents:
21
diff
changeset
|
239 main() |