// this is a generic logger that does checksum testing so the data written should be always good // Assumes a sirf III chipset logger attached to pin 0 and 1 #include #include #include "SdCard.h" #include "Fat16.h" // this function will return the number of bytes currently free in RAM int freeRam(void) { extern int __bss_end; extern int *__brkval; int free_memory; if((int)__brkval == 0) { free_memory = ((int)&free_memory) - ((int)&__bss_end); } else { free_memory = ((int)&free_memory) - ((int)__brkval); } return free_memory; } void ROM_putstring(const char *str, uint8_t nl) { uint8_t i; for (i=0; pgm_read_byte(&str[i]); i++) { Serial.print(pgm_read_byte(&str[i])); } if (nl) { Serial.print('\n'); Serial.print('\r'); } } #define putstring(x) ROM_putstring(PSTR(x), 0) #define putstring_nl(x) ROM_putstring(PSTR(x), 1) void sleep_sec(uint8_t x); // power saving modes #define SLEEPDELAY 0 // how long to sleep before reading another NMEA sentence #define TURNOFFGPS 0 // probably only want to do this if the sleep delay > 60 or so #define LOG_RMC_FIXONLY 1 // log only when we get RMC's with fix? SdCard card; Fat16 fd; #define led1Pin 4 // LED1 connected to digital pin 4 #define led2Pin 3 // LED2 connected to digital pin 3 #define powerPin 2 // GPS power control // set the RX_BUFFER_SIZE to 32! #define BUFFSIZE 75 // we buffer one NMEA sentense at a time, 83 bytes is longer than the max length char buffer[BUFFSIZE]; // this is the double buffer uint8_t bufferidx = 0; #define LOG_RMC 1 // essential location data #define RMC_ON "$PSRF103,4,0,1,1*21\r\n" // the command we send to turn RMC on (1 hz rate) //#define RMC_ON "$PSRF103,4,0,10,1*11\r\n" // 1/30 hz #define RMC_OFF "$PSRF103,4,0,0,1*20\r\n" // the command we send to turn RMC off #define LOG_GGA 0 // contains fix, hdop & vdop data #define GGA_ON "$PSRF103,0,0,1,1*25\r\n" // the command we send to turn GGA on (1 hz rate) #define GGA_OFF "$PSRF103,0,0,0,1*24\r\n" // the command we send to turn GGA off #define LOG_GSA 0 // satelite data #define GSA_ON "$PSRF103,2,0,1,1*27\r\n" // the command we send to turn GSA on (1 hz rate) #define GSA_OFF "$PSRF103,2,0,0,1*26\r\n" // the command we send to turn GSA off #define LOG_GSV 0 // detailed satellite data #define GSV_ON "$PSRF103,3,0,1,1*26\r\n" // the command we send to turn GSV on (1 hz rate) #define GSV_OFF "$PSRF103,3,0,0,1*27\r\n" // the command we send to turn GSV off #define LOG_GLL 0 // Loran-compatibility data // this isnt output by default #define USE_WAAS 1 // useful in US, but slower fix #define WAAS_ON "$PSRF151,1*3F\r\n" // the command for turning on WAAS #define WAAS_OFF "$PSRF151,0*3E\r\n" // the command for turning off WAAS uint8_t fix = 0; // current fix data // read a Hex value and return the decimal equivalent uint8_t parseHex(char c) { if (c < '0') return 0; if (c <= '9') return c - '0'; if (c < 'A') return 0; if (c <= 'F') return (c - 'A')+10; } uint8_t i; // blink out an error code void error(uint8_t errno) { while(1) { for (i=0; i