Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Debugger issues with NI DAQ

Hello,

 

I'm having an issue with NationalInstruments.DAQmx.AnalogMultiChannelReader causing issues with Visual Studio's debugger. I'm creating an AnalogMultiChannelReader that runs in a new thread and continuously check for and reads incoming waveforms using ReadWaveform().

//Creating the DAQ task
private NationalInstruments.DAQmx.Task SampleTask;
SampleTask = new NationalInstruments.DAQmx.Task();
SampleTask.AIChannels.CreateVoltageChannel("Dev1/ai0", "", AITerminalConfiguration.Differential, 0.0, settings.DiodeLaserDaqMaximumVoltage, AIVoltageUnits.Volts);
SampleTask.AIChannels.CreateVoltageChannel("Dev1/ai1", "", AITerminalConfiguration.Differential, 0.0, settings.DiodeLaserDaqMaximumVoltage, AIVoltageUnits.Volts);
SampleTask.Timing.ConfigureSampleClock("",DLSampleRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, samplesExpected);
SampleTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("/Dev1/PFI2", DigitalEdgeStartTriggerEdge.Rising);
SampleTask.Triggers.StartTrigger.DigitalEdge.DigitalFilterEnable = true;
SampleTask.Triggers.StartTrigger.DigitalEdge.DigitalFilterMinimumPulseWidth = 0.0001;
SampleTask.Triggers.StartTrigger.Retriggerable = true;
SampleTask.Stream.Timeout = -1;
SampleTask.Stream.Buffer.InputBufferSize = 1000000;
SampleTask.Control(TaskAction.Verify);
SampleTask.Control(TaskAction.Commit);

//Creating the reader
private AnalogMultiChannelReader SampleReader;
SampleReader = new AnalogMultiChannelReader(SampleTask.Stream);
SampleTask.Start();

//Reading waveforms in the thread
if (SampleTask.Stream.AvailableSamplesPerChannel > 0)
{
AnalogWaveform<double>[] waves = SampleReader.ReadWaveform(samplesExpected);
}

However, if we run the application from Visual Studio with the debugger attached and try to close the application using the "Stop Debugging" option in Visual Studio while the reader's DaqStream is still running, both Visual Studio and the application become completely unresponsive, to the point of having to reboot the whole computer. I've been able to prevent this for crashes and manual shutdowns, but I can't find any way to prevent it when the debugger is forcibly ended. Does anyone know if this is a known issue or if there is a way to handle the reader that won't conflict with the debugger in this way?

0 Kudos
Message 1 of 1
(843 Views)