Page 1 of 2

Tryin to get the sample sdr app to work

Posted: Fri May 31, 2019 6:14 pm
by darin
Good afternoon,

I installed API 3.02 and input the sample program from the documentation starting on page 29. I believe I've verified everything is input correctly; however, I'm getting errors on compiling. I'm running this on Windows 10. Any ideas what I have done wrong here? Any assistance is greatly appreciated!


C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x113): undefined reference to `_imp__sdrplay_api_Update'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x357): undefined reference to `_imp__sdrplay_api_Open'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x36d): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x398): undefined reference to `_imp__sdrplay_api_DebugEnable'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x3ae): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x3ce): undefined reference to `_imp__sdrplay_api_ApiVersion'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x3e4): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x440): undefined reference to `_imp__sdrplay_api_LockDeviceApi'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x462): undefined reference to `_imp__sdrplay_api_GetDevices'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x478): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x776): undefined reference to `_imp__sdrplay_api_SelectDevice'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x78c): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x7a8): undefined reference to `_imp__sdrplay_api_UnlockDeviceApi'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x7c4): undefined reference to `_imp__sdrplay_api_GetDeviceParams'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x7da): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x8dd): undefined reference to `_imp__sdrplay_api_Init'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x90a): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x962): undefined reference to `_imp__sdrplay_api_Init'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0x97c): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0xa12): undefined reference to `_imp__sdrplay_api_Update'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0xa2c): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0xa91): undefined reference to `_imp__sdrplay_api_Update'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0xaa7): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0xae2): undefined reference to `_imp__sdrplay_api_Uninit'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0xafc): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0xb42): undefined reference to `_imp__sdrplay_api_Uninit'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0xb58): undefined reference to `_imp__sdrplay_api_GetErrorString'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0xb91): undefined reference to `_imp__sdrplay_api_ReleaseDevice'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0xb9b): undefined reference to `_imp__sdrplay_api_UnlockDeviceApi'
C:\Users\Darin\AppData\Local\Temp\ccwTXEES.o:sdrapp.c:(.text+0xbab): undefined reference to `_imp__sdrplay_api_Close'
collect2.exe: error: ld returned 1 exit status

Re: Tryin to get the sample sdr app to work

Posted: Mon Jun 03, 2019 10:33 am
by darin
I resolved the compiling errors by placing the sdrplay_api.lib and .dll in the project folder. Not the right way to do it, but program compiles with no errors now so gets past that hurdle until I figure out the right way to do it.

I'm now getting a fail to Initialize the device. I changed the line
if ((argc > 1) && (argc < 4))
if ((argc > 0) && (argc < 4))
as I'm using an RSP1 and my understanding is the device ID for RSP1 is 1. When I had argc > 1, it was bypassing all the code.

The program is finding the device(when I disconnect RSP1, it fails for not finding device); however, this line..

printf("Dev %d: SerNo: %s hwVer: %d tuner= 0x% .2x\n", i, devs.SerNo, devs.hwVer, devs.tuner);
is giving
"Dev 0: SerNo 0000000001 hwVer: 1 tuner 0x01"
Is the firmware very different for RSP1 and it doesn't use the same format as the newer RSP's?

I've put print statements in various parts of the program and it is going into all the right areas for a single tuner model and not going into the duo sections.

Here is the init line that is failing..
if ((err = sdrplay_api_Init(chosenDevice->dev, &cbFns, NULL)) != sdrplay_api_Success)

prior to that, I'm using these lines to define cbFns
cbFns.StreamACbFn = StreamACallback;
cbFns.StreamBCbFn = StreamBCallback;
cbFns.EventCbFn = EventCallback;
That is all directly from the example in the API Spec doc for API 3.02

Any ideas on why this is failing?
Thanks for any assistance!

Re: Tryin to get the sample sdr app to work

Posted: Mon Jun 03, 2019 11:48 am
by sdrplay
As with all compilations, the compiler needs to be told where the include files and library files are. You can either put them into directories that the compiler is already aware of, or use -I (for include files) and -L (for library files) parameters to the compiler to inform it as to where they are.

The RSP1 is different to the other RSPs in that it doesn't report its serial number.

If you are having problems during runtime, I suggest adding a call to enable debug output before the call to sdrplay_api_Init

sdrplay_api_ErrT err = sdrplay_api_DebugEnable(chosenDevice->dev, 1);

Best regards,

SDRplay Support

Re: Tryin to get the sample sdr app to work

Posted: Mon Jun 03, 2019 4:09 pm
by darin
Thank you for the reply.

Yeah, I've tried different ways to link and keep getting errors, but I'll figure that part out.

So I have the following code in place

err = sdrplay_api_DebugEnable(chosenDevice->dev, 1); // when i print err after this statement I get a 0 so it succeeds

if ((err = sdrplay_api_Init(chosenDevice->dev, &cbFns, NULL)) != sdrplay_api_Success)
printf("sdrplay_api_Init failed %s\n", sdrplay_api_GetErrorString(err)); // this prints sdrplay_api_Init failed sdrplay_api_Fail

No additional info comes up on the terminal screen when running the .exe file. Where would I see the debug info?

Thank you

Re: Tryin to get the sample sdr app to work

Posted: Mon Jun 03, 2019 7:16 pm
by sdrplay
You can use Microsoft DebugView to view the debug output from the API... ... /debugview

Re: Tryin to get the sample sdr app to work

Posted: Mon Jun 03, 2019 8:54 pm
by darin
Thank you for your help but I am not seeing where this is showing any debug info.

In the Visual Studio app folder, I have
sdrapp.c source
sdrapp.sln VS file
sdrapp.vcxproj.filters VS file
sdrapp.vcxproj.user VS file
Debug folder

in the Debug folder there is a folder for tolog files which are all text files that show various paths for actions taken for incremental builds I believe
sdrapp.pdb I thought this is where i'd find the debug info from sdr_api_DebugEnable. When I try to open it with DebugView the message box says this file contains invalid entries and will not be fully processed and nothing shows up when the application opens. Same is true for VC142.pdb which I believe is debug info regarding the compiling process.

Re: Tryin to get the sample sdr app to work

Posted: Mon Jun 03, 2019 10:38 pm
by sdrplay
Hello Darin,

You run debugview and a window appears. Run it as administrator and turn on the Capture->Capture Global Win32 option from the menu

Then, as you run your exe with DebugEnable set to true, then you will see the API output appear in the DebugView window.

Note, DebugEnable should be disabled once you have finished with debug otherwise it will affect the performance of your program.

Best regards,

SDRplay Support

Re: Tryin to get the sample sdr app to work

Posted: Tue Jun 04, 2019 1:55 am
by darin
Good evening SDRplay Support,

Thank y'all for your patience and education! Debugging showed it was failing for chParams->tunerParams.gain.LNAstate being 5, outside expected range of 0:4. Changed it to equal 3 and the program flowed right to EventCallback and StreamACallback.

Do appreciate it!


Re: Tryin to get the sample sdr app to work

Posted: Tue Jul 02, 2019 7:17 pm
by bobasaurus
The rsp1 has fewer lna states, only 0:3 are allowed I believe.

Re: Tryin to get the sample sdr app to work

Posted: Wed Aug 14, 2019 7:08 pm
by ka4zbn
I want to try using the api in a C# application using Visual Studio 2019. It looks like I need to import the DLL and declare the calls as static :

static extern <an actual function >;

I wonder if anybody already has these statements working and willing to share. I tried the following in my initial code effort this morning but it has plenty of errors. Most of the console application did translate fine. The main issue appears to be getting the extern functions imported and enabled. I should mention I rarely use C# but wanted to learn and thought this might be a good test. I am ok with C, C++, and VB. Have only used python with a raspberry PI. That is I am probably also making some syntax errors.

using System;
using System.Runtime.InteropServices;

namespace ConsoleApp1_sdr_example

public static extern void StreamACallback(short* xi, short* xq, sdrplay_api_StreamCbParamsT* params, uint numSamples, uint reset, void* cbContext);
public static extern void EventCallback(sdrplay_api_EventT eventId, sdrplay_api_TunerSelectT tuner, sdrplay_api_EventParamsT*params, void* cbContext);
...< would add the other functions here>