Interface data forwarding method and device, equipment and storage medium

By storing and forwarding interface data in shared memory in kernel space and directly sending configuration parameters to the target interface, the resource overhead problem during data forwarding between different interfaces is solved, and efficient interface data forwarding is achieved.

CN119759614APending Publication Date: 2025-04-04KYLAND TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411928179.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

When forwarding data between different interfaces, the prior art requires frequent transfer of data between kernel space and application space, resulting in high resource overhead.

Method used

By setting shared memory in the kernel space, storing and forwarding interface data, and directly sending data to the target interface using configuration parameters, reducing the number of data transfers between the kernel space and the application space.

Benefits of technology

It improves the efficiency of forwarding interface data, reduces unnecessary resource overhead, and realizes efficient data forwarding between different interfaces.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759614A_ABST
    Figure CN119759614A_ABST
Patent Text Reader

Abstract

The invention relates to an interface data forwarding method and device, equipment and a storage medium. According to the scheme, after the to-be-forwarded interface data is obtained from the initial interface, the interface data is stored in the shared memory of the kernel space, and at least one target interface corresponding to the initial interface and the configuration parameters corresponding to the target interfaces are determined; sending the interface data to the corresponding target interfaces through the configuration parameters; visibly, when the interface data is forwarded, the interface data does not need to be transferred back and forth between the kernel space and the application space, and only the interface data needs to be stored in the shared memory of the kernel space, so that the interface data can be sent to the corresponding target interface by utilizing the configuration parameters; and the number of times of transferring the data between the kernel space and the application space is reduced, so that the forwarding efficiency of the interface data is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data forwarding, and in particular to a method, device, equipment and storage medium for forwarding interface data. Background Art

[0002] At present, when different interfaces forward data, the conventional practice is to implement drivers in the kernel space, such as: IIC (Inter-Integrated Circuit) driver, SPI (Serial Peripheral Interface) driver, etc. After receiving the data of the corresponding interface, the driver transmits the data to the application layer, and then performs protocol conversion on the data in the user layer, and passes the converted data to the corresponding driver, and finally transmits it through hardware. This data forwarding method requires data to be transferred between the kernel space and the application space, which brings unnecessary resource overhead.

[0003] Therefore, how to reduce the number of data transfers between the kernel space and the application space when forwarding data between different interfaces is a problem that needs to be solved by those skilled in the art. Summary of the invention

[0004] The present application provides a method, apparatus, device and storage medium for forwarding interface data, so as to reduce the number of data transfers between kernel space and application space when forwarding data between different interfaces.

[0005] In a first aspect, the present application provides a method for forwarding interface data, comprising:

[0006] Acquire interface data to be forwarded; the interface data is data acquired from the initial interface;

[0007] storing the interface data in a shared memory of a kernel space;

[0008] Determine at least one target interface corresponding to the initial interface, and configuration parameters corresponding to each target interface;

[0009] The interface data is sent to the corresponding target interface through each configuration parameter.

[0010] Optionally, if the initial interface is a hardware interface or a real device interface, after obtaining the interface data to be forwarded, the method further includes:

[0011] Determine whether the interface data needs to be forwarded;

[0012] If yes, execute the step of storing the interface data in the shared memory of the kernel space; if no, send the interface data of the hardware interface directly to the corresponding real device interface, or send the interface data of the real device interface directly to the corresponding hardware interface.

[0013] Optionally, determining whether the interface data needs to be forwarded includes:

[0014] Determine a value of a forwarding flag bit corresponding to the initial interface;

[0015] Determine whether the interface data needs to be forwarded according to the value.

[0016] Optionally, if the initial interface is a hardware interface, the target interface includes: at least one virtual device interface, and / or, at least one hardware interface; if the initial interface is a virtual device interface, the target interface includes: at least one hardware interface.

[0017] Optionally, if the initial interface is a hardware interface, the target interface includes: at least one real device interface, and / or, at least one hardware interface; if the initial interface is a real device interface, the target interface includes: at least one hardware interface.

[0018] Optionally, before obtaining the interface data to be forwarded, the method further includes:

[0019] Setting a configuration file in the application space; the configuration file includes: an initial interface, a target interface, and configuration parameters corresponding to each target interface;

[0020] The configuration information in the shared memory is updated using the configuration file.

[0021] Optionally, determining at least one target interface corresponding to the initial interface and configuration parameters corresponding to each target interface includes:

