Data communication method and apparatus, and electronic device, storage medium and system

By introducing the communication scheduling layer in the business system, the data transmission is uniformly managed and data is sent according to the scheduling strategy, and the data transmission caused by the communication driver to occupy CPU resources is not timely, which improves the stability of the system.

WO2025020633A1PCT designated stage expired Publication Date: 2025-01-30CONTEMPORARY AMPEREX FUTURE ENERGY RES INST (SHANGHAI) LTD +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/092617
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-07-27
Filing Date
2024-05-11
Publication Date
2025-01-30

AI Technical Summary

Technical Problem

In a business system, because the communication driver occupies CPU resources when sending or receiving data, the data transmission of other modules is not timely, which may cause system instability.

Method used

By introducing the communication scheduling layer to uniformly manage the data transmission generated by the application, the communication data corresponding to the data block in the data block queue is sent to the target communication driver according to the scheduling strategy to reduce the situation of the communication driver to seize the CPU resources.

Benefits of technology

Improve the stability of data transmission, ensure the timely processing of communication data, and then improve the stability of system operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024092617_30012025_PF_FP_ABST
    Figure CN2024092617_30012025_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present application are a data communication method and apparatus, and an electronic device, a storage medium and a system. The method comprises: acquiring a data block of an application program, wherein the data block comprises communication data and communication driver information; after the data block is acquired, storing the data block in a data block queue; and according to a scheduling policy, sending, to a target communication driver corresponding to the communication driver information, the communication data corresponding to the data block in the data block queue. In the embodiments of the present application, uniform scheduling is performed on data which is generated by an application program and needs to be transmitted, such that the stability of data transmission is improved, thereby improving the stability of system operation.
Need to check novelty before this filing date? Find Prior Art

Description

Data communication method, device, electronic device, storage medium and system

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to Chinese patent application No. 202310936120.1, filed on July 27, 2023, entitled “Data Communication Method, Device, Electronic Device, Storage Medium and System,” and the entire contents of that application are incorporated herein by reference. Technical Field

[0003] The present application relates to the field of data processing technology, and in particular to a data communication method, device, electronic device, storage medium and system. Background Art

[0004] As business systems grow in size and performance requirements become increasingly stringent, the data volume and real-time requirements for communication between modules within the system are also increasing significantly. In traditional communication frameworks, the application layer of the business system caches the data to be transmitted, and then each communication driver sends it based on the busyness of its interface.

[0005] If a module generates a large amount of data, its corresponding communication driver will continuously seize CPU resources, resulting in data from other modules not being sent in a timely manner, which may lead to instability in the business system.

[0006] Summary of the Invention

[0007] The purpose of the embodiments of the present application is to provide a data communication method, device, electronic device, storage medium and system for uniformly scheduling data that needs to be transmitted by applications and improving the stability of the system.

[0008] In a first aspect, an embodiment of the present application provides a data communication method, comprising:

[0009] Acquire a data block of the application, wherein the data block includes communication data and communication driver information;

[0010] After obtaining the data block, the data block is stored in the data block queue;

[0011] According to the scheduling strategy, the communication data corresponding to the data block in the data block queue is sent to the target communication driver corresponding to the communication driver information.

[0012] The embodiment of the present application stores the data that needs to be transmitted generated by the application in the form of data blocks in a data block queue and performs unified scheduling. Compared with the existing solution, the application directly communicates data with the communication driver and the communication driver seizes CPU resources. The method of the embodiment of the present application uses a scheduling strategy to orderly send the communication data corresponding to the data blocks in the data block queue to the corresponding target communication driver, reducing the occurrence of the communication driver seizing CPU resources according to its own priority, so that the communication data can be processed in a timely manner, improving the stability of data transmission, and thereby improving the stability of system operation.

[0013] In any embodiment, when a data block is written into a data queue, the data block may be stored into a data queue of a corresponding priority according to the priority information.

[0014] The embodiment of the present application stores data blocks according to their priority information, so that data with high priority is processed first, and the data is processed in order, thereby improving the stability of the system.

[0015] In any embodiment, sending communication data corresponding to a data block in a data block queue to a target communication driver corresponding to the communication driver information according to a scheduling policy includes:

[0016] Based on the priority of the data queue, the data block to be processed is obtained from the data queue;

[0017] The communication data corresponding to the data block to be processed is sent to the target communication driver corresponding to the communication driver information.

[0018] The embodiment of the present application processes data blocks according to the priority of the data queue, so that data with high priority is processed first, thereby improving the orderliness of data processing and further improving the stability of system operation.

[0019] In any embodiment, sending the communication data corresponding to the data block to be processed to the target communication driver corresponding to the communication driver information includes:

[0020] If the working state of the target communication driver is idle, the communication data corresponding to the data block to be processed is sent to the target communication driver; and / or

[0021] If the target communication driver is in a busy state, the data block to be processed is put back into the original data queue, and the next data block to be processed is obtained from the data queue based on the priority of the data queue;

[0022] If the working state of the target communication driver corresponding to the next data block to be processed is an idle state, the communication data corresponding to the next data block to be processed is sent to the target communication driver corresponding to the next data block to be processed.

[0023] In the embodiment of the present application, whether to send communication data to the target communication driver is determined according to the busy / idle status of the target communication driver, thereby improving the success rate of communication data sending.

[0024] In any embodiment, sending the communication data corresponding to the data block to be processed to the target communication driver corresponding to the communication driver information includes:

[0025] The cumulative duration is calculated based on the duration of the data block sent in the data transmission time slot corresponding to the current moment and the estimated duration corresponding to the data block to be processed; wherein the data transmission time slot is a time period for sending data blocks obtained by pre-dividing time;

