@@ -71,7 +71,7 @@ def init_signals():
7171def rx_callback (device: pyhackrf.PyHackrfDevice , buffer: np.ndarray[:], buffer_length: int , valid_length: int ):
7272 global run_available, device_data
7373
74- current_device_data = device_data[device.get_hackrf_device_ptr ()]
74+ current_device_data = device_data[device.pyhackrf_serialno_read ()]
7575
7676 current_device_data[' byte_count' ] += valid_length
7777 current_device_data[' stream_power' ] += np.sum(buffer [:valid_length].astype(np.int8, copy = False ) ** 2 )
@@ -90,7 +90,7 @@ def rx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
9090 current_device_data[' rx_file' ].write(accepted_data.tobytes())
9191
9292 if current_device_data[' num_samples' ] == 0 :
93- run_available[device.get_hackrf_device_ptr ()] = False
93+ run_available[device.pyhackrf_serialno_read ()] = False
9494 return - 1
9595
9696 return 0
@@ -99,7 +99,7 @@ def rx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
9999def tx_callback (device: pyhackrf.PyHackrfDevice , buffer: np.ndarray[:], buffer_length: int , valid_length: int ):
100100 global run_available, device_data
101101
102- current_device_data = device_data[device.get_hackrf_device_ptr ()]
102+ current_device_data = device_data[device.pyhackrf_serialno_read ()]
103103
104104 if current_device_data[' tx_complete' ]:
105105 return - 1 , buffer , valid_length
@@ -129,12 +129,12 @@ def tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
129129 if current_device_data[' tx_queue' ].empty():
130130 if writed:
131131 current_device_data[' tx_complete' ] = True
132- run_available[device.get_hackrf_device_ptr ()] = False
132+ run_available[device.pyhackrf_serialno_read ()] = False
133133 valid_length = writed * 2
134134 return 0 , buffer , valid_length
135135 else :
136136 current_device_data[' tx_complete' ] = True
137- run_available[device.get_hackrf_device_ptr ()] = False
137+ run_available[device.pyhackrf_serialno_read ()] = False
138138 return - 1 , buffer , valid_length
139139
140140 sent_data = current_device_data[' tx_queue' ].get_nowait()
@@ -155,7 +155,7 @@ def tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
155155 if len (raw_data):
156156 writed = len (raw_data) // 8
157157 elif current_device_data[' tx_file' ].tell() < 1 :
158- run_available[device.get_hackrf_device_ptr ()] = False
158+ run_available[device.pyhackrf_serialno_read ()] = False
159159 valid_length = 0
160160 return - 1 , buffer , valid_length
161161 else :
@@ -166,7 +166,7 @@ def tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
166166
167167 if current_device_data[' num_samples' ] == 0 :
168168 current_device_data[' tx_complete' ] = True
169- run_available[device.get_hackrf_device_ptr ()] = False
169+ run_available[device.pyhackrf_serialno_read ()] = False
170170 valid_length = writed * 2
171171 return 0 , buffer , valid_length
172172
@@ -176,7 +176,7 @@ def tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
176176
177177 if not current_device_data[' repeat_tx' ] and current_device_data[' tx_file' ].tell() < 1 :
178178 current_device_data[' tx_complete' ] = True
179- run_available[device.get_hackrf_device_ptr ()] = False
179+ run_available[device.pyhackrf_serialno_read ()] = False
180180 valid_length = writed * 2
181181 return 0 , buffer , valid_length
182182
@@ -188,7 +188,7 @@ def tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
188188 rewrited = len (raw_data) // 8
189189 else :
190190 current_device_data[' tx_complete' ] = True
191- run_available[device.get_hackrf_device_ptr ()] = False
191+ run_available[device.pyhackrf_serialno_read ()] = False
192192 valid_length = writed * 2
193193 return 0 , buffer , valid_length
194194
@@ -204,10 +204,10 @@ def tx_complete_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:],
204204 global run_available, device_data
205205
206206 if not success:
207- run_available[device.get_hackrf_device_ptr ()] = False
207+ run_available[device.pyhackrf_serialno_read ()] = False
208208 return
209209
210- current_device_data = device_data[device.get_hackrf_device_ptr ()]
210+ current_device_data = device_data[device.pyhackrf_serialno_read ()]
211211
212212 current_device_data[' byte_count' ] += valid_length
213213 current_device_data[' stream_power' ] += np.sum(buffer [:valid_length].astype(np.int8, copy = False ) ** 2 )
@@ -216,12 +216,12 @@ def tx_complete_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:],
216216def flush_callback (device: pyhackrf.PyHackrfDevice , success: int ):
217217 global run_available, device_data
218218
219- current_device_data = device_data[device.get_hackrf_device_ptr ()]
219+ current_device_data = device_data[device.pyhackrf_serialno_read ()]
220220
221221 if success:
222222 current_device_data[' flush_complete' ] = True
223223
224- run_available[device.get_hackrf_device_ptr ()] = False
224+ run_available[device.pyhackrf_serialno_read ()] = False
225225
226226
227227def pyhackrf_transfer (frequency: int = None , sample_rate: int = 10 _000_000, baseband_filter_bandwidth: int = 7 _000_000, i_frequency: int = None , lo_frequency: int = None , image_reject: pyhackrf.py_rf_path_filter = pyhackrf.py_rf_path_filter.RF_PATH_FILTER_BYPASS,
@@ -240,7 +240,7 @@ def pyhackrf_transfer(frequency: int = None, sample_rate: int = 10_000_000, base
240240 else :
241241 device = pyhackrf.pyhackrf_open_by_serial(serial_number)
242242
243- run_available[device.get_hackrf_device_ptr ()] = True
243+ run_available[device.pyhackrf_serialno_read ()] = True
244244
245245 sample_rate = int (sample_rate) if int (sample_rate) in AVAILABLE_SAMPLING_RATES else 10 _000_000
246246 baseband_filter_bandwidth = int (baseband_filter_bandwidth) if int (baseband_filter_bandwidth) in AVAILABLE_BASEBAND_FILTER_BANDWIDTHS else pyhackrf.pyhackrf_compute_baseband_filter_bw(int (baseband_filter_bandwidth))
@@ -261,7 +261,7 @@ def pyhackrf_transfer(frequency: int = None, sample_rate: int = 10_000_000, base
261261 ' rx_queue' : rx_queue,
262262 ' tx_queue' : tx_queue
263263 }
264- device_data[device.get_hackrf_device_ptr ()] = current_device_data
264+ device_data[device.pyhackrf_serialno_read ()] = current_device_data
265265
266266 if (rx_queue is not None or rx_filename is not None ) and (tx_queue is not None or tx_filename is not None ):
267267 raise RuntimeError (' HackRF cannot receive and send IQ samples at the same time.' )
@@ -365,7 +365,7 @@ def pyhackrf_transfer(frequency: int = None, sample_rate: int = 10_000_000, base
365365
366366 time_start = time.time()
367367 time_prev = time.time()
368- while run_available[device.get_hackrf_device_ptr ()]:
368+ while run_available[device.pyhackrf_serialno_read ()]:
369369 time.sleep(0.05 )
370370 time_now = time.time()
371371 time_difference = time_now - time_prev
@@ -387,7 +387,7 @@ def pyhackrf_transfer(frequency: int = None, sample_rate: int = 10_000_000, base
387387 time_prev = time_now
388388
389389 if print_to_console:
390- if not run_available[device.get_hackrf_device_ptr ()]:
390+ if not run_available[device.pyhackrf_serialno_read ()]:
391391 sys.stderr.write(' Exiting...\n ' )
392392 else :
393393 sys.stderr.write(' Exiting... [ pyhackrf streaming stopped ]\n ' )
0 commit comments