[0022] Determine a target interface corresponding to the initial interface from the configuration information; wherein the number of the target interface is at least one;

[0023] Configuration parameters corresponding to each target interface are determined from the configuration information.

[0024] In a second aspect, the present application provides a device for forwarding interface data, including:

[0025] An acquisition module, used to acquire interface data to be forwarded; the interface data is data acquired from an initial interface;

[0026] A storage module, used for storing the interface data in a shared memory of a kernel space;

[0027] A determination module, used to determine at least one target interface corresponding to the initial interface, and configuration parameters corresponding to each target interface;

[0028] The first sending module is used to send the interface data to the corresponding target interface through various configuration parameters.

[0029] In a third aspect, the present application provides an electronic device, including:

[0030] A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the steps of the forwarding method described above in the present application through the computer program.

[0031] In a fourth aspect, the present application also provides a computer storage medium, which stores computer executable instructions, and the computer executable instructions are used to execute the steps of the above-mentioned forwarding method of the present application.

[0032] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the present application discloses a forwarding solution for interface data. After the solution obtains the interface data to be forwarded from the initial interface, the interface data will be stored in the shared memory of the kernel space, and at least one target interface corresponding to the initial interface and the configuration parameters corresponding to each target interface will be determined; the interface data will be sent to the corresponding target interface through each configuration parameter; it can be seen that when forwarding interface data, the present application does not need to transfer the interface data back and forth between the kernel space and the application space. It only needs to store the interface data in the shared memory of the kernel space, and then the configuration parameters can be used to send the interface data to the corresponding target interface, thereby reducing the number of data transfers between the kernel space and the application space, thereby improving the forwarding efficiency of the interface data. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0035] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0036] Figure 1 A flow chart of a method for forwarding interface data provided in an embodiment of the present application;

[0037] Figure 2 A flow chart of another method for forwarding interface data provided in an embodiment of the present application;

[0038] Figure 3 A schematic diagram of data forwarding provided in an embodiment of the present application;

[0039] Figure 4 Another data forwarding schematic diagram provided in an embodiment of the present application;

[0040] Figure 5 A flow chart of another method for forwarding interface data provided in an embodiment of the present application;

[0041] Figure 6 A schematic diagram of a configuration file mapping process provided in an embodiment of the present application;

[0042] Figure 7 A data forwarding flow chart provided in an embodiment of the present application;

[0043] Figure 8 Another data forwarding flow chart provided in an embodiment of the present application;

[0044] Fig. 9 A schematic diagram of the structure of a device for forwarding interface data provided in an embodiment of the present application;

[0045] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0046] In the prior art, when different interfaces are forwarding data, the driver needs to transfer the data from the kernel space to the application space for protocol conversion, and then transfer the converted data from the application space to the kernel space, which brings unnecessary resource overhead.

[0047] For example: in the Linux operating system, after receiving data using a serial port device, the data needs to be sent out from the CAN (Controller Area Network) port. At this time, the serial port driver needs to send the data from the kernel space to the application space, convert the data into CAN port data, set the relevant parameters of the CAN device interface, send it from the application space to the kernel space, and then send it to the CAN device interface.

[0048] In other related technologies, the data flow can be redirected by using pipes in the Linux operating system, or data can be transmitted through DMA (Direct Memory Access) to improve data transmission efficiency. However, these solutions can only be used for communication between single interfaces and cannot achieve conversion between multiple types of data protocols.

[0049] Therefore, in an embodiment of the present application, a method, apparatus, device and storage medium for forwarding interface data are provided to reduce the number of data transfers between kernel space and application space when forwarding data between different interfaces.

[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0051] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0052] See also Figure 1 , is a flow chart of a method for forwarding interface data provided in an embodiment of the present application, the method specifically comprising:

[0053] S101, obtaining interface data to be forwarded; the interface data is data obtained from the initial interface;

[0054] In this application, the interface data is data obtained from the initial interface and needs to be forwarded to the target interface. The interface data can be obtained from the initial interface through the driver in the kernel. For example, if the initial interface is a serial port, the interface data to be forwarded needs to be obtained from the serial port through the serial port driver.

[0055] S102, storing the interface data in the shared memory of the kernel space;

[0056] In the present application, a shared memory is set up in the kernel space. When each interface needs to forward interface data, the interface data needs to be stored in the shared memory so that the interface data to be forwarded can be directly forwarded and processed in the kernel space. There is no need to forward the interface data from the kernel space to the application space for processing, and then forward it to the kernel space to send it to the target interface, thereby reducing the number of times the interface data is switched between the application space and the kernel space and improving system performance.

