Changeset - 903c905fbe0b
[Not reviewed]
default
0 3 0
ethanzonca@CL-ENS241-08.cedarville.edu - 12 years ago 2013-03-18 18:17:47
ethanzonca@CL-ENS241-08.cedarville.edu
Watchdog fix, interleaved APRS messaging tweaks
3 files changed with 24 insertions and 17 deletions:
0 comments (0 inline, 0 general)
master/master/lib/sensordata.c
Show inline comments
 
@@ -58,17 +58,21 @@ int32_t sensordata_get(uint8_t nodeID, u
 
	}
 
}
 
 
bool isEven = false;
 
bool isEven = true;
 
 
// Generate APRS comment
 
// TODO: Can we move this buffer to a local scope of this function?
 
 
char* slavesensors_getAPRScomment(char* commentBuffer, uint16_t bufferSize) 
 
{
 
	snprintf(commentBuffer,bufferSize, "t9%d~s%s~v%s~h%s~_%s~|%s", sensors_getBoardTemp(), get_sv(), get_speedKnots(), get_hdop(), get_latitudeLSBs(), get_longitudeLSBs());
 
	snprintf(commentBuffer,bufferSize, "~v%s~_%s~|%s", get_speedKnots(), get_latitudeLSBs(), get_longitudeLSBs());
 
	
 
	if(isEven) 
 
	{
 
		// Master details
 
		uint16_t len = strlen(commentBuffer);
 
		snprintf(commentBuffer + len, bufferSize-len, "~t9%d~s%s~h%s", sensors_getBoardTemp(), get_sv(), get_hdop());
 
		
 
		// Find slave sensors to include in this log
 
		for(int i=0; i<MAX_NUM_SLAVES; i++)
 
		{
 
@@ -115,6 +119,14 @@ char* slavesensors_getAPRScomment(char* 
 
			}
 
		
 
		}
 
		
 
		if(logger_aprsInfoTextAvailable())
 
		{
 
			uint16_t len = strlen(commentBuffer);
 
			snprintf(commentBuffer + len, bufferSize-len, "~%s",logger_getAprsInfoText());
 
			logger_aprsInfoTextConsumed();
 
		}
 
		
 
		isEven = false;
 
	}
 
	else {
 
@@ -122,12 +134,7 @@ char* slavesensors_getAPRScomment(char* 
 
		isEven = true;
 
	}	
 
	
 
	if(logger_aprsInfoTextAvailable())
 
	{
 
		uint16_t len = strlen(commentBuffer);
 
		snprintf(commentBuffer + len, bufferSize-len, "~%s",logger_getAprsInfoText());
 
		logger_aprsInfoTextConsumed();
 
	}
 
 
	
 
	
 
	return commentBuffer;
master/master/lib/slavesensors.c
Show inline comments
 
@@ -496,13 +496,15 @@ void slavesensors_process(uint8_t parseR
 
	else if(parseResult == PARSERESULT_NODATA) 
 
	{
 
		// Wait for data
 
		if(requesting && time_millis() - beginRequest > TIMEOUT_SLAVEREQUEST) {
 
		if(requesting && ( (time_millis() - beginRequest) > TIMEOUT_SLAVEREQUEST)) {
 
			// if we're requesting, we have no data, and we're over the timeout, this is bad!
 
			// setParserState(STATE_RESET); - meh, can't do this because it freaking increments the cirbufptr
 
			gotoNextSlaveOrSensor(true);
 

	
 
			char msg[128];
 
			snprintf(msg, 128, "Slave %u (%s) timeout",currentSlave,slaveNames[currentSlave]);
 
			error_log_msg(ERROR_SLAVETIMEOUT, false, msg); // log error, don't blink LED
 
			
 
			gotoNextSlaveOrSensor(true);
 
		}
 
	}
 
	
master/master/master.c
Show inline comments
 
@@ -38,12 +38,13 @@
 

	
 
int main(void)
 
{
 
	// Initialize libraries
 
	time_setup();
 
	watchdog_setup(); // enables interrupts
 
	
 
	// Power debounce
 
	_delay_ms(1000);
 
	
 
	// Initialize libraries
 
	time_setup();
 
	watchdog_setup(); // enables interrupts
 
	led_setup();
 
	gps_setup();
 
	serial0_setup();
 
@@ -70,9 +71,6 @@ int main(void)
 
	// Result of last parser run
 
	int parseResult = PARSERESULT_NODATA;
 
	
 
	// FIXME: Probably don't need this.
 
	serial1_ioff();
 
	
 
	while(1)
 
    {
 
		// Periodic: LED execution indicator
 
@@ -136,7 +134,7 @@ int main(void)
 
			// Start getting values for next transmission
 
			if(slavesensors_isrequesting())
 
			{
 
				// TODO: something is terribly wrong. Timeout?
 
				error_log_msg(ERROR_FATAL, false, "Still requesting on following loop");
 
			}
 
			else
 
			{
0 comments (0 inline, 0 general)