From ace45594d97c8b11847ca6b54026fbcdb7c8f430 Mon Sep 17 00:00:00 2001 From: jirjirjir <57523418+jirjirjir@users.noreply.github.com> Date: Mon, 19 Jun 2023 08:52:59 +0300 Subject: [PATCH] Update RTLSDR.py (#1057) Update rtlsdr.pyx Update crtlsdr.pxd Update config.py --- src/urh/dev/config.py | 3 ++- src/urh/dev/native/RTLSDR.py | 4 +++- src/urh/dev/native/lib/crtlsdr.pxd | 2 ++ src/urh/dev/native/lib/rtlsdr.pyx | 8 ++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/urh/dev/config.py b/src/urh/dev/config.py index e72ca680fb..7533132953 100644 --- a/src/urh/dev/config.py +++ b/src/urh/dev/config.py @@ -99,7 +99,8 @@ "bandwidth": dev_range(start=1, stop=int(3.2 * M), step=1), "rx_rf_gain": list(range(-100, 500)), "direct_sampling": ["disabled", "I-ADC input enabled", "Q-ADC input enabled"], - "freq_correction": dev_range(start=-1 * 10 ** 3, stop=1 * 10 ** 3, step=1) + "freq_correction": dev_range(start=-1 * 10 ** 3, stop=1 * 10 ** 3, step=1), + "bias_tee_enabled": [False, True] } DEVICE_CONFIG["RTL-TCP"] = copy.deepcopy(DEVICE_CONFIG["RTL-SDR"]) diff --git a/src/urh/dev/native/RTLSDR.py b/src/urh/dev/native/RTLSDR.py index 3b5fcf23e4..9aa0a496d0 100644 --- a/src/urh/dev/native/RTLSDR.py +++ b/src/urh/dev/native/RTLSDR.py @@ -18,7 +18,8 @@ class RTLSDR(Device): Device.Command.SET_RF_GAIN.name+"_get_allowed_values": "get_tuner_gains", Device.Command.SET_BANDWIDTH.name: "set_tuner_bandwidth", Device.Command.SET_FREQUENCY_CORRECTION.name: "set_freq_correction", - Device.Command.SET_DIRECT_SAMPLING_MODE.name: "set_direct_sampling" + Device.Command.SET_DIRECT_SAMPLING_MODE.name: "set_direct_sampling", + Device.Command.SET_BIAS_TEE_ENABLED.name: "set_bias_tee" }) DATA_TYPE = np.int8 @@ -77,6 +78,7 @@ def device_parameters(self): (self.Command.SET_FREQUENCY_CORRECTION.name, self.freq_correction), (self.Command.SET_DIRECT_SAMPLING_MODE.name, self.direct_sampling_mode), (self.Command.SET_RF_GAIN.name, self.gain), + (self.Command.SET_BIAS_TEE_ENABLED.name, self.bias_tee_enabled), ("identifier", self.device_number)]) @property diff --git a/src/urh/dev/native/lib/crtlsdr.pxd b/src/urh/dev/native/lib/crtlsdr.pxd index 415fa6a417..6415d3ff30 100644 --- a/src/urh/dev/native/lib/crtlsdr.pxd +++ b/src/urh/dev/native/lib/crtlsdr.pxd @@ -69,3 +69,5 @@ cdef extern from "rtl-sdr.h": int rtlsdr_read_async(rtlsdr_dev_t *dev, rtlsdr_read_async_cb_t cb, void *ctx, uint32_t buf_num, uint32_t buf_len); int rtlsdr_cancel_async(rtlsdr_dev_t *dev) + + int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on) \ No newline at end of file diff --git a/src/urh/dev/native/lib/rtlsdr.pyx b/src/urh/dev/native/lib/rtlsdr.pyx index b37cf77e94..c1ea1ad464 100644 --- a/src/urh/dev/native/lib/rtlsdr.pyx +++ b/src/urh/dev/native/lib/rtlsdr.pyx @@ -332,3 +332,11 @@ cpdef int cancel_async(): :return: 0 on success """ return crtlsdr.rtlsdr_cancel_async(_c_device) + +cpdef int set_bias_tee(int on): + """ + Enable or disable the bias tee on GPIO PIN 0. + + return -1 if device is not initialized. 0 otherwise. + """ + return crtlsdr.rtlsdr_set_bias_tee (_c_device, on) \ No newline at end of file