Skip to content

Commit c2cb4fe

Browse files
committed
cleaned up the code
1 parent 8970418 commit c2cb4fe

File tree

2 files changed

+0
-44
lines changed

2 files changed

+0
-44
lines changed

python_hackrf/pylibhackrf/pyhackrf.pyx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ PY_HACKRF_OPERACAKE_MAX_BOARDS = chackrf.HACKRF_OPERACAKE_MAX_BOARDS
4141
PY_HACKRF_OPERACAKE_MAX_DWELL_TIMES = chackrf.HACKRF_OPERACAKE_MAX_DWELL_TIMES
4242
PY_HACKRF_OPERACAKE_MAX_FREQ_RANGES = chackrf.HACKRF_OPERACAKE_MAX_FREQ_RANGES
4343

44-
4544
class py_rf_path_filter(IntEnum):
4645
RF_PATH_FILTER_BYPASS = chackrf.rf_path_filter.RF_PATH_FILTER_BYPASS
4746
RF_PATH_FILTER_LOW_PASS = chackrf.rf_path_filter.RF_PATH_FILTER_LOW_PASS
@@ -50,15 +49,13 @@ class py_rf_path_filter(IntEnum):
5049
def __str__(self) -> str:
5150
return self.name
5251

53-
5452
class py_sweep_style(IntEnum):
5553
LINEAR = chackrf.sweep_style.LINEAR
5654
INTERLEAVED = chackrf.sweep_style.INTERLEAVED
5755

5856
def __str__(self) -> str:
5957
return self.name
6058

61-
6259
class py_operacake_switching_mode(IntEnum):
6360
OPERACAKE_MODE_MANUAL = chackrf.operacake_switching_mode.OPERACAKE_MODE_MANUAL
6461
OPERACAKE_MODE_FREQUENCY = chackrf.operacake_switching_mode.OPERACAKE_MODE_FREQUENCY
@@ -67,7 +64,6 @@ class py_operacake_switching_mode(IntEnum):
6764
def __str__(self) -> str:
6865
return self.name
6966

70-
7167
class py_operacake_ports(IntEnum):
7268
A1: 0
7369
A2: 1
@@ -89,7 +85,6 @@ class py_operacake_ports(IntEnum):
8985
return item in cls
9086
return False
9187

92-
9388
@cython.boundscheck(False)
9489
@cython.wraparound(False)
9590
cdef int __rx_callback(chackrf.hackrf_transfer *transfer) nogil:
@@ -113,7 +108,6 @@ cdef int __rx_callback(chackrf.hackrf_transfer *transfer) nogil:
113108

114109
return result
115110

116-
117111
@cython.boundscheck(False)
118112
@cython.wraparound(False)
119113
cdef int __tx_callback(chackrf.hackrf_transfer *transfer) nogil:
@@ -141,7 +135,6 @@ cdef int __tx_callback(chackrf.hackrf_transfer *transfer) nogil:
141135

142136
return result
143137

144-
145138
@cython.boundscheck(False)
146139
@cython.wraparound(False)
147140
cdef int __sweep_callback(chackrf.hackrf_transfer *transfer) nogil:
@@ -165,7 +158,6 @@ cdef int __sweep_callback(chackrf.hackrf_transfer *transfer) nogil:
165158

166159
return result
167160

168-
169161
@cython.boundscheck(False)
170162
@cython.wraparound(False)
171163
cdef void __tx_complete_callback(chackrf.hackrf_transfer *transfer, int success) nogil:
@@ -186,7 +178,6 @@ cdef void __tx_complete_callback(chackrf.hackrf_transfer *transfer, int success)
186178
if global_callbacks[<size_t> transfer.device]['__tx_complete_callback'] is not None:
187179
global_callbacks[<size_t> transfer.device]['__tx_complete_callback'](global_callbacks[<size_t> transfer.device]['device'], np_buffer, transfer.buffer_length, transfer.valid_length, success)
188180

