Changeset - 0062f8daffe7
[Not reviewed]
default
0 9 0
ethanzonca@CL-ENS241-08.cedarville.edu - 12 years ago 2013-01-10 21:58:42
ethanzonca@CL-ENS241-08.cedarville.edu
GPS parser now functional, APRS is now broadcasted with possibly correct position information
9 files changed with 318 insertions and 84 deletions:
0 comments (0 inline, 0 general)
master/master/config.h
Show inline comments
 
@@ -19,7 +19,7 @@
 
 
#define F_CPU 11059200
 
#define MODULE_ID '1'
 
 
#define BOARDTEMP_ADDR 0x90
 
 
// --------------------------------------------------------------------------
 
// Error Codes config (led.c, used throughout code)
 
@@ -62,12 +62,18 @@
 
// Public broadcast address
 
#define BROADCAST_ADDR 0 
 
 
 
// --------------------------------------------------------------------------
 
// GPS config (xxx.c)
 
// --------------------------------------------------------------------------
 
#define NMEABUFFER_SIZE 150
 
 
// --------------------------------------------------------------------------
 
// USART config (serial.c)
 
// --------------------------------------------------------------------------
 
 
#define USART0_BAUDRATE 115200
 
#define USART1_BAUDRATE 4800
 
#define USART1_BAUDRATE 115200
 
 
 
// --------------------------------------------------------------------------
 
@@ -112,7 +118,7 @@
 
#define APRS_COMMENT    "CedarvilleUniversity HAB"
 
 
// Transmit the APRS sentence every X milliseconds
 
#define APRS_TRANSMIT_PERIOD 10000
 
#define APRS_TRANSMIT_PERIOD 5000
 

	
 

	
 
// --------------------------------------------------------------------------
master/master/lib/afsk.c
Show inline comments
 
