Skip to content

Commit 1f706b7

Browse files
committed
updated to new 1.0.6 version
1 parent 5e769e0 commit 1f706b7

16 files changed

Lines changed: 52 additions & 439 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ dist/
88

99
*.egg-info
1010

11-
python_hackrf/libhackrf/hackrf_old.h
12-
python_hackrf/libhackrf/hackrf_old.c
11+
python_hackrf/pylibhackrf/hackrf_old.h
12+
python_hackrf/pylibhackrf/hackrf_old.c

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include python_hackrf/libhackrf/hackrf.h
2-
include python_hackrf/libhackrf/chackrf.pxd
1+
include python_hackrf/pylibhackrf/hackrf.h
2+
include python_hackrf/pylibhackrf/chackrf.pxd
33
include README.md
44
include pyproject.toml

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ options:
6464
-s, --serial_numbers show only founded serial_numbers
6565
```
6666
```
67-
usage: python -m python_hackrf sweep [-h] [-d] [-a] [-f] [-p] [-l] [-g] [-w] [-1] [-N] [-B] [-s] [-SR] [-r]
67+
usage: python -m python_hackrf sweep [-h] [-d] [-a] [-f] [-p] [-l] [-g] [-w] [-1] [-N] [-B] [-s] [-SR] [-BF] [-r]
6868
6969
options:
7070
-h, --help show this help message and exit
@@ -80,6 +80,7 @@ options:
8080
-B binary output. If specified = Enable
8181
-s sweep style ("L" - LINEAR, "I" - INTERLEAVED). Default is INTERLEAVED
8282
-SR sample rate (2, 4, 6, 8, 10, 12, 14, 16, 18, 20). Default is 20
83+
-BF baseband filter (1.75, 2.5, 3.5, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 14.0, 15.0 20.0, 24.0, 28.0). Default is 15.0
8384
-r filename. output file
8485
```
8586
## Note

android/python_hackrf/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class PythonHackrffRecipe(CythonRecipe):
8-
version = '1.0.5'
8+
version = '1.0.6'
99
url = 'https://github.com/GvozdevLeonid/python_hackrf/releases/download/v.{version}/python_hackrf-{version}.tar.gz'
1010
depends = ['python3', 'setuptools', 'libusb']
1111
site_packages_name = 'python_hackrf'
@@ -28,7 +28,7 @@ def postbuild_arch(self, arch):
2828
python_hackrf_dir = os.path.join(self.ctx.get_python_install_dir(arch.arch), 'python_hackrf')
2929
os.makedirs(python_hackrf_dir, exist_ok=True)
3030
try:
31-
shutil.move(os.path.join(self.ctx.get_python_install_dir(arch.arch), 'libhackrf'), os.path.join(python_hackrf_dir, 'libhackrf'))
31+
shutil.move(os.path.join(self.ctx.get_python_install_dir(arch.arch), 'pylibhackrf'), os.path.join(python_hackrf_dir, 'pylibhackrf'))
3232
shutil.move(os.path.join(self.ctx.get_python_install_dir(arch.arch), 'pyhackrf_tools'), os.path.join(python_hackrf_dir, 'pyhackrf_tools'))
3333

3434
shutil.copy(os.path.join(self.get_build_dir(arch.arch), '__init__.py'), python_hackrf_dir)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "python_hackrf"
3-
version = "1.0.5"
3+
version = "1.0.6"
44
authors = [
55
{name="Leonid Gvozdev", email="leo.gvozdev.dev@gmail.com"},
66
]

python_hackrf/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
from python_hackrf.libhackrf import pyhackrf
1+
__version__ = '1.0.6'
2+
3+
from python_hackrf.pylibhackrf import pyhackrf
24
from python_hackrf.pyhackrf_tools import pyhackrf_info, pyhackrf_sweep

python_hackrf/__main__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .pyhackrf_tools import pyhackrf_info, pyhackrf_sweep
2-
from .libhackrf import pyhackrf
2+
from .pylibhackrf import pyhackrf
33
import argparse
44

55
if __name__ == '__main__':
@@ -16,7 +16,7 @@
1616
pyhackrf_info_parser.add_argument('-s', '--serial_numbers', action='store_true', help='show only founded serial_numbers')
1717

1818
pyhackrf_sweep_parser = subparsers.add_parser(
19-
'sweep', help='a command-line spectrum analyzer.', usage='python -m python_hackrf sweep [-h] [-d] [-a] [-f] [-p] [-l] [-g] [-w] [-1] [-N] [-B] [-s] [-SR] [-r]'
19+
'sweep', help='a command-line spectrum analyzer.', usage='python -m python_hackrf sweep [-h] [-d] [-a] [-f] [-p] [-l] [-g] [-w] [-1] [-N] [-B] [-s] [-SR] [-BF] [-r]'
2020
)
2121
pyhackrf_sweep_parser.add_argument('-d', action='store', help='serial_number. serial number of desired HackRF', metavar='')
2222
pyhackrf_sweep_parser.add_argument('-a', action='store_true', help='amp_enable. RX RF amplifier. If specified = Enable')
@@ -30,6 +30,7 @@
3030
pyhackrf_sweep_parser.add_argument('-B', action='store_true', help='binary output. If specified = Enable')
3131
pyhackrf_sweep_parser.add_argument('-s', action='store', help='sweep style ("L" - LINEAR, "I" - INTERLEAVED). Default is INTERLEAVED', metavar='', default='I')
3232
pyhackrf_sweep_parser.add_argument('-SR', action='store', help='sample rate (2, 4, 6, 8, 10, 12, 14, 16, 18, 20). Default is 20', metavar='', default=20)
33+
pyhackrf_sweep_parser.add_argument('-BF', action='store', help='baseband filter (1.75, 2.5, 3.5, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 14.0, 15.0 20.0, 24.0, 28.0). Default is 15.0', metavar='', default=15.0)
3334
pyhackrf_sweep_parser.add_argument('-r', action='store', help='filename. output file', metavar='')
3435
args, unparsed_args = parser.parse_known_args()
3536

@@ -69,5 +70,6 @@
6970
filename=args.r,
7071
sweep_style=pyhackrf.py_sweep_style.LINEAR if args.s == 'L' else pyhackrf.py_sweep_style.INTERLEAVED,
7172
sample_rate=int(args.SR) * 1e6,
73+
baseband_filter=float(args.BF) * 1e6,
7274
print_to_console=True,
7375
)

python_hackrf/pyhackrf_tools/pyhackrf_info.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,23 @@
2626
def pyhackrf_info(print_to_console: bool = True, initialize: bool = True) -> None | str:
2727
if initialize:
2828
pyhackrf.pyhackrf_init()
29+
2930
print_info = ''
3031
device_list = pyhackrf.pyhackrf_device_list()
31-
print_info += f'pyhackrf_info version: {pyhackrf.pyhackrf_library_release()}\n'
32-
print_info += f'pylibhackrf version: {pyhackrf.pyhackrf_library_release()} ({pyhackrf.pyhackrf_library_version()})\n'
33-
print_info += 'Found HackRF\n'
32+
print_info += f'python_hackrf version: {pyhackrf.python_hackrf_library_version()}\n'
33+
print_info += f'libhackrf version: {pyhackrf.pyhackrf_library_release()} ({pyhackrf.pyhackrf_library_version()})\n'
3434

35-
for i in range(device_list.devicecount):
36-
device = pyhackrf.pyhackrf_open_by_serial(device_list.serial_numbers[i])
37-
board_id, board_name = device.pyhackrf_board_id_read()
38-
read_partid_serialno = device.pyhackrf_board_partid_serialno_read()
39-
print_info += f'Index: {i}\n'
40-
print_info += f'Serial number: {device_list.serial_numbers[i]}\n'
41-
print_info += f'Board ID Number: {board_id} ({board_name})\n'
42-
print_info += f'Firmware Version: {device.pyhackrf_version_string_read()} ({device.pyhackrf_usb_api_version_read()})\n'
43-
print_info += f'Part ID Number: 0x{read_partid_serialno["part_id"][0]:08x} 0x{read_partid_serialno["part_id"][1]:08x}\n'
35+
if device_list.devicecount > 0:
36+
print_info += 'Found HackRF:\n'
37+
for i in range(device_list.devicecount):
38+
device = pyhackrf.pyhackrf_open_by_serial(device_list.serial_numbers[i])
39+
board_id, board_name = device.pyhackrf_board_id_read()
40+
read_partid_serialno = device.pyhackrf_board_partid_serialno_read()
41+
print_info += f'Index: {i}\n'
42+
print_info += f'Serial number: {device_list.serial_numbers[i]}\n'
43+
print_info += f'Board ID Number: {board_id} ({board_name})\n'
44+
print_info += f'Firmware Version: {device.pyhackrf_version_string_read()} ({device.pyhackrf_usb_api_version_read()})\n'
45+
print_info += f'Part ID Number: 0x{read_partid_serialno["part_id"][0]:08x} 0x{read_partid_serialno["part_id"][1]:08x}\n'
4446

4547
if print_to_console:
4648
print(print_info)

python_hackrf/pyhackrf_tools/pyhackrf_sweep.pyx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ PY_BLOCKS_PER_TRANSFER = 16
4545
# hackrf sweep settings
4646
AVAILABLE_SAMPLING_RATES = (2_000_000, 4_000_000, 6_000_000, 8_000_000, 10_000_000, 12_000_000, 14_000_000, 16_000_000, 18_000_000, 20_000_000)
4747
AVAILABLE_BASEBAND_FILTER_BANDWIDTHS = (1_750_000, 2_500_000, 3_500_000, 5_000_000, 5_500_000, 6_000_000, 7_000_000, 8_000_000, 9_000_000, 10_000_000, 12_000_000, 14_000_000, 15_000_000, 20_000_000, 24_000_000, 28_000_000)
48-
BASEBAND_FILTER_BANDWIDTH_RATIO = 0.75
4948
INTERLEAVED_OFFSET_RATIO = 0.375
5049
LINEAR_OFFSET_RATIO = 0.5
5150

@@ -229,7 +228,7 @@ cdef sweep_callback(buffer: np.ndarray[:], buffer_length: int, valid_length: int
229228

230229

231230
def pyhackrf_sweep(frequencies: list = [0, 6000], lna_gain: int = 16, vga_gain: int = 20, bin_width: int = 100_000,
232-
serial_number: str = None, amp_enable: bool = False, antenna_enable: bool = False, sample_rate: int = 20_000_000, bandwidth: int = 15_000_000,
231+
serial_number: str = None, amp_enable: bool = False, antenna_enable: bool = False, sample_rate: int = 20_000_000, baseband_filter: int = 15_000_000,
233232
num_sweeps: int = None, binary_output: bool = False, one_shot: bool = False, use_queue: bool = False, filename: str = None, sweep_style: pyhackrf.py_sweep_style = pyhackrf.py_sweep_style.INTERLEAVED,
234233
print_to_console: bool = True, device: pyhackrf.PyHackrfDevice = None):
235234

@@ -250,11 +249,13 @@ def pyhackrf_sweep(frequencies: list = [0, 6000], lna_gain: int = 16, vga_gain:
250249
SAMPLE_RATE = int(sample_rate)
251250
else:
252251
SAMPLE_RATE = 20_000_000
253-
254-
if bandwidth in AVAILABLE_BASEBAND_FILTER_BANDWIDTHS:
255-
BASEBAND_FILTER_BANDWIDTH = int(bandwidth)
252+
253+
SAMPLE_RATE = int(sample_rate)
254+
255+
if baseband_filter in AVAILABLE_BASEBAND_FILTER_BANDWIDTHS:
256+
BASEBAND_FILTER_BANDWIDTH = int(baseband_filter)
256257
else:
257-
BASEBAND_FILTER_BANDWIDTH = int(SAMPLE_RATE * BASEBAND_FILTER_BANDWIDTH_RATIO)
258+
BASEBAND_FILTER_BANDWIDTH = pyhackrf.pyhackrf_compute_baseband_filter_bw(int(baseband_filter))
258259

259260
frequency_step_1 = sample_rate // 4
260261
frequency_step_2 = sample_rate // 2

0 commit comments

Comments
 (0)