LimeSDR Mini connected but cannot receive IQ samples

I can detect my LimeSDR Mini using LimeUtil.exe --find. I am able to connect, initialize, and configure frequency, gain, etc. — the LimeSDR Mini indicators blink as expected.

However, I cannot receive IQ samples. Does anyone know why this might be happening or how to fix it? Any advice would be greatly appreciated.

WinForm
int r = LimeAPI.LMS_Open(out dev, null, IntPtr.Zero);
if (r != 0)
{
MessageBox.Show(“Unable to open the device!”);
return;
}

r = LimeAPI.LMS_Init(dev);
if (r != 0)
{
MessageBox.Show(“Init error!”);
LimeAPI.LMS_Close(dev);
return;
}
Thread.Sleep(200);

r = LimeAPI.LMS_EnableChannel(dev, 0 /RX/, 0, 1 /enable/);
if (r != 0) MessageBox.Show("EnableChannel failed: " + r);
Thread.Sleep(200);

LimeAPI.LMS_SetLOFrequency(dev, false, 0, 433.907e6);
Thread.Sleep(200);

double freq;
LimeAPI.LMS_GetLOFrequency(dev, false, 0, out freq);
MessageBox.Show("LO freq = " + freq);

// 設 SPAN = SampleRate
LimeAPI.LMS_SetSampleRate(dev, 2e6, 0);
Thread.Sleep(200);

LimeAPI.LMS_SetAntenna(dev, 0, 0, “LNA_H”);
Thread.Sleep(200);

LimeAPI.LMS_SetGaindB(dev, 0, 0, 30.0); // RX 通道 0, 30dB
Thread.Sleep(200);

LimeAPI.LMS_SetTestSignal(dev, 0, 0, 0, 0, 0);
Thread.Sleep(200);

// 6. 設定 Stream
LimeAPI.lms_stream_t rx = new LimeAPI.lms_stream_t()
{
isTx = 0,
channel = 0,
fifoSize = 1024 * 1024,
throughputVsLatency = 0.5f,
dataFmt = 0,
handle = IntPtr.Zero
};
IntPtr streamPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LimeAPI.lms_stream_t)));
Marshal.StructureToPtr(rx, streamPtr, false);

LimeAPI.LMS_SetupStream(dev, streamPtr);
Thread.Sleep(200);
LimeAPI.LMS_StartStream(streamPtr);
Thread.Sleep(200);

// 7. 讀取一次 IQ
int SAMPLE_COUNT = 4096;
short buffer = new short[SAMPLE_COUNT * 2];
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
LimeAPI.lms_stream_meta_t meta = new LimeAPI.lms_stream_meta_t();

var sw = System.Diagnostics.Stopwatch.StartNew();
while (sw.Elapsed.TotalSeconds < 5)
{
int rec = LimeAPI.LMS_RecvStream(streamPtr, handle.AddrOfPinnedObject(), (uint)SAMPLE_COUNT, ref meta, 1000);
if (rec > 0)
{
Console.WriteLine($“Received {rec} samples”);
for (int i = 0; i < Math.Min(10, rec * 2); i += 2)
Console.WriteLine($“I:{buffer[i]} Q:{buffer[i + 1]}”);
}
}
handle.Free();

// 8. Stop & cleanup
LimeAPI.LMS_StopStream(streamPtr);
Thread.Sleep(200);
LimeAPI.LMS_DestroyStream(dev, streamPtr);
Thread.Sleep(200);
Marshal.FreeHGlobal(streamPtr);
LimeAPI.LMS_Close(dev);
Thread.Sleep(200);

LimeAPI.cs:
const string dll = “LimeSuite.dll”; // 在 bin 資料夾要有這個檔

[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_Open(out IntPtr device, string info, IntPtr args);

[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_Close(IntPtr device);

[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_Init(IntPtr device);

[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_SetLOFrequency(
IntPtr device,
bool dir_tx, // false = RX / true = TX
uint channel,
double frequency
);

[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_GetLOFrequency(
IntPtr device,
bool dir_tx,
uint channel,
out double frequency
);

[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern double LMS_GetRSSI(IntPtr device, uint channel);

[DllImport(“LimeSuite.dll”, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_EnableChannel(
IntPtr device,
int dir_tx, // 0=RX, 1=TX
uint channel,
int enabled // 0=disable, 1=enable
);

[DllImport(dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = “LMS_SetSampleRate”)]
public static extern int LMS_SetSampleRate(
IntPtr device,
double rate, // sample rate (Hz),例如 2e6 = 2 MHz
uint oversample // 通常填 0 (driver 決定),或 1,2,… 視需求
);

// 設定增益(RX / TX)
[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_SetGaindB(IntPtr device, int isTx, uint channel, double gain);

// Stream 結構
[StructLayout(LayoutKind.Sequential)]
public struct lms_stream_t
{
public int isTx;
public uint channel;
public uint fifoSize;
public float throughputVsLatency;
public int dataFmt; // 0=I16, 1=F32
public IntPtr handle;
}

[StructLayout(LayoutKind.Sequential)]
public struct lms_stream_meta_t
{
public int waitForTimestamp;
public ulong timestamp;
}

// Stream 操作
[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_SetupStream(IntPtr device, IntPtr stream);

[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_StartStream(IntPtr stream);

[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_RecvStream(IntPtr stream, IntPtr samples, uint sample_count, ref lms_stream_meta_t meta, uint timeout_ms);

[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_StopStream(IntPtr stream);

[DllImport(dll, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_DestroyStream(IntPtr device, IntPtr stream);

[DllImport(“LimeSuite.dll”, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_SetAntenna(IntPtr device, int dir_tx, uint channel, string name);

[DllImport(“LimeSuite.dll”, CallingConvention = CallingConvention.Cdecl)]
public static extern int LMS_SetTestSignal(
IntPtr device, // device handle
int dir, // 0 = RX, 1 = TX
uint channel,
int type, // LMS_TESTSIG_NONE, LMS_TESTSIG_NCODIV8, …
double freq,
double amplitude
);

need more information, what version of the LimeSDR Mini board you have? And where did you get the LimeSuite.dll, what it’s version?

1 Like

As shown in the image, is this the LimeSDR Mini version information?
Also, the LimeSuite.dll I am using was built from the repository at the URL below.
The operating system is Windows 11, and LimeSuiteGUI.exe can connect successfully.
Thank you.

download:PothosSDR-2021.07.25-vc16-x64.exe
https://downloads.myriadrf.org/builds/PothosSDR/

image

The LimeSuite.dll you are using is too old, it does not have support for your LimeSDR-Mini v2 version. Even though it can communicate with the device, the library does not know about specific settings required for the board. For example, you are not getting IQ data, because the library does not enable all necessary clocks mini v2: fix #393 always enable adc, dac clocks · myriadrf/LimeSuite@d676b49 · GitHub

I suggest you build LimeSuite.dll from source GitHub - myriadrf/LimeSuite: Driver and GUI for LMS7002M-based SDR platforms

2 Likes

“OK, I will try again, and if it does not succeed, I will raise the issue again. Thank you.”