The first time in the raspberry pie on the simultaneous implementation of socket programming and serial programming _ programming

Source: Internet
Author: User
Tags sleep function server port

After the last realization of the RFID and Raspberry sent to the communication, today to try to transfer data from the RFID through the TCP/IP protocol to moxa and then transmitted to the cloud.

Since the two MOXA3121 and the other one have not been well understood (forget ... ) delivery mechanism, the Raspberry faction carries on the wireless transmission, in order to verify the usability of the program, simplifies the notebook as the cloud, uses the network cable to connect the raspberry Pie network mouth and the notebook's net mouth.

Although still in the process of debugging encountered difficulties, but before debugging the serial port experience, finally in the afternoon or basically realize the function.

It is to be noted that:

1, for TCP/IP protocol transmission, we must ensure that the server and client located in the same network segment

This, in the initial trial of the TCP debugging assistant, found that only using a network cable to connect the desktop and notebook network port does not implement the TCP debugging assistant communication. Thinking after the discovery, the desktop IP set to 192.168.127.222, and the IP of the notebook is 192.168.137.1, the two are not a network segment at all. After the desktop was changed to 137, the two moxa IP was changed to 192.168.137.252, 192.168.137.201. Successful implementation of the most basic communication.

2, the client's socket in the settings must use the server's IP and port ...

Socket programming in the server, the port needs to indicate that IP with inaddr_any (Let server monitor all IP). And the client needs to connect the information of the server port with the information of the IP and Client_socket. The client's port is specified by the computer itself.

Still need to do the work:

1, sleep function mechanism, why the parameter <1 time, too fast. Causing the raspberry pie to send and receive instructions in a reasonable way.

2, the real implementation of the remote transmission of data to Moxa

3, the program modular, increase the readability and introduction of the program

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.