Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 port get stuck

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

0 Kudos
Message 1 of 11
(6,644 Views)

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! Smiley Happy

Message Edited by Broken Arrow on 06-04-2009 08:16 AM
Richard






0 Kudos
Message 2 of 11
(6,633 Views)

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

0 Kudos
Message 3 of 11
(6,582 Views)

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

LabVIEW 2012
0 Kudos
Message 4 of 11
(6,580 Views)

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. 

Message 5 of 11
(6,575 Views)

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   

 

 

0 Kudos
Message 6 of 11
(6,537 Views)
You should post your VI. If the VI has a loop, you should be using the termination monitor so that if can be stopped from TestStand when you terminate that.
0 Kudos
Message 7 of 11
(6,535 Views)

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. 

 

0 Kudos
Message 8 of 11
(6,517 Views)

It is a third party com port

 

Thanks

Rafi

0 Kudos
Message 9 of 11
(6,483 Views)

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...)

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 10 of 11
(6,477 Views)