Skip to content

Commit

Permalink
Update RTLSDR.py (#1057)
Browse files Browse the repository at this point in the history
Update rtlsdr.pyx

Update crtlsdr.pxd

Update config.py
  • Loading branch information
jirjirjir authored Jun 19, 2023
1 parent 5e342d7 commit ace4559
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/urh/dev/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
4 changes: 3 additions & 1 deletion src/urh/dev/native/RTLSDR.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/urh/dev/native/lib/crtlsdr.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 8 additions & 0 deletions src/urh/dev/native/lib/rtlsdr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit ace4559

Please sign in to comment.