Data processing method and device and computing equipment

By using the target socket mechanism on the processor, the problem that the EtherCAT master protocol stack cannot be used normally on the lightweight protocol stack operating system is solved, and the compatibility and data transmission of the EtherCAT master protocol stack on systems that do not support original sockets is achieved, which expands its application scope and improves the accuracy and efficiency of data transmission.

CN120263873APending Publication Date: 2025-07-04XFUSION DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510400521.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-31
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

The existing EtherCAT master protocol stack cannot be used normally on operating systems running lightweight protocol stacks, resulting in limited application scope.

Method used

By introducing a target socket mechanism on the processor, the processor obtains packets of the second protocol stack through the target socket, and processes and sends EtherCAT protocol frames through the first protocol stack, realizing data exchange between the first protocol stack and the second protocol stack, including removing or adding outer protocol headers, ensuring the accuracy and compatibility of data transmission.

Benefits of technology

The EtherCAT master protocol stack is implemented normally on operating systems that do not support original sockets, expanding its application scope, and improving the accuracy and efficiency of data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120263873A_ABST
    Figure CN120263873A_ABST
Patent Text Reader

Abstract

Embodiments of the invention provide a data processing method and apparatus, and a computing device, which can normally use an EtherCAT master station protocol stack on an operating system running a lightweight protocol stack, and improve the application range of the EtherCAT master station protocol stack. Specifically, the processor obtains a first message of a second protocol stack through a target socket, then obtains an EtherCAT protocol frame in the first message through the first protocol stack according to the first message, and sends the EtherCAT protocol frame through the first protocol stack. It can be understood that the first protocol stack in the processor can process the message of the second protocol stack and send the EtherCAT protocol frame provided by the second protocol stack, for example, the EtherCAT protocol frame is sent to a network card supporting an original socket, so that the EtherCAT protocol frame is sent to the EtherCAT slave station equipment through the network card.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of servers, and in particular, to a data processing method, apparatus, and computing device. Background Art

[0002] Ethernet for Control Automation Technology (EtherCAT) is a real-time industrial communication protocol based on Ethernet. Due to its characteristics of high performance, low latency, and high synchronization accuracy, it is widely used in the field of industrial automation. For example, it is applied in automation fields such as machine tool control, robot control, and automated production line control.

[0003] The core component for implementing EtherCAT communication is the EtherCAT master protocol stack. The EtherCAT master protocol stack is used to manage and coordinate EtherCAT slave devices (referred to as slaves) in the network. That is, the EtherCAT master protocol stack communicates with multiple slaves through Ethernet to ensure the normal operation of the entire operating system.

[0004] Currently, the EtherCAT master protocol stack runs on operating systems that support raw sockets, such as embedded operating systems like Linux or Windows. Among them, the operating system needs to bind a network card that supports raw sockets so that the EtherCAT master protocol stack can bypass the transport layer and network layer in the Transmission Control Protocol / Internet Protocol (TCP / IP) protocol stack and directly access the link layer of the TCP / IP protocol stack to receive and send EtherCAT protocol frames, thereby implementing message sending and receiving operations based on EtherCAT protocol frames with EtherCAT slaves.

[0005] However, many current operating systems do not support raw sockets. Specifically, operating systems with a lightweight TCP / IP protocol stack often do not support raw sockets. For example, the lightweight protocol stack is the Lightweight Internet Protocol Stack (LWIP) protocol stack. This makes the EtherCAT master protocol stack unable to be used normally on operating systems with a lightweight protocol stack, and the application scope of the EtherCAT master protocol stack is limited. Summary of the Invention

[0006] The embodiments of the present application provide a data processing method, apparatus and computing device, which can normally use the EtherCAT master protocol stack on an operating system running a lightweight protocol stack, and improve the application range of the EtherCAT master protocol stack.

[0007] In a first aspect, the embodiments of the present application provide a data processing method. This method is applied to a computing device, which can be an embedded device running a system incompatible with SOME, such as a Linux system or a Windows system. Specifically, this method can be applied to the processor of the computing device. The processor includes a first protocol stack and a second protocol stack, where the first protocol stack and the second protocol stack communicate through a target socket.

[0008] The method specifically includes: the processor obtains a first message of the second protocol stack through the target socket, and then according to the first message, obtains the EtherCAT protocol frame in the first message through the first protocol stack, and sends the EtherCAT protocol frame through the first protocol stack. It can be understood that the first protocol stack in the processor can process the messages of the second protocol stack and send the EtherCAT protocol frames provided by the second protocol stack, such as sending them to a network card supporting raw sockets, so as to be sent to the EtherCAT slave device through the network card. Thus, even if the first protocol stack in the processor is incompatible with the second protocol stack, the first protocol stack can still obtain the first message of the second protocol stack through the target socket and send the EtherCAT protocol frame in the first message, realizing the effective data communication between the first protocol stack and the second protocol stack, thereby realizing the normal use of the EtherCAT master protocol stack on an operating system running a lightweight protocol stack, and further improving the application range of the EtherCAT master protocol stack.

[0009] In a specific implementation, the processor can remove the outer protocol header of the first message through the first protocol stack to obtain the EtherCAT protocol frame. The outer protocol header includes the target channel address, the source media access control (MAC) address, and the protocol type. The target channel address is connected to the target socket and is used to indicate the channel address for transmitting the first message. By removing the outer protocol header of the first message, the processor can directly extract the EtherCAT protocol stack, reducing unnecessary processing steps and improving the extraction efficiency. Further, by connecting the target socket to the target channel address, the accuracy of data transmission can be ensured, avoiding errors or losses in data transmission.

[0010] In another specific implementation, the processor can obtain a second packet through a first protocol stack; if the second packet is a packet of a second protocol stack, encapsulate the second packet into a target channel packet; send the target channel packet to the second protocol stack through a target socket; where the target channel packet is a packet that can be sent through the target socket. It can be understood that even if the first protocol stack and the second protocol stack are not compatible, the processor can still send the second packet to the second protocol stack through the first protocol stack. That is, bidirectional data transmission between the first protocol stack and the second protocol stack is achieved.

[0011] In yet another specific implementation, an outer protocol header is added to the second packet, and the outer protocol header includes a target channel address, a source MAC address, and a protocol type to obtain a target channel packet; the target channel address is connected to the target socket and is used to indicate the channel address for transmitting the target channel packet. Thus, by adding an outer protocol header to the second packet, specifically the target channel address, the source MAC address, and the protocol type, it can be ensured that the obtained target channel packet is accurately transmitted to the first protocol stack.

[0012] In yet another specific implementation, the processor calls a socket interface to obtain target parameters, and the target parameters indicate to create a raw socket that supports the EtherCAT protocol; according to the target parameters, create a target socket and bind the created target socket to the target channel address; after obtaining a first packet of the second protocol stack through the target socket, send the first packet to the first protocol stack through the target channel address.

