Limedrv

What is Limedrv
Limedrv is a libLimeSuite Golang wrapper. It is designed to be easy of use and to be very easily integrated with any type of DSP inside go.

Getting Started
From now on, this article assumes that you know how to setup your golang environment and can build simple hello world programs. If you don't know or never played with GoLang, please refer to: https://golang.org/doc/install

Enumerating Devices
The first thing we need to be able to enumerate all devices that are plugged in. For that, let's create simple program that prints out every lime device that it finds.

package main

import (	"github.com/myriadrf/limedrv"	"log" )

func main { devices := limedrv.GetDevices log.Printf("Found %d devices\n", len(devices))

for i, v := range devices { log.Printf("%d: %s\n", i, v.DeviceName) } }



Now we can try to open the device and list its capabilities:

package main

import (	"github.com/myriadrf/limedrv"	"log" )

func main { devices := limedrv.GetDevices log.Printf("Found %d devices\n", len(devices))

if len(devices) == 0 { log.Fatal("No devices found!") }

d := devices[0]

log.Printf("Opening %s\n", d.DeviceName) dev := limedrv.Open(d) // Open the selected device defer dev.Close     // Defer the close of the device

log.Println(dev) }



Receiving Samples
Receiving data is also simple with limedrv:

package main

import (   "github.com/myriadrf/limedrv"    "log" )

var stop chan bool var receivedSamplesChunk = 0

func OnSamples(data []complex64, channel int, timestamp uint64) { log.Printf("Received %d samples on channel #%d with timestamp %d\n", len(data), channel, timestamp) receivedSamplesChunk++

if receivedSamplesChunk == 10 { stop <- true } }

func main {

stop = make(chan bool) // Create Stop Channel

devices := limedrv.GetDevices log.Printf("Found %d devices\n", len(devices))

if len(devices) == 0 { log.Fatal("No devices found!") }

d := devices[0]

log.Printf("Opening %s\n", d.DeviceName) dev := limedrv.Open(d) // Open the selected device defer dev.Close     // Defer the close of the device

dev.SetCallback(OnSamples) // Set Samples Callback dev.SetSampleRate(3e6, 4) // Set Sample Rate to 2 msps and 4x oversampling // Get RX Channel 0 (A) channel := dev.RXChannels[limedrv.ChannelA]

channel. SetCenterFrequency(106.3e6). // Set Center Frequency SetAntennaByName(limedrv.LNAW). // Set LNAW Port SetLPF(1.5e6). // Set LPF to 1 MHz EnableLPF. // Enable the LPF SetGainNormalized(0.2). // Set gain to 0.2 in Normalized value (0 -> 1) SetDigitalLPF(500e3). // Set Digital LPF (GFIR) to 500kHz EnableDigitalLPF. // Enable Digital LPF (GFIR) Enable                           // Enable the RX Channel

log.Println("Starting LimeSDR") dev.Start

<-stop // Block main routine waiting for stop signal

log.Println("Stopping LimeSDR") dev.Stop }



You can also enable MIMO (on supported devices) by just enabling the second channel:

dev.RXChannels[limedrv.ChannelA]. SetCenterFrequency(106.3e6). // Set Center Frequency SetAntennaByName(limedrv.LNAW). // Set LNAW Port SetLPF(1.5e6). // Set LPF to 1 MHz EnableLPF. // Enable the LPF SetGainNormalized(0.2). // Set gain to 0.2 in Normalized value (0 -> 1) SetDigitalLPF(500e3). // Set Digital LPF (GFIR) to 500kHz EnableDigitalLPF. // Enable Digital LPF (GFIR) Enable                           // Enable the RX Channel channel. dev.RXChannels[limedrv.ChannelB]. SetCenterFrequency(106.3e6). // Set Center Frequency SetAntennaByName(limedrv.LNAH). // Set LNAW Port SetLPF(1.5e6). // Set LPF to 1 MHz EnableLPF. // Enable the LPF SetGainNormalized(0.2). // Set gain to 0.2 in Normalized value (0 -> 1) SetDigitalLPF(500e3). // Set Digital LPF (GFIR) to 500kHz EnableDigitalLPF. // Enable Digital LPF (GFIR) Enable                           // Enable the RX Channel



Transmitting Samples
Currently limedrv only supports RX. But TX support is planned.