Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bias tee check box on device settings #854

Merged
merged 8 commits into from
May 16, 2021
1 change: 1 addition & 0 deletions src/urh/controller/widgets/DeviceSettingsWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ def emit_editing_finished_signals(self):
self.ui.comboBoxAntenna.currentIndexChanged.emit(self.ui.comboBoxAntenna.currentIndex())
self.ui.comboBoxChannel.currentIndexChanged.emit(self.ui.comboBoxChannel.currentIndex())
self.ui.checkBoxDCCorrection.clicked.emit(self.ui.checkBoxDCCorrection.isChecked())
self.ui.checkBoxBiasTee.clicked.emit(self.ui.checkBoxBiasTee.isChecked())

def emit_device_parameters_changed(self):
settings = {"name": str(self.device.name)}
Expand Down
1 change: 1 addition & 0 deletions src/urh/dev/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"tx_channel": ["TX1", "TX2"],
"tx_rf_gain": list(range(0, 61)),
"rx_rf_gain": list(range(0, 61)),
"bias_tee_enabled": [False, True]
}

# https://github.com/mossmann/hackrf/wiki/HackRF-One#features
Expand Down
4 changes: 3 additions & 1 deletion src/urh/dev/native/BladeRF.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class BladeRF(Device):
DEVICE_METHODS = Device.DEVICE_METHODS.copy()
DEVICE_METHODS.update({
Device.Command.SET_RF_GAIN.name: "set_gain",
Device.Command.SET_CHANNEL_INDEX.name: "set_channel"
Device.Command.SET_CHANNEL_INDEX.name: "set_channel",
Device.Command.SET_BIAS_TEE_ENABLED.name: "set_bias_tee"
})

DATA_TYPE = np.int16
Expand Down Expand Up @@ -96,6 +97,7 @@ def device_parameters(self):
(self.Command.SET_SAMPLE_RATE.name, self.sample_rate),
(self.Command.SET_BANDWIDTH.name, self.bandwidth),
(self.Command.SET_RF_GAIN.name, self.gain),
(self.Command.SET_BIAS_TEE_ENABLED.name, self.bias_tee_enabled),
("identifier", self.device_serial)])

@staticmethod
Expand Down
29 changes: 24 additions & 5 deletions src/urh/dev/native/lib/bladerf.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,32 @@ cpdef int set_center_freq(bladerf_frequency frequency):
return bladerf_set_frequency(_c_device, get_current_bladerf_channel(), frequency)

cpdef bladerf_frequency get_center_freq():
cdef bladerf_frequency result = 0
err = bladerf_get_frequency(_c_device, get_current_bladerf_channel(), &result)
cdef bladerf_frequency result = 0
err = bladerf_get_frequency(_c_device, get_current_bladerf_channel(), &result)

if err != 0:
return 0
if err != 0:
return 0

return result

cpdef int set_bias_tee(on_or_off):
IF BLADERF_API_VERSION >= 2:
jopohl marked this conversation as resolved.
Show resolved Hide resolved
cdef bool bias_tee = 1 if on_or_off else 0
return bladerf_set_bias_tee(_c_device, get_current_bladerf_channel(), bias_tee)
jopohl marked this conversation as resolved.
Show resolved Hide resolved
ELSE:
return -1

cpdef int get_bias_tee():
IF BLADERF_API_VERSION >= 2:
jopohl marked this conversation as resolved.
Show resolved Hide resolved
cdef bool result = 0
err = bladerf_get_bias_tee(_c_device, get_current_bladerf_channel(), &result)
if err < 0:
return err

return result
ELSE:
return -1


cpdef int prepare_sync():
enable_module()
Expand Down Expand Up @@ -165,4 +184,4 @@ cpdef float get_api_version():
print(result.minor)
print(result.patch)

print(result.describe.decode())
print(result.describe.decode())
15 changes: 8 additions & 7 deletions src/urh/dev/native/lib/cbladerf.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ cdef extern from "libbladeRF.h":
int bladerf_get_bandwidth(bladerf *dev, bladerf_module module, unsigned int *bandwidth)

IF BLADERF_API_VERSION >= 2:
int bladerf_set_bias_tee(bladerf *dev, bladerf_channel ch, bool enable)
int bladerf_get_bias_tee(bladerf *dev, bladerf_channel ch, bool *enable)

IF BLADERF_API_VERSION >= 1.91:
jopohl marked this conversation as resolved.
Show resolved Hide resolved
int bladerf_set_frequency(bladerf *dev, bladerf_channel ch, uint64_t frequency)
int bladerf_get_frequency(bladerf *dev, bladerf_channel ch, uint64_t *frequency)
ELIF BLADERF_API_VERSION >= 1.91:
int bladerf_set_frequency(bladerf *dev, bladerf_channel ch, unsigned int frequency)
int bladerf_get_frequency(bladerf *dev, bladerf_channel ch, unsigned int *frequency)
jopohl marked this conversation as resolved.
Show resolved Hide resolved
ELSE:
int bladerf_set_frequency(bladerf *dev, bladerf_module module, unsigned int frequency)
int bladerf_get_frequency(bladerf *dev, bladerf_module module, unsigned int *frequency)
Expand All @@ -125,11 +126,11 @@ cdef extern from "libbladeRF.h":
int bladerf_sync_rx(bladerf *dev, void *samples, unsigned int num_samples, bladerf_metadata *metadata, unsigned int timeout_ms)
int bladerf_sync_tx(bladerf *dev, const void *samples, unsigned int num_samples, bladerf_metadata *metadata, unsigned int timeout_ms)

IF BLADERF_API_VERSION >= 2:
ctypedef uint64_t bladerf_frequency
IF BLADERF_API_VERSION >= 1.91:
jopohl marked this conversation as resolved.
Show resolved Hide resolved
ctypedef uint64_t bladerf_frequency
ELSE:
ctypedef unsigned int bladerf_frequency
ctypedef unsigned int bladerf_frequency

ctypedef unsigned int bladerf_sample_rate
ctypedef unsigned int bladerf_bandwidth
ctypedef int bladerf_gain
ctypedef int bladerf_gain