[0013] Among them, the target channel address can be a virtual channel address, where the virtual channel address is an address that will not be actually allocated or used when transmitting data supported by the first protocol stack. Thus, it is ensured that the target channel address will not conflict with other addresses in the actual network.

[0014] In yet another specific implementation, the processor can create an initial socket according to the target parameters; adjust the identifier of the initial socket to the identifier of the target socket, and process the attribute information of the adjusted socket to obtain a target socket that is compatible with the first protocol stack.

[0015] In yet another specific implementation, if the socket interface includes a first parameter, a second parameter, and a third parameter, the first parameter is used to indicate the protocol family supported by the created socket, the second parameter is used to indicate the type of the created socket, and the third parameter is used to indicate the protocol supported by the created socket. If the first parameter is PF_PACKET, the second parameter is the raw socket identifier, and the third parameter is the identifier that supports the EtherCAT protocol, the processor can obtain the target parameters.

[0016] Among them, if the first protocol stack is a lightweight Internet protocol LWIP protocol stack and the second protocol stack is an EtherCAT protocol stack.

[0017] In a second aspect, an embodiment of the present application further provides a data processing device, which is characterized in that it is applied to a processor. The processor includes a first protocol stack and a second protocol stack, and the first protocol stack communicates with the second protocol stack through a target socket. The device includes:

[0018] An acquisition unit, configured to acquire a first message of the second protocol stack through the target socket;

[0019] An analysis unit, configured to obtain an EtherCAT protocol frame of the first message through the first protocol stack according to the first message;

[0020] A sending unit, configured to send the EtherCAT protocol frame through the first protocol stack.

[0021] In a third aspect, an embodiment of the present application provides a computing device, including:

[0022] A memory, configured to store a program;

[0023] A processor, configured to execute the program stored in the memory. When the program stored in the memory is executed, the processor is configured to execute the method according to any one of the first aspect.

[0024] In a fourth aspect, the present application provides a computer storage medium, configured to store a computer program. When the computer program is executed, it is used to implement the method provided by any one of the implementation manners in the first aspect of the present application.

[0025] In a fifth aspect, the present application provides a computer program product containing instructions. When it runs on at least one computing device, it causes at least one computing device to implement the method provided by any one of the implementation manners in the first aspect of the present application.

[0026] Any of the above-provided data processing methods corresponds to a computing device, a computer-readable storage medium, a computer program product, etc., which are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method, and will not be elaborated here. Description of the Drawings

[0027] Figure 1 It is an application scenario diagram provided by an embodiment of the present application;

[0028] Figure 2A It is a flowchart of a data processing method provided by an embodiment of the present application;

[0029] Figure 2B It is another interaction diagram of a data processing method provided by an embodiment of the present application;

[0030] Figure 3Flowchart of a method for creating a target socket provided by an embodiment of the present application;

[0031] Figure 4 Flowchart of another method for creating a target socket provided by an embodiment of the present application;

[0032] Figure 5A Flowchart of another data processing method provided by an embodiment of the present application;

[0033] Figure 5B Flowchart of another data processing method provided by an embodiment of the present application;

[0034] Figure 6 Schematic structural diagram of a data processing device provided by an embodiment of the present application. Detailed implementation manners

[0035] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.

[0036] First, the professional terms involved in the embodiments of the present application will be described.

[0037] (1) Socket

[0038] A socket is a data structure used to implement communication between different processes in a computer network. The socket provides an interface for an application program to access network services, enabling data to be transmitted between a local or remote server.

[0039] Sockets include stream sockets, datagram sockets, and raw sockets.

[0040] Among them, stream sockets usually use the Transmission Control Protocol (TCP) for data transmission. The data of stream sockets is transmitted in order without loss or duplication.

[0041] Datagram sockets usually use the User Datagram Protocol (UDP) for data transmission. Datagram sockets are transmitted in the form of independent data packets, and there may be loss, duplication, or out-of-order.

[0042] Raw socket: A socket that allows users to directly access the underlying network protocol. A raw socket can customize the header and content of a datagram. Raw sockets can be used for transmission using various network layer protocols. For example, they can use protocols such as Internet Protocol (IP), Internet Control Message Protocol (ICMP), or EtherCAT protocol, UDP, or TCP for transmission.

[0043] Furthermore, raw sockets are further divided into raw sockets that support PF-PACKET and raw sockets that do not support PF-PACKET. Raw sockets that support PF-PACKET can directly operate on Ethernet frames at the data link layer. That is, the data sent by this raw socket must contain the protocol header of the link layer, and the received data also contains the protocol header of the link layer. Raw sockets that do not support PF-PACKET operate at the network layer and are usually used to operate data above the IP layer. For raw sockets that do not support PF-PACKET, the data sent does not contain the protocol header of the link layer, and the received data also does not contain the protocol header of the link layer.

[0044] (2) EtherCAT

[0045] EtherCAT is a real-time industrial communication protocol based on Ethernet, designed to meet the requirements of industrial automation and control systems for high performance, low latency, and high synchronization accuracy. EtherCAT is widely used in fields such as motion control, process control, and embedded systems, providing strong support for the development of modern industrial automation.

[0046] To implement EtherCAT communication, master and slave devices that support EtherCAT are required.

[0047] The master can be a server or other electronic devices running the EtherCAT master protocol stack, which is not specifically limited in the embodiments of this application. The master is responsible for managing and coordinating all slaves in network communication.

[0048] Among them, the slaves can be sensors, actuators, and drivers, etc.

[0049] (3) EtherCAT Master Protocol Stack

[0050] The EtherCAT master protocol stack is a key software component for implementing EtherCAT communication. In the embodiments of the present application, the EtherCAT master protocol stack may be a Simple Open EtherCAT Master (SOEM) protocol stack, a lightweight open-source EtherCAT master protocol stack.

[0051] The EtherCAT master protocol stack can run on operating systems such as Linux or Windows that support raw sockets, and the operating system needs to bind a network card that supports raw sockets. Thus, the EtherCAT master protocol stack can directly access the link layer or network layer of the TCP / IP protocol stack using raw sockets, that is, directly send and receive EtherCAT protocol frames without going through the transport layer of the Transmission Control Protocol / Internet Protocol (TCP / IP) protocol stack. Therefore, the time overhead processed by the EtherCAT master protocol stack can be reduced, and the communication efficiency can be improved.

[0052] (4) Lightweight protocol stack

[0053] The lightweight protocol stack is a simplified TCP / IP protocol stack designed specifically for resource-constrained operating systems. Compared with the full-function ICP / IP protocol stack, the lightweight protocol stack occupies less memory and processor resources while ensuring basic network communication functions.

[0054] Exemplarily, the LWIP protocol stack is an open-source and lightweight TCP / IP protocol stack that provides a complete implementation of the TCP / IP protocol. For example, it provides protocol implementations such as TCP, UDP, and ICMP.