[0057] S103, determining at least one target interface corresponding to the initial interface, and configuration parameters corresponding to each target interface;

[0058] In this embodiment, the target interface to which the interface data needs to be forwarded can be one or more, which is not specifically limited here. In this way, the interface data can be forwarded to multiple interfaces at the same time, thereby improving the data forwarding efficiency; and, since different target interfaces have different sending protocols, different configuration parameters need to be configured for different target interfaces, which may include: bit rate, baud rate, data bit, etc., which are not specifically limited here. When determining the target interface and the corresponding configuration parameters, the present application can determine them in a variety of ways, for example: the target interface and configuration parameters to be forwarded can be obtained from the interface data, or the target interface and configuration parameters to be forwarded can be found in the pre-set configuration information, which is not specifically limited here.

[0059] S104: Send the interface data to the corresponding target interface through various configuration parameters.

[0060] In the present application, after determining the target interface and the corresponding configuration data, the interface data can be sent to the corresponding target interface through the configuration data. For example: after obtaining the interface data from the serial port device, if the interface data needs to be sent out from the CAN port, then in the prior art, the interface data needs to be transferred from the kernel space to the application space, and after the configuration parameters are determined in the application space, the interface data is transferred from the application space to the kernel space using the configuration parameters, and then sent to the CAN interface. In the present solution, after obtaining the interface data from the serial port device, it is not necessary to transfer the interface data from the kernel space to the application space, but only to store the interface data in the shared memory of the kernel space, and then after determining the configuration parameters corresponding to the CAN port, the interface data can be sent directly to the CAN interface using the configuration parameters.

[0061] From the above, it can be seen that when the target interface data is transferred, the present application does not need to transfer the interface data back and forth between the kernel space and the application space. It only needs to store the interface data in the shared memory of the kernel space, and then use the configuration parameters to send the interface data to the corresponding target interface, thereby reducing the number of data transfers between the kernel space and the application space, thereby improving the forwarding efficiency of the interface data.

[0062] See also Figure 2 , is a flow chart of another method for forwarding interface data provided in an embodiment of the present application, the method specifically comprising:

[0063] S201, acquiring interface data to be forwarded from an initial interface; if the initial interface is a hardware interface or a real device interface, executing S202; if the initial interface is a virtual device interface, executing S204;

[0064] S202, determining whether the interface data needs to be forwarded;

[0065] If not, execute S203; if yes, execute S204;

[0066] S203, directly sending the interface data of the hardware interface to the corresponding real device interface, or directly sending the interface data of the real device interface to the corresponding hardware interface;

[0067] S204, storing the interface data into the shared memory of the kernel space;

[0068] S205, determining at least one target interface corresponding to the initial interface, and configuration parameters corresponding to each target interface;

[0069] S206: Send the interface data to the corresponding target interface through various configuration parameters.

[0070] In one embodiment of the present application, if the initial interface is a hardware interface, the target interface includes: at least one virtual device interface, and / or, at least one hardware interface; if the initial interface is a virtual device interface, the target interface includes: at least one hardware interface.

[0071] In this application, the original real device interface in the application space cannot directly send data to other interfaces when forwarding data, so a virtual device interface corresponding to the original real device interface can be created. If data needs to be forwarded, the interface data is sent to the corresponding driver through the virtual device interface, and the interface data is stored in the shared memory through the driver, so that the interrupt program sends the interface data to the corresponding target interface through the configuration parameters. In this case, the target interface can be at least one hardware interface. Among them, the interrupt program is a program in the kernel space. Whenever new data is stored in the shared memory, the interrupt program will be triggered. The interrupt program will find the target interface to be forwarded and the configuration parameters corresponding to the target interface according to the configuration information, and use the configuration parameters to send the interface data to the driver of the target interface so that it can be sent to the target interface through the driver.

[0072] Correspondingly, if the hardware interface sends data to the application space, the interface data needs to be stored in the shared memory through the driver of the hardware interface, so that the interrupt program can send the interface data to the corresponding target interface through the configuration parameters. In this case, the target interface can be at least one virtual device interface, or at least one hardware interface, or both of at least one virtual device interface and at least one hardware interface. In addition, if the initial interface is a hardware interface, after the driver of the hardware interface receives the interface data, it is also necessary to determine whether the interface data needs to be forwarded. If forwarding is required, the interface data can be directly sent to the corresponding real device interface without storing the interface data in the shared memory. Similarly, the real device interface will send data that does not need to be forwarded directly to the corresponding hardware interface through the corresponding driver.

