From f560c966af4852d101abf29d16aa67afe2a04111 Mon Sep 17 00:00:00 2001 From: Shigeru KANEMOTO Date: Wed, 1 Jul 2015 14:22:25 +0900 Subject: [PATCH 1/5] Refactor the main loop --- gpssim.c | 96 +++++++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 50 deletions(-) diff --git a/gpssim.c b/gpssim.c index a984459..f900edb 100644 --- a/gpssim.c +++ b/gpssim.c @@ -1138,7 +1138,7 @@ int main(int argc, char *argv[]) int i; int nsat; channel_t chan[MAX_CHAN]; - double elvmask = 0.0/R2D; + double elvmask = 0.0/R2D; int isbf,iwrd; unsigned long tow; @@ -1155,8 +1155,8 @@ int main(int argc, char *argv[]) #endif void *iq_buff = NULL; - gpstime_t grx0,grx1; - range_t rho0,rho1; + gpstime_t grx; + range_t rho_backup[MAX_SAT]; double delt; // = 1.0/SAMP_FREQ; int isamp; @@ -1374,7 +1374,7 @@ int main(int argc, char *argv[]) //////////////////////////////////////////////////////////// // Initial reception time - grx0 = g0; + grx = g0; for (i=0; i Configuration Properties -> C/C++ -> Language -> Open MP Support -> Yes (/openmp) for (i=0; i>4); // 12-bit bladeRF -> 8-bit HackRF - else - ((short*)iq_buff)[isamp] += chan[i].iq_buff[isamp]; - } - } if (data_format==SC08) + { + for (isamp=0; isamp<2*iq_buff_size; isamp++) + { + char sample = 0; + for (i=0; i>4); // 12-bit bladeRF -> 8-bit HackRF + ((signed char*)iq_buff)[isamp] = sample; + } fwrite(iq_buff, 1, 2*iq_buff_size, fp); - else + } else { + for (isamp=0; isamp<2*iq_buff_size; isamp++) + { + short sample = 0; + for (i=0; i Date: Wed, 1 Jul 2015 14:23:09 +0900 Subject: [PATCH 2/5] typo --- gpssim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gpssim.c b/gpssim.c index f900edb..f60043e 100644 --- a/gpssim.c +++ b/gpssim.c @@ -1482,14 +1482,14 @@ int main(int argc, char *argv[]) ip = chan[i].dataBit * chan[i].codeCA * cosTable512[iTable]; qp = chan[i].dataBit * chan[i].codeCA * sinTable512[iTable]; - // Sotre I/Q samples into buffer + // Store I/Q samples into buffer chan[i].iq_buff[isamp*2] = (short)(ip>>1); chan[i].iq_buff[isamp*2+1] = (short)(qp>>1); #else ip = chan[i].dataBit * chan[i].codeCA * cos(2.0*PI*chan[i].carr_phase); qp = chan[i].dataBit * chan[i].codeCA * sin(2.0*PI*chan[i].carr_phase); - // Sotre I/Q samples into buffer + // Store I/Q samples into buffer chan[i].iq_buff[isamp*2] = (short)(ADC_GAIN*ip); chan[i].iq_buff[isamp*2+1] = (short)(ADC_GAIN*qp); #endif From edc28a01e786f5064d370059614bfa9fcaf5cbd3 Mon Sep 17 00:00:00 2001 From: Shigeru KANEMOTO Date: Wed, 1 Jul 2015 18:03:02 +0900 Subject: [PATCH 3/5] Test --- .gitignore | 2 +- Makefile | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 479b8d7..575a5fc 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,7 @@ gps-sdr-sim-lut *.dSYM/ # Output -gpssim.bin +*.bin # Temporary files *.swp diff --git a/Makefile b/Makefile index 660a519..bd4727f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Makefile for Linux etc. -.PHONY: all clean +.PHONY: all clean test test-lut test-nolut all: gps-sdr-sim gps-sdr-sim-lut SHELL=/bin/bash @@ -18,4 +18,17 @@ gpssim-lut.o: gpssim.c ${CC} -c -D_SINE_LUT ${CFLAGS} $< -o $@ clean: - rm -f gpssim.o gpssim-lut.o gps-sdr-sim gps-sdr-sim-lut + rm -f gpssim.o gpssim-lut.o gps-sdr-sim gps-sdr-sim-lut *.bin + +test: test-lut +test-lut: gps-sdr-sim-lut + time ./gps-sdr-sim-lut -e brdc3540.14n -u circle.csv -b 8 + test "$$(md5sum gpssim.bin | awk '{print $$1}')" == "39a577af659440605c4ebbe178f4c4e3" + time ./gps-sdr-sim-lut -e brdc3540.14n -u circle.csv -b 16 + test "$$(md5sum gpssim.bin | awk '{print $$1}')" == "bdd460893ad73b19412fc1757e62ccf9" + +test-nolut: gps-sdr-sim + time ./gps-sdr-sim -e brdc3540.14n -u circle.csv -b 8 + test "$$(md5sum gpssim.bin | awk '{print $$1}')" == "f4beb0857f82038d0465eb9934009edd" + time ./gps-sdr-sim -e brdc3540.14n -u circle.csv -b 16 + test "$$(md5sum gpssim.bin | awk '{print $$1}')" == "10403720cb3483515f470fdea09e02ed" From f9e7d862f80a15b982330e2e3ddaa2cee1aca1cc Mon Sep 17 00:00:00 2001 From: Shigeru KANEMOTO Date: Wed, 1 Jul 2015 18:27:51 +0900 Subject: [PATCH 4/5] Unused variable. --- gpssim.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gpssim.c b/gpssim.c index f60043e..4fd89af 100644 --- a/gpssim.c +++ b/gpssim.c @@ -244,7 +244,6 @@ void codegen(int *ca, int prn) int g1[1023],g2[1023],r1[10],r2[10],c1,c2; int i,j; - int sv = prn-1; if (prn<1 || prn>32) return; From ea69a3f60aeb4a71eaeceb07c94ff75240e46015 Mon Sep 17 00:00:00 2001 From: Shigeru KANEMOTO Date: Wed, 1 Jul 2015 21:37:02 +0900 Subject: [PATCH 5/5] Remove 'xyz' variable. --- gpssim.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/gpssim.c b/gpssim.c index 4fd89af..09d1172 100644 --- a/gpssim.c +++ b/gpssim.c @@ -1127,7 +1127,7 @@ int main(int argc, char *argv[]) ephem_t eph[MAX_SAT]; gpstime_t g0; - double llh[3],xyz[3]; + double llh[3]; double pos[3],vel[3],clk[2]; double tmat[3][3]; double los[3]; @@ -1268,15 +1268,10 @@ int main(int argc, char *argv[]) printf("User motion data = %d\n", numd); - // Initial location - xyz[0] = umd[0][0]; - xyz[1] = umd[0][1]; - xyz[2] = umd[0][2]; + // Initial location in Geodetic coordinate system + xyz2llh(umd[0], llh); - // Geodetic coordinate system - xyz2llh(xyz, llh); - - printf("xyz = %11.1f, %11.1f, %11.1f\n", xyz[0], xyz[1], xyz[2]); + printf("xyz = %11.1f, %11.1f, %11.1f\n", umd[0][0], umd[0][1], umd[0][2]); printf("llh = %11.6f, %11.6f, %11.1f\n", llh[0]*R2D, llh[1]*R2D, llh[2]); //////////////////////////////////////////////////////////// @@ -1325,11 +1320,7 @@ int main(int argc, char *argv[]) if (eph[sv].vflg==1) { satpos(eph[sv], g0, pos, vel, clk); - - los[0] = pos[0] - xyz[0]; - los[1] = pos[1] - xyz[1]; - los[2] = pos[2] - xyz[2]; - + subVect(los, pos, umd[0]); ecef2neu(los, tmat, neu); neu2azel(azel, neu);