@@ -204,7 +204,8 @@ void afsk_send(const uint8_t *buffer, in
 

	
 
void afsk_setup() 
 
{
 
	
 
	DDRA |= 0b00100000;
 
	DDRD |= 0b10000000;
 
	// Source timer2 from clkIO (datasheet p.164)
 
	ASSR &= ~(_BV(EXCLK) | _BV(AS2));
 

	
 
@@ -222,13 +223,5 @@ void afsk_setup()
 
	//TIMSK2 |= _BV(TOIE2);
 
	TIMSK2 |= 0b00000001;
 
	
 
	// FIXME TODO
 
	DDRD = 0xff;
 
	PORTD = 0xff;
 
	
 
	// todo: init radio, maybe in main
 
	
 
	
 
	
 
	while(afsk_busy());
 
}
 
\ No newline at end of file
master/master/lib/aprs.c
Show inline comments
 
@@ -13,6 +13,7 @@
 
#include "../config.h"
 
#include "aprs.h"
 
#include "ax25.h"
 
#include "trackuinoGPS/gpsMKa.h"
 
#include <stdio.h>
 

	
 
const char *gps_aprs_lat = "39.74744N";
 
@@ -46,17 +47,19 @@ void aprs_send()
 
  ax25_send_header(addresses, sizeof(addresses)/sizeof(addresses[0]));
 
  ax25_send_byte('/');                // Report w/ timestamp, no APRS messaging. $ = NMEA raw data
 
  // ax25_send_string("021709z");     // 021709z = 2nd day of the month, 17:09 zulu (UTC/GMT)
 
  ax25_send_string(gps_time);         // 170915 = 17h:09m:15s zulu (not allowed in Status Reports)
 
  ax25_send_string(get_timestamp());         // 170915 = 17h:09m:15s zulu (not allowed in Status Reports)
 
  ax25_send_byte('h');
 
  ax25_send_string(gps_aprs_lat);     // Lat: 38deg and 22.20 min (.20 are NOT seconds, but 1/100th of minutes)
 
  ax25_send_string(get_latitude());     // Lat: 38deg and 22.20 min (.20 are NOT seconds, but 1/100th of minutes)
 
  ax25_send_byte('/');                // Symbol table
 
  ax25_send_string(gps_aprs_lon);     // Lon: 000deg and 25.80 min
 
  ax25_send_string(get_longitude());     // Lon: 000deg and 25.80 min
 
  ax25_send_byte('O');                // Symbol: O=balloon, -=QTH
 
  snprintf(temp, 4, "%03d", (int)(gps_course + 0.5)); 
 
  ax25_send_string(temp);             // Course (degrees)
 
  ax25_send_byte('/');                // and
 
  snprintf(temp, 4, "%03d", (int)(gps_speed + 0.5));
 
  ax25_send_string(temp);             // speed (knots)
 
  //snprintf(temp, 4, "%03d", (int)(gps_speed + 0.5));
 
  ax25_send_string(get_speedKnots());             // speed (knots)
 
  
 
  /*
 
  ax25_send_string("/A=");            // Altitude (feet). Goes anywhere in the comment area
 
  snprintf(temp, 7, "%06ld", (long)(meters_to_feet(gps_altitude) + 0.5));
 
  ax25_send_string(temp);
 
@@ -69,6 +72,8 @@ void aprs_send()
 
  ax25_send_string("/V=");
 
  snprintf(temp, 6, "%d", 123);//sensors_vin());
 
  ax25_send_string(temp);
 
  */
 
  
 
  ax25_send_byte(' ');
 
  ax25_send_string(APRS_COMMENT);     // Comment
 
  ax25_send_footer();
master/master/lib/looptime.c
Show inline comments
 
@@ -20,8 +20,6 @@ volatile uint32_t millis = 0; // Millise
 

	
 
void time_setup() 
 
{
 
	DDRA = 0xff;
 
	
 
	// Generic microcontroller config options
 
	OCR0A = 173; // Approx 172.7969 ticks per ms with 64 prescaler
 
	
master/master/lib/serial.c
Show inline comments
 
@@ -36,12 +36,8 @@ void serial0_setup() {
 
	//UCSR0A |= (1<<RXC0);
 
}
 
 
volatile uint8_t charTest;
 
 
ISR(USART1_RX_vect)
 
{
 
	serial1_sendChar(UDR1);
 
}
 
 
 
void serial1_setup() {
 
//PROVEN in test project
master/master/lib/trackuinoGPS/gpsMKa.c
Show inline comments
 
@@ -7,10 +7,31 @@
 
 
#include <stdbool.h>
 
#include <avr/io.h>
 
#include <avr/interrupt.h>
 
#include "gpsMKa.h"
 
#include "../serial.h"
 
#include "../../config.h"
 

	
 

	
 
 
// Circular buffer for incoming data
 
uint8_t nmeaBuffer[NMEABUFFER_SIZE];
 
 
// Location of parser in the buffer
 
uint8_t nmeaBufferParsePosition = 0;
 
 
// Location of receive byte interrupt in the buffer
 
volatile uint16_t nmeaBufferDataPosition = 0;
 
 

	
 
/*
 
volatile uint8_t charTest;
 
ISR(USART1_RX_vect)
 
{
 
	serial0_sendChar(UDR1);
 
	
 
}*/
 

	
 
// holds the byte ALREADY PARSED. includes starting character
 
int bytesReceived = 0;
 

	
 
@@ -25,25 +46,46 @@ int numBytes = 0;
 

	
 
//variables to store data from transmission
 
//least significant digit is stored at location 0 of arrays
 
uint8_t tramsmissionType[5];
 
uint8_t timestamp[9];	//hhmmss.ss
 
uint8_t latitude[8];	//lllll.lla
 
uint8_t longitude[8];	//yyyyy.yyb
 
uint8_t quality;		//quality for GGA and validity for RMC
 
uint8_t numSatellites[2];
 
uint8_t hdop[4];		//xx.x
 
uint8_t altitude[8];	//xxxxxx.x
 
uint8_t wgs84Height[6];	//sxxx.x
 
uint8_t lastUpdated[6];	//blank - included for testing
 
uint8_t stationID[6];	//blank - included for testing
 
uint8_t checksum[2];	//xx
 
uint8_t knots[5];		//xxx.xx
 
uint8_t course[5];		//xxx.x
 
uint8_t datestamp[6];	//ddmmyy
 
uint8_t variation[6];	//xxx.xb
 
char tramsmissionType[7];
 

	
 
char timestamp[12];	//hhmmss.ss
 
char* get_timestamp() {
 
	return timestamp;
 
}
 
	
 
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[3];
 
char hdop[6];		//xx.x
 
char altitude[10];	//xxxxxx.x
 
char wgs84Height[8];	//sxxx.x
 
char lastUpdated[8];	//blank - included for testing
 
char stationID[8];	//blank - included for testing
 
char checksum[3];	//xx
 
char knots[8];		//xxx.xx
 
char* get_speedKnots() {
 
	return knots;
 
}
 

	
 
char course[8];		//xxx.x
 
char datestamp[9];	//ddmmyy
 
char variation[9];	//xxx.xb
 
int calculatedChecksum;
 
int receivedChecksum;
 

	
 
char convertBuf1[15];
 
char convertBuf2[15];
 

	
 
// transmission state machine
 
enum decodeState {
 
	//shared fields
 
@@ -74,46 +116,105 @@ 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));
 
}
 

	
 

	
 
// Could inline if program space available
 
static void setParserState(uint8_t state)
 
{
 
	decodeState = state;
 
 
	
 
	// If resetting, clear vars
 
	if(state == INITIALIZE)
 
	{
 
		calculatedChecksum = 0;
 
	}
 
	
 
	// Every time we change state, we have parsed a byte
 
	nmeaBufferParsePosition = (nmeaBufferParsePosition + 1) % NMEABUFFER_SIZE;
 
}
 

	
 

	
 

	
 
//// MKa GPS transmission parser START
 
void parse_gps_transmission(void){
 
	
 
	// Pull byte off of the buffer
 
	char byte = 'a';// serial1_readChar();
 
	char byte;
 
	
 
	while(nmeaBufferDataPosition != nmeaBufferParsePosition) {
 
		
 
		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(byte == '$') //start of transmission sentence
 
		if(decodeState == INITIALIZE) //start of transmission sentence
 
	{
 
		decodeState = GET_TYPE;
 
			if(byte == '$') {
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found $\r\n");
 
				#endif
 
				
 
				setParserState(GET_TYPE);
 
		numBytes = 0; //prep for next phases
 
		skipBytes = 0;
 
		calculatedChecksum = 0;
 
	}
 
	
 
			else {
 
				setParserState(INITIALIZE);
 
			}
 
		}
 
	
 
	//parse transmission type
 
	else if (decodeState == GET_TYPE)
 
	{
 
		tramsmissionType[numBytes] = byte;
 
		numBytes++;
 
		
 
			#ifdef DEBUG_NMEA
 
			serial0_sendString("stored a type byte\r\n");
 
			#endif
 
			
 
		if(byte == ',') //end of this data type
 
		{
 
				tramsmissionType[5] = 0x00;
 
				
 
			if (tramsmissionType[2] == 'G' &&
 
			tramsmissionType[3] == 'G' &&
 
			tramsmissionType[4] == 'A')
 
			{
 
				decodeState = GGA_TIME;
 
					setParserState(GGA_TIME);
 
					numBytes = 0;
 
			}
 
			else if (tramsmissionType[2] == 'R' &&
 
			tramsmissionType[3] == 'M' &&
 
			tramsmissionType[4] == 'C')
 
			{
 
				decodeState = RMC_TIME;
 
					setParserState(RMC_TIME);
 
					numBytes = 0;
 
			}
 
			else //this is an invalid transmission type
 
			{
 
				decodeState = INITIALIZE;
 
					setParserState(INITIALIZE);
 
			}
 
		}
 
			else {
 
				// continue
 
				setParserState(GET_TYPE);
 
			}
 
			
 
	}
 
	
 
	///parses GGA transmissions START
 
@@ -123,13 +224,20 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == ',') //end of this data type
 
		{
 
			decodeState = GGA_LATITUDE;
 
				timestamp[6] = 0x00; // Cut off at 6 for APRS
 
				serial0_sendString("time byte DONE\r\n");
 
				setParserState(GGA_LATITUDE);
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data
 
		{
 
			timestamp[numBytes] = byte; //adjust number of bytes to fit array
 
				//#ifdef DEBUG_NMEA
 
				serial0_sendString("found GGA time byte\r\n");
 
				//#endif
 
				
 
				setParserState(GGA_TIME);
 
				timestamp[numBytes] = byte; //byte; //adjust number of bytes to fit array
 
			numBytes++;
 
		}
 
	}
 
@@ -139,18 +247,40 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == ',' && skipBytes == 0) //discard this byte
 
		{
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found lat skip byte\r\n");
 
				#endif
 
				
 
			skipBytes = 1;
 
				setParserState(GGA_LATITUDE);
 
		}
 
		else if (byte == ',') //end of this data type
 
		{
 
			decodeState = GGA_LONGITUDE;
 
				
 
				latitude[numBytes] = 0x00; // null terminate
 
				
 
				
 
				// First 2 bytes
 
				//convertBuf1[0] = latitude[0];
 
				//convertBuf1[1] = latitude[1];
 
				//convertBuf1[2] = '\0';
 
				//strncpy(convertBuf2, latitude, 7);
 
				//convertBuf2[7] = '\0';
 
				
 
				
 
				setParserState(GGA_LONGITUDE);
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data
 
		{
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found lat byte\r\n");
 
				#endif
 
				
 
			latitude[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
				setParserState(GGA_LATITUDE);
 
		}
 
	}
 
	
 
@@ -159,18 +289,29 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == ',' && skipBytes == 0) //discard this byte
 
		{
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found long skip byte\r\n");
 
				#endif
 
				
 
			skipBytes = 1;
 
				setParserState(GGA_LONGITUDE);
 
		}
 
		else if (byte == ',') //end of this data type
 
		{
 
			decodeState = GGA_QUALITY;
 
				longitude[numBytes] = 0x00;
 
				setParserState(GGA_QUALITY);
 
			numBytes = 0; //prep for next phase of parse
 
			skipBytes = 0;
 
		}
 
		else //store data
 
		{
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found long byte\r\n");
 
				#endif
 
				
 
			longitude[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
				setParserState(GGA_LONGITUDE);
 
		}
 
	}
 
	
 
@@ -179,12 +320,17 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == ',') //end of this data type
 
		{
 
			decodeState = GGA_SATELLITES;
 
				setParserState(GGA_SATELLITES);
 
			numBytes = 0; //prep for next phase of parse
 
		}
 
		else //store data
 
		{
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found quality byte\r\n");
 
				#endif
 
				
 
			quality = byte; //maybe reset if invalid data ??
 
				setParserState(GGA_QUALITY);
 
		}
 
	}
 
	
 