[0073] See also Figure 3 , which is a data forwarding diagram provided in an embodiment of the present application; here, only the virtual device interface / dev / vmttyAMA0 forwards data and the real device interface / dev / ttyAMA0 sends data as an example for explanation. When data needs to be forwarded, the virtual device interface / dev / vmttyAMA0 sends the interface data to the shared memory through the vmttyAMA0 driver, and the interrupt program uses the configuration parameters to send the interface data to the can0 driver, and through the can0 driver, the interface data is sent to the external hardware interface can0; for data that does not need to be forwarded, the real device interface / dev / ttyAMA0 directly sends the interface data to the external hardware interface ttyAMA0 through the ttyAMA0 driver.

[0074] Moreover, if the hardware resources of the new device are insufficient when the application is transferred from the old device to the new device, such as the new communication interface of the new device is different from the old communication interface of the old device, there is no need to change the application code. The application can use the new communication interface to send data in the new device, that is, create a virtual device interface corresponding to the old communication interface in the application space. The data sent by the application on the new device can be forwarded from the virtual device interface to the new communication interface through this solution, so that the application can achieve the same effect as the original on the new device without changing.

[0075] For example: the application communicates through the CAN interface on the old device, but there is no CAN interface in the new device, only a serial port. At this time, a virtual CAN interface and the driver corresponding to the virtual CAN interface are set in the application space. Therefore, when the application sends data through the serial port on the new device, the virtual CAN interface can be used to send the data to the shared memory, and the serial port configuration parameters can be used to forward the data to the serial port. In this way, the application device can communicate through the serial port on the new device without changing the application code.

[0076] In another embodiment of the present application, if the initial interface is a hardware interface, the target interface includes: at least one real device interface, and / or, at least one hardware interface; if the initial interface is a real device interface, the target interface includes: at least one hardware interface.

[0077] It should be noted that since the original real device interface does not have the function of forwarding data, in this application, the driver corresponding to the original real device interface can be modified. After the modified driver receives the interface data sent by the real device interface, it can first determine whether the interface data needs to be forwarded; if forwarding is not required, the interface data is directly sent to the corresponding hardware interface; if forwarding is required, the interface data is stored in shared memory, and the interface data is sent to the target interface through the driver of the target interface using configuration parameters. In this case, the target interface is at least one hardware interface.

[0078] Correspondingly, after receiving the interface data sent by the hardware interface, the driver also needs to determine whether the interface data needs to be forwarded; if it does not need to be forwarded, it is directly sent to the corresponding real device interface; if it needs to be forwarded, the data is stored in the shared memory and sent to the target interface through the driver of the target interface. In this case, the target interface is at least one real device interface. Figure 4 , is another data forwarding schematic diagram provided by an embodiment of the present application; here, only the real device interface / dev / ttyAMA0 forwarding data is used as an example for explanation. When data needs to be forwarded, the real device interface / dev / ttyAMA0 sends the interface data to the driver of ttyAMA0. The driver determines that the interface data needs to be forwarded, and then sends the interface data to the shared memory. The interrupt program uses the corresponding configuration parameters to send the interface data to the driver of can0, and the interface data is sent to the hardware interface can0 through the driver of can0.

[0079] In the present application, when the drivers of the hardware interface and the real device interface determine whether the interface data needs to be forwarded, they can specifically determine it through the value of the forwarding flag bit. The process specifically includes: determining the value of the forwarding flag bit corresponding to the initial interface; determining whether the interface data needs to be forwarded according to the value. Among them, the forwarding flag bit is a forwarding flag bit set in different drivers. If the configuration information records that the target data sent by a certain interface needs to be forwarded, the forwarding flag bit in the driver of the interface is set to 1 at this time, so that after the driver receives the interface data sent by the interface, the interface data is stored in the shared memory; for example: if the configuration information records that the hardware interface can0 needs to forward data, then the forwarding flag bit in the driver of the hardware interface can0 needs to be set to 1. After the subsequent driver of the hardware interface can0 receives the interface data sent by the hardware interface can0, it can determine that the interface data is data that needs to be forwarded and store it in the shared memory.

