Changeset - 3a560af409fa
[Not reviewed]
default
0 4 0
mkanning@CL-SEC241-10.cedarville.edu - 13 years ago 2012-11-15 11:14:47
mkanning@CL-SEC241-10.cedarville.edu
going through trackuino code
4 files changed with 80 insertions and 24 deletions:
0 comments (0 inline, 0 general)
master/master/lib/trackuinoGPS/config.h
Show inline comments
 
@@ -23,7 +23,7 @@
 
// THIS IS THE TRACKUINO FIRMWARE CONFIGURATION FILE. YOUR CALLSIGN AND
 
// OTHER SETTINGS GO HERE.
 
//
 
// NOTE: all pins are Arduino based, not the Atmega chip. Mapping:
 
// NOTE: all pins are Arduino based, not the Atmega chip. Mapping: this could be an issue !! ??
 
// http://www.arduino.cc/en/Hacking/PinMapping
 
// --------------------------------------------------------------------------
 

	
master/master/lib/trackuinoGPS/gps.c
Show inline comments
 
@@ -35,11 +35,7 @@ static void parse_altitude(const char *t
 
// Module types
 
typedef void (*t_nmea_parser)(const char *token);
 

	
 
enum t_sentence_type {
 
  SENTENCE_UNK,
 
  SENTENCE_GGA,
 
  SENTENCE_RMC
 
};
 

	
 

	
 

	
 
// Module constants
 
@@ -80,10 +76,18 @@ static const t_nmea_parser rmc_parsers[]
 
  NULL              // E/W
 
};
 

	
 

	
 

	
 
static const int NUM_OF_UNK_PARSERS = (sizeof(unk_parsers) / sizeof(t_nmea_parser));
 
static const int NUM_OF_GGA_PARSERS = (sizeof(gga_parsers) / sizeof(t_nmea_parser));
 
static const int NUM_OF_RMC_PARSERS = (sizeof(rmc_parsers) / sizeof(t_nmea_parser));
 

	
 
enum t_sentence_type {
 
	SENTENCE_UNK,
 
	SENTENCE_GGA,
 
	SENTENCE_RMC
 
};
 

	
 
// Module variables
 
static t_sentence_type sentence_type = SENTENCE_UNK;
 
static bool at_checksum = false;
 
@@ -116,18 +120,22 @@ float gps_speed = 0;
 
float gps_altitude = 0;
 

	
 
// Module functions
 
/// convert hex to binary ??
 
unsigned char from_hex(char a) 
 
{
 
  if (a >= 'A' && a <= 'F')
 
	if (a >= 'A' && a <= 'F'){
 
    return a - 'A' + 10;
 
  else if (a >= 'a' && a <= 'f')
 
	}else if (a >= 'a' && a <= 'f'){
 
    return a - 'a' + 10;
 
  else if (a >= '0' && a <= '9')
 
	}else if (a >= '0' && a <= '9'){
 
    return a - '0';
 
  else
 
	}else{
 
    return 0;
 
}
 
}
 

	
 
/// determine what type of message is being sent ??
 
/// we only send one message type so may not be needed
 
void parse_sentence_type(const char *token)
 
