Changeset - e54e67fc99cd
[Not reviewed]
Merge default
0 2 0
ethanzonca@CL-SEC241-08.cedarville.edu - 12 years ago 2012-11-15 15:50:44
ethanzonca@CL-SEC241-08.cedarville.edu
Merge
2 files changed with 113 insertions and 14 deletions:
0 comments (0 inline, 0 general)
master/master/lib/trackuinoGPS/gpsMKa.c
Show inline comments
 
@@ -2,47 +2,149 @@
 
 * gpsMKa.c
 
 *
 
 * Created: 11/15/2012 12:02:38 PM
 
 *  Author: mkanning
 
 */ 
 
#include <stdbool.h>
 

	
 
// has the transmission started 
 
bool transmissionBegin = false;
 
#include <avr/io.h>
 
#include "gpsMKa.h"
 

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

	
 
//data (and checksum) of most recent transmission
 
char data[16];
 

	
 
//used to skip over bytes during parse
 
int skipBytes = 0;
 

	
 
//variables to store data from transmission
 
uint8_t tramsmissionType;
 
uint8_t timestamp[9]; //hhmmss.ss
 
uint8_t latitude[8]; //llll.ll,a
 
uint8_t longitude[8]; //yyyyy.yy,a
 
uint8_t quality;
 
uint8_t numSatellites;
 
uint8_t hdop;
 
uint8_t altitude;
 
uint8_t wgs84Height;
 
uint8_t lastUpdated;
 
uint8_t stationID;
 
uint8_t checksum;
 

	
 
// transmission state machine
 
enum decodeState { 
 
	INITIALIZE=0,
 
	GET_TYPE,
 
	GGA_TIME,
 
	GGA_LATITUDE,
 
	GGA_LONGITUDE,
 
	GGA_QUALITY,
 
	GGA_SATELLITES,
 
	GGA_HDOP,
 
	GGA_ALTITUDE,
 
	GGA_WGS84,
 
	GGA_LAST_UPDATE,
 
	GGA_STATION_ID,
 
	RMC_TIME
 
}decodeState;
 

	
 
/// MKa GPS transmission parser START
 
void parse_gps_transmission(void){
 
	bytesReceived++;
 
	
 
	// Pull byte off of the buffer
 
	char byte = uart_getchar();
 
	
 
	// $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx
 
	//        ^8        ^18       ^28                               
 
	if(byte == '$') //start of transmission sentence
 
	{
 
		transmissionBegin = true;
 
		bytesReceived = 1; //resets transmission if '$' is found
 
		decodeState = GET_TYPE;
 
	}
 
	
 
	if (transmissionBegin)
 
	//parse transmission type
 
	else if (decodeState == GET_TYPE)
 
	{
 
		if (bytesReceived == 3) //check 4th byte
 
		if (bytesReceived == 4 ) //check 4th byte
 
		{
 
			tramsmissionType = byte;
 
		}
 
		
 
		if(byte = ',') //end of type data
 
		{
 
			if(byte == ' ')
 
			if (tramsmissionType == 'G')
 
			{
 
				decodeState = GGA_TIME;
 
			} 
 
			else if(tramsmissionType == 'R')
 
			{
 
				decodeState = RMC_TIME; //not implemented
 
			}
 
			else
 
			{
 
				
 
			}
 
		} 
 
				//reset 
 
				decodeState = INITIALIZE;
 
				bytesReceived = 0;
 
			}			
 
		}
 
	}
 
	
 
	//parse GGA timestamp
 
	else if (decodeState == GGA_TIME)
 
	{
 
		if (byte = ',')//end of timestamp data
 
		{
 
			decodeState = GGA_LATITUDE;
 
			skipBytes = 0; //prep for next phase of parse
 
		}
 
		else //store the byte of timestamp data
 
		{
 
			timestamp[bytesReceived-7] = byte; //adjust number of bytes to fit array
 
		}
 
	}
 
	
 
	//parse GGA latitude data
 
	else if (decodeState == GGA_LATITUDE)
 
	{
 
		if (byte == ',' && skipBytes == 0) //discard this byte
 
		{
 
			skipBytes = 1;
 
		}
 
		else if (byte == ',') //end of latitude data
 
		{
 
			decodeState = GGA_LONGITUDE;
 
			skipBytes = 0; //prep for next phase of parse
 
		}
 
		else
 
		{
 
			latitude[bytesReceived-17] = byte; //adjust number of bytes to fit array
 
		}	
 
	}
 
	
 
	//parse GGA longitude data
 
	else if (decodeState == GGA_LONGITUDE)
 
	{
 
		if (byte == ',' && skipBytes == 0) //discard this byte
 
		{
 
			skipBytes = 1;
 
		}
 
		//use a state machine implementation rather than this
 
		else if (byte == ',') //end of latitude data
 
		{
 
			decodeState = GGA_QUALITY;
 
		}
 
		else
 
		{
 
			longitude[bytesReceived-17] = byte; //adjust number of bytes to fit array
 
		}	
 
	}
 
	
 
	//parse GGA quality data
 
	else if (decodeState = GGA_QUALITY)
 
	{
 
		quality = byte;
 
	}
 
	
 
}
 

	
 
/// MKa GPS transmission parser END
 
\ No newline at end of file
master/master/lib/trackuinoGPS/gpsMKa.h
Show inline comments
 
@@ -8,11 +8,8 @@
 
 
#ifndef GPSMKA_H_
 
#define GPSMKA_H_
 
#define GGA_MESSAGE
 
#define RMC_MESSAGE
 
#define UKN_MESSAGE
 
// states
 
#define 
 
 
 
#endif /* GPSMKA_H_ */
 
\ No newline at end of file
0 comments (0 inline, 0 general)