Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

set the read timeout using asynchronous BeginReadMultiSample

When using the asynchromous BeginReadMultiSample method with analog level triggering, I get the following error:
 
Some or all of the samples requested have not yet been acquired. To wait for the samples to become available use a longer read timeout or read later in your program. To make the samples available sooner, increase the sample rate. If your task uses a start trigger, make sure that your start trigger is configured correctly. It is also possible that you configured the task for external timing, and no clock was supplied. If this is the case, supply an external clock.
 
This is DAQmx error -200284.
 
The error occurs when the trigger condition does not occur within a few seconds after starting my Task.  This is a problem, because I want to wait indefinitely for a trigger to occur, not have a short timeout followed by an error.  I need to know if its possible to adjust the "read timeout" as suggested by the error message, and how to do so if it's possible.
 
Any help will be most appreciated.
 
Jerry
 
0 Kudos
Message 1 of 9
(5,500 Views)

You can configure how long the function waits by setting the Timeout property on the DaqStream class. For example:

myTask.Stream.Timeout = 1000; // Wait for 1sec
// ('Timeout' is in milliseconds)

Setting this property to (-1) will allow you to wait indefinitely.  The syntax will be slightly different depending on if you are using VB/C/C# etc..

Hoep this helps.
-Jeff

0 Kudos
Message 2 of 9
(5,476 Views)

Jeff,

Thanks for the help and what you recommended worked.  I couldn't find how to do this anywhere in the Meas Studio help documentation.

However, now that I got past the timeout issue, another problem has arisen.

After I start my task using BeginReadMultiSample, there seems to be no way to stop the task if the board is waiting for a trigger condition to occur.  I have a control button that performs Task.Dispose.  This is meant for the user to stop data acq completely.  This works fine as long as the trigger condition is being satisfied.  But if the board is waiting for a trigger, and Task.Dispose is called, the system completely hangs up.  Task.Stop does the same.  In fact, any attempt to control the task while the board is waiting for the trigger seems to hang up the system.

Any advice on how to cleanly stop the data acq task while waiing for a trigger?

Thanks,

Jerry

 

0 Kudos
Message 3 of 9
(5,470 Views)

Jerry,

What I would do is create a button that performs the callback for the code.  Inside of the "halt button" callback, I would put the following:

try
 

0 Kudos
Message 4 of 9
(5,454 Views)

Jerry,

What I would do is create a button that performs the callback for the code.  Inside of the "halt button" callback, I would put the following:

try
 

0 Kudos
Message 5 of 9
(5,458 Views)

Jerry,

What I would do is create a button that performs the callback for the code.  Inside of the "halt button" callback, I would put the following:

try
  

0 Kudos
Message 6 of 9
(5,454 Views)
Jerry,
 
What I would do is create a button that performs the callback for the code.  Inside of the "halt button" callback, i would put the following:
 
try
   {
   myTask.Control(TaskAction.Abort);
   }
   catch (DaqException.ex)
   {
   MessageBox.Show(Ex.Message);
   myTask.Dispose();
   statButton.Enabled = true;
   }
 
this will go to the callback.  Inside of that, I would handle the exception for the error that occurs when aborting a task (-88710) and disregard JUST that error code.  This would go inside of the callback itself.
 
catch (DAQException.ex)
 
   if (ex.Error != -88710)
         {
      MessageBox.Show(ex.Message);
         }
 
Hope this is helpful.
-Jeff
0 Kudos
Message 7 of 9
(5,450 Views)

Jeff,

Your suggestion worked great! Problem solved.

Thank you again,

Jerry

 

0 Kudos
Message 8 of 9
(5,446 Views)
Jerry:

I'll file a bug report to include a link to the DaqSreaam.Timeout property from the Read/Write method documentation in a future version of DAQ.

Thanks,
-- Chris W
NI .NET/C++ DAQmx Team
0 Kudos
Message 9 of 9
(5,441 Views)