# HG changeset patch # User Matt Johnston # Date 1339808927 -28800 # Node ID a3473b5ea50e5bedcfad59f14b43363e36ef7d9e # Parent aa247177837ac600c000cf7795325fa63e1a0125# Parent ea1779d276416be71e75dc6e09b292c4e38ce1ee merge diff -r ea1779d27641 -r a3473b5ea50e main.c --- a/main.c Sat Jun 16 09:08:07 2012 +0800 +++ b/main.c Sat Jun 16 09:08:47 2012 +0800 @@ -30,7 +30,7 @@ // 1 second. we have 1024 prescaler, 32768 crystal. #define SLEEP_COMPARE 32 // limited to uint16_t -#define MEASURE_WAKE 300 +#define MEASURE_WAKE 20 #define VALUE_NOSENSOR -9000 #define VALUE_BROKEN -8000 @@ -234,11 +234,11 @@ fprintf_P(crc_stdout, PSTR("START\n")); fprintf_P(crc_stdout, PSTR("now=%lu\n" - "time_step=%lu\n" + "time_step=%hu\n" "first_time=%lu\n" "last_time=%lu\n"), clock_epoch, - MEASURE_WAKE, + (uint16_t)MEASURE_WAKE, first_measurement_clock, last_measurement_clock); fprintf_P(crc_stdout, PSTR("sensors=%u\n"), n_sensors); @@ -250,13 +250,13 @@ printhex(id, ID_LEN, crc_stdout); fputc('\n', crc_stdout); } - fprintf_P(crc_stdout, PSTR("measurements=%u\n"), n_measurements); + fprintf_P(crc_stdout, PSTR("measurements=%hu\n"), n_measurements); for (uint16_t n = 0; n < n_measurements; n++) { fprintf_P(crc_stdout, PSTR("meas%u="), n); for (uint8_t s = 0; s < n_sensors; s++) { - fprintf_P(crc_stdout, PSTR(" %u"), measurements[n][s]); + fprintf_P(crc_stdout, PSTR(" %hu"), measurements[n][s]); } fputc('\n', crc_stdout); } @@ -519,7 +519,8 @@ if (comms_timeout != 0) { - comms_timeout--; + // XXX testing + //comms_timeout--; } if (measure_count >= MEASURE_WAKE) @@ -750,6 +751,7 @@ sei(); need_comms = 1; + need_measurement = 1; #if 0 for (;;) diff -r ea1779d27641 -r a3473b5ea50e server/ts.py --- a/server/ts.py Sat Jun 16 09:08:07 2012 +0800 +++ b/server/ts.py Sat Jun 16 09:08:47 2012 +0800 @@ -19,6 +19,8 @@ import binascii import hmac import zlib +import urllib +import urllib2 import config @@ -57,7 +59,6 @@ print>>sys.stderr, "Bad expected START line '%s'\n" % l.rstrip('\n') return None crc = crc16(l, crc) - lines.append(l) while True: l = readline(sock) @@ -122,9 +123,9 @@ def send_results(lines): enc_lines = binascii.b2a_base64(zlib.compress('\n'.join(lines))) - hmac.new(config.HMAC_KEY, enc_lines).hexdigest() + mac = hmac.new(config.HMAC_KEY, enc_lines).hexdigest() - url_data = urllib.url_encode( ('lines', enc_lines), ('hmac', mac) ) + url_data = urllib.urlencode( {'lines': enc_lines, 'hmac': mac} ) con = urllib2.urlopen(config.UPDATE_URL, url_data) result = con.read(100) if result == 'OK':