Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL hCom trouble

We use a DLL file to receive data from the serial port, this works.
 
We:
- open port
- handle the data
- close the port again
- return calculated values
 
problem: We need to seperate the open/close and handle parts to reach maximum speed. So we dont have to open and close the serial port each time we receive new data.
 
We open the serial port with hCom:
 
hCom = CreateFile( pcCommPort,
                    GENERIC_READ | GENERIC_WRITE,
                    0,    // must be opened with exclusive-access
                    NULL, // no security attributes
                    OPEN_EXISTING, // must use OPEN_EXISTING
                    0,    // not overlapped I/O
                    NULL  // hTemplate must be NULL for comm devices
                    );
 
But the question is, how can we open the port in one DLL block, so we can use this in the read DLL block function? So we have to return the hCom HANDLE value or something.
0 Kudos
Message 1 of 2
(6,818 Views)
You can pass the handle as a variable or you can store it in a the DLL variable, or create a class in your dll that manages the com port.
 
Thanks
Karsten
0 Kudos
Message 2 of 2
(6,759 Views)