{
 
  if (strcmp(token, "$GPGGA") == 0) {
 
@@ -139,9 +147,11 @@ void parse_sentence_type(const char *tok
 
  }
 
}
 

	
 

	
 
void parse_time(const char *token)
 
{
 
  // Time can have decimals (fractions of a second), but we only take HHMMSS
 
	///we prolly want the entire time (unix time) ??
 
  strncpy(new_time, token, 6);
 
  // Terminate string
 
  new_time[6] = '\0';
 
@@ -152,18 +162,22 @@ void parse_time(const char *token)
 
    ((new_time[4] - '0') * 10 + (new_time[5] - '0'));
 
}
 

	
 
/// not sure of exact purpose, besides the name...
 
void parse_status(const char *token)
 
{
 
  // "A" = active, "V" = void. We shoud disregard void sentences
 
  if (strcmp(token, "A") == 0)
 
	// "A" = active, "V" = void. We should disregard void sentences
 
	if (strcmp(token, "A") == 0){
 
    active = true;
 
  else
 
	}else{
 
    active = false;
 
}
 
}
 

	
 
/// this is a vital function
 
void parse_lat(const char *token)
 
{
 
  // Parses latitude in the format "DD" + "MM" (+ ".M{...}M")
 
	/// not sure about the format...
 
  char degs[3];
 
  if (strlen(token) >= 4) {
 
    degs[0] = token[0];
 
@@ -176,17 +190,21 @@ void parse_lat(const char *token)
 
  new_aprs_lat[7] = '\0';
 
}
 

	
 
/// if this is hemisphere it is not needed. we are in the north.
 
void parse_lat_hemi(const char *token)
 
{
 
  if (token[0] == 'S')
 
	if (token[0] == 'S'){
 
    new_lat = -new_lat;
 
	}
 
  new_aprs_lat[7] = token[0];
 
  new_aprs_lon[8] = '\0';
 
}
 

	
 
/// another vital function
 
void parse_lon(const char *token)
 
{
 
  // Longitude is in the format "DDD" + "MM" (+ ".M{...}M")
 
	/// again not sure of formatting...
 
  char degs[4];
 
  if (strlen(token) >= 5) {
 
    degs[0] = token[0];
 
@@ -200,24 +218,29 @@ void parse_lon(const char *token)
 
  new_aprs_lon[8] = '\0';
 
}
 

	
 
/// if this is hemisphere it is not needed
 
void parse_lon_hemi(const char *token)
 
{
 
  if (token[0] == 'W')
 
	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);
 
@@ -227,27 +250,37 @@ void parse_altitude(const char *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){
 
	// 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
 
	{
 
				
 
	}
 
}
 
/// 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) {
 
		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've got two rmc and gga
 
				// Return a valid position only when we have two rmc and gga
 
        // messages with the same timestamp.
 
        switch (sentence_type) {
 
          case SENTENCE_UNK:
 
@@ -295,8 +328,9 @@ bool gps_decode(char c)
 
        }
 
      }
 
#ifdef DEBUG_GPS
 
      if (num_tokens)
 
			if (num_tokens){
 
        Serial.println();
 
			}
 
#endif
 
      at_checksum = false;        // CR/LF signals the end of the checksum
 
      our_checksum = '$';         // Reset checksums
 
@@ -319,16 +353,19 @@ bool gps_decode(char c)
 
      // Parse token
 
      switch (sentence_type) {
 
        case SENTENCE_UNK:
 
          if (num_tokens < NUM_OF_UNK_PARSERS && unk_parsers[num_tokens])
 
					if (num_tokens < NUM_OF_UNK_PARSERS && unk_parsers[num_tokens]){
 
            unk_parsers[num_tokens](token);
 
					}
 
          break;
 
        case SENTENCE_GGA:
 
          if (num_tokens < NUM_OF_GGA_PARSERS && gga_parsers[num_tokens])
 
					if (num_tokens < NUM_OF_GGA_PARSERS && gga_parsers[num_tokens]){
 
            gga_parsers[num_tokens](token);
 
					}
 
          break;
 
        case SENTENCE_RMC:
 
          if (num_tokens < NUM_OF_RMC_PARSERS && rmc_parsers[num_tokens])
 
					if (num_tokens < NUM_OF_RMC_PARSERS && rmc_parsers[num_tokens]){
 
            rmc_parsers[num_tokens](token);
 
					}
 
          break;
 
      }
 

	
master/master/lib/trackuinoGPS/gps.cpp
Show inline comments
 
@@ -15,6 +15,8 @@
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 */
 

	
 
/*<--delete this
 

	
 
#include "config.h"
 
#include "gps.h"
 
#include <WProgram.h>
 
@@ -117,6 +119,7 @@ float gps_speed = 0;
 
float gps_altitude = 0;
 

	
 
// Module functions
 
/// converts from hex to binary ??
 
unsigned char from_hex(char a) 
 
{
 
  if (a >= 'A' && a <= 'F')
 
@@ -129,6 +132,7 @@ unsigned char from_hex(char a)
 
    return 0;
 
}
 

	
 
/// determines what type of message is being sent ??
 
void parse_sentence_type(const char *token)
 
{
 
  if (strcmp(token, "$GPGGA") == 0) {
master/master/master.cproj
Show inline comments
 
@@ -192,13 +192,28 @@
 
    <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">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\trackuinoGPS\gps.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)