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
 
@@ -55,23 +55,27 @@ int32_t sensordata_get(uint8_t nodeID, u
 
	else 
 
	{
 
		return 0;
 
	}
 
}
 
 
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++)
 
		{
 
			// Board temperature sensors (all slaves)
 
			uint32_t val = sensordata_get(i, SENSOR_BOARDTEMP);
 
			if(val != -2111111111) {
 
@@ -112,25 +116,28 @@ char* slavesensors_getAPRScomment(char* 
 
			if(val != -2111111111) {
 
				uint16_t len = strlen(commentBuffer);
 
				snprintf(commentBuffer + len, bufferSize-len, "~R%li",val);
 
			}
 
		
 
		}
 
		
 
		if(logger_aprsInfoTextAvailable())
 
		{
 
			uint16_t len = strlen(commentBuffer);
 
			snprintf(commentBuffer + len, bufferSize-len, "~%s",logger_getAprsInfoText());
 
			logger_aprsInfoTextConsumed();
 
		}
 
		
 
		isEven = false;
 
	}
 
	else {
 
		// odd does nothing
 
		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
 
@@ -493,19 +493,21 @@ void slavesensors_process(uint8_t parseR
 
	}
 
	
 
	// TODO: If we time out, WE NEED TO RESET THE PARSER. It could be in a bad state.
 
	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);
 
		}
 
	}
 
	
 
	// Finished reception of a message (one sensor data value). If not finished, send out command to get the next one
 
	else if(parseResult == PARSERESULT_PARSEOK)
 
	{
master/master/master.c
Show inline comments
 
@@ -35,18 +35,19 @@
 
#include "lib/slavesensors.h"
 
#include "lib/serparser.h"
 
#include "lib/sensordata.h"
 

	
 
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();
 
	serial1_setup();
 
	i2c_init();
 
	sensordata_setup(); // must happen before slavesensors/logger/AFSK
 
@@ -67,15 +68,12 @@ int main(void)
 
	uint32_t lastDataReq = 0;
 
	uint32_t lastBuzz = 0;
 
	
 
	// Result of last parser run
 
	int parseResult = PARSERESULT_NODATA;
 
	
 
	// FIXME: Probably don't need this.
 
	serial1_ioff();
 
	
 
	while(1)
 
    {
 
		// Periodic: LED execution indicator
 
		if(time_millis() - lastLedCycle > LEDCYCLE_RATE) 
 
		{
 
			led_power_toggle();
 
@@ -133,13 +131,13 @@ int main(void)
 
		// Periodic: Data Request
 
		if(time_millis() - lastDataReq > DATAREQUEST_RATE)  
 
		{
 
			// 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
 
			{
 
				slavesensors_startprocess();
 
			}
 
			
0 comments (0 inline, 0 general)