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/01/19 22:40] – rocketboy | 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 1: | Line 1: | ||
- | ===== C code to simulate NMEA output from a GPS in real time - with live Google | + | ===== C code to simulate NMEA output from a GPS in real time - with live Google |
- | The code here perfoms | + | The code here performs |
- | **GPSgen.c** - converts | + | **GPSgen.c** - converts source balloon track KML files into GPS NEMA logs (i.e. files containing $GPGGA messages etc.) |
- | **emulate.c** - outputs | + | **emulate.c** - outputs |
- | **outer.kml** is the outer kml shell that is configured to re-read the realtime | + | **outer.kml** is a kml shell that is configured to initiate the real-time display of the kml file generated by emulate |
- | 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. |
- | 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 realtime | + | 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 | ||
{{code: | {{code: | ||
- | Both programs are " | + | Both programs are " |
< | < | ||
Line 22: | Line 24: | ||
Both programs are written using stanard POSIX function calls - so should be portble to many environments including unix and DOS. | Both programs are written using stanard POSIX function calls - so should be portble to many environments including unix and DOS. | ||
+ | |||
Line 264: | Line 267: | ||
while(1) | while(1) | ||
{ | { | ||
- | i = fscanf(stdin," | + | i = scanf(" |
if (i != 1) | if (i != 1) | ||
{ | { | ||
Line 298: | 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 309: | Line 312: | ||
while(1) | while(1) | ||
{ | { | ||
- | i = fscanf(stdin,"%f , %f , %f",& | + | i = scanf("%f , %f , %f",& |
if (i != 3) | if (i != 3) | ||
Line 323: | Line 326: | ||
Output_NEMA(Now, | Output_NEMA(Now, | ||
- | look_for("</ | + | look_for("</ |
look_for("</ | look_for("</ | ||
- | return(0); | + | return 0; |
} | } | ||
Line 473: | 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 540: | 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 548: | 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 558: | Line 561: | ||
if ((Dir == ' | if ((Dir == ' | ||
- | return(Deg); | + | return Deg; |
else | else | ||
- | return(-Deg); // Assume ' | + | return -Deg; // Assume ' |
} | } | ||
Line 621: | Line 624: | ||
Second - BaseSec, | Second - BaseSec, | ||
- | return(GPGGA); | + | return GPGGA; |
} | } | ||
Line 631: | Line 634: | ||
fprintf(stderr," | fprintf(stderr," | ||
- | return(GPRMC); | + | return GPRMC; |
} | } | ||
Line 638: | Line 641: | ||
if (i > 0) | if (i > 0) | ||
{ // some fileds converted | { // some fileds converted | ||
- | return(GPVTG); | + | return GPVTG; |
} | } | ||
- | return(NONE); | + | return NONE; |
} | } | ||
Line 685: | Line 688: | ||
} | } | ||
- | return(0); // normal termination | + | return 0; // normal termination |
} | } | ||
code/emulator.1200782400.txt.gz · Last modified: 2008/07/19 23:31 (external edit)