LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

structure handle

how is structure handle in c and c++ be handled in labview? the structure is defined in a header file which is not part of the dll which I am trying to use
Can a computer learn how to program?
0 Kudos
Message 1 of 21
(3,685 Views)
Hi kevinhy,

Does your DLL function take or return a pointer to a complex data type (structures)? You can use LabVIEW clusters to represent structures in C/C++. The following documents and example programs might be helpful:

http://digital.ni.com/public.nsf/websearch/3FF4805467498BA986256CB80082FED8?OpenDocument
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3E78F56A4E034080020E74861
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3DD8F56A4E034080020E74861&p_node=DZ52048
http://digital.ni.com/public.nsf/websearch/D1705141137852B586256A63007490A7?OpenDocument

Hope this helps a little and good luck with your application!
Shakhina P.
Applications Engineer
NI
Message 2 of 21
(3,651 Views)
Thanks a lot Shahina, I finally start to make some progress now, but I will be sure to prompt more questions later.
Can a computer learn how to program?
0 Kudos
Message 3 of 21
(3,630 Views)
Hi, the dll requirs that I send the initial value of the structure handle to "null". how to express "null" in labview when it is to be passed into a function in a dll which is expecting a complex(structure) data type?
Can a computer learn how to program?
0 Kudos
Message 4 of 21
(3,608 Views)
To pass NULL to your DLL function using Call Library Function node, try passing an int32 with value zero.
http://digital.ni.com/public.nsf/websearch/B86515E47C330E3086256E7E005DD109?OpenDocument

Let me know if this doesn't work, and I'll look into it further. If you could post parts of your dll function and structure declaration, that would be helpful as well.

Good luck!
Shakhina
Message 5 of 21
(3,587 Views)
thank you again, the attachned zip including the reference book(starts from page 60 are the info about the dll function), the dll and my vi. it runs now with error because the hardware is not attached. but once the hardware is attached, the first two node runs without error while the locating buffer node returns and error saying "the memory is corrupted", most like the value of "hAceDesc" is illegal.
Can a computer learn how to program?
0 Kudos
Message 6 of 21
(3,581 Views)
Hi kevinhy,

Do you get the same results if you pass I32 with a value 0 as Numeric (for Type) Signed 32-bit Integer (for Data Type) by Pointer to Value (for Pass)? You can also try creating a Cluster (with values initialized to 0 if numeric, empty string if string, etc) and pass that to your DLL function. I couldn't find the definition of HACQDESC from the pdf document, you might have the header file.

Otherwise you might need to write a wrapper function that calls your DLL function and passes NULL to it.

Hope you'll get it to work soon.
Best regards,
Shahina P.
NI
Message 7 of 21
(3,566 Views)
the answer is yes. the same problem persists. I do have a header file and also there is a demo code to run operate the machine in C. I couldn't pull much out of it but it might be useful for a experienced programmer.
Can a computer learn how to program?
Message 8 of 21
(3,563 Views)
Try the modified VI, do you get a value other than 0 for hAcqDesc (on the front panel)? If you get 0 then the initialization in Acquisition_GetNextSensor is not working properly.

Also, is there reason why you are passing 0 (NULL) to pProcesseData in Acquisition_DefineNextBuffers, whereas in the C code a pointer to a malloc'd buffer is passed?

Best regards,
Shahina P.
NI
Message 9 of 21
(3,547 Views)
Thanks, all functions returns zero 🙂 I haven't check yet but I wonder what modification have you done, there doesn't seem to be any significate changes in the code but apparently yours runs while my code fails. the reason I pass zero to pProcessData is because I don't know how to define a pointer with required size(this pointer must points to the beginning of the buffer and of the size of the buffer which is 512*512*n, where n is the number of frames). I posted that question on this forum but haven't got any replies yet.

a lot of thanks

kevin
Can a computer learn how to program?
0 Kudos
Message 10 of 21
(3,532 Views)