[0055] Since raw sockets require more memory to store and process network data packets and more computing resources, for resource-constrained operating systems, it may exceed the available memory and increase the processor load, etc., making the operating system running the lightweight protocol stack not support raw sockets, that is, it is not compatible with the EtherCAT master protocol stack.

[0056] In view of the above problems, the embodiments of the present application provide a data processing method. This method is specifically applied to a processor, which includes a first protocol stack and a second protocol stack. The processor obtains a first packet of the second protocol stack through a target socket, and obtains and sends the EtherCAT protocol frame in the first packet through the first protocol stack to achieve the compatibility between the first protocol stack and the EtherCAT protocol stack, and to achieve the compatibility of the EtherCAT master protocol stack on an operating system that does not support raw sockets.

[0057] To better illustrate the technical solutions provided by the embodiments of the present application, the application scenarios of the embodiments of the application will be introduced below.

[0058] Exemplarily, Figure 1 This is an application scenario diagram provided by the embodiments of the present application. As Figure 1 shown, the network communication architecture of the server 10 includes a user interface layer and a protocol stack. In the embodiments of the present application, to distinguish the EtherCAT master protocol frame, this protocol stack is called the first protocol stack, and the EtherCAT master protocol stack is called the second protocol stack.

[0059] The user interface layer can also be called the application layer and directly interacts with the user application program. In the embodiments of the present application, the user interface layer includes a socket interface for creating sockets.

[0060] In the embodiments of the present application, the user application program can pass the data to be sent to the created socket. For example, the user application program can call a write interface (such as Write()) or a send interface (such as send()) to pass the data to be sent to the created socket and then to the protocol stack.

[0061] It should be noted that the user interface layer may also include other interfaces. For example, it may include a configuration interface for setting network parameters or protocol stack configurations, and may also include a log and debugging interface for recording the status or error information of network communication. The embodiments of the present application do not specifically limit this.

[0062] The first protocol stack is located between the user interface layer and the driver layer. The first protocol stack in the embodiments of the present application is a lightweight protocol stack, such as the LWIP protocol stack, the UIP protocol stack, or the FreeRTOS+TCP protocol stack, etc. The embodiments of the present application do not specifically limit this.

[0063] Among them, the first protocol stack includes a network layer, a transport layer, a link layer, and a driver layer. The network layer and the transport layer are used to implement the TCP / IP network communication protocol. In the embodiments of the present application, after the first protocol stack obtains the data to be sent through the socket, the data to be sent is encapsulated by the transport layer, the network layer, and the link layer in sequence to obtain a standard channel message, and then the standard channel message is sent to the driver layer of the first protocol stack for processing by the driver layer.

[0064] It should be noted that the driver layer mentioned below all refers to the driver layer of the first protocol stack.

[0065] Exemplarily, if the first protocol stack is the LWIP protocol stack, after the first protocol stack obtains the data to be sent through the socket, at the transport layer, according to the socket protocol type, the data to be sent is encapsulated to obtain the initial encapsulated data. If the socket protocol type is a TCP socket, TCP header information is added to the outer layer of the data to be sent, where the TCP header information includes information such as sequence number and acknowledgment number to ensure the reliable transmission of the data to be sent. If the socket protocol type is a UDP socket, UDP header information is added to the outer layer of the data to be sent, where the UDP header information contains information such as port.

[0066] Then, the first protocol stack continues to add Internet Protocol (IP) header information to the initial encapsulated data at the network layer, where the IP header information includes information such as source IP address and destination IP address, to obtain the intermediate encapsulated data. The first protocol stack continues to add Ethernet header information, including source Media Access Controller (MAC) address and destination MAC address, to the intermediate encapsulated data at the link layer to obtain the standard channel packet.

[0067] The first protocol stack is also used to obtain the standard protocol packet sent by the network card through the driver layer. The standard protocol packet refers to the packet of the TCP / IP network communication protocol. The first protocol stack performs de-encapsulation processing on the standard protocol packet from the driver layer, link layer, network layer, and transport layer in sequence, extracts the data to be received in the standard protocol packet, and sends the data to be received to the corresponding user application through the socket.

[0068] Exemplarily, if the first protocol stack is the LWIP protocol stack, the standard protocol packet from the outer layer to the inner layer is in sequence: Ethernet header information, IP header information, TCP or UDP header information, and the data to be received. The protocol stack is specifically used for: at the driver layer, performing encapsulation processing on the standard protocol stack packet to obtain the target channel packet. The target channel packet is a packet that meets the transmission requirements of the first protocol stack. Then, at the link layer, de-encapsulation processing is performed on the target channel packet to remove the Ethernet header to obtain the first packet to be de-encapsulated. Then, the protocol stack performs de-encapsulation processing on the first packet to be de-encapsulated at the network layer to remove the IP header information to obtain the second packet to be de-encapsulated. Then, the protocol stack performs de-encapsulation processing on the second packet to be de-encapsulated at the transport layer to remove the TCP header information or UDP header information, and extracts the response data to send the response data to the corresponding user application through the socket.

[0069] The driver layer is responsible for the communication between the first protocol stack and the specific hardware device. The hardware device refers to the physical components of the computing device 10. For example, the hardware device is an Ethernet controller, network card, etc.

[0070] In the embodiments of the present application, the user application includes a second protocol stack (i.e., the EtherCAT master protocol stack). The first protocol stack does not support raw sockets. For example, the first protocol stack is a lightweight protocol stack, and the hardware device is a network card that supports raw sockets. The first protocol stack manages slave stations #1 to #n through Ethernet. Wherein, n is a positive integer. Considering that the first protocol stack is not compatible with the second protocol stack, the embodiments of the present application perform the following processing to achieve compatibility between the lightweight protocol stack and the second protocol stack: An identification mechanism and a processing mechanism are added at the driver layer.

[0071] The identification mechanism is used to identify the first packet sent through the socket of the first protocol stack and / or identify the second packet sent through the network card. Wherein, the first packet includes an EtherCAT protocol frame sent by the EtherCAT master protocol stack, and the second packet is a packet supporting the EtherCAT protocol.

[0072] The processing mechanism is used to extract the EtherCAT protocol stack from the first packet and output it to the slave station through the network card. Or encapsulate the second packet sent by the network card to obtain a target channel packet. The target channel packet is a packet supported by the first protocol stack for transmission. The target channel packet is sent to the EtherCAT master protocol stack through the socket of the first protocol stack.

[0073] Thus, data transmission between the lightweight protocol stack and the second protocol stack is achieved, that is, compatibility between the lightweight protocol stack and the second protocol stack is achieved.

[0074] In a specific implementation, the server 10 calls the socket interface of the user interface layer to create a target socket. Wherein, the target socket is a raw socket supporting EtherCAT, and the target socket is bound to a target channel address. Wherein, the target channel address is used to uniquely identify the communication channel of EtherCAT. Thus, the second protocol stack directly accesses the link layer of the first protocol stack through the communication channel corresponding to the target socket and the target channel address.

[0075] Specifically, the second protocol stack generates an EtherCAT protocol frame, calls the pre-created target socket, and sends the EtherCAT protocol frame to the driver layer through the first packet. The driver layer identifies and extracts the EtherCAT protocol frame in the first packet, sends the EtherCAT protocol frame as a complete packet to the network card, and then sends it to the Ethernet through the network card. The transmission frame is correctly transmitted to slave stations #1 to #n through the Ethernet.

[0076] The slave station generates a second packet and then sends the second packet to the driver layer through the Ethernet. The driver layer identifies the second packet and sends the second packet to the second protocol stack through the target socket.

[0077] Therefore, even if the operating system does not support raw socket, the server provided by the embodiments of the present application can still communicate with the second protocol stack through the socket of the first protocol stack, identify and process the EtherCAT protocol frames transmitted by the target socket through the driver layer, and send them to the slave station through the network card. That is to say, the operating system that does not support raw socket can also implement the transmission of the EtherCAT protocol and be compatible with the second protocol stack. Therefore, the application scope of the second protocol stack is improved.

[0078] Next, a data processing method provided by the embodiments of the present application will be introduced.

[0079] Appendix Figure 2A is a flowchart of a data processing method provided by the embodiments of the present application. This method is applied to Figure 1 the server 10 shown in the figure. This method includes the following steps:

[0080] S10. The server 10 creates a target socket.

[0081] The target socket is used to directly communicate between the second protocol stack and the driver layer of the first protocol stack. Specifically, the second protocol stack can send the generated EtherCAT protocol frames to the sending driver layer through the target socket, or receive the EtherCAT protocol frames sent by the driver layer through the target socket.

[0082] In the embodiments of the present application, the target socket is a raw socket that supports EtherCAT, and the target socket is bound to the target channel address. Among them, the target channel address is used to uniquely identify the EtherCAT communication channel and is bound when creating the target socket. Thus, the server 10 can transmit EtherCAT protocol frames through the target communication channel corresponding to the target channel address by calling the target socket.

[0083] In the embodiments of the present application, the target channel address can be a Media Access Control (MAC) address. For example, the target channel address is 00:1E:C0:01:02:03. It can also be a network card interface. For example, the target channel address is eth0:1, that is, the target channel address created based on the network card eth0. The target channel address can also be a channel address composed of a protocol type and a channel number. For example, the target channel address is EtherCAT:1, that is, the protocol type is EtherCAT and the channel number is 1. At this time, the format of the target channel address can also be other forms, such as a channel address composed of an IP address and a port number. The embodiments of the present application do not specifically limit it.

[0084] Further, the target channel address may also be an address allocated or used when transmitting data supported by the first protocol stack. For ease of description, the address allocated or used when transmitting data supported by the first protocol stack is referred to as the standard channel address. At this time, the target channel address corresponding to the target channel includes the user interface layer, the network layer, the transport layer, and the link layer of the first protocol stack, as well as the driver layer.

[0085] In addition, if the target channel address for transmitting EtherCAT protocol frames is the standard channel address, it may conflict with other addresses in the actual network. Therefore, in the embodiments of the present application, the target channel address is set as a virtual channel address. Among them, the virtual channel address is an address that will not be actually allocated or used when transmitting data supported by the first protocol stack, thereby ensuring that the target channel address does not conflict with other addresses in the actual network.

[0086] It can be understood that the target channel address provided by the embodiments of the present application may also be other addresses, and the embodiments of the present application do not specifically limit it. For ease of description, the following takes the target channel address as the MAC address as an example for illustrative purposes. In actual use, the target channel address may also be other addresses, which can be specifically adjusted according to needs, and the embodiments of the present application do not limit it.

[0087] It should be noted that the target channel address provided by the embodiments of the present application may be allocated by the operating system, or pre-configured by the user, or generated by other means, and the embodiments of the present application do not specifically limit it.

[0088] In addition, the embodiments of the present application can create a target socket through the socket interface of the user interface layer. Attached Figure 3 The following is a flowchart of a method for creating a target socket provided by the embodiments of the present application. The method includes the following steps:

[0089] S310. The server 10 obtains target parameters through the socket interface of the user interface layer.

[0090] Among them, the interface of the user interface layer is a function or a set of functions provided by the operating system, and developers can call the interface to set relevant parameters. In the embodiments of the present application, the interface of the user interface layer includes a socket interface for creating, configuring, and managing sockets. Specifically, developers can call the socket interface to set target parameters, thereby enabling the server 10 to create a target socket based on the target parameters. Among them, the target parameters indicate that the created socket is a raw socket that supports the EtherCAT protocol.

[0091] Further, the target parameters may also be a raw socket that supports PF-PACKET and supports the EtherCAT protocol. Among them, PF_PACKET is a special socket protocol family that allows user application programs to send and receive data frames at the link layer.

[0092] In one example, the socket interface is socket(), and the socket includes a socket parameter field where a developer can add a target parameter. Thus, server 10 can obtain the target parameter based on this socket.

[0093] In another example, the socket interface is Socket(), which includes a first field X, a second field Y, and a third field Z, i.e., socket(X, Y, Z). Here, X indicates the protocol family of the socket, that is, how the socket processes address information and underlying network protocols, Y indicates the socket type, and Z indicates the protocol type supported by the socket.

[0094] Exemplarily, if X is the first protocol family identifier, such as AF - INET, it indicates that the socket can use an IPv4 address for network communication. If X is the second protocol family identifier, such as AF_INET6, it indicates that the socket can use an IPv6 address for network communication. If X is the third protocol family identifier, such as PF - PACKET, it indicates that the protocol family of the socket is PF_PACKET. It should be noted that X can also be other protocol family identifiers, which are not specifically limited in the embodiments of this application.

[0095] Exemplarily, if Y is the first type identifier, such as the stream socket identifier, it indicates that the socket operation type is a connection - oriented socket. If Y is the second type identifier, such as the datagram socket identifier, it indicates that the socket operation type is a connectionless socket. If Y is the third type identifier, such as the raw socket identifier, it indicates that the socket is a raw socket. It should be noted that Y can also be other type identifiers, which are not specifically limited in the embodiments of this application.

[0096] Exemplarily, if Z is the first protocol identifier, such as 0, it indicates that the socket automatically selects a protocol according to the specified protocol family and socket operation type. If Z is the second protocol identifier, such as htons(ETH_P_ECAT), it indicates that the protocol supported by this socket is EtherCAT. It should be noted that Z can also be other protocol identifiers, which are not specifically limited in the embodiments of this application.

[0097] Among them, the developer sets X to the third protocol family identifier, Y to the third type identifier, and Z to the second protocol identifier to obtain the target parameter. For example, if X is set to PF_PACKET, Y is set to SOCK_RAW, and Z is set to htons(ETH_P_ECAT), it indicates that the socket interface obtains the target parameter, and the target parameter is a raw socket that supports PF - PACKET and the EtherCAT protocol.

