From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Avoiding Race Conditions using Network Variables w/ RT

Solved!
Go to solution

SYSTEM:
I am using a cRIO system connected to a host PC via ethernet.
One of the pieces of my cRIO system I'm having a problem with is using CAN. 

BACKGROUND:
FPGA waits for a read, and when a message is received (U8 Array format), it shoves each element into a U8 Target-to-Host FIFO.
RT sees the message in the FIFO, collects it, and builds it into a 2D U8 Array (in case more that one message is received) and appends it to a growing 2D U8 Array.



PROBLEM:
Originally, I was passing that 2D array off to the Host computer through a Network Variable, and displaying it on the front panel of the host machine.  This works, except over time this 2D U8 array gets huge- especially if I'm using an echo. 


Ultimately I want the host to display the entire history, but having the RT rewrite that entire variable every time and sending the whole thing over the network slows it down. 

FAILED ATTEMPTS:
I was hoping to change it to a Queue, but apparently it can only be accessed by other elements in the host (in this case, the LabVIEW RT Module.)

Writing a blank array to the Network Variable after reading it obviously causes major race condition issues.

QUESTION:
Any suggestions on how to pass this data to the host without losing data?

Is it possible to have something similar to a queue or FIFO over the network? 

Thanks,

~Andrew

0 Kudos
Message 1 of 3
(2,327 Views)
Solution
Accepted by topic author Dyskresiac
There's two routes that you could go: 1) For continuous streaming to the host network streams give the effect of the queue over the network but it does require something to sent the data to I.e. hard if you need to connect/disconnect your host. 2) stick with shared variables but your RT code will have to manage the buffer. For example you might set up a circular buffer of the last n samples which is written to the variable. Based on what you say I would go with 2 although for it to give a full history is hard.
James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
Message 2 of 3
(2,318 Views)

I'm going to have to try the Network Stream.  I haven't used one before and once you mentioned it, I remember reading about that in the RT Manual/User Guide thing.

I don't have to disconnect my host at any point.  (I had thought about going that route at one point but decided against it for my first RT project.)

I'm going to try that.  THanks.

0 Kudos
Message 3 of 3
(2,313 Views)