LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communicate with Instruments via TCP

Solved!
Go to solution

So I have an instrument that communicates via ethernet only (Agilent 16702B). I am using VISA VI's to communicate to this instrument, this is what the address looks like: "TCPIP0::LA-Agilent16702::6500::SOCKET"

 

Communication is fine for an undetermined amount of time.. Its weird, during an automated test all of a sudden there will be an issue with talking to the instrument (no new commands are being executed, this is after X number of times of executing the same code) and I get the following error:

 

 

Error -1073807194 occurred at VISA Write in StartLogicAnalyzer.vi->Troubleshoot.vi


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

 

Anybody ever have the same or similar issue or maybe even know what is happening here?

 

Thanks so much for any help,

Anthony

0 Kudos
Message 1 of 15
(4,802 Views)

It's not uncommon to lose communication with instruments. There could be any number of reasons for the loss in communication. Could be hardware-related in terms of cables. Could be related to your network. Could be instrument firmware. It sounds like you may be opening a connection to the instrument and keeping it open throughout the run. You may want to consider switching to a method where you open and close the connection only when you need to communicate with the instrument.

0 Kudos
Message 2 of 15
(4,794 Views)

It sounds like you may be opening a connection to the instrument and keeping it open throughout the run. You may want to consider switching to a method where you open and close the connection only when you need to communicate with the instrument.


You really want to open the VISA session once-

 

Close it when (and only when) you exit your program-

 

Do everything inbetween (like read or write) on the same session,

 

Take a look at Ben's AE nugget---- the "Resource Module" is not too much of a stretchSmiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 15
(4,786 Views)
Solution
Accepted by amaglio

I would do as follows:


1) Open VISA session

2) Keep it open until a connection error is detected

3) In case of connection error. Close and reopen VISA session to re-estabilish connection

4) Close when exiting the software

 

Marco

0 Kudos
Message 4 of 15
(4,774 Views)

@Jeff Bohrer wrote:

It sounds like you may be opening a connection to the instrument and keeping it open throughout the run. You may want to consider switching to a method where you open and close the connection only when you need to communicate with the instrument.


You really want to open the VISA session once-

 

Close it when (and only when) you exit your program-

 

Do everything inbetween (like read or write) on the same session,

 

Take a look at Ben's AE nugget---- the "Resource Module" is not too much of a stretchSmiley Wink


I would beg to differ. Or rather, I would say that it depends. The cost of opening/closing a communication should be based on how often you communicate and how long you communicate (both in terms of the active communication, and the lenght of the complete conversation, including those awkward pauses when you don't know if you should say something or wait for the other person to say something). In other words, if you send short commands that last a second or two at most, and this is done at a frequency of minutes, and the whole test lasts on the order of many, many, minutes (close to hours), then you are far better off opening/closing the connection. Leaving a connection open throughout is pointless. Furthermore, if a connection is left open for a long time without there being any sort of activity on it (like a hearbeat), and that connection goes through some network devices, such as gateways, some of the these devices will simply close a connection if it's left inactive for a long time.

Message 5 of 15
(4,756 Views)

Thank you very much guys. The solution Marco proposed works. When I get the error all I need to do is open the close the VISA session and reopen it again. Thanks again!

 

Anthony

0 Kudos
Message 6 of 15
(4,747 Views)

Be aware that you should look at the specific errorcode  that you are getting, verifying that it's due to the connection being lost, and not simply closing/opening willy-nilly regardless of the actual error that occurred. Doing this would effectively swallow up the error should it be regarding something else.

0 Kudos
Message 7 of 15
(4,745 Views)

@smercurio_fc wrote:

Be aware that you should look at the specific errorcode  that you are getting, verifying that it's due to the connection being lost, and not simply closing/opening willy-nilly regardless of the actual error that occurred. Doing this would effectively swallow up the error should it be regarding something else.




Agreed, this is important. Thanks

0 Kudos
Message 8 of 15
(4,742 Views)

a.png

Specifies whether to use keep-alive packets on TCP connections. Setting this property to TRUE requests that a TCP/IP provider enable the use of keep-alive packets on TCP connections. After the system detects a dropped connection, VISA returns a lost connection error code on subsequent I/O calls on the session. The time required for the system to detect the dropped connection depends on the system and is not settable. The default is FALSE.

Smiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 15
(4,735 Views)

You also need to consider the device on the other end of the connection. If this device could be reset during the test opening and closing the connection is not always a bad thing. I agree if you know you will be sending data up and back steadily and without much delay leaving it open is not a problem. If you will have long gaps between messages it is best to open/close the connection as needed.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 10 of 15
(4,732 Views)