[0098] It should be noted that the above socket interface is only for illustrative purposes. In actual use, it can also be in other formats. For example, socket(int X, int Y, int Z), that is, the socket interface specifies that the type of each variable is an integer type, which is not specifically limited in the embodiments of the present application.

[0099] In the embodiments of the present application, the target parameter can also be obtained in other ways, which is not specifically limited in the embodiments of the present application.

[0100] S320. The server 10 creates a target socket according to the target parameter.

[0101] The server 10 is specifically the kernel of the server 10. According to the target parameter, a target socket is created. Exemplarily, if the target parameter is PF_PACKET and the raw socket supporting EtherCAT is available, the created socket, for example, the identifier of the created socket is *psock, then:

[0102] *psock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ECAT))

[0103] S330. The server 10 binds the target socket to the target channel address.

[0104] The server 10 binds the target socket to the target channel address. Exemplarily, the server 10 can call an address binding function, such as calling a function named bind(), to bind the target socket to the target channel address.

[0105] S340. The server 10 returns the identifier of the target socket to the second protocol stack.

[0106] Exemplarily, the identifier of the socket created by the server 10 is *psock, and the server returns the socket identifier *psock to the second protocol stack. Thus, the second protocol stack can use *psock to obtain the target socket and receive or send EtherCAT protocol frames.

[0107] In actual use, when the server 10 creates a socket, it is not certain whether the obtained socket parameters are target parameters. To improve the creation accuracy of the target socket, the server 10 judges the created socket. If it meets the target parameters, the created socket is considered as the target socket. The following will be described in detail with reference to the attached Figure 4 for detailed description.

[0108] Attached Figure 4 is a flowchart of another method for creating a target socket provided by the embodiments of the present application. The method includes the following steps:

[0109] S410. The server 10 obtains socket parameters through the socket interface of the user interface layer.

[0110] In the embodiment of the present application, the socket parameters may be target parameters or may not be target parameters, which are specifically adjusted according to needs. The socket parameters indicate whether the created socket is a target socket.

[0111] S420. The server 10 creates an initial socket according to the socket parameters.

[0112] S430. The server 10 determines whether the initial socket is a raw socket that supports the EtherCAT protocol. If so, S440 is executed.

[0113] In a specific implementation, the server 10 uses the socket parameters of the initial socket to determine whether the initial socket is a raw socket that supports the EtherCAT protocol. Specifically, if the socket parameters are target parameters, it is determined that the initial socket is a raw socket that supports the EtherCAT protocol.

[0114] Exemplarily, if the socket parameters include a first parameter, a second parameter, and a third parameter. The first parameter is PF_PACKET, the second parameter is the raw socket identifier (for example, SOCK_RAW), and the third parameter is the EtherCAT protocol support identifier (for example, htons(ETH_P_ECAT)). The server 10 can determine that the initial socket is a raw socket that supports the EtherCAI protocol, and this socket is a raw socket that supports the PF_PACKET protocol family.

[0115] S440. The server 10 modifies the first identifier of the initial socket to the second identifier.

[0116] Wherein the first identifier is the identifier of the initial socket, and the second identifier is the identifier of the target socket. Thus, the second protocol stack can obtain the target socket according to the second identifier.

[0117] It should be noted that the first identifier is different from the second identifier.

[0118] After the server 10 determines that the initial socket is a raw socket that supports the EtherCAT protocol, it modifies the first identifier to the second identifier. Exemplarily, the first identifier is *psock, and the second identifier is PF-INET raw socket. If the initial socket is a raw socket that supports the EtherCAT protocol, *psock is modified to PF-INET raw socket.

[0119] S450. The server 10 processes the attribute information of the socket after the identifier is modified to obtain the target socket.

[0120] Server 10 processes according to the default process of the first protocol stack, processes the attribute information of the initial socket after the modification flag is set, and obtains a target socket. Among them, the target socket can be compatible with the first protocol stack, be correctly recognized and managed by the first protocol stack, so as to realize the correct network communication function.

[0121] Among them, the attribute information of the socket indicates the information related to network communication of the socket, including but not limited to: blocking model, receive buffer size, registered callback function, interface, etc.

[0122] The default processing process of the first protocol stack includes multiple steps, and the default processing processes of different first protocol stacks are different. Here, taking the LWIP protocol stack as an example of the first protocol stack, a schematic description is given.

[0123] The default processing process of LWIP, that is, the LWIP default process, includes but is not limited to the following processes:

[0124] ① Server 10 initializes and configures the socket to ensure that the socket is correctly recognized and managed by the LWIP protocol stack. For example, Server 10 sets various attributes of the socket, including but not limited to the blocking mode, the size of the receive buffer, etc. Also, for example, register a callback function to respond in a timely manner when a network event (such as a packet arrives or a connection is disconnected, etc.) occurs.

[0125] ② Server 10 adds the configured socket to the event loop of LWIP to ensure that the socket can receive and send data.

[0126] ③ Server 10 provides a unified interface, so that the second protocol stack can conveniently use the socket for data transmission. For example, the interface includes operations such as sending, interfacing, connecting, etc.

[0127] Thus, through the processing of the above LWIP default process, the socket can be compatible with the existing network protocol stack (LWIP protocol stack), and can be normally obtained and recognized by the driver layer.

[0128] S460. Server 10 binds the target socket to the target channel address.

[0129] When the initial socket is a raw socket that supports the EtherCAT protocol, Server 10 will bind the target channel address to this socket. Exemplarily, Server 10 can call an address binding function, for example, call a function named bind(), to bind this socket to the target channel address.

[0130] It should be noted that step S460 and S450 can be executed simultaneously, or S460 can be executed first and then S450, or S450 can be executed first and then S460. The embodiments of the present application do not specifically limit this.

[0131] Further, if the initial socket is a raw socket that does not support the EtherCAT protocol, or the initial socket is not a raw socket, it is processed according to the default process of the first protocol stack, and the attribute information of the initial socket is processed to obtain a standard socket. Among them, the standard socket is a socket that communicates according to the protocol of the first protocol stack.

[0132] S470. The server 10 sends the created socket identifier to the application layer.

[0133] Among them, if the socket obtained by the server 10 is a target socket, the target socket identifier (i.e., the second identifier) is sent to the second protocol stack, so that the second protocol stack can directly access the EtherCAT protocol frame based on the target socket.

[0134] Further, if the obtained socket is a standard socket, the identifier of the standard socket (i.e., the first identifier) is returned to the corresponding application program, so that the application program can call the standard socket to perform communication of the standard protocol. Thus, the server 10 can ensure that the created target socket is compatible with the first protocol stack and does not affect the network communication of the first protocol stack.

[0135] The embodiment of the present application can also create a target socket in other ways, and the embodiment of the present application does not specifically limit it.