[0026] If the accumulated time length is less than the data sending time slot corresponding to the current moment, the communication data corresponding to the data block to be processed is sent to the target communication driver corresponding to the communication driver information.

[0027] The embodiment of the present application divides time in advance to obtain multiple time slots, and performs corresponding operations in different time slots, so that data that needs to be transmitted in a short period of time or continuous burst communication can be dispersed in multiple time slots for processing, thereby improving the stability of data transmission and further improving the stability of system operation.

[0028] In any embodiment, after sending the communication data corresponding to the data block to be processed to the target communication driver corresponding to the communication driver information, the method further includes:

[0029] Update the duration of the sent data based on the estimated sending duration.

[0030] In the embodiment of the present application, since the size of the data sending time slot is fixed, and the time required to send a communication data is not fixed, the cumulative duration of the sent data can be counted to facilitate the judgment of whether to end the data sending operation.

[0031] In any embodiment, the method further comprises:

[0032] Pre-set the time interval for interrupt triggering; the time interval is the time interval between two adjacent interrupts;

[0033] According to a preset division rule, the time gap is divided to obtain a plurality of sub-time slots, wherein different sub-slots are used to perform different data operations.

[0034] The embodiment of the present application divides time into multiple time slots by interruption, and divides each time slot into multiple sub-time slots, thereby stipulating that corresponding data operations are performed in different sub-time slots, reducing the impact of data transmission on task execution.

[0035] In any embodiment, the sub-time slots include: a data reception time slot, a data processing time slot, and a data transmission time slot.

[0036] In the embodiment of the present application, by performing data receiving operations in the data receiving time slot, processing data in the data processing time slot, and sending data in the data sending time slot, the impact of the data transmission process on task execution is reduced, and the stability of the data transmission process is improved.

[0037] In any embodiment, a guard period is set before and after the data receiving time slot, the data processing time slot, and the data sending time slot.

[0038] The embodiment of the present application reduces the risk of processing timeout by setting a protection time period.

[0039] In any embodiment, the method further comprises:

[0040] If the first data queue includes a target data block to be processed whose waiting time is greater than the preset waiting time, the target data block to be processed is migrated from the first data queue to the second data queue; the priority of the first data queue is lower than that of the second data queue.

[0041] The embodiment of the present application reduces the probability of data not being processed for a long time by increasing the priority of data blocks that have not been processed for a long time.

[0042] In any embodiment, the method further comprises:

[0043] Get the data to be received from the communication driver and send it to the corresponding application.

[0044] By sending the data obtained from the communication driver to the corresponding application, the embodiment of the present application reduces the impact on task execution compared to the existing solution that generates an interrupt as soon as there is data to receive data.

[0045] In a second aspect, an embodiment of the present application provides another data communication method, the method comprising:

[0046] Receive data blocks sent by the application layer, which include communication data and communication driver information;

[0047] Store the data block in the data block queue;

[0048] If the current moment is in the data sending time slot, obtain the data block to be processed from the data block queue, and send the communication data corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information according to the scheduling strategy; wherein, the data sending time slot is a time period for sending data blocks obtained by pre-dividing time.

[0049] The embodiments of the present application improve the stability of data transmission by uniformly scheduling the data that needs to be transmitted generated by the application, thereby improving the stability of system operation.

[0050] In a third aspect, an embodiment of the present application provides a data communication device, including:

[0051] A data block acquisition module is used to acquire the data block of the application, the data block including communication data and communication driver information;

[0052] A cache module, used to store data blocks in a data block queue;

[0053] The sending module is used to send the data block corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information according to the scheduling strategy.

[0054] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, and a bus, wherein:

[0055] The processor and memory communicate with each other through the bus;

[0056] The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the method of the first aspect or the second aspect.

[0057] In a fifth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium, comprising:

[0058] The non-transitory computer-readable storage medium stores computer instructions, which enable a computer to execute the method of the first aspect or the second aspect.

[0059] In a sixth aspect, an embodiment of the present application provides a data communication system, including an application layer, a communication scheduling layer, and a driver layer; wherein:

[0060] The application layer includes application programs, which are used to generate data blocks and send data blocks to the communication scheduling layer;

[0061] The communication scheduling layer is used to execute the method described in the first aspect;

[0062] The driver layer includes a communication driver, which is used to receive communication data sent by the communication scheduling layer and send the communication data.

[0063] In the embodiment of the present application, a communication scheduling layer is introduced into the data communication system, and the communication scheduling layer is responsible for the transmission of data generated by the application, thereby reducing the negative impact of the short-term transmission of multiple data on the system operation.

[0064] Other features and advantages of the present application will be described in the following description and, in part, will become apparent from the description or be understood by practicing the embodiments of the present application. The objectives and other advantages of the present application can be achieved and obtained through the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.

[0066] FIG1 is a flow chart of a data communication method provided in an embodiment of the present application;

[0067] FIG2 is a schematic diagram of a data queue structure provided in an embodiment of the present application;

[0068] FIG3 is a schematic diagram of a time gap provided in an embodiment of the present application;

[0069] FIG4 is a flow chart of a data transmission method provided in an embodiment of the present application;

[0070] FIG5 is a flow chart of another data communication method provided in an embodiment of the present application;

[0071] FIG6 is a schematic diagram of the structure of a data communication device provided in an embodiment of the present application;

[0072] FIG7 is a schematic diagram of the physical structure of an electronic device provided in an embodiment of the present application;

[0073] FIG8 is a schematic diagram of the structure of a data communication system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0074] The following embodiments of the technical solution of the present application will be described in detail with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present application and are therefore only examples and are not intended to limit the scope of protection of the present application.

