EttusResearch / uhd

The USRP™ Hardware Driver Repository
http://uhd.ettus.com
Other
946 stars 646 forks source link

Failed to receive on two Rx channels with B210 #642

Closed sada45 closed 7 months ago

sada45 commented 1 year ago

Issue Description

Hi, I'm trying to receive IQ signal from two Rx channels with B210 and Python APIs. It works fine while using one Rx channel. However, if the st_args.channels = [0, 1], it returns the error Invalid recv stream command - stream now on multiple channels in a single streamer will fail to time align.
Then, I tried the solution provided in the #325 to set the stream_cmd.stream_now = False. But it turns out that the collected sample are all zeros.

Setup Details

UHD: 4.3.0.0, Python: 3.8.10, OS: Ubuntu 20.04, USRP: B210

Expected Behavior

Actual Behaviour

While using two channels and stream_cmd.stream_now = True

Traceback (most recent call last):
  File "/home/sada45/BLong/USRP/test.py", line 35, in <module>
    streamer.issue_stream_cmd(stream_cmd)
RuntimeError: RuntimeError: Invalid recv stream command - stream now on multiple channels in a single streamer will fail to time align.

If the stream_cmd.stream_now = False, the error is gone, but received samples are all 0: image

Steps to reproduce the problem

My code to collect the signal samples is:

b210 = uhd.usrp.MultiUSRP("type=b200")
b210.set_rx_rate(config.sample_rate, 0)
b210.set_rx_freq(uhd.libpyuhd.types.tune_request(get_freq_with_chan_num(config.chan)), 0)
b210.set_rx_gain(config.gain, 0)
st_args = uhd.usrp.StreamArgs("fc32", "sc16")
st_args.channels = [0,1]
metadata = uhd.types.RXMetadata()
streamer = b210.get_rx_stream(st_args)
recv_buffer = np.zeros((2, 1000), dtype=np.complex64)
stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.start_cont)
stream_cmd.stream_now = False
streamer.issue_stream_cmd(stream_cmd)
streamer.recv(recv_buffer, metadata)
print(recv_buffer[0, 0:10])
print(recv_buffer[1, 0:10])

stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.stop_cont)
streamer.issue_stream_cmd(stream_cmd)

Additional Information

mbr0wn commented 7 months ago

2 channel RX definitely works. Bump your gain and you should be fine. Sorry for leaving this open for so long.