Changeset - d96de01781be
[Not reviewed]
default
4 3 2
mkanning@CL-SEC241-10.cedarville.edu - 13 years ago 2012-11-15 14:02:59
mkanning@CL-SEC241-10.cedarville.edu
more changes to GPS tracker
9 files changed with 76 insertions and 921 deletions:
0 comments (0 inline, 0 general)
master/master/lib/aprs_trackuino/gps.c
Show inline comments
 
deleted file
master/master/lib/aprs_trackuino/gps.cpp
Show inline comments
 
deleted file
master/master/lib/aprs_trackuino/gps.h
Show inline comments
 
deleted file
master/master/lib/aprs_trackuino/trackuino.pde
Show inline comments
 
deleted file
master/master/lib/trackuinoGPS/gps.c
Show inline comments
 
@@ -208,108 +208,110 @@ void parse_lon(const char *token)
 
		degs[2] = token[2];
 
		degs[3] = '\0';
 
		new_lon = atof(degs) + atof(token + 3) / 60;
 
	}
 
	// APRS-ready longitude
 
	strncpy(new_aprs_lon, token, 8);
 
	new_aprs_lon[8] = '\0';
 
}
 

	
 
/// if this is hemisphere it is not needed
 
void parse_lon_hemi(const char *token)
 
{
 
	if (token[0] == 'W'){
 
		new_lon = -new_lon;
 
	}
 
	new_aprs_lon[8] = token[0];
 
	new_aprs_lon[9] = '\0';
 
}
 

	
 
/// we do not need to record speed
 
void parse_speed(const char *token)
 
{
 
	new_speed = atof(token);
 
}
 

	
 
/// we do not need to record course
 
void parse_course(const char *token)
 
{
 
	new_course = atof(token);
 
}
 

	
 
/// will use this to validate pressure readings
 
void parse_altitude(const char *token)
 
{
 
	new_altitude = atof(token);
 
}
 

	
 

	
 
//
 
// Exported functions
 
//
 
/// void zeroing of data. presumably to be called at start
 
void gps_setup() {
 
	strcpy(gps_time, "000000");
 
	strcpy(gps_aprs_lat, "0000.00N");
 
	strcpy(gps_aprs_lon, "00000.00E");
 
}
 

	
 
/// MKa GPS transmission parser
 
