Changeset - 3824e42662b1
[Not reviewed]
default
0 7 0
ethanzonca@CL-ENS241-08.cedarville.edu - 12 years ago 2013-01-22 15:36:10
ethanzonca@CL-ENS241-08.cedarville.edu
Added APRS comment with some sensor values for testing, added method to procedurally create APRS comment, other various changes
7 files changed with 36 insertions and 8 deletions:
0 comments (0 inline, 0 general)
master/master/lib/aprs.c
Show inline comments
 
@@ -5,24 +5,25 @@
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#include "../config.h"
 
#include "aprs.h"
 
#include "ax25.h"
 
#include "gps.h"
 
#include "sensordata.h"
 
#include <stdio.h>
 

	
 
const char *gps_aprs_lat = "39.74744N";
 
const char *gps_aprs_lon = "-83.81249W";
 
const char *gps_time = "081533/";
 
float gps_altitude = 123.5;
 
int gps_course = 5;
 
int gps_speed = 13;
 

	
 
float meters_to_feet(float m)
 
{
 
  // 10000 ft = 3048 m
 
@@ -69,20 +70,18 @@ void aprs_send()
 
  ax25_send_string("/Ti=");
 
  snprintf(temp, 6, "%d", 122);//sensors_int_lm60()); -- PUT SENSOR DATA HERE
 
  ax25_send_string(temp);
 
  ax25_send_string("/Te=");
 
  snprintf(temp, 6, "%d", 123);//sensors_ext_lm60());
 
  ax25_send_string(temp);
 
  ax25_send_string("/V=");
 
  snprintf(temp, 6, "%d", 123);//sensors_vin());
 
  ax25_send_string(temp);
 
  */
 
  
 
  ax25_send_byte(' ');
 
  ax25_send_string("SV:");
 
  ax25_send_string(getNumSatelites());
 
  ax25_send_byte(' ');
 
  ax25_send_string(APRS_COMMENT);     // Comment
 
  //ax25_send_string(APRS_COMMENT);     // Comment
 
  ax25_send_string(slavesensors_getAPRScomment());
 
  ax25_send_footer();
 

	
 
  ax25_flush_frame();                 // Tell the modem to go
 
}
master/master/lib/gps.c
Show inline comments
 
@@ -47,25 +47,25 @@ char latitude[14];	//lllll.lla
 
char* get_latitude() {
 
	return latitude;
 
}
 

	
 
char longitude[14];	//yyyyy.yyb
 
char* get_longitude() {
 
	return longitude;
 
}
 

	
 

	
 
char quality;		//quality for GGA and validity for RMC
 
char numSatellites[4];
 
