From b4cc0acb6efbbc0561f0895002b06eac2eea7cfb Mon Sep 17 00:00:00 2001 From: Ryan Thompson Date: Wed, 21 Dec 2022 17:03:14 -0600 Subject: [PATCH 1/3] WIP: schedule_retune debug --- .../test_scheduled_retune/src/main.c | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c b/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c index 808c5cb6..46e915b9 100644 --- a/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c +++ b/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c @@ -50,17 +50,15 @@ #define VERBOSITY BLADERF_LOG_LEVEL_INFO -#define TIMEOUT_MS 2500 -#define ITERATIONS 500 -#define SAMPLE_RATE 5000000 -#define BANDWIDTH 5000000 +#define ITERATIONS 16 +#define SAMPLE_RATE 8 * 1000 * 1000 +#define TIMEOUT_MS ITERATIONS * 1000 +#define BANDWIDTH SAMPLE_RATE -#define NUM_SAMPLES 2000 -#define TS_INC 50000 +#define NUM_SAMPLES SAMPLE_RATE/3 // 1/3 second worth of samples to make a blip +#define TS_INC SAMPLE_RATE // 1 second hop intervals #define RETUNE_INC (NUM_SAMPLES + (TS_INC - NUM_SAMPLES) / 10) -#define SCHEDULE_AHEAD 4 - int schedule_retune(struct bladerf *dev, bladerf_module m, struct hop_set *hops, bool quick_tune, uint64_t *hop_ts) { @@ -123,7 +121,7 @@ int run_test(struct bladerf *dev, bladerf_module module, } /* Add some initial startup delay */ - meta.timestamp += (SAMPLE_RATE / 50); + meta.timestamp += SAMPLE_RATE; if (module == BLADERF_MODULE_TX) { meta.flags = BLADERF_META_FLAG_TX_BURST_START | @@ -142,19 +140,10 @@ int run_test(struct bladerf *dev, bladerf_module module, goto out; } - /* Schedule first N hops */ - for (i = 0; i < SCHEDULE_AHEAD; i++) { - status = schedule_retune(dev, module, hops, quick_tune, &retune_ts); - if (status != 0) { - fprintf(stderr, "Failed to schedule initial retune #%u: %s\n", - i, bladerf_strerror(status)); - goto out; - } - } for (i = 0; i < ITERATIONS; i++) { if (module == BLADERF_MODULE_TX) { - status = bladerf_sync_tx(dev, samples, NUM_SAMPLES, &meta, TIMEOUT_MS); + status = bladerf_sync_tx(dev, samples, NUM_SAMPLES, &meta, 0); if (status != 0) { fprintf(stderr, "Failed to TX @ iteration %u: %s\n", i + 1, bladerf_strerror(status)); @@ -163,7 +152,7 @@ int run_test(struct bladerf *dev, bladerf_module module, } else { size_t n_written; - status = bladerf_sync_rx(dev, samples, NUM_SAMPLES, &meta, TIMEOUT_MS); + status = bladerf_sync_rx(dev, samples, NUM_SAMPLES, &meta, 0); if (status != 0) { fprintf(stderr, "Failed to RX @ iteration %u: %s\n", i + 1, bladerf_strerror(status)); @@ -191,6 +180,8 @@ int run_test(struct bladerf *dev, bladerf_module module, fprintf(stderr, "Failed to schedule retune @ %"PRIu64": %s\n", meta.timestamp + RETUNE_INC, bladerf_strerror(status)); goto out; + } else { + printf("Retune set successfully @ iteration %u\n", i); } } @@ -199,7 +190,7 @@ int run_test(struct bladerf *dev, bladerf_module module, if (module == BLADERF_MODULE_TX) { fprintf(stderr, "Waiting for transmission to complete...\n"); status = wait_for_timestamp(dev, BLADERF_MODULE_TX, - meta.timestamp, 2500); + meta.timestamp, TIMEOUT_MS); if (status == BLADERF_ERR_TIMEOUT) { fprintf(stderr, "Wait timed out.\n"); From ae6ef3b2a178da26a7f2aa50598672ed8aeeecd8 Mon Sep 17 00:00:00 2001 From: Ryan Thompson Date: Thu, 22 Dec 2022 13:51:36 -0600 Subject: [PATCH 2/3] WIP: added samp_rate/4 CW to test_scheduled_retune --- .../test_scheduled_retune/src/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c b/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c index 46e915b9..4d8059a9 100644 --- a/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c +++ b/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c @@ -59,6 +59,8 @@ #define TS_INC SAMPLE_RATE // 1 second hop intervals #define RETUNE_INC (NUM_SAMPLES + (TS_INC - NUM_SAMPLES) / 10) +#define CW true + int schedule_retune(struct bladerf *dev, bladerf_module m, struct hop_set *hops, bool quick_tune, uint64_t *hop_ts) { @@ -100,9 +102,16 @@ int run_test(struct bladerf *dev, bladerf_module module, } if (module == BLADERF_MODULE_TX) { - /* Set IQ values to ~ sqrt(2)/2 */ + int16_t cw_samp_values[4] = {0, 2047, 0, -2047}; for (i = 0; i < (2 * NUM_SAMPLES); i += 2) { - samples[i] = samples[i+1] = 1448; + if (CW) { + /* IQ values for CW @ -1/4 samp_rate */ + samples[i] = cw_samp_values[(i/2) % 4]; + samples[i+1] = cw_samp_values[(i/2 + 1) % 4]; + } else { + /* Set IQ values to ~ sqrt(2)/2 */ + samples[i] = samples[i+1] = 1448; + } } } else { out = fopen("samples.bin", "wb"); From c931d5f53420ca9a74576dc6fe5cf351c166f925 Mon Sep 17 00:00:00 2001 From: Ryan Thompson Date: Fri, 23 Dec 2022 09:25:06 -0600 Subject: [PATCH 3/3] WIP: test_scheduled_retune speed control added --- .../libbladeRF_test/test_scheduled_retune/src/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c b/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c index 4d8059a9..e1a2e3ad 100644 --- a/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c +++ b/host/libraries/libbladeRF_test/test_scheduled_retune/src/main.c @@ -50,13 +50,14 @@ #define VERBOSITY BLADERF_LOG_LEVEL_INFO -#define ITERATIONS 16 #define SAMPLE_RATE 8 * 1000 * 1000 -#define TIMEOUT_MS ITERATIONS * 1000 #define BANDWIDTH SAMPLE_RATE -#define NUM_SAMPLES SAMPLE_RATE/3 // 1/3 second worth of samples to make a blip -#define TS_INC SAMPLE_RATE // 1 second hop intervals +#define SPEED 1 // hops/sec +#define ITERATIONS 8 +#define TIMEOUT_MS ITERATIONS * 1000 / SPEED +#define NUM_SAMPLES SAMPLE_RATE / (2*SPEED) // 1/3 second worth of samples to make a blip +#define TS_INC SAMPLE_RATE / SPEED // 1 second hop intervals #define RETUNE_INC (NUM_SAMPLES + (TS_INC - NUM_SAMPLES) / 10) #define CW true