Update of /cvsroot/firebug/fireboard/fireboard/sensors/leadtek9546
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26542
Added Files:
Makefile leadtek_9546.c
Removed Files:
HPLUART1M.nc HPLUARTC1.nc
Log Message:
c file for dealing with various aspects of checksums and
programming strings added. Test code can be written against the
code in this file.
--- NEW FILE: Makefile ---
clean:
rm -rf *~ *.exe *.bak
--- NEW FILE: leadtek_9546.c ---
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include "leadtek_9546.h"
unsigned char
crc(char * data, int size) {
unsigned char cs = 0;
int i;
//Omit $-character
for (i=1; i<size; i++) {
cs = cs ^((unsigned char)data[i]);
}
return cs;
}
int main(int argc, char ** argv) {
char data[] = {"$LTC,1000,0"};
char data1[] = {"$GPGSV,3,3,11,03,19,314,21,29,19,044,39,02,15,293,24"};
char data2[] = {"$GPGGA,023129.762,3754.1755,N,12218.2682,W,1,08,1.1,-19.4,M,,,,0000"};
const uint8_t gps_gga_mask_crc[] = {"$LTC,NMEA," NMEA_GGA_MASK};
const uint8_t gps_rmc_mask_crc[] = {"$LTC,NMEA," NMEA_RMC_MASK};
const uint8_t gps_syncmode_on_crc[] = {"$LTC,SYNCMODE,1"};
const uint8_t gps_syncmode_off_crc[] = {"$LTC,SYNCMODE,0"};
const uint8_t gps_test_crc[] = {"$LTC,1552,1"};
printf("string: %s, crc: %x\n",data,crc(data,strlen(data)));
printf("string: %s, crc: %x\n",data1,crc(data1,strlen(data1)));
printf("string: %s, crc: %x\n",data2,crc(data2,strlen(data2)));
printf("string: %s, crc: %x\n",gps_syncmode_off_crc,crc(gps_syncmode_off_crc,strlen(gps_syncmode_off_crc)));
printf("string: %s, crc: %x\n",gps_test_crc,crc(gps_test_crc,strlen(gps_test_crc)));
return 0;
}
// Will add these in later.
#if 0
/**
* This is an example for how to parse an NMEA GGA string.
* It doubles as test code, and can be used in nesc with
* minor changes.
*/
#include <stdio.h>
static const unsigned char gga_string[] = ["$GPGGA,200831.748,3754.1771,N,12218.2665,W,1,06,1.2,-0.8,M,,,,0000*34"];
int
main(int argc, char ** argv) {
int i;
unsigned char * p;
return 0;
}
int
main(int argc, char ** argv) {
char nofix[] = {"$GPGGA,205121.168,,,,,9,23,,,M,,,,0000*3F"};
int num_commas,j;
const char foo[] = {"df" "\n"};
printf("%s",foo);
printf("%d\n",'0'-'0');
printf("%d\n",'1'-'0');
printf("%d\n",'2'-'0');
printf("%d\n",'3'-'0');
j = 0;
num_commas = 0;
while (num_commas < 6) {
printf("%c",nofix[j]);
if (nofix[j] == ',') {
num_commas++;
}
j++;
}
printf("\n%c\n",nofix[j]);
return 0;
}
#include <stdio.h>
int
main(int argc, char ** argv) {
unsigned short foo = 13888;
unsigned char bar[] = {"3754.1763"};
float dec_secs = 0;
printf("cast foo to float: %f\n", (float)foo);
dec_secs = 10*(bar[2]-'0') + (bar[3]-'0') + 0.1*(bar[5]-'0')
+ 0.01*(bar[6]-'0')
+ 0.001*(bar[7]-'0') + 0.0001*(bar[8]-'0');
printf("dec_secs: %f\n",dec_secs);
// Write some test code for packing and
// extracting NSEW
/*
NS = (gga_fields[3][0] == 'N') ? 1 : 0;
EW = (gga_fields[5][0] == 'W') ? 1 : 0;
pGGA->NSEWind = EW | (NS<<4); // eg. Status = 000N000E = 00010000
gga_log_array[10] = pGGA->NSEWind;
*/
return 0;
}
#endif
--- HPLUART1M.nc DELETED ---
--- HPLUARTC1.nc DELETED ---
|