LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read and write simultaneously to same file from two VIs, or 'open when available?'

I have two VIs that both access the same text file asynchronously, one continuously reading and one writing. Every so often one or the other process fails because the file is currently locked. Is there a way to:

 

1. Tell Labview to open for read in such a way that it does not prevent writing by another program?

2. Have LV wait for the lock to clear and then open (without me making some sort of while loop)? 

3. Something else? 

 

0 Kudos
Message 1 of 24
(4,571 Views)

a QMH (Queued Message Handler) would be the way to fix your problem.

 

Writer sends requests to write and the data to write into the queue.  Reader sends requests to receive file data and a ref to the Queue he is listening on.

 

Cakewalk


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 24
(4,555 Views)

I think though, that this won't work because they are separate memory spaces (compiled VI into exe). Or is there a way to share a queue between them?

0 Kudos
Message 3 of 24
(4,536 Views)

@AlexGSFC wrote:

I think though, that this won't work because they are separate memory spaces (compiled VI into exe). Or is there a way to share a queue between them?


You can wrap-up an Action Engine and use VI Server to call functions in one application with another application.

 

Allison claimed she posted an example in this thread.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 24
(4,530 Views)

I am assuming you have tried opening the file with the access level set to read only, and the problem still occurs?

0 Kudos
Message 5 of 24
(4,523 Views)

@AlexGSFC wrote:

I think though, that this won't work because they are separate memory spaces (compiled VI into exe). Or is there a way to share a queue between them?


Here is a network queue. It acts just like a normal queue but transports data over a TCP connection so you can use the queue to communicate between two applications.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 24
(4,521 Views)

I am using the read/write from spreadsheet. Is there a way to make this read only when I read? Or, more generally if I am using these two together on the same file is there a way to make them not step on eachother's toes? 

0 Kudos
Message 7 of 24
(4,482 Views)

Thank's for this idea. I might try this this week and see where I get. 

0 Kudos
Message 8 of 24
(4,481 Views)

Hi, can you save this network queue as 2016? Our system is locked into that version until we have a lot of down time to regression test everything with a newer version. Thanks!

0 Kudos
Message 9 of 24
(4,456 Views)

Here is a LV 2015 version. I happened to have a copy on my PC.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 24
(4,451 Views)