02-13-2012 08:20 PM
How do I check if a FPGA interface refnum is valid? It appears (LabVIEW 2009) that "Not a Number/Path/Refnum?" always returns true when wired to the output of Open FPGA VI Reference. I'm writing code that needs to be able to run without an FPGA for testing purposes so I wrapped all calls to the FPGA in a case structure that I thought would execute only if the FPGA reference is valid. Turns out they never execute, even when the FPGA reference is valid (probe shows it has a numeric value, and the FPGA VI is running). I assume this is somehow similar to semaphore and rendezvous references that have their own special function to check validity, but I don't see any such function for FPGA. Do I have to typecast to an int and check if not equal to zero?
Solved! Go to Solution.
02-14-2012 04:02 PM
Hi Nathan,
I believe what you're seeing is expected behavior as the "Not a Number/Path/Refnum?" function doesn't integrate seamlessly with references. I did a quick mock-up with a FPGA Open Reference VI and an FPGA Interface Dynamic Refnum, my code/result is below.
As shown, the refnums behave as you'd expect giving us true values, however the type-cast reference and refnum both result in false values. Since there doesn't appear to be a straightforward way to check validity (as you can do with semaphores), it looks like you will probably need to do a bit of extra coding to get the behavior you want. I would be interested to see what you've come up with as this would be a useful feature.
Tim W.
Applications Engineering
National Instruments
02-14-2012 04:25 PM
Thanks for looking at this. Try something: uncheck the "Dynamic Mode" checkbox, and the behavior changes. The output of "Not a Refnum?" will always be true. After seeing your message I checked this in LabVIEW 2011. The project in which I discovered the behavior is in LabVIEW 2009 (as mentioned in my original post) which did not have dynamic mode. This seems like a bug, or at least weird behavior, especially the mismatch between dynamic mode and not dynamic mode.
02-15-2012 12:59 PM
I'm still playing around with this behavior a bit more. In 2011, I switched between dyanamic mode and not-dynamic mode and got the same behavior in both modes (that is, neither one caused the Not a Refnum boolean to light up). In your Open FPGA VI Reference, how do you have it configured? Is it pointing to a VI, Build Spec, or Bitfile?
Tim W.
Applications Engineering
National Instruments
02-15-2012 01:04 PM
It's pointing at a VI. Here's the simplest project I can generate that demonstrates this. When I run Host.vi, I get a false output when the Open FPGA Reference is in Dynamic mode, and a true output when it's not.
02-15-2012 04:06 PM
Things are getting a bit stranger. I ran your example on my cRIO 9075 and got false values on the boolean for both dynamic and not-dynamic modes. I'm going to track down an R Series card to test it with something closer to your set up.
Tim W.
Applications Engineering
National Instruments
02-15-2012 04:09 PM
That's strange, sounds like it's doing exactly what it should do for you, and not for me. I see this behavior even without any hardware attached - just running the FPGA on the development computer with simulated IO.
02-15-2012 04:20 PM
In case it helps, here are screenshots from running it in both dynamic mode (top), and not dynamic mode (bottom). There's an oddity in the probe in not-dynamic mode as well, as you can see: in the tree the probe has a value, but in the display it's shown as 0.
02-17-2012 11:45 AM
Hi Tim - just wondering, any update on this? Is there any more information I can provide that would be useful? Were you able to duplicate the behavior I'm seeing, or do you only get the expected behavior?
02-17-2012 11:59 AM
Hi Nathan,
I've gotten busy with a few other things, but am still working on this, I will update you once I get it figured out.
Tim W.
Applications Engineering
National Instruments