LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

COM Port Disconnect Recovery

Hi,

 

LV2010, Win7 64bit.

 

I've got an issue with reconnecting the VISA COM Port when a hardware disconnection occurs.  This is when an unexpected disconnection occurs due to a cable fault or some other end point fault.

 

I can detect a disconnection through the errors produced with the read/write functions which is fine.  However when I reconnect the hardware and try to reconnect the port I get the following message:

 

VISA:  (Hex 0xBFFF00A6) The connection for the given session has been lost.

 

I've tried doing a VISA Close when the error is detected but this just fails with another error.  The only way to get it back is to close the application and restart it, usually.  In some cases I have to go into device manager to remove the port and start over.

 

I'd like to handle the disconnection elegantly in the application but can't find anything in LV to enable me to do this.

 

 

 

Any suggestions please.

 

Dave.

0 Kudos
Message 1 of 16
(5,905 Views)

Have you searched the forum? Post back if you still face issues.

 

Mathan

0 Kudos
Message 2 of 16
(5,904 Views)

Yes I've searched and can't find anthing useful.  Maybe I'm using the wrong search terms but as I didn't find anything I thought I'd post the question!

0 Kudos
Message 3 of 16
(5,902 Views)

Tools>>Option>>Enviornment.  Select "Automatically close VISA sessions"

 

Capture.PNG

 

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 16
(5,885 Views)

Tried that, no difference.

 

Not surprising as the description says the sessions are closed when the VI is idle and mines not idle (at least I don't think so as idle isn't defined).  Surely this is effectively the same action as using the VISA close VI?  If I use that then as error is reported.

0 Kudos
Message 5 of 16
(5,881 Views)

OK, What is the "Widget"?   How is it connected?


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 16
(5,866 Views)

It's a FTDI device with a custom COM port driver rather than the one supplied.  However I'm not sure that is really an issue because outside of LV, in C#, I don't have the issue.  I can pull the plug and then just reconnect after putting the plug back in.

0 Kudos
Message 7 of 16
(5,860 Views)

Any more comments?  It looks like this is a bug I should log with NI.

0 Kudos
Message 8 of 16
(5,802 Views)

Hi,

 

I am also using an FTDI device and have been dealing with this type of problems since LV2009.

I use the attached VI to close a VISA COM port. I have no problems reusing the COM port after the device has been reconnected.

 

Jorge
0 Kudos
Message 9 of 16
(5,790 Views)

@JorgeF wrote:

Hi,

 

I am also using an FTDI device and have been dealing with this type of problems since LV2009.

I use the attached VI to close a VISA COM port. I have no problems reusing the COM port after the device has been reconnected.

 


Sometimes it really helps to READ the help.

RTFM.png

VISA Close Details

Error I/O operates uniquely in this function. The function closes the device session regardless of whether an error occurred in a preceding operation. For each VISA session that you open, you should close the session when you are finished with it. This function accepts all available classes.

 

So, now that you have dead code and you just garunteed that incomming errors are tossed out, how will you debug your app?


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 16
(5,742 Views)