Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

preepend a number to make logs sortable by actual millisecond (gps is…

… late)
  • Loading branch information...
commit baeab9375cf7b892dc5201645ad01302dfa2aa55 1 parent fb8e134
tz authored July 13, 2012

Showing 1 changed file with 89 additions and 0 deletions. Show diff stats Hide diff stats

  1. 89  logsync.c
89  logsync.c
... ...
@@ -0,0 +1,89 @@
  1
+#include <stdio.h>
  2
+#include <string.h>
  3
+
  4
+char syncbuf[1024][256];
  5
+
  6
+int main( int argc, char *argv[] ) {
  7
+    char buf[256];
  8
+    int cnt, mstik, newtik, i, jcnt, gcnt, jtik, gtik, icnt;
  9
+    icnt = 0;
  10
+    while( !feof(stdin) ) {
  11
+	memset( buf, 0, sizeof(buf) );
  12
+	gets(buf);
  13
+	printf( "%06d%s\r\n", icnt++, buf );
  14
+	if( buf[3] == '=' )
  15
+	    break;
  16
+    }
  17
+    cnt = 0;
  18
+    //    strcpy( syncbuf[cnt++], buf );
  19
+    while( !feof(stdin) ) {
  20
+	memset( buf, 0, sizeof(buf) );
  21
+	gets(buf);
  22
+	if( buf[3] == 'J' ) {
  23
+	    strcpy(syncbuf[cnt++], buf );
  24
+	    continue;
  25
+	}
  26
+	printf( "%06d%s\r\n", icnt++, buf );
  27
+	if( buf[3] == '$' )
  28
+	    break;
  29
+    }
  30
+    mstik = atoi(buf);
  31
+    while( !feof(stdin) ) {
  32
+	memset( buf, 0, sizeof(buf) );
  33
+	gets(buf);
  34
+	if( buf[3] == 'J' ) {
  35
+	    strcpy(syncbuf[cnt++], buf );
  36
+	    continue;
  37
+	}
  38
+	newtik = atoi(buf);
  39
+	if(newtik < mstik )
  40
+	    break;
  41
+	mstik = newtik;
  42
+	printf( "%06d%s\r\n", icnt++, buf );
  43
+    }
  44
+    gtik = newtik;
  45
+    jcnt = 100000;
  46
+    gcnt = 100000;
  47
+    icnt = 100000;
  48
+    jtik = 0;
  49
+    for( i = 0 ; i < cnt; i++ ) {
  50
+	jtik = atoi(syncbuf[i]);
  51
+	printf( "%06d%s\r\n", jcnt, syncbuf[i] );
  52
+    }
  53
+    i = 0;
  54
+    while( !feof(stdin) ) {
  55
+	memset( buf, 0, sizeof(buf) );
  56
+	gets(buf);
  57
+	switch( buf[3] ) {
  58
+	case '$':
  59
+	    newtik = atoi(buf);
  60
+	    if( newtik < gtik )
  61
+		gcnt++;
  62
+	    gtik = newtik;
  63
+	    if( !strncmp( "$GPGSA,", &buf[3], 7  ) )
  64
+		icnt = gcnt; // PPS follows this as it is one-per and after the RMC
  65
+	    printf( "%06d%s\r\n", gcnt, buf );
  66
+	    break;
  67
+	case '=':
  68
+	    if( icnt < jcnt )
  69
+		icnt = jcnt;
  70
+	    printf( "%06d%s\r\n", ++icnt, buf );
  71
+	    break;
  72
+	case 'J':
  73
+	    newtik = atoi(buf);
  74
+	    if( newtik < jtik )
  75
+		jcnt++;
  76
+	    jtik = newtik;
  77
+	    printf( "%06d%s\r\n", jcnt, buf );
  78
+	    if( jcnt < icnt ) {
  79
+		jcnt = icnt;
  80
+		jtik = 0;
  81
+	    }
  82
+	    break;
  83
+        default:
  84
+	    printf( "???%06d%s", jcnt, buf );
  85
+	    break;
  86
+	}
  87
+    }
  88
+
  89
+}

0 notes on commit baeab93

Please sign in to comment.
Something went wrong with that request. Please try again.