LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best Method For Communication With Executable

I am building an application that I will need to be able to communicate with once I create an executable out of it. I will need to communicate with it using other executables that I build in LabVIEW, but I would also like others to be able to communicate with it via other programming languages such as Python, MATLAB, and others. Is there a preferred and robust method to be able to do this? I would like to be able to communicate with it by sending string commands but also to transfer data both ways (I am thinking that the data transfer should be done with a variant). Thanks so much for any input.

0 Kudos
Message 1 of 15
(4,510 Views)

Data transfer with a variant might not be best if you want everything from soup to nuts to be able to communicate with your EXE because not every language will be able to deal with a LV variant.  If you want 2-way command-response using strings, maybe you should look at TCP or UDP in a client-server type implementation.  Depending on what you are trying to do, there are probably several ways you could implement your solution.  If your app needs to behave as a server-type app, then some network communication solution could work well.  You could also access your client over networks as well, rather than from the same machine.  Without more imformation on your task, that's about the best I have for now!  🙂

0 Kudos
Message 2 of 15
(4,506 Views)

Yes, I definitely don't want to create something then find out that some application can't communicate with my app. So variant probably isnt the way to go. So how do you transfer things like arrays if not using variant? Just format the values?

 

Speed is a concern here as this application is going to be used in automated testing, I currently use reference to communcate with it... Is TCP and/or UDP fast and efficient ways of transferring data? 

0 Kudos
Message 3 of 15
(4,504 Views)

Probably the best (well easiest) way to transfer complex datatypes is with XML. You can find the flatten to and flatten from XML under file IO.

=====================
LabVIEW 2012


0 Kudos
Message 4 of 15
(4,495 Views)

I just did a speed test in an application that I am working on.  Over TCP/IP, I was able to achieve 9MBytes per second over an ethernet connection with the client and server running on the same PC.

Message 5 of 15
(4,481 Views)

Cool, thats not too shabby... When I use it, I won't be transferring too much data at a time, just short commands and small amounts of data. But I will be communicating frequently.. Do you think that the the amount of time it takes to actually initiate the process of sending the data is any slower than using control references in the LabVIEW development environment? The way I do it now is get references to certain controls and then just set the value using this reference from other VIs. I am curious as to whether or not that will be much if any difference in speed using TCP instead... I would imagine it will probably be insignificant..

0 Kudos
Message 6 of 15
(4,476 Views)

If you are talking about communicating between two EXE's (for instance) as in a client and a server application, then doing what you are talking about will most likely be somewhat slower when compared to a single EXE that passes a control reference to a subVI and that subVI uses the reference to change a value on the EXE's front panel.  The application architecture is different.

Message 7 of 15
(4,470 Views)

Thanks 10Degree, I will probably benchmark the difference between the way I am doing it now and the way I would implement using TCP to see how much slower it will be. Thanks for your insight

0 Kudos
Message 8 of 15
(4,465 Views)

You can get very good performance using TCP. If you will be transferring large amounts of data doing so in binary format will be the most efficient. The exact format of the data would depend on exactly what you are sending. An array of numbers can simply be sent as a stream of 16, 32 or 63 bit numbers. Use the one that best fits your application. If you send the data as raw data always include some type of header that would specify the number of bytes in the data stream. If you are sending less data than XML would be very portable and easily allow other applications to understand they data. However you will have some overhead when converting the data to the XML stream.

 

Since you mention performance as an issue I would avoid using references to controls and indicators. Use wires to pass the data through your application. It will be MUCH faster. If you need to pass data between tasks uses queues or possibly an action engine (functional global)

 

The native TCP VIs are very good. However as with any application you can write a high performance application or write spaghetti code which will result in poor performance.



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 9 of 15
(4,455 Views)

Thanks for your input Mark, it is much appreciated. When using TCP can there be multiple lines of communication going at the same time. For example, lets say I have a TCP server executable that may communicate with X number of TCP client executables. Can this TCP server executable open multiple TCP connections to numerous TCP client executables? If so, what is the best way to do this... Should I just increment the port number or does this have to be 6342? Thanks for you help

0 Kudos
Message 10 of 15
(4,372 Views)