[0136] The server can send the data of the EtherCAT protocol stack to the slave station based on the target socket. Specifically, refer to S20~S40 shown.

[0137] S20. The server 10 obtains a first message through the target socket.

[0138] The first message includes an EtherCAT protocol frame generated by the second protocol stack. Specifically, the second protocol stack generates an EtherCAT protocol stack and sends the EtherCAT protocol stack to the server 10 in the form of the first message. Exemplarily, the first message is sent to the driver layer of the server 10.

[0139] The EtherCAT protocol frame includes an outer Ethernet header information and inner layer data. To distinguish the Ethernet header information added by the link layer of the first protocol stack described below, the Ethernet header information of the EtherCAT protocol stack is called the first Ethernet header information. Among them, the first Ethernet header information includes the recipient address, the sender address, and the identified protocol type.

[0140] Exemplarily, the first Ethernet header information includes a destination MAC address field, a source MAC address field, and a protocol type field (i.e., EtherType). The second protocol stack adds a first destination MAC address to the destination MAC address field. Among them, the first destination MAC address is the address for receiving the EtherCAT protocol frame. In the embodiments of the present application, the first destination MAC address is the MAC address of the slave station. The first source MAC address is added to the source MAC address field. The first source MAC address is the address for sending the EtherCAT protocol frame. In the embodiments of the present application, the first source MAC address can be the MAC address of the EtherCAT master station. A fixed value (e.g., 0x88A4) is added to the protocol type field to indicate that this frame is an EtherCAT protocol frame.

[0141] The inner-layer data includes actual communication data. For example, the inner-layer data includes the data requested to be read, or the data or control instructions that may be written.

[0142] In a specific embodiment, the second protocol stack can send the EtherCAT protocol frame to the first protocol stack through the target socket. Specifically, the second protocol stack sends the EtherCAT protocol frame to the link layer of the first protocol stack, and the EtherCAT protocol frame is encapsulated at the link layer to obtain the first packet. The link layer of the first protocol stack sends the first packet to the driver layer of the first protocol stack. Thus, it can be ensured that the EtherCAT protocol frame is correctly delivered to the driver layer.

[0143] Exemplarily, if the first protocol stack is the LWIP protocol stack, the LWIP protocol stack encapsulates the EtherCAT protocol frame at the link layer and adds Ethernet header information to obtain the first packet. Among them, this Ethernet header information is called the second Ethernet header information. In the embodiments of the present application, the second Ethernet header information includes the target channel address (the second destination MAC address), the source MAC address, and the protocol type. The first protocol stack sends the first packet to the driver layer. For example, if the target channel address is a virtual MAC address, specifically 00:00:5E:00:53, the source MAC address (i.e., the first source MAC address) is 01:01:01:01:01, and the protocol type is 0x88A4, the EtherCAT protocol frame is:

[0144] {The first Ethernet header:

[0145] The first destination MAC address: 00:1A:2B:3C:4D:5E

[0146] The source MAC address: 01:01:01:01:01

[0147] The protocol type: 0x88, 0xA4

[0148] EtherCAT data:

[0149] 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x01,0x02,0x03,0x04

[0150] }

[0151] Then the first message formed is:

[0152] {Second Ethernet header:

[0153] Second destination MAC address: 00:00:5E:00:53

[0154] Source MAC address: 01:01:01:01:01

[0155] Protocol type: 0x88, 0xA4

[0156] EtherCAT data:

[0157] EtherCAT protocol frame

[0158] }

[0159] It should be noted that in the embodiments of the present application, the EtherCAT protocol frame can be generated first, then the target socket can be created, and the EtherCAT protocol frame can be sent using the created target socket. The target socket can also be created in advance at startup. The embodiments of the present application do not specifically limit this.

[0160] S30. The server 10 extracts the EtherCAT protocol frame of the first message.

[0161] In one implementation, after the driver layer of the server 10 receives the first message, it extracts the EtherCAT protocol frame in the first message and uses the EtherCAT protocol frame as a new message to send it to the EtherCAT slave device through the network card.

[0162] Exemplarily, for example, the first message includes an outer protocol header and an inner EtherCAT frame, specifically:

[0163] {Second Ethernet header:

[0164] Second destination MAC address: 00:00:5E:00:53

[0165] Source MAC address: 01:01:01:01:01

[0166] Protocol type: 0x88, 0xA4

[0167] EtherCAT data:

[0168] EtherCAT protocol frame

[0169] }

[0170] Among them, the outer protocol header includes the destination

[0171] channel address, specifically 00:00:5E:00:53, the source MAC address is 01:01:01:01:01, and the protocol type is 0x88A4. The driver layer extracts the EtherCAT protocol frame.

[0172] In a specific embodiment, the driver layer strips the outer protocol header of the first packet to obtain the EtherCAT protocol frame.

[0173] S40. The server 10 sends the EtherCAT protocol frame to the slave station through the network card.

[0174] Exemplarily, the extracted EtherCAT protocol frame is:

[0175] {First Ethernet header:

[0176] Destination MAC address: 00:1A:2B:3C:4D:5E

[0177] Source MAC address: 01:01:01:01:01

[0178] Protocol type: 0x88, 0xA4

[0179] EtherCAT data:

[0180] 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x01,0x02,0x03,0x04

[0181] }

[0182] The server 10 can send the EtherCAT protocol frame as a complete packet to the slave station through the network card.

[0183] Thus, the EtherCAT master protocol stack can directly interact with the LWIP protocol stack, send the EtherCAT protocol frame to the slave station through the LWIP protocol stack and the network card, thereby realizing the compatibility between the EtherCAT master protocol stack and the LWIP protocol stack.

[0184] Furthermore, attach Figure 2B . This method is applied after S10, and this method includes the following content:

[0185] S50. The server 10 receives the second message sent by the slave station through the network card.

[0186] The second message is a message that supports the EtherCAT protocol. It is generated by the slave station and sent to the server 10 through the network card. The second message includes an Ethernet header and response frame data. For example, the second message is as follows:

[0187] {Ethernet header:

[0188] Destination MAC address: 01:01:01:01:01

[0189] Source MAC address: 00:1A:2B:3C:4D:5E

[0190] Protocol type: 0x88, 0xA4

[0191] EtherCAT data:

[0192] 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x01,0x02,0x03,0x04

[0193] }

[0194] S60. The server 10 identifies the second message and sends it through the target socket.

[0195] Exemplarily, after the server 10 obtains the second message sent by the network card at the driver layer, it encapsulates the second message into a target channel message for correct identification by the first protocol stack. In one example, the target channel message can be correctly identified by the link layer of the first protocol stack. The outer layer of the target channel message is Ethernet header information, and the inner layer is the second message. Among them, the destination MAC address of the Ethernet header information is the target channel address, the source MAC address is the MAC address of the slave station, and the protocol type is the identifier that supports EtherCAT, specifically 0x88A4.

[0196] Exemplary illustration is as follows. The following is the second message:

[0197] {Ethernet header:

[0198] Destination MAC address: 00:1A:2B:3C:4D:5E

[0199] Source MAC address: 08:00:27:0F:0E:1D

[0200] Protocol type: 0x88A4 (EtherCAT)

[0201] EtherCAT frame header:

[0202] Frame type: Read data frame

[0203] Command: Read data

[0204] Data length: 16 bytes

[0205] EtherCAT data:

[0206] 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x01,0x02,0x03,0x04

[0207] }

[0208] If the target channel address is 00:00:5E:00:53

[0209] Then the target channel message is:

[0210] {Ethernet header:

[0211] Destination MAC address: 00:00:5E:00:53

[0212] Source MAC address: 08:00:27:0F:0E:1D

[0213] Protocol type: 0x88A4 (EtherCAT)

[0214] EtherCAT data:

[0215] Ethernet header:

[0216] Destination MAC address: 00:1A:2B:3C:4D:5E

[0217] Source MAC address: 08:00:27:0F:0E:1D

[0218] Protocol type: 0x88A4 (EtherCAT)

[0219] EtherCAT frame header:

[0220] Frame type: Read data frame

[0221] Command: Read data

[0222] Data length: 16 bytes

[0223] EtherCAT data:

[0224] 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x01,0x02,0x03,0x04

[0225] }

[0226] The server 10 can send the target channel message to the link layer of the second protocol stack. The second protocol stack unpacks the target channel message and sends the unpacked second message to the second protocol stack through the target socket.

[0227] In summary, through the above data processing method, the compatibility between the first protocol stack and the second protocol stack can be achieved, and the data interaction between the first protocol stack and the second protocol stack can be realized.

[0228] In summary, even if the operating system provided by the embodiment of the present application does not support raw socket, the operating system can still communicate with the second protocol stack through the target socket created by the user interface layer, identify and process the EtherCAT message transmitted by the target socket through the driver layer, send the EtherCAT frame in the message to the slave device through the network card, and can identify and process the EtherCAT protocol message sent by the network card through the driver layer, and send the EtherCAT protocol message to the second protocol stack. That is to say, the operating system that does not support raw socket can also implement the transmission of the EtherCAT protocol and be compatible with the second protocol stack. In summary, the embodiment of the application creates a socket through the user interface layer and adds an identification and processing mechanism through the driver layer, thereby expanding the application scope of the second protocol stack.

[0229] Furthermore, the server 10 not only adds an identification mechanism and a channel processing mechanism in the driver layer, but also realizes the compatibility with the second protocol stack without affecting the transmission of other actual network data.

[0230] Appendix Figure 5A , this method is applied after S10, and this method includes the following steps:

[0231] S510. The server obtains the first transmission message.

[0232] The first transmission message indicates a message sent by the second protocol stack or other application programs through the socket.

[0233] S520. The server determines whether the first transmission message is the first message. If so, execute S530.

[0234] If the server obtains the first transmission message through the target socket, then the first transmission message is the first message; otherwise, the first transmission message is not the first message.

[0235] If the first transmitted message is the first message, when the first protocol stack is the LWIP protocol stack, the first message from the outer layer to the inner layer is: Ethernet header information and EtherCAT protocol frame. If the first transmitted message is not the first message, the first transmitted message from the outer layer to the inner layer is: Ethernet header information, IP header information, TCP / UDP header information, and data frame.

[0236] Specifically, the driver layer of the server adds an identification mechanism. After receiving the first transmitted message, the driver layer can determine whether the destination MAC address in the Ethernet header of the first transmitted message is the target channel address. If the destination MAC address is the target channel address, the driver layer determines that the received first transmitted message is the first message; otherwise, the determination layer determines that the first transmitted message is not the first message.

[0237] In a specific implementation, if the first transmitted message is not the first message, it is processed according to the normal process of the first protocol stack.

[0238] S530. The server strips the outer channel to obtain the EtherCAT protocol frame in the first transmitted message.

[0239] Specifically, the driver layer of the server adds a message processing mechanism. After the driver layer determines that the transmission is the first message, it extracts the EtherCAT protocol frame in the first transmitted message. The specific extraction method is to strip the outer channel of the first transmitted message. Among them, the outer other channel is the Ethernet header information, specifically, strip the Ethernet header information and extract the EtherCAT protocol frame. As described in step S20, it will not be elaborated here.

[0240] S540. The server sends the EtherCAT protocol frame to the slave station through the network card.

[0241] Specifically, the driver layer of the server sends the EtherCAT protocol frame to the slave station through the network card.

[0242] Further, as shown in the appendix Figure 5B shown is another flowchart of the data processing method provided by the embodiment of the present application. The method includes the following content:

[0243] S511. The server obtains a second transmitted message.

[0244] The second transmitted message indicates the message sent to the server through the network card.

[0245] In the embodiment of the present application, the driver layer of the server receives the second transmitted message through the network card.

[0246] S521. The server determines whether the second transmitted message is the second message. If so, execute S531.

[0247] In one implementation, an identification mechanism is added to the driver layer of the server to identify whether the second transmitted message is the second message. The driver layer is used to determine whether the protocol type of the second transmitted message is the EtherCAT protocol. If so, it is determined that the second transmitted message is the second message; otherwise, it is determined that the second transmitted message is not the second message.

[0248] In a specific implementation, if the second transmitted message is not the second message, it is processed according to the normal process of the first protocol stack.

[0249] S531. The server adds an outer channel to the second transmitted message to obtain a target channel message.

[0250] Specifically, the driver layer of the server includes a processing mechanism for adding an outer channel to the second transmitted message, that is, adding Ethernet header information to obtain a target channel message. Among them, the Ethernet header information added at this time includes the destination MAC address as the target channel address, the source MAC address as the sender address of the response message, and the protocol type as EtherCAT. The inner layer of the target channel message is the information of the second message.

[0251] S541. The server sends the target channel message to the first protocol stack.

[0252] Specifically, the driver layer of the server sends the target channel message to the link layer of the first protocol stack.

[0253] S551. The server performs de - message processing on the target channel message at the link layer of the first protocol stack to obtain the second message.

[0254] The server performs de - message processing on the target channel message at the link layer of the first protocol stack, extracts the second message information, and obtains the second message.

[0255] S561. The server directly sends the second message to the second protocol stack through the target socket.

[0256] The data processing method provided by the embodiment of the present application realizes compatibility with the second protocol stack without affecting the transmission of other actual network data by adding an identification mechanism and a channel processing mechanism to the driver layer.

[0257] It should be noted that the server provided by the embodiment of the present application can be an embedded device. For example, the system running on this server is a Linux and Windows system that SOME does not support. In addition, in the embodiment of the present application, SOME and LWIP can be combined and applied to more types of embedded platforms, such as RISC - V, ESP32, etc. This can not only expand the application range of SOEM but also meet the real - time communication requirements under different hardware architectures.

[0258] Further, an embodiment of the present application further provides a data processing device, which is applied to a processor. The processor includes a first protocol stack and a second protocol stack, and the first protocol stack communicates with the second protocol stack through a target socket.

[0259] Appendix Figure 6 FIG. 5 is a schematic structural diagram of a data processing device provided by an embodiment of the present application. The device 600 includes:

[0260] An obtaining unit 601, configured to obtain a first message of the second protocol stack through the target socket;

[0261] An analyzing unit 602, configured to obtain an EtherCAT protocol frame of the first message through the first protocol stack according to the first message;

[0262] A sending unit 603, configured to send the EtherCAT protocol frame through the first protocol stack.

[0263] Optionally, the analyzing unit 602 is specifically configured to: remove an outer protocol header of the first message through the first protocol stack to obtain an EtherCAT protocol frame. The outer protocol header includes a target channel address, a source media access control (MAC) address, and a protocol type; the target channel address is connected to the target socket and is used to indicate a channel address for transmitting the first message.

[0264] Optionally, the device 600 further includes a receiving unit, and the receiving unit is specifically configured to:

[0265] Obtain a second message through the first protocol stack; if the second message is a message of the second protocol stack, encapsulate the second message into a target channel message; send the target channel message to the second protocol stack through the target socket; wherein, the target channel message is a message that can be sent through the target socket.

[0266] Optionally, encapsulating the second message into a target channel message includes:

[0267] Adding an outer protocol header to the second message to obtain a target channel message. The outer protocol header includes a target channel address, a source MAC address, and a protocol type; the target channel address is connected to the target socket and is used to indicate a channel address for transmitting the target channel message.

[0268] Further, the device 600 further includes a creating unit, and the creating unit is specifically configured to: call a socket interface to obtain target parameters, where the target parameters indicate to create a raw socket that supports the EtherCAT protocol; create a target socket according to the target parameters, and bind the created target socket to the target channel address; send the first message to the first protocol stack through the target channel address.

[0269] The creating unit is further configured to:

[0270] Create an initial socket according to the target parameters; adjust the identifier of the initial socket to the identifier of the target socket, and process the attribute information of the adjusted socket to obtain the target socket, which is compatible with the first protocol stack.

[0271] Optionally, if the socket interface includes a first parameter, a second parameter, and a third parameter, the first parameter is used to indicate the protocol family supported by the created socket, the second parameter is used to indicate the type of the created socket, and the third parameter is used to indicate the protocol supported by the created socket. If the first parameter is the identifier indicating that the protocol family supported by the socket is PF_PACKET, the second parameter is the raw socket identifier, and the third parameter is the identifier indicating support for the EtherCAT protocol, the obtained parameter is the target parameter.

[0272] Among them, the first protocol stack is the Lightweight Internet Protocol (LWIP) stack, and the second protocol stack is the EtherCAT protocol stack.

[0273] The embodiments of the present application also provide a computer program product containing instructions. The computer program product can be software or a program product containing instructions that can run on a computing device or be stored in any available medium. When the computer program product runs on a computing device, it causes the computing device to execute the above data processing method. The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computing device can store or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid-state drive), etc. The computer-readable storage medium includes instructions that direct the computing device to execute the above data processing method.

[0274] The descriptions of the processes or structures corresponding to the above respective drawings have their own focuses. For parts not detailed in a certain process or structure, reference can be made to the relevant descriptions of other processes or structures.

[0275] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A data processing method, characterized in that, Applied to a processor, the processor includes a first protocol stack and a second protocol stack, and the first protocol stack communicates with the second protocol stack through a target socket. The method includes: Obtain a first message of the second protocol stack through the target socket; According to the first message, obtain an EtherCAT protocol frame of the first message through the first protocol stack; Send the EtherCAT protocol frame through the first protocol stack.

2. The method according to claim 1, characterized in that, The obtaining the EtherCAT protocol frame of the first message according to the first message and through the first protocol stack includes: Through the first protocol stack, remove the outer protocol header of the first message to obtain the EtherCAT protocol frame. The outer protocol header includes a target channel address, a source media access control (MAC) address, and a protocol type; the target channel address is connected to the target socket and is used to indicate the channel address for transmitting the first message.

3. The method according to claim 1, wherein The method further includes: Obtain a second message through the first protocol stack; If the second message is a message of the second protocol stack, encapsulate the second message into a target channel message; Send the target channel message to the second protocol stack through the target socket; Wherein, the target channel message is a message that can be sent through the target socket.

4. The method according to claim 3, characterized in that, The encapsulating the second message into a target channel message includes: Add an outer protocol header to the second message to obtain the target channel message. The outer protocol header includes a target channel address, a source MAC address, and a protocol type; the target channel address is connected to the target socket and is used to indicate the channel address for transmitting the target channel message.

5. The method according to claim 1, characterized in that, Before obtaining the first message of the second protocol stack through the target socket, the method further includes: Call a socket interface to obtain target parameters, where the target parameters indicate creating a raw socket that supports the EtherCAT protocol; according to the target parameters, create the target socket and bind the created target socket to a target channel address; After obtaining the first message of the second protocol stack through the target socket, the method further includes: Send the first message to the first protocol stack through the target channel address.

6. The method according to claim 5, wherein The creating the target socket according to the target parameters includes: Create an initial socket according to the target parameters; Adjust the identifier of the initial socket to the identifier of the target socket, and process the attribute information of the adjusted socket to obtain the target socket, and the target socket is compatible with the first protocol stack.

7. The method according to claim 5, characterized in that If the socket interface includes a first parameter, a second parameter, and a third parameter, where the first parameter is used to indicate the protocol family supported by the created socket, the second parameter is used to indicate the type of the created socket, and the third parameter is used to indicate the protocol supported by the created socket, the calling the socket interface to obtain target parameters includes: Invoke the socket interface. If the first parameter is an identifier indicating that the protocol family supported by the socket is PF_PACKET, the second parameter is the raw socket identifier, and the third parameter is an identifier supporting the EtherCAT protocol, obtain the target parameter.

8. The method according to claim 3, wherein The first protocol stack is the lightweight Internet protocol LWIP protocol stack, and the second protocol stack is the EtherCAT protocol stack.

9. A data processing device, characterized in that, Applied to a processor, the processor includes a first protocol stack and a second protocol stack, and the first protocol stack communicates with the second protocol stack through a target socket. The device includes: An acquisition unit, configured to acquire a first message of the second protocol stack through the target socket; An analysis unit, configured to obtain an EtherCAT protocol frame of the first message according to the first message and through the first protocol stack; A sending unit, configured to send the EtherCAT protocol frame through the first protocol stack.

10. A computing device, characterized in that, Includes a processor and a memory, and the processor is coupled to the memory; The memory is used to store a program; The processor is configured to execute the program stored in the memory. When the program stored in the memory is executed, the processor is configured to execute the method according to any one of claims 1-8.