@@ -44,6 +44,7 @@ PY_BLOCKS_PER_TRANSFER = 16
4444
4545# hackrf sweep settings
4646AVAILABLE_SAMPLING_RATES = (2 _000_000, 4 _000_000, 6 _000_000, 8 _000_000, 10 _000_000, 12 _000_000, 14 _000_000, 16 _000_000, 18 _000_000, 20 _000_000)
47+ AVAILABLE_BASEBAND_FILTER_BANDWIDTHS = (1 _750_000, 2 _500_000, 3 _500_000, 5 _000_000, 5 _500_000, 6 _000_000, 7 _000_000, 8 _000_000, 9 _000_000, 10 _000_000, 12 _000_000, 14 _000_000, 15 _000_000, 20 _000_000, 24 _000_000, 28 _000_000)
4748BASEBAND_FILTER_BANDWIDTH_RATIO = 0.75
4849INTERLEAVED_OFFSET_RATIO = 0.375
4950LINEAR_OFFSET_RATIO = 0.5
@@ -79,16 +80,16 @@ cdef int pwr_1_stop = 0
7980cdef int pwr_2_start = 0
8081cdef int pwr_2_stop = 0
8182cdef float norm_factor = 0
82- cdef int start_frequency = 0
83+ cdef unsigned long start_frequency = 0
8384
8485sweep_started = False
8586run_available = True
8687check_max_num_sweeps = False
8788
8889cdef int max_num_sweeps = 0
89- cdef unsigned int accepted_bytes = 0
90+ cdef unsigned long long accepted_bytes = 0
9091cdef double sweep_rate = 0
91- cdef unsigned int sweep_count = 0
92+ cdef unsigned long long sweep_count = 0
9293
9394
9495def sigint_callback_handler (sig , frame ):
@@ -116,7 +117,7 @@ cdef sweep_callback(buffer: np.ndarray[:], buffer_length: int, valid_length: int
116117 timestamp = datetime.datetime.now()
117118 time_str = timestamp.strftime(" %Y -%m -%d , %H :%M :%S .%f " )
118119
119- cdef int frequency = 0
120+ cdef unsigned long frequency = 0
120121 cdef int index = 0
121122 cdef int i, j
122123 for j in range (PY_BLOCKS_PER_TRANSFER):
@@ -228,7 +229,7 @@ cdef sweep_callback(buffer: np.ndarray[:], buffer_length: int, valid_length: int
228229
229230
230231def pyhackrf_sweep (frequencies: list = [0 , 6000 ], lna_gain: int = 16 , vga_gain: int = 20 , bin_width: int = 100 _000,
231- serial_number: str = None , amp_enable: bool = False , antenna_enable: bool = False , sample_rate: int = 20 _000_000,
232+ serial_number: str = None , amp_enable: bool = False , antenna_enable: bool = False , sample_rate: int = 20 _000_000, bandwidth: int = 15 _000_000,
232233 num_sweeps: int = None , binary_output: bool = False , one_shot: bool = False , use_queue: bool = False , filename: str = None , sweep_style: pyhackrf.py_sweep_style = pyhackrf.py_sweep_style.INTERLEAVED,
233234 print_to_console: bool = True , device: pyhackrf.PyHackrfDevice = None ):
234235
@@ -249,6 +250,11 @@ def pyhackrf_sweep(frequencies: list = [0, 6000], lna_gain: int = 16, vga_gain:
249250 SAMPLE_RATE = int (sample_rate)
250251 else :
251252 SAMPLE_RATE = 20 _000_000
253+
254+ if bandwidth in AVAILABLE_BASEBAND_FILTER_BANDWIDTHS:
255+ BASEBAND_FILTER_BANDWIDTH = int (bandwidth)
256+ else :
257+ BASEBAND_FILTER_BANDWIDTH = int (SAMPLE_RATE * BASEBAND_FILTER_BANDWIDTH_RATIO)
252258
253259 frequency_step_1 = sample_rate // 4
254260 frequency_step_2 = sample_rate // 2
@@ -260,7 +266,6 @@ def pyhackrf_sweep(frequencies: list = [0, 6000], lna_gain: int = 16, vga_gain:
260266 accepted_bytes = 0
261267 sweep_started = False
262268
263- BASEBAND_FILTER_BANDWIDTH = int (SAMPLE_RATE * BASEBAND_FILTER_BANDWIDTH_RATIO)
264269 if SWEEP_STYLE == pyhackrf.py_sweep_style.INTERLEAVED:
265270 OFFSET = int (SAMPLE_RATE * INTERLEAVED_OFFSET_RATIO)
266271 else :
0 commit comments