Page 2 of 3
Posted: Tue Mar 27, 2018 10:31 pm
At the risk of showing just what a poor developer I am ...
Can anyone point me to C++ code that uses mir_sdr_StreamCallback ? I have looked at Steve Andrew's C# code, and have spent a day trying to figure out how to do that callback in C++.
Posted: Wed Mar 28, 2018 12:57 am
At the end of the API document there is a section marked API Usage. There is some simple code written in C/C++ that illustrates how mir_sdr_StreamInit and mir_sdr_StreamCallback are set up and used. It's written for Windows but should need little changing apart from the semaphores to get it running under various flavours of Unix/Linux. This should get the ball rolling for you. Just on the off-chance that you don't have the document, you can download it from here - https://www.sdrplay.com/docs/SDRplay_SD ... cation.pdf
On the off-chance you have not already done so, You can also download the required hardware drivers from https://www.sdrplay.com/downloads/
Posted: Wed Mar 28, 2018 1:31 am
Thanks ! I think I see what to do now. It helps to walk away and think about these things for a while.
Posted: Wed Mar 28, 2018 5:42 am
We also have some example code on our github repository: https://github.com/SDRplay/examples
Posted: Thu Apr 12, 2018 7:33 pm
Thanks to Steve Andrews and the SDRPlay staff for their help. After some hair-pulling, I now have a DLL working using the mir streaming API that samples and decimates to 192 kHz, feeding I/Q samples to VE3NEA's Skimmer Server ( http://www.dxatlas.com/SkimServer/
). I plan to make this available for free to anyone interested.
Posted: Fri Jul 12, 2019 2:07 am
Trying to build a C# Winforms app and I'm trying to the example you posted in StreamingSample_3.zip
However it's missing the "mir_sdr_api.dll" file as you said and that file does not exist on my system anywhere even though I am using SDRUno.
I have download the latest API and it has a sdrplay_api.dll - so I was thinking maybe the API filename was changed?
However, when trying to directly access the DLL directly as you did in your example:
Code: Select all
[DllImport("sdrplay_api.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern mir_sdr_ErrT mir_sdr_StreamInit(ref int gRdB, double fsMHz, double rfMHz, mir_sdr_Bw_MHzT bwType, mir_sdr_If_kHzT ifType, int LNAstate, ref int gRdBsystem, mir_sdr_SetGrModeT setGrMode, ref int samplesPerPacket, mir_sdr_StreamCallback_t StreamCbFn, mir_sdr_GainChangeCallback_t GainChangeCbFn, IntPtr cbContext);
When trying to call that function it errors:
System.BadImageFormatException: 'An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)'
I checked the API documents and the 'mir_sdr_StreamInit' method does not exist.
So I switched to sdrplay_api_Open() and it throws the same error.
Can you please provide any guidance?
Posted: Fri Jul 12, 2019 1:06 pm
Looks like you need API 2.13, API 3.x has different function calls, etc.
Posted: Fri Jul 12, 2019 1:46 pm
SteveAndrew wrote:Hi Steve
In the meantime, I've changed the code so that streaming is started before setting a decimation factor. In addition, I've added some very basic sanity checks, and another function that reports any errors to the console, along with a brief description of the error. The revised code is attached here as StreamingSample_3.zip. [...]
All the best...
Hello SteveAndrew, thank you for posting the C# example code. This example C# source code really jump started me a few months ago down the rabbit hole of SDR and DSP. Using your c# example code while reading Chris Thompson's tutorial "SDR for the Radio Amateur" really got me going.
I wanted to send your a private message thanking you but this forum would not let me or I could not figure out how.
SDR for the Radio Amateur
Posted: Fri Jul 12, 2019 9:34 pm
sdrplay wrote:Looks like you need API 2.13, API 3.x has different function calls, etc.
Is the official answer for new C# .NET projects to use an OLD API? I don't want to get left behind.
I've been working on this all through the night and I actually built a functional .NET Wrapper for the new 3.04 API.
My goal is to build a multi-antenna array for FoxHunt direction finding and maybe include GPS mapping.
I was considering purchasing the SDR Duo for the synchronized clock to help with the TDOA accuracy.
However, now I'm concerned about SDRPlay support.
Posted: Sun Jul 14, 2019 6:13 pm
If you want to use dual tuner mode of the RSPduo then you will need to use API 3.x
We don't directly support C# but there are people on here that may be able to help with C# related issues.