LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using a VC++ DLL with Labwindow CVI 6.0

Hello All.

I have been reading all about VC++ DLL's and their use in LW CVI 6.0.

My problem is that I have upgraded some existing software to include a UI and automate it on an NT system. the old code was for DOS and written in C. The code used numerous inp() and outp() commands to talk to the serial ports (COM1 and 2). I attempted to rewrite the comm protocols usinf comrd and comrdbyte, etc, but it was too slow. I read that using inp and outp isn't a good idea in LW since it is not a low level programming environment. All of this I understand.


The next step for me was to creat a VC++ DLL for the functions that use inp and outp. I have done this and created the .h .lib and .dll files. Whenever I include th
e .lib file in LW, run the program, I get a Protection Fault. I then try to rewrite the DLL with terms like extern "C" and compile that in VC++, but Labwindows gives me an empty declaration error when looking at the header file that contains my function prototypte.

If anyone has any help that could let me use my functions in a VC++ DLL in LW CVI, please let me know. Below is one of the functions I am trying to write in the DLL.

_____________________________

char SendChar(char Byte, int Port)
{
if (inp(SerStaReg[Port]) & 0x01) inp(SerDatReg[Port]);
while (!(inp(SerStaReg[Port]) & 0x20));
outp(SerDatReg[Port], Byte);

return (RecvChar(Port));
}

___________________________

RecvChar is another function used to read the port. serdatreg is 2f8 or 3f8 depending on the port and serstareg is 2fd or 3fd depending.

I have declared them a million ways in the header file as well as around the function itself, what is the right way and why do I get the protection fault er
ror. I have also gotten various other errors depending on what declarations I make (ie. __declspec(dllexport) __stdcall extern "C" {} and so on. I have read a number of replie, but none seem t work for me


please help
0 Kudos
Message 1 of 2
(2,705 Views)
comrd() is too slow? I think it's way more than fast enough for the baud rates that a PC's COM1 and COM2 support. You might want to look at it again.
For your empty declaration error, try using something like this in your VC header file.

#ifdef __cplusplus
extern "C" {
#endif

// prototypes of functions exported for CVI to call

#ifdef __cplusplus
}
#endif"
0 Kudos
Message 2 of 2
(2,705 Views)