Code examples .Net and C#?

Add useful snippets of code or links to entire SDR projects.
Toontje
Posts: 50
Joined: Fri Aug 07, 2015 8:36 am

Code examples .Net and C#?

Postby Toontje » Tue Mar 22, 2016 12:53 pm

Hi coders!

I want to make a start with understanding how to write an app for the SDRplay using Visual Studio and C#.
Do we have any code examples i can start off with?

Thanks,

Ton.
Last edited by Toontje on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

Sasan
Posts: 96
Joined: Sat Jun 27, 2015 1:15 am

Re: Code examples .Net and C#?

Postby Sasan » Tue Mar 22, 2016 11:23 pm

Hi
I wrote a simple console app which saves I/Q streams to a file (which can later be opened in apps like Gqrx or SDRSharp)
It's very basic and does not get command line arguments (all values are hard-coded)
The code is attached.

Note that I'm not a C# programmer and I don't even use Windows a lot, so it's just a proof-of-concept to show how to call the API from C#.
I compiled the code on .NET 3.5 and executed it on Windows 10 to make sure it works.
It calls the mir_sdr_api.dll, found in :
C:\Program Files\MiricsSDR\API\x86 and C:\Program Files\MiricsSDR\API\x64
Does this help you?

P.S: take a look at SDRPlay's sample codes (in C): https://github.com/SDRplay/
and API specification: http://www.sdrplay.com/docs/Mirics_SDR_ ... cation.pdf
Attachments
Program.cs.zip
(1.6 KiB) Downloaded 342 times
Last edited by Sasan on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

Toontje
Posts: 50
Joined: Fri Aug 07, 2015 8:36 am

Re: Code examples .Net and C#?

Postby Toontje » Wed Mar 23, 2016 7:22 am

Yes, this helps me a lot!

Thanks!
Last edited by Toontje on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

ronkpa
Posts: 5
Joined: Tue Apr 11, 2017 2:01 am

Re: Code examples .Net and C#?

Postby ronkpa » Wed Apr 26, 2017 7:13 pm

Thank you Sasan Program.cs was very helpful. I am creating a C# wrapper based on your work.
The latest API release is 2.10 (11/Apr/2017).
The latest API Specification is 2.09 (22 Dec 2016) says there is only one SetParam command 101=change 1st LO freq.
In your program you use commands 201 and 202. Do you have a later API specification, or did you use another reference?
Thanks again.
Last edited by ronkpa on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

Sasan
Posts: 96
Joined: Sat Jun 27, 2015 1:15 am

Re: Code examples .Net and C#?

Postby Sasan » Thu Apr 27, 2017 8:17 am

ronkpa wrote:Thank you Sasan Program.cs was very helpful. I am creating a C# wrapper based on your work.
The latest API release is 2.10 (11/Apr/2017).
The latest API Specification is 2.09 (22 Dec 2016) says there is only one SetParam command 101=change 1st LO freq.
In your program you use commands 201 and 202. Do you have a later API specification, or did you use another reference?
Thanks again.


I don't remember which version I'd used, but the latest API specification says the "mir_sdr_SetParam" function is deprecated and will be removed in future.
(Section 3.2 on http://www.sdrplay.com/docs/Mirics_SDR_ ... cation.pdf
OR section 3.3 on http://www.sdrplay.com/docs/SDRplay_SDR ... cation.pdf)

So I think you can ignore the values I'd used (and the function as well)

Reason: No reason

sdrplay
Posts: 613
Joined: Wed Jan 07, 2015 7:58 am

Re: Code examples .Net and C#?

Postby sdrplay » Sat May 13, 2017 6:40 pm

If you have the c# communication to the API sorted, then you can follow the flow in the play_sdr example we updated on github (http://www.github.com/SDRplay/examples)

Best regards,

SDRplay Support

Reason: No reason

chris11
Posts: 1
Joined: Thu Nov 16, 2017 3:21 pm

Re: Code examples .Net and C#?

Postby chris11 » Thu Nov 16, 2017 3:33 pm

Hello,

Sasan thank you very much for the code examples. Did anyone manage to create Pinvoke statements which work in Visual Studio C# for the latest dll or can give me some hints.
Last edited by chris11 on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

SteveAndrew
Posts: 1
Joined: Thu Nov 16, 2017 11:06 pm

Re: Code examples .Net and C#?

Postby SteveAndrew » Sun Nov 19, 2017 7:01 am

Hi everyone

I've just uploaded a zip file to the Playground (SdrScan.zip)

It's a simple C# program that shows how to get data from the API using the streaming function. It was written using Visual Studio 2010, .Net Framework 4 for 64 bit systems. It should compile and run in later editions of Visual Studio (in theory) but as with most things Microsoft, in theory, theory and practice are the same thing, in practice they are not :-)

The code is based on the original work done by Sasan... Many thanks for getting the ball rolling.

Hope this helps...
Last edited by SteveAndrew on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason


Return to “Code Corner”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest