comparison server/ts.py @ 119:81591bdfa92c

try to flush
author Matt Johnston <matt@ucc.asn.au>
date Sat, 06 Oct 2012 23:58:37 +0800
parents eecd2612a68e
children de950be796dd
comparison
equal deleted inserted replaced
118:bb0c946460f3 119:81591bdfa92c
40 s.settimeout(1) 40 s.settimeout(1)
41 41
42 return s 42 return s
43 43
44 44
45 def flush(sock):
46 while readline(sock):
47 pass
48
45 @retry() 49 @retry()
46 def fetch(sock): 50 def fetch(sock):
51 flush(sock)
47 sock.send("fetch\n") 52 sock.send("fetch\n")
48 53
49 crc = 0 54 crc = 0
50 55
51 lines = [] 56 lines = []
92 @retry() 97 @retry()
93 def turn_off(sock): 98 def turn_off(sock):
94 if TESTING: 99 if TESTING:
95 return 99 100 return 99
96 L("Sending btoff") 101 L("Sending btoff")
102 flush(sock)
97 sock.send("btoff\n"); 103 sock.send("btoff\n");
98 # read newline 104 # read newline
99 l = readline(sock) 105 l = readline(sock)
100 if not l: 106 if not l:
101 W("Bad response to btoff") 107 W("Bad response to btoff")
119 L("next_wake_secs %f\n", next_wake_secs) 125 L("next_wake_secs %f\n", next_wake_secs)
120 return next_wake_secs 126 return next_wake_secs
121 127
122 @retry() 128 @retry()
123 def clear_meas(sock): 129 def clear_meas(sock):
130 flush(sock)
124 sock.send("clear\n"); 131 sock.send("clear\n");
125 l = readline(sock) 132 l = readline(sock)
126 if l and l.rstrip() == 'cleared': 133 if l and l.rstrip() == 'cleared':
127 return True 134 return True
128 135