[0075] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned figure descriptions are intended to cover non-exclusive inclusions.

[0076] In the description of the embodiments of this application, the technical terms "first" and "second" are used only to distinguish different objects and should not be understood to indicate or imply relative importance or implicitly specify the quantity, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, the meaning of "plurality" is more than two, unless otherwise clearly and specifically defined.

[0077] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0078] In the description of the embodiments of this application, the term "and / or" is simply a description of the association relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent the following three situations: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.

[0079] In the description of the embodiments of the present application, the term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).

[0080] In the description of the embodiments of the present application, unless otherwise expressly specified or limited, technical terms such as "installed," "connected," "connected," and "fixed" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integration; mechanical connections or electrical connections; direct connections or indirect connections through an intermediate medium; internal connections between two components or interactions between two components. Those skilled in the art can understand the specific meanings of the above terms in the embodiments of the present application based on specific circumstances.

[0081] Automation technology is becoming increasingly mature, and business systems are essential to every industry. These systems, however, perform different functions. As business systems grow in size and performance requirements increase, the data volume and real-time requirements for communication between modules within these systems also increase significantly. In traditional communication architectures, application software stores required data in a cache, such as a FIFO memory. Each communication driver then reads and sends data from the cache based on the availability of its interface. The same applies to receiving data. Typically, after receiving data from a terminal, the driver processes the data and sends it to the application.

[0082] Since each communication driver in the business system works on its own, that is, when a communication driver has data to send or receive, it will occupy CPU resources to send or receive data. While the communication driver is sending or receiving data, other communication drivers cannot transmit data. In the case where the communication driver has a large amount of data to send, other communication drivers need to wait. If the timeliness of the data that other communication drivers need to transmit is high, this data will not be transmitted in time, which may cause system failure. In addition, when receiving data, if there is a large amount of data in a short period of time, the existing solution will frequently generate interruptions, and the priority of the interruption is usually higher than the priority of the operating system task. Frequent interruptions to the application may occur, resulting in the inability to execute high real-time tasks in a timely manner, thereby affecting the stability of the business system.

[0083] To address the above technical issues, embodiments of the present application provide a data communication method, apparatus, electronic device, storage medium, and system. By uniformly scheduling data sent by applications, applications do not directly call communication drivers to send and receive data, thereby improving the stability of data transmission and, in turn, the stability of business system operations.

[0084] It is understood that the business system provided in the embodiments of the present application may specifically be an energy storage valve control system, or a system in other application fields, such as a power dispatching system, a smart grid system, an energy management system, a core banking system, an e-commerce platform, etc. The embodiments of the present application are described using the energy storage valve control system as a specific application scenario.

[0085] FIG1 is a flow chart of a data communication method provided by an embodiment of the present application. As shown in FIG1 , the method includes:

[0086] Step 101: Acquire a data block of an application program, the data block including communication data and communication driver information;

[0087] Step 102: storing the data block in the data block queue;

[0088] Step 103: sending the communication data corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information according to the scheduling policy.

[0089] In step 101, it is understood that the entity executing the method described in the embodiments of the present application may be a communication scheduling layer, that is, a communication scheduling layer set up in the business system; the communication scheduling layer is set up between the application and the communication driver, and is mainly used to manage and allocate communication resources. In other words, it uniformly manages the transmission of data generated by the application and uniformly manages the data received by the communication driver. The specific functions of the communication scheduling layer are described below. Of course, other functional modules can also be used to implement the methods of the embodiments of the present application. For ease of description, the following embodiments are described using the communication scheduling layer in the business system as the execution entity.

[0090] Data communication is required between multiple applications within the business system. Therefore, when an application needs to send communication data through the corresponding communication driver, it can assemble the generated communication data and the parameters related to the communication data to obtain a data block. Therefore, the data block can include communication data and communication driver information. Among them, communication data refers to data that needs to be sent through the communication driver. Communication driver information refers to information used to represent the communication driver, for example: it can be the name of the communication driver, the ID of the communication driver, etc. The purpose of adding communication driver information to the data block is to allow the communication scheduling layer to send the communication data to the corresponding communication driver.

[0091] In step 102, the data block queue is a first-in, first-out linear table. After receiving a data block, the communication scheduling layer can store the data block in the data block queue according to the time when the data block was sent by the application. It is understood that there can be one or more data block queues.

[0092] In step 103, the scheduling policy is used to determine the communication data transmission time corresponding to the data blocks in the data block queue. It can be pre-set based on actual conditions. The communication scheduling layer selects the data block to be transmitted from the data block queue based on the scheduling policy and sends the communication data contained in the selected data block to the designated target communication driver.

[0093] The embodiment of the present application stores the data that needs to be transmitted generated by the application in the form of data blocks in a data block queue and performs unified scheduling. Compared with the existing solution, the application directly communicates data with the communication driver and the communication driver seizes CPU resources. The method of the embodiment of the present application uses a scheduling strategy to orderly send the communication data corresponding to the data blocks in the data block queue to the corresponding target communication driver, reducing the occurrence of the communication driver seizing CPU resources according to its own priority, so that the communication data can be processed in a timely manner, improving the stability of data transmission, and thereby improving the stability of system operation.

[0094] Based on the above embodiment, when writing a data block into a data queue, the data block may be stored in a data queue of a corresponding priority according to priority information.