[0080] In summary, the present application provides a multi-interface forwarding solution based on shared memory. The solution can be operated directly in the kernel space, and all interfaces share memory, thereby reducing the switching of interface data between the application space and the kernel space, thereby reducing unnecessary overhead caused by data transfer, thereby making multi-interface forwarding more reliable and faster.

[0081] See also Figure 5 , is a flow chart of another method for forwarding interface data provided in an embodiment of the present application, the method specifically comprising:

[0082] S301, setting a configuration file in the application space; the configuration file includes: an initial interface, a target interface, and configuration parameters corresponding to each target interface;

[0083] S302, using the configuration file to update the configuration information in the shared memory;

[0084] S303, obtaining interface data to be forwarded; the interface data is data obtained from the initial interface;

[0085] S304, storing the interface data into the shared memory of the kernel space;

[0086] S305, determining a target interface corresponding to the initial interface from the configuration information; wherein the number of the target interface is at least one;

[0087] S306, determining configuration parameters corresponding to each target interface from the configuration information;

[0088] S307: Send the interface data to the corresponding target interface through various configuration parameters.

[0089] In this application, in order to quickly determine the target interface corresponding to the initial interface and the configuration parameters corresponding to each target interface, a configuration file can be set in the application space before forwarding the data. The configuration file is the forwarding strategy for this forwarding data. The configuration file mainly includes: the initial node for data forwarding, the target interface for data forwarding, and the configuration parameters corresponding to each target interface. Different forwarding strategies require different configuration files, and before each data forwarding, if the forwarding strategy changes, the configuration file needs to be updated so that the interface data can be forwarded through an accurate forwarding strategy.

[0090] Since the configuration file is set by the user in the application space, in order to facilitate the use of the information in the configuration file to determine the target interface and configuration parameters of the interface data in the kernel space, this application needs to add a mapping driver in the kernel space, and use the driver to map the configuration information in the configuration file to the shared memory space. At this time, two parts of space are reserved in the shared memory space. One part saves the configuration information through a list, and the configuration information includes: the initial interface, the target interface, and the configuration parameters corresponding to each target interface; the other part is used to store the interface data that needs to be forwarded. If the user needs to modify the forwarding strategy, the configuration file in the user space can be modified at this time. After the configuration file is modified, the information recorded in the configuration file will be immediately synchronized to the configuration information of the shared memory space. Whenever a module writes data in the shared memory space, it will block other modules. Only when reading data can multiple modules proceed at the same time.

[0091] See also Figure 6 , is a schematic diagram of the configuration file mapping process provided in the embodiment of the present application. In this embodiment, the UART (Universal Asynchronous Receiver and Transmitter) interface and the CAN interface are used as examples for explanation. Among them, each interface that needs to be forwarded will have a configuration file, and each configuration file represents a forwarding strategy. In each configuration file, the first interface is the initial interface, and the other interfaces are the target interfaces that need to forward data. Configuration parameters are recorded after each interface.

[0092] In this application, in order to facilitate the distinction of virtual device interfaces, vm is added in front of the virtual device interface, for example: vmcan0. For data that needs to be forwarded or received in the application space, it can be forwarded or received through the virtual device interface. If the first interface in the configuration file is a hardware interface, it means that the interface data received from the hardware driver in the kernel space needs to be forwarded. If the second interface is a virtual device interface starting with vm, it means that the interface data is forwarded to the virtual device interface in the application space. If the second interface does not have vm, it means that the interface data is forwarded to another external hardware interface through the driver.

[0093] like Figure 6 As shown, the two boxes in the first row represent two configuration files. Here, the first configuration file is used as an example for explanation: the first interface in the configuration file is ttyAMA0 (serial port), ttyAMA0 is the initial interface, and the initial interface is a hardware interface. The second interface in the configuration file is vmcan0, vmcan0 is the target interface, and the target interface is a virtual device interface. Among them, the configuration parameters recorded after ttyAMA0 are: 9600 and cs8, where 9600 is the baud rate and cs8 indicates that the data bit is 8 bits; the configuration parameters recorded after vmcan0 are: bitrate 500000, indicating that the bit rate is 500000.

[0094] Furthermore, the information recorded in each configuration file will be mapped to the configuration information in the shared memory space through the driver. The other part of the mapping is the interface data that needs to be forwarded. For example, the information in the first configuration file will be mapped to List 1 in the configuration information, and the information in the second configuration file will be mapped to List 2 in the configuration information. If there are other configuration files, they will be mapped to other lists in turn.

