From 8021908d0e46ab168fc06cd13d321c422a461d5e Mon Sep 17 00:00:00 2001 From: Lenhart Date: Thu, 21 Jan 2021 21:32:41 +0100 Subject: [PATCH] fixed a few typos, intendations, and simplified if cases --- gpssim.h | 24 +++++++++---------- player/limeplayer.c | 56 ++++++++++++++++++--------------------------- 2 files changed, 34 insertions(+), 46 deletions(-) diff --git a/gpssim.h b/gpssim.h index be86905..9f26e53 100644 --- a/gpssim.h +++ b/gpssim.h @@ -78,7 +78,7 @@ #define SC08 (8) #define SC16 (16) -#define EPHEM_ARRAY_SIZE (13) // for daily GPS broadcast ephemers file (brdc) +#define EPHEM_ARRAY_SIZE (13) // for daily GPS broadcast ephemeris file (brdc) /*! \brief Structure representing GPS time */ typedef struct @@ -87,7 +87,7 @@ typedef struct double sec; /*!< second inside the GPS \a week */ } gpstime_t; -/*! \brief Structure repreenting UTC time */ +/*! \brief Structure representing UTC time */ typedef struct { int y; /*!< Calendar year */ @@ -106,7 +106,7 @@ typedef struct gpstime_t toc; /*!< Time of Clock */ gpstime_t toe; /*!< Time of Ephemeris */ int iodc; /*!< Issue of Data, Clock */ - int iode; /*!< Isuse of Data, Ephemeris */ + int iode; /*!< Issue of Data, Ephemeris */ double deltan; /*!< Delta-N (radians/sec) */ double cuc; /*!< Cuc (radians) */ double cus; /*!< Cus (radians) */ @@ -116,15 +116,15 @@ typedef struct double crs; /*!< Correction to radius sin (meters) */ double ecc; /*!< e Eccentricity */ double sqrta; /*!< sqrt(A) (sqrt(m)) */ - double m0; /*!< Mean anamoly (radians) */ + double m0; /*!< Mean anomaly (radians) */ double omg0; /*!< Longitude of the ascending node (radians) */ double inc0; /*!< Inclination (radians) */ double aop; double omgdot; /*!< Omega dot (radians/s) */ double idot; /*!< IDOT (radians/s) */ double af0; /*!< Clock offset (seconds) */ - double af1; /*!< rate (sec/sec) */ - double af2; /*!< acceleration (sec/sec^2) */ + double af1; /*!< Rate (sec/sec) */ + double af2; /*!< Acceleration (sec/sec^2) */ double tgd; /*!< Group delay L2 bias */ int svhlth; int codeL2; @@ -171,13 +171,13 @@ typedef struct #endif double code_phase; /*< Code phase */ gpstime_t g0; /*!< GPS time at start */ - unsigned long sbf[5][N_DWRD_SBF]; /*!< current subframe */ + unsigned long sbf[5][N_DWRD_SBF]; /*!< Current subframe */ unsigned long dwrd[N_DWRD]; /*!< Data words of sub-frame */ - int iword; /*!< initial word */ - int ibit; /*!< initial bit */ - int icode; /*!< initial code */ - int dataBit; /*!< current data bit */ - int codeCA; /*!< current C/A code */ + int iword; /*!< Initial word */ + int ibit; /*!< Initial bit */ + int icode; /*!< Initial code */ + int dataBit; /*!< Current data bit */ + int codeCA; /*!< Current C/A code */ double azel[2]; range_t rho0; } channel_t; diff --git a/player/limeplayer.c b/player/limeplayer.c index d272d4b..2519727 100644 --- a/player/limeplayer.c +++ b/player/limeplayer.c @@ -101,20 +101,17 @@ int main(int argc, char *const argv[]){ }; int c = getopt_long(argc, argv, "g:c:a:i:s:b:d:", long_options, &option_index); - if (c == -1) - break; + if (c == -1) break; switch (c) { case 0: - #if 1 - fprintf(stderr, "option %s", long_options[option_index].name); - if (optarg) - fprintf(stderr, " with arg %s", optarg); - fprintf(stderr, "\n"); - #endif - + #if 1 + fprintf(stderr, "option %s", long_options[option_index].name); + if (optarg) + fprintf(stderr, " with arg %s", optarg); + fprintf(stderr, "\n"); + #endif break; - case 'a': antenna = strtol(optarg, NULL, 0); break; @@ -130,26 +127,23 @@ int main(int argc, char *const argv[]){ case 'i': index = strtol(optarg, NULL, 0); break; - case 's': - sampleRate = strtod(optarg, NULL); - break; - case 'd': - dynamic = strtol(optarg, NULL, 0); - if(dynamic > 2047){ - dynamic = 2047; - } - break; - default: - print_usage(argv[0]); - break; + case 's': + sampleRate = strtod(optarg, NULL); + break; + case 'd': + dynamic = strtol(optarg, NULL, 0); + if(dynamic > 2047){ + dynamic = 2047; + } + break; + default: + print_usage(argv[0]); + break; } } // Use correct values // Use existing device - if(index < 0){ - index = 0; - } - if(index >= device_count){ + if((index < 0) || (index >= device_count)){ index = 0; } printf("Using device index %d [%s]" "\n", index, device_list[index]); @@ -181,10 +175,7 @@ int main(int argc, char *const argv[]){ int channel_count = LMS_GetNumChannels(device, LMS_CH_TX); // printf("Tx channel count %d" "\n", channel_count); - if(channel < 0){ - channel = 0; - } - if(channel >= channel_count){ + if((channel < 0) || (channel >= channel_count)){ channel = 0; } printf("Using channel %d" "\n", channel); @@ -201,10 +192,7 @@ int main(int argc, char *const argv[]){ // printf("Channel %d, antenna [%s] has BW [%lf .. %lf] (step %lf)" "\n", channel, antenna_name[i], antenna_bw[i].min, antenna_bw[i].max, antenna_bw[i].step); } } - if(antenna < 0){ - antenna = DEFAULT_ANTENNA; - } - if(antenna >= antenna_count){ + if((antenna < 0) || (antenna >= antenna_count)){ antenna = DEFAULT_ANTENNA; } // LMS_SetAntenna(device, LMS_CH_TX, channel, antenna); // SetLOFrequency should take care of selecting the proper antenna