void parse_gps_transmission(char c){
 
/// MKa GPS transmission parser START
 
void parse_gps_transmission(char gpsToken){
 
	// i think c is the most recent character of transmission and is constantly 
 
	// tested if terminal character. if terminal then do parse on previous transmission.
 
	 
 
	// $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx
 
	if(c == '\n') //end of transmission sentence. may need more checks
 
	if(gpsToken == '$') //start of transmission sentence
 
	{
 
		
 
	}
 
}
 

	
 
/// MKa GPS transmission parser END
 

	
 
/// process gps transmission 
 
bool gps_decode(char c)
 
{
 
	int ret = false;
 

	
 
	switch(c) {
 
		case '\r':
 
		case '\n': // End of sentence
 
			if (num_tokens && our_checksum == their_checksum) { ///checksum is valid (good transmission)
 
				#ifdef DEBUG_GPS
 
				Serial.print(" (OK!) ");
 
				Serial.print(millis());
 
				#endif
 
				// Return a valid position only when we have two rmc and gga
 
				// messages with the same timestamp.
 
				switch (sentence_type) {
 
					case SENTENCE_UNK:
 
						break;    // Keeps gcc happy
 
					case SENTENCE_GGA:
 
						strcpy(gga_time, new_time);
 
						break;
 
					case SENTENCE_RMC:
 
						strcpy(rmc_time, new_time);
 
						break;
 
				}
 

	
 
				// Valid position scenario:
 
				//
 
				// 1. The timestamps of the two previous GGA/RMC sentences must match.
 
				//
 
				// 2. We just processed a known (GGA/RMC) sentence. Suppose the
 
				//    contrary: after starting up this module, gga_time and rmc_time
 
				//    are both equal (they're both initialized to ""), so (1) holds
 
				//    and we wrongly report a valid position.
 
				//
 
				// 3. The GPS has a valid fix. For some reason, the Venus 634FLPX
 
				//    reports 24 deg N, 121 deg E (the middle of Taiwan) until a valid
 
				//    fix is acquired:
 
				//
 
				//    $GPGGA,120003.000,2400.0000,N,12100.0000,E,0,00,0.0,0.0,M,0.0,M,,0000*69 (OK!)
 
				//    $GPGSA,A,1,,,,,,,,,,,,,0.0,0.0,0.0*30 (OK!)
 
				//    $GPRMC,120003.000,V,2400.0000,N,12100.0000,E,000.0,000.0,280606,,,N*78 (OK!)
 
				//    $GPVTG,000.0,T,,M,000.0,N,000.0,K,N*02 (OK!)
 

	
 
				if (sentence_type != SENTENCE_UNK &&      // Known sentence?
 
				strcmp(gga_time, rmc_time) == 0 &&    // RMC/GGA times match?
 
				active) {                             // Valid fix?
 
					// Atomically merge data from the two sentences
master/master/lib/trackuinoGPS/gps.h
Show inline comments
 
/* trackuino copyright (C) 2010  EA5HAV Javi
 
 *
 
 * This program is free software; you can redistribute it and/or
 
 * modify it under the terms of the GNU General Public License
 
 * as published by the Free Software Foundation; either version 2
 
 * of the License, or (at your option) any later version.
 
 *
 
 * This program is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 */
 

	
 
#ifndef __GPS_H__
 
#define __GPS_H__
 

	
 
#include <stdint.h>
 
#include <stdlib.h>
 
#include <string.h>
 
#include <stdbool.h>
 

	
 
extern char gps_time[7];       // HHMMSS
 
extern uint32_t gps_seconds;   // seconds after midnight
 
extern char gps_date[7];       // DDMMYY
 
extern float gps_lat;
 
extern float gps_lon;
 
extern char gps_aprs_lat[9];
 
extern char gps_aprs_lon[10];
 
extern float gps_course;
 
extern float gps_speed;
 
extern float gps_altitude;
 

	
 

	
 

	
 
void gps_setup();
 
bool gps_decode(char c);
 

	
 
#endif
 
enum t_sentence_type {
 
typedef enum t_sentence_type {
 
	SENTENCE_UNK,
 
	SENTENCE_GGA,
 
	SENTENCE_RMC
 
};
 
\ No newline at end of file
 
}t_sentence_type;
 
#endif
master/master/lib/trackuinoGPS/gpsMKa.c
Show inline comments
 
new file 100644
 
/*
 
 * gpsMKa.c
 
 *
 
 * Created: 11/15/2012 12:02:38 PM
 
 *  Author: mkanning
 
 */ 
 
#include <stdbool.h>
 

	
 
// has the transmission started 
 
bool transmissionBegin = false;
 

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

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

	
 
/// MKa GPS transmission parser START
 
void parse_gps_transmission(void){
 
	
 
	// 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
 
	if(byte == '$') //start of transmission sentence
 
	{
 
		transmissionBegin = true;
 
		bytesReceived = 1; //resets transmission if '$' is found
 
	}
 
	
 
	if (transmissionBegin)
 
	{
 
		if (bytesReceived == 3) //check 4th byte
 
		{
 
			if(byte == ' ')
 
			{
 
				
 
			}
 
		} 
 
		else
 
		{
 
		}
 
		//use a state machine implementation rather than this
 
	}
 
	
 
}
 

	
 
/// MKa GPS transmission parser END
 
\ No newline at end of file
master/master/lib/trackuinoGPS/gpsMKa.h
Show inline comments
 
new file 100644
 
/*
 
 * gpsMKa.h
 
 *
 
 * 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
 
// states
 
#define 
 
 
 
#endif /* GPSMKA_H_ */
 
\ No newline at end of file
master/master/master.cproj
Show inline comments
 
@@ -150,70 +150,65 @@
 
    <Compile Include="lib\sd\byteordering.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\sd\fat.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\sd\fat.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\sd\fat_config.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\sd\partition.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\sd\partition.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\sd\partition_config.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\sd\sd-reader_config.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\sd\sd_raw.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\sd\sd_raw.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\sd\sd_raw_config.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\serial.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\serial.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\serparser.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\serparser.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\trackuinoGPS\config.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\trackuinoGPS\gps.c">
 
    <Compile Include="lib\trackuinoGPS\gpsMKa.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\trackuinoGPS\gps.h">
 
    <Compile Include="lib\trackuinoGPS\gpsMKa.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="master.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
  </ItemGroup>
 
  <ItemGroup>
 
    <Folder Include="lib" />
 
    <Folder Include="lib\trackuinoGPS" />
 
    <Folder Include="lib\sd" />
 
  </ItemGroup>
 
  <ItemGroup>
 
    <None Include="lib\trackuinoGPS\trackuino.pde">
 
      <SubType>compile</SubType>
 
    </None>
 
  </ItemGroup>
 
  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
 
</Project>
 
\ No newline at end of file
0 comments (0 inline, 0 general)