[0095] During the specific implementation process, the application can also specify the priority information of the data block when generating the data block. The priority information is used to determine the urgency with which the corresponding communication data needs to be sent. Priority information can include high priority, medium priority and low priority, where the higher the priority, the faster the corresponding communication data needs to be sent. It is understandable that the priority information can also include more or fewer levels of priority, which can be set in advance according to actual conditions. In addition, in addition to using high, medium and low to divide the priority information, other division methods can also be used, as long as different levels of priority can be distinguished. For example, numbers can be used for division, and different data represent different priorities. English letters can also be used for division, and similarly, different English letters represent different priorities.

[0096] It is understandable that the communication scheduling layer can set a corresponding number of data queues based on the priority information of the data block. For example, if the priority information includes high priority, medium priority, and low priority, the communication scheduling layer can set three data queues, namely, a high priority data queue, a medium priority data queue, and a low priority data queue. The communication scheduling layer stores the received high-priority data blocks in the high-priority data queue, stores the medium-priority data blocks in the medium-priority data queue, and stores the low-priority data blocks in the low-priority data queue. Figure 2 is a schematic diagram of a data queue structure provided in an embodiment of the present application, as shown in Figure 2.

[0097] The embodiment of the present application stores data blocks according to their priority information. The priority of a data block is positively correlated with the timeliness of the data block. When processing data, data in a high-priority data block queue is processed first, so that high-priority communication data can be processed in a timely manner, thereby improving the stability of the system.

[0098] In another embodiment, the communication scheduling layer can further set data queues based on the priority information of the data block and the communication driver. Specifically, for example, priority information includes high priority, medium priority, and low priority; and communication drivers include serial port communication drivers, network port communication drivers, and USB communication drivers. The communication scheduling layer can set a high-priority data queue, medium-priority data queue, and low-priority data queue corresponding to the serial port communication driver; a high-priority data queue, medium-priority data queue, and low-priority data queue corresponding to the network port communication driver; and a high-priority data queue, medium-priority data queue, and low-priority data queue corresponding to the USB communication driver.

[0099] In another embodiment, the communication scheduling layer may further set corresponding data queues based on the communication drivers. For example, the communication drivers include a serial communication driver, a network communication driver, and a USB communication driver. The communication scheduling layer may set a data queue corresponding to the serial communication driver, a data queue corresponding to the network communication driver, and a data queue corresponding to the USB communication driver.

[0100] On the basis of the above embodiment, sending the communication data corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information according to the scheduling strategy includes:

[0101] Based on the priority of the data queue, the data block to be processed is obtained from the data queue;

[0102] The communication data corresponding to the data block to be processed is sent to the target communication driver corresponding to the communication driver information.

[0103] In a specific implementation, the priority of a data queue corresponds to the priority information of the data blocks stored in that data queue. That is, high-priority data blocks are stored in the high-priority data queue, medium-priority data blocks are stored in the medium-priority data queue, and low-priority data blocks are stored in the low-priority data queue. The communication scheduling layer may preferentially select data blocks from the high-priority data queue. If the high-priority data queue is not empty, the data block may be obtained as the data block to be processed according to the first-in, first-out principle. If the high-priority data queue is empty, the data block is obtained from the medium-priority data queue, and so on.

[0104] After receiving the data block to be processed, the communication scheduling layer can parse the data block to obtain the communication data and communication driver information corresponding to the data block to be processed. The communication scheduling layer determines the target communication driver based on the communication driver information and sends the communication data to the target communication driver.

[0105] The embodiment of the present application processes data blocks according to the priority of the data queue. Since the higher the priority, the more time-sensitive the data is, the data with higher priority is processed first, thereby improving the orderliness of data processing and further improving the stability of system operation.

[0106] Based on the above embodiment, the communication scheduling layer sends the communication data corresponding to the data block to be processed to the target communication driver corresponding to the communication driver information, including at least one of the following situations:

[0107] (1) If the working state of the target communication driver is idle, the communication data corresponding to the data block to be processed is sent to the target communication driver.

[0108] In the specific implementation process, the working state of the communication driver includes idle state and busy state. The idle state means that the communication driver is not currently processing data transmission, and the busy state means that the communication driver is currently processing data transmission. When the communication driver is in the idle state, it can receive data to be processed. Therefore, after the communication scheduling layer obtains the data block to be processed from the data block queue, it parses the data block to obtain the corresponding communication driver information and communication data. Based on the communication driver information, it queries the working state of the corresponding target communication driver. If the working state is idle, the communication data obtained by parsing is sent to the target communication driver. After receiving the communication data, the target communication driver sends the communication data.

[0109] (2) If the target communication driver is in a busy state, the data block to be processed is put back into the original data queue, and the next data block to be processed is obtained from the data queue based on the priority of the data queue;

[0110] If the working state of the target communication driver corresponding to the next data block to be processed is an idle state, the communication data corresponding to the next data block to be processed is sent to the target communication driver corresponding to the next data block to be processed.

[0111] During the specific implementation process, the communication scheduling layer determines that the working state of the target communication driver is busy based on the communication driver information, which means that the target communication driver is currently processing other data and cannot process the communication data in the data block to be processed. In order to improve the success rate of communication data transmission and improve the efficiency of processing data blocks in the data queue, the communication scheduling layer puts the data block to be processed back into the original data queue. The original data queue refers to the data queue where the data block to be processed was located before it was taken out. For example, if the data block to be processed is obtained by the communication scheduling layer from a high-priority data queue, the data block to be processed is put back into the high-priority data queue. It can be understood that the data block to be processed can be placed at the end of the original data queue or at the head of the original data queue.