189-
190181
cdef void __tx_flush_callback(void *flush_ctx, int success) noexcept nogil:
191182
global global_callbacks
192183
cdef size_t device_ptr = <size_t> flush_ctx
@@ -195,7 +186,6 @@ cdef void __tx_flush_callback(void *flush_ctx, int success) noexcept nogil:
195186
if global_callbacks[device_ptr]['__tx_flush_callback'] is not None:
196187
global_callbacks[device_ptr]['__tx_flush_callback'](global_callbacks[device_ptr]['device'], success)
197188

198-
199189
cdef class PyHackRFDeviceList:
200190
cdef chackrf.hackrf_device_list_t *__hackrf_device_list
201191

@@ -227,7 +217,6 @@ cdef class PyHackRFDeviceList:
227217
if self.__hackrf_device_list is not NULL:
228218
return chackrf.hackrf_board_id_name(self.__hackrf_device_list[0].usb_board_ids[index]).decode('utf-8')
229219

230-
231220
cdef class PyHackrfDevice:
232221

233222
cdef chackrf.hackrf_device *__hackrf_device
@@ -716,38 +705,31 @@ cdef class PyHackrfDevice:
716705
raise RuntimeError(f'pyhackrf_operacake_gpio_test() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
717706
return test_result
718707

719-
720708
# ---- initialization and exit ---- #
721709
def pyhackrf_init() -> None:
722710
result = chackrf.hackrf_init()
723711
if result != chackrf.hackrf_error.HACKRF_SUCCESS:
724712
raise RuntimeError(f'pyhackrf_init() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
725713

726-
727714
def pyhackrf_exit() -> None:
728715
result = chackrf.hackrf_exit()
729716
if result != chackrf.hackrf_error.HACKRF_SUCCESS:
730717
raise RuntimeError(f'pyhackrf_exit() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
731718

732-
733719
# ---- version ---- #
734720
def python_hackrf_library_version() -> str:
735721
return __version__
736722

737-
738723
def pyhackrf_library_version() -> str:
739724
return chackrf.hackrf_library_version().decode('utf-8')
740725

741-
742726
def pyhackrf_library_release() -> str:
743727
return chackrf.hackrf_library_release().decode('utf-8')
744728

745-
746729
# ---- device ---- #
747730
def pyhackrf_device_list() -> PyHackRFDeviceList:
748731
return PyHackRFDeviceList()
749732

750-
751733
def pyhackrf_device_list_open(pyhackrf_device_list: PyHackRFDeviceList, index: int) -> PyHackrfDevice | None:
752734
pyhackrf_device = PyHackrfDevice()
753735
result = chackrf.hackrf_device_list_open(pyhackrf_device_list.get_hackrf_device_list_ptr(), index, pyhackrf_device.get_hackrf_device_double_ptr())
@@ -758,7 +740,6 @@ def pyhackrf_device_list_open(pyhackrf_device_list: PyHackRFDeviceList, index: i
758740

759741
raise RuntimeError(f'pyhackrf_device_list_open() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
760742

761-
762743
def pyhackrf_open() -> PyHackrfDevice | None:
763744
pyhackrf_device = PyHackrfDevice()
764745

@@ -770,7 +751,6 @@ def pyhackrf_open() -> PyHackrfDevice | None:
770751

771752
raise RuntimeError(f'pyhackrf_open() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
772753

773-
774754
def pyhackrf_open_by_serial(desired_serial_number: str) -> PyHackrfDevice | None:
775755
if desired_serial_number in (None, ''):
776756
return pyhackrf_open()
@@ -784,11 +764,9 @@ def pyhackrf_open_by_serial(desired_serial_number: str) -> PyHackrfDevice | None
784764

785765
raise RuntimeError(f'pyhackrf_open_by_serial() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
786766

787-
788767
# ---- baseband filter bandwidth ---- #
789768
def pyhackrf_compute_baseband_filter_bw_round_down_lt(bandwidth_hz: int) -> int:
790769
return chackrf.hackrf_compute_baseband_filter_bw_round_down_lt(<uint32_t> bandwidth_hz)
791770

792-
793771
def pyhackrf_compute_baseband_filter_bw(bandwidth_hz: int) -> int:
794772
return chackrf.hackrf_compute_baseband_filter_bw(<uint32_t> bandwidth_hz)

python_hackrf/pylibhackrf/pyhackrf_android.pyx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ from ctypes import c_int
3232
import numpy as np
3333
cimport cython
3434

35-
3635
cdef dict global_callbacks = {}
3736

3837
PY_BYTES_PER_BLOCK = chackrf.BYTES_PER_BLOCK
@@ -42,7 +41,6 @@ PY_HACKRF_OPERACAKE_MAX_BOARDS = chackrf.HACKRF_OPERACAKE_MAX_BOARDS
4241
PY_HACKRF_OPERACAKE_MAX_DWELL_TIMES = chackrf.HACKRF_OPERACAKE_MAX_DWELL_TIMES
4342
PY_HACKRF_OPERACAKE_MAX_FREQ_RANGES = chackrf.HACKRF_OPERACAKE_MAX_FREQ_RANGES
4443

45-
4644
class py_rf_path_filter(IntEnum):
4745
RF_PATH_FILTER_BYPASS = chackrf.rf_path_filter.RF_PATH_FILTER_BYPASS
4846
RF_PATH_FILTER_LOW_PASS = chackrf.rf_path_filter.RF_PATH_FILTER_LOW_PASS
@@ -51,15 +49,13 @@ class py_rf_path_filter(IntEnum):
5149
def __str__(self) -> str:
5250
return self.name
5351

54-
5552
class py_sweep_style(IntEnum):
5653
LINEAR = chackrf.sweep_style.LINEAR
5754
INTERLEAVED = chackrf.sweep_style.INTERLEAVED
5855

5956
def __str__(self) -> str:
6057
return self.name
6158

62-
6359
class py_operacake_switching_mode(IntEnum):
6460
OPERACAKE_MODE_MANUAL = chackrf.operacake_switching_mode.OPERACAKE_MODE_MANUAL
6561
OPERACAKE_MODE_FREQUENCY = chackrf.operacake_switching_mode.OPERACAKE_MODE_FREQUENCY
@@ -68,7 +64,6 @@ class py_operacake_switching_mode(IntEnum):
6864
def __str__(self) -> str:
6965
return self.name
7066

71-
7267
class py_operacake_ports(IntEnum):
7368
A1: 0
7469
A2: 1
@@ -90,7 +85,6 @@ class py_operacake_ports(IntEnum):
9085
return item in cls
9186
return False
9287

93-
9488
@cython.boundscheck(False)
9589
@cython.wraparound(False)
9690
cdef int __rx_callback(chackrf.hackrf_transfer *transfer) nogil:
@@ -114,7 +108,6 @@ cdef int __rx_callback(chackrf.hackrf_transfer *transfer) nogil:
114108

115109
return result
116110

117-
118111
@cython.boundscheck(False)
119112
@cython.wraparound(False)
120113
cdef int __tx_callback(chackrf.hackrf_transfer *transfer) nogil:
@@ -142,7 +135,6 @@ cdef int __tx_callback(chackrf.hackrf_transfer *transfer) nogil:
142135

143136
return result
144137

145-
146138
@cython.boundscheck(False)
147139
@cython.wraparound(False)
148140
cdef int __sweep_callback(chackrf.hackrf_transfer *transfer) nogil:
@@ -166,7 +158,6 @@ cdef int __sweep_callback(chackrf.hackrf_transfer *transfer) nogil:
166158

167159
return result
168160

169-
170161
@cython.boundscheck(False)
171162
@cython.wraparound(False)
172163
cdef void __tx_complete_callback(chackrf.hackrf_transfer *transfer, int success) nogil:
@@ -187,7 +178,6 @@ cdef void __tx_complete_callback(chackrf.hackrf_transfer *transfer, int success)
187178
if global_callbacks[<size_t> transfer.device]['__tx_complete_callback'] is not None:
188179
global_callbacks[<size_t> transfer.device]['__tx_complete_callback'](global_callbacks[<size_t> transfer.device]['device'], np_buffer, transfer.buffer_length, transfer.valid_length, success)
189180

190-
191181
cdef void __tx_flush_callback(void *flush_ctx, int success) noexcept nogil:
192182
global global_callbacks
193183
cdef size_t device_ptr = <size_t> flush_ctx
@@ -196,7 +186,6 @@ cdef void __tx_flush_callback(void *flush_ctx, int success) noexcept nogil:
196186
if global_callbacks[device_ptr]['__tx_flush_callback'] is not None:
197187
global_callbacks[device_ptr]['__tx_flush_callback'](global_callbacks[device_ptr]['device'], success)
198188

199-
200189
cdef class PyHackRFDeviceList:
201190
cdef list __hackrf_device_list
202191

@@ -711,38 +700,31 @@ cdef class PyHackrfDevice:
711700
raise RuntimeError(f'pyhackrf_operacake_gpio_test() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
712701
return test_result
713702

714-
715703
# ---- initialization and exit ---- #
716704
def pyhackrf_init() -> None:
717705
result = chackrf.hackrf_init_on_android()
718706
if result != chackrf.hackrf_error.HACKRF_SUCCESS:
719707
raise RuntimeError(f'pyhackrf_init() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
720708

721-
722709
def pyhackrf_exit() -> None:
723710
result = chackrf.hackrf_exit()
724711
if result != chackrf.hackrf_error.HACKRF_SUCCESS:
725712
raise RuntimeError(f'pyhackrf_exit() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
726713

727-
728714
# ---- version ---- #
729715
def python_hackrf_library_version() -> str:
730716
return __version__
731717

732-
733718
def pyhackrf_library_version() -> str:
734719
return chackrf.hackrf_library_version().decode('utf-8')
735720

736-
737721
def pyhackrf_library_release() -> str:
738722
return chackrf.hackrf_library_release().decode('utf-8')
739723

740-
741724
# ---- device ---- #
742725
def pyhackrf_device_list() -> PyHackRFDeviceList:
743726
return PyHackRFDeviceList()
744727

745-
746728
def pyhackrf_device_list_open(pyhackrf_device_list: PyHackRFDeviceList, index: int) -> PyHackrfDevice | None:
747729
pyhackrf_device = PyHackrfDevice()
748730
result = chackrf.hackrf_open_on_android(pyhackrf_device_list.file_descriptors[index], pyhackrf_device.get_hackrf_device_double_ptr())
@@ -753,7 +735,6 @@ def pyhackrf_device_list_open(pyhackrf_device_list: PyHackRFDeviceList, index: i
753735

754736
raise RuntimeError(f'pyhackrf_device_list_open() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
755737

756-
757738
def pyhackrf_open() -> PyHackrfDevice | None:
758739
hackrf_device_list = get_hackrf_device_list(1)
759740
result = chackrf.hackrf_error.HACKRF_ERROR_NOT_FOUND
@@ -767,7 +748,6 @@ def pyhackrf_open() -> PyHackrfDevice | None:
767748

768749
raise RuntimeError(f'pyhackrf_open() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
769750

770-
771751
def pyhackrf_open_by_serial(desired_serial_number: str) -> PyHackrfDevice | None:
772752
if desired_serial_number in (None, ''):
773753
return pyhackrf_open()
@@ -786,11 +766,9 @@ def pyhackrf_open_by_serial(desired_serial_number: str) -> PyHackrfDevice | None
786766

787767
raise RuntimeError(f'pyhackrf_open_by_serial() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
788768

789-
790769
# ---- baseband filter bandwidth ---- #
791770
def pyhackrf_compute_baseband_filter_bw_round_down_lt(bandwidth_hz: int) -> int:
792771
return chackrf.hackrf_compute_baseband_filter_bw_round_down_lt(<uint32_t> bandwidth_hz)
793772

794-
795773
def pyhackrf_compute_baseband_filter_bw(bandwidth_hz: int) -> int:
796774
return chackrf.hackrf_compute_baseband_filter_bw(<uint32_t> bandwidth_hz)

0 commit comments

Comments
 (0)