From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware HANDLE in CIN

I want to use the following code to open a device and return a HANDLE. How do I program my code to do this with a CIN.  I did manage to write a wrapper DLL for the same device and that is working fine, but I trying to do the same with a CIN.

 

 

HANDLE PortOpen(VOID)
{
 hPort = CreateFile ("\\\\.\\SDCI0\\0",
      GENERIC_READ | GENERIC_WRITE,
      0,
      NULL,
      OPEN_EXISTING,
      FILE_ATTRIBUTE_NORMAL,
      NULL);
 return hPort;

}

 

Please note I'm a beginner, unfortunately the explanation in the Labview documents is not clear enough for me.

0 Kudos
Message 1 of 4
(2,444 Views)
CEE,
I think that the MUCH easier way to accomplish what you're looking for is to use a Call Library Function node (CLFN) The CLFN is designed to call , pass data to, execute, and get data back from a dll. Since you said you've already got a dll up and running to accomplish your task, now it is simply a matter of using the CLFN to control your dll. There are some great tutorials , exampels , and help on using CLFN. Lastly, there is a great document on the differences between CIN and CLFN. I think you'll find the tutorial and example especially useful since you've already got a working dll wrapper. Post to let us know if you have other questions.
 
Chris C
0 Kudos
Message 2 of 4
(2,432 Views)

Chris,

 

Thank you for the info. I have been using CLFN and its working ok. The problem I have is that I’m fairly new to C++ and using advance functions in Labview (Still exploring all options). The previous hardware I used had a DLL created by the manufacturer, but for the current interface I had to write a wrapper (my first attempt). The reason I wanted to try a CIN is to write each function e.g. OpenPort, ConfigPort, RxData, and ClosePort as separate nodes.

 

CEE

0 Kudos
Message 3 of 4
(2,424 Views)
CEE,
I may be missing some of what you're trying to communicate but I still think you could use the CLFN to accomplish the "modular" function calls (open, read, write, close). In the CLFN, you can add dll functions to each instance of the node. So make a vi that calls the "open" function of the dll. Then make another vi that calls the "close" function of the dll. I assume that you already have functions inside the dll that preform the desired actions.
 
However, if you're still set on using CINs, the "Using External Code In LabVIEW" help is a great resource. (I assume you're using LabVIEW8). If you go to Help>>Fundamentals>>Calling Code Written in Text-Based Programming Languages, I think you'll find some really good information in there. See the attached picture.
 
Chris C

Message Edited by Chris_C. on 05-30-2006 10:55 AM

0 Kudos
Message 4 of 4
(2,416 Views)