06-04-2009 03:17 AM
HI,
Once in a while I get this problem that the RS232 port is stuck. The only way out is to resets the pc.
My application run in LabView under TestStand. When it happened the VI is stuck too and I must exit the program with 'abort'.
Now, if I check with an external RS232 program (e.g.. Procomm), I see that the port is busy.
1) Is there any way to force close this port?
2) A LabView process is still running (after I closed all applications) and would not accept 'End Process'. Could that be related to the port being stuck?
Thanks
Rafi
06-04-2009 08:14 AM - edited 06-04-2009 08:16 AM
Can you post a snippet of how you are reading the serial ports and getting bytes at port? You may be stuck waiting for bytes to arrive at the Read function, or stuck in a loop waiting for bytes to arrive that have already been read out.
If your code is structured well, then hardware related synch issues can cause hiccups. You should have error checking so that the program will bail out when it doesn't get the data it expects at the expected rate. For example, if you are reading (what you think is) exactly 18 bytes every time, you should check that there is exactly 18 bytes present before calling VISA Read. If you don't get the data in X seconds, also bail out or retry the Send.
It's not LabVIEW processes. Thousands of LabVIEW programs talking to RS232 devices running rock-solid for weeks at time can't be wrong!
06-09-2009 02:08 AM
Hi and thanks,
I don't argue that something is wrong in LV. I'm just looking for a solution when this is happening.
I exit TestStand, LabView but still there is a LV process running. This process, probably is holding my com. The only way I know to get rid of it is to restart the PC. I'm asking whether there is a better way
Thanks
Rafi
06-09-2009 03:03 AM
Hi
A possible reason for this is that there are VISA sessions being opened and not closed down properly. The quick way around this is to close a VISA session to the serial port before opening it and discarding the error if it says "Its already closed". The proper way is to ensure that the serial port resources are closed properly throught the test program. The nature of this problem is that after running successfully for periods of time the test will hang up at indeterminable intervals.
Craig
06-09-2009 07:39 AM
The root cause of the problem is that the process is unable to shut down properly, which prevents the serial handle from being automatically closed with the process cleanup. It is possible that it is actually a serial command which is stuck, or the process could be failing to shut down for some other reason.
I would recommend that you downlload Portmon from Microsoft's SysInternals page, and run it while you reproduce the problem. After you have captured the low-level serial traffic from the port, you should be able to look at the log and see if any of the commands never returned a result such as SUCCESS. If any of the lines are missing a result, then that particular command is for some reason stuck in the driver and is likely to be preventing the port from being closed.
-Jason S.
06-11-2009 09:14 AM
Hi Jason,
Thank you for your advice. I installed the portmon on my PC and was able to log data before the port got stuck.
It is a SendAndWait routine where I was waiting for "BOOT". The text arrived and the vi closes the port. From what I see, it got stuck upon closing the port. I was doing power reset to my system just prior to this test and here, I'm monitoring the boot up.
Do you see any hint to what had happened?
Thanks
Rafi
Logged data just before the port got stuck
-----------------------------------------------------
12:36:48 LabVIEW.exe IOCTL_SERIAL_GET_COMMSTATUS Adsser0 SUCCESS
12:36:48 LabVIEW.exe IOCTL_SERIAL_GET_COMMSTATUS Adsser0 SUCCESS
12:36:48 LabVIEW.exe IOCTL_SERIAL_GET_COMMSTATUS Adsser0 SUCCESS
12:36:48 LabVIEW.exe IRP_MJ_READ Adsser0 SUCCESS Length 100: .... -------------- BOOT ------------.. ------------------------
12:36:48 LabVIEW.exe IOCTL_SERIAL_GET_COMMSTATUS Adsser0 SUCCESS
12:36:48 LabVIEW.exe IOCTL_SERIAL_CLR_RTS Adsser0 SUCCESS
12:36:48 LabVIEW.exe IOCTL_SERIAL_CLR_DTR Adsser0 SUCCESS
12:36:48 LabVIEW.exe IOCTL_SERIAL_PURGE Adsser0 SUCCESS Purge: TXABORT RXABORT TXCLEAR RXCLEAR
12:36:48 LabVIEW.exe IRP_MJ_CLEANUP Adsser0 SUCCESS
12:36:48 LabVIEW.exe IRP_MJ_CLOSE Adsser0
06-11-2009 09:27 AM
06-11-2009 08:51 PM
12:36:48 LabVIEW.exe IRP_MJ_CLOSE Adsser0
It does look to me like the close for the serial port is getting stuck. Is this the built-in port on a computer, an NI serial port, or is it another third-party product?
-Jason S.
06-14-2009 01:09 AM
It is a third party com port
Thanks
Rafi
06-15-2009 04:43 AM
What version of the VISA driver and OS are you using?
I had similar problems while using multiple COM ports and VISA 2.3 (? not shure, more than 5 Years ago...)