07-29-2010 08:07 AM
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
07-29-2010 08:26 AM
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
07-29-2010 09:26 AM
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
08-02-2010 01:45 AM
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.
08-10-2010 05:09 PM
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