A method, apparatus, storage medium, and electronic device for real-time network data transmission
Patent Information
- Application Number
- CN202410151730.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-02
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2044-02-02
AI Technical Summary
[0004]但是,由于存在通信抖动使得通信延迟不可预测,降低了通信的准确性和可靠性
[0040]本说明书实施例中通过主站中所包含的协议层生成预设指令后,将预设指令发送给系统抽象层所包含的预设内核中,以通过预设内核,调用预设的生成任务函数,来生成针对预设指令的实时任务,以及调用预设的时钟创建函数创建针对实时任务的实时定时器,并在通过实时定时器检测到到达实时任务的执行时间时,将预设指令发送到主站所包含的驱动层中,通过驱动层中预先加载的实时网络驱动,将预设指令发送给从站,以使从站根据接收到的预设指令来执行任务。
Smart Images

Figure CN117880384B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the fields of communications and computer technology, and in particular to a real-time network data transmission method, apparatus, storage medium, and electronic device. Background Technology
[0002] In the field of automation, a real-time Ethernet communication protocol (Ethernet for Control Automation Technology, EtherCAT) can be used to achieve precise control of robots. This communication protocol is a high-performance Ethernet protocol used in real-time control and automation.
[0003] When using the EtherCAT communication protocol to communicate between the robot controller and each actuator, the robot controller acts as the master station in the EtherCAT communication protocol, and each actuator acts as the slave station. Thus, the master station sends instructions to each slave station through the EtherCAT communication protocol.
[0004] However, communication jitter makes communication delays unpredictable, reducing the accuracy and reliability of communication. Furthermore, the general-purpose Linux network card driver used in the EtherCAT communication protocol has inherent latency, which cannot meet the high real-time performance requirements of actual production.
[0005] Therefore, how to optimize the real-time performance of general-purpose Linux network card drivers and reduce communication jitter is a technical problem that urgently needs to be solved. Summary of the Invention
[0006] This specification provides a real-time network data transmission method, apparatus, and electronic device to partially solve the problems existing in the prior art.
[0007] The embodiments in this specification adopt the following technical solutions:
[0008] This specification provides a real-time network data transmission method, which is applied to a master station. The master station includes a protocol layer, a system abstraction layer, and a driver layer. The driver layer includes a pre-loaded real-time network driver, comprising:
[0009] Preset instructions are generated through the protocol layer;
[0010] The preset instruction is sent to the preset kernel contained in the system abstraction layer, so that the preset kernel can call the preset task generation function to generate a real-time task for the preset instruction, and call the preset clock creation function to create a real-time timer for the real-time task. When the real-time timer detects that the execution time of the real-time task has arrived, the preset instruction is sent to the driver layer.
[0011] The preset instructions are sent to the slave station through the real-time network driver loaded in the driver layer, so that the slave station can execute tasks according to the received preset instructions.
[0012] Optionally, the pre-loaded real-time network driver specifically includes:
[0013] Obtain the installation script for the real-time network driver;
[0014] Run the installation script to create a real-time network card driver module. Through the real-time network card driver module, set the address of the network interface card used by the real-time network driver to be configured to the address of the network interface card used by the general network driver, and modify the driver name of the general network driver used by the driver layer to the driver name of the real-time network driver to be configured, so as to complete the loading of the real-time network driver.
[0015] Optionally, the preset instructions are sent to the slave station through the real-time network driver loaded in the driver layer, specifically including:
[0016] The preset instruction is sent to the real-time media access control module set after loading the real-time network driver in the driver layer, so that the real-time media access control module sets the sending time of the preset instruction according to the waiting time when sending the previous instruction, wherein the waiting time is used to represent the time interval between the driver layer sending the previous and next instructions.
[0017] Based on the sending time, the preset instruction is sent to the slave station through the real-time driver module set after loading the real-time network driver in the driver layer.
[0018] Optionally, the driver layer includes a send buffer;
[0019] Before sending the preset instructions to the slave station via the real-time network driver loaded in the driver layer, the method further includes:
[0020] The preset instruction is stored in the send buffer;
[0021] The preset instructions are sent to the slave station through the real-time network driver loaded in the driver layer, specifically including:
[0022] The preset instruction stored in the transmit buffer is sent to the slave station, wherein the data stored in the transmit buffer is sent to the slave station according to the first-in, first-out principle.
[0023] Optionally, the driver layer includes a send index buffer, a receive buffer, and a receive index buffer;
[0024] The method further includes:
[0025] The index value corresponding to the preset instruction is stored in the sending index buffer;
[0026] The method further includes:
[0027] Receive the response data returned by the slave station in response to the preset command;
[0028] The response data is stored in the receiving buffer, and the index value corresponding to the response data is stored in the receiving index buffer;
[0029] If it is determined that there exists an index value in the sending index buffer that matches the index value corresponding to the response data stored in the receiving index buffer, then the response data stored in the receiving buffer is sent to the preset kernel contained in the system abstraction layer, so that the response data can be processed by the preset kernel.
[0030] Optionally, the preset kernel includes a real-time kernel, which includes the Xenomai kernel of the real-time subsystem.
[0031] Optionally, sending the preset instructions to the preset kernel contained in the system abstraction layer specifically includes:
[0032] If it is determined that the task corresponding to the preset instruction is a real-time task, then the preset instruction is sent to the preset kernel contained in the system abstraction layer.
[0033] This specification provides a real-time network data transmission device, which includes a protocol layer, a system abstraction layer, and a driver layer. The driver layer includes a pre-loaded real-time network driver, comprising:
[0034] The generation module is used to generate preset instructions through the protocol layer;
[0035] The sending module is used to send the preset instruction to the preset kernel contained in the system abstraction layer, so that the preset kernel can call a preset task generation function to generate a real-time task for the preset instruction, and call a preset clock creation function to create a real-time timer for the real-time task, and send the preset instruction to the driver layer when the execution time of the real-time task is detected by the real-time timer.
[0036] The transmission module is used to send the preset instructions to the slave station through the real-time network driver loaded in the driver layer, so that the slave station can execute tasks according to the received preset instructions.
[0037] This specification provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned real-time network data transmission method.
[0038] This specification provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the aforementioned real-time network data transmission method.
[0039] The above-described at least one technical solution adopted in the embodiments of this specification can achieve the following beneficial effects:
[0040] In the embodiments described in this specification, after generating preset instructions through the protocol layer included in the master station, the preset instructions are sent to the preset kernel included in the system abstraction layer. The preset kernel then calls a preset task generation function to generate a real-time task for the preset instructions and calls a preset clock creation function to create a real-time timer for the real-time task. When the real-time timer detects that the execution time of the real-time task has arrived, the preset instructions are sent to the driver layer included in the master station. The preset instructions are then sent to the slave station through the pre-loaded real-time network driver in the driver layer, so that the slave station can execute the task according to the received preset instructions.
[0041] The manual describes how a real-time timer for real-time tasks is created using a preset kernel in the system abstraction layer to send preset instructions to the driver layer on time. The real-time media access control module, which is preloaded into the driver layer after the real-time network driver is loaded, is used to set the sending time of the preset instructions, reducing communication jitter and thus achieving precise control over the sending of preset instructions. Attached Figure Description
[0042] The accompanying drawings, which are included to provide a further understanding of this specification and form part of this specification, illustrate exemplary embodiments and are used to explain this specification, but do not constitute an undue limitation thereof. In the drawings:
[0043] Figure 1 A flowchart illustrating a real-time network data transmission method provided in an embodiment of this specification;
[0044] Figure 2 A schematic diagram of a real-time network data transmission method provided in the embodiments of this specification;
[0045] Figure 3 This is a schematic diagram of the structure of a real-time network data transmission device provided in the embodiments of this specification;
[0046] Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this specification. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this specification will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of them. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this specification.
[0048] The technical solutions provided in the various embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0049] Figure 1 A flowchart illustrating a real-time network data transmission method provided in this specification includes:
[0050] S100: Generate preset instructions through the protocol layer.
[0051] As automation systems demand higher real-time performance and real-time communication, an open-source real-time Ethernet communication protocol (Ethernet for Control Automation Technology, EtherCAT) can be used to achieve more flexible control of robots.
[0052] In the EtherCAT communication protocol, the robot's controller acts as the master station, and each of the robot's actuators acts as a slave station. The master station generates instructions and sends them to the slave stations so that the slave stations can execute the corresponding tasks according to the received instructions.
[0053] Normally, the master station sends instructions to the slave station by generating and distributing real-time instructions through the protocol layer, system abstraction layer, and driver layer deployed in the master station.
[0054] However, after the master station uses the EtherCAT communication protocol to send real-time commands to the general network driver, the communication jitter problem exists due to the unstable time interval between the two commands sent by the general network driver, as well as the inherent latency of the general network driver, which has a certain impact on real-time performance and thus cannot meet the real-time requirements in actual production.
[0055] To address the aforementioned issues, in this embodiment, after generating preset instructions through the protocol layer included in the master station, the preset instructions are sent to the preset kernel included in the system abstraction layer. The preset kernel then calls a preset task generation function to generate a real-time task for the preset instructions and calls a preset clock creation function to create a real-time timer for the real-time task. When the real-time timer detects that the execution time of the real-time task has arrived, the preset instructions are sent to the driver layer included in the master station. The driver layer then sends the preset instructions to the slave station through a pre-loaded real-time network driver, enabling the slave station to execute the task according to the received preset instructions.
[0056] In this method, a real-time timer for real-time tasks is created by using a preset kernel in the system abstraction layer, so that preset instructions are sent to the driver layer on time. The real-time media access control module, which is preloaded in the driver layer after the real-time network driver is loaded, is used to set the sending time of the preset instructions, reduce communication jitter, and thus achieve precise control over the sending of preset instructions.
[0057] First, the main station needs to generate preset instructions through the protocol layer.
[0058] Specifically, in the embodiments described in this specification, the master station first generates a preset instruction through the protocol layer according to the rules specified in the EtherCAT communication protocol. Then, the preset instruction is sent to the slave station through the system abstraction layer and the driver layer via the EtherCAT bus, so that the slave station can perform the corresponding action or task according to the received instruction.
[0059] The data used to generate the preset instructions can be generated during actual operation. For example, the master station can obtain the data needed to generate the preset instructions from real-time data or sensor readings, or the master station can obtain the slave station's configuration information, such as device parameters and communication parameters, from the response data returned by the slave station. The master station then generates the preset instructions through the protocol layer based on the obtained configuration information.
[0060] S102: Send the preset instruction to the preset kernel contained in the system abstraction layer, so that the preset kernel can call the preset task generation function to generate a real-time task for the preset instruction, and call the preset clock creation function to create a real-time timer for the real-time task, and when the execution time of the real-time task is detected by the real-time timer, send the preset instruction to the driver layer.
[0061] In the embodiments of this specification, after the master station generates a preset instruction through the protocol layer, it sends the preset instruction to the preset kernel contained in the system abstraction layer. The preset kernel then calls the preset task generation function to generate a real-time task for the preset instruction and calls the preset clock creation function to create a real-time timer for the real-time task. Thus, when the real-time timer detects that the execution time of the real-time task has arrived, the preset instruction is sent to the driver layer contained in the master station.
[0062] The default kernel mentioned here includes the real-time kernel, which includes the real-time subsystem Xenomai kernel, while the system abstraction layer contains the non-real-time kernel, which includes the Linux kernel.
[0063] In this specification, the decision to send the generated instructions from the master station to the real-time kernel or the non-real-time kernel in the system abstraction layer depends on whether the robot needs to run.
[0064] Specifically, the master station initializes the communication parameters and device parameters of the slave station before the robot runs. After generating the initialization command based on the configuration information of the slave station, the master station sends the initialization command to the non-real-time kernel contained in the system abstraction layer. The non-real-time kernel then sends the preset command to the driver layer.
[0065] During robot operation, the master station generates preset instructions according to the preset rules in the EtherCAT communication protocol. These preset instructions are then sent to the real-time kernel contained in the preset kernel. The real-time kernel then creates corresponding real-time tasks and real-time timers based on the preset instructions, ensuring that the preset instructions are sent to the driver layer on time.
[0066] It should be noted that preset commands can be periodic commands generated by the master station according to preset rules in the EtherCAT communication protocol, or specific commands generated by the master station based on the response data returned by the slave station after receiving the preset commands.
[0067] By calling a preset clock creation function in the real-time kernel, a real-time timer is created for the real-time task corresponding to the preset instruction. This ensures that the preset instruction can be sent to the driver layer on time when the execution time of the real-time task is reached, based on the real-time timer.
[0068] S104: The preset instruction is sent to the slave station through the real-time network driver loaded in the driver layer, so that the slave station executes the task according to the received preset instruction.
[0069] In this specification, the master station transmits preset instructions to the driver layer through the system abstraction layer, and then sends the preset instructions to the slave station according to the real-time network driver loaded in the driver layer, so that the slave station can execute tasks according to the received preset instructions.
[0070] Specifically, in this specification, after the master station transmits the preset command to the driver layer through the system abstraction layer, the driver layer stores the preset command in a send buffer included in the driver layer. Simultaneously, it stores the index value corresponding to the preset command in a send index buffer included in the driver layer. By loading the real-time network driver and configuring the real-time media access control module, and based on the waiting time when sending the previous command, the driver layer sets the send time for the preset command. Based on the send time and the real-time driver module configured after loading the real-time network driver, the driver layer sends the preset command to the slave station. The data stored in the send buffer is sent to the slave station according to the first-in, first-out (FIFO) principle. The waiting time mentioned here represents the time interval between the driver layer sending two commands.
[0071] In this specification, the real-time media access control module configured after loading the real-time network driver can set the sending time of the preset command based on the average time interval between each historical command before sending the previous command and the waiting time when sending the previous command. In this way, the time interval between sending each command is relatively stable, thereby reducing communication jitter.
[0072] For example, if the average time interval between historical instructions before sending the previous instruction is calculated by the real-time media access control module set after loading the real-time network driver, and the waiting time for sending the previous instruction is 1 second, then the difference between the two is -0.5 seconds. Subsequently, the waiting time when sending the current preset instruction is adjusted to 1 second, and the sending time of the preset instruction is set accordingly. Then, based on the sending time and the real-time driver module set after loading the real-time network driver in the driver layer, the preset instruction is sent to the slave station.
[0073] It should be noted that the real-time network driver mentioned here may refer to RTnet.
[0074] In addition, after the driver layer contained in the master station receives the response data returned by the slave station in response to the preset command, it stores the response data in the receive buffer and the index value corresponding to the response data in the receive index buffer. If it is determined that there is an index value in the send index buffer that matches the index value corresponding to the response data stored in the receive index buffer, the response data stored in the receive buffer is sent to the preset kernel contained in the system abstraction layer so that the response data can be processed by the preset kernel.
[0075] Before storing the response data in the receive buffer, the real-time network application programming interface (API) module, configured after loading the real-time network driver in the driver layer, is used to judge the return value of the slave station after executing the received preset instruction. Based on whether the return value is greater than a preset value, it is determined whether the slave station that received the preset instruction has correctly completed the corresponding task. Then, the response data with a return value greater than the preset value is stored in the receive buffer, and the corresponding index value is stored in the receive index buffer for further matching of the response data later. The preset value can be set to 0.
[0076] It's important to note that before the robot can run, a real-time network driver needs to be loaded from some general-purpose network drivers. Here, the general-purpose network driver refers to the default network driver. The reason for loading the real-time network driver is that if the default network driver is used, the time interval between the sending times of adjacent commands will be unstable due to the default driver's inability to set the sending time, leading to communication jitter. Furthermore, the default network driver has a fixed delay, causing commands to fail to be sent in a timely manner, thus impacting real-time performance. Therefore, loading the real-time network driver is necessary to improve real-time performance.
[0077] Specifically, obtain the installation script for the real-time network driver, run the installation script to create a real-time network card driver module, so that the address of the network interface card used by the real-time network driver to be configured can be set to the address of the network interface card used by the general network driver. Then, modify the driver name of the general network driver used in the driver layer included in the main station to the driver name of the real-time network driver to be configured, thereby completing the loading of the real-time network driver in the driver layer included in the main station.
[0078] It is important to note that the installation script for the real-time network driver mentioned here includes: the driver name of the general network driver, the address of the network interface card corresponding to the general network driver, the preset data transmission protocol stack in the real-time network driver, the status information of the real-time media access control module set after loading the real-time network driver, and the status information of the real-time packet capture module set after loading the real-time network driver module.
[0079] The preset data transmission protocol stack in the real-time network driver can refer to a UDP / IP protocol stack. This stack is used to convert preset commands into a specified data transmission format to improve data transmission speed. The real-time media access control module, set after loading the real-time network driver, obtains exclusive control over the network driver's transmission. As described above, the real-time media access control module also sets the sending time of the current command based on the waiting time for sending the previous command, ensuring a relatively stable time interval between each command and reducing communication jitter. The real-time packet capture module, set after loading the real-time network driver module, is used to capture the response data returned by the slave station after receiving the preset commands.
[0080] In other words, after the master station sends the preset command to the driver layer, it first uses the preset data transmission protocol stack to convert the preset command into the specified data transmission format to improve the data transmission speed. Then, due to the function of the real-time media access control module set after loading the real-time network driver, there is a strong binding relationship between the original network interface card and the real-time network driver, so that the driver layer uses the real-time network driver and sends the preset command to the slave station through the original network interface card. Furthermore, the real-time packet capture module set after loading the real-time network driver module captures the response data returned by the slave station after receiving the preset command, which facilitates the master station's further operations on the slave station.
[0081] It should be noted that the real-time network data transmission method described in this manual is applicable to devices using the EtherCAT communication protocol.
[0082] By using the above method, after loading the real-time network driver into the driver layer included in the main station, the instructions created by the main station during robot operation can use the real-time media access control module set after loading the real-time network driver to set the sending time of the instructions, thereby controlling the sending time of the preset instructions and reducing communication jitter.
[0083] Figure 2 This is a schematic diagram of a real-time network data transmission method provided in the embodiments of this specification.
[0084] like Figure 2As shown, the main station contains three parts: the protocol layer, the system abstraction layer, and the driver layer. The driver layer contains a real-time network driver, a send buffer, a send index buffer, a receive buffer, and a receive index buffer. The protocol layer contains the system abstraction layer, which contains a non-real-time kernel and a real-time kernel.
[0085] Before operating the robot, the master station obtains the slave station's clock time and corresponding configuration information, such as device parameters and communication parameters, by broadcasting data frames. The protocol layer generates initialization instructions based on this configuration information and sends the initialization instructions to the non-real-time kernel contained in the system abstraction layer. The non-real-time kernel then sends the initialization instructions to the send buffer of the driver layer and stores the index value corresponding to the initialization instructions in the send index buffer. Subsequently, the general network driver sends the initialization instructions to the slave station according to the first-in-first-out principle based on the data stored in the send buffer, so that the slave station can execute the received initialization instructions.
[0086] During robot operation, the master station generates preset instructions according to the preset rules in the EtherCAT communication protocol. After sending the preset instructions to the real-time kernel contained in the preset kernel, the real-time kernel creates the corresponding real-time task and real-time timer according to the preset instructions. When the real-time timer detects that the execution time of the real-time task has been reached, the preset instructions are sent to the driver layer. The preset instructions are used to represent the periodic instructions generated by the master station according to the preset rules in the EtherCAT communication protocol, and to further generate corresponding specific instructions based on the response data returned by the slave station after receiving the preset instructions.
[0087] The driver layer stores the received preset instructions in a transmit buffer and the corresponding index value in a transmit index buffer. Following a first-in, first-out (FIFO) principle, the preset instructions are transmitted to the data transmission protocol stack via the real-time network application programming interface module (API) configured after loading the real-time network driver. This stack converts the preset instructions into a specified data transmission format, resulting in a converted instruction. The converted instruction is then transmitted to the real-time media access control module (MTC) configured after loading the real-time network driver. The MTC module then sets the transmission time for the converted instruction based on the waiting time before sending the previous instruction. The waiting time represents the time interval between the driver layer sending two instructions. Finally, based on the set transmission time, the converted instruction is sent to the slave station via the real-time network interface card (NIC) driver module configured after loading the real-time network driver.
[0088] The slave station executes the corresponding task and returns response data after receiving the converted instruction. The real-time packet capture module, configured after loading the real-time network driver in the driver layer, captures the response data from the corresponding network card and transmits it to the real-time network application programming interface (API) module. The API module then judges the return value in the response data to determine if the slave station correctly executed the received preset instruction. Response data with a return value greater than the preset value is stored in the receive buffer, and the corresponding index value is stored in the receive index buffer. This allows the system to check if a matching index value exists in the send index buffer, ensuring that the received index buffer contains the index value of the response data sent by the master station. The preset value can be set to 0.
[0089] If it is determined that there is an index value in the sending index buffer that matches the index value of the response data stored in the receiving index buffer, then the response data stored in the receiving buffer is sent to the preset kernel contained in the system abstraction layer so that the response data can be processed by the preset kernel.
[0090] As can be seen from the above, by using a preset kernel in the system abstraction layer to create a real-time timer for real-time tasks, preset instructions can be sent to the driver layer on time. The real-time media access control module, which is preloaded in the driver layer after loading the real-time network driver, can be used to set the sending time of the preset instructions, thereby reducing communication jitter. This achieves precise control over the sending of preset instructions and greatly improves real-time performance to a certain extent.
[0091] The above is a real-time network data transmission method provided by the embodiments of this specification. Based on the same idea, this specification also provides corresponding devices, storage media and electronic devices.
[0092] Figure 3 This is a schematic diagram of a real-time network data transmission device provided in an embodiment of this specification. The device includes:
[0093] Generation module 301 is used to generate preset instructions through the protocol layer;
[0094] The sending module 302 is used to send the preset instruction to the preset kernel contained in the system abstraction layer, so that the preset kernel can call a preset task generation function to generate a real-time task for the preset instruction, and call a preset clock creation function to create a real-time timer for the real-time task, and send the preset instruction to the driver layer when the execution time of the real-time task is detected by the real-time timer.
[0095] The transmission module 303 is used to send the preset instruction to the slave station through the real-time network driver loaded in the driver layer, so that the slave station can execute the task according to the received preset instruction.
[0096] Optionally, the device further includes a loading module 304;
[0097] The loading module 304 is specifically used to: obtain an installation script for the real-time network driver; run the installation script to create a real-time network card driver module, so as to set the address of the network interface card used by the real-time network driver to be configured to the address of the network interface card used by the general network driver, and modify the driver name of the general network driver used by the driver layer to the driver name of the real-time network driver to be configured, so as to complete the loading of the real-time network driver.
[0098] Optionally, the transmission module 303 is specifically used to send the preset instruction to the real-time media access control module set in the driver layer after loading the real-time network driver, so that the real-time media access control module sets the sending time of the preset instruction according to the waiting time when sending the previous instruction, wherein the waiting time is used to represent the time interval between the driver layer sending two instructions; according to the sending time, the preset instruction is sent to the slave station through the real-time driver module set in the driver layer after loading the real-time network driver.
[0099] Optionally, the driver layer includes a send buffer;
[0100] Before sending the preset instruction to the slave station through the real-time network driver loaded in the driver layer, the transmission module 303 is also used to store the preset instruction in the sending buffer;
[0101] The transmission module 303 is specifically used to send the preset instruction stored in the transmission buffer to the slave station, wherein the data stored in the transmission buffer is sent to the slave station according to the first-in-first-out principle.
[0102] Optionally, the driver layer includes a send index buffer, a receive buffer, and a receive index buffer;
[0103] The transmission module 303 is also used to store the index value corresponding to the preset instruction in the transmission index buffer;
[0104] The transmission module 303 is further configured to receive response data returned by the slave station in response to the preset instruction; store the response data in the receiving buffer and store the index value corresponding to the response data in the receiving index buffer; if it is determined that there is an index value in the sending index buffer that matches the index value corresponding to the response data stored in the receiving index buffer, then the response data stored in the receiving buffer is sent to the preset kernel included in the system abstraction layer, so that the response data can be processed by the preset kernel.
[0105] Optionally, the preset kernel includes a real-time kernel, which includes the Xenomai kernel of the real-time subsystem.
[0106] Optionally, the sending module 302 is specifically used to send the preset instruction to the preset kernel contained in the system abstraction layer if it is determined that the task corresponding to the preset instruction is a real-time task.
[0107] This specification also provides a computer-readable storage medium storing a computer program that, when executed by a processor, can be used to perform the above-described actions. Figure 1 This provides a real-time network data transmission method.
[0108] based on Figure 1 The present invention provides a real-time network data transmission method, and the embodiments of this specification also provide... Figure 4 The diagram shows the structure of the electronic device. Figure 4 At the hardware level, this electronic device includes a processor, internal bus, network interface, memory, and non-volatile memory, and may also include other hardware required for business operations. The processor reads the corresponding computer program from the non-volatile memory into memory and then executes it to achieve the above. Figure 1 The aforementioned method for real-time network data transmission.
[0109] Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of hardware and software. In other words, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0110] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0111] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0112] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0113] For ease of description, the above devices are described in terms of function, divided into various units. Of course, in implementing this specification, the functions of each unit can be implemented in one or more software and / or hardware.
[0114] Those skilled in the art will understand that embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0115] This specification is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this specification. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0116] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0117] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0118] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0119] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0120] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0121] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0122] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0123] This specification can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This specification can also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0124] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0125] The above description is merely an embodiment of this specification and is not intended to limit this specification. Various modifications and variations can be made to this specification by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims of this specification.
Claims
1. A real-time network data transmission method, characterized in that, The method is applied to a master station, which includes a protocol layer, a system abstraction layer, and a driver layer. The driver layer contains a pre-loaded real-time network driver, including: Preset instructions are generated through the protocol layer; The preset instruction is sent to the preset kernel contained in the system abstraction layer, so that the preset kernel can call the preset task generation function to generate a real-time task for the preset instruction, and call the preset clock creation function to create a real-time timer for the real-time task. When the real-time timer detects that the execution time of the real-time task has arrived, the preset instruction is sent to the driver layer. The preset instructions are sent to the slave station through the real-time network driver loaded in the driver layer, so that the slave station can execute tasks according to the received preset instructions.
2. The method as described in claim 1, characterized in that, The pre-loaded real-time network driver includes: Obtain the installation script for the real-time network driver; Run the installation script to create a real-time network card driver module. Through the real-time network card driver module, set the address of the network interface card used by the real-time network driver to be configured to the address of the network interface card used by the general network driver, and modify the driver name of the general network driver used by the driver layer to the driver name of the real-time network driver to be configured, so as to complete the loading of the real-time network driver.
3. The method as described in claim 1, characterized in that, The preset instructions are sent to the slave station through the real-time network driver loaded in the driver layer, specifically including: The preset instruction is sent to the real-time media access control module set after loading the real-time network driver in the driver layer, so that the real-time media access control module sets the sending time of the preset instruction according to the waiting time when sending the previous instruction, wherein the waiting time is used to represent the time interval between the driver layer sending the previous and next instructions. Based on the sending time, the preset instruction is sent to the slave station through the real-time driver module set after loading the real-time network driver in the driver layer.
4. The method as described in claim 1, characterized in that, The driver layer includes a send buffer; Before sending the preset instructions to the slave station via the real-time network driver loaded in the driver layer, the method further includes: The preset instruction is stored in the send buffer; The preset instructions are sent to the slave station through the real-time network driver loaded in the driver layer, specifically including: The preset instruction stored in the transmit buffer is sent to the slave station, wherein the data stored in the transmit buffer is sent to the slave station according to the first-in, first-out principle.
5. The method as described in claim 4, characterized in that, The driver layer includes a send index buffer, a receive buffer, and a receive index buffer. The method further includes: The index value corresponding to the preset instruction is stored in the sending index buffer; The method further includes: Receive the response data returned by the slave station in response to the preset command; The response data is stored in the receiving buffer, and the index value corresponding to the response data is stored in the receiving index buffer; If it is determined that there exists an index value in the sending index buffer that matches the index value corresponding to the response data stored in the receiving index buffer, then the response data stored in the receiving buffer is sent to the preset kernel contained in the system abstraction layer, so that the response data can be processed by the preset kernel.
6. The method according to any one of claims 1 to 5, characterized in that, The preset kernel includes a real-time kernel, which includes the Xenomai kernel, a real-time subsystem.
7. The method as described in claim 6, characterized in that, Sending the preset instructions to the preset kernel contained in the system abstraction layer specifically includes: If it is determined that the task corresponding to the preset instruction is a real-time task, then the preset instruction is sent to the preset kernel contained in the system abstraction layer.
8. A real-time network data transmission device, characterized in that, The device includes a protocol layer, a system abstraction layer, and a driver layer. The driver layer includes a pre-loaded real-time network driver, comprising: The generation module is used to generate preset instructions through the protocol layer; The sending module is used to send the preset instruction to the preset kernel contained in the system abstraction layer, so that the preset kernel can call a preset task generation function to generate a real-time task for the preset instruction, and call a preset clock creation function to create a real-time timer for the real-time task, and send the preset instruction to the driver layer when the execution time of the real-time task is detected by the real-time timer. The transmission module is used to send the preset instructions to the slave station through the real-time network driver loaded in the driver layer, so that the slave station can execute tasks according to the received preset instructions.
9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the method described in any one of claims 1-7.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method described in any one of claims 1-7.
Citation Information
Patent Citations
System and method for eliminating EtherCAT communication period jitter
CN110995613A
Improved EtherCAT communication master station method and system based on IGH open source framework
CN114666185A