@@ -69,10 +69,10 @@ def init_signals():
6969def rx_callback (device: pyhackrf.PyHackrfDevice , buffer: np.ndarray[:], buffer_length: int , valid_length: int ):
7070 global run_available, device_data
7171
72- if not run_available[device.uuid ]:
72+ if not run_available[device.serialno ]:
7373 return - 1
7474
75- current_device_data = device_data[device.uuid ]
75+ current_device_data = device_data[device.serialno ]
7676
7777 current_device_data[' byte_count' ] += valid_length
7878 current_device_data[' stream_power' ] += np.sum(buffer [:valid_length].view(np.int8).astype(np.uint64, copy = False ) ** 2 )
@@ -91,7 +91,7 @@ def rx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
9191 current_device_data[' rx_file' ].write(accepted_data.tobytes())
9292
9393 if current_device_data[' num_samples' ] == 0 :
94- run_available[device.uuid ] = False
94+ run_available[device.serialno ] = False
9595 return - 1
9696
9797 return 0
@@ -100,9 +100,9 @@ def rx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
100100def tx_callback (device: pyhackrf.PyHackrfDevice , buffer: np.ndarray[:], buffer_length: int , valid_length: int ):
101101 global run_available, device_data
102102
103- current_device_data = device_data[device.uuid ]
103+ current_device_data = device_data[device.serialno ]
104104
105- if current_device_data[' tx_complete' ] or not run_available[device.uuid ]:
105+ if current_device_data[' tx_complete' ] or not run_available[device.serialno ]:
106106 return - 1 , buffer , valid_length
107107
108108 to_write = buffer_length // 2
@@ -130,12 +130,12 @@ def tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
130130 if current_device_data[' tx_queue' ].empty():
131131 if writed:
132132 current_device_data[' tx_complete' ] = True
133- run_available[device.uuid ] = False
133+ run_available[device.serialno ] = False
134134 valid_length = writed * 2
135135 return 0 , buffer , valid_length
136136 else :
137137 current_device_data[' tx_complete' ] = True
138- run_available[device.uuid ] = False
138+ run_available[device.serialno ] = False
139139 return - 1 , buffer , valid_length
140140
141141 sent_data = current_device_data[' tx_queue' ].get_nowait()
@@ -157,7 +157,7 @@ def tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
157157 writed = len (raw_data) // 8
158158 elif current_device_data[' tx_file' ].tell() < 1 :
159159 # file is empty
160- run_available[device.uuid ] = False
160+ run_available[device.serialno ] = False
161161 valid_length = 0
162162 return - 1 , buffer , valid_length
163163 else :
@@ -169,7 +169,7 @@ def tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
169169 # limit samples
170170 if current_device_data[' num_samples' ] == 0 :
171171 current_device_data[' tx_complete' ] = True
172- run_available[device.uuid ] = False
172+ run_available[device.serialno ] = False
173173 valid_length = writed * 2
174174 return 0 , buffer , valid_length
175175
@@ -181,7 +181,7 @@ def tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
181181 # file is finished
182182 if not current_device_data[' repeat_tx' ]:
183183 current_device_data[' tx_complete' ] = True
184- run_available[device.uuid ] = False
184+ run_available[device.serialno ] = False
185185 valid_length = writed * 2
186186 return 0 , buffer , valid_length
187187
@@ -193,7 +193,7 @@ def tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:], buffer_l
193193 rewrited = len (raw_data) // 8
194194 else :
195195 current_device_data[' tx_complete' ] = True
196- run_available[device.uuid ] = False
196+ run_available[device.serialno ] = False
197197 valid_length = writed * 2
198198 return 0 , buffer , valid_length
199199
@@ -209,10 +209,10 @@ def tx_complete_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:],
209209 global run_available, device_data
210210
211211 if not success:
212- run_available[device.uuid ] = False
212+ run_available[device.serialno ] = False
213213 return
214214
215- current_device_data = device_data[device.uuid ]
215+ current_device_data = device_data[device.serialno ]
216216
217217 current_device_data[' byte_count' ] += valid_length
218218 current_device_data[' stream_power' ] += np.sum(buffer [:valid_length].view(np.int8).astype(np.uint64, copy = False ) ** 2 )
@@ -221,12 +221,12 @@ def tx_complete_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[:],
221221def flush_callback (device: pyhackrf.PyHackrfDevice , success: int ):
222222 global run_available, device_data
223223
224- current_device_data = device_data[device.uuid ]
224+ current_device_data = device_data[device.serialno ]
225225
226226 if success:
227227 current_device_data[' flush_complete' ] = True
228228
229- run_available[device.uuid ] = False
229+ run_available[device.serialno ] = False
230230
231231
232232def pyhackrf_transfer (frequency: int = None , sample_rate: int = 10 _000_000, baseband_filter_bandwidth: int = None , i_frequency: int = None , lo_frequency: int = None , image_reject: pyhackrf.py_rf_path_filter = pyhackrf.py_rf_path_filter.RF_PATH_FILTER_BYPASS,
@@ -245,7 +245,7 @@ def pyhackrf_transfer(frequency: int = None, sample_rate: int = 10_000_000, base
245245 else :
246246 device = pyhackrf.pyhackrf_open_by_serial(serial_number)
247247
248- run_available[device.uuid ] = True
248+ run_available[device.serialno ] = True
249249
250250 sample_rate = int (sample_rate) if int (sample_rate) in AVAILABLE_SAMPLING_RATES else 10 _000_000
251251 baseband_filter_bandwidth = int (baseband_filter_bandwidth) if baseband_filter_bandwidth in AVAILABLE_BASEBAND_FILTER_BANDWIDTHS else pyhackrf.pyhackrf_compute_baseband_filter_bw(int (sample_rate * .75 ))
@@ -266,7 +266,7 @@ def pyhackrf_transfer(frequency: int = None, sample_rate: int = 10_000_000, base
266266 ' rx_queue' : rx_queue,
267267 ' tx_queue' : tx_queue
268268 }
269- device_data[device.uuid ] = current_device_data
269+ device_data[device.serialno ] = current_device_data
270270
271271 if (rx_queue is not None or rx_filename is not None ) and (tx_queue is not None or tx_filename is not None ):
272272 raise RuntimeError (' HackRF cannot receive and send IQ samples at the same time.' )
@@ -373,7 +373,7 @@ def pyhackrf_transfer(frequency: int = None, sample_rate: int = 10_000_000, base
373373
374374 time_start = time.time()
375375 time_prev = time.time()
376- while run_available[device.uuid ]:
376+ while run_available[device.serialno ]:
377377 time.sleep(0.05 )
378378 time_now = time.time()
379379 time_difference = time_now - time_prev
@@ -396,7 +396,7 @@ def pyhackrf_transfer(frequency: int = None, sample_rate: int = 10_000_000, base
396396
397397 time_now = time.time()
398398 if print_to_console:
399- if not run_available[device.uuid ]:
399+ if not run_available[device.serialno ]:
400400 sys.stderr.write(' \n Exiting...\n ' )
401401 else :
402402 sys.stderr.write(' \n Exiting... [ pyhackrf streaming stopped ]\n ' )
@@ -427,8 +427,8 @@ def pyhackrf_transfer(frequency: int = None, sample_rate: int = 10_000_000, base
427427 except RuntimeError as e:
428428 sys.stderr.write(f' {e}\n ' )
429429
430- device_data.pop(device.uuid , None )
431- run_available.pop(device.uuid , None )
430+ device_data.pop(device.serialno , None )
431+ run_available.pop(device.serialno , None )
432432
433433 try :
434434 device.pyhackrf_close()
0 commit comments