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?'


@Mark_Yedinak wrote:

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


Thanks, I am not sure though - how do I set the data type? It seems like I can enqueue whatever, but the dequeue only seems to spit out a string and I don't see with the obtain queue a place to set element type.

 

Thanks!

0 Kudos
Message 11 of 24
(1,461 Views)

You can enqueue anything. The dequeue returns the data as a flattened string. The receiving end needs to know the data type which was enqueued and use a Unflatten From String to get the data back in the correct type.

 

Basically something like this:

Basic Network Queue.png



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 12 of 24
(1,459 Views)

Mark,

 

If I am opening the server queue in one application and adding elements to it on another application (but same machine), is localhost still the right connection? When I use localhost I get the error when opening the client queue: GetRawSocketFromConnectionID.vi - invalid connID

 

If I open the server and client from within the same application, however, it opens up the client queue OK. 

 

Thanks for you continued help!
Alex

 

0 Kudos
Message 13 of 24
(1,446 Views)

Show me your code. Localhost will work. The name of the queue needs to be the same for the server and the client.



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 14 of 24
(1,441 Views)

Here are the two files. I run the servetest first and then try adding to the queue via the other vi and I get that error.

Download All
0 Kudos
Message 15 of 24
(1,437 Views)

Give this a try. Don't close the client until you are done using the queue.



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
Download All
0 Kudos
Message 16 of 24
(1,433 Views)

Sorry, can you repost those as LV 2016 (or do a screen grab)? I tried removing the close queue and I still get the error on the client initialize.

0 Kudos
Message 17 of 24
(1,429 Views)

These are pretty straightforward VIs. I am not sure why you would be getting an error on your Create Client. Have you verified that you don't have a firewall blocking the connection?



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
Download All
0 Kudos
Message 18 of 24
(1,426 Views)

OK so,

 

If I run those two VIs from the same project, then it works fine. If I run them from separate projects then I get the connect error. It is possible that we have a firewall set up, that sounds like the sort of thing they do here. Is there a specific port or something that i should ask about? 

 

Alex

0 Kudos
Message 19 of 24
(1,411 Views)

I have used this library across projects as well as across multiple computers. By default the server will automatically select an unused port number. This will generally be above 50000 but is random and will change every time you execute the code. You can specify a port to use if you want. A set port will generally make IT folks happier since they only have to provide a firewall rule for a specific port (or a few) rather than a large range of port numbers. The NI Service Locator uses port 3580. That port will also need to be allowed.

 

The reason the code work in a single project but not across projects is that it will use a native LabVIEW queue if it can. Within a project the client will find that native queue and use that. Different projects will not see each other's native queues so you need the network. If the firewall is blocking access then it will not work because of that.



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 20 of 24
(1,403 Views)