Skip to content

Commit afb6aec

Browse files
committed
fixed issue
1 parent e8ed4cc commit afb6aec

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

python_hackrf/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ def main() -> None:
165165
except Exception:
166166
pass
167167

168-
if port_a is None:
168+
if args.a is None:
169169
if port_b[0] == 'B':
170170
port_a = 'A1'
171171
else:
172172
port_a = 'B1'
173173

174-
if port_b is None:
174+
if args.b is None:
175175
if port_a[0] == 'B':
176176
port_b = 'A1'
177177
else:

python_hackrf/pyhackrf_tools/pyhackrf_operacake.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ def pyhackrf_operacake_gpio_test(address: int,
177177
if test_result == 0xFFFF:
178178
print('GPIO mode disabled.')
179179
print('Remove additional add-on boards and retry.')
180+
180181
elif test_result:
181182
reg, mask = 0x7, 0x7
182183

python_hackrf/pyhackrf_tools/pyhackrf_transfer.pyx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from python_hackrf import pyhackrf
2626
import numpy as np
27+
cimport numpy as cnp
2728
cimport cython
2829
import signal
2930
import time
@@ -75,18 +76,18 @@ cdef rx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np.uint8_t,
7576
if not run_available[device.serialno]:
7677
return -1
7778

78-
current_device_data = device_data[device.serialno]
79+
cdef dict current_device_data = device_data[device.serialno]
7980

8081
current_device_data['byte_count'] += valid_length
8182
current_device_data['stream_power'] += np.sum(buffer[:valid_length].view(np.int8).astype(np.uint64, copy=False) ** 2)
8283

83-
to_read = valid_length
84+
cdef int to_read = valid_length
8485
if current_device_data['num_samples']:
8586
if (to_read > current_device_data['num_samples'] * 2):
8687
to_read = current_device_data['num_samples'] * 2
8788
current_device_data['num_samples'] -= (to_read // 2)
8889

89-
accepted_data = (buffer[:to_read:2].astype(np.int8, copy=False) / 128 + 1j * buffer[1:to_read:2].astype(np.int8, copy=False) / 128).astype(np.complex64)
90+
cdef cnp.ndarray accepted_data = (buffer[:to_read:2].astype(np.int8, copy=False) / 128 + 1j * buffer[1:to_read:2].astype(np.int8, copy=False) / 128).astype(np.complex64)
9091

9192
if current_device_data['rx_queue'] is not None:
9293
current_device_data['rx_queue'].put_nowait(accepted_data)
@@ -105,13 +106,13 @@ cdef rx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np.uint8_t,
105106
cdef tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np.uint8_t, 1], buffer_length: int, valid_length: int):
106107
global run_available, device_data
107108

108-
current_device_data = device_data[device.serialno]
109+
cdef dict current_device_data = device_data[device.serialno]
109110

110111
if current_device_data['tx_complete'] or not run_available[device.serialno]:
111112
return -1, buffer, valid_length
112113

113-
to_write = buffer_length // 2
114-
writed = 0
114+
cdef int to_write = buffer_length // 2
115+
cdef int writed = 0
115116
if current_device_data['num_samples']:
116117
if (to_write > current_device_data['num_samples']):
117118
to_write = current_device_data['num_samples']
@@ -219,7 +220,7 @@ cdef tx_complete_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np
219220
run_available[device.serialno] = False
220221
return
221222

222-
current_device_data = device_data[device.serialno]
223+
cdef dict current_device_data = device_data[device.serialno]
223224

224225
current_device_data['byte_count'] += valid_length
225226
current_device_data['stream_power'] += np.sum(buffer[:valid_length].view(np.int8).astype(np.uint64, copy=False) ** 2)
@@ -228,7 +229,7 @@ cdef tx_complete_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np
228229
cdef flush_callback(device: pyhackrf.PyHackrfDevice, success: int):
229230
global run_available, device_data
230231

231-
current_device_data = device_data[device.serialno]
232+
cdef dict current_device_data = device_data[device.serialno]
232233

233234
if success:
234235
current_device_data['flush_complete'] = True
@@ -259,7 +260,7 @@ def pyhackrf_transfer(frequency: int = None, sample_rate: int = 10_000_000, base
259260
if num_samples and num_samples >= SAMPLES_TO_XFER_MAX:
260261
raise RuntimeError(f'num_samples must be less than {SAMPLES_TO_XFER_MAX}')
261262

262-
current_device_data = {
263+
cdef dict current_device_data = {
263264
'num_samples': num_samples,
264265
'flush_complete': False,
265266
'repeat_tx': repeat_tx,
@@ -378,8 +379,12 @@ def pyhackrf_transfer(frequency: int = None, sample_rate: int = 10_000_000, base
378379
if num_samples and print_to_console:
379380
sys.stderr.write(f'samples_to_xfer {num_samples}/{num_samples / 1e6:.3f} Mio\n')
380381

381-
time_start = time.time()
382-
time_prev = time.time()
382+
cdef double time_start = time.time()
383+
cdef double time_prev = time.time()
384+
cdef double time_difference = 0
385+
cdef int byte_count = 0
386+
cdef int stream_power = 0
387+
cdef double dB_full_scale = 0
383388
while run_available[device.serialno]:
384389
time.sleep(0.05)
385390
time_now = time.time()

python_hackrf/pylibhackrf/pyhackrf.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class py_operacake_switching_mode(IntEnum):
6666

6767
cdef dict global_callbacks = {}
6868

69-
cdef dict operacake_ports = {
69+
cdef public dict operacake_ports = {
7070
'A1': 0,
7171
'A2': 1,
7272
'A3': 2,

python_hackrf/pylibhackrf/pyhackrf_android.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class py_operacake_switching_mode(IntEnum):
6767

6868
cdef dict global_callbacks = {}
6969

70-
cdef dict operacake_ports = {
70+
cdef public dict operacake_ports = {
7171
'A1': 0,
7272
'A2': 1,
7373
'A3': 2,

0 commit comments

Comments
 (0)