Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxClearTask thread

Hello,
I use a USB 6501 with VisualC++7.1.
I use DAQmxCreateTask which creates a thread.
Then DAQmxCreateDOChan, DAQmxStartTask, DAQmxStopTask and DAQmxClearTask.
None of these functions give me an error.
But DAQmxClearTask doesn't terminate the thread.
Is that normal?
Thank you.
0 Kudos
Message 1 of 9
(8,531 Views)

Hello,

 

First of all the DAQmxCreateTask() function doesn't create a thread. The DAQmxCreateTask() function creates a context where software and hardware resources required for the task are allocated.

 

The DAQmxCreateDOChan() function specifies the digital lines that we want to use.

 

The DAQmxStartTask() function starts the generation task. From this point the hardware resources are allocated. If you run another application that tries to use the allocated digital lines, an error will be returned.

 

The DAQmxStopTask() functions stops the generation task.

 

The DAQmxClearTask() releases the allocated resources.

 

I precise that the DAQmxStartTask() and DAQmxStopTask() functions have a meaning only in a buffered generation (id est if you generate digital patterns on a clock). In this case a timing function must be used (the DAQmxCfgSampClkTiming() function for example) to precise the number of pattern to generate on the digital lines and the update rate. Before the start of the generation (DAQmxStartTask() call), the pattern must be written in the driver internal buffer with a function like DAQmxWriteDigitalU32().

 
For more information, please look at the NI-DAQmx examples in "...\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Digital" and the NI-DAQmx Help file.
 
Best regards,
Message 2 of 9
(8,500 Views)

Hello,

thank you for your answer.

this line:

if( DAQmxFailed(miError=DAQmxCreateTask("tache0",&mtaskHandle0)))

creates a thread in my software, and this thread is never stopped or terminated by any DAQmx function.

Si I'm very surprised by your anwer...

I don't know where is this problem, but I don't think that the window task manager gives wrong information.

Are you sure that DAQmxCreateTask does not create any thread?

Thank you.

0 Kudos
Message 3 of 9
(8,497 Views)
Hi Ien!

   as stated in LabWindows Help, a task is a collection of one or more virtual channels with timing, triggering, and other properties. So, task and thread are different concepts.  Maybe the problem is in french language:

     multi-tasking = multitache 
     (NI) task = tache. 

This may generate confusion, I can understand!!!

   Let me know if this helps you a little bit!

graziano

PS.: j'aurais essaye d'ecrire en francais, mais je connais pas assez bien...........Smiley Wink

Message 4 of 9
(8,493 Views)

Thank you for your help, but there is no language problem, even if my english is poor.

When I execute DAQmxCreateTask 's line with Visual C++ debugger, a new thread is created in my application. It's the Windows Task Manager that is showing this.

For me, it's because DAQmxCreateTask creates a thread. That why I don't understand why DAQmxClearTask doesn't terminate this thread.

Where is the bug? Is it the Windows Task Manager, which badly detect the thread number of an application?

Or does DAQmxCreateTask create a thread, which could be logical...

Thank you.

0 Kudos
Message 5 of 9
(8,461 Views)
OK ien, now I've understood!

   It's an interesting issue, and for what you said in your post, I guess that LabWindows applications work this way:
  
     a thread is created for the application, and then threads are added for each measurement task, which are destroied only at program exit.

   Of course, an user can explicitly add threads.

   Your post is interesting because gives the opportunity to ask NI for explanations about it! I hope someone will answer...

   Thanks...

graziano
0 Kudos
Message 6 of 9
(8,457 Views)
Sorry!!!!
   I usually work with LabWindows/CVI, and I think Labwindows doesn't work the way I mentioned above!

   Anyway, NI answer on both issues are welcomed (thread creation by VC++ / CVI).

   Bye!

graziano
0 Kudos
Message 7 of 9
(8,454 Views)

Hello NI support and DAQmx C API users,

I am still very new to legacy DAQ and DAQmx C/C++ function calls, so I hope I this is the place to ask my question 🙂

If i have created a bunch of TaskHandles in my code and I call DAQmxStartTask() for each task, does the DAQmx driver run the tasks in parallel?

e.g.

Taskhandle a

Taskhandle b

DAQmxCreateTask(&a)

DAQmxCreateTask(&b)

// .... code to create DAQmxCreateCIPulseWidthChan for ctr0 and DAQmxCreateCITwoEdgeSepChan for ctr1 measurement

DAQmxStartTask(a)

DAQmxStartTask(b)

 

Is PCI-6602 hardware going to run finish running taskhandle a before starting taskhandle b? Are they going to run at the same time?

Thanks,

Geoff

 

0 Kudos
Message 8 of 9
(7,871 Views)
Bonjour Geoff,

Je vous suggère de jetter un oeil aux liens suivants:

How many threads does NI-DAQmx has ?
NI-DAQmx and NI-DAQ FAQ

Cordialement,

Message Edité par Mathieu Steiner le 10-02-2007 08:08 AM

0 Kudos
Message 9 of 9
(7,855 Views)