[0112] In the case where the data is placed at the tail and the original data queue is a high-priority data queue, the communication scheduling layer can re-acquire the next data block to be processed according to the scheduling strategy, that is, determine whether there are other data blocks in the high-priority data queue. It can be understood that other data blocks refer to data blocks other than the returned data blocks. If there are, the communication scheduling layer obtains the next data block to be processed from the head of the high-priority data queue. If there are no other data blocks in the high-priority data queue, the communication scheduling layer obtains the next data block to be processed from the head of the second-highest-priority data queue. According to the above process, it is determined whether the working state of the target communication driver corresponding to the next data block to be processed is idle. If it is idle, the communication data in the next data block to be processed is sent to the communication driver corresponding to the next data block to be processed. If the working state of the communication driver corresponding to the next data block to be processed is still busy, it is processed according to the method described in the above embodiment.

[0113] In the case where the data block is placed at the head and the original data queue is a high-priority data queue, the communication scheduling layer can re-acquire the next data block to be processed according to the scheduling strategy, that is, determine whether there are other data blocks in the high-priority data queue. It can be understood that other data blocks refer to data blocks other than the returned data blocks. If there are, the communication scheduling layer obtains the next data block to be processed from the head of the high-priority data queue except for the returned data blocks. If there are no other data blocks in the high-priority data queue, the communication scheduling layer obtains the next data block to be processed from the head of the second-highest-priority data queue. According to the above process, it is determined whether the working state of the target communication driver corresponding to the next data block to be processed is idle. If it is idle, the communication data in the next data block to be processed is sent to the communication driver corresponding to the next data block to be processed. If the working state of the communication driver corresponding to the next data block to be processed is still busy, it is processed according to the method described in the above embodiment.

[0114] In an embodiment of the present application, whether to send communication data to the target communication driver is determined based on the busy or idle status of the target communication driver, so that for a communication driver in a busy state, communication data is temporarily not sent to it. On the one hand, the load on the communication driver is reduced, and on the other hand, the idle communication driver can receive the data to be processed as soon as possible, making the load on the communication driver more evenly distributed and improving the success rate of communication data transmission.

[0115] On the basis of the above embodiment, sending the communication data corresponding to the data block to be processed to the target communication driver corresponding to the communication driver information includes:

[0116] Counting the cumulative duration of data blocks sent in the data sending time slot corresponding to the current moment; wherein the data sending time slot is a time period for sending data blocks obtained by pre-dividing time;

[0117] If the accumulated duration is less than the data sending time slot corresponding to the current moment, the communication scheduling layer sends the communication data corresponding to the data block to be processed to the target communication driver corresponding to the communication driver information.

[0118] In the specific implementation process, Figure 3 is a schematic diagram of a time gap provided by an embodiment of the present application, as shown in Figure 3. In order to improve the stability of system operation, time can be divided in advance to obtain multiple time gaps, each of which has a corresponding action processing time. For example, a time gap can include a data reception time gap, a data processing time gap, and a data transmission time gap. In other words, a time gap can be divided to obtain a time period for data reception, a time period for data processing, and a time period for data transmission. It is understandable that the time gap division can use microsecond-level time intervals, generated by a high-precision device (such as an FPGA). The time gap can be 50 microseconds, and the FPGA generates an interrupt every 50 microseconds. It should be noted that the specific length of the time gap and the division of the time gap can be set according to actual conditions. For example, a 50-microsecond time gap can be divided into 0-15 microseconds for data reception time gap, 16-30 microseconds for data processing time gap, and 31-50 microseconds for data transmission time gap.

[0119] Regarding the data transmission time slot, which is used for data transmission, the communication scheduling layer obtains the pending data block from the data queue and calculates the cumulative duration, i.e., the sum of the duration of the data block sent in the data transmission time slot corresponding to the current moment and the estimated duration required to send the communication data corresponding to the pending data block. The estimated duration can be estimated by the application based on the size of the communication data and the data transmission rate of the corresponding communication driver. If the cumulative duration is less than the data transmission time slot corresponding to the current moment, it means that the communication data corresponding to the pending data block can be sent out within the data transmission time slot. Therefore, the communication scheduling layer sends the communication data corresponding to the pending data block to the corresponding target communication driver.

[0120] If the accumulated duration is greater than or equal to the data transmission time slot corresponding to the current moment, it means that the communication data cannot be completely sent out within the data transmission time slot, so the data transmission operation is terminated.

[0121] It is understood that, to reduce the impact of data processing timeouts, guard periods can be set before and after each data operation time slot. It is understood that these guard periods are also counted within the time slot. That is, the sum of all guard periods and the time slot corresponding to each data operation constitutes one time slot. For example, if a time slot is 50 microseconds and the guard period is set to 5 microseconds, there are four guard periods in one time slot: the data reception time slot, the data processing time slot, and the data transmission time slot are all 10 microseconds. It should be noted that the specific lengths of the guard periods and the time slots for each data operation can be pre-set.

[0122] In the embodiment of the present application, data receiving operations are performed in the data receiving time slot, data processing is performed in the data processing time slot, and data is sent in the data sending time slot, thereby reducing the impact of the data transmission process on task execution and improving the stability of the data transmission process. Figure 4 is a flow chart of a data transmission method provided in an embodiment of the present application. As shown in Figure 4, the method includes:

[0123] Step 301: Take out the data block to be processed from the data queue; the communication scheduling layer selects the data queue for obtaining the data block to be processed according to the priority, and obtains the data block to be processed from the data queue according to the first-in-first-out principle in the selected data queue.

[0124] Step 302: Query the operating status of the communication driver corresponding to the data block to be processed. After obtaining the data block to be processed, the communication scheduling layer parses the data block to obtain the communication data, communication driver information, and estimated duration contained in the data block. Communication data is data that needs to be sent to the communication driver and is sent by the communication driver. Communication driver information is information that indicates the communication driver to receive the communication data. The communication scheduling layer uses this information to determine the target communication driver. The estimated duration is the time required for the application to successfully send the communication data, calculated based on the communication data and the target communication driver. After determining the target communication driver, the communication scheduling layer can query the target communication driver's operating status, which can be either idle or busy.

