1. Yesterday I did a serial data transfer for LabVIEW and Python, and today we will try the TCP data transfer.
2.Python Program Programming:
(1) First pass input command: sudo ifconfig, get the IP address of the machine, in program programming will use.
(2) programming as shown:
1) First set the IP address and port, the port can be customized, as long as the port number on both ends of the same;
2) Create a socket project, bind the address, listen, wait for the client connection, and for receiving the data from LabVIEW;
3) because the TCP receive control that facilitates LabVIEW determines the size of bytes to receive, the Raspberry Pi calculates the length of the returned data.
3.LabVIEW Programming:
(1) is the TCP receive block Diagram section of LabVIEW. The first accepted control is to determine the size of the received data, to receive a string, to convert the type. So the second receive control can dynamically know, this time how many bytes of data to receive, so as to avoid waiting time-out;
(2) Since there is a sending loop module and a receiving loop module, the method of stopping the loop is to synchronize with the notifier.
4. Program Run Results
(1) LabVIEW Operator Interface:
The destination address of TCP is consistent with the IP address of the Raspberry Pi, the port number is the constant value used by the 8888,labview, the front panel is invisible, the program block diagram sets the constant value.
(2) Python Runtime Interface:
In Send: 0012 indicates the subsequent data size is 12 bytes
TCP data transmission based on LabVIEW and Python