diff --git a/master/master/config.h b/master/master/config.h --- a/master/master/config.h +++ b/master/master/config.h @@ -43,20 +43,8 @@ // Slave Sensors config (slavesensors.c) // -------------------------------------------------------------------------- -// NOT USED. Could integrate into slavesensors.c setup function for configurability eventually. -// Currently manual configuration of sensors is done in slavesensors.c -#define SLAVE0_SENSORS BOARDTEMP -#define SLAVE1_SENSORS BOARDTEMP | HUMIDITY | TEMPERATURE | PRESSURE | AMBIENTLIGHT -#define SLAVE2_SENSORS BOARDTEMP | GEIGER -#define SLAVE3_SENSORS BOARDTEMP | CAMERA -#define SLAVE4_SENSORS NONE -#define SLAVE5_SENSORS NONE -#define SLAVE6_SENSORS NONE -#define SLAVE7_SENSORS NONE - -// MAX_SLAVES should be one more than the number of slaves we actually have (loop ends when next slave first sensor is NONE) -#define MAX_SLAVES 8 -#define MAX_SLAVE_SENSORS 8 +#define MAX_NUM_SLAVES 5 // Maximum number of nodes in the system +#define MAX_NUM_SENSORS 20 // Maximum number of unique types of sensors in the system // Node identifier of log destination xbee #define XBEE_LOGDEST_NAME "HAB-LOGGER" 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 @@ -120,15 +120,10 @@ enum decodeState { }decodeState; -char debugBuff[128]; - ISR(USART1_RX_vect) { nmeaBuffer[nmeaBufferDataPosition % NMEABUFFER_SIZE] = UDR1; nmeaBufferDataPosition = (nmeaBufferDataPosition + 1) % NMEABUFFER_SIZE; - //serial0_sendChar(UDR1); - //snprintf(debugBuff, 32, "GPS: bdp: %d, bpp: %d decodestate: %u \r\n", nmeaBufferDataPosition, nmeaBufferParsePosition, decodeState); - //serial0_sendString((debugBuff)); } @@ -163,9 +158,6 @@ void parse_gps_transmission(void){ byte = nmeaBuffer[nmeaBufferParsePosition]; - //snprintf(debugBuff, 64, "GPSParse: byte [%c] decodestate: %u bp: %u pp: %u\r\n", byte, decodeState, nmeaBufferDataPosition, nmeaBufferParsePosition); - //serial0_sendString((debugBuff)); - if(decodeState == INITIALIZE) //start of transmission sentence { if(byte == '$') { @@ -642,9 +634,8 @@ void parse_gps_transmission(void){ } #ifdef DEBUG_NMEA serial0_sendString("OMG GOT TO CHECKSUM!\r\n"); - #endif + #endif - serial0_sendString((debugBuff)); setParserState(INITIALIZE); numBytes = 0; //prep for next phase of parse } diff --git a/master/master/lib/sensordata.c b/master/master/lib/sensordata.c --- a/master/master/lib/sensordata.c +++ b/master/master/lib/sensordata.c @@ -13,33 +13,31 @@ #include "../config.h" #include "sensordata.h" -int16_t boardTemps[MAX_SLAVES]; -uint16_t variousSensors[MAX_SLAVES * (MAX_SLAVE_SENSORS - 1)]; +int16_t slaves[MAX_NUM_SLAVES][MAX_NUM_SENSORS]; void sensordata_setup() { - for(int i=0; i= nodeCount && currentSlaveSensor >= numValues) - { + + // Special case for slave telling us how many things we're about to get + if(type + 0x30 == '@') { + serial0_sendString("Got an awesome count!\r\n"); + serial0_sendChar(parsedVal + 0x30); + serial0_sendString("\r\n"); + numReadingsToExpect = parsedVal; currentSlave = 0; currentSlaveSensor = 0; - requesting = false; + requesting = true; } - // If we finished up one slave, go to the next - else if(currentSlaveSensor >= numValues) - { - currentSlave++; - currentSlaveSensor = 0; - requesting = true; - slavesensors_request(); - } - // If we haven't finished a slave (or all of them), just get the next sensor of the current slave - else - { - // request data for the current sensor of the current slave - currentSlaveSensor++; - requesting = true; - slavesensors_request(); + else { + + // Store data in structure + sensordata_set(currentSlave,type,parsedVal); + serial0_sendString("Stored some sexy data!\r\n"); + + // If we finished all sensors for all slaves + if(currentSlave >= nodeCount && currentSlaveSensor >= numReadingsToExpect) + { + currentSlave = 0; + currentSlaveSensor = 0; + requesting = false; + } + // If we finished up one slave, go to the next + else if(currentSlaveSensor >= (numReadingsToExpect-1)) + { + currentSlave++; + currentSlaveSensor = 0; + requesting = true; + slavesensors_request(); + } + // If we haven't finished a slave (or all of them), just get the next sensor of the current slave + else + { + // request data for the current sensor of the current slave + currentSlaveSensor++; + requesting = true; + //slavesensors_request(); slaves now send all values at once, we don't need to keep requesting + } } }