code:emulator
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
code:emulator [2008/07/19 23:33] – external edit 127.0.0.1 | code:emulator [2021/03/04 14:52] (current) – [C code to simulate NMEA output from a GPS in real time - with live Google Earth Display] rocketboy | ||
---|---|---|---|
Line 2: | Line 2: | ||
The code here performs the following: | The code here performs the following: | ||
- | **GPSgen.c** - converts source balloon track KML files into a GPS NEMA logs (i.e. files containing $GPGGA messages etc.) | + | **GPSgen.c** - converts source balloon track KML files into GPS NEMA logs (i.e. files containing $GPGGA messages etc.) |
**emulate.c** - outputs a GPS log to the PC serial port - pacing the output to simulate real time gps output - at the same time //emulate// creates a real-time KML file so you can see where the payload is currently flying using Google Earth. | **emulate.c** - outputs a GPS log to the PC serial port - pacing the output to simulate real time gps output - at the same time //emulate// creates a real-time KML file so you can see where the payload is currently flying using Google Earth. | ||
**outer.kml** is a kml shell that is configured to initiate the real-time display of the kml file generated by emulate (open // | **outer.kml** is a kml shell that is configured to initiate the real-time display of the kml file generated by emulate (open // | ||
Together these programs allow real time testing of payloads with a GPS simulation - as if the payload was flying through the coordinates in the source KML. This allows cut-down algorithms etc. to be checked. | Together these programs allow real time testing of payloads with a GPS simulation - as if the payload was flying through the coordinates in the source KML. This allows cut-down algorithms etc. to be checked. | ||
+ | |||
+ | Some test NMEA files can be found [[code: | ||
The screenshot below shows the emulation of the Pegasus 1 flight running in the top left DOS window, the generated NMEA in the bottom left DOS window against a background of a Google Earth real-time display of the flight. | The screenshot below shows the emulation of the Pegasus 1 flight running in the top left DOS window, the generated NMEA in the bottom left DOS window against a background of a Google Earth real-time display of the flight. | ||
Line 265: | Line 267: | ||
while(1) | while(1) | ||
{ | { | ||
- | i = fscanf(stdin," | + | i = scanf(" |
if (i != 1) | if (i != 1) | ||
{ | { | ||
Line 299: | Line 301: | ||
// get first LineString co-ordinate as launch position | // get first LineString co-ordinate as launch position | ||
- | i = fscanf(stdin,"%f , %f , %f",& | + | i = scanf("%f , %f , %f",& |
if (i !=3) | if (i !=3) | ||
{ | { | ||
fprintf(stderr," | fprintf(stderr," | ||
- | return(1); // abnormal termination | + | return 1; // abnormal termination |
} | } | ||
Line 310: | Line 312: | ||
while(1) | while(1) | ||
{ | { | ||
- | i = fscanf(stdin,"%f , %f , %f",& | + | i = scanf("%f , %f , %f",& |
if (i != 3) | if (i != 3) | ||
Line 328: | Line 330: | ||
look_for("</ | look_for("</ | ||
- | return(0); | + | return 0; |
} | } | ||
Line 474: | Line 476: | ||
do | do | ||
{ | { | ||
- | if (fgets(pch, size - 1, stdin) == NULL) | + | if (fgets(pch, size, stdin) == NULL) |
- | return(0); | + | return 0; |
} | } | ||
while(buf[0] != ' | while(buf[0] != ' | ||
- | return(1); // line read OK | + | return 1; // line read OK |
} | } | ||
Line 541: | Line 543: | ||
point = (int)((bearing + 11.25) / 22.5); // calculate a compas point 0 - 16 for 0 - 360 | point = (int)((bearing + 11.25) / 22.5); // calculate a compas point 0 - 16 for 0 - 360 | ||
point &= 0x000F; // wrap 16 to 0 | point &= 0x000F; // wrap 16 to 0 | ||
- | return( & | + | return & |
} | } | ||
Line 549: | Line 551: | ||
double Time_to_Sec(int Hours, int Minutes, double Seconds) | double Time_to_Sec(int Hours, int Minutes, double Seconds) | ||
{ | { | ||
- | return(Seconds + ((double)Minutes * 60.0) + ((double)Hours * 3600.0)); | + | return Seconds + ((double)Minutes * 60.0) + ((double)Hours * 3600.0); |
} | } | ||
Line 559: | Line 561: | ||
if ((Dir == ' | if ((Dir == ' | ||
- | return(Deg); | + | return Deg; |
else | else | ||
- | return(-Deg); // Assume ' | + | return -Deg; // Assume ' |
} | } | ||
Line 622: | Line 624: | ||
Second - BaseSec, | Second - BaseSec, | ||
- | return(GPGGA); | + | return GPGGA; |
} | } | ||
Line 632: | Line 634: | ||
fprintf(stderr," | fprintf(stderr," | ||
- | return(GPRMC); | + | return GPRMC; |
} | } | ||
Line 639: | Line 641: | ||
if (i > 0) | if (i > 0) | ||
{ // some fileds converted | { // some fileds converted | ||
- | return(GPVTG); | + | return GPVTG; |
} | } | ||
- | return(NONE); | + | return NONE; |
} | } | ||
Line 686: | Line 688: | ||
} | } | ||
- | return(0); // normal termination | + | return 0; // normal termination |
} | } | ||
code/emulator.1216510404.txt.gz · Last modified: 2010/02/06 09:38 (external edit)