From 9df3b4fde0e0b8d60375a139de50ae95aff8cf01 Mon Sep 17 00:00:00 2001 From: scateu Date: Tue, 14 Jul 2015 23:15:38 +0800 Subject: [PATCH 1/2] Add static location mode: "-l" input llh (degree) --- gpssim.c | 76 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/gpssim.c b/gpssim.c index cc3c433..ad3b0d0 100644 --- a/gpssim.c +++ b/gpssim.c @@ -12,6 +12,12 @@ #include #endif +#ifndef bool +typedef int bool; +#define true 1 +#define false 0 +#endif + #define MAX_CHAR (100) #define MAX_SAT (32) @@ -299,7 +305,7 @@ void xyz2llh(double *xyz, double *llh) return; } -/* + void llh2xyz(double *llh, double *xyz) { double n; @@ -333,7 +339,7 @@ void llh2xyz(double *llh, double *xyz) return; } -*/ + void ltcmat(double *llh, double t[3][3]) { double slat, clat; @@ -1071,6 +1077,7 @@ void usage(void) "Options:\n" " -e RINEX navigation file for GPS ephemerides (required)\n" " -u User motion file (required)\n" + " -l Latitude,Longitude,Height (static mode) eg: 30.286502,120.032669,100\n" " -o I/Q sampling data file (default: gpssim.bin)\n" " -s Sampling frequency [Hz] (default: 2600000)\n" " -b I/Q data format [8/16] (default: 8)\n"); @@ -1125,6 +1132,7 @@ int main(int argc, char *argv[]) int iumd; int numd; char umfile[MAX_CHAR]; + bool staticLocationMode = false; double xyz[USER_MOTION_SIZE][3]; char navfile[MAX_CHAR]; @@ -1153,7 +1161,7 @@ int main(int argc, char *argv[]) exit(1); } - while ((result=getopt(argc,argv,"e:u:o:s:b:"))!=-1) + while ((result=getopt(argc,argv,"e:u:l:o:s:b:"))!=-1) { switch (result) { @@ -1163,6 +1171,14 @@ int main(int argc, char *argv[]) case 'u': strcpy(umfile, optarg); break; + case 'l': + // static llh coordinate input mode. + // add by scateu@gmail.com + staticLocationMode = true; + sscanf(optarg,"%lf,%lf,%lf",&llh[0],&llh[1],&llh[2]); + llh[0] = llh[0] / R2D; // convert to RAD + llh[1] = llh[1] / R2D; // convert to RAD + break; case 'o': strcpy(outfile, optarg); break; @@ -1214,27 +1230,45 @@ int main(int argc, char *argv[]) // Receiver position //////////////////////////////////////////////////////////// - // Read user motion file - numd = readUserMotion(xyz, umfile); - if (numd==-1) + if (!staticLocationMode) { - printf("Failed to open user motion file.\n"); - exit(1); + // Read user motion file + numd = readUserMotion(xyz, umfile); + if (numd==-1) + { + printf("Failed to open user motion file.\n"); + exit(1); + } + else if (numd==0) + { + printf("Failed to read user motion data.\n"); + exit(1); + } + + printf("User motion data = %d\n", numd); + + // Initial location in Geodetic coordinate system + xyz2llh(xyz[0], llh); + + printf("xyz = %11.1f, %11.1f, %11.1f\n", xyz[0][0], xyz[0][1], xyz[0][2]); + printf("llh = %11.6f, %11.6f, %11.1f\n", llh[0]*R2D, llh[1]*R2D, llh[2]); + + } else { + // static llh coordinate input mode. "-l" + // add by scateu@gmail.com + printf("Using static location mode.\n"); + llh2xyz(llh,xyz[0]); // convert llh to xyz + printf("xyz = %11.1f, %11.1f, %11.1f\n", xyz[0][0], xyz[0][1], xyz[0][2]); + printf("llh = %11.6f, %11.6f, %11.1f\n", llh[0]*R2D, llh[1]*R2D, llh[2]); + + numd = USER_MOTION_SIZE; + for (int i=1;i Date: Tue, 14 Jul 2015 23:30:07 +0800 Subject: [PATCH 2/2] Add README and prompt for static llh coordinate mode '-l' --- README.md | 9 +++++++-- gpssim.c | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 42353f3..8a44333 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,14 @@ Doppler for the GPS satellites in view. This simulated range data is then used to generate the digitized I/Q samples for the GPS signal. The bladeRF command line interface requires I/Q pairs stored as signed -16-bit integers, while the hackrf_transfere supports signed bytes. +16-bit integers, while the hackrf_transfer supports signed bytes. ``` Usage: gps-sdr-sim [options] Options: -e RINEX navigation file for GPS ephemerides (required) - -u User motion file (required) + -u User motion file + -l Latitude,Longitude,Height (static mode) eg: 30.286502,120.032669,100 -o I/Q sampling data file (default: gpssim.bin) -s Sampling frequency [Hz] (default: 2600000) -b I/Q data format [8/16] (default: 8) @@ -55,6 +56,10 @@ For example: > gps-sdr-sim -e brdc3540.14n -u circle.csv -b 16 ``` +``` +> gps-sdr-sim -e brdc3540.14n -l 30.286502,120.032669,100 -b 16 +``` + ### Transmitting the samples The TX port of a particular SDR platform is connected to the GPS receiver diff --git a/gpssim.c b/gpssim.c index ad3b0d0..c61ad1b 100644 --- a/gpssim.c +++ b/gpssim.c @@ -1076,7 +1076,7 @@ void usage(void) printf("Usage: gps-sdr-sim [options]\n" "Options:\n" " -e RINEX navigation file for GPS ephemerides (required)\n" - " -u User motion file (required)\n" + " -u User motion file \n" " -l Latitude,Longitude,Height (static mode) eg: 30.286502,120.032669,100\n" " -o I/Q sampling data file (default: gpssim.bin)\n" " -s Sampling frequency [Hz] (default: 2600000)\n" @@ -1213,9 +1213,10 @@ int main(int argc, char *argv[]) exit(1); } - if (umfile[0]==0) + if (umfile[0]==0 && !staticLocationMode) { printf("User motion file is not specified.\n"); + printf("Or you may use -l to specify llh coordinate directly.\n"); exit(1); }