# How to program LimeSDR in C#?

**URL:** https://discourse.myriadrf.org/t/how-to-program-limesdr-in-c/5625
**Category:** System Development
**Created:** [14 January 2020 14:56 UTC](https://discourse.myriadrf.org/t/how-to-program-limesdr-in-c/5625 "2020-01-14T14:56:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![OgreVorbis](https://avatars.discourse-cdn.com/v4/letter/o/96bed5/32.png) [@OgreVorbis](https://discourse.myriadrf.org/u/OgreVorbis)
#### Post date: [14 January 2020 14:56 UTC](https://discourse.myriadrf.org/t/how-to-program-limesdr-in-c/5625/1 "2020-01-14T14:56:39Z")

</div>

Please forgive me if this forum is not dedicated to programming. I can’t find a good place to ask this question because I can’t find a forum dedicated to SDR programming and stackoverflow is too specific with the questions you can ask.  
I am looking to write programs to control the lime SDR with C# on a similar level to what one would use GNU radio and python to do. What is the name of the core library that GNU radio uses? Maybe there is a C# binding?  
Not asking anything too specific, but if someone could point me in the right direction of what library to use, I would appreciate that.

---

<div class="post-metadata">

### Author: ![andrewback](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@andrewback](https://discourse.myriadrf.org/u/andrewback)
#### Post date: [14 January 2020 15:25 UTC](https://discourse.myriadrf.org/t/how-to-program-limesdr-in-c/5625/2 "2020-01-14T15:25:15Z")

</div>

Lime Suite is the hardware driver.

> **[myriadrf/LimeSuite](https://github.com/myriadrf/LimeSuite)**
>
> Driver and GUI for LMS7002M-based SDR platforms. Contribute to myriadrf/LimeSuite development by creating an account on GitHub.

gr-limesdr builds on this to provide sink/source blocks in GNU Radio.

> **[myriadrf/gr-limesdr](https://github.com/myriadrf/gr-limesdr)**
>
> gr-limesdr Plugin for GNURadio. Contribute to myriadrf/gr-limesdr development by creating an account on GitHub.

But you wouldn’t use this unless you were using GNU Radio and you’d just use Lime Suite instead.

Wrappers have been created for other languages, such as Golang.

[https://wiki.myriadrf.org/Limedrv](https://wiki.myriadrf.org/Limedrv)

So this could give some clues as to how you might approach this.

The LimeStream util from lime-tools also serves as a good example for accessing the SDR and setting up streaming.

> **[myriadrf/lime-tools](https://github.com/myriadrf/lime-tools/tree/master/limestream)**
>
> A collection of useful tools for use with the LimeSDR family of boards - myriadrf/lime-tools

You could possibly even use this is a very simple “driver”, at least initially perhaps during the early stages of development.

---

<div class="post-metadata">

### Author: ![mzs](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/mzs/32/2678_2.png) [@mzs](https://discourse.myriadrf.org/u/mzs)
#### Post date: [14 January 2020 15:56 UTC](https://discourse.myriadrf.org/t/how-to-program-limesdr-in-c/5625/3 "2020-01-14T15:56:03Z")

</div>

You could probably learn something from reading the SDRsharp-limesdr plugin code. It may not be exactly what you are looking for but it may help, it is C# code.

> **[GoranRadivojevic/sdrsharp-limesdr](https://github.com/GoranRadivojevic/sdrsharp-limesdr)**
>
> LimeSDR frontend for SDR#. Contribute to GoranRadivojevic/sdrsharp-limesdr development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![RightHalfPlane](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@RightHalfPlane](https://discourse.myriadrf.org/u/RightHalfPlane)
#### Post date: [15 January 2020 04:42 UTC](https://discourse.myriadrf.org/t/how-to-program-limesdr-in-c/5625/4 "2020-01-15T04:42:48Z")

</div>

You can call C routines in dlls directly from C#. Here is a simple example.  
You would just need to do the same thing to your SDR library calls.

```
    [DllImport("NCSA-LIBRARY.dll")]
    public static unsafe extern int writeSDS2D(String nameFile, double* data, int xsize, int ysize, int type, int iflip);

        int ret = 0;
        unsafe
        {
            fixed (double* d = &data[0], last = &data[xsize * ysize - 1])
            {

                ret = writeSDS2D(R2.strData, d, xsize, ysize, 0, 0);
            }
        }
        if (ret != 0)
        {
            WarningBuff = "saveNCSA Error Writing File : " + R2.strData + " \n";
            WarningExpression(WarningBuff);
        }
```
