From 619e2d956040835a239c8596a66eacca5780a35e Mon Sep 17 00:00:00 2001 From: Tadas Sasnauskas Date: Tue, 10 Dec 2024 17:15:03 +0200 Subject: [PATCH] HackRF code example fix (#59) Getting rid of 100k entries before receiving was doing nothing. --- content/hackrf.rst | 4 ++-- figure-generating-scripts/hackrf.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/content/hackrf.rst b/content/hackrf.rst index 5937fd3..07c534e 100644 --- a/content/hackrf.rst +++ b/content/hackrf.rst @@ -225,8 +225,6 @@ After running the code below, if in your time plot, the samples are reaching the return 0 - samples = samples[100000:] # get rid of the first 100k samples just to be safe, due to transients - sdr.set_rx_callback(rx_callback) sdr.pyhackrf_start_rx() print('is_streaming', sdr.pyhackrf_is_streaming()) @@ -236,6 +234,8 @@ After running the code below, if in your time plot, the samples are reaching the sdr.pyhackrf_stop_rx() sdr.pyhackrf_close() + samples = samples[100000:] # get rid of the first 100k samples just to be safe, due to transients + fft_size = 2048 num_rows = len(samples) // fft_size spectrogram = np.zeros((num_rows, fft_size)) diff --git a/figure-generating-scripts/hackrf.py b/figure-generating-scripts/hackrf.py index 2facadd..6a7a85d 100644 --- a/figure-generating-scripts/hackrf.py +++ b/figure-generating-scripts/hackrf.py @@ -93,8 +93,6 @@ def rx_callback(device, buffer, buffer_length, valid_length): # this callback f return 0 -samples = samples[100000:] # get rid of the first 100k samples just to be safe, due to transients - sdr.set_rx_callback(rx_callback) sdr.pyhackrf_start_rx() print('is_streaming', sdr.pyhackrf_is_streaming()) @@ -104,6 +102,8 @@ def rx_callback(device, buffer, buffer_length, valid_length): # this callback f sdr.pyhackrf_stop_rx() sdr.pyhackrf_close() +samples = samples[100000:] # get rid of the first 100k samples just to be safe, due to transients + fft_size = 2048 num_rows = len(samples) // fft_size spectrogram = np.zeros((num_rows, fft_size))