LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

OpenComConfig opens Port twice

Hi out there,

accidentally I noticed that OpenComConfig opens an already opened port twice.

I'm using LabWindows CVI 2009 (9.1.0)

In my Application I open a serial port with

iStatus = OpenComConfig (iComPort, "", 19200, 0, 8, 1, 512, 0); with iComPort = 1

OpenComConfig returns 0 as expected.

 

From a panel callback there is a second

iStatus = OpenComConfig (iComPort, "", 19200, 0, 8, 1, 512, 0); with iComPort = 1

Again OpenComConfig returns 0! I expected an error because the port is already open!

 

Is that the intended behavior of OpenComConfig ?

 

thx in advance

ah

 

0 Kudos
Message 1 of 3
(2,952 Views)

everything seems to be fine; official help says:

 

If the specified port is already open, OpenComConfig closes the port and then opens it again.

Message 2 of 3
(2,950 Views)

Wolfgang has it right - I like treating opening an already open com port as an error, but to do so I use a static variable to retain the com port open / closed state, for this very reason, if you reopen it with OpenComConfig there's no error.

 

If the com port has been opened by another process however, you do get an error.  I think the com port is a process resource, not a thread resource, so if you reopen from a different thread in your process you get no error.

Message 3 of 3
(2,926 Views)