Code examples .Net and C#?
Code examples .Net and C#?
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.
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
Reason: No reason
Re: Code examples .Net and C#?
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
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 3790 times
Last edited by Sasan on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason
Reason: No reason
DF2HF, NM9A, EP2C
Re: Code examples .Net and C#?
Yes, this helps me a lot!
Thanks!
Thanks!
Last edited by Toontje on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason
Reason: No reason
Re: Code examples .Net and C#?
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.
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
Reason: No reason
Re: Code examples .Net and C#?
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.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.
(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
DF2HF, NM9A, EP2C
Re: Code examples .Net and C#?
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
Best regards,
SDRplay Support
Reason: No reason
Re: Code examples .Net and C#?
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.
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
Reason: No reason
-
- Posts: 213
- Joined: Thu Nov 16, 2017 11:06 pm
- Location: Gold Coast, QLD, Australia
Re: Code examples .Net and C#?
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...
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
Reason: No reason
Re: Code examples .Net and C#?
"I've just uploaded a zip file to the Playground (SdrScan.zip)"
Can someone point me to the "Playground" ?
Thanks
Can someone point me to the "Playground" ?
Thanks
Reason: No reason
-
- Posts: 213
- Joined: Thu Nov 16, 2017 11:06 pm
- Location: Gold Coast, QLD, Australia
Re: Code examples .Net and C#?
Hi N2NIC
That code has a bug in it. It wont run when used in 32-bit mode. Andy in tech support finally traced the problem for - an absolute hero ! In the meantime, I'll redo a simple demo and post the source code here for you.
Playground link is: http://www.sdrplay.com/playground/ but it does require different login credentials. I should not have posted it there in the first place.
That code has a bug in it. It wont run when used in 32-bit mode. Andy in tech support finally traced the problem for - an absolute hero ! In the meantime, I'll redo a simple demo and post the source code here for you.
Playground link is: http://www.sdrplay.com/playground/ but it does require different login credentials. I should not have posted it there in the first place.
Reason: No reason