comparison main.c @ 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 a670a67ba489
comparison
equal deleted inserted replaced
338:12123e390169 339:449272fc63a3
27 // - bluetooth params 27 // - bluetooth params
28 // - number of sensors (and range?) 28 // - number of sensors (and range?)
29 29
30 // 1 second. we have 1024 prescaler, 32768 crystal. 30 // 1 second. we have 1024 prescaler, 32768 crystal.
31 #define SLEEP_COMPARE 32 31 #define SLEEP_COMPARE 32
32 #define MEASURE_WAKE 10 32 // limited to uint16_t
33 #define MEASURE_WAKE 300
33 34
34 #define VALUE_NOSENSOR -9000 35 #define VALUE_NOSENSOR -9000
35 #define VALUE_BROKEN -8000 36 #define VALUE_BROKEN -8000
36 37
37 // limited to uint16_t for now 38 // limited to uint16_t
38 #define COMMS_WAKE 3600 39 #define COMMS_WAKE 3600
40 // limited to uint8_t
39 #define WAKE_SECS 250 // XXX testing 41 #define WAKE_SECS 250 // XXX testing
40 42
41 #define BAUD 19200 43 #define BAUD 19200
42 #define UBRR ((F_CPU)/8/(BAUD)-1) 44 #define UBRR ((F_CPU)/8/(BAUD)-1)
43 45
47 49
48 #define PORT_SHDN PORTD 50 #define PORT_SHDN PORTD
49 #define DDR_SHDN DDRD 51 #define DDR_SHDN DDRD
50 #define PIN_SHDN PD7 52 #define PIN_SHDN PD7
51 53
54 // limited to uint16_t
52 #define NUM_MEASUREMENTS 100 55 #define NUM_MEASUREMENTS 100
56 // limited to uint8_t
53 #define MAX_SENSORS 5 57 #define MAX_SENSORS 5
54 58
55 // fixed at 8, have a shorter name 59 // fixed at 8, have a shorter name
56 #define ID_LEN OW_ROMCODE_SIZE 60 #define ID_LEN OW_ROMCODE_SIZE
61
62 // #define HAVE_UART_ECHO
57 63
58 int uart_putchar(char c, FILE *stream); 64 int uart_putchar(char c, FILE *stream);
59 static void long_delay(int ms); 65 static void long_delay(int ms);
60 static void blink(); 66 static void blink();
61 67
85 91
86 static uint8_t readpos; 92 static uint8_t readpos;
87 static char readbuf[30]; 93 static char readbuf[30];
88 static uint8_t have_cmd; 94 static uint8_t have_cmd;
89 95
90 static uint8_t measure_count; 96 static uint16_t measure_count;
91 static uint16_t comms_count; 97 static uint16_t comms_count;
92 98
93 static uint32_t clock_epoch; 99 static uint32_t clock_epoch;
94 100
95 // thanks to http://projectgus.com/2010/07/eeprom-access-with-arduino/ 101 // thanks to http://projectgus.com/2010/07/eeprom-access-with-arduino/
275 } 281 }
276 282
277 static void 283 static void
278 cmd_measure() 284 cmd_measure()
279 { 285 {
280 printf_P(PSTR("Measuring\n")); 286 printf_P(PSTR("measuring\n"));
281 need_measurement = 1; 287 need_measurement = 1;
282 } 288 }
283 289
284 static void 290 static void
285 cmd_sensors() 291 cmd_sensors()
478 484
479 485
480 ISR(USART_RX_vect) 486 ISR(USART_RX_vect)
481 { 487 {
482 char c = UDR0; 488 char c = UDR0;
489 #ifdef HAVE_UART_ECHO
483 uart_putchar(c, NULL); 490 uart_putchar(c, NULL);
491 #endif
484 if (c == '\r' || c == '\n') 492 if (c == '\r' || c == '\n')
485 { 493 {
486 if (readpos > 0) 494 if (readpos > 0)
487 { 495 {
488 readbuf[readpos] = '\0'; 496 readbuf[readpos] = '\0';