@@ -193,13 +339,15 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == ',') //end of this data type
 
		{
 
			decodeState = GGA_HDOP;
 
				numSatellites[numBytes] = 0x00;
 
				setParserState(GGA_HDOP);
 
			numBytes = 0; //prep for next phase of parse
 
		}
 
		else //store data
 
		{
 
			numSatellites[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
				setParserState(GGA_SATELLITES);
 
		}
 
	}
 
	
 
@@ -208,7 +356,8 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == ',' ) //end of this data type
 
		{
 
			decodeState = GGA_ALTITUDE;
 
				hdop[numBytes] = 0x00;
 
				setParserState(GGA_ALTITUDE);
 
			numBytes = 0; //prep for next phase of parse
 
			skipBytes = 0;
 
		}
 
@@ -216,6 +365,7 @@ void parse_gps_transmission(void){
 
		{
 
			hdop[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
				setParserState(GGA_HDOP);
 
		}
 
	}
 
	
 
@@ -225,16 +375,19 @@ void parse_gps_transmission(void){
 
		if (byte == ',' && skipBytes == 0) //discard this byte
 
		{
 
			skipBytes = 1;
 
				setParserState(GGA_ALTITUDE);
 
		}
 
		else if(byte == ',') //end of this data type
 
		{
 
			decodeState = GGA_WGS84;
 
				altitude[numBytes] = 0x00;
 
				setParserState(GGA_WGS84);
 
			numBytes = 0; //prep for next phase of parse
 
		}
 
		else //store data
 
		{
 
			altitude[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
				setParserState(GGA_ALTITUDE);
 
		}
 
	}
 
	
 
@@ -244,10 +397,12 @@ void parse_gps_transmission(void){
 
		if (byte == ',' && skipBytes == 0) //discard this byte
 
		{
 
			skipBytes = 1;
 
				setParserState(GGA_WGS84);
 
		}
 
		else if(byte == ',') //end of this data type
 
		{
 
			decodeState = GGA_LAST_UPDATE;
 
				wgs84Height[numBytes] = 0x00;
 
				setParserState(GGA_LAST_UPDATE);
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
@@ -255,6 +410,7 @@ void parse_gps_transmission(void){
 
		{
 
			wgs84Height[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
				setParserState(GGA_WGS84);
 
		}
 
	}
 
	
 
@@ -263,13 +419,15 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == ',') //end of this data type
 
		{
 
			decodeState = GGA_STATION_ID;
 
				lastUpdated[numBytes] = 0x00;
 
				setParserState(GGA_STATION_ID);
 
			numBytes = 0; //prep for next phase of parse
 
		}
 
		else //store data - this should be blank
 
		{
 
			lastUpdated[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
				setParserState(GGA_LAST_UPDATE);
 
		}
 
	}
 
	
 
@@ -278,13 +436,15 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == ',' || byte == '*') //end of this data type
 
		{
 
			decodeState = GPS_CHECKSUM;
 
				stationID[numBytes] = 0x00;
 
				setParserState(GPS_CHECKSUM);
 
			numBytes = 0; //prep for next phase of parse
 
		}
 
		else //store data - this should be blank
 
		{
 
			stationID[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
				setParserState(GGA_STATION_ID);
 
		}
 
	}
 
	///parses GGA transmissions END
 
@@ -292,73 +452,106 @@ void parse_gps_transmission(void){
 
	/// $GPRMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,ddmmyy,x.x,a*hh
 
	///parses RMC transmissions
 
	//time
 
		// emz: commented setter, GMC time better?
 
	else if(decodeState == RMC_TIME)
 
	{
 
		if (byte == ',') //end of this data type
 
		{
 
			decodeState = RMC_VALIDITY;
 
				//timestamp[numBytes] = 0x00;
 
				setParserState(RMC_VALIDITY);
 
			numBytes = 0; //prep for next phase of parse
 
		}
 
		else //store data
 
		{
 
			timestamp[numBytes] = byte; //adjust number of bytes to fit array
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found time byte\r\n");
 
				#endif
 
				
 
				//timestamp[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
				setParserState(RMC_TIME);
 
		}
 
	}
 
	
 
	//validity
 
		// not needed? dupe gga
 
	else if(decodeState == RMC_VALIDITY)
 
	{
 
		if (byte == ',') //end of this data type
 
		{
 
			decodeState = RMC_LATITUDE;
 
				setParserState(RMC_LATITUDE);
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data
 
		{
 
			quality = byte;
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found valid byte\r\n");
 
				#endif
 
				
 
				//quality = byte;
 
			numBytes++;
 
				setParserState(RMC_VALIDITY);
 
		}
 
	}
 
	
 
	//latitude
 
		//latitude RMC (we don't need this, commented out setter)
 
	else if(decodeState == RMC_LATITUDE)
 
	{
 
		if (byte == ',' && skipBytes == 1) //discard this byte
 
			if (byte == ',' && skipBytes == 0) //discard this byte
 
		{
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found lat skip byte\r\n");
 
				#endif
 
				
 
			skipBytes = 1; 
 
				setParserState(RMC_LATITUDE);
 
		}
 
		else if (byte == ',') //end of this data type
 
		{
 
			decodeState = RMC_LONGITUDE;
 
				setParserState(RMC_LONGITUDE);
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data
 
		{
 
			latitude[numBytes]= byte; //adjust number of bytes to fit array
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found lat byte\r\n");
 
				#endif
 
				
 
				//latitude[numBytes]= byte; //adjust number of bytes to fit array
 
			numBytes++;
 
				setParserState(RMC_LATITUDE);
 
		}
 
	}
 
	
 
	//longitude
 
		//longitude RMC (we don't need this, commented out setter)
 
	else if(decodeState == RMC_LONGITUDE)
 
	{
 
		if (byte == ',' && skipBytes == 1) //discard this byte
 
			if (byte == ',' && skipBytes == 0) //discard this byte
 
		{
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found long byte\r\n");
 
				#endif
 
				
 
			skipBytes = 1; 
 
				setParserState(RMC_LONGITUDE);
 
		}
 
		else if (byte == ',') //end of this data type
 
		{
 
			decodeState = RMC_KNOTS;
 
				setParserState(RMC_KNOTS);
 
			skipBytes = 0;
 
			numBytes = 0;
 
		}
 
		else //store data
 
		{
 
			longitude[numBytes]= byte; //adjust number of bytes to fit array
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("found long byte\r\n");
 
				#endif
 
				
 
				//longitude[numBytes]= byte; //adjust number of bytes to fit array
 
			numBytes++;
 
				setParserState(RMC_LONGITUDE);
 
		}
 
	}
 
	
 
@@ -367,11 +560,13 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == ',') //end of this data type
 
		{
 
			decodeState = RMC_COURSE;
 
				knots[numBytes] = 0x00;
 
				setParserState(RMC_COURSE);
 
			numBytes = 0; //prep for next phase of parse
 
		}
 
		else //store data
 
		{
 
				setParserState(RMC_KNOTS);
 
			knots[numBytes]= byte; //adjust number of bytes to fit array
 
			numBytes++;
 
		}
 
@@ -382,11 +577,13 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == ',') //end of this data type
 
		{
 
			decodeState = RMC_DATE;
 
				course[numBytes] = 0x00;
 
				setParserState(RMC_DATE);
 
			numBytes = 0; //prep for next phase of parse
 
		}
 
		else //store data
 
		{
 
				setParserState(RMC_COURSE);
 
			course[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
		}
 
@@ -397,12 +594,14 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == ',') //end of this data type
 
		{
 
			decodeState = RMC_MAG_VARIATION;
 
				datestamp[numBytes] = 0x00;
 
				setParserState(RMC_MAG_VARIATION);
 
			skipBytes = 0; //prep for next phase of parse
 
			numBytes = 0;
 
		}
 
		else //store data
 
		{
 
				setParserState(RMC_DATE);
 
			datestamp[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
		}
 
@@ -413,11 +612,13 @@ void parse_gps_transmission(void){
 
	{
 
		if (byte == '*') //end of this data type
 
		{
 
			decodeState = GPS_CHECKSUM;
 
				variation[numBytes] = 0x00;
 
				setParserState(GPS_CHECKSUM);
 
			numBytes = 0; //prep for next phase of parse
 
		}
 
		else //store data
 
		{
 
				setParserState(RMC_MAG_VARIATION);
 
			variation[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
		}
 
@@ -441,23 +642,33 @@ void parse_gps_transmission(void){
 
			{
 
				
 
			}
 
				#ifdef DEBUG_NMEA
 
				serial0_sendString("OMG GOT TO CHECKSUM!\r\n");
 
				#endif
 
			
 
			decodeState = INITIALIZE;
 
				snprintf(debugBuff, 128, "\r\n\r\ntype: %s tstamp: %s lat: %s lon: %s speed: %s hdop: %s course: %s \r\n\r\n",
 
				tramsmissionType,timestamp,latitude,longitude,knots,hdop, course);
 
				serial0_sendString((debugBuff));
 
				setParserState(INITIALIZE);
 
			numBytes = 0; //prep for next phase of parse
 
		}
 
		else //store data
 
		{
 
				setParserState(GPS_CHECKSUM);
 
			checksum[numBytes] = byte; //adjust number of bytes to fit array
 
			numBytes++;
 
		}
 
	}
 
		else {
 
			setParserState(INITIALIZE);
 
		}
 
	
 
	if (decodeState!=GPS_CHECKSUM && decodeState!=INITIALIZE)	//want bytes between '$' and '*'
 
	{
 
		//input byte into running checksum
 
		XORbyteWithChecksum(byte);
 
	}
 
	
 
	}	
 

	
 
}
 
/// MKa GPS transmission parser END
master/master/lib/trackuinoGPS/gpsMKa.h
Show inline comments
 
@@ -12,4 +12,9 @@
 
#define RMC_MESSAGE
 
#define UKN_MESSAGE
 
 
char* get_longitude();
 
char* get_latitude();
 
char* get_timestamp();
 
char* get_speedKnots();
 
 
#endif /* GPSMKA_H_ */
 
\ No newline at end of file
master/master/master.c
Show inline comments
 
@@ -24,10 +24,14 @@
 
#include "lib/aprs.h"
 
#include "lib/afsk.h"
 
#include "lib/led.h"
 
//#include "lib/logger.h"
 
#include "lib/logger.h"
 
#include "lib/watchdog.h"
 
//!
 
#include "lib/sd/sd_raw_config.h"
 

	
 
#include "lib/trackuinoGPS/gpsMKa.h"
 

	
 
#include "lib/i2c.h"
 
#include "lib/boardtemp.h"
 

	
 
#include "lib/looptime.h"
 
#include "lib/slavesensors.h"
 
#include "lib/serparser.h"
 
@@ -55,6 +59,8 @@ int main(void)
 
	
 
	serial1_setup();
 
	
 
	i2c_init(); // for board temp
 

	
 
	sensordata_setup(); // must happen before sensors/logger/afsk
 
	slavesensors_setup();
 
	logger_setup();
 
@@ -64,14 +70,14 @@ int main(void)
 
	serial0_sendString("\r\n\r\n---------------------------------\r\n");
 
	serial0_sendString("HAB Controller 1.0 - Initialized!\r\n");
 
	serial0_sendString("---------------------------------\r\n\r\n");
 
	serial0_sendString("\f\r\n\r\Hello.\r\n\r\n");
 
	serial0_sendString("\f\r\n\rHello.\r\n\r\n");
 
	
 
	led_on(LED_POWER);
 
	led_off(LED_SIDEBOARD);
 

	
 
	
 
	// Buffer for string operations
 
	char logbuf[16];
 
	char logbuf[32];
 
	
 
	// Software timers	
 
	uint32_t lastAprsBroadcast = 0;
 
@@ -125,8 +131,10 @@ int main(void)
 
		// Periodic: Logging
 
		if(time_millis() - lastLog > LOGGER_RATE) 
 
		{
 
			
 
			led_on(LED_STATUS);
 
			snprintf(logbuf, 16, "%lu,%d,\r\n", time_millis(), sensordata_get(HUMIDITY));
 
			sensors_readBoardTemp(); // i2c read, 400k
 
			snprintf(logbuf, 32, "%lu,%d,%uF\r\n", time_millis(), sensordata_get(HUMIDITY), sensors_getBoardTemp());
 
			logger_log(logbuf);
 
			//serial0_sendString("Logging: ");
 
			//serial0_sendString(logbuf);
 
@@ -139,6 +147,8 @@ int main(void)
 
		// Periodic: APRS transmission
 
		if(time_millis() - lastAprsBroadcast > APRS_TRANSMIT_PERIOD) 
 
		{
 
			
 
			
 
			serial0_sendString(":: APRS Periodic\r\n");
 
			
 
			while(afsk_busy());
 
@@ -161,10 +171,8 @@ int main(void)
 
		
 

	
 
		parseResult = serparser_parse();
 
		
 

	
 
		slavesensors_process(parseResult);
 

	
 
		parse_gps_transmission();
 
		wdt_reset();
 
    }
 
}
 
\ No newline at end of file
master/master/master.cproj
Show inline comments
 
@@ -132,6 +132,18 @@
 
    <Compile Include="lib\ax25.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\boardtemp.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\boardtemp.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\i2c.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\i2c.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\led.c">
 
      <SubType>compile</SubType>
 
    </Compile>
0 comments (0 inline, 0 general)