char* getNumSatelites() {
 
char* get_sv() {
 
	return numSatellites;
 
}
 

	
 
char hdop[6];		//xx.x
 
char* get_hdop() {
 
	return hdop;
 
}
 

	
 
char altitude[10];	//xxxxxx.x
 
char wgs84Height[8];	//sxxx.x
 
char lastUpdated[8];	//blank - included for testing
 
char stationID[8];	//blank - included for testing
 
@@ -117,24 +117,36 @@ enum decodeState {
 
	RMC_DATE,
 
	RMC_MAG_VARIATION,
 
	
 
}decodeState;
 

	
 

	
 
ISR(USART1_RX_vect)
 
{
 
	nmeaBuffer[nmeaBufferDataPosition % NMEABUFFER_SIZE] = UDR1;
 
	nmeaBufferDataPosition = (nmeaBufferDataPosition + 1) % NMEABUFFER_SIZE;
 
}
 

	
 
void gps_setup() 
 
{
 
	sprintf(timestamp, "0");
 
	sprintf(latitude, "0");
 
	sprintf(longitude, "0");
 
	sprintf(numSatellites, "0");
 
	sprintf(hdop, "0");
 
	sprintf(knots, "0");
 
	sprintf(course, "0");
 
	sprintf(dayofmonth, "0");
 
}
 

	
 

	
 
// Could inline if program space available
 
static void setParserState(uint8_t state)
 
{
 
	decodeState = state;
 
 
	
 
	// If resetting, clear vars
 
	if(state == INITIALIZE)
 
	{
 
		calculatedChecksum = 0;
 
	}
master/master/lib/gps.h
Show inline comments
 
@@ -3,22 +3,23 @@
 
 *
 
 * Created: 11/15/2012 12:02:53 PM
 
 *  Author: mkanning
 
 */ 
 
 
 
#ifndef GPSMKA_H_
 
#define GPSMKA_H_
 
#define GGA_MESSAGE
 
#define RMC_MESSAGE
 
#define UKN_MESSAGE
 
 
void gps_setup();
 
char* get_longitude();
 
char* get_latitude();
 
char* get_timestamp();
 
char* get_speedKnots();
 
char* get_course();
 
char* get_hdop();
 
char* getNumSatelites();
 
char* get_sv();
 
char* get_dayofmonth();
 
 
#endif /* GPSMKA_H_ */
 
\ No newline at end of file
master/master/lib/sensordata.c
Show inline comments
 
@@ -3,24 +3,26 @@
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 

	
 
#include "../config.h"
 
#include "sensordata.h"
 
#include "boardtemp.h"
 
#include "gps.h"
 

	
 
int16_t slaves[MAX_NUM_SLAVES][MAX_NUM_SENSORS];
 

	
 
void sensordata_setup() 
 
{
 
	for(int i=0; i<MAX_NUM_SLAVES; i++) {
 
		for(int j=0; j<MAX_NUM_SENSORS; j++) {
 
			slaves[i][j] = -32768; // minimum value of 16 bit integer
 
		}
 
	}
 
}
 
 
@@ -32,12 +34,22 @@ void sensordata_set(uint8_t nodeID, uint
 
}
 
 
int16_t sensordata_get(uint8_t nodeID, uint8_t type) 
 
{
 
	// Avoid reading out of bad places!
 
	if(nodeID < MAX_NUM_SLAVES) {
 
		return slaves[nodeID][type];
 
	}
 
	else {
 
		return 0;
 
	}
 
}
 
 
 
char commentBuffer[128];
 
 
 
// [A-30.5 B45.64 C99542]"
 
char* slavesensors_getAPRScomment() {
 
	snprintf(commentBuffer,128, "T%d S%s V%s H%s", sensors_getBoardTemp(), get_sv(), get_speedKnots(), get_hdop());
 
	return commentBuffer;
 
}
 
\ No newline at end of file
master/master/lib/sensordata.h
Show inline comments
 
@@ -12,14 +12,15 @@
 
 
 
#ifndef SENSORDATA_H_
 
#define SENSORDATA_H_
 
 
#include "slavesensors.h"
 
 
void sensordata_setup();
 
void sensordata_set(uint8_t nodeID, uint8_t type, uint16_t value);
 
int16_t sensordata_get(uint8_t nodeID, uint8_t type);
 
void sensordata_setBoardTemp(uint8_t slaveID, int16_t value);
 
int16_t sensordata_getBoardTemp(uint8_t slaveID);
 
char* slavesensors_getAPRScomment();
 
 
#endif /* SENSORDATA_H_ */
 
\ No newline at end of file
master/master/lib/slavesensors.c
Show inline comments
 
@@ -234,25 +234,24 @@ int xbeeIsOk()
 
	if(strcmp(tmppntr, "OK") == 0)
 
	{
 
		return 0;
 
	}
 
	else
 
	{
 
		led_errorcode(ERROR_NOXBEE);
 
		return 1;
 
	}
 
}
 
 
 
 
bool slavesensors_isrequesting() 
 
{
 
	return requesting;	
 
}
 
 
void slavesensors_startprocess() 
 
{
 
	requesting = true;
 
	slavesensors_request();		
 
}
 
 
// TODO: inline. static.
master/master/master.c
Show inline comments
 
@@ -36,24 +36,25 @@
 
#include "lib/slavesensors.h"
 
#include "lib/serparser.h"
 
#include "lib/sensordata.h"
 

	
 
int main(void)
 
{
 
	led_on(LED_POWER);
 
	
 
	// Initialize libraries
 
	time_setup();
 
	watchdog_setup(); // enables interrupts
 
	led_setup();	
 
	gps_setup();
 
	serial0_setup();
 
	serial1_setup();
 
	i2c_init();
 
	sensordata_setup(); // must happen before sensors/logger/afsk
 
	slavesensors_setup();
 
	logger_setup();
 
	afsk_setup();
 
	//\f
 
	
 
	#ifdef DEBUG_OUTPUT
 
	serial0_sendString("\r\n---------------------------------\r\n");
 
	serial0_sendString("HAB Controller 1.0 - Initialized!\r\n");
 
@@ -107,36 +108,39 @@ int main(void)
 
			//serial0_sendString(debugBuf);
 
			
 
			// Turn on sideboard LED if we have a fix
 
			if(strcmp("99.99", get_hdop()) == 0) {
 
				led_off(LED_SIDEBOARD);
 
			}
 
			else {
 
				led_on(LED_SIDEBOARD);
 
			}
 
			
 
			sensors_readBoardTemp(); // i2c read, 400k
 
		
 
			logbuf[0] = 0x00;
 
			//snprintf(logbuf, 128, "%lu,%d,%u,%s,%s,%s,%s,%s\r\n", time_millis(), sensors_getBoardTemp(),get_timestamp(),get_latitude(),get_longitude(),get_speedKnots(),get_hdop(), get_course());
 
			for(int i=0; i<MAX_NUM_SLAVES; i++) {
 
				for(int j=0; j<MAX_NUM_SENSORS; j++) {
 
					int16_t tmp = sensordata_get(i, j);
 
					if(tmp != -32768) {
 
						//serial0_sendString("OH GOSH DATUM\r\n");
 
						snprintf(logbuf,128,"Found value %d...\r\n", tmp);
 
						snprintf(logbuf + strlen(logbuf),128," %d,", tmp);
 
						serial0_sendString(logbuf);
 
					}
 
					
 
				}
 
			}
 
			snprintf(logbuf + strlen(logbuf),128,"\r\n");
 
			
 
			logger_log(logbuf);
 
			
 
			// Print out logger debug
 
			#ifdef DEBUG_OUTPUT
 
			//serial0_sendString("LOG> ");
 
			//serial0_sendString(logbuf);
 
			#endif
 
			
 
			led_off(LED_CYCLE);
 
			lastLog = time_millis();
 
		}		
 
		
0 comments (0 inline, 0 general)