Mercurial > templog
comparison server/ts.py @ 40:9b5b202129c3
main.c:
- get rid of some debugging
- separate uart_enabled flag
ts.py:
- remember next wake time, not the interval
log.py:
- comments for sqlite
templog.py
- use cgi
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 23 Jun 2012 22:10:23 +0800 |
parents | 4bfa9b7b2e4b |
children | 26c8ab2ba3f1 |
comparison
equal
deleted
inserted
replaced
39:9a3b967a920c | 40:9b5b202129c3 |
---|---|
165 if length <= 0: | 165 if length <= 0: |
166 return | 166 return |
167 time.sleep(length) | 167 time.sleep(length) |
168 | 168 |
169 def main(): | 169 def main(): |
170 next_wake_time = 0 | |
170 | 171 |
171 while True: | 172 while True: |
172 sock = None | 173 sock = None |
173 try: | 174 try: |
174 sock = get_socket(BTADDR) | 175 sock = get_socket(BTADDR) |
177 traceback.print_exc(file=sys.stderr) | 178 traceback.print_exc(file=sys.stderr) |
178 sleep_time = SLEEP_TIME | 179 sleep_time = SLEEP_TIME |
179 if sock: | 180 if sock: |
180 next_wake = None | 181 next_wake = None |
181 try: | 182 try: |
182 next_wake = do_comms(sock) | 183 next_wake_interval = do_comms(sock) |
184 next_wake_time = time.now() + next_wake_interval | |
183 except Exception, e: | 185 except Exception, e: |
184 print>>sys.stderr, "Error in do_comms:" | 186 print>>sys.stderr, "Error in do_comms:" |
185 traceback.print_exc(file=sys.stderr) | 187 traceback.print_exc(file=sys.stderr) |
186 if next_wake: | 188 if next_wake_time > time.now(): |
187 sleep_time = min(next_wake+EXTRA_WAKEUP, sleep_time) | 189 sleep_time = min(next_wake_time - time.now() - EXTRA_WAKEUP, sleep_time) |
188 | 190 |
189 if TESTING: | 191 if TESTING: |
190 print "Sleeping for %d" % sleep_time | 192 print "Sleeping for %d" % sleep_time |
191 sleep_for(sleep_time) | 193 sleep_for(sleep_time) |
192 | 194 |