📄 ogr_msgdump.c
字号:
exactly by one second (511500 units of c_511500). However, after enough sats have been acquired, the GPS gets an idea of its internal clock drift, and (in my unit) 511500 units of c_511500 correspond to about 1.00002 sec of the receiver time. These 20 microseconds per second correspond to aprox. 6000 m/sec, the drift of the internal clock reflected in the pseudoranges. Monitoring this field we can check our clock drift. Also, as I have already said, the increments of c_511500 are not exactly 511500, as the GPS tries to take each measurement synced to a GPS second. Name svidPosition Byte 37 Type ByteDescription Space Vehicle ID (PRN-1) Statistics:Record 0x0d ( 345) L= 8 bytes Record 0x0e ( 1) L= 12 bytes Record 0x11 ( 1) L= 16 bytes Record 0x14 ( 304) L= 84 bytes Record 0x17 ( 55) L= 52 bytes Record 0x27 ( 209) L= 2 bytes Record 0x28 ( 209) L= 4 bytes Record 0x36 ( 6998) L= 9 bytes Record 0x37 ( 523) L= 33 bytes Record 0x38 ( 2376) L= 37 bytes Record 0xff ( 1) L= 27 bytes -----------------------------------------------------------------*//* ------------------------------ includes -------------------------------- */#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>#include <time.h>#include <assert.h>#include <unistd.h>//#include <sys/io.h>#include <sys/types.h>#include <sys/mman.h>#include <sys/stat.h>#include <fcntl.h>#include <signal.h>#include "port.h"#include "ogr_defines.h"#include "ogr_structs.h"#include "ogr_prototypes.h"#include "ogr_globals.h"/* ------------------------------- defines -------------------------------- *//* ----------------------------- prototypes ------------------------------- *//* ------------------------------ globals --------------------------------- *//* ----------------------------- procedures ------------------------------- */int write_msg_0x11( FILE *fp, double lat, double lon){ char id, len; int nof = 0; if ( !fp) return (0); id = 0x11; nof = fwrite ( &id, sizeof( char), 1, fp); len = 16; nof += fwrite ( &len, sizeof( char), 1, fp); nof += sizeof( double) * fwrite ( &lat, sizeof( double), 1, fp); nof += sizeof( double) * fwrite ( &lon, sizeof( double), 1, fp); return (0);}int write_msg_0xff( FILE *fp){ char id, len, str[14]; UINT16 shrt; int nof = 0; if ( !fp) return (0); id = 0xff; nof = fwrite ( &id, sizeof( char), 1, fp); len = 18; nof += fwrite ( &len, sizeof( char), 1, fp); shrt = 0x17; nof += fwrite ( &shrt, sizeof( UINT16), 1, fp); shrt = 0x1; nof += fwrite ( &shrt, sizeof( UINT16), 1, fp); strncpy( str, "OpenGPSRec ", 13); str[13] = '\0'; nof += fwrite ( str, sizeof( char), 14, fp); return (0);}/* * date & time info */int write_msg_0x0e( FILE *fp, struct tm *gmt){ char id, len, chr; UINT16 shrt; int nof = 0; if ( !fp) return (0); id = 0x0e; nof = fwrite ( &id, sizeof( char), 1, fp); len = 8; nof += fwrite ( &len, sizeof( char), 1, fp); chr = (char) gmt->tm_mon+1; nof += fwrite ( &chr, sizeof( char), 1, fp); chr = (char) gmt->tm_mday; nof += fwrite ( &chr, sizeof( char), 1, fp); shrt = (UINT16) gmt->tm_year + 1900; nof += fwrite ( &shrt, sizeof( UINT16), 1, fp); chr = (char) gmt->tm_hour; nof += fwrite ( &chr, sizeof( char), 1, fp); chr = 0; nof += fwrite ( &chr, sizeof( char), 1, fp); chr = (char) gmt->tm_min; nof += fwrite ( &chr, sizeof( char), 1, fp); chr = (char) gmt->tm_sec; nof += fwrite ( &chr, sizeof( char), 1, fp); return (0);}/* * 50 Hz counter and navigation word (30 bit) */static int write_msg_0x36( FILE *fp, unsigned long tow, int sfm, int word, INT16 prn, unsigned long msg){ char id, len, chr; int nof = 0; unsigned long count50hz; if ( !fp) return (0); id = 0x36; nof = fwrite ( &id, sizeof( char), 1, fp); len = 9; nof += fwrite ( &len, sizeof( char), 1, fp);// count50hz = tow * 50 + (word - 1) * 30 + (sfm-1) * 300;// *** FIXME: week roll-over? ***// count50hz = tow * 50 + word * 30 + (sfm-1) * 300 - 300; count50hz = tow * 50 + word * 30 - 300; nof += sizeof( long) * fwrite ( &count50hz, sizeof( long), 1, fp); nof += sizeof( long) * fwrite ( &msg, sizeof( long), 1, fp); chr = (char) (prn-1); nof += fwrite ( &chr, sizeof( char), 1, fp); if ( nof != 11) return (-1); return (0);}/* 0 long phase counter 4 char track byte 5 char unknown 6 char unknown 7 char unknown 8 word doppler 10 long integrated phase 14 double pseudorange 22 long 511500 Hz counter 26 word signal strength 28 double time of week 36 char PRN-1 */ /* * tracking info */int write_msg_0x38( FILE *fp, int ch, double pseudorange, unsigned long phase_counter, double rec_time){ char id, len, chr; int nof = 0; INT16 strength, doppler; static unsigned long counter_511500Hz[NOFCHN]; unsigned long intphase; static double tow_init = -1.0; if ( !fp) return (0); if ( tow_init < 0.0) tow_init = RT_Ctrl->tow_tic_count / 10.0; id = 0x38; nof = fwrite ( &id, sizeof( char), 1, fp); len = 37; nof += fwrite ( &len, sizeof( char), 1, fp);// now the data ... nof += sizeof( long) * fwrite ( &phase_counter, sizeof( long), 1, fp); chr = 0xff; nof += fwrite ( &chr, sizeof( char), 1, fp); chr = 0; nof += fwrite ( &chr, sizeof( char), 1, fp); nof += fwrite ( &chr, sizeof( char), 1, fp); nof += fwrite ( &chr, sizeof( char), 1, fp); doppler = 0; nof += sizeof( INT16) * fwrite ( &doppler, sizeof( INT16), 1, fp); intphase = 0; nof += sizeof( long) * fwrite ( &intphase, sizeof( long), 1, fp); nof += sizeof( double) * fwrite ( &pseudorange, sizeof( double), 1, fp); counter_511500Hz[ch] += 511500; nof += sizeof( long) * fwrite ( &(counter_511500Hz[ch]), sizeof( long), 1, fp); strength = 9; nof += sizeof( INT16) * fwrite ( &strength, sizeof( INT16), 1, fp);// tow = Ctrl->tow_tic_count / 10.0; nof += sizeof( double) * fwrite ( &rec_time, sizeof( double), 1, fp); chr = (char) (Chan[ch].prn-1); nof += fwrite ( &chr, sizeof( char), 1, fp); if ( nof != 39) return (-1); return (0);}void write_frames_to_file( FILE *fp, int ch, int sfm, unsigned long tow, unsigned long sf[]){ int word; if ( !fp) return;#if 0 gotoxy( 1, 22+ch); printf( "(%d) sfr = %d, tow = %ld", ch, sfm, tow); printf( "\n");#endif for ( word=1; word<=10; word++) { write_msg_0x36( fp, tow, sfm, word, Chan[ch].prn, sf[word]); }#if 0 { int j; gotoxy( 1, 22+ch); printf( "(%d)", ch); for(j=1;j<=10;j++) printf( " %08lx", Msg[ch].subframe_parity[j]); printf( "\n"); for(j=1;j<=10;j++) printf( " %08lx", sf[j]); printf( "\n"); }#endif return;}/* ------------------------------- end of file ---------------------------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -