EttusResearch / uhd

The USRP™ Hardware Driver Repository
http://uhd.ettus.com
Other
1k stars 667 forks source link

UHD utility function rx_samples_to_file incorrectly errors out for "RX channel out of range" #723

Closed gwkraus closed 9 months ago

gwkraus commented 10 months ago

Issue Description

The UHD utility function "rx_samples_to_file" incorrectly throws an out-of-range for configured RX frontends error for UHD version 4.4 onwards. The identical command works correctly with version 4.3 and older.

Setup Details

Here's my setup: Hardware: Dell XPS 15 9500, 64GB RAM, Intel Core i9-10885-H processor (16 cores) OS: Ubuntu 22.04.3 LTS USRP: B210 with GPSDO UHD: pulled versions 4.3 and 4.4 from github and built locally on my laptop, downloaded fpga images with image_downloader utility on 30 JAN 2024. first non-working version:[INFO] [UHD] linux; GNU C++ version 11.4.0; Boost_107400; UHD_4.4.0.HEAD-33-g4a77791c
last working version: [INFO] [UHD] linux; GNU C++ version 11.4.0; Boost_107400; UHD_4.3.0.HEAD-0-g1f8fd345

Expected Behavior

I expect that the rx_samples_to_file program will configure the USRP, collect the requested amount of samples, and write the sample data to a file.

Actual Behaviour

Execution proceeds normally until the error, occuring after Setting the RX Gain. The error message is as follows: Error: LookupError: IndexError: multi_usrp: RX channel 18446744073709551615 out of range for configured RX frontends

Steps to reproduce the problem

I built and installed each version. After installing the version, I executed the rx_samples_to_file program from within the uhd directory ~/uhd-4.x/host/build/examples (where x is 3 or 4)

Here is the command I used. The identical command works with v4.3 and fails with v4.4 ./rx_samples_to_file --duration 10 --ref internal --spb 204800 --rate 20000000 --freq 763000000 --gain 70 --file ./my_samples.dat

Additional Information

I attempted to specify a channel, but the results were exactly the same. Also, I inadvertently forgot to specify a --gain value one time, and execution in v4.4 worked as normal. Problem is the default gain value is 0, so that in itself is an issue if not specified.

manderseck commented 9 months ago

@gwkraus Thanks for reporting this issue. I have created a fix that'll run through our internal procedures and will be pushed public in the next weeks. Some background: The example was changed between UHD 4.3 and 4.4 in commit https://github.com/EttusResearch/uhd/commit/d91c86dd3368c79aa10e7f016fa620e5ddd03a36. The line that reads usrp->set_rx_gain(gain, uhd::usrp::multi_usrp::ALL_CHANS); calls into set_rx_gain() with the ALL_CHANS argument which until now was only valid in multi_usrp_rfnoc (used for RFNoC devices), but not in multi_usrp (used for B2xx). Therefore the author of the change might not have captured it in his testing. My change fixes this in multi_usrp.cpp. If you want to use the example until my change gets published you can either do the change yourself or adapt the example to loop through the given channels like it is done for the rx_bandwidth further down. With the change on its way I'll close this bug. Feel free to re-open if necessary.