Chapter 9: Communication

Style: Science Author: Wen Geng JunchiWords: 1877Update Time: 24/01/12 03:57:34
Li Rong received a call one day.

"Hello, are you Li Rong?"

Li Rong asked: "Who are you?"

"I'm Xinyuan."

Li Rong said: "Excuse me, what can I do?"

Xinyuan said: "Now we have to try to transfer the data from the embedded side to the computer side. Then, you continue to work on the embedded side, and our team continues to work on the computer side program."

There are many ways for the embedded terminal to transmit data to the computer terminal, including wired and wireless methods. The wired method can be through serial port, network cable, optical cable, and bus. Wireless methods can be through mobile phone modules, radio waves, short-distance transmission modules, Bluetooth, and infrared.

Each method has their advantages and disadvantages.

For example, long-distance data transmission can use mobile phone modules and radio stations, but in this case the data is transmitted to the public network. Using point-to-point communication, the speed is fast, but the transmission distance is short. Using a wired connection requires wiring and higher hardware costs. Using Bluetooth or infrared is cheaper, but the transmission distance is shorter.

Li Rong said, "Okay, then I'll go over and talk."

He took several circuit boards to the Water Conservancy Engineering Institute.

Li Rong said: "Each hydrological data is transferred to the computer for processing. What methods do you think can be used?"

Xinyuan said: "You can use mobile phone modules and radio stations."

Li Rong said: "Then let's try communicating."

Lirong first prepares sensors to detect parameters such as flow, pressure, temperature, etc., and at the same time transmits the data to the embedded terminal. The data is displayed on the display screen, and the embedded terminal then transmits the data to the computer through wired and wireless methods. You can compare the data on the display screen with the data on the computer to see if the transmission is correct.

Determine in what format the data should be transmitted, such as text, binary, JSON, etc. Choose the appropriate transmission protocol to ensure data is transmitted reliably.

To ensure the security of transmitted data, encryption algorithms can be used to encrypt data to prevent data leakage or tampering.

Determine the size of each packet to transfer data more efficiently. If the packet size is too large, it may cause transmission delays and network congestion. If the amount of data is large, you can consider compressing the data to reduce transmission time and bandwidth consumption.

Sensors are arranged along the river, and there are still a lot of them. Under normal circumstances, data is transmitted every 10 minutes, but in emergency situations, data is transmitted every few seconds. The amount of data is very large and needs to be processed on the embedded side first. Repeated data with no application value will be transmitted less or not at all. In an emergency, a large number of sensors transmit a large amount of data. At this time, it is necessary to consider the parallel processing of these data by the computer to prevent conflicts and packet loss.

When receiving data on the computer side, corresponding processing programs are needed to parse and process the received data to ensure the correctness and integrity of the data. Considering errors that may occur during data transmission, such as lost data packets, disconnection, etc., a reasonable error handling mechanism is required to retransmit the data if an error occurs. Determine the speed and frequency of data transfer based on actual needs and hardware limitations.

If there is a problem with the data, an alarm signal will be sent out, which can be displayed on the computer.

First debug the LAN to ensure that there is a stable network connection between the embedded terminal and the computer terminal. Data transmission can be achieved through wireless connections such as Wi-Fi.

First send data from the embedded terminal, and then view it on the computer through the serial port. The computer can receive the data, which means that data can be sent from the embedded terminal.

Then send data to the wireless module through the computer serial port, and the wireless module can send the data. This shows that the wireless module is also working normally. Then the data is sent to the wireless module through the embedded system and sent to the administrator computer.

Xinyuan said: "It's strange, the administrator's computer can't receive it at this time."

Li Rong said: "Oh. My agreement is wrong. Modify it and try again."

After Li Rong modified the agreement, he said, "Is the port open?"

Xinyuan said: "Oh. By the way, the port must be opened. I always forget this and forget that."

After several modifications, the embedded data can be transferred to the computer.

Li Rong said, "By the way, I'll show you something."

Li Rong took out two devices, which were smaller than mobile phones.

There are some buttons on it, and there is a picture engraved on hard acrylic, showing some of the main locations of Tengcheng and Tenghe. It is a thumbnail, not as precise as a map. However, it can be seen that Lirong has done a lot of research on the characteristics of the Tenghe River Basin. If sender A presses a position, receiver B can receive it. As the sender, B presses a position, and the receiver A can receive it.

Xinyuan couldn't help laughing. "What's the use of this?"

Li Rong laughed at himself, "It doesn't have much effect, that is, where are you on the Tengcheng river? Just let me know. Then I will reply to you and tell you where I am."

Xinyuan said: "Isn't it okay to use a mobile phone? Make a software on the mobile phone to send the location."

Li Rong said: "You said so, yes, you can also use mobile phone software. But if you all use mobile phones, don't you need to do other things?" He thought again, "These two are transmitting data one-to-one, no Via the mobile network.”

Xinyuan said: "Okay. In fact, the functions of many things are integrated into the mobile phone, such as remote controls, cameras, and readers."

Li Rong said: "Just think of this as a handicraft. I'll give it to you."

Xinyuan said: "Thank you."

In fact, from Xinyuan's point of view, he mainly made this thing for fun.

Xinyuan said: "What other weird things have you done?"

Li Rong said: "Let me think about it, use a remote control to control the light switch. Because when I sleep, I lie on the bed, but I can't reach the switch on the wall. So I made a remote control for the light."

Xinyuan said: "How to control it? You add a wireless controller and relay so that the light circuit can be turned on or off."

Li Rong said: "No. I put the seesaw-like wooden board, relay and controller next to the light switch. It was not installed in the wall. After receiving the signal, the wooden board pressed the switch and the light turned off."

Xinyuan said: "It's so troublesome. In fact, if the device is placed inside the switch, the wall will not look so messy."