From 0ca4e2ae7c9a8210d883e1bbb3e2d1e0ad257c30 Mon Sep 17 00:00:00 2001
From: TimEverett <tim.everett3@gmail.com>
Date: Mon, 29 Oct 2018 16:20:10 -0600
Subject: [PATCH] 1) Restore u-blox cycle slip handling details lost in merge
 of 2.4.3 b30 changes 2) Change default Galileo nav messages to "any" 3) Minor
 debug trace formatting changes

---
 src/ephemeris.c |  2 +-
 src/postpos.c   |  2 +-
 src/rcv/ublox.c | 10 +++++++++-
 src/solution.c  |  6 +++---
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/ephemeris.c b/src/ephemeris.c
index f57f52c..0bf6163 100644
--- a/src/ephemeris.c
+++ b/src/ephemeris.c
@@ -95,7 +95,7 @@
 
 /* ephemeris selections ------------------------------------------------------*/
 static int eph_sel[]={ /* GPS,GLO,GAL,QZS,BDS,SBS */
-    0,0,1,0,0,0
+    0,0,0,0,0,0
 };
 
 /* variance by ura ephemeris -------------------------------------------------*/
diff --git a/src/postpos.c b/src/postpos.c
index 0c16405..8a651f4 100644
--- a/src/postpos.c
+++ b/src/postpos.c
@@ -240,7 +240,7 @@ static int inputobs(obsd_t *obs, int solq, const prcopt_t *popt)
     gtime_t time={0};
     int i,nu,nr,n=0;
     
-    trace(3,"infunc  : revs=%d iobsu=%d iobsr=%d isbs=%d\n",revs,iobsu,iobsr,isbs);
+    trace(3,"\ninfunc  : revs=%d iobsu=%d iobsr=%d isbs=%d\n",revs,iobsu,iobsr,isbs);
     
     if (0<=iobsu&&iobsu<obss.n) {
         settime((time=obss.data[iobsu].time));
diff --git a/src/rcv/ublox.c b/src/rcv/ublox.c
index 389dd7a..a524e05 100644
--- a/src/rcv/ublox.c
+++ b/src/rcv/ublox.c
@@ -384,10 +384,12 @@ static int decode_rxmrawx(raw_t *raw)
         slip=lockt==0||lockt*1E-3<raw->lockt[sat-1][f-1]||
              halfc!=raw->halfc[sat-1][f-1];
         if (std_slip>0&&cpstd>=std_slip) slip=LLI_SLIP;
+        if (slip) raw->lockflag[sat-1][f-1]=slip;
         raw->lockt[sat-1][f-1]=lockt*1E-3;
         raw->halfc[sat-1][f-1]=halfc;
         /* LLI: bit1=slip,bit2=half-cycle-invalid, bit7=half-cycle-subtract */
-        LLI=(slip?LLI_SLIP:0)|(halfc?LLI_HALFS:0)|(!halfv&&L!=0.0?LLI_HALFC:0);
+        LLI=(halfc?LLI_HALFS:0)|(!halfv&&L!=0.0?LLI_HALFC:0);
+        if (L!=0.0) LLI|=raw->lockflag[sat-1][f-1]>0.0?LLI_SLIP:0;
 
         for (j=0;j<n;j++) {
             if (raw->obs.data[j].sat==sat) break;
@@ -413,6 +415,7 @@ static int decode_rxmrawx(raw_t *raw)
         raw->obs.data[j].SNR[f-1]=(unsigned char)(cn0*4);
         raw->obs.data[j].LLI[f-1]=(unsigned char)LLI;
         raw->obs.data[j].code[f-1]=(unsigned char)code;
+        if (L!=0.0) raw->lockflag[sat-1][f-1]=0;
     }
     raw->time=time;
     raw->obs.n=n;
@@ -1114,6 +1117,7 @@ static int decode_timtm2(raw_t *raw)
     unsigned long towMsR, towSubMsR, towMsF, towSubMsF, accEst;
     int time, timeBase, newRisingEdge, newFallingEdge;
     unsigned char *p=raw->buff+6;
+    double tr[6],tf[6];
 
     trace(4, "decode_timtm2: len=%d\n", raw->len);
 
@@ -1148,6 +1152,10 @@ static int decode_timtm2(raw_t *raw)
     } else {
         raw->obs.flag = 0;
     }
+    time2epoch(gpst2time(wnR,towMsR*1E-3+towSubMsR*1E-9),tr);
+    time2epoch(gpst2time(wnF,towMsF*1E-3+towSubMsF*1E-9),tf);
+    trace(3,"time mark rise: %f:%f:%.3f\n",tr[3],tr[4],tr[5]);
+    trace(3,"time mark fall: %f:%f:%.3f\n",tf[3],tf[4],tf[5]);
     return 0;
 }
 
diff --git a/src/solution.c b/src/solution.c
index 95c0d75..583b668 100644
--- a/src/solution.c
+++ b/src/solution.c
@@ -1111,7 +1111,7 @@ static int outecef(unsigned char *buff, const char *s, const sol_t *sol,
     const char *sep=opt2sep(opt);
     char *p=(char *)buff;
     
-    trace(3,"outecef:\n");
+    trace(3,"outecef:\n\n");
     
     p+=sprintf(p,"%s%s%14.4f%s%14.4f%s%14.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f",
                s,sep,sol->rr[0],sep,sol->rr[1],sep,sol->rr[2],sep,sol->stat,sep,
@@ -1137,7 +1137,7 @@ static int outpos(unsigned char *buff, const char *s, const sol_t *sol,
     const char *sep=opt2sep(opt);
     char *p=(char *)buff;
     
-    trace(3,"outpos  :\n");
+    trace(3,"outpos  :\n\n");
     
     ecef2pos(sol->rr,pos);
     soltocov(sol,P);
@@ -1181,7 +1181,7 @@ static int outenu(unsigned char *buff, const char *s, const sol_t *sol,
     const char *sep=opt2sep(opt);
     char *p=(char *)buff;
     
-    trace(3,"outenu  :\n");
+    trace(3,"outenu  :\n\n");
     
     for (i=0;i<3;i++) rr[i]=sol->rr[i]-rb[i];
     ecef2pos(rb,pos);
-- 
GitLab