[0095] Here, this solution is explained through the following two specific forwarding processes.

[0096] See also Figure 7 , is a data forwarding flow chart provided in an embodiment of the present application, which records the specific process of forwarding the data received by the kernel driver to the application space. First, the ttyAMA0 hardware driver in the kernel obtains data from the ttyAMA0 interface, and determines whether forwarding is required based on the flag bit. If forwarding is not required, the data is sent to the real device interface / dev / ttyAMA0 of the application space. If forwarding is required, the data is written to the forwarding data space in the shared memory and the interrupt program is triggered. Figure 6 From the configuration information recorded in the first configuration file, it can be seen that if the initial interface is ttyAMA0, the target interface is vmcan0. Therefore, the driver determines that the data needs to be forwarded and stores the data in the shared memory space. The interrupt program searches the forwarding list. If the interface that needs to be forwarded is not found, it ends directly. Otherwise, it is transmitted to the corresponding driver according to the configuration parameters in the list, and sent to the corresponding target interface through the driver. In this embodiment, the interrupt program can find out from the list that the target interface that needs to be forwarded is vmcan0. At this time, the data needs to be transmitted to the driver of vmcan0 according to the configuration parameters in the list, and then sent to the vmcan0 interface of the application space through the driver.

[0097] See also Figure 8, is another data forwarding flow chart provided by an embodiment of the present application, which records the process of receiving data from a virtual device interface in an application space and forwarding it to other physical interfaces, wherein all data forwarded in the application space needs to be sent from the virtual device interface. Figure 8 , the interface data of vmcan0 needs to be written to the shared memory forwarding data part through the vmcan0 driver. Then the interrupt program is triggered, and the interrupt program will search the configuration information in the permission list to determine the target interface to which the data needs to be forwarded. Figure 6 The configuration information in List 2 can determine that the target interfaces are: ttyAMA0 hardware interface and ttyAMA1 hardware interface. The interrupt program configures the parameters of the driver programs of ttyAMA0 hardware interface and ttyAMA1 hardware interface respectively according to the information in the list, and sends the interface data to the actual external serial port hardware through the driver programs of ttyAMA0 hardware interface and ttyAMA1 hardware interface.

[0098] In summary, the present application provides a multi-interface forwarding method based on shared memory. By forwarding data in the shared memory in the kernel space, the number of data transfers between the application space and the kernel space is reduced, the system performance is improved, and rapid conversion between multi-interface data is achieved, reducing the overhead of multiple data copies. Moreover, the present application can quickly determine at least one target interface and configuration parameters for forwarding interface data by setting a configuration file, thereby achieving multi-interface data forwarding and improving data forwarding efficiency.

[0099] See also Fig. 9 , Fig. 9 A schematic diagram of the structure of a forwarding device for interface data provided in an embodiment of the present application, the device specifically comprises:

[0100] The acquisition module 11 is used to acquire the interface data to be forwarded; the interface data is the data acquired from the initial interface;

[0101] A storage module 12, used for storing the interface data in a shared memory of a kernel space;

[0102] A determination module 13, configured to determine at least one target interface corresponding to the initial interface, and configuration parameters corresponding to each target interface;

[0103] The first sending module 14 is used to send the interface data to the corresponding target interface through various configuration parameters.

[0104] As an optional embodiment, the forwarding device further includes:

[0105] A judging module, used for judging whether the interface data needs to be forwarded when the initial interface is a hardware interface or a real device interface; if so, triggering the storage module; if not, triggering the second sending module or the third sending module;

[0106] A second sending module, used for directly sending the interface data of the hardware interface to the corresponding real device interface;

[0107] The third sending module is used to send the interface data of the real device interface directly to the corresponding hardware interface.

[0108] As an optional embodiment, the judgment module is specifically used to: determine the value of the forwarding flag corresponding to the initial interface; and determine whether the interface data needs to be forwarded according to the value.

[0109] As an optional embodiment, if the initial interface is a hardware interface, the target interface includes: at least one virtual device interface, and / or, at least one hardware interface; if the initial interface is a virtual device interface, the target interface includes: at least one hardware interface.

[0110] As an optional embodiment, if the initial interface is a hardware interface, the target interface includes: at least one real device interface, and / or, at least one hardware interface; if the initial interface is a real device interface, the target interface includes: at least one hardware interface.

[0111] As an optional embodiment, the forwarding device further includes:

[0112] A setting module, used to set a configuration file in the application space; the configuration file includes: an initial interface, a target interface, and configuration parameters corresponding to each target interface;

[0113] An updating module is used to update the configuration information in the shared memory using the configuration file.

[0114] As an optional embodiment, the determining module includes:

[0115] A first determining unit, configured to determine a target interface corresponding to the initial interface from the configuration information; wherein the number of the target interface is at least one;

[0116] The second determining unit is used to determine the configuration parameters corresponding to each target interface from the configuration information.

[0117] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0118] See also Fig.10 , Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, the electronic device specifically includes:

[0119] The processor 21, the memory 22 and the computer program stored in the memory 22 and executable on the processor 21, the processor 21 executes the steps of the data playback method described in any of the above method embodiments through the computer program.

[0120] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0121] The memory 22 may include one or more computer-readable storage media, which may be non-transitory. The memory 22 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 22 is at least used to store the following computer program 221, wherein, after the computer program is loaded and executed by the processor 21, it can implement the relevant steps in the forwarding method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 22 may also include an operating system 222 and data 223, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 222 may include Windows, Unix, Linux, etc.

[0122] In some embodiments, the electronic device may further include a display screen 23 , an input / output interface 24 , a communication interface 25 , a sensor 26 , a power source 27 , and a communication bus 28 .

[0123] certainly, Fig.10 The structure of the electronic device shown does not constitute a limitation on the electronic device in the embodiments of the present application. In actual applications, the electronic device may include Fig.10 More or fewer components than shown, or combinations of certain components.

[0124] In another exemplary embodiment, a computer storage medium is also provided, and when the program instructions are executed by a processor, the steps of the forwarding method described in any of the above method embodiments are implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0125] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0126] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0127] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for forwarding interface data, characterized in that: include: Get the interface data to be forwarded; The interface data is data obtained from the initial interface; storing the interface data in a shared memory of a kernel space; Determine at least one target interface corresponding to the initial interface, and configuration parameters corresponding to each target interface; The interface data is sent to the corresponding target interface through each configuration parameter.

2. The forwarding method according to claim 1, characterized in that: If the initial interface is a hardware interface or a real device interface, after obtaining the interface data to be forwarded, the method further includes: Determine whether the interface data needs to be forwarded; If yes, execute the step of storing the interface data in the shared memory of the kernel space; if no, send the interface data of the hardware interface directly to the corresponding real device interface, or send the interface data of the real device interface directly to the corresponding hardware interface.

3. The forwarding method according to claim 2, characterized in that: Determining whether the interface data needs to be forwarded includes: Determine a value of a forwarding flag bit corresponding to the initial interface; Determine whether the interface data needs to be forwarded according to the value.

4. The forwarding method according to claim 1, characterized in that: If the initial interface is a hardware interface, the target interface includes: at least one virtual device interface, and / or, at least one hardware interface; if the initial interface is a virtual device interface, the target interface includes: at least one hardware interface.

5. The forwarding method according to claim 1, characterized in that: If the initial interface is a hardware interface, the target interface includes: at least one real device interface, and / or, at least one hardware interface; if the initial interface is a real device interface, the target interface includes: at least one hardware interface.

6. The forwarding method according to any one of claims 1 to 5, characterized in that: Before obtaining the interface data to be forwarded, the method further includes: Setting a configuration file in the application space; the configuration file includes: an initial interface, a target interface, and configuration parameters corresponding to each target interface; The configuration information in the shared memory is updated using the configuration file.

7. The forwarding method according to claim 6, characterized in that: Determining at least one target interface corresponding to the initial interface and configuration parameters corresponding to each target interface includes: Determine a target interface corresponding to the initial interface from the configuration information; wherein the number of the target interface is at least one; Configuration parameters corresponding to each target interface are determined from the configuration information.

8. A device for forwarding interface data, characterized in that: include: An acquisition module, used for acquiring interface data to be forwarded; The interface data is data obtained from the initial interface; A storage module, used for storing the interface data in a shared memory of a kernel space; A determination module, used to determine at least one target interface corresponding to the initial interface, and configuration parameters corresponding to each target interface; The first sending module is used to send the interface data to the corresponding target interface through various configuration parameters.

9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the steps of the forwarding method described in any one of claims 1 to 7 of the present application through the computer program.

10. A computer storage medium, characterized in that: The computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the steps of the forwarding method described in any one of claims 1 to 7 of the present application.