diff options
author | Harsh Sharma <harsh.sharma@multitech.com> | 2021-01-29 16:43:34 -0600 |
---|---|---|
committer | Harsh Sharma <harsh.sharma@multitech.com> | 2021-01-29 16:43:34 -0600 |
commit | 5ab2ffb580da0a84cb6ffe88545ec5e4f3d2e6f3 (patch) | |
tree | a0155012b7478230f518d020c8a3d5c4a18ba7f4 | |
parent | 03a003c56355b7597c68711ce95424285b66d311 (diff) | |
download | lora_gateway_mtac_full-5ab2ffb580da0a84cb6ffe88545ec5e4f3d2e6f3.tar.gz lora_gateway_mtac_full-5ab2ffb580da0a84cb6ffe88545ec5e4f3d2e6f3.tar.bz2 lora_gateway_mtac_full-5ab2ffb580da0a84cb6ffe88545ec5e4f3d2e6f3.zip |
Added pa, mix, dig and dac options to utiltx test
-rw-r--r-- | libloragw/tst/test_loragw_gps.c | 10 | ||||
-rw-r--r-- | util_tx_test/src/util_tx_test.c | 71 |
2 files changed, 70 insertions, 11 deletions
diff --git a/libloragw/tst/test_loragw_gps.c b/libloragw/tst/test_loragw_gps.c index bb84068..994c0ad 100644 --- a/libloragw/tst/test_loragw_gps.c +++ b/libloragw/tst/test_loragw_gps.c @@ -51,8 +51,6 @@ struct tref ppm_ref; /* --- PRIVATE FUNCTIONS DECLARATION ---------------------------------------- */ static void sig_handler(int sigio); -static void gps_process_sync(void); -static void gps_process_coords(void); /* -------------------------------------------------------------------------- */ /* --- PRIVATE FUNCTIONS DEFINITION ----------------------------------------- */ @@ -82,13 +80,8 @@ int main() char serial_buff[128]; /* buffer to receive GPS data */ /* NMEA/UBX variables */ - enum gps_msg latest_msg = UNKNOWN; /* keep track of latest NMEA/UBX message parsed */ static struct tref time_reference_gps; /* time reference used for GPS <-> timestamp conversion */ - fd_set fds; - char delim[4] = "$"; - char *token[254]; - /* configure signal handling */ sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; @@ -135,7 +128,6 @@ int main() while ((quit_sig != 1) && (exit_sig != 1)) { wait_ms(100); int r = gps_read(&gpsdata, 0, 0); - int used=0; if (r!= -1 && (gpsdata.status != STATUS_NO_FIX) && (gpsdata.fix.mode == MODE_2D || gpsdata.fix.mode == MODE_3D) && !isnan(gpsdata.fix.latitude) && @@ -148,7 +140,7 @@ int main() lgw_gps_sync(&time_reference_gps, trig_tstamp, gpsdata.fix.time); printf("\n--- GPS ---\n"); - printf("Set: %d\n", gpsdata.set); + printf("Set: %lld\n", gpsdata.set); printf("Online: %10.0f\n", gpsdata.online); printf("Status: %d\n", gpsdata.status); printf("Satellites Used: %d\n", gpsdata.satellites_used); diff --git a/util_tx_test/src/util_tx_test.c b/util_tx_test/src/util_tx_test.c index 0ac8244..f217d16 100644 --- a/util_tx_test/src/util_tx_test.c +++ b/util_tx_test/src/util_tx_test.c @@ -153,6 +153,10 @@ void usage(void) { printf(" --lbt-sctm <uint> lbt scan time in usec to be applied to all channels [128, 5000]\n"); printf(" --lbt-rssi <int> lbt rssi target in dBm [-128..0]\n"); printf(" --lbt-rssi-offset <int> rssi offset in dB to be applied to SX127x RSSI [-128..127]\n"); + printf(" --pa <uint> pa gain\n"); + printf(" --mix <uint> mix gain\n"); + printf(" --dig <uint> dig gain\n"); + printf(" --dac <uint> dac gain\n"); printf(" --path <string> path of SPIDEV e.g. /dev/spidev0.0\n"); } @@ -193,6 +197,11 @@ int main(int argc, char **argv) uint8_t lbt_nb_channel = 1; uint32_t sx1301_count_us; uint32_t tx_notch_freq = DEFAULT_NOTCH_FREQ; + bool force_tx_lut = false; + uint8_t dig_gain = 0; /*!> 2 bits, control of the digital gain of SX1301 */ + uint8_t pa_gain = 0; /*!> 2 bits, control of the external PA (SX1301 I/O) */ + uint8_t dac_gain = 0; /*!> 2 bits, control of the radio DAC */ + uint8_t mix_gain = 0; /*!> 4 bits, control of the radio mixer */ /* RF configuration (TX fail if RF chain is not enabled) */ enum lgw_radio_type_e radio_type = LGW_RADIO_TYPE_NONE; @@ -215,7 +224,10 @@ int main(int argc, char **argv) {"lbt-rssi", required_argument, 0, 0}, {"lbt-nbch", required_argument, 0, 0}, {"lbt-rssi-offset", required_argument, 0, 0}, - {"path", required_argument, 0, 0}, + {"pa", required_argument, 0, 0}, + {"mix", required_argument, 0, 0}, + {"dig", required_argument, 0, 0}, + {"dac", required_argument, 0, 0}, {0, 0, 0, 0} }; @@ -472,6 +484,46 @@ int main(int argc, char **argv) usage(); return EXIT_FAILURE; } + } else if( strcmp(long_options[option_index].name, "pa") == 0 ) { /* <uint> */ + i = sscanf(optarg, "%i", &xi); + if ((i != 1) || (xi < 0)) { + MSG("ERROR: invalid PA gain\n"); + usage(); + return EXIT_FAILURE; + } else { + pa_gain = xi; + force_tx_lut = true; + } + } else if( strcmp(long_options[option_index].name, "dig") == 0 ) { /* <uint> */ + i = sscanf(optarg, "%i", &xi); + if ((i != 1) || (xi < 0)) { + MSG("ERROR: invalid Dig gain\n"); + usage(); + return EXIT_FAILURE; + } else { + dig_gain = xi; + force_tx_lut = true; + } + } else if( strcmp(long_options[option_index].name, "dac") == 0 ) { /* <uint> */ + i = sscanf(optarg, "%i", &xi); + if ((i != 1) || (xi < 0)) { + MSG("ERROR: invalid Dac gain\n"); + usage(); + return EXIT_FAILURE; + } else { + dac_gain = xi; + force_tx_lut = true; + } + } else if( strcmp(long_options[option_index].name, "mix") == 0 ) { /* <uint> */ + i = sscanf(optarg, "%i", &xi); + if ((i != 1) || (xi < 0)) { + MSG("ERROR: invalid mix gain\n"); + usage(); + return EXIT_FAILURE; + } else { + mix_gain = xi; + force_tx_lut = true; + } } else if (strcmp(long_options[option_index].name,"path") == 0) { /* <string> Path to spi device */ i = sscanf(optarg, "%s", arg_s); if ((i != 1) || (strncmp(arg_s, "/dev/", 5 ) != 0)) { @@ -555,7 +607,22 @@ int main(int argc, char **argv) } /* TX gain config */ - lgw_txgain_setconf(&txgain_lut); + if (force_tx_lut) { + struct lgw_tx_gain_lut_s txgain_lut_forced = { + .size = 1, + .lut[0] = { + .dig_gain = dig_gain, + .pa_gain = pa_gain, + .dac_gain = dac_gain, + .mix_gain = mix_gain, + .rf_power = 0 + } + }; + lgw_txgain_setconf(&txgain_lut_forced); + MSG("settings forced dig_gain%d pa_gain%d dac_gain%d mix_gain%d", dig_gain, pa_gain, dac_gain, mix_gain); + } else { + lgw_txgain_setconf(&txgain_lut); + } /* Start concentrator */ i = lgw_start(); |