Skip to content

Commit

Permalink
add bias tee check box on device settings
Browse files Browse the repository at this point in the history
Fixes #703
  • Loading branch information
sophiekovalevsky committed Mar 25, 2021
1 parent ca39660 commit e7d818c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
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
15 changes: 14 additions & 1 deletion src/urh/dev/native/lib/bladerf.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ cpdef bladerf_frequency get_center_freq():

return result

cpdef int set_bias_tee(on_or_off):
cdef bool bias_tee = 1 if on_or_off else 0
return bladerf_set_bias_tee(_c_device, get_current_bladerf_channel(), bias_tee)

cpdef int get_bias_tee():
cdef bool result = 0
err = bladerf_get_bias_tee(_c_device, get_current_bladerf_channel(), &result)

if err != 0:
return 0

return result

cpdef int prepare_sync():
enable_module()
return bladerf_sync_config(_c_device, get_current_channel_layout(), BLADERF_FORMAT_SC16_Q11, 32, 2048, 16, 100)
Expand Down Expand Up @@ -165,4 +178,4 @@ cpdef float get_api_version():
print(result.minor)
print(result.patch)

print(result.describe.decode())
print(result.describe.decode())
6 changes: 5 additions & 1 deletion src/urh/dev/native/lib/cbladerf.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ cdef extern from "libbladeRF.h":
int bladerf_set_frequency(bladerf *dev, bladerf_module module, unsigned int frequency)
int bladerf_get_frequency(bladerf *dev, bladerf_module module, unsigned int *frequency)

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)

ctypedef enum bladerf_format:
BLADERF_FORMAT_SC16_Q11
BLADERF_FORMAT_SC16_Q11_META
Expand Down Expand Up @@ -132,4 +136,4 @@ ELSE:

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

0 comments on commit e7d818c

Please sign in to comment.