1 diff -ur gps3d-1.20/Makefile gps3d-1.20-pere/Makefile
2 --- gps3d-1.20/Makefile Fri Mar 29 17:15:14 2002
3 +++ gps3d-1.20-pere/Makefile Sat Jan 1 23:29:03 2005
7 -CFLAGS= -g0 -O99 -fomit-frame-pointer -I. -DNDEBUG -DX11
8 +CFLAGS= -g -O99 -fomit-frame-pointer -I. -DNDEBUG -DX11
11 #CFLAGS= -g3 -O0 -Wall -I. -D_DEBUG
22 ${CC} ${LDFLAGS} -o gpsd ${GPSD_OBJ} -lm
25 - ${CC} ${LDFLAGS} -o viz ${VIZ_OBJ} -L/usr/X11R6/lib -lGL -lX11 -lXext -lm
26 + ${CC} ${LDFLAGS} -o viz ${VIZ_OBJ} -L/usr/X11R6/lib -lGL -lX11 -lXext -lgps -lm
29 -rm -f *.o core ${ALL}
30 diff -ur gps3d-1.20/viz_app.h gps3d-1.20-pere/viz_app.h
31 --- gps3d-1.20/viz_app.h Fri Mar 29 17:15:14 2002
32 +++ gps3d-1.20-pere/viz_app.h Sun Jan 2 00:23:59 2005
35 void newChannel(void*,int (*callback)(void*),void*);
38 +int gpsInput(void *data);
39 void gpsCharInput(uint8_t);
41 void gpsOutput(const char *);
43 void paintSquareInfo(double,double,double,double,double,double);
44 void newGGA(const uint8_t*,const uint8_t*,const uint8_t*);
45 void newFix(const uint8_t*,const uint8_t*,const uint8_t*,const uint8_t*,const uint8_t*);
46 +void newFixValue(double latitude, double longitude, double timestamp);
47 void paintGreatcircle(double,double,double,double,int,double*,double*);
51 void paintSatellites();
52 void newSolution(const uint8_t [][81],int);
53 +void newSolutionValue(const int prn_used[], int nFields);
54 +void newSatelliteFixValue(int prn, double elevation, double azimuth);
58 diff -ur gps3d-1.20/viz_brush.cpp gps3d-1.20-pere/viz_brush.cpp
59 --- gps3d-1.20/viz_brush.cpp Fri Mar 29 17:15:14 2002
60 +++ gps3d-1.20-pere/viz_brush.cpp Sat Jan 1 22:39:56 2005
64 uint8_t c= *(buffer++);
70 diff -ur gps3d-1.20/viz_fix.cpp gps3d-1.20-pere/viz_fix.cpp
71 --- gps3d-1.20/viz_fix.cpp Fri Mar 29 17:15:14 2002
72 +++ gps3d-1.20-pere/viz_fix.cpp Sat Jan 1 23:15:46 2005
78 -const uint8_t *latitude,
79 -const uint8_t *latitudeSign,
80 -const uint8_t *longitude,
81 -const uint8_t *longitudeSign,
82 -const uint8_t *timeStamp
84 +void newFixValue(double latitude, double longitude, double timestamp)
88 - if(parseNMEAAngle(latitude,latitudeSign,&tmpLa)<0) return;
89 - if(parseNMEAAngle(longitude,longitudeSign,&tmpLo)<0) return;
90 - if(tmpLa!=la || tmpLo!=lo)
91 + if(latitude!=la || longitude!=lo)
93 - double hr= (timeStamp[0]-'0')*10 + (timeStamp[1]-'0');
94 - double mm= (timeStamp[2]-'0')*10 + (timeStamp[3]-'0');
95 - double ss= (timeStamp[4]-'0')*10 + (timeStamp[5]-'0');
96 - ss+= (timeStamp[6]-'0')/10.0 + (timeStamp[7]-'0')/100.0;
113 double dist= system::sqrt(pos[0] + pos[1] + pos[2]);
114 getHTTPMap(0,la,lo,dist);
119 +const uint8_t *latitude,
120 +const uint8_t *latitudeSign,
121 +const uint8_t *longitude,
122 +const uint8_t *longitudeSign,
123 +const uint8_t *timeStamp
128 + if(parseNMEAAngle(latitude,latitudeSign,&tmpLa)<0) return;
129 + if(parseNMEAAngle(longitude,longitudeSign,&tmpLo)<0) return;
132 + double hr= (timeStamp[0]-'0')*10 + (timeStamp[1]-'0');
133 + double mm= (timeStamp[2]-'0')*10 + (timeStamp[3]-'0');
134 + double ss= (timeStamp[4]-'0')*10 + (timeStamp[5]-'0');
135 + ss+= (timeStamp[6]-'0')/10.0 + (timeStamp[7]-'0')/100.0;
138 + newFixValue(tmpLa, tmpLo, ss);
142 diff -ur gps3d-1.20/viz_gps.cpp gps3d-1.20-pere/viz_gps.cpp
143 --- gps3d-1.20/viz_gps.cpp Fri Mar 29 17:15:14 2002
144 +++ gps3d-1.20-pere/viz_gps.cpp Sun Jan 2 00:25:59 2005
148 #include <viz_system.h>
158 - if(c==0 || c=='*') break;
161 + if(c==0 || c=='*') break;
169 - c-= (c>'9' ? 'A'-10 : '0');
170 - if(c<0 || c>15) break;
174 + c-= (c>'9' ? 'A'-10 : '0');
175 + if(c<0 || c>15) break;
180 return sum2!=(uint32_t)sum1;
181 @@ -123,101 +124,89 @@
188 +static int process_status(struct gps_data_t *status)
191 - static int state= 0;
192 - static uint8_t buffer[81];
196 - if(c=='\n') state= 1;
199 - if(c=='$') state= 2;
200 - else if(c=='\n') state= 1;
214 - if(p-buffer>=80) state= 0;
217 +#if 0 /* Not supported yet */
219 + newGGA(utc, quality, altitude);
220 + newTrackFix(latitude,latitudesign, longitude, longitudesign);
221 + newWaypoint(latitude, latitudeSign, longitude, longitudeSign,
224 + if (status->latlon_stamp.changed)
226 + system::error(0,"info: Got new GPS pos\n");
227 + newFixValue(status->latitude, status->longitude,
228 + status->latlon_stamp.last_refresh);
229 + status->latlon_stamp.changed = 0;
232 + if (status->satellite_stamp.changed)
234 + system::error(0,"info: Got %d GPS satellite fixes\n",
235 + status->satellites);
236 + for (int i = 0; i < status->satellites; ++i)
238 + newSatelliteFixValue(status->PRN[i], status->elevation[i],
239 + status->azimuth[i]);
241 + status->satellite_stamp.changed = 0;
243 + if (status->fix_quality_stamp.changed)
245 + int prn_used[MAXCHANNELS];
246 + system::error(0,"info: Got GPS satellite solution (%d)\n",
247 + status->satellites_used);
248 + for (int i = 0; i < status->satellites; ++i)
250 + prn_used[i] = status->PRN[i];
252 + newSolutionValue(status->used, status->satellites_used);
253 + status->fix_quality_stamp.changed = 0;
259 +static struct gps_data_t *status = NULL;
261 +int gpsInput(void *data)
264 + if (gps_poll(status))
267 - int r= system::readSocket(gpsSocket(),&c,1);
268 - if(r==1) gpsCharInput(c);
270 + return process_status(status);
277 +void *gpsSocket(void)
280 - static void *socket;
284 - const char *sport= getPort();
285 - const char *server= getServer();
286 - if(1!=system::sscanf(sport,"%d",&port)) port= 2222;
287 - socket= system::makeSocket(server,port);
288 - if(socket==(void*)-1) system::error(0,"warning: can't connect to GPS server %s:%d\n",server,port);
289 - else system::error(0,"info: Connected to GPS server %s:%d\n",server,port);
291 + char *port= (char*)getPort();
292 + char *server= (char*)getServer();
293 + status = gps_open(server, DEFAULT_GPSD_PORT);
295 + system::error(0,"warning: can't connect to GPS server %s:%s\n",server,port);
298 + system::error(0,"info: Connected to GPS server %s:%s\n",server,port);
299 + gps_query(status, "w+x\n");
305 + return (void*)status->gps_fd;
310 +/* gpsd do not accept input, and can't handle talkback. Disabled. */
316 - system::sprintf((char*)buf,"$PMGNCMD,%s*XX\r\n",msg);
327 - static const uint8_t *tohex= (const uint8_t *)"0123456789ABCDEF";
328 - p[0]= tohex[(sum>>4)&0xF];
329 - p[1]= tohex[(sum>>0)&0xF];
334 - int r= system::writeSocket(gpsSocket(),buf,n);
336 - else if(system::lastError()!=system::eAgain && system::lastError()!=system::eInterrupt)
338 - system::error(0,"warning: can't write to gps socket\n");
344 void gpsLoadTrackFile(
345 diff -ur gps3d-1.20/viz_satellite.cpp gps3d-1.20-pere/viz_satellite.cpp
346 --- gps3d-1.20/viz_satellite.cpp Fri Nov 24 01:19:49 2000
347 +++ gps3d-1.20-pere/viz_satellite.cpp Sat Jan 1 23:49:05 2005
349 #include <viz_system.h>
351 #define TRAJSIZE 10000
352 -static int trajSizes[50];
353 -static int trajColor[50];
354 -static double lastSatAzimuth[50];
355 -static double lastSatElevation[50];
356 -static double satX[50][TRAJSIZE];
357 -static double satY[50][TRAJSIZE];
358 -static double satZ[50][TRAJSIZE];
359 -static double satT[50][TRAJSIZE];
360 +#define MAXSATELLITES 50
361 +static int trajSizes[MAXSATELLITES];
362 +static int trajColor[MAXSATELLITES];
363 +static double lastSatAzimuth[MAXSATELLITES];
364 +static double lastSatElevation[MAXSATELLITES];
365 +static double satX[MAXSATELLITES][TRAJSIZE];
366 +static double satY[MAXSATELLITES][TRAJSIZE];
367 +static double satZ[MAXSATELLITES][TRAJSIZE];
368 +static double satT[MAXSATELLITES][TRAJSIZE];
370 // earthRadius = 6 378 136 meters
371 // GPS satellites orbit at 20 180 000 meters altitude (from ground)= 26558136 from earth center
376 +void newSolutionValue(const int prn_used[], int nFields)
378 + int tj[MAXSATELLITES];
379 + system::memset(tj,0,sizeof(tj));
380 + if(nFields>15) nFields=15;
381 + for(int j=3; j<nFields; ++j)
383 + tj[prn_used[j]] = 1;
386 + if(system::memcmp(trajColor,tj,sizeof(tj)))
388 + system::memcpy(trajColor,tj,sizeof(tj));
394 const uint8_t sol[][81],
399 - int size= 50*sizeof(int);
400 - system::memset(tj,0,size);
401 + int tj[MAXSATELLITES];
402 + system::memset(tj,0,sizeof(tj));
403 if(nFields>15) nFields=15;
404 for(int j=3; j<nFields; ++j)
410 - if(system::memcmp(trajColor,tj,size))
411 + if(system::memcmp(trajColor,tj,sizeof(tj)))
413 - system::memcpy(trajColor,tj,size);
414 + system::memcpy(trajColor,tj,sizeof(tj));
418 @@ -106,30 +123,18 @@
419 return sphereIntersect(result,0,aSquared,r,d);
422 -void newSatelliteFix(
424 -const uint8_t *elevation,
425 -const uint8_t *azimuth,
428 +void newSatelliteFixValue(int prn, double elevation, double azimuth)
433 - if(lastStamp()<0) return;
434 - if(1!=system::sscanf((const char*)prn,"%d",&num)) return;
435 - if(1!=system::sscanf((const char*)elevation,"%lf",&e)) return;
436 - if(1!=system::sscanf((const char*)azimuth,"%lf",&a)) return;
439 - if(a>360.0) return;
440 - if(num>=50) return;
441 + if(elevation>90.0) return;
442 + if(azimuth>360.0) return;
443 + if(prn>=MAXSATELLITES) return;
445 - int pnum= trajSizes[num];
446 + int pnum= trajSizes[prn];
449 - lastSatAzimuth[num]!=a ||
450 - lastSatElevation[num]!=e
451 + lastSatAzimuth[prn]!=azimuth ||
452 + lastSatElevation[prn]!=elevation
456 @@ -138,23 +143,40 @@
469 int mod= pnum%TRAJSIZE;
470 - satX[num][mod]= sat[0];
471 - satY[num][mod]= sat[1];
472 - satZ[num][mod]= sat[2];
473 - satT[num][mod]= lastStamp();
474 - trajSizes[num]= ++pnum;
475 + satX[prn][mod]= sat[0];
476 + satY[prn][mod]= sat[1];
477 + satZ[prn][mod]= sat[2];
478 + satT[prn][mod]= lastStamp();
479 + trajSizes[prn]= ++pnum;
484 +void newSatelliteFix(
486 +const uint8_t *elevation,
487 +const uint8_t *azimuth,
494 + if(lastStamp()<0) return;
495 + if(1!=system::sscanf((const char*)prn,"%d",&num)) return;
496 + if(1!=system::sscanf((const char*)elevation,"%lf",&e)) return;
497 + if(1!=system::sscanf((const char*)azimuth,"%lf",&a)) return;
499 + newSatelliteFixValue(num, e, a);
502 static inline void satPos(
506 void paintSatellites()
508 - for(int i=0;i<50;++i)
509 + for(int i=0;i<MAXSATELLITES;++i)
512 int nPoints= trajSizes[i];