Skip to content

Commit 22ccca2

Browse files
committed
added boundaries for tx gain
1 parent 31b7812 commit 22ccca2

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

python_hackrf/pylibhackrf/pyhackrf.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ cdef class PyHackrfDevice:
364364
raise RuntimeError(f'pyhackrf_set_vga_gain() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
365365

366366
def pyhackrf_set_txvga_gain(self, value: int) -> None:
367+
value = int(max(0, min(47, value)))
367368
result = chackrf.hackrf_set_txvga_gain(self.__hackrf_device, <uint32_t> value)
368369
if result != chackrf.hackrf_error.HACKRF_SUCCESS:
369370
raise RuntimeError(f'pyhackrf_set_txvga_gain() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')

python_hackrf/pylibhackrf/pyhackrf_android.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ cdef class PyHackrfDevice:
363363
raise RuntimeError(f'pyhackrf_set_vga_gain() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')
364364

365365
def pyhackrf_set_txvga_gain(self, value: int) -> None:
366+
value = int(max(0, min(47, value)))
366367
result = chackrf.hackrf_set_txvga_gain(self.__hackrf_device, <uint32_t> value)
367368
if result != chackrf.hackrf_error.HACKRF_SUCCESS:
368369
raise RuntimeError(f'pyhackrf_set_txvga_gain() failed: {chackrf.hackrf_error_name(result).decode("utf-8")} ({result})')

0 commit comments

Comments
 (0)