Nuand / bladeRF

bladeRF USB 3.0 Superspeed Software Defined Radio Source Code
http://nuand.com
Other
1.13k stars 455 forks source link

there's no Python bindings for set_feature function #909

Open osalhi-kali opened 1 year ago

osalhi-kali commented 1 year ago

i try to update code for using sample rate = 122.88Mhz but i have issues so Could you please update python code and make it available for the public. Thank you

rghilduta commented 1 year ago

The API's now called bladerf_enable_feature, it should be in the python package. Please see 689d6da345bf20d7724e20f3dd3aa3f78a6dc28c

osalhi-kali commented 1 year ago

thank you for your reply, we should call it on _bladerf.py file like this ?

############################################################### def get_feature(self): feature = ffi.new("bladerf_feature *") ret = libbladeRF.bladerf_get_feature(self.dev[0], feature) _check_error(ret) return feature[0]

def enable_feature(self, feature, enable):
    ret = libbladeRF.bladerf_enable_feature(self.dev[0], feature, bool(enable))
    _check_error(ret)

######################################################################

when i use this like: d = _bladerf.BladeRF(devinfo=devices[0]) ch = d.Channel(channel) d.enable_feature(1, True) ch.sample_rate = 122.88e6 so far everything is working but when I plot data spectrogram, i see sample rate still on 61440000Mhz. and i try to understand code source i find i should use rational_sample_rate but it's not implemented.

could you please told me how i can set sample rate on 122.88 Mhz thank you

rghilduta commented 1 year ago

As a test, cold you please enable the feature right after creating d and not change "sample_rate"?

osalhi-kali commented 1 year ago

FS_check

I did a simple test I generated a 20Mhz band signal and I activated the feature after the creation of d without changing the sample rate, when you try to check you see the sample_rate move from 30.72Mhz to 61.44Mhz print(ch.sample_rate) but the device doesn't take the change into account and still always on 30.72Mhz, in resume, you can change the fs but the device doesn't change it.

could you help me with this issue, please?

code :

devices = _bladerf.get_device_list()
d = _bladerf.BladeRF(devinfo=devices[0])
d.enable_feature(1, True)
channel=_bladerf.CHANNEL_RX(0)
ch = d.Channel(channel)
print(ch.sample_rate)

# Setup synchronous stream
d.sync_config(layout=_bladerf.ChannelLayout.RX_X1,
                  fmt=_bladerf.Format.SC8_Q7,
                  num_buffers=32,
                  buffer_size=32768,
                  num_transfers=16,
                  stream_timeout=1000)
bytes_per_sample = 2
buf = bytearray(num_samples*bytes_per_sample)
if num_samples > 0:
        num = min(len(buf)//bytes_per_sample,
                    num_samples)
else:
        num = len(buf)//bytes_per_sample
d.sync_rx(buf, num)
data = np.frombuffer(buf, dtype='<i1')
signal_i = data[0:-1:2] / 256
signal_q = data[1::2] / 256
signal = signal_i + 1j*signal_q

info

  Board:                    Nuand bladeRF 2.0 (bladerf2)
  Serial #:                 bbcbba55a2e04f9bb73603eb12fedb49
  VCTCXO DAC calibration:   0x1c61
  FPGA size:                77 KLE
  FPGA loaded:              yes
  Flash size:               64 Mbit
  USB bus:                  2
  USB address:              23
  USB speed:                SuperSpeed
  Backend:                  libusb
  Instance:                 0

version

  bladeRF-cli version:        1.9.0-git-8a7b41ae
  libbladeRF version:         2.5.0-git-8a7b41ae

  Firmware version:           2.4.0-git-a3d5c55f
  FPGA version:               0.15.0 (configured from SPI flash)