Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the two ways for ServerSuperIO to continuously transmit large chunks of data

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

What are the knowledge points of this article "what are the two ways for ServerSuperIO to continuously transmit large chunks of data flow?" most people do not understand, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article "what are the two ways for ServerSuperIO to continuously transmit chunks of data flow?"

10. Overview of two ways to continuously transmit large data streams (such as files) 10.1

With the current situation of the Internet of things or the understanding of the Internet of things, especially the industrial Internet of things, we must have the ability to integrate a variety of data sources. Data sources can be divided into two categories: hardware generation and software generation. As shown below:

Based on the reality, as a framework of the Internet of things, it must have the ability to integrate all kinds of data, as well as a variety of application scenarios. Take the data size as an example, it is possible to receive data within the range of cache carrying capacity at one time and beyond the scope of cache carrying capacity at one time, as long as the network allows. Previous serial articles are based on small data packets, and this article introduces the transmission mode of large data streams.

10.2 two modes of transmission of large data streams 10.2.1 protocol packets

This method defines the beginning and end of the packet protocol, decomposes a large block of data into small packets of a certain length, and transmits data in batches in a combination of protocol header, small data packet and protocol tail. After receiving the data of each batch, check the data, assemble the data, and restore the complete data. The schematic diagram is as follows:

There are several problems with this approach:

(1) when there is a problem with the data of each package, the data should be reissued. It is necessary to design a good agreement and complete the reissue mechanism.

(2) there are a variety of data sources, such as compressed files, serialized files, encrypted files, etc., so that the data of each small packet may be consistent with the protocol header or tail, or even consistent with the CRC check, resulting in the data can not be properly checked and parsed. In this case, the reissued data may be a high probability event.

To choose this way of transmitting large blocks of data flow, we should choose according to the actual situation of the site, avoid possible risks and improve the overall stability of the project and products.

If you choose this way, then according to the previous article, it can be realized, and netizens can do it on their own. This article mainly introduces the following ways.

10.2.2 request length, confirmation method

The client first sends a command requesting to send data, and identifies the length of the data to be sent this time in the command. If the server receives the request command, it judges whether the request data length is within the allowable range, and then returns the same command data or other confirmation data to the client to identify whether the data information of this length is allowed to be sent. If it can be sent, the client continues to send the data stream, and the server continues to receive it. The schematic diagram is as follows:

For this way of data transmission, ServerSuperIO provides a special interface. The following is a detailed introduction.

10.3 to achieve continuous transmission of large blocks of data 10.3.1 Design request to send data protocol

Request to send 0x62 instruction, a total of 10 bytes, checksum is the sum starting from the "slave address", excluding "Datagram", "checksum" and "protocol end".

The request instruction data frame is as follows:

After receiving the request command, the server returns the same command information to the client, and the client enters the state of continuously sending data.

10.3.2 client code implementation

Send the request data command first, the code is as follows:

+ View Code

After receiving the confirmation message from the server, the code to send the data persistently is as follows:

+ View Code

10.3.3 implementation of ServerSuperIO framework and matters needing attention

There is basically nothing to talk about about the code implementation on the client side, mainly on how to implement it in a device-driven way based on the ServerSuperIO framework. Note: the following automatic control mode is implemented.

1. Implementation of Protocol Interface

The DeviceProtocol:ProtocolDriver API has a GetPackageLength (byte [] data, IChannel channel, ref int readTimeout) function interface. The data parameter is the command that requests to send data, the channel parameter is the instance of the current IO channel, and readTimeout is the time it takes to customize the length of the received data returned. If the return value is 0, you will not enter the task of receiving data continuously. You can return confirmation information directly through the parameter channel. The specific code is as follows:

+ View Code

two。 Implementation of Protocol Command

In order to deal with large chunks of data, a protocol command is added to parse and save the data. The code is as follows:

+ View Code

3. The device driver calls the protocol and drives the protocol commands

When receiving a large data stream, all data information will be returned to the Communicate interface of the device driver, where the Data of the info parameter is the current command to request data, and BigData is the information that continuously receives the data, and drives the protocol command DeviceFileCommand by calling the this.Protocol.DriverAnalysis protocol interface. The specific code is as follows:

+ View Code

4. Considerations for host program service instance configuration

StartCheckPackageLength = true is mainly configured in the configuration parameters, and the protocol interface GetPackageLength of the corresponding device driver is detected in the process of receiving data.

+ View Code

10.4 running effect

Picture

The above is the content of this article on "what are the two ways for ServerSuperIO to continuously transmit large data streams". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report