LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Flush flushes unrelated block diagram constant

I was trying to implement some retry code to detect a VISA write error and try and reconnect to the com port.

 

On my computer (VISA 14, or 15, LV2012-2015), with the following code, the output array has 2 elements both empty. (I would expect an array of 2 elements with "text" in each element.

Also, VISA Write returns 0 and no error in the final iteration. 

 

Notes:

Adding probes various places can solve the issue.

VISA Close also doesn't return an error.

I've omitted the "try and reconnect" part of the code to get the issue down to the bare minimum of code.

I am aware that the close on the bottom will cause an error on the first iteration. That's the desired test case (testing the for loop logic)

VISA Flush Error2.png

Here's the True case

VISA Flush Error True Case.png

Message 1 of 9
(3,365 Views)

So are you trying to figure out why the output text is empty? It shouldn't be. It should never be, even with weird VISA connection issues, that output will always be [text,text]. I ran this on my computer and that's what I got.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 9
(3,353 Views)
Why do you expect an error on the VISA Write? Even if you close the session, the write will automatically create a new one. Pretty difficult to get any sort of error on a write with serial communication.
0 Kudos
Message 3 of 9
(3,351 Views)

@James.M wrote:

So are you trying to figure out why the output text is empty? It shouldn't be. It should never be, even with weird VISA connection issues, that output will always be [text,text]. I ran this on my computer and that's what I got.


Yes, the text is empty.

Yeah, I was worried some people wouldn't be able to reproduce this. Since adding probes can fix this, it's there's probably a timing thing going on. It could also just be driver dependent. Stupid serial ports.

 


@Dennis_Knutson wrote:
Why do you expect an error on the VISA Write? Even if you close the session, the write will automatically create a new one. Pretty difficult to get any sort of error on a write with serial communication.

 

 

Yes, I get error

-1073807313: You must be enabled for events of the specified type in order to receive them.

0 Kudos
Message 4 of 9
(3,339 Views)

@Oligarlicky wrote:

Yes, the text is empty.

Yeah, I was worried some people wouldn't be able to reproduce this. Since adding probes can fix this, it's clearly something to do with the race condition


Well the laws of LabVIEW would force that array to always result in two elements with the values "text". Unless someone can point something out that I'm missing, and you're really seeing empty strings for those two elements, then you've found a weird bug. That For loop will always iterate 2 times and that constant is being indexed out of the loop with nothing in between. This will result in [text,text] regardless of the rest of the code.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 5 of 9
(3,328 Views)

I would copy + paste or re-create the code in a new VI...sounds like a candidate for some sort of weird corruption.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 6 of 9
(3,275 Views)

Copy paste didn't fix it

 

I've attached a couple traces in case any AEs want to look at this.

 

It looks like VISA does reopen. Sometimes the flush lands in between the write async and the "completing write async" which causes the event error.

 

Sometimes the write async completes first and I get no error but I still lose my "text"

IO Trace.PNG

Where does the close at line 21 come from? Is that part of the flush?

Download All
0 Kudos
Message 7 of 9
(3,223 Views)

Hi Oligarlicky

 

I have taken a look at your VI am have noticed a couple of things. First when I use your VI snippit I get the same issue as you do in that I get an empty string array. If I Copy it to another VI I still get the same problem however if I remake everything it works as expected and I get the array of 2 text strings. So something may have just gotten messed up in the code though I cannot tell what. Going back to modifying your code I was able to get it to work if I put an indicator connected to the text content. The other way I found of getting the correct output on the array indicator was if I changed the VISA write inside the loop to be Synchronous instead of Asynchronous.

 

I am still confused as to what could be causing this issue so I will be looking more into the root cause of this problem.

Scott B.
AE NI
0 Kudos
Message 8 of 9
(3,191 Views)

It is very intermittent but I'm glad you were able to reproduce it. Like I said, I didn't even have to add an indicator to make it work, I could just add probes. Sometimes, I didn't even have to change anything and I would have to run it a few times to get it to fail.

0 Kudos
Message 9 of 9
(3,177 Views)