09-03-2015 03:07 PM - edited 09-03-2015 03:20 PM
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)
Here's the True case
09-03-2015 03:14 PM
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> ---'
09-03-2015 03:14 PM
09-03-2015 03:24 PM - edited 09-03-2015 03:28 PM
@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.
09-03-2015 03:32 PM
@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> ---'
09-04-2015 04:42 AM
I would copy + paste or re-create the code in a new VI...sounds like a candidate for some sort of weird corruption.
09-08-2015 11:32 AM - edited 09-08-2015 11:36 AM
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"
Where does the close at line 21 come from? Is that part of the flush?
09-09-2015 02:50 PM
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.
09-09-2015 05:00 PM
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.