Changeset - 5696a474fa0f
[Not reviewed]
default
0 2 0
ethanzonca@CL-ENS241-08.cedarville.edu - 12 years ago 2013-02-26 14:36:48
ethanzonca@CL-ENS241-08.cedarville.edu
Added support for standalone master operation (no slaves)
2 files changed with 62 insertions and 42 deletions:
0 comments (0 inline, 0 general)
master/master/lib/sensordata.c
Show inline comments
 
@@ -58,6 +58,7 @@ int32_t sensordata_get(uint8_t nodeID, u
 
	}
 
}
 
 
bool isEven = false;
 
 
// Generate APRS comment
 
// TODO: Can we move this buffer to a local scope of this function?
 
@@ -65,59 +66,67 @@ int32_t sensordata_get(uint8_t nodeID, u
 
char commentBuffer[COMMENTBUFFER_SIZE];
 
char* slavesensors_getAPRScomment() 
 
{
 
	snprintf(commentBuffer,COMMENTBUFFER_SIZE, "t9%d s%s v%s h%s _%s |%s ", sensors_getBoardTemp(), get_sv(), get_speedKnots(), get_hdop(), get_latitudeLSBs(), get_longitudeLSBs());
 
	snprintf(commentBuffer,COMMENTBUFFER_SIZE, "t9%d~s%s~v%s~h%s~_%s~|%s", sensors_getBoardTemp(), get_sv(), get_speedKnots(), get_hdop(), get_latitudeLSBs(), get_longitudeLSBs());
 
	
 
	// 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) {
 
			uint16_t len = strlen(commentBuffer);
 
			snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, " t%u%li",i,val);
 
		}
 
	if(isEven) 
 
	{
 
		// 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) {
 
				uint16_t len = strlen(commentBuffer);
 
				snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, "~t%u%li",i,val);
 
			}
 
		
 
		// Battery voltages (all slaves)
 
		val = sensordata_get(i, SENSOR_BATTERYLEVEL);
 
		if(val != -2111111111) {
 
			uint16_t len = strlen(commentBuffer);
 
			snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, " l%u%li",i,val);
 
		}
 
			// Battery voltages (all slaves)
 
			val = sensordata_get(i, SENSOR_BATTERYLEVEL);
 
			if(val != -2111111111) {
 
				uint16_t len = strlen(commentBuffer);
 
				snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, "~l%u%li",i,val);
 
			}
 
		
 
			// Pressure
 
			val = sensordata_get(i, SENSOR_PRESSURE);
 
			if(val != -2111111111) {
 
				uint16_t len = strlen(commentBuffer);
 
				snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, "~P%li",val);
 
			}
 
		
 
		// Pressure
 
		val = sensordata_get(i, SENSOR_PRESSURE);
 
		if(val != -2111111111) {
 
			uint16_t len = strlen(commentBuffer);
 
			snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, " P%li",val);
 
		}
 
			// Air Temperature
 
			val = sensordata_get(i, SENSOR_AIRTEMP);
 
			if(val != -2111111111) {
 
				uint16_t len = strlen(commentBuffer);
 
				snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, "~C%li",val);
 
			}
 
		
 
		// Air Temperature
 
		val = sensordata_get(i, SENSOR_AIRTEMP);
 
		if(val != -2111111111) {
 
			uint16_t len = strlen(commentBuffer);
 
			snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, " C%li",val);
 
		}
 
			// Altitude
 
			val = sensordata_get(i, SENSOR_ALTITUDE);
 
			if(val != -2111111111) {
 
				uint16_t len = strlen(commentBuffer);
 
				snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, "~A%li",val);
 
			}
 
		
 
		// Altitude
 
		val = sensordata_get(i, SENSOR_ALTITUDE);
 
		if(val != -2111111111) {
 
			uint16_t len = strlen(commentBuffer);
 
			snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, " A%li",val);
 
		}
 
			// Radiation
 
			val = sensordata_get(i, SENSOR_CPM_RADIATION);
 
			if(val != -2111111111) {
 
				uint16_t len = strlen(commentBuffer);
 
				snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, "~R%li",val);
 
			}
 
		
 
		// Radiation
 
		val = sensordata_get(i, SENSOR_CPM_RADIATION);
 
		if(val != -2111111111) {
 
			uint16_t len = strlen(commentBuffer);
 
			snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, " R%li",val);
 
		}
 
		
 
		}
 
		isEven = false;
 
	}
 
	else {
 
		// odd does nothing
 
		isEven = true;
 
	}	
 
	
 
	if(logger_aprsInfoTextAvailable())
 
	{
 
		uint16_t len = strlen(commentBuffer);
 
		snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, " %s",logger_getAprsInfoText());
 
		snprintf(commentBuffer + len, COMMENTBUFFER_SIZE-len, "~%s",logger_getAprsInfoText());
 
		logger_aprsInfoTextConsumed();
 
	}
 
	
master/master/lib/slavesensors.c
Show inline comments
 
@@ -236,6 +236,12 @@ void slavesensors_network_scan()
 
	
 
	slavesensors_selectlogger();
 
	
 
	// If we don't have slaves to worry about, we're good to go
 
	if(nodeCount == 0)
 
	{
 
		dataReady = true;
 
	}		
 
	
 
	serial0_ion();
 
}
 
 
@@ -410,6 +416,10 @@ bool slavesensors_isrequesting()
 
 
void slavesensors_startprocess() 
 
{
 
	if(nodeCount == 0)
 
	{
 
		return;
 
	}		
 
	requesting = true;
 
	slavesensors_request();		
 
}
 
@@ -428,6 +438,7 @@ uint8_t numReadingsToExpect = 0; // numb
 
uint8_t numRetries = 0;
 
 
void gotoNextSlaveOrSensor(bool fail) {
 
	
 
	// If we finished all sensors for all slaves
 
	if(currentSlave >= (nodeCount-1) && currentSlaveSensor >= (numReadingsToExpect-1))
 
	{
0 comments (0 inline, 0 general)