EttusResearch / uhd

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

The rx_samples_to_file example program does not properly save to a file with a fully-qualified path when simultaneously recording multiple channels #689

Closed terikin closed 4 months ago

terikin commented 1 year ago

Issue Description

The rx_samples_to_file example program properly saves samples to a file with a fully-qualified path when recording a single channel, but not with multiple channels. (It seems that multi-channel recording is a recent addition; I'm running UHD-4.4.)

Setup Details; Expected and Actual Behavior

For example, the single-channel case works fine: $ /usr/local/lib/uhd/examples/rx_samples_to_file --freq 1e9 --nsamps 10000 --channels 0 --file /home/user/samples.dat producing the expected output file.

The multi-channel case (run on an x310 with two UBX-160 daughterboards) fails: $ /usr/local/lib/uhd/examples/rx_samples_to_file --freq 1e9 --nsamps 10000 --channels 0,1 --file /home/user/samples.dat

The multi-channel case without a fully-qualified path works fine, however: $ /usr/local/lib/uhd/examples/rx_samples_to_file --freq 1e9 --nsamps 10000 --channels 0,1 --file samples.dat which produces two files, ch0_samples.dat and ch1_samples.dat, respectively.

Additional Information

Looking at the source code, it is apparent that the program blindly prepends "ch#_" to the provided file string, which of course will have problems with fully-qualified paths.

I've fixed this in my own build using the std::filesystem library, but that requires building UHD with C++ 17 instead of C++ 14. It might just be a drop-in replacement to use the boost::filesystem library instead, in which case I could probably figure out how to submit a pull request with the change.

manderseck commented 4 months ago

@terikin Sorry for the huge delay in my response. Thanks for reporting this issue. We have checked and reproduced this. Currently there is a PR up for this against our internal master and it is working through our pipelines. A little bit later it'll be merged into the public master.