Remote LabVIEW via LV-Link
About 1 min
Introduction

Python implementation
configure
from lvlinkpy import Session
# Create a session. The argument is the lv-link port number asigned on LabVIEW.
s = Session(19810)
# Check control references
s.print_control_info()
LVLinkpy session constructed. Estimated latency is 0.00 ms
===================================
Boolean:{"_dim": 0, "_type": "?"}
Numeric:{"_dim": 0, "_type": "i4"}
String:{"_dim": 0, "_type": "U"}
Cluster:{"_dim": 0, "_type": "C"}
stop button without latch:{"_dim": 0, "_type": "?"}
===================================
get value
def get_value_tutorial1():
# User can get the value from the name of the control.
# Suppose there is a control called "Boolean" in the LabVIEW.
print(s.get_value("Boolean"))
# If the control name is incorrectly given, it will raise an error.
print(s.get_value("fdzggZWSdgs"))
True
An exception occurred: KeyError – 'ValueName: fdzggZWSdgs is not a valid variable on server site.'
None
def get_value_tutorial2():
# Almost the value type on LabVIEW is supported.
print(s.get_value("Boolean"))
print(s.get_value("Numeric"))
print(s.get_value("String"))
print(s.get_value("Cluster"))
True
810
qwerty
{'Array': [1, 2, 3]}]]
set value
def set_value_tutorial1():
# User can set the value by the name of the control.
# Suppose there is a control called "Boolean" in the LabVIEW, this code will set the control value to "True".
s.set_value(valueName="Boolean", value=True)
type check on Python
def set_value_tutorial2():
# This package will perform type check before send to LabVIEW.
# So, If user send a string to a bool control, it will raise an error.
# However, ignore_check=True can avoid type check on python. This action may lead an error on LabVIEW.
# Since the LV-Link server on LabVIEW will ignore the error, this code will not have effect.
s.set_value(valueName="Boolean", value="string")
s.set_value(valueName="Boolean", value="string", ignore_check=True)
An exception occurred: ValueError – the data type of the data(Boolean, type: U) does not fit to the origin data(type: ?). please check the data type or try to call update session function
Special Notice: unsupported latch action
def set_value_tutorial3():
# mechaction=True argument can activate mechanical actions of the control.
# (for example firing an event case)
s.set_value(valueName="Boolean", value=True, mechaction=True)
def stop_vi():
# there is a "Stop" button on LabVIEW. When setting it to True, LabVIEW VI will be stopped.
s.set_value("Stop", value=True)
# however, this button has a latch action and it is not supported on LV-Link
# (including "latch when pressed", "latch when released", "latch until released")
# set a stop button without latch action.
s.set_value("stop button without latch", value=True)
# in order to do the "button-click" functionally, we can use the mechaction with event case instead.
LabVIEW implementation