[0125] Step 303: Determine whether the working status is busy; if the working status is busy, execute step 304; otherwise, execute step 305.

[0126] Step 304: Put it back into the original data queue; the communication scheduling layer puts the data block to be processed back into the original data queue. For the specific operation method, please refer to the above embodiment.

[0127] Step 305: Accumulate the time based on the estimated time in the data block to be processed and the time required for the sent data; the communication scheduling layer accumulates the estimated time of the data block to be processed and the time required for the sent data to obtain the cumulative time.

[0128] Step 306: Determine whether the data transmission time slot threshold is reached; determine whether the accumulated time length is less than the data transmission time slot threshold. If so, send the communication data in the data block to be processed to the corresponding target communication data and continue to execute step 301; if not, end the data transmission action.

[0129] The embodiment of the present application divides time in advance to obtain multiple time slots, and performs corresponding operations in different time slots, so that data that needs to be transmitted in a short period of time or continuous burst communication can be dispersed in multiple time slots for processing, thereby improving the stability of data transmission and further improving the stability of system operation.

[0130] Based on the above embodiment, after sending the communication data in the data block to be processed to the target communication driver corresponding to the communication driver information, the method further includes:

[0131] Update the duration of the sent data based on the estimated sending duration.

[0132] In a specific implementation, after the communication scheduling layer sends the communication data in the pending data block to the target communication driver, it adds the estimated transmission duration to the duration of the sent data to obtain the new duration of the sent data. It should be understood that the duration of the sent data before the accumulation refers to the duration required to send the communication data in the pending data block before sending it to the target communication driver.

[0133] In the embodiment of the present application, since the size of the data sending time slot is fixed, and the time required to send a communication data is not fixed, the cumulative duration of the sent data can be counted to facilitate the judgment of whether to end the data sending operation.

[0134] Based on the above embodiment, the method further includes:

[0135] If the first data queue includes a target data block to be processed whose waiting time is greater than the preset waiting time, the target data block to be processed is migrated from the first data queue to the second data queue; the priority of the first data queue is lower than that of the second data queue.

[0136] In the specific implementation process, since the communication scheduling layer takes the data blocks to be processed from the queue according to certain rules, for example, the data queue is selected according to the priority, and the data blocks to be processed are determined by the "first in, first out" rule. In this case, if high-priority data blocks appear frequently, there may be data blocks in the low-priority data queue that are not processed for a long time. In order to solve this problem, the embodiment of the present application upgrades the priority of the data blocks that have not been processed for a long time. Specifically, the communication scheduling layer can time the data blocks stored in the data queue and obtain the waiting time of each data block. When a data queue (referred to as the first data queue in the embodiment of the present application) has a waiting time greater than the preset waiting time, which is referred to as the target data block to be processed, the target data block to be processed is migrated from the first data queue to the second data queue. It should be noted that the priority of the first data queue is lower than that of the second data queue. For example, the first data queue can be a low-priority data queue, and the second data queue can be a medium-priority data queue or a high-priority data queue.

[0137] The embodiment of the present application reduces the probability of data not being processed for a long time by increasing the priority of data blocks that have not been processed for a long time.

[0138] Based on the above embodiment, the method further includes:

[0139] The data to be received is obtained from the communication driver, and the data to be received is sent to the corresponding application program.

[0140] In a specific implementation, during data reception, the communication scheduling layer may query each communication driver to determine whether there is data to be received. If a communication driver has data to be received, the communication scheduling layer retrieves the data and sends it to the corresponding application. It is understood that the communication scheduling layer may query each communication driver at a preset time interval.

[0141] To improve the stability of system operation, the system pre-divides time into multiple time slots, each containing a corresponding action processing time. For example, a time slot can include a data reception slot, a data processing slot, and a data transmission slot. In other words, a time slot can be divided into time periods for data reception, data processing, and data transmission. It is understood that the time slots can be divided using microsecond-level time intervals, generated by a high-precision device (e.g., an FPGA). A time slot can be 50 microseconds, with the FPGA generating an interrupt every 50 microseconds. It should be noted that the specific length of the time slots and how they are divided can be set based on actual circumstances. For example, a 50-microsecond time slot can be divided into a data reception slot of 0-15 microseconds, a data processing slot of 16-30 microseconds, and a data transmission slot of 31-50 microseconds.

[0142] For the data receiving time slot, the communication scheduling layer polls each communication driver to obtain the data to be received.

[0143] The embodiment of the present application periodically receives data through the communication scheduling layer and sends the received data to the corresponding application. Compared with the existing solution that generates an interrupt as soon as there is data to receive data, the embodiment of the present application reduces the impact on task execution.

[0144] FIG5 is a flow chart of another data communication method provided in an embodiment of the present application. As shown in FIG5 , the method includes:

[0145] Step 401: The communication scheduling layer receives a data block sent by the application layer. The data block includes communication data and communication driver information. It is understandable that the data block may also include other information, such as the size of the communication data, estimated transmission time, priority information, etc.

[0146] Step 402: The communication scheduling layer stores the data block in a data block queue. For a single data block queue, the data block is stored at the end of the data queue. For multiple data queues with different priorities, the data block is stored in a data queue with a corresponding priority based on the priority information of the data block.

[0147] Step 403: If the current time is within a data transmission time slot, the communication scheduling layer retrieves the pending data block from the data block queue and, based on the scheduling policy, sends the communication data corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information. The data transmission time slot is a pre-divided time period for transmitting data blocks. It is understood that the scheduling policy can be found in the above-described embodiment and will not be further described here.

