Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCP Connection will auto close #3

Open
tosobright opened this issue Mar 29, 2019 · 2 comments
Open

TCP Connection will auto close #3

tosobright opened this issue Mar 29, 2019 · 2 comments

Comments

@tosobright
Copy link

Python Code:
from labview_automation import LabVIEW

vi_path = 'C:\Users\Administrator\Desktop\add.vi'
lv = LabVIEW()
lv.start() # Launches the active LabVIEW with the listener VI
with lv.client() as c:
control_values = {
"a": 2,
"b": 5
}
indicators = c.run_vi_synchronous(
vi_path, control_values)
print(indicators['c'])
#error_message = c.describe_error(indicators['Error Out'])
#lv.kill() # Stop LabVIEW

LVAutomation Listener:
[2019/3/29 9:17:52] (GUID - 5c9cad606465322594000008) Command received.

Message: {
"run_options" : 0,
"indicator_names" : [],
"control_values" : {
"a" : 2,
"b" : 5
},
"vi_path" : "C:\Users\Administrator\Desktop\add.vi",
"command" : "run_vi",
"open_frontpanel" : false
}
[2019/3/29 9:17:52] (GUID - 5c9cad606465322594000008) Command sent successfully.

Message: {
"c" : 7.0000000000,
"RunVIState_Status" : false,
"RunVIState_Code" : 0,
"RunVIState_Source" : ""
}
[2019/3/29 9:17:52] (TCP Connection-5c9cad606465322594000008) Lost

Python Shell:

lv.client().run_vi_synchronous(vi_path, control_values)

Traceback (most recent call last):
File "<pyshell#0>", line 1, in
lv.client().run_vi_synchronous(vi_path, control_values)
File "D:\Python\Python27\lib\site-packages\labview_automation\labview.py", line 175, in client
raise NotStartedError("You must start LabVIEW to get talk to it.")
NotStartedError: You must start LabVIEW to get talk to it.

@alexbhandari
Copy link

I was having this issue as well. By specifying 32bit with lv=LabVIEW(bitness='x86') I was able to keep the connection open long enough to run my VI. Does this work for you? It still does seem to auto close after code completes for me. Also you may need to be running both 32 bit labview and python for this to work smoothly. That's just a guess though since there doesn't seem to be much documentation on this that I can find.

@alexbhandari
Copy link

Did some more testing and I still have this issue actually, but only on the first run. When I run for the first time and the listener opens then it will close before running the command and throw this error. However, if I then run my script a second time leaving the listener window open from the first run, then it will run the command successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants