From 85a0aa16b8b5c2058c4904788ee605fdcd03ecb2 Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Sat, 14 Oct 2023 07:05:29 -0400 Subject: [PATCH] Modify -p option to allow setting of fixed gain value --- README.md | 2 +- gpssim.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d739fa7..656fcd9 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Options: -s Sampling frequency [Hz] (default: 2600000) -b I/Q data format [1/8/16] (default: 16) -i Disable ionospheric delay for spacecraft scenario - -p Disable path loss and hold power level constant + -p [fixed_gain] Disable path loss and hold power level constant -v Show details about simulated channels ``` diff --git a/gpssim.c b/gpssim.c index c490021..9c990f7 100644 --- a/gpssim.c +++ b/gpssim.c @@ -1707,7 +1707,7 @@ void usage(void) " -s Sampling frequency [Hz] (default: 2600000)\n" " -b I/Q data format [1/8/16] (default: 16)\n" " -i Disable ionospheric delay for spacecraft scenario\n" - " -p Disable path loss and hold power level constant\n" + " -p [fixed_gain] Disable path loss and hold power level constant\n" " -v Show details about simulated channels\n", ((double)USER_MOTION_SIZE) / 10.0, STATIC_MAX_DURATION); @@ -1761,6 +1761,7 @@ int main(int argc, char *argv[]) int gain[MAX_CHAN]; double path_loss; double ant_gain; + int fixed_gain = 128; double ant_pat[37]; int ibs; // boresight angle index @@ -1893,6 +1894,16 @@ int main(int argc, char *argv[]) ionoutc.enable = FALSE; // Disable ionospheric correction break; case 'p': + if (optind < argc && argv[optind][0] != '-') // Check if next item is an argument + { + fixed_gain = atoi(argv[optind]); + if (fixed_gain < 1 || fixed_gain > 128) + { + fprintf(stderr, "ERROR: Fixed gain must be between 1 and 128.\n"); + exit(1); + } + optind++; // Move past this argument for next iteration + } path_loss_enable = FALSE; // Disable path loss break; case 'v': @@ -2251,7 +2262,7 @@ int main(int argc, char *argv[]) if (path_loss_enable == TRUE) gain[i] = (int)(path_loss * ant_gain * 128.0); // scaled by 2^7 else - gain[i] = 128; // hold the power level constant + gain[i] = fixed_gain; // hold the power level constant } }