-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSPduo support #62
Comments
Hi @fventuri, this is a good start and only works for probing and not in an application - master mode has certain limits... must be only Low-IF mode, sample rate must be either 6 or 8 MHz only - IF Freq must be either 1.62 MHz or 2.048 correspondingly. Once the first tuner is in master mode, then probe should only return or allow slave mode. If I start one instance of CubicSDR and then run probe again I get a map::at error Slave mode cannot have any sample rate control, or IF frequency. It can have independent bw and decimation control however. |
Thanks for your feedback. I committed several changes to the 'RSPduo_fixes' branch in my repo that should address some of the problems with the application. While I was testing the code for SoapySDRPlay, I noticed that CubicSDR has a couple of quirks:
Also the code for the driver has become more messy to handle the dual tuner and master/slave cases, but at least I was able to make it run without crashing for the most common use cases I could think of. Please give it a try when you get a chance and let me know how it goes for you. Franco |
Hi, I tried the new Franco's branch for API v3 & RSP Duo support with a fresh built CubicSDR. When I start CubicSDR it scans for Soapy devices and finds my RSP Duo. I select it and the app hang and exits. On the console windo I can see: SDR enumerator starting. Reporting enumeration complete. I don't know if it's a CubicSDR issue or a SoapySDRPlay one. |
Thanks for the feedback, nmaster2042.
means is more or less the following. RSPduo mode 7 (7=1+2+4) means that the RSPduo can run in 'single tuner', 'dual tuner' or 'master' mode (these codes are described in the enum 'sdrplay_api_RspDuoModeT' in the include file 'sdrplay_api_rspDuo.h') - this is typically the list of modes that the RSPduo accepts when no other application is using it. On the other hand mode 8 means CubicSDR tries to run that RSPduo in 'slave' mode, which is the mode you would choose when another application is already using the same RSPduo in 'master' mode. Typically this happens because CubicSDR on exit saves its last used configuration in a config file called $HOME/.CubicSDR/config.xml. If you look at that contents of that file, you'll see a stanza that looks more or less like this:
When you restart CubicSDR it reads that file and tries to ask the driver for the mode previously saved in the 'rspduo_mode' element. If in your case, you might have something like 'Tuner B (Slave)', that can trigger the error you saw. A quick workaround (for now) is to edit that config file and change the 'rspduo_mode' line to something like 'Tuner A (Master)' - after that CubicSDR should work. Finally I should probably address this issue by making a simple change in the driver, such that in a scenario like yours it would select 'single tuner' or 'master' mode (with the same tuner in the config, or the other tuner, or always 'Tuner A'?). Hope this helps, |
That is the problem with the "pull the rug under the SDR feet" problem of the Duo. Cubic expects that Settings are obeyed and don't change dynamically because of another instance in particular.
@SDRplay suggested in #58 presenting different devices in the selection panel:
I'm not even sure other API layers using Soapy underneath like gr-osmo or such in GQRX and others would interface that dynamic settings any more kindly, so presenting different capability classes as pseudo-"Devices" may be the solution. |
I must admit I'm a bit confused as to what the intention is with the driver. In SDRuno, we always start the RSPduo in single tuner mode EXCEPT when the RSPduo is already being used in master mode, then slave mode must be used. It's very simple, there are no variables required. Why can't it be done like that?... scenario 1: RSPduo connected, but neither tuner in use
scenario 2: RSPduo connected and master mode is already in use by CubicSDR
scenario 3: RSPduo connected and single tuner is in use by CubicSDR
This to me seems very simple - is there a problem with implementing it this way? By allowing variables to be passed, there seems to be an assumption that they override existing behaviour - for example if the RSPduo is already being used in master mode, would you expect that another instance of CubicSDR where "single tuner" is being passed in via the rspduo_mode variable would work - because it won't and shouldn't be expected to either. Unless I've missed something about the way CubicSDR and the SoapySDR framework behave? |
@SDRplay summurizes it right I think, the SoapySDR driver should only present the settings appropriate to each of the 3 scenarios above.
Alas no. Only 1 device, 1 |
Thanks for your comments, vsonnier and SDRplay. My perspective on the SoapySDRplay driver was to write a "general purpose" SoapySDR driver, following more or less the guidelines here: https://github.com/pothosware/SoapySDR/wiki/DriverGuide (and more specifically the API contract specified here: https://github.com/pothosware/SoapySDR/blob/master/include/SoapySDR/Device.hpp). From this point of view CubicSDR is just one of the applications using the SoapySDRplay driver (for instance there could be other applications where they would want the 'Dual Tuner' option, since the API shows that a device could have multiple channels). This said, I have no problem implementing the driver as presenting multiple "virtual devices" in the RSPduo case (I don't think it should be too hard) - I have just a few high level questions to avoid possible misunderstandings in the future:
As per my initial comment about CubicSDR ignoring the return value from 'activateStream()', there could be several reasons why the call to 'sdrplay_api_Init()' fails besides the case of a wrong RSPduo mode (see the list at the bottom of page 26 in https://www.sdrplay.com/docs/SDRplay_API_Specification_v3.06.pdf) - I am not sure how's CubicSDR expects the driver to communicate this failure. Franco |
I don't understand the significance of the naming. If that means something to the end application then I don't have a problem with whatever it needs to be. Note that once the RSPduo is in use, then the driver (for the 2nd instance of the end application) gets all the information it needs from the API about what that instance can or can't do. So the driver will not need to query any virtual device name for that information. It's possible for the master tuner to be either tuner, the slave is just whichever one isn't in use. Again, you can get that information from the API. The importance about the sample rate is... Single Tuner - sample rate can be 2 - 10 MHz in Zero-IF mode and 6 MHz (which produces a final sample rate of 2 MHz) in Low-IF mode. Other sample rates can be used in Low-IF mode but with less efficiency so we tend not to recommend them now. Delivers 1 IQ stream. Master Tuner - Low-IF mode only either 6 MHz or 8 MHz (both produce a final sample rate of 2 MHz) - you would ONLY use 8 MHz if the other tuner was using an application like dump1090 which expects 8 MHz sample rate. Delivers 1 IQ stream. Slave Tuner - Neither sample rate or IF mode can be set - follows whatever the Master Tuner is using. Delivers 1 IQ stream. Dual Tuner - Low-IF mode only and only 6 MHz sample rate (produces a final sample rate of 2 MHz) - delivers 2 IQ streams. Note that for all of these scenarios, parameters like decimation and IF Bandwidth are independent and can be used by either tuner (except dual tuner mode where you would want those parameters to be consistent). Gain control for each tuner is also independent of these scenarios. |
Forgot to mention that when using 6 MHz Low-IF, the IF mode should be set to 1.62 MHz and when using the 8 MHz Low-IF, the IF mode should be set to 2.048 MHz - if not this could cause the incorrect tuner mode to be selected. |
I made the changes you suggested - now the SoapySDRPlay driver can present multiple 'virtual devices' for the RSPduo depending on the available RSPduo modes. Franco |
Hi Franco. I just rebuilt your SoapySDRPlay api3 branch. I removed the .CubicSDR folder in order to reinitialize CubicSDR user configuration, as you explained. Now when I start CubicSDR I can see 5 devices. From a user point of view it's more understandable like this. But, I can't start a SDR session with any of these devices: CubicSDR crashes and I get this error in the console: SDR thread starting. One other detail, When selecting Tuner A single or master, Bias tee option has to be removed. |
OK, it seems I have a small issue with the sdrplay 3 API on my system. I'm investigating this issue and I'll make more tests. |
5 devices?? I'm not at my desk but will take a look as soon as I can. Why is it not just 1 device and then deal with the different modes like another IF mode?... i.e. RSPduo = 1 device The thing I didn't like about the rspduo_mode variable was that it was required to be set to do anything. What should happen is that the API should be queried and then the functionality presented as dropdown options to the user. Same goes for Tuner # Is that not possible? I'll take a look asap and provide some feedback. |
Can't work. Make the Mode a setting that is RW with |
These are virtual devices. When starting the firs CubicSDR, and no tuners are actually in use you get 5 devices (Tuner A single, Tuner B single, Dual tuner, Tuner A master and tuner B master). When you chose device tuner A Master for example, when you start another instance of CubicSDR you only get Tnuer B slave with good IF and sample rate settings. Let's give a try. It's probably different than on SDRUno I never used but this way is better than the rspduo_mode option. |
My point was I don't understand why there is 5, but there should be 3. Why is Tuner in the virtual name? Are you saying that when you select the device, that you then can't customise the other options?? If so, then what is to stop me from selecting Tuner A master and 10 MHz sample rate with Zero IF - this is obviously not a valid combination. If you can deal with that, then why can't the tuner also be like antenna select? |
In the actual implementation, when you select RSP Duo Tuner A master you simply can't select 10 mhz sample rate and zero-if because sample rate is fixed to 6 mhz and if mode = 1620 khz to prevent user to select wrong values as I made and crashing the app. Instead you can select Tuner A single to put 10 Mhz sample rate and Zero IF. I think the reason why there is 5 virtual devices and not 3 is because it seems to be the way to deal with options of each tuner considering the mode (single, dual, master/slave). In Cubic SDR, when you select a device, there is different options, but one can't be dynamically changed depending of the value of an other option. In the first implementation with the rspduo_mode, you could select the mode but you had to manually set sample rate and if mode correctly because options couldn't be automatically modified. It's my understanding. I'm testing this, for now it seems to work ok. |
In master mode, the sample rate can be either 6 MHz (1.62 MHz IF) or 8 MHz (2.048 MHz IF) - so is 8 MHz not an option? I guess what I'm not understanding is that if you can select sample rate depending on whether you've selected master or single (as you've stated above), then I don't understand why the same is also not true of what antenna/tuner is used. I'll try it myself later today when I'm at my desk and I'll probably get a better feel for it and get back to you. |
For now, in master mode, only 6 Mhz SR with IF mode of 1620 khz is selectable. The master / slave mode is actually working I can use 2 instances of CubicSDR. Yes, the best way is to get a try by yourself to give a feedback. |
But if 8 Mhz / 2048 khz is added in master mode, user will need to pay attention to adjust the 2 parameters correctly because it will be possible to select for example 6 Mhz SR and 2048 khz IF mod witch will be incorrect. OR, for master mode it would be better to have 2 options combining the 2 parameters:
This would prevent users (like me lol) to chose incorrect combination. |
Thanks everyone for trying it and especially their feedback. A couple of comments:
As per when the driver is used in slave mode, in this case the driver uses the sample rate already set by the master (be it 6Ms/s or 8Ms/s), so if someone were to start say dump1090 in master mode (which would set the sample rate to 8Ms/s) and then run CubicSDR in slave mode, CubicSDR would use an 8Ms/s sample rate (and an IF mode of 2048 kHz). Franco |
You are right Franco, the simplest is the best I think. In the particular case of app such as dump1090, the only thing to remember is to start it in master mode so it can get its 8 Mhz SR. As we can chose witch tuner will be the master, it can serve all uses cases I think. |
OK, I think I figured out the issue with CubicSDR and the list of antennas shown. I took a look at the source code for CubicSDR and I found this code(see https://github.com/cjcliffe/CubicSDR/blob/master/src/forms/SDRDevices/SDRDevices.cpp#L136):
This explains why when I was selecting any of the tuner B cases (either in single tuner mode or in master mode), the antenna entry was not there (because there's only one choice). After understanding this, I may have to revisit my comments about the way CubicSDR handles the antenna selection (and therefore the tuner choice discussion above). Franco |
This is the initial Device dialog choosing. The other place where list of antennas are read and displayed is this: https://github.com/cjcliffe/CubicSDR/blob/57454e4b32040e98a6c296cbfeb1335b108a940b/src/AppFrame.cpp#L1036 But the principle is the same: there is no point, in principle, of displaying a list of antennas made of 1 entry because there is no choice. This is to have a cleaner UX, nothing more, nothing less. For information, here is the original PR I made to support multiple antennas easily when I bought my RSP2 : cjcliffe/CubicSDR#571 |
Thanks vsonnier for the clarification about the antenna thing. I fixed another bug I found this afternoon where in CubicSDR switching from one pseudo device (for instance Tuner A - Single) to a different pseudo device (for instance Tuner B - Single), and then back again to the first pseudo device (Tuner A - Single) causes some problems because CubicSDR tries to re-use the initial instance of that pseudo device (instead of reinitializing it), while I think the SDRplay 3.x API expects that the client goes through a full ReleaseDevice/SelectDevice cycle (+ GetDeviceParams). I added a check in readSettings() so that, if the device is not the one selected (i.e. if CubicSDR didn't initialize it), then a new function called 'reselectDevice()' is invoked, that does exactly that. I also found out this afternoon that, when streaming in Single Tuner mode, there are quite a number of times where the time elapsed between two successive calls to 'rx_callback' is above 100,000us, which then causes timeouts in 'acquireReadBuffer()', which show up in the console as messages: 'SoapySDR read failed with code: -1'. Franco |
Truth be told, the I'll have a look (later) at the |
Comment on Low-IF 8MHz sample rate... In Registration.cpp there is a duplication of On line 148 of Settings,cpp, 8 MHz sample rate seems to be set as true if master is selected - I'm confused by this, surely if I just want to make sure that 8 MHz sample rate is ONLY selected if the user specifically selects the 8 MHz device option. It's only a dump1090 compatibility option and the default should be 6 MHz |
Andy, Vincent, first of all thanks for all your feedback and your patience; I think I am starting to see the light on how the input sample rate, output sample rate, decimation, and IF mode all work together for the RSPs (all this knowledge will turn very useful for the GNURadio module). Anyway, I renamed the branch to ''API3+RSPduo' (https://github.com/fventuri/SoapySDRPlay/tree/API3+RSPduo) as discussed yesterday, and I pushed all the suggested changes and fixes there (hopefully I didn't miss anything); I was able to run a couple of quick tests here using CubicSDR (single tuner mode, and master/slave) with no crashes. A few comments:
Franco |
Thanks Franco, we've restarted testing and things look a lot better. Couple of comments (that you may or may not be able to do anything about)...
can either of these be done? Andy. |
No RSP-specific code in Clubic please. Still, here is an idea : a) For the first case, the name of the device must suffice. So to stay generic, displaying the name of the device on the titlebar would fit our need. We already use wxWidgets b) For the second case, make the slave stop streaming, i.e |
I added the following code to the event callback function in Streaming.cpp
However for some reason in the CubicSDR running as a slave I never see the eventId sdrplay_api_RspDuoModeChange (but I do see a few sdrplay_api_GainChange events) when I close the CubicSDR running in master mode first - what I see here is that the rx_callback in the slave stops being called, which causes the method acquireReadBuffer() to timeout while waiting for a buffer to become available, returning SOAPY_SDR_TIMEOUT. I just pushed my code with the change above to the API3+RSPduo branch - please give it a try there to see if that's what happens to you too. Franco |
As per adding the device name for the CubicSDR title bar, I added the two lines below to src/AppFrame.cpp and they seem to work for me:
If you are interested I can create a pull request with CubicSDR. Franco |
@fventuri Thanks, but this is a bit too simple: if you look at the usage of |
Thanks Vincent.
Franco |
I've made a PR for Cubic, please test it with the driver: cjcliffe/CubicSDR#786. |
Thanks Vincent. Franco |
Today I spent sometime cleaning up the code with the SelectDevice() and ReleaseDevice() API calls. I noticed that the SoapySDRPlay driver freezes in this scenario (even when using the master branch from CubicSDR, so this is not due to any of the changes Vincent made yersterday):
I was able to track down the problem to the 'sdrplay_api_ReleaseDevice()' API and more exactly to the 'sdrplay_api_LockDevice()' API call inside ReleaseDevice.
and the output looks like this:
i.e. sdrplay_api_LockDevice() never returns (notice that the two previous API calls are successful), and that causes CubicSDR to freeze. Franco |
I just pushed a few code changes to the 'API3+RSPduo' branch to take care of the following:
One last thing - I am still trying to figure out how to prevent sdrplay_api_Init() to fail in the following scenario:
when they try to stream again in single tuner mode, I see that sdrplay_api_Init() fails and the logs show a message like this:
It might be just a corner case that no user will actually encounter, but I wanted to let you know in case you think it is worth investigating. Franco |
@fventuri I haven't checked the code, but are you releasing the device and selecting it again when switching between modes, because you need to. In SDRuno, when switching from single tuner to master, I release the device, set rspDuoMode to master and then select the device again. Same when going back to single tuner - of course you need to make sure the slave isn't in use before allowing the master mode to switch back to single tuner mode. Does that help? Andy |
Good catch, Andy. Thanks, |
Hi.
I just made tests with the last fixes in API3+RSPduo branch and CubicSDR
with vsonier PR cjcliffe/CubicSDR#786.
If I start in signe tuner mode, stop, select master mode and start again,
CubicSDR crashes and I have this error in the console:
SDR thread done.
[INFO] devIdx: 2
[INFO] hwVer: 3
[INFO] rspDuoMode: 4
[INFO] tuner: 1
[INFO] rspDuoSampleFreq: 6000000,000000
SDR thread starting.
device init()
[INFO] Using format CF32.
[ERROR] error in activateStream() - Init() failed: sdrplay_api_Fail
terminate called after throwing an instance of 'std::runtime_error'
what(): error in activateStream() - Init() failed
Abandon (core dumped)
Le lun. 17 févr. 2020 à 04:54, Franco Venturi <[email protected]> a
écrit :
… Good catch, Andy.
I wasn't reselecting the device (i.e. calling the API functions
ReleaseDevice() + SelectDevice()) when switching back to the previous
RSPduo mode.
I just pushed out the code with the fix to the API3+RSPduo branch; I ran a
couple of quick tests and I was able to switch mode back and forth without
any issue.
Thanks,
Franco
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<pothosware/SoapySDRPlay3#62>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNR5KFYMAIXV7SYIUNMPXTRDIC7PANCNFSM4J3UQHQA>
.
|
This issue occurs only when, at first streaming start in single tuner mode I set sample rate = 2048 khz (default option on my setup). The same test starting single tuner mode with sample rate = 2 mhz is ok. Now if I start the first streaming in signle tuner mode with sample rate = 6 Mhz, when I change to master mode I get this on Cubic: To get a proper working stream again, I have to go to the sample rate menu and change it for ex to 1 mhz and again to 2 mhz to fix. |
The sample rate for master mode in the dropdown CANNOT be greater than 2 MHz - in fact, the library shouldn't accept or ideally not give any option to select a sample rate greater than 2 MHz in master mode. Internally the SoapySDRPlay library will use 6 MHz, but that is to deliver a final sample rate of 2 MHz - if you are able to attempt to switch from single tuner mode to master mode using a final sample rate of 6 MHz, then that's where the issue is. |
@SDRplay no, there is no issue about master mode and 2 mhz max sample rate. I start in single tuner, I can chose whatever sample rate (ex: 6 mhz or 2.048 mhz). Then I stop streaming, select device and chose master mode. Here I only get max of 2 mhz selectable values and I let default 2 mhz. The issue is at this stage is that cubic is crashing if in the first start in single tuner mode has been done with sample rate of 2.048 mhz. |
ok, well there is nothing fundamentally wrong with doing that, so something wrong in the sequencing - if you are able to capture a debug log, that would help. Maybe @fventuri can help with that? |
Here is a strace while reproducing the issue I mentioned, I hope it can be usable. |
Unfortunately not, I need the DebugEnable statement enabled in the SoapySDRPlay library and then the output from that. |
Thanks for the feedback nmaster2042 and Andy. I just pushed a code change to the 'API3+RSPduo' branch that validates the output sample rate when the RSPduo is in master or slave mode and, if it is > 2MHz, sends a warning message and forces it to 2MHz. If a similar issue happens again and you are able to repeat it consistently, I'd like you do do the following:
Franco |
Since I start seeing some 'git clone' activity on the repo, I just enabled the 'Issues' tab there (https://github.com/fventuri/SoapySDRPlay/issues), to be able to track the remaining issues before the pull request for the 'API3+RSPduo' branch. Franco |
@fventuri: I rebuilt the SoapySDRPlay with your last changes, the issue I pointed is now gone. I'll continue making other tests. |
I made a fork under my account and created a branch called 'RSPduo_fixes' (https://github.com/fventuri/SoapySDRPlay/tree/RSPduo_fixes).
I cleaned up a couple of warnings during compile and I also straightened up the code for the RSPduo mode/tunes and antennas (hopefully).
I tested my changes this afternoon using 'SoapySDRUtil' with the following commands:
SoapySDRUtil --probe="driver=sdrPlay, rspduo_mode=Tuner A (Single Tuner)"
SoapySDRUtil --probe="driver=sdrPlay, rspduo_mode=Tuner B (Single Tuner)"
SoapySDRUtil --probe="driver=sdrPlay, rspduo_mode=Tuner A (Master/Slave)"
SoapySDRUtil --probe="driver=sdrPlay, rspduo_mode=Tuner B (Master/Slave)"
SoapySDRUtil --probe="driver=sdrPlay, rspduo_mode=Dual Tuner"
and in each case 'SoapySDRUtil' returned what I expected (including 2 RX channels in the last case with 'Dual Tuner').
Please give it a try and if it looks OK to you, I'll go ahead and send a pull request.
Franco
Originally posted by @fventuri in pothosware/SoapySDRPlay3#58 (comment)
The text was updated successfully, but these errors were encountered: