LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

control VIs remotely using Python via TCP/IP

Hello all,

 

 

I've read through a lot of topics here, but only a few address my question. However, I could not find any useful information. So...

 

I have the NI PXI chassis with an AIO card in it (NI-PXI 6259) and an embedded controller running Windows + LabView. There I run some VI's that generate signals (sine, sawtooth, DC) and output them to hardware. So far so good.

But is there a possibility to pass the signal parameters to the VIs (amplitude, frequency, offset) via Python from a remote computer running Linux. Has anybody tried this before? Could you share some code/point me in the right direction?

 

Thanks in advance,

maslick

0 Kudos
Message 1 of 7
(4,067 Views)

I would build the LabVIEW project into a DLL or .NET Interop assembly exposing the methods and accessors as public.  There are a lot of good sections in the LabVIEW help file that cover this.


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

I have never tried that specifically with Python on the other end of the connection, but if your python environment can establish TCP/IP connections, the process should be pretty straight forward. 

 

To test it, there is a TCP/IP server example that ships with LV. Try running that on the embedded controller and see if you can talk to it from your python environment. 

 

Mike..

 

PS: Jeff, your idea is good but there appears to be a problem with establishing outgoing TCP/IP connections from LV-generated .NET assemblies. I recently ran into a situation where a VI built into a .NET assembly consistently failed when trying to establish an outgoing connection (error 63), but the exact same VI built into a conventional executable worked fine.


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 7
(4,044 Views)

Thanks guys. I could manage to establish connection and exchange strings between Python and the TCP server vi.

But how can I open and run a specific VI remotely from Python?

0 Kudos
Message 4 of 7
(4,029 Views)
That will require some work since NI doesn't document how VI Server works internally. But...

You could create a server to which you can send the name of a VI that you want run. If there are parameters you want to pass to the VI, that will require some additional work. However, thinking off the top of my head if you pass the run time parameters as JSON strings, you could convert them into native LV data types (including arrays and clusters) with very little effort.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 7
(3,932 Views)

@maslick wrote:

Thanks guys. I could manage to establish connection and exchange strings between Python and the TCP server vi.

But how can I open and run a specific VI remotely from Python?


Now we are digging into an area of LabVIEW I have little experience in (GREAT I Might learn something):smileyvery-happy:  [edit: I just did]

 

There are command line options. 

See this topic of the help file.  Its easier to find on disk than on-line


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 7
(3,646 Views)

can you please share on how you managed to pass strings from python to labview

0 Kudos
Message 7 of 7
(3,013 Views)