LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with DLL terminology going from C++ to LabVIEW

So I want to use a DLL which operates as follows:

 The DLL is called with some parameters to initiate a read operation to an RS232 device.

 The DLL returns with a pass/fail indication that the message was transmitted on the RS232 port.

Now here is where I get lost -

 The DLL is now waiting for a response from the RS232 device.

 The DLL some how sends the result to the program that initially called it with the device data or timeout.

 

What is the name for this mechanism? Is it Messaging or Callback or what?

 

I have the C++ source code for the DLL and a program that calls the DLL but I have no training in C++. I've traced parts of both programs and can see what's going on but I would like to use the DLL with LabVIEW and am getting stuck by terminology and newbness to this type of DLL call from LabVIEW.

 

 

This is in the message map section of a C++ file:

ON_REGISTERED_MESSAGE(MsgReadPropAckID, MSG_Receive)

 

afx_msg LONG MSG_Receive(WPARAM ch,LPARAM port); //Receive message function

 

I think there is also a shared variable used between the two C++ programs. Which I am also unfamiliar with and am wondering how this is all set up in LabVIEW.

 

Can someone explain this? Thanks!

Message 1 of 7
(3,030 Views)

For RS232 communication, I don't understand why you would want to use a DLL when a VISA can handle it.

0 Kudos
Message 2 of 7
(3,024 Views)

I would but the protocol is BACnet, which is too complicated for me to write. The DLL handles the token passing and other complexities.

0 Kudos
Message 3 of 7
(3,019 Views)

You can not interface C++ specific features through the Call Library Node. For one thing C++ interfaces are not binary compatible between compilers at all. The DLL specification does provide rules how to export function and variable pointers, but not C++ objects. In early days you even had trouble to mix and match standard C DLLs and executables calling them between different compilers as Microsoft, Borland and Symantec did not agree on how to pass certain parameters betwen caller and callee.

 

How C++ objects are layed out in memory, and how to initialize and destroy them still is very compiler specific, so trying to call a C++ library compilid with GCC from a MSVC executable or vice versa is still a good way to crash your system sooner or later. This also applies to other C++ compilers. The Call Library Node consequently doesn't support C++ objects at all.

 

So in order to call your C++ library you will have to add a standard C wrapper to it, either by adding it directly to the DLL or writing a seperate wrapper DLL. This standard C wrapper will export function calls with LabVIEW friendly parameters, which is the best way to interface them with the Call Library Node.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 7
(3,017 Views)

This doesn't explain what the C++ mechanism is but it points out that is doesn't matter because it's not compatible with LabVIEW. 🙂

 

I'm going to take another look at the DLL source code. I think it can be changed to reply with the data or timeout indication instead of just an indication that the message was sent on the bus. I've been using other functions of this DLL with LabVIEW and Teststand with no issues so I think it's just that specific function that uses that C++ mechanism. I like the wrapper idea but I'll try modifying the DLL first.

 

Thanks rolfk, for the explanation. I can move on now. 🙂

0 Kudos
Message 5 of 7
(3,011 Views)

I'm not sure about MFCism and all that stuff as I have never used the MFC at all. However I think the specific message implementation might be in fact a Windows message being sent to the application. This is theoretically possible in LabVIEW by usiung the Windows Message Queue example but in practice often limited, because not all types of Windows messages get send to the actual application windows that this message queue library hooks.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 7
(3,009 Views)

Dear Pat,

 

if you want to use BACNet in LabView, I believe the easiest way is as follows.

 

1. Go to the BACNet CSharp project page HERE

 

2. Download the project files of the latest stable release.

 

3. Get yourself Microsoft visual C# express and build the project, I believe it is free.

 

4. Use the C# exported functions through .NET interface from LabView, it is very programmer friendly.

 

The .NET works as follows, you create an object via contructor, this is where you select the library, and then you can use the object methods and properities...

 

You can skip steps 1 - 3 if you find that library build somewhere (for your target OS)

 

0 Kudos
Message 7 of 7
(3,008 Views)