TCP data transmission based on LabVIEW and Python

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.