SigDigger icon indicating copy to clipboard operation
SigDigger copied to clipboard

Allow custom sample rates for Soapy devices

Open catkira opened this issue 1 year ago • 14 comments

The Soapy driver returns a list of sample rate, ie SoapyPlutoSDR has this:

std::vector<double> SoapyPlutoSDR::listSampleRates( const int direction, const size_t channel ) const
{
	std::vector<double> options;
	options.push_back(65105);//25M/48/8+1
	options.push_back(1e6);
	options.push_back(2e6);
	options.push_back(3e6);
	options.push_back(4e6);
	options.push_back(5e6);
	options.push_back(6e6);
	options.push_back(7e6);
	options.push_back(8e6);
	options.push_back(9e6);
	options.push_back(10e6);
	return(options);
}

However most SDRs can do any sample rate in a given range, also Pluto. Therefore it would be nice, if SigDigger would allow custom sample rates and not only the ones listed by the driver.

catkira avatar Jul 10 '22 13:07 catkira

Some Soapy dev said here, that there is a new API for this: getSampleRateRange()

Does SigDigger already support this?

catkira avatar Jul 10 '22 13:07 catkira

It does not (yet), but I have already been thinking on how to offer support for that, and the right UI for this.

I believe I have a solution: How about some checkbox next to the sample rate list (like "manual"), switch back to a line edit box, let the user write it down, and then perform a check to see whether the device supports that range?

Cheers,

BatchDrake avatar Jul 10 '22 13:07 BatchDrake

yes, that sounds good!

catkira avatar Jul 10 '22 13:07 catkira

the check should only be performed, if the range specification is implemented in the driver.

catkira avatar Jul 10 '22 18:07 catkira

I've just added a temptative checkbox to override the sample rate. Build SigDigger from the develop branch and tell me whether it works (and, of course, if it saves the setting right after restarting SigDigger, etc)

BatchDrake avatar Jul 31 '22 18:07 BatchDrake

There is a weird effect. It seems that the entered custom sample rate gets rounded to the next available sample rate in the list.

When I enter 12 MSPS and start the stream I get 10 MSPS. When I enter 13 MSPS I get 15 MSPS. When I enter 20 MSPS I get 20 MSPS. When I enter 30 MSPS I get 20 MSPS.

I have manually added 15 MSPS and 20 MSPS to the driver of SoapyPlutoSDR.

catkira avatar Aug 01 '22 07:08 catkira

It is weird indeed. Does the GUI revert back to a drop-down list? Can you confirm that you can specify an arbitrary sample rate to the device with other applications?

I'd also like to rule out any UI effect. Put an arbitrary sample rate (one that is clearly not in the list, like, dunno, 12.345678 Mps), click okay in the settings dialog, close SigDigger and attach to this issue the file ~/.suscan/uiconfig.yaml, so I can see what is actually being saved in the device profile.

Additionally, in your current source directory, locate this file: https://github.com/BatchDrake/SigDigger/blob/develop/Suscan/Analyzer.cpp and right before line 542 (the one with suscan_analyzer_new) write this:

printf("Analyzer being created with sample rate: %u\n", config.getSampleRate());

Compile again, launch SigDigger with a custom rate from the terminal, and tell me what do you see from there once you hit start. If you see your custom sample rate in terminal with no roundups, I am afraid it is actually the device falling back to a predefined rate. Let's cross our fingers it is not the case 🤞

BatchDrake avatar Aug 01 '22 07:08 BatchDrake

The GUI does not revert back.

I guess You mean ~/.suscan/config/uiconfig.yaml. It seems to be correct, there is samp_rate: 12345670

The terminal output is

[INFO] Opening PlutoSDR #0 192.168.137.2...
Analyzer being created with sample rate: 12345670
[INFO] Opening PlutoSDR #0 192.168.137.2...
[INFO] Using format CF32.
[INFO] Auto setting Buffer Size: 262144
[INFO] Set MTU Size: 262144
[INFO] Has direct RX copy: 1

catkira avatar Aug 01 '22 07:08 catkira

I believe I've found the offending lines, but the issue is in Suscan. Locate these highlighted lines in your local Suscan source tree:

https://github.com/BatchDrake/suscan/blob/master/analyzer/source.c#L1757-L1768

And replace them by:

closest_rate = source->config->samp_rate;

Then recompile Suscan and install Suscan again. You shouldn't need to recompile SigDigger, just restarting it should be enough.

BatchDrake avatar Aug 01 '22 08:08 BatchDrake

Its working now 💯

catkira avatar Aug 01 '22 08:08 catkira

Somehow GitHub failed to deliver my last message. Anyways, I am keeping this issue open until I find a clean solution to this issue (most likely testing that the requested sample rate falls in any of the acceptable device ranges). Thanks a lot for your help!

BatchDrake avatar Aug 01 '22 08:08 BatchDrake

Yes, if the Soapy driver supports a range, suscan should just test if it falls inside that range.

catkira avatar Aug 01 '22 08:08 catkira

@BatchDrake any news about this? Can You put the suscan fix inside the repo?

catkira avatar Aug 30 '22 06:08 catkira

I am afraid I am blocked these days, I am still catching up with other projects and I don't expect to have any spare time for this until the second half of September (where I will be fixing this and other issues too).

Sorry for the inconvenience,

El mar., 30 ago. 2022 8:14, Benjamin Menküc @.***> escribió:

@BatchDrake https://github.com/BatchDrake any news about this?

— Reply to this email directly, view it on GitHub https://github.com/BatchDrake/SigDigger/issues/183#issuecomment-1231191647, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEVET4MEKCR7UXLLUS3ABLV3WRC7ANCNFSM53E7WSEA . You are receiving this because you were mentioned.Message ID: @.***>

BatchDrake avatar Aug 30 '22 06:08 BatchDrake

Perfect, so I'm going to leave this issue open until I figure out a definitive fix. I believe it will involve testing whether the sample rate falls in any of the accepted ranges, not a big deal but it has to be done right. Thanks for your help!

El lun., 1 ago. 2022 10:11, Benjamin Menküc @.***> escribió:

Its working now 💯

— Reply to this email directly, view it on GitHub https://github.com/BatchDrake/SigDigger/issues/183#issuecomment-1200865630, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEVETZ2HUDAIYMH6IFPKY3VW6BDDANCNFSM53E7WSEA . You are receiving this because you were assigned.Message ID: @.***>

BatchDrake avatar Oct 11 '22 07:10 BatchDrake

Hi,

I am closing this issue because we already have a way to specifying custom sample rates outside the ranges reported by the devices. Feel free to reopen it if you experience any issues with this feature.

Cheers,

BatchDrake avatar Apr 12 '23 06:04 BatchDrake