Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to take CameraLink serial port into use in VC6+MFC?

I'm trying to use the CameraLink serial port.
Developing environment is VC6 + MFC.

Serial port controlling functions reside in CLSERNAT.DLL. clsernat.h is included in the project.

Following code is used for accessing tjhe functions in DLL.
--snip------------

HINSTANCE hLib=LoadLibrary("CLSERNAT.DLL");

&clSerialClose = GetProcAddress((HMODULE)hLib,"clSerialClose");

--snip------------

The compiling gives this error:
error C2440: '=' : cannot convert from 'int(__stdcall *)(void)' to 'void (__cdecl *)(void *)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast

How the type casting should be made?

Thanks!
0 Kudos
Message 1 of 3
(4,174 Views)
Hello Hannu,

If you are using a National Instruments digital framegrabber (PCI 1424 or PCI/PXI 1422), then I would recommend using the IMAQ Serial Read and Write functions that ship with the NI-IMAQ driver.
0 Kudos
Message 2 of 3
(4,174 Views)
Hi Hannu
I'm a C++Builder programmer, the borland's c++ syntax is quite diferent but I think I can help you.

1- You could import the file CLSERNAT.lib in your project (in the VC enviroment), in this way you don't have to load the library yourself and you can use the funtion in your source code.

2- If you have to load the library yourself define pointer to the function in the DLL

typedef void __stdcall (*TFunctionInDll)(void*);

Load the Dll:

int IdentDLL = (int)LoadLibrary("CLSERNAT.DLL");

do the typecast

TFunctionInDll FunctionInDll= (TFunctionInDll)GetProcAddress((HINSTANCE)IdentLib,"clSerialCLose");

and call the function the usual way

FunctionInDll(NULL);

The typedef definition must be with the same parameters of the function in the
dll.
0 Kudos
Message 3 of 3
(4,174 Views)