UKHAS Wiki

UK High Altitude Society

User Tools

Site Tools


code:emulator

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
code:emulator [2008/07/19 23:33] – external edit 127.0.0.1code: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 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// file from Google Earth to initiate the real-time display). **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// file from Google Earth to initiate the real-time display).
  
 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 source KML can be from a previous balloon flight - the output of a balloon trajectory forecast - or can be hand crafted to test something specific.  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 source KML can be from a previous balloon flight - the output of a balloon trajectory forecast - or can be hand crafted to test something specific. 
 +
 +Some test NMEA files can be found [[code:NMEA|here]]
  
 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,"%128s",buf); // read a non whitespace from the input+ i = scanf("%128s",buf); // read a non whitespace from the input
  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",&FromLon,&FromLat,&FromAlt);+ i = scanf("%f , %f , %f",&FromLon,&FromLat,&FromAlt);
  if (i !=3)  if (i !=3)
  {  {
  fprintf(stderr,"1st coordinate not 3D\n");  fprintf(stderr,"1st coordinate not 3D\n");
- return(1); // abnormal termination+ return 1; // abnormal termination
  }  }
  
Line 310: Line 312:
  while(1)  while(1)
  {  {
- i = fscanf(stdin,"%f , %f , %f",&ToLon,&ToLat,&ToAlt);+ i = scanf("%f , %f , %f",&ToLon,&ToLat,&ToAlt);
  
  if (i != 3)  if (i != 3)
Line 328: Line 330:
  look_for("</LineString>"); // look for closing </LineString> token  look_for("</LineString>"); // look for closing </LineString> token
  
- 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] != '$'); // loop until NMEA valid line read  while(buf[0] != '$'); // loop until NMEA valid line read
   
- 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&points[point * 4]);   + return &points[point * 4];   
 } }
  
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 == 'N') || (Dir == 'E'))  if ((Dir == 'N') || (Dir == 'E'))
- return(Deg);+ return Deg;
  else  else
- return(-Deg); // Assume 'W' or 'S'+ return -Deg; // Assume 'W' or 'S'
 } }
  
Line 622: Line 624:
  Second - BaseSec,LatDeg,LonDeg,Alt,Bearing,deg_to_compass16(Bearing),Distance);  Second - BaseSec,LatDeg,LonDeg,Alt,Bearing,deg_to_compass16(Bearing),Distance);
  
- return(GPGGA);+ return GPGGA;
  }  }
  
Line 632: Line 634:
  fprintf(stderr," Co=%5.1f %.3s Kh=%.1f%",Course,deg_to_compass16(Course),SpeedKn * 1.852);  fprintf(stderr," Co=%5.1f %.3s Kh=%.1f%",Course,deg_to_compass16(Course),SpeedKn * 1.852);
  
- 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)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki