Example Code

Python LabVIEW TCP/IP socket communication

代码和文档

添加附件

 

Short example how to build LabVIEW and Python clients and servers.

 

LabVIEW server + Python client = control LabVIEW from Python

LabVIEW client + Python server = control Python from LabVIEW

 

Hope this is useful for someone. Have fun!

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect

NI社区“代码范例交流区”(Example Code Exchange)中的代码范例已获得MIT许可

评论
SoheylV
Member
Member
修改时间

Thank you very much for useful video and files. Could you please include the missing typedefs for the TCP Multiple Connections - Server.vi to make it more complete?

PrimaryKey
NI Employee (retired)
修改时间

I could include the typedefs but you can just disconnect them. I think that is faster and the code works the same. Sorry for not disconnecting them before puting them herehere.

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
AudreyZalar
Member
Member
修改时间

Where is the .ctl of the TCP Multiple Connections - Server?? The arrow button is broken, I can't run it. Please do help. Thank you in advance

PrimaryKey
NI Employee (retired)
修改时间

Fixed the CTL problem

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
n12iki
Member
Member
修改时间

Hi

I really enjoy using your program. I am getting a huge string before the data I need that looks like this \t\u0000\u0000\u0000\t\u0000\u0000\u0000\t. This is when I write it to a file. I am using the python client and labview server. I was wondering if you had an idea of how to remove this. I have tried .replace() in python but it didnt work. Thanks for putting this code up it helped out a lot

curosman
Member
Member
修改时间

Check this simple...socket programming in python

http://net-informations.com
Dharmiee
Member
Member
修改时间

Hi,

I'm trying to do this LabVIEW server + Python client = control LabVIEW from Python

--------------------------------------------------------------------------- TimeoutError Traceback (most recent call last) Cell In[17], line 6 4 client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 5 server_address = ('169.254.201.53', 8000) ----> 6 client.connect(server_address) 8 for x in range(100😞 9 size = struct.unpack('i', client.recv(1024))[0] # Extract the msg size from four bytes - mind the encoding


TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

the above is the error i received from the script