rtlsdr-manager icon indicating copy to clipboard operation
rtlsdr-manager copied to clipboard

SamplesAvailable Never Called

Open W3AXL opened this issue 4 years ago • 1 comments

I'm trying to get a basic WPF reading samples from my RTL dongle. The app connects to the radio fine, but my assigned SamplesAvailable function never fires after I start async sample reading.

The relevant code (taken almost verbatim from the Demo1.cs example)

Debug.WriteLine("Initializing radio");

// Create & connect to the device
rtlManager.OpenManagedDevice(Convert.ToUInt16(fRadioList.SelectedIndex), rtlName);

// Set samplerate
rtlManager[rtlName].SampleRate = new Frequency { Hz = rfSampleRate };

// Set frequency
rtlManager[rtlName].CenterFrequency = new Frequency { Hz = 151700000 };

// Set Buffer
rtlManager[rtlName].MaxAsyncBufferSize = 512 * 1024;
rtlManager[rtlName].DropSamplesOnFullBuffer = true;
rtlManager[rtlName].ResetDeviceBuffer();

// Set gain mode
rtlManager[rtlName].TunerGainMode = TunerGainModes.Manual;

// Set gain
Debug.WriteLine(String.Format("Setting initial RTL gain to {0} dB", rtlManager[rtlName].SupportedTunerGains[fRadioGain.SelectedIndex]));
rtlManager[rtlName].TunerGain = rtlManager[rtlName].SupportedTunerGains[fRadioGain.SelectedIndex];

// Start
Debug.WriteLine("Connecting to RTL device: " + fRadioList.Text);
rtlManager[rtlName].StartReadSamplesAsync(16384);

// Assign sample callback
rtlManager[rtlName].SamplesAvailable += (sender, args) =>
{
    sampleCallback(rtlManager[rtlName].GetSamplesFromAsyncBuffer(args.SampleCount), args.SampleCount);
    Debug.WriteLine($"{args.SampleCount} samples recieved");
};

My sampleCallback function is never called, and the debug print inside the SamplesAvailable function also never prints. However the app runs fine with no errors or exceptions so I'm led to believe the callback just isn't being called for some reason.

W3AXL avatar Jun 27 '21 04:06 W3AXL

The demo behaves the same way. SamplesAvailable is never called.

Demo output

W3AXL avatar Jun 27 '21 14:06 W3AXL