Mercurial > templog
changeset 339:449272fc63a3
- Debug log file for server
- Fix some variable sizes, turn off local echo for avr code
- symlink config for wrt server
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 15 Jun 2012 23:34:24 +0800 |
parents | 12123e390169 |
children | 3baca8d980f4 |
files | Makefile main.c server/config.py web/config.py web/log.py |
diffstat | 5 files changed, 30 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Thu Jun 14 00:00:57 2012 +0800 +++ b/Makefile Fri Jun 15 23:34:24 2012 +0800 @@ -82,7 +82,6 @@ checkprog: $(AVRDUDE) -v - fuse: $(AVRDUDE) $(FUSES)
--- a/main.c Thu Jun 14 00:00:57 2012 +0800 +++ b/main.c Fri Jun 15 23:34:24 2012 +0800 @@ -29,13 +29,15 @@ // 1 second. we have 1024 prescaler, 32768 crystal. #define SLEEP_COMPARE 32 -#define MEASURE_WAKE 10 +// limited to uint16_t +#define MEASURE_WAKE 300 #define VALUE_NOSENSOR -9000 #define VALUE_BROKEN -8000 -// limited to uint16_t for now +// limited to uint16_t #define COMMS_WAKE 3600 +// limited to uint8_t #define WAKE_SECS 250 // XXX testing #define BAUD 19200 @@ -49,12 +51,16 @@ #define DDR_SHDN DDRD #define PIN_SHDN PD7 +// limited to uint16_t #define NUM_MEASUREMENTS 100 +// limited to uint8_t #define MAX_SENSORS 5 // fixed at 8, have a shorter name #define ID_LEN OW_ROMCODE_SIZE +// #define HAVE_UART_ECHO + int uart_putchar(char c, FILE *stream); static void long_delay(int ms); static void blink(); @@ -87,7 +93,7 @@ static char readbuf[30]; static uint8_t have_cmd; -static uint8_t measure_count; +static uint16_t measure_count; static uint16_t comms_count; static uint32_t clock_epoch; @@ -277,7 +283,7 @@ static void cmd_measure() { - printf_P(PSTR("Measuring\n")); + printf_P(PSTR("measuring\n")); need_measurement = 1; } @@ -480,7 +486,9 @@ ISR(USART_RX_vect) { char c = UDR0; +#ifdef HAVE_UART_ECHO uart_putchar(c, NULL); +#endif if (c == '\r' || c == '\n') { if (readpos > 0)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/config.py Fri Jun 15 23:34:24 2012 +0800 @@ -0,0 +1,1 @@ +../web/config.py \ No newline at end of file
--- a/web/config.py Thu Jun 14 00:00:57 2012 +0800 +++ b/web/config.py Fri Jun 15 23:34:24 2012 +0800 @@ -3,6 +3,8 @@ HMAC_KEY = 'a hmac key' +UPDATE_URL = 'https://evil.ucc.asn.au/~matt/templog/update' + GRAPH_WIDTH = 800 GRAPH_HEIGHT = 400
--- a/web/log.py Thu Jun 14 00:00:57 2012 +0800 +++ b/web/log.py Fri Jun 15 23:34:24 2012 +0800 @@ -73,10 +73,22 @@ rrdfile = sensor_rrd_path(sensor_id) rrdtool.update(rrdfile, *values) + + # be paranois f = file(rrdfile) os.fsync(f.fileno()) +def record_debug(lines): + f = open('%s/debug.log', config.DATA_PATH, 'a+') + f.write('===== %s =====' % time.strftime('%a, %d %b %Y %H:%M:%S') + f.writelines(('%s\n' % s for s in lines)) + f.flush() + return f + def parse(lines): + + debugf = record_debug(lines): + entries = dict(l.split('=', 1) for l in lines) if len(entries) != len(lines): raise Exception("Keys are not unique") @@ -110,3 +122,6 @@ for sensor_id, measurements in zip(sensors, meas): sensor_update(sensor_id, measurements, first_real_time, time_step) + + debugf.write("Updated %d sensors\n" % len(sensors) + debugf.flush()