Il contenuto non è disponibile nella lingua selezionata.

Verrà mostrato il contenuto in un'altra delle lingue disponibili. Il tuo browser potrebbe avere delle funzionalità di traduzione.

Error Code -200479 When Running a NI-DAQ™mx Application

Updated Aug 14, 2023

Reported In

Software

  • LabVIEW

Driver

  • NI-DAQmx

Programming Language

  • Python

Issue Details

I am using the DAQmx Start Task.vi and DAQmx Read.vi or DAQmx Write.vi functions to acquire or generate data. When I run my program, I receive the following error message: Error -200479 Specified operation cannot be performed while the task is running

 

Solution

This particular error occurs when a task's state is set to Running when it is already in the Running state. There are three common scenarios where this error may show up:
  • Referencing the same task twice, and attempting to start both before stopping one of them
  • Placing a DAQmx Start Task.vi inside a while loop without stopping the previous instance of the task
  • Placing a DAQmx Read.vi or a DAQmx Write.vi before a DAQmx Start Task.vi and setting Autostart to False
You can avoid this error by starting and clearing the task outside of the While loop, and ensuring that the DAQmx Read.vi is not called before the DAQmx Start.vi, as in the example below:



If a DAQmx Start Task.vi is placed inside a While loop without stopping or clearing the task, on every successive iteration of the While loop the task will attempt to start a task that is already Running. In order to avoid this, make sure that you stop or clear the task before it is restarted using the DAQmx Stop Task.vi or DAQmx Clear Task.vi. Typically, starting and stopping the task outside of the While loop will avoid this error and improve driver performance as there are less state transitions taking place. 

Additional Information

When using the DAQmx Python API, you may encounter a similar issue. Below is a small code snippet that demonstrates the problem. When the commented line is executed, an error message will appear due to the auto_start parameter being set to True.
DataStream = nidaqmx.stream_writers.AnalogSingleChannelWriter(task.out_stream, auto_start=True)
DataStream.write_many_sample(Data) 
# task.start()

Understanding the source of this error involves understanding the NI-DAQmx Task State Model. NI-DAQmx uses the Task State Model to improve ease of use and speed up driver performance. The Task State Model consists of five states: UnverifiedVerifiedReservedCommitted, and Running. For more information about the Task State Model refer to the Related Links.

When a task begins to perform an operation, the task transitions to the Running state. You can explicitly perform this transition by invoking the DAQmx Start Task.vi, however, starting a task does not necessarily begin acquiring samples or generating data. It is important to note that if a DAQmx Read.vi or DAQmx Write.vi is called, it will automatically start the task and transition the task into the Running state. If the DAQmx Start Task.vi is called after either one of these functions, it will be trying to start a task that is already in the Running state. In order to avoid this error, ensure that the DAQmx Start Task.vi is not called after your task has begun acquiring or generating data.