LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[C interface] Correspondance between TaskHandle and LVRefNum

Yet another problem coming from me.... Sorry guys to give you that much work...
Whatever,

In my attempt to create a DAQmx C application, I want to use both the functions prototyped in NIDAQmxBase.h and a handmade (well, LabView made) shared library.

In my VI source of the shared library, I created a control and an indicator for the task in and task out channels, so that I can pass them as arguments to the C functions created by application builder.

The problem is, that in NIDAQmxBase.h, the task channels are represented by a TaskHandle instance (a uInt32 "typedefed"), and in my library, my function recquires a LVRefNum, defined as a MagicCookie.

The file given as a source of explanation about this MagicCookie type (cookie.cpp) does not exist on my hard drive ?

How can I make these two work together ? (Something like LVRefNum createLVRefNum(TaskHandle th) and TaskHandle getTaskHandle(LVRefNum lvrn))

Thanks,

Kevin

0 Kudos
Message 1 of 9
(3,937 Views)
Hey Kevin,
 
Are you performing a DAQ operation both from DAQmx base AND in the LV dll?  I don't understand why you would need to do this.  I ask because I don't see a need to pass the task name to the LV dll unless you were calling the DAQ driver from the LV dll.
 
Aside from performing all DAQ tasks in one language it is best to convert the task handles to a more universal datatype.  Try type-casting the value to a string and passing that to be converted once inside/outside the dll.
 
-Brett
0 Kudos
Message 2 of 9
(3,924 Views)
Hello Bret,

If I could, I would have made a dll to perform the whole task, but on my Linux machine, the Start and Stop task for DAQ always return an error.

That is why I made a dll with only the core of my task, leaving the task initialization and termination to the C API.
So, for the core of my task (not only DAQ VIs, but also VIs that does not have a C equivalent), I had to connect the task in/out channels to respectively a control/indicator.

The idea of typecasting the TaskHandle would be exactly what I want to do, but I don't know HOW TO convert such a task descriptor to the LVRefNum type from the dll. That is, I found in some .h from the C API that the LVRefNum is a "MagicCookie" type, which I don't have any description. That .h file refers in a comment in the MagicCookie part to a file called cookie.cpp, that does not exist in my computer, and a search "cookie.cpp" in the ni.com entire site does not match any answer.

If I knew how the MagicCookie describes the task, I would certainly be able to cast/transform my TaskHandle instance into a LVRefNum one, and the problem would be solved.
0 Kudos
Message 3 of 9
(3,921 Views)

Could you do the typecasting in your LV source code rather than in C?  This way you could pass strings rather than task names and refnums.

-Brett

0 Kudos
Message 4 of 9
(3,901 Views)
This would really be great, but I don't know how to do, or even if it is possible...
[edit]
Actually, that would not be that great, as the type TaskHandle is an integer, some kind of "task descriptor", an ID of the task instance...
[/edit]

Message Edited by Zukero on 07-26-2005 03:57 AM

0 Kudos
Message 5 of 9
(3,900 Views)
Can you write the C code to pass and receive strings???...so if the task name is "AnalogTask"....pass the value "AnalogTask" in string format into the LV created dll.  In the LV dll follow the image I sent you and typecast the string value to a task handle....that is the easiest, and recommended, way to perform this operation.
 
-Brett
0 Kudos
Message 6 of 9
(3,880 Views)
Shamefully no, the C API for DAQmx uses a pointer to an integer to refer to a given task. So i can't use a String in the C code.

0 Kudos
Message 7 of 9
(3,870 Views)

Are you not specifying a string name when you create this task?...earlier in the code?.....that is what could be used as the task name to be passed into LV as a string.

 

-Brett

0 Kudos
Message 8 of 9
(3,853 Views)
The code looks like something like this :

TaskHandle th;

DAQmxBaseCreateTask(&th);


and the the adress of this task handle is used in each function of the DAQmx C API. It is actually an integer (uInt32), and behaves like the file descriptors used by the C functions open()/close()

So, I don't think I can get it with a string.

Message Edited by Zukero on 08-03-2005 10:46 AM

0 Kudos
Message 9 of 9
(3,858 Views)