Finally found the trick, I mean "a" trick, not sure if it will work for others but it solved my problem:
To programatically open a connection to a shared variable hosted on a cRIO from that same cRIO, try "Open and Verify Variable Connection" from the PSP Variable Palette, with a timeout of -1 . The 1st SV will take between 10 to 30 sec and the next ones will be connected normally in a matter of ms.
If I use the normal "Open Variable Connection", it keeps on timing out after 5 sec and never connects, no matter how long I keep trying.
What made me take so long to figure it out:
After restarting the cRIO and running the vi, the connection to the SV never happens. If I stop the vi and run it again, it connects directly.
By the same token if I restarted my cRIO with a start-up application and then connect to the rtexe through operate->debug application, I could see that the connection did not occur. But if I stopped the rtexe and started it again, it would again connect directly.. and I was like wwhhhhyyyyyyy??
Can't thank you enough. I have been pulling my hair out for four days. Most of my code was written with just the "open connection" vi and everything was working fine for months until just four days ago. It is almost inexplicable. (Do NI/LabVIEW updates break things? I keep using the update service now and then).
Atleast for now, I can use your "trick" to get things working. Thank you.
I had the exact same issue recently. In my case the fix in this thread did not work and the issue was eventually resolved by using the hostname of the cRIO in the variable address. Using "localhost" or the IP of the cRIO both failed, but using the hostname (without the .local extension) worked. It may be obtained programmatically using: