fixed a few typos, intendations, and simplified if cases

This commit is contained in:
Lenhart 2021-01-21 21:32:41 +01:00
parent bf998ab36c
commit 8021908d0e
2 changed files with 34 additions and 46 deletions

View File

@ -78,7 +78,7 @@
#define SC08 (8) #define SC08 (8)
#define SC16 (16) #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 */ /*! \brief Structure representing GPS time */
typedef struct typedef struct
@ -87,7 +87,7 @@ typedef struct
double sec; /*!< second inside the GPS \a week */ double sec; /*!< second inside the GPS \a week */
} gpstime_t; } gpstime_t;
/*! \brief Structure repreenting UTC time */ /*! \brief Structure representing UTC time */
typedef struct typedef struct
{ {
int y; /*!< Calendar year */ int y; /*!< Calendar year */
@ -106,7 +106,7 @@ typedef struct
gpstime_t toc; /*!< Time of Clock */ gpstime_t toc; /*!< Time of Clock */
gpstime_t toe; /*!< Time of Ephemeris */ gpstime_t toe; /*!< Time of Ephemeris */
int iodc; /*!< Issue of Data, Clock */ 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 deltan; /*!< Delta-N (radians/sec) */
double cuc; /*!< Cuc (radians) */ double cuc; /*!< Cuc (radians) */
double cus; /*!< Cus (radians) */ double cus; /*!< Cus (radians) */
@ -116,15 +116,15 @@ typedef struct
double crs; /*!< Correction to radius sin (meters) */ double crs; /*!< Correction to radius sin (meters) */
double ecc; /*!< e Eccentricity */ double ecc; /*!< e Eccentricity */
double sqrta; /*!< sqrt(A) (sqrt(m)) */ 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 omg0; /*!< Longitude of the ascending node (radians) */
double inc0; /*!< Inclination (radians) */ double inc0; /*!< Inclination (radians) */
double aop; double aop;
double omgdot; /*!< Omega dot (radians/s) */ double omgdot; /*!< Omega dot (radians/s) */
double idot; /*!< IDOT (radians/s) */ double idot; /*!< IDOT (radians/s) */
double af0; /*!< Clock offset (seconds) */ double af0; /*!< Clock offset (seconds) */
double af1; /*!< rate (sec/sec) */ double af1; /*!< Rate (sec/sec) */
double af2; /*!< acceleration (sec/sec^2) */ double af2; /*!< Acceleration (sec/sec^2) */
double tgd; /*!< Group delay L2 bias */ double tgd; /*!< Group delay L2 bias */
int svhlth; int svhlth;
int codeL2; int codeL2;
@ -171,13 +171,13 @@ typedef struct
#endif #endif
double code_phase; /*< Code phase */ double code_phase; /*< Code phase */
gpstime_t g0; /*!< GPS time at start */ 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 */ unsigned long dwrd[N_DWRD]; /*!< Data words of sub-frame */
int iword; /*!< initial word */ int iword; /*!< Initial word */
int ibit; /*!< initial bit */ int ibit; /*!< Initial bit */
int icode; /*!< initial code */ int icode; /*!< Initial code */
int dataBit; /*!< current data bit */ int dataBit; /*!< Current data bit */
int codeCA; /*!< current C/A code */ int codeCA; /*!< Current C/A code */
double azel[2]; double azel[2];
range_t rho0; range_t rho0;
} channel_t; } channel_t;

View File

@ -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); int c = getopt_long(argc, argv, "g:c:a:i:s:b:d:", long_options, &option_index);
if (c == -1) if (c == -1) break;
break;
switch (c) { switch (c) {
case 0: case 0:
#if 1 #if 1
fprintf(stderr, "option %s", long_options[option_index].name); fprintf(stderr, "option %s", long_options[option_index].name);
if (optarg) if (optarg)
fprintf(stderr, " with arg %s", optarg); fprintf(stderr, " with arg %s", optarg);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
#endif #endif
break; break;
case 'a': case 'a':
antenna = strtol(optarg, NULL, 0); antenna = strtol(optarg, NULL, 0);
break; break;
@ -130,26 +127,23 @@ int main(int argc, char *const argv[]){
case 'i': case 'i':
index = strtol(optarg, NULL, 0); index = strtol(optarg, NULL, 0);
break; break;
case 's': case 's':
sampleRate = strtod(optarg, NULL); sampleRate = strtod(optarg, NULL);
break; break;
case 'd': case 'd':
dynamic = strtol(optarg, NULL, 0); dynamic = strtol(optarg, NULL, 0);
if(dynamic > 2047){ if(dynamic > 2047){
dynamic = 2047; dynamic = 2047;
} }
break; break;
default: default:
print_usage(argv[0]); print_usage(argv[0]);
break; break;
} }
} }
// Use correct values // Use correct values
// Use existing device // Use existing device
if(index < 0){ if((index < 0) || (index >= device_count)){
index = 0;
}
if(index >= device_count){
index = 0; index = 0;
} }
printf("Using device index %d [%s]" "\n", index, device_list[index]); 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); int channel_count = LMS_GetNumChannels(device, LMS_CH_TX);
// printf("Tx channel count %d" "\n", channel_count); // printf("Tx channel count %d" "\n", channel_count);
if(channel < 0){ if((channel < 0) || (channel >= channel_count)){
channel = 0;
}
if(channel >= channel_count){
channel = 0; channel = 0;
} }
printf("Using channel %d" "\n", channel); 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); // 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){ if((antenna < 0) || (antenna >= antenna_count)){
antenna = DEFAULT_ANTENNA;
}
if(antenna >= antenna_count){
antenna = DEFAULT_ANTENNA; antenna = DEFAULT_ANTENNA;
} }
// LMS_SetAntenna(device, LMS_CH_TX, channel, antenna); // SetLOFrequency should take care of selecting the proper antenna // LMS_SetAntenna(device, LMS_CH_TX, channel, antenna); // SetLOFrequency should take care of selecting the proper antenna