LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with GetSystemComHandle

When using the following stripped-down multithreaded code in CVI 5.5.1
the OpenCom() function crashes when the thread is executed for the
second time. It only works if I remove the GetSystemComHandle() call.
Any comments, suggestions?

Thanks, Marcel

#include
#include
#include

HANDLE ThreadHandle;
int ThreadID;
HANDLE ComHandle;

DWORD WINAPI ComThread(LPVOID Param)
{
OpenCom(1, "");
GetSystemComHandle(1, (int*)&ComHandle);
CloseCom(1);
return 1;
}

int main(int argc, char *argv[])
{
if (InitCVIRTE(0, argv, 0) == 0)
return -1;
ThreadHandle = CreateThread(NULL, 0, ComThread, 0, 0, &ThreadID);
WaitForSingleObject(ThreadHandle, INFINITE);
ThreadHandle
= CreateThread(NULL, 0, ComThread, 0, 0, &ThreadID);
WaitForSingleObject(ThreadHandle, INFINITE);

CloseCVIRTE();
return 0;
}
0 Kudos
Message 1 of 2
(2,949 Views)
This was a bug is our serial thread locking that was found a little while ago with the GetSystemComHandle. It has been fixed but we have no patch planned since we are already in beta for CVI 6.0. You can contact me if you would like to get the beta software to avoid this problem.

Best Regards,

Chris Matthews
Measurement Studio Support Manager
Message 2 of 2
(2,949 Views)