# HG changeset patch # User ethanzonca@CL-ENS241-08.cedarville.edu # Date 2013-01-18 16:53:44 # Node ID fb9fb20b39dac5ac5b175e34517630e61c4d890e # Parent b3d1f8cb42acdf4c49beacea6465a598f751db3b Fixed issue where timeouts were not functional, number of discovered nodes now displayed on center LEDs. diff --git a/master/master/config.h b/master/master/config.h --- a/master/master/config.h +++ b/master/master/config.h @@ -17,7 +17,7 @@ // Module config (master.c) // -------------------------------------------------------------------------- -#define DEBUG_OUTPUT +//#define DEBUG_OUTPUT #define F_CPU 11059200 #define MODULE_ID '1' diff --git a/master/master/lib/boardtemp.c b/master/master/lib/boardtemp.c --- a/master/master/lib/boardtemp.c +++ b/master/master/lib/boardtemp.c @@ -14,7 +14,7 @@ #include "boardtemp.h" #include "i2c.h" -int8_t boardTemp; // Board Temperature (from i2c) +int8_t boardTemp = 255; // Board Temperature (from i2c) void sensors_readBoardTemp() { diff --git a/master/master/lib/gps.c b/master/master/lib/gps.c --- a/master/master/lib/gps.c +++ b/master/master/lib/gps.c @@ -12,8 +12,6 @@ #include "serial.h" #include "../config.h" #include "led.h" - - // Circular buffer for incoming data uint8_t nmeaBuffer[NMEABUFFER_SIZE]; @@ -23,15 +21,6 @@ uint8_t nmeaBufferParsePosition = 0; // Location of receive byte interrupt in the buffer volatile uint16_t nmeaBufferDataPosition = 0; - - -/* -volatile uint8_t charTest; -ISR(USART1_RX_vect) -{ - serial0_sendChar(UDR1); - -}*/ // holds the byte ALREADY PARSED. includes starting character int bytesReceived = 0; @@ -101,9 +90,6 @@ char variation[9]; //xxx.xb int calculatedChecksum; int receivedChecksum; -char convertBuf1[15]; -char convertBuf2[15]; - // transmission state machine enum decodeState { //shared fields @@ -279,15 +265,6 @@ void parse_gps_transmission(void){ latitude[7] = 0x00; // null terminate - - // First 2 bytes - //convertBuf1[0] = latitude[0]; - //convertBuf1[1] = latitude[1]; - //convertBuf1[2] = '\0'; - //strncpy(convertBuf2, latitude, 7); - //convertBuf2[7] = '\0'; - - setParserState(GGA_LONGITUDE); skipBytes = 0; //prep for next phase of parse numBytes = 0; diff --git a/master/master/lib/led.c b/master/master/lib/led.c --- a/master/master/lib/led.c +++ b/master/master/lib/led.c @@ -36,9 +36,15 @@ void led_off(uint8_t led) *(ledList[led].port) &= ~(1< Error initializing.\r\n"); + #endif + led_errorcode(ERROR_SD_INIT); return; } @@ -52,7 +55,10 @@ void logger_setup() // Check that partition was created correctly if(!partition) { + #ifdef DEBUG_OUTPUT serial0_sendString("SD> Error opening partition.\r\n"); + #endif + // Error opening partition. MBR might be screwed up. led_errorcode(ERROR_SD_PARTITION); return; diff --git a/master/master/lib/slavesensors.c b/master/master/lib/slavesensors.c --- a/master/master/lib/slavesensors.c +++ b/master/master/lib/slavesensors.c @@ -17,6 +17,7 @@ #include "serparser.h" #include "slavesensors.h" #include "led.h" +#include "looptime.h" #include #include @@ -74,13 +75,16 @@ void slavesensors_network_scan() { int atOK; + #ifdef DEBUG_OUTPUT serial0_sendString("Beginning network scan...\r\n\r\n"); + #endif _delay_ms(500); // xbee warmup wdt_reset(); + led_on(LED_ACTIVITY); atOK = slavesensors_enterAT(); - + char nameString[20] = "NONE"; char slaveNames[6][16]; // Hold 16-char addresses of max 6 nodes, we only need them for debug so they are local @@ -91,6 +95,7 @@ void slavesensors_network_scan() { //todo if(atOK == 0) { + led_on(LED_STATUS); serial0_sendString("ATND"); serial0_sendChar(0x0D); @@ -103,13 +108,12 @@ void slavesensors_network_scan() { } wdt_reset(); } - // Scan data end when newline by itself ("") int lineCount = 0; while(1) { bufPtr = serial0_readLine(); - + // If we're starting a new block but got a newline instead, we're done! if(lineCount == 0 && strcmp(bufPtr, "") == 0) { break; @@ -142,11 +146,26 @@ void slavesensors_network_scan() { } + // Display number of found nodes on spinning indicator + switch(nodeCount) { + case 0: + break; + case 3: + led_on(LED_ACT2); + _delay_ms(100); + case 2: + led_on(LED_ACT1); + _delay_ms(100); + case 1: + led_on(LED_ACT0); + _delay_ms(100); + } + led_on(LED_SIDEBOARD); _delay_ms(200); led_off(LED_SIDEBOARD); - #ifdef DEBUG_NETWORKSCAN + #ifdef DEBUG_OUTPUT serial0_sendString("Discovered: \r\n"); for(int i=0; i - // 9 data lines per node, terminated, followed by a new line with only at the end of all nodes. - - // followed by another signifies end of scan data - for(int i=0; i LEDCYCLE_RATE) { - spin(); + led_spin(); if(!afsk_busy()) serial1_ion();