LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual COM port for USB - cannot disconnect without freezing the software

Hi all,

 

We are using a converter chip to handle serial-USB conversion in our products.  It works great until a connection is lost and then the software freezes.  I believe this is due to the COM port being destroyed by the chip's driver before we have a chance to exit gracefully.  I'm looking for a way to flag this so that I know the COM port is destroyed and I can then close it in the code and stop trying to access it, but without much luck.  Is there any function in CVI that allows us to do this or at least capture the error when the COM port is destroyed?

 

Thanks,

 

Judy

0 Kudos
Message 1 of 5
(4,375 Views)

Hi Judy,

 

are you checking for timeout in your code? VISA returns the timeout error both for read and write operations:

VI_ERROR_TMO: Timeout occurred before operation could complete

 

Wolfgang

0 Kudos
Message 2 of 5
(4,372 Views)

Hi Wolfgang,

 

Thanks for the suggestion, but we don't use VISA.  I am looking for a ComStat Error and trying to exit on that, but we don't use handshaking, so I really can't do much on that.

 

Judy

0 Kudos
Message 3 of 5
(4,366 Views)

Hi Judy,

 

Are you using the CVI RS-232 library in your code?

 

What is the "nature" of the freezing? Do you have to use the task manager to forcefully terminate your program?

Could that be because you have a ComRd in a loop and your are stuck because of successive timeouts?

 

Do you check the return values of your RS-232 function calls?

If you do the error checking you may guess the reason of the problem better.

S. Eren BALCI
IMESTEK
0 Kudos
Message 4 of 5
(4,312 Views)

I suspect the nature of the problem is that with the USB / serial converter chips and the corresponding virtual com port, the virtual com port does not appear to Windows as a serial port unless the converter chip is turned on and running.  From the application perspective, if the USB-serial converter has power removed, it doesn't act like a dead serial port that's going to timeout - rather the entire serial port simply disappears completely without a trace.

 

You could try to close the port and try to reopen/configure it - you'd get a no such port error or somesuch on the reopen attempt.

 

I know conceptually it seems messy to close / reopen a port every time you go to use it, but it doesn't take long and it doesn't harm anything - nothing's wearing out here.

 

Menchar

0 Kudos
Message 5 of 5
(4,246 Views)