[0148] The embodiment of the present application uniformly schedules the data that needs to be transmitted generated by the application through the communication scheduling layer, thereby improving the stability of data transmission and further improving the stability of system operation.

[0149] Figure 6 is a schematic diagram of the structure of a data communication device provided in an embodiment of the present application. The device can be a module, program segment, or code on an electronic device. It should be understood that the device corresponds to the method embodiment of Figure 1 above and can perform each step involved in the method embodiment of Figure 1. The specific functions of the device can be found in the description above. To avoid repetition, detailed description is appropriately omitted here. The device includes: a data block acquisition module 501, a cache module 502, and a sending module 503, wherein:

[0150] The data block acquisition module 501 is used to acquire the data block of the application, the data block including communication data and communication driver information;

[0151] The cache module 502 is used to store data blocks in a data block queue;

[0152] The sending module 503 is used to send the data block corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information according to the scheduling policy.

[0153] Based on the above embodiment, the cache module 502 is specifically configured to:

[0154] The data block is stored in a data queue of corresponding priority according to the priority information.

[0155] Based on the above embodiment, the sending module 503 is specifically configured to:

[0156] Retrieving the to-be-processed data block from the data queue based on the priority of the data queue;

[0157] The communication data corresponding to the data block to be processed is sent to a target communication driver corresponding to the communication driver information.

[0158] Based on the above embodiment, the sending module 503 is specifically configured to:

[0159] If the working state of the target communication driver is an idle state, sending the communication data corresponding to the data block to be processed to the target communication driver; and / or

[0160] If the working state of the target communication driver is busy, the data block to be processed is put back into the original data queue, and based on the priority of the data queue, the next data block to be processed is obtained from the data queue;

[0161] If the working state of the target communication driver corresponding to the next data block to be processed is an idle state, the communication data corresponding to the next data block to be processed is sent to the target communication driver corresponding to the next data block to be processed.

[0162] Based on the above embodiment, the sending module 503 is specifically configured to:

[0163] Calculating the cumulative duration based on the duration of the data block sent in the data sending time slot corresponding to the current moment and the estimated duration corresponding to the data block to be processed; wherein the data sending time slot is a time period for sending data blocks obtained by pre-dividing time;

[0164] If the accumulated time length is less than the data sending time slot corresponding to the current moment, the communication data corresponding to the data block to be processed is sent to the target communication driver corresponding to the communication driver information.

[0165] Based on the above embodiment, the device further includes an updating module, which is used to:

[0166] The duration of the sent data is updated according to the estimated sending duration.

[0167] Based on the above embodiment, the device further includes a time slot division module, which is used to:

[0168] Preset the time interval for interrupt triggering; the time interval is the time interval between two adjacent interrupts;

[0169] The time gap is divided according to a preset division rule to obtain a plurality of sub-time slots, wherein different sub-time slots are used to perform different data operations.

[0170] Based on the above embodiment, the sub-time slots include: a data receiving time slot, a data processing time slot and a data sending time slot.

[0171] Based on the above embodiment, protection time periods are set before and after the data receiving time slot, the data processing time slot and the data sending time slot.

[0172] Based on the above embodiment, the device further includes a migration module, which is used to:

[0173] If the first data queue includes a target data block to be processed whose waiting time is greater than the preset waiting time, the target data block to be processed is migrated from the first data queue to the second data queue; the priority of the first data queue is lower than that of the second data queue.

[0174] Based on the above embodiment, the device further includes a data receiving module, which is used to:

[0175] Acquire the data to be received from the communication driver, and send the data to be received to the corresponding application.

[0176] FIG7 is a schematic diagram of the physical structure of an electronic device provided in an embodiment of the present application. As shown in FIG7 , the electronic device includes: a processor 601, a memory 602, and a bus 603; wherein,

[0177] The processor 601 and the memory 602 communicate with each other via the bus 603;

[0178] The processor 601 is used to call the program instructions in the memory 602 to execute the methods provided by the above-mentioned method embodiments, for example, including: obtaining a data block of an application, the data block including communication data and communication driver information; storing the data block in a data block queue; and sending the communication data corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information according to a scheduling strategy.

[0179] The processor 601 can be an integrated circuit chip with signal processing capabilities. The above-mentioned processor 601 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.

[0180] The memory 602 may include but is not limited to random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0181] This embodiment discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the methods provided by the above-mentioned method embodiments, for example, including: obtaining a data block of an application, the data block including communication data and communication driver information; storing the data block in a data block queue; and sending the communication data corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information according to a scheduling strategy.

[0182] This embodiment provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions enable the computer to execute the methods provided by the above-mentioned method embodiments, for example, including: obtaining a data block of an application, the data block including communication data and communication driver information; storing the data block in a data block queue; and sending the communication data corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information according to a scheduling strategy.

[0183] FIG8 is a schematic diagram of the structure of a data communication system provided in an embodiment of the present application. As shown in FIG8 , the system includes an application layer, a communication scheduling layer, and a driver layer.

[0184] The application layer includes application programs, which are used to generate data blocks and send data blocks to the communication scheduling layer;

[0185] The communication scheduling layer primarily implements time slot management, data block management, and communication decision-making. Time slot management enables the communication scheduling layer to execute actions within corresponding time slots. Data block management receives and caches data blocks sent by the application layer. Communication decision-making allows the communication scheduling layer to retrieve pending data blocks from the data queue according to specific rules and send the communication data in the pending data blocks to the corresponding target communication driver.

[0186] The driver layer includes a communication driver, which is used to receive communication data sent by the communication scheduling layer and transmit the communication data. It is understood that communication drivers include but are not limited to: Ethernet drivers, serial port drivers, low-voltage differential signaling (LVDS) communication drivers, serial peripheral interface (SPI) communication drivers, and USB communication drivers.

[0187] In the embodiment of the present application, a communication scheduling layer is introduced into the data communication system, and the communication scheduling layer is responsible for the transmission of data generated by the application, thereby reducing the negative impact of the short-term transmission of multiple data on the system operation.

[0188] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interface, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0189] In addition, the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0190] Furthermore, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0191] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any actual relationship or order between these entities or operations.

[0192] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, various modifications and variations of the present application are possible. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A data communication method, comprising: Acquire a data block of an application, wherein the data block includes communication data and communication driver information; Storing the data block in a data block queue; The communication data corresponding to the data block in the data block queue is sent to a target communication driver corresponding to the communication driver information according to a scheduling strategy.

2. The method according to claim 1, wherein: The step of storing the data block in a data block queue comprises: The data block is stored in a data queue corresponding to the priority level according to the priority information.

3. The method according to claim 2, wherein: The sending the communication data corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information according to the scheduling strategy includes: Based on the priority of the data queue, obtaining a to-be-processed data block from the data queue; The communication data corresponding to the to-be-processed data block is sent to a target communication driver corresponding to the communication driver information.

4. The method according to claim 3, wherein: The sending the communication data corresponding to the to-be-processed data block to the target communication driver corresponding to the communication driver information includes: If the working state of the target communication driver is an idle state, sending the communication data corresponding to the to-be-processed data block to the target communication driver; and / or If the working state of the target communication driver is busy, the to-be-processed data block is put back into the original data queue, and based on the priority of the data queue, the next to-be-processed data block is obtained from the data queue; If the working state of the target communication driver corresponding to the next data block to be processed is an idle state, the communication data corresponding to the next data block to be processed is sent to the target communication driver corresponding to the next data block to be processed.

5. The method according to claim 3, wherein: The sending the communication data corresponding to the to-be-processed data block to the target communication driver corresponding to the communication driver information includes: The cumulative duration is calculated according to the duration of the data block sent in the data sending time slot corresponding to the current moment and the estimated sending duration corresponding to the data block to be processed; wherein the data sending time slot is a time period for sending data blocks obtained by dividing the time in advance; If the accumulated time length is less than the data sending time slot corresponding to the current moment, the communication data corresponding to the to-be-processed data block is sent to the target communication driver corresponding to the communication driver information.

6. The method according to claim 5, wherein: After sending the communication data corresponding to the to-be-processed data block to the target communication driver corresponding to the communication driver information, the method further includes: The duration of the sent data is updated according to the estimated sending duration.

7. The method according to claim 5 or 6, wherein: The method further comprises: Preset the time interval for interrupt triggering; the time interval is the time interval between two adjacent interrupts; The time gap is divided according to a preset division rule to obtain a plurality of sub-time slots, wherein different sub-time slots are used to perform different data operations.

8. The method according to claim 7, wherein: The sub-time slots include: a data receiving time slot, a data processing time slot and a data sending time slot.

9. The method according to claim 8, wherein: A protection time period is set before and after the data receiving time slot, the data processing time slot and the data sending time slot.

10. The method according to any one of claims 2 to 9, wherein: The method further comprises: If the first data queue includes a target data block to be processed whose waiting time is greater than a preset waiting time, the target data block to be processed is migrated from the first data queue to the second data queue; the priority of the first data queue is lower than that of the second data queue.

11. The method according to any one of claims 1 to 10, wherein: The method further comprises: The data to be received is obtained from the communication driver, and the data to be received is sent to the corresponding application program.

12. A data communication method, wherein: The method comprises: Receiving a data block sent by the application layer, wherein the data block includes communication data and communication drive information; Storing the data block in a data block queue; If the current moment is in a data sending time slot, obtain the data block to be processed from the data block queue, and send the communication data corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information according to the scheduling strategy; wherein the data sending time slot is a time period for sending data blocks obtained by dividing the time in advance.

13. A data communication device, wherein: include: A data block acquisition module, used to acquire a data block of an application, wherein the data block includes communication data and communication drive information; A cache module, used for storing the data block in a data block queue; The sending module is used to send the data block corresponding to the data block in the data block queue to the target communication driver corresponding to the communication driver information according to the scheduling strategy.

14. An electronic device, wherein: include: processor, memory and bus, wherein, The processor and the memory communicate with each other via the bus; The memory stores program instructions executable by the processor, and the processor can execute the method according to any one of claims 1 to 12 by calling the program instructions.

15. A non-transitory computer-readable storage medium, wherein: The non-transitory computer-readable storage medium stores computer instructions, which, when executed by a computer, cause the computer to perform the method according to any one of claims 1 to 12.

16. A data communication system, wherein: It includes application layer, communication scheduling layer and driver layer; among which: The application layer includes an application program, and the application program is used to generate a data block and send the data block to the communication scheduling layer; The communication scheduling layer is used to execute the method according to any one of claims 1 to 9; The driver layer includes a communication driver, and the communication driver is used to receive communication data sent by the communication scheduling layer and send the communication data.

Citation Information

Patent Citations

  • Method for transmitting streaming data and data transmitting device

    CN110121114A

  • Method and device for controlling data transmission and medium

    CN114285804A

  • Cloud computing resource calling method and device, electronic equipment and storage medium

    CN115934323A

  • Universal RDMA (Remote Direct Memory Access) flow-level priority scheduling method, device, equipment and medium

    CN116436869A

  • Electronic device and data transfer method thereof

    US20180121268A1