Skip to content

Commit a4f154f

Browse files
committed
Tuning indexing
1 parent a2e772d commit a4f154f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

python_hackrf/pyhackrf_tools/pyhackrf_sweep.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ from libc.stdint cimport uint32_t, uint64_t
3434
from python_hackrf import pyhackrf
3535
import numpy as np
3636
import datetime
37+
cimport cython
3738
import signal
3839
import struct
3940
import time
@@ -72,6 +73,8 @@ def init_signals():
7273
pass
7374

7475

76+
@cython.boundscheck(False)
77+
@cython.wraparound(False)
7578
cdef sweep_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np.uint8_t, 1], buffer_length: int, valid_length: int):
7679
global run_available, device_data
7780

@@ -189,13 +192,13 @@ cdef sweep_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np.uint8
189192
pwr_2 = pwr[pwr_2_start:pwr_2_stop]
190193
for i in range(len(pwr_2)):
191194
line += f'{pwr_2[i]:.10f}, '
192-
line = line[:-2] + '\n'
195+
line = line[:len(line) - 2] + '\n'
193196

194197
else:
195198
line = f'{time_str}, {frequency}, {frequency + sample_rate}, {sample_rate / fft_size}, {fft_size}, '
196199
for i in range(len(pwr)):
197200
line += f'{pwr[i]:.2f}, '
198-
line = line[:-2] + '\n'
201+
line = line[:len(line) - 2] + '\n'
199202

200203
current_device_data['file'].write(line)
201204

python_hackrf/pyhackrf_tools/pyhackrf_transfer.pyx

Lines changed: 7 additions & 0 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 cython
2728
import signal
2829
import time
2930
import sys
@@ -66,6 +67,8 @@ def init_signals():
6667
pass
6768

6869

70+
@cython.boundscheck(False)
71+
@cython.wraparound(False)
6972
cdef rx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np.uint8_t, 1], buffer_length: int, valid_length: int):
7073
global run_available, device_data
7174

@@ -97,6 +100,8 @@ cdef rx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np.uint8_t,
97100
return 0
98101

99102

103+
@cython.boundscheck(False)
104+
@cython.wraparound(False)
100105
cdef tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np.uint8_t, 1], buffer_length: int, valid_length: int):
101106
global run_available, device_data
102107

@@ -205,6 +210,8 @@ cdef tx_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np.uint8_t,
205210
return 0, buffer, valid_length
206211

207212

213+
@cython.boundscheck(False)
214+
@cython.wraparound(False)
208215
cdef tx_complete_callback(device: pyhackrf.PyHackrfDevice, buffer: np.ndarray[np.uint8_t, 1], buffer_length: int, valid_length: int, success: int):
209216
global run_available, device_data
210217

0 commit comments

Comments
 (0)