@@ -31,6 +31,7 @@ from libc.stdlib cimport malloc, free
3131from enum import IntEnum
3232cimport numpy as np
3333import numpy as np
34+ import uuid
3435
3536PY_BYTES_PER_BLOCK = chackrf.BYTES_PER_BLOCK
3637PY_MAX_SWEEP_RANGES = chackrf.MAX_SWEEP_RANGES
@@ -157,10 +158,9 @@ cdef class PyHackrfDevice:
157158
158159 cdef chackrf.hackrf_device* __hackrf_device
159160 cdef list __pyoperacakes
160- cdef public str serialno
161+ cdef public str uuid
161162
162163 def __cinit__ (self ):
163- self .serialno = self .pyhackrf_serialno_read()
164164 self .__hackrf_device = NULL
165165 self .__pyoperacakes = []
166166
@@ -183,11 +183,12 @@ cdef class PyHackrfDevice:
183183 cdef chackrf.hackrf_device** get_hackrf_device_double_ptr(self ):
184184 return & self .__hackrf_device
185185
186- # ---- callbacks ---- #
187- cdef _setup_callbacks(self ):
186+ cdef _setup_device(self ):
188187 global global_callbacks
189188
190189 if self .__hackrf_device is not NULL :
190+ self .serialno = self .pyhackrf_serialno_read()
191+
191192 global_callbacks[< size_t> self .__hackrf_device] = {
192193 ' __rx_callback' : None ,
193194 ' __tx_callback' : None ,
@@ -198,7 +199,7 @@ cdef class PyHackrfDevice:
198199 }
199200 return
200201
201- raise RuntimeError (f' __setup_callbacks () failed: Device not initialized!' )
202+ raise RuntimeError (f' _setup_device () failed: Device not initialized!' )
202203
203204 # ---- device ---- #
204205 def pyhackrf_close (self ) -> None:
@@ -680,7 +681,7 @@ def pyhackrf_device_list_open(pyhackrf_device_list: PyHackRFDeviceList, index: i
680681 result = chackrf.hackrf_open_on_android(pyhackrf_device_list.file_descriptors[index], pyhackrf_device.get_hackrf_device_double_ptr())
681682
682683 if result == chackrf.hackrf_error.HACKRF_SUCCESS:
683- pyhackrf_device._setup_callbacks ()
684+ pyhackrf_device._setup_device ()
684685 return pyhackrf_device
685686
686687 raise RuntimeError(f'pyhackrf_device_list_open() failed: {chackrf.hackrf_error_name(result ).decode("utf-8")} ({result})')
@@ -694,7 +695,7 @@ def pyhackrf_open() -> PyHackrfDevice | None:
694695 pyhackrf_device = PyHackrfDevice()
695696 result = chackrf.hackrf_open_on_android(device_list[0 ][0 ], pyhackrf_device.get_hackrf_device_double_ptr())
696697 if result == chackrf.hackrf_error.HACKRF_SUCCESS:
697- pyhackrf_device._setup_callbacks ()
698+ pyhackrf_device._setup_device ()
698699 return pyhackrf_device
699700
700701 raise RuntimeError (f' pyhackrf_open() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})' )
@@ -708,12 +709,12 @@ def pyhackrf_open_by_serial(desired_serial_number: str) -> PyHackrfDevice | None
708709 result = chackrf.hackrf_error.HACKRF_ERROR_NOT_FOUND
709710
710711 if len (device_list):
711- for file_descriptor, _ , serial_number in device_list:
712+ for file_descriptor, board_id , serial_number in device_list:
712713 if serial_number == desired_serial_number:
713714 pyhackrf_device = PyHackrfDevice()
714715 result = chackrf.hackrf_open_on_android(file_descriptor, pyhackrf_device.get_hackrf_device_double_ptr())
715716 if result == chackrf.hackrf_error.HACKRF_SUCCESS:
716- pyhackrf_device._setup_callbacks ()
717+ pyhackrf_device._setup_device ()
717718 return pyhackrf_device
718719
719720 raise RuntimeError (f' pyhackrf_open_by_serial() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})' )
0 commit comments