Data transmission method, data transmission device, readable storage medium and electronic equipment
By acquiring and mapping the logical link information of connected terminals, the redundancy problem caused by the large number of interface types is solved, the processing flow of new interfaces is simplified, and the data transmission efficiency is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WEICHAI POWER CO LTD
- Filing Date
- 2023-08-10
- Publication Date
- 2026-05-26
AI Technical Summary
The existing technology has a wide variety of communication interface types for connected terminals, which leads to redundancy in the data transmission and reception process and makes the process complicated when adding new interfaces.
By acquiring data transmission information, including the physical type and link index of the target logical link, the application type of the logical link is determined, and data transmission is performed by matching the target interface according to the application type, using link identifiers and interface descriptors for mapping.
It achieves a unified abstraction of the link management process for different types of interfaces, reduces processing redundancy, simplifies the process of adding new interfaces, and improves data transmission efficiency.
Smart Images

Figure CN117041323B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data transmission, and more specifically, to a data transmission method, a data transmission apparatus, a computer-readable storage medium, and an electronic device. Background Technology
[0002] The existing network terminal communication interface types are numerous and the data transmission and reception processes are completely isolated, which leads to redundancy in the common processing of different interface types, and the process of adding new interfaces is also more cumbersome. Summary of the Invention
[0003] The main objective of this application is to provide a data transmission method, a data transmission device, a computer-readable storage medium, and an electronic device, so as to at least solve the problems of high redundancy in the processing of different types of interfaces in the prior art, and the complexity of the processing when adding a new interface.
[0004] To achieve the above objectives, according to one aspect of this application, a data transmission method is provided, comprising: acquiring data transmission information, the data transmission information including at least target data, a physical type of a target logical link, and a link index of the target logical link, wherein the target logical link is a logical communication link used to transmit the target data, the physical type of the target logical link represents the physical interface type corresponding to the target logical link, and the link index of the target logical link represents the link number of the target logical link; determining an application type of the target logical link based on the physical type of the target logical link and the link index of the target logical link, the application type of the target logical link representing the function of the logical link; determining a target interface based on the application type of the target logical link to match the target logical link and the target interface, the target interface being used to transmit the target data; and transmitting the target data using the target logical link and the target interface.
[0005] Optionally, before acquiring data transmission information, the method further includes: configuring a link identifier for each logical communication link, wherein the link identifier includes the application type of the logical communication link, the physical type of the logical communication link, and the link index of the logical communication link, wherein the physical type of the logical communication link represents the physical interface type corresponding to the logical communication link, the link index of the logical communication link represents the link number of the logical communication link, and the application type of the logical communication link represents the function of the logical communication link.
[0006] Optionally, determining a target interface based on the application type of the target logical link to match the target logical link and the target interface includes: determining the target interface and its interface descriptor based on the application type of the target logical link, wherein the interface descriptor represents the identification information of the interface; invoking a target callback function to start the target logical link, wherein the target callback function is a link start function, the target callback function corresponds to the application type of the target logical link, and the link start function is used to start the target logical link; and, when the target logical link is started, completing the mapping between the link identifier of the target logical link and the interface descriptor of the target interface to realize the mapping between the target logical link and the target interface.
[0007] Optionally, invoking a target callback function to start the target logical link includes: if the physical type of the target logical link is a network interface type, invoking the target callback function and obtaining a target signal, wherein the target signal is a listening signal or a connection signal, the listening signal is a signal to listen for whether an external connection signal has arrived, and the connection signal is a signal to confirm whether a successful connection to the target interface has been achieved; if the target signal is the listening signal and the listening signal is a signal indicating that an external connection signal has arrived, determining that the target logical link is started; if the target signal is the connection signal and the connection signal is a signal confirming that a successful connection to the target interface has been achieved, determining that the target logical link is started.
[0008] Optionally, before configuring the link identifier for each of the logical communication links, the method further includes: configuring callback functions for each of the application types, where each application type corresponds to a set of callback functions, and the set of callback functions includes at least: a link start function, a link stop function, a data send function, a data receive function, and a keep-alive function. The link start function is used to start the logical communication link, the link stop function is used to stop the logical communication link, the data send function is used to send data through the logical communication link using an interface, the data receive function is used to receive data through the logical communication link using the interface, and the keep-alive function is used to monitor the connection status of the logical communication link.
[0009] Optionally, the method further includes: processing the target data using a target processing method by calling the callback function, wherein the target processing method is a first processing method or a second processing method, wherein the first processing method is one of the following: communication link establishment, data transmission processing, transmission exception handling, periodic keep-alive processing, and the second processing method is one of the following: listening signal management, connection signal management, link pool management, data reception processing, reception exception handling, wherein the processing method corresponds to the callback function.
[0010] Optionally, each application type is stored in an application pool, and the interface identifier of each interface is stored in a link pool. The method further includes: when adding a new interface, obtaining the application type corresponding to the new interface and the link index corresponding to the new interface; if the application type corresponding to the new interface exists in the application pool, adding the interface identifier of the new interface and the link index corresponding to the new interface to the link pool to add the new interface; if the application type corresponding to the new interface does not exist in the application pool, adding the application type corresponding to the new interface to the application pool, and adding the interface identifier of the new interface and the link index corresponding to the new interface to the link pool to add the new interface.
[0011] According to another aspect of this application, a data transmission apparatus is provided, comprising: an acquisition unit, configured to acquire data transmission information, the data transmission information including at least target data, a physical type of a target logical link, and a link index of the target logical link, the target logical link being a logical communication link for transmitting the target data, the physical type of the target logical link representing a physical interface type of the target logical link, and the link index of the target logical link representing a link number of the target logical link; a first determining unit, configured to determine an application type of the target logical link based on the physical type of the target logical link and the link index of the target logical link, the application type of the target logical link representing a function of the logical link; a second determining unit, configured to determine a target interface based on the application type of the target logical link to match the target logical link and the target interface, the target interface being used to transmit the target data; and a transmission unit, configured to transmit the target data using the target logical link and the target interface.
[0012] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to perform any of the described data transmission methods.
[0013] According to another aspect of this application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including methods for performing any of the data transmission methods described above.
[0014] Applying the technical solution of this application, the above-mentioned data transmission method first obtains data transmission information, which includes at least the target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link indicates the physical interface type corresponding to the target logical link, and the link index of the target logical link indicates the link number of the target logical link. Then, based on the physical type and link index of the target logical link, the application type of the target logical link is determined, which indicates the function of the logical link. Next, based on the application type of the target logical link, the target interface is determined to match the target logical link and the target interface. The target interface is used to transmit the target data. Finally, the target data is transmitted using the target logical link and the target interface. This method abstracts and unifies the link management process for different types of interfaces, reduces processing redundancy, uses link identifiers to represent unique communication links, and maps them to interface descriptors. This solves the problems of high redundancy in the processing of different types of interfaces in the prior art, and the complex processing when adding new interfaces. Attached Figure Description
[0015] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0016] Figure 1 A hardware structure block diagram of a mobile terminal performing a data transmission method according to an embodiment of this application is shown;
[0017] Figure 2 A schematic flowchart of a data transmission method according to an embodiment of this application is shown;
[0018] Figure 3 A schematic diagram of a data transmission system provided according to an embodiment of this application is shown;
[0019] Figure 4 A flowchart illustrating another data transmission method provided according to an embodiment of this application is shown;
[0020] Figure 5 A schematic flowchart of yet another data transmission method provided according to an embodiment of this application is shown;
[0021] Figure 6 A structural block diagram of a data transmission apparatus provided according to an embodiment of this application is shown.
[0022] The above figures include the following reference numerals:
[0023] 102. Processor; 104. Memory; 106. Transmission device; 108. Input / output device. Detailed Implementation
[0024] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0025] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] As described in the background section, existing network terminal communication interfaces are numerous and the data transmission and reception processes are completely isolated, which leads to redundancy in the common processing of different interface types. Furthermore, the processing when adding a new interface is more cumbersome. To address the problem of high redundancy in the processing of different types of interfaces and the complexity of adding a new interface in the existing technology, embodiments of this application provide a data transmission method, a data transmission device, a computer-readable storage medium, and an electronic device.
[0028] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0029] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for a data transmission method according to an embodiment of the present invention. Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0030] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the data transmission method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thus implementing the above-described method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The transmission device 106 is used to receive or send data via a network. Specific examples of the aforementioned networks may include wireless networks provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0031] This embodiment provides a data transmission method that runs on a mobile terminal, computer terminal, or similar computing device. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0032] Figure 2 This is a flowchart of a data transmission method according to an embodiment of this application. For example... Figure 2 As shown, the method includes the following steps:
[0033] Step S201: Obtain data transmission information. The data transmission information includes at least target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link indicates the physical interface type corresponding to the target logical link. The link index of the target logical link indicates the link number of the target logical link.
[0034] Specifically, a unique target logical link can be determined based on the physical type of the target logical link and the link index of the target logical link. The data transmission information includes not only the target data to be transmitted, but also the physical type of the target logical link and the link index of the target logical link, which means that the target logical link used for transmission can be directly determined.
[0035] Before acquiring data transmission information, the method further includes the following steps: configuring a link identifier for each of the logical communication links. The link identifier includes the application type of the logical communication link, the physical type of the logical communication link, and the link index of the logical communication link. The physical type of the logical communication link represents the physical interface type corresponding to the logical communication link, the link index of the logical communication link represents the link number of the logical communication link, and the application type of the logical communication link represents the function of the logical communication link.
[0036] Specifically, this allows each logical communication link to receive a unique link identifier, facilitating subsequent mapping between link identifiers and interface descriptors, and enabling direct configuration of logical communication links and interfaces. A communication link is a data path comprised of communication nodes and the communication interfaces between them. One physical link can correspond to multiple logical links, just as multiple socket connections can be created between two nodes on an Ethernet network. Each logical communication link is assigned a unique identifier, called a link identifier, which consists of three parts: application type, physical type, and link index. The application type indicates the purpose of the communication link. Application types can be vehicle-to-cloud management applications (i.e., interaction between the vehicle and the cloud, monitoring vehicle status) or device-to-ECU communication applications. Each application type corresponds to a set of callback functions, such as link opening, link closing, data sending, data receiving, and keep-alive processing, executing specific processing procedures for that link within the callback functions. The physical type represents the actual physical interface type, commonly such as Ethernet port, serial port, or CAN bus. Interfaces of the same physical type can use different communication protocols and be applied in different scenarios (corresponding to multiple application types). Different physical type interfaces generally use different application types. The link index represents the communication link number under a certain physical type and is unique.
[0037] Before configuring the link identifier for each of the aforementioned logical communication links, the method further includes: configuring callback functions for each of the aforementioned application types. Each application type corresponds to a set of callback functions, and each set of callback functions includes at least: a link start function, a link stop function, a data send function, a data receive function, and a keep-alive function. The link start function is used to start the aforementioned logical communication link, the link stop function is used to stop the aforementioned logical communication link, the data send function is used to send data through the aforementioned logical communication link using an interface, the data receive function is used to receive data through the aforementioned logical communication link using the aforementioned interface, and the keep-alive function is used to monitor the connection status of the aforementioned logical communication link.
[0038] Specifically, by calling callback functions, different processing methods can be applied to data and communication logic links, making the processing of data and communication logic links more convenient and efficient. The link opening function is used to create or open the relevant link, such as opening a serial port device file, creating a socket listener or connection, etc., preparing for data transmission and reception or connection establishment; the link closing function is used to close the relevant link and stop data transmission and reception; the data sending function is used to frame data and send it through the interface based on a specific communication protocol; the data receiving function is used to receive data from the interface and deframe it based on a specific communication protocol; the keep-alive function is used to periodically handshake with the peer with agreed data content, monitoring the connection status of the peer or the link (normal or disconnected). Furthermore, the callback functions are not limited to the above and can be adjusted accordingly in practical applications.
[0039] Step S202: Based on the physical type and link index of the target logical link, determine the application type of the target logical link. The application type of the target logical link represents the function of the logical link.
[0040] Specifically, the link identifier of the logical communication link includes the application type of the logical communication link, the physical type of the logical communication link, and the link index of the logical communication link. The physical type and the link index of the logical communication link can directly identify a unique logical communication link. Then, the application type of the logical communication link can be directly determined based on the link identifier. In this way, the target interface used for transmitting data can be determined, with one application corresponding to one interface.
[0041] Step S203: Based on the application type of the target logical link, determine the target interface to match the target logical link and the target interface. The target interface is used to transmit the target data.
[0042] Specifically, a logical communication link has a unique link identifier, and an interface also has a unique interface descriptor. The interface descriptor is a handle used by the operating system when operating the communication interface. Commonly used descriptors include those obtained when creating a network socket or when opening a device file (serial port, CAN). By mapping the link identifier and the interface descriptor, the target logical link and the target interface are matched to enable subsequent data transmission.
[0043] The specific implementation steps for determining the target interface based on the application type of the aforementioned target logical link, and matching the aforementioned target logical link and the aforementioned target interface, are as follows:
[0044] Step S301: Based on the application type of the target logical link, determine the target interface and the interface descriptor of the target interface. The interface descriptor represents the identification information of the interface.
[0045] Step S302: Call the target callback function to start the target logical link. The target callback function is the link start function. The target callback function corresponds to the application type of the target logical link. The link start function is used to start the target logical link.
[0046] The specific steps for invoking the target callback function to initiate the aforementioned target logic chain are as follows:
[0047] Step S3021: If the physical type of the target logical link is a network interface type, call the target callback function and obtain the target signal. The target signal is a listening signal or a connection signal. The listening signal is a signal to listen for whether an external connection signal has arrived, and the connection signal is a signal to confirm whether the connection to the target interface has been successfully established.
[0048] Step S3022: If the target signal is the monitoring signal and the monitoring signal is an external connection signal that has arrived, determine that the target logical link is enabled.
[0049] Step S3023: If the target signal is the connection signal and the connection signal is a signal confirming that the connection to the target interface has been successfully established, then the target logical link is determined to be enabled.
[0050] Specifically, by calling a callback function, a logical communication link is opened to create the entire link.
[0051] In an alternative embodiment, a data transmission system is also provided, such as Figure 3As shown, the system includes a data sending and receiving module, a communication interface data transmission and reception management module, and a communication interface. The communication interface data transmission and reception management module abstracts the common processing parts of all communication links, while the specific parts are implemented by callback processing (functions). As a communication framework or device, the communication interface data transmission and reception management provides services to "data sending and receiving" users through link identifiers and establishes a mapping with specific communication interface descriptors (device / file descriptors, socket descriptors). The communication interface data transmission and reception management module includes an application pool and a common processing module. The common processing module handles general processing for all communication interfaces, selecting the AppType (application type of the logical communication link) based on LinkType (physical type of the logical communication link) and LinkIndex (link index of the logical communication link) and completing the mapping from link identifiers to interface descriptors. Based on different processing content, it is divided into two parts: business management and link management. Business management mainly handles business-related content, including communication link establishment, data sending processing, sending exception handling, and periodic keep-alive processing, which is implemented by calling callback processing (functions) in the application pool. Business management is responsible for establishing all logical links in the connected terminal, receiving data from business modules and forwarding it to specific communication interfaces. Link management is responsible for the underlying processing of the links, including socket listening and connection, link pool management, data reception processing, and reception exception handling, also implemented by calling callback functions in the application pool. The link pool is responsible for monitoring interface descriptors, including socket listening, socket connections, and established communication link interface descriptors. The application pool uses callback processing to differentiate the unique parts of different interfaces. Each application type (AppType) uses a set of callback functions, where Net1, Net2, Serial1, Serial2, Serial3, Can1, Can2, and Can3 correspond to different interfaces.
[0052] Step S303: When the target logical link is enabled, the mapping between the link identifier of the target logical link and the interface descriptor of the target interface is completed to realize the mapping between the target logical link and the target interface.
[0053] Specifically, this allows for the mapping between the link identifier of the target logical link and the interface descriptor of the target interface, thus enabling the mapping between the target logical link and the target interface for subsequent data transmission.
[0054] Furthermore, steps S301 to S303 described above are all implemented by the service management module within the communication interface data transceiver management module, such as... Figure 4As shown, firstly, according to the communication interface plan, the link opening callback function is called to execute the "link opening" process for each link. Then, it is determined whether the logical communication link is a network link. If it is, the link management module is notified to create a socket listener or connection descriptor. If a connection is detected or successful, it indicates that the logical communication link has been successfully created. The link management module is then notified that the logical communication link has been successfully created, and the mapping from the link identifier of the logical communication link to the interface descriptor is completed. Afterward, data to be sent by the business module is received, and data transmission processing is performed. If the logical communication link is not a network link, opening the interface signifies successful link creation, and subsequent steps are then performed.
[0055] For socket links, both a client and a server are required. Therefore, when the communication interface data transmission and reception management module acts as a server, a listening function is implemented; when it acts as a client, a connection function is implemented. The link is considered successfully created only when a connection is detected or the connection to the other end is successful. The underlying processing of this process is handled by the link management thread. For other link types, opening the interface signifies successful link creation. In case of data transmission errors (interface errors, or network transmission errors), the existing link will be closed and an attempt will be made to rebuild it. During normal data transmission, a keep-alive message will be periodically sent based on actual needs to confirm the link's connection status (whether communication is normal or has been disconnected).
[0056] At the same time, the link management module in the communication interface data transceiver management module performs the following... Figure 5 The steps shown are as follows: First, create a socket listener or connection descriptor according to the requirements of the business management module, and put the socket listener and connection descriptor into the link pool for real-time monitoring. Then, put all successfully created communication link interface descriptors into the link pool and monitor them in real time. Next, check whether the interface data has arrived. If the interface data has arrived, perform data reception processing and send the data to the business module. If the interface data has not arrived, the listening or connected link is successfully connected, and the connection success information is transmitted to the business management module.
[0057] The link management thread is responsible for the underlying interface processing. It puts the interface descriptors of successfully created links and socket listening or connection descriptions into the link pool for monitoring and processes them according to the received content. When data reception is abnormal, it notifies the business management module to close the existing link and attempt to rebuild it.
[0058] Step S204: Transmit the target data using the target logical link and the target interface described above.
[0059] Specifically, the link management process of different types of interfaces has been abstracted and unified, making the extension process simple and efficient. The common parts of the link management process of all communication interfaces are extracted, reducing processing redundancy. Users can send data to the corresponding interface by specifying the link type and link index, which is simple and convenient. A communication framework is provided to manage all communication interfaces. While unifying the common parts, it can also handle the special parts. This avoids the problems of existing network terminal communication interface types being numerous and the data transmission and reception processes being completely isolated, which would lead to redundancy in the common processing of different interface types and make the process of adding new interfaces more cumbersome. Among them, the network terminal is an embedded device that uses various types of interfaces for network communication.
[0060] The method further includes: processing the target data by calling the callback function, wherein the target processing method is either a first processing method or a second processing method. The first processing method is one of the following: communication link establishment, data transmission processing, transmission exception handling, periodic keep-alive processing. The second processing method is one of the following: listening signal management, connection signal management, link pool management, data reception processing, reception exception handling. The processing method corresponds to the callback function.
[0061] Specifically, the business management module and the link management module in the communication interface data transmission and reception management module can perform simple and efficient processing of data or links by calling different callback functions. The first processing method is executed by the business management module in the communication interface data transmission and reception management module, and the second processing method is executed by the link management module in the communication interface data transmission and reception management module. Each processing method corresponds to a specific callback function.
[0062] The application types mentioned above are stored in the application pool, and the interface identifiers of each interface are stored in the link pool. The method also includes the following steps:
[0063] Step S401: When adding a new interface, obtain the application type and the link index corresponding to the new interface.
[0064] Step S402: If the application type corresponding to the newly added interface exists in the application pool, add the interface identifier of the newly added interface and the link index corresponding to the newly added interface to the link pool to add the newly added interface.
[0065] Step S403: If the application type corresponding to the newly added interface does not exist in the application pool, add the application type corresponding to the newly added interface to the application pool, and add the interface identifier of the newly added interface and the link index corresponding to the newly added interface to the link pool to add the newly added interface.
[0066] Specifically, the link management process for different types of interfaces has been abstracted and unified. When adding a new type of interface, only the different implementation details of the specific interface need to be considered, and when increasing the number of existing type interfaces, only the index needs to be added, making the expansion process simple and efficient. Adding new interfaces is more convenient; it only requires adding special (callback) processing for the new application type, or simply adding the link index (for existing application types).
[0067] The data transmission method described in this application first obtains data transmission information, which includes at least the target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link indicates the physical interface type corresponding to the target logical link, and the link index of the target logical link indicates the link number of the target logical link. Then, based on the physical type and link index of the target logical link, the application type of the target logical link is determined, which indicates the function of the logical link. Next, based on the application type of the target logical link, the target interface is determined to match the target logical link and the target interface. The target interface is used to transmit the target data. Finally, the target data is transmitted using the target logical link and the target interface. This method abstracts and unifies the link management process for different types of interfaces, reducing processing redundancy. It uses link identifiers to represent unique communication links and maps them to interface descriptors, solving the problems of high redundancy in the processing of different types of interfaces in the prior art, and the complex processing when adding new interfaces.
[0068] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0069] This application also provides a data transmission apparatus. It should be noted that the data transmission apparatus of this application can be used to execute the data transmission method provided in this application. This apparatus is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0070] The data transmission apparatus provided in the embodiments of this application will be described below.
[0071] Figure 6 This is a schematic diagram of a data transmission apparatus according to an embodiment of this application. Figure 6 As shown, the device includes an acquisition unit 10, a first determination unit 20, a second determination unit 30, and a transmission unit 40. The acquisition unit 10 is used to acquire data transmission information, which includes at least target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link indicates the physical interface type of the target logical link, and the link index of the target logical link indicates the link number of the target logical link. The first determination unit 20 is used to determine the application type of the target logical link based on the physical type and the link index of the target logical link. The application type of the target logical link indicates the function of the logical link. The second determination unit 30 is used to determine the target interface based on the application type of the target logical link to match the target logical link and the target interface. The target interface is used to transmit the target data. The transmission unit 40 is used to transmit the target data using the target logical link and the target interface.
[0072] The data transmission apparatus of this application includes an acquisition unit, a first determination unit, a second determination unit, and a transmission unit. The acquisition unit is used to acquire data transmission information, which includes at least target data, a physical type of a target logical link, and a link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link indicates the physical interface type of the target logical link, and the link index of the target logical link indicates the link number of the target logical link. The first determination unit is used to determine the application type of the target logical link based on the physical type and the link index of the target logical link. The application type of the target logical link indicates the function of the logical link. The second determination unit is used to determine a target interface based on the application type of the target logical link to match the target logical link and the target interface. The target interface is used to transmit the target data. The transmission unit is used to transmit the target data using the target logical link and the target interface. This device abstracts and unifies the link management process for different types of interfaces, reducing processing redundancy. It uses link identifiers to represent unique communication links and maps them to interface descriptors, solving the problems of high redundancy in the processing of different types of interfaces in the prior art and the complexity of the processing when adding new interfaces.
[0073] In an optional embodiment, the apparatus further includes a first configuration unit. The first configuration unit is configured to configure a link identifier for each of the logical communication links before acquiring data transmission information. The link identifier includes the application type of the logical communication link, the physical type of the logical communication link, and the link index of the logical communication link. The physical type of the logical communication link represents the physical interface type corresponding to the logical communication link, the link index of the logical communication link represents the link number of the logical communication link, and the application type of the logical communication link represents the function of the logical communication link. This allows each logical communication link to obtain a unique link identifier, facilitating subsequent mapping between the link identifier and the interface descriptor, and enabling direct configuration of the logical communication links and interfaces.
[0074] In one optional embodiment, the second determining unit includes a first determining module, a first calling module, and a mapping module. The first determining module is used to determine the target interface and its interface descriptor based on the application type of the target logical link. The interface descriptor represents the identification information of the interface. The first calling module is used to call a target callback function to start the target logical link. The target callback function is a link starting function, which corresponds to the application type of the target logical link. The link starting function is used to start the target logical link. The mapping module is used to map the link identifier of the target logical link and the interface descriptor of the target interface when the target logical link is started, thereby realizing the mapping between the target logical link and the target interface. This allows for the mapping between the link identifier of the target logical link and the interface descriptor of the target interface, enabling subsequent data transmission using the target logical link and the target interface.
[0075] For example, the first calling module includes a second calling module, a second determining module, and a third determining module. The second calling module is used to call the target callback function and obtain the target signal when the physical type of the target logical link is a network interface type. The target signal is either a listening signal or a connection signal. The listening signal is a signal that listens for the arrival of an external connection signal, and the connection signal is a signal that confirms whether the connection to the target interface has been successfully established. The second determining module is used to determine that the target logical link is open when the target signal is the listening signal and the listening signal is a signal that an external connection signal has arrived. The third determining module is used to determine that the target logical link is open when the target signal is the connection signal and the connection signal is a signal that confirms the successful connection to the target interface. By calling the callback function, the logical communication link is opened to achieve the creation of the entire link.
[0076] In this embodiment, the device further includes a second configuration unit. The second configuration unit is used to configure callback functions for each application type before configuring the link identifier for each of the logical communication links. Each application type corresponds to a set of callback functions. A set of callback functions includes at least: a link start function, a link stop function, a data send function, a data receive function, and a keep-alive function. The link start function is used to start the logical communication link; the link stop function is used to stop the logical communication link; the data send function is used to send data through the logical communication link using an interface; the data receive function is used to receive data through the logical communication link using the interface; and the keep-alive function is used to monitor the connection status of the logical communication link. By calling the callback functions, different processing methods can be applied to the data and communication logical links, making the processing of data and communication logical links more convenient and efficient.
[0077] In an optional embodiment, the above-mentioned device further includes a processing unit. The processing unit is used to process the target data using a target processing method by calling the callback function. The target processing method is either a first processing method or a second processing method. The first processing method is one of the following: communication link establishment, data transmission processing, transmission exception handling, or periodic keep-alive processing. The second processing method is one of the following: monitoring signal management, connection signal management, link pool management, data reception processing, or reception exception handling. The processing methods correspond to the callback functions. The service management module and link management module in the communication interface data transmission and reception management module can achieve simple and efficient processing of data or links by calling different callback functions.
[0078] As an optional solution, the aforementioned application types are stored in an application pool, and the interface identifiers of each interface are stored in a link pool. The device further includes an acquisition module, a first addition module, and a second addition module. The acquisition module is used to acquire the application type corresponding to the newly added interface and the link index corresponding to the newly added interface when adding a new interface. The first addition module is used to add the interface identifier and the link index corresponding to the newly added interface to the link pool if the application type corresponding to the newly added interface exists in the application pool, thereby adding the newly added interface. The second addition module is used to add the application type corresponding to the newly added interface to the application pool if the application type corresponding to the newly added interface does not exist in the application pool, and to add the interface identifier and the link index corresponding to the newly added interface to the link pool, thereby adding the newly added interface. The link management process for different types of interfaces is abstracted and unified. When adding a new type of interface, only the different implementation details of the specific interface are considered, and when increasing the number of existing type interfaces, only the index needs to be added, making the expansion process simple and efficient. Adding new interfaces is more convenient, requiring only the addition of special (callback) processing for the new application type, or simply adding the link index (for existing application types).
[0079] The aforementioned data transmission device includes a processor and a memory. The aforementioned acquisition units, etc., are all stored as program units in the memory, and the processor executes these program units stored in the memory to achieve the corresponding functions. All of the aforementioned modules are located in the same processor; alternatively, the aforementioned modules may be located in different processors in any combination.
[0080] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and adjusting kernel parameters can address the issues of high redundancy in the processing of different types of interfaces in existing technologies, as well as the complexity of processing new interfaces.
[0081] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0082] This invention provides a computer-readable storage medium including a stored program, wherein the program, when running, controls the device containing the computer-readable storage medium to execute the data transmission method.
[0083] Specifically, the data transmission methods include:
[0084] Step S201: Obtain data transmission information. The data transmission information includes at least target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link indicates the physical interface type corresponding to the target logical link. The link index of the target logical link indicates the link number of the target logical link.
[0085] Specifically, a unique target logical link can be determined based on the physical type of the target logical link and the link index of the target logical link. The data transmission information includes not only the target data to be transmitted, but also the physical type of the target logical link and the link index of the target logical link, which means that the target logical link used for transmission can be directly determined.
[0086] Step S202: Based on the physical type and link index of the target logical link, determine the application type of the target logical link. The application type of the target logical link represents the function of the logical link.
[0087] Specifically, the link identifier of the logical communication link includes the application type of the logical communication link, the physical type of the logical communication link, and the link index of the logical communication link. The physical type and the link index of the logical communication link can directly identify a unique logical communication link. Then, the application type of the logical communication link can be directly determined based on the link identifier. In this way, the target interface used for transmitting data can be determined, with one application corresponding to one interface.
[0088] Step S203: Based on the application type of the target logical link, determine the target interface to match the target logical link and the target interface. The target interface is used to transmit the target data.
[0089] Specifically, a logical communication link has a unique link identifier, and an interface also has a unique interface descriptor. The interface descriptor is a handle used by the operating system when operating the communication interface. Commonly used descriptors include those obtained when creating a network socket or when opening a (serial port, CAN) device file. By mapping the link identifier and the interface descriptor, the target logical link and the target interface are matched to enable subsequent data transmission.
[0090] Step S204: Transmit the target data using the target logical link and the target interface described above.
[0091] Specifically, the link management process of different types of interfaces has been abstracted and unified, making the extension process simple and efficient. The common parts of the link management process of all communication interfaces are extracted, reducing processing redundancy. Users can send data to the corresponding interface by specifying the link type and link index, which is simple and convenient. A communication framework is provided to manage all communication interfaces. While unifying the common parts, it can also handle the special parts. This avoids the problems of existing network terminal communication interface types being numerous and the data transmission and reception processes being completely isolated, which would lead to redundancy in the common processing of different interface types and make the process of adding new interfaces more cumbersome. Among them, the network terminal is an embedded device that uses various types of interfaces for network communication.
[0092] Optionally, before obtaining data transmission information, the above method further includes: configuring a link identifier for each of the above logical communication links, wherein the link identifier includes the application type of the above logical communication link, the physical type of the above logical communication link, and the link index of the above logical communication link, wherein the physical type of the above logical communication link represents the physical interface type corresponding to the above logical communication link, the link index of the above logical communication link represents the link number of the above logical communication link, and the application type of the above logical communication link represents the function of the above logical communication link.
[0093] Optionally, based on the application type of the target logical link, a target interface is determined to match the target logical link and the target interface. This includes: determining the target interface and its interface descriptor based on the application type of the target logical link, where the interface descriptor represents the interface's identification information; invoking a target callback function to start the target logical link, where the target callback function is a link start function corresponding to the application type of the target logical link; and when the target logical link is started, completing the mapping between the link identifier of the target logical link and the interface descriptor of the target interface to achieve the mapping between the target logical link and the target interface.
[0094] Optionally, invoking a target callback function to start the target logical link includes: if the physical type of the target logical link is a network interface type, invoking the target callback function and obtaining a target signal, wherein the target signal is a listening signal or a connection signal, the listening signal is a signal to listen for whether an external connection signal has arrived, and the connection signal is a signal to confirm whether a successful connection to the target interface has been established; if the target signal is the listening signal and the listening signal is a signal indicating that an external connection signal has arrived, determining that the target logical link is started; if the target signal is the connection signal and the connection signal is a signal confirming that a successful connection to the target interface has been established, determining that the target logical link is started.
[0095] Optionally, before configuring the link identifier for each of the above-mentioned logical communication links, the method further includes: configuring callback functions for each of the above-mentioned application types, wherein one of the above-mentioned application types corresponds to a set of callback functions, and the set of above-mentioned callback functions includes at least: a link start function, a link stop function, a data send function, a data receive function, and a keep-alive function, wherein the link start function is used to start the above-mentioned logical communication link, the link stop function is used to stop the above-mentioned logical communication link, the data send function is used to send data through the above-mentioned logical communication link using an interface, the data receive function is used to receive data through the above-mentioned logical communication link using the above-mentioned interface, and the keep-alive function is used to monitor the connection status of the above-mentioned logical communication link.
[0096] Optionally, the above method further includes: processing the target data by calling the above callback function using a target processing method, wherein the target processing method is a first processing method or a second processing method, wherein the first processing method is one of the following: communication link establishment, data transmission processing, transmission exception handling, periodic keep-alive processing, and the second processing method is one of the following: listening signal management, connection signal management, link pool management, data reception processing, reception exception handling, wherein the above processing method corresponds to the above callback function.
[0097] Optionally, each of the above application types is stored in an application pool, and the interface identifier of each interface is stored in a link pool. The method further includes: when adding a new interface, obtaining the application type corresponding to the new interface and the link index corresponding to the new interface; if the application type corresponding to the new interface exists in the application pool, adding the interface identifier of the new interface and the link index corresponding to the new interface to the link pool to add the new interface; if the application type corresponding to the new interface does not exist in the application pool, adding the application type corresponding to the new interface to the application pool, and adding the interface identifier of the new interface and the link index corresponding to the new interface to the link pool to add the new interface.
[0098] This invention provides a processor for running a program, wherein the program executes the data transmission method described above.
[0099] Specifically, the data transmission methods include:
[0100] Step S201: Obtain data transmission information. The data transmission information includes at least target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link indicates the physical interface type corresponding to the target logical link. The link index of the target logical link indicates the link number of the target logical link.
[0101] Specifically, a unique target logical link can be determined based on the physical type of the target logical link and the link index of the target logical link. The data transmission information includes not only the target data to be transmitted, but also the physical type of the target logical link and the link index of the target logical link, which means that the target logical link used for transmission can be directly determined.
[0102] Step S202: Based on the physical type and link index of the target logical link, determine the application type of the target logical link. The application type of the target logical link represents the function of the logical link.
[0103] Specifically, the link identifier of the logical communication link includes the application type of the logical communication link, the physical type of the logical communication link, and the link index of the logical communication link. The physical type and the link index of the logical communication link can directly identify a unique logical communication link. Then, the application type of the logical communication link can be directly determined based on the link identifier. In this way, the target interface used for transmitting data can be determined, with one application corresponding to one interface.
[0104] Step S203: Based on the application type of the target logical link, determine the target interface to match the target logical link and the target interface. The target interface is used to transmit the target data.
[0105] Specifically, a logical communication link has a unique link identifier, and an interface also has a unique interface descriptor. The interface descriptor is a handle used by the operating system when operating the communication interface. Commonly used descriptors include those obtained when creating a network socket or when opening a (serial port, CAN) device file. By mapping the link identifier and the interface descriptor, the target logical link and the target interface are matched to enable subsequent data transmission.
[0106] Step S204: Transmit the target data using the target logical link and the target interface described above.
[0107] Specifically, the link management process of different types of interfaces has been abstracted and unified, making the extension process simple and efficient. The common parts of the link management process of all communication interfaces are extracted, reducing processing redundancy. Users can send data to the corresponding interface by specifying the link type and link index, which is simple and convenient. A communication framework is provided to manage all communication interfaces. While unifying the common parts, it can also handle the special parts. This avoids the problems of existing network terminal communication interface types being numerous and the data transmission and reception processes being completely isolated, which would lead to redundancy in the common processing of different interface types and make the process of adding new interfaces more cumbersome. Among them, the network terminal is an embedded device that uses various types of interfaces for network communication.
[0108] Optionally, before obtaining data transmission information, the above method further includes: configuring a link identifier for each of the above logical communication links, wherein the link identifier includes the application type of the above logical communication link, the physical type of the above logical communication link, and the link index of the above logical communication link, wherein the physical type of the above logical communication link represents the physical interface type corresponding to the above logical communication link, the link index of the above logical communication link represents the link number of the above logical communication link, and the application type of the above logical communication link represents the function of the above logical communication link.
[0109] Optionally, based on the application type of the target logical link, a target interface is determined to match the target logical link and the target interface. This includes: determining the target interface and its interface descriptor based on the application type of the target logical link, where the interface descriptor represents the interface's identification information; invoking a target callback function to start the target logical link, where the target callback function is a link start function corresponding to the application type of the target logical link; and when the target logical link is started, completing the mapping between the link identifier of the target logical link and the interface descriptor of the target interface to achieve the mapping between the target logical link and the target interface.
[0110] Optionally, invoking a target callback function to start the target logical link includes: if the physical type of the target logical link is a network interface type, invoking the target callback function and obtaining a target signal, wherein the target signal is a listening signal or a connection signal, the listening signal is a signal to listen for whether an external connection signal has arrived, and the connection signal is a signal to confirm whether a successful connection to the target interface has been established; if the target signal is the listening signal and the listening signal is a signal indicating that an external connection signal has arrived, determining that the target logical link is started; if the target signal is the connection signal and the connection signal is a signal confirming that a successful connection to the target interface has been established, determining that the target logical link is started.
[0111] Optionally, before configuring the link identifier for each of the above-mentioned logical communication links, the method further includes: configuring callback functions for each of the above-mentioned application types, wherein one of the above-mentioned application types corresponds to a set of callback functions, and the set of above-mentioned callback functions includes at least: a link start function, a link stop function, a data send function, a data receive function, and a keep-alive function, wherein the link start function is used to start the above-mentioned logical communication link, the link stop function is used to stop the above-mentioned logical communication link, the data send function is used to send data through the above-mentioned logical communication link using an interface, the data receive function is used to receive data through the above-mentioned logical communication link using the above-mentioned interface, and the keep-alive function is used to monitor the connection status of the above-mentioned logical communication link.
[0112] Optionally, the above method further includes: processing the target data by calling the above callback function using a target processing method, wherein the target processing method is a first processing method or a second processing method, wherein the first processing method is one of the following: communication link establishment, data transmission processing, transmission exception handling, periodic keep-alive processing, and the second processing method is one of the following: listening signal management, connection signal management, link pool management, data reception processing, reception exception handling, wherein the above processing method corresponds to the above callback function.
[0113] Optionally, each of the above application types is stored in an application pool, and the interface identifier of each interface is stored in a link pool. The method further includes: when adding a new interface, obtaining the application type corresponding to the new interface and the link index corresponding to the new interface; if the application type corresponding to the new interface exists in the application pool, adding the interface identifier of the new interface and the link index corresponding to the new interface to the link pool to add the new interface; if the application type corresponding to the new interface does not exist in the application pool, adding the application type corresponding to the new interface to the application pool, and adding the interface identifier of the new interface and the link index corresponding to the new interface to the link pool to add the new interface.
[0114] This invention provides a device including a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs at least the following steps:
[0115] Step S201: Obtain data transmission information. The data transmission information includes at least target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link indicates the physical interface type corresponding to the target logical link. The link index of the target logical link indicates the link number of the target logical link.
[0116] Step S202: Based on the physical type and link index of the target logical link, determine the application type of the target logical link. The application type of the target logical link represents the function of the logical link.
[0117] Step S203: Based on the application type of the target logical link, determine the target interface to match the target logical link and the target interface. The target interface is used to transmit the target data.
[0118] Step S204: Transmit the target data using the target logical link and the target interface described above.
[0119] Optionally, before obtaining data transmission information, the above method further includes: configuring a link identifier for each of the above logical communication links, wherein the link identifier includes the application type of the above logical communication link, the physical type of the above logical communication link, and the link index of the above logical communication link, wherein the physical type of the above logical communication link represents the physical interface type corresponding to the above logical communication link, the link index of the above logical communication link represents the link number of the above logical communication link, and the application type of the above logical communication link represents the function of the above logical communication link.
[0120] Optionally, based on the application type of the target logical link, a target interface is determined to match the target logical link and the target interface. This includes: determining the target interface and its interface descriptor based on the application type of the target logical link, where the interface descriptor represents the interface's identification information; invoking a target callback function to start the target logical link, where the target callback function is a link start function corresponding to the application type of the target logical link; and when the target logical link is started, completing the mapping between the link identifier of the target logical link and the interface descriptor of the target interface to achieve the mapping between the target logical link and the target interface.
[0121] Optionally, invoking a target callback function to start the target logical link includes: if the physical type of the target logical link is a network interface type, invoking the target callback function and obtaining a target signal, wherein the target signal is a listening signal or a connection signal, the listening signal is a signal to listen for whether an external connection signal has arrived, and the connection signal is a signal to confirm whether a successful connection to the target interface has been established; if the target signal is the listening signal and the listening signal is a signal indicating that an external connection signal has arrived, determining that the target logical link is started; if the target signal is the connection signal and the connection signal is a signal confirming that a successful connection to the target interface has been established, determining that the target logical link is started.
[0122] Optionally, before configuring the link identifier for each of the above-mentioned logical communication links, the method further includes: configuring callback functions for each of the above-mentioned application types, wherein one of the above-mentioned application types corresponds to a set of callback functions, and the set of above-mentioned callback functions includes at least: a link start function, a link stop function, a data send function, a data receive function, and a keep-alive function, wherein the link start function is used to start the above-mentioned logical communication link, the link stop function is used to stop the above-mentioned logical communication link, the data send function is used to send data through the above-mentioned logical communication link using an interface, the data receive function is used to receive data through the above-mentioned logical communication link using the above-mentioned interface, and the keep-alive function is used to monitor the connection status of the above-mentioned logical communication link.
[0123] Optionally, the above method further includes: processing the target data by calling the above callback function using a target processing method, wherein the target processing method is a first processing method or a second processing method, wherein the first processing method is one of the following: communication link establishment, data transmission processing, transmission exception handling, periodic keep-alive processing, and the second processing method is one of the following: listening signal management, connection signal management, link pool management, data reception processing, reception exception handling, wherein the above processing method corresponds to the above callback function.
[0124] Optionally, each of the above application types is stored in an application pool, and the interface identifier of each interface is stored in a link pool. The method further includes: when adding a new interface, obtaining the application type corresponding to the new interface and the link index corresponding to the new interface; if the application type corresponding to the new interface exists in the application pool, adding the interface identifier of the new interface and the link index corresponding to the new interface to the link pool to add the new interface; if the application type corresponding to the new interface does not exist in the application pool, adding the application type corresponding to the new interface to the application pool, and adding the interface identifier of the new interface and the link index corresponding to the new interface to the link pool to add the new interface.
[0125] The devices mentioned in this article can be servers, PCs, tablets, mobile phones, etc.
[0126] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having at least the following method steps:
[0127] Step S201: Obtain data transmission information. The data transmission information includes at least target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link indicates the physical interface type corresponding to the target logical link. The link index of the target logical link indicates the link number of the target logical link.
[0128] Step S202: Based on the physical type and link index of the target logical link, determine the application type of the target logical link. The application type of the target logical link represents the function of the logical link.
[0129] Step S203: Based on the application type of the target logical link, determine the target interface to match the target logical link and the target interface. The target interface is used to transmit the target data.
[0130] Step S204: Transmit the target data using the target logical link and the target interface described above.
[0131] Optionally, before obtaining data transmission information, the above method further includes: configuring a link identifier for each of the above logical communication links, wherein the link identifier includes the application type of the above logical communication link, the physical type of the above logical communication link, and the link index of the above logical communication link, wherein the physical type of the above logical communication link represents the physical interface type corresponding to the above logical communication link, the link index of the above logical communication link represents the link number of the above logical communication link, and the application type of the above logical communication link represents the function of the above logical communication link.
[0132] Optionally, based on the application type of the target logical link, a target interface is determined to match the target logical link and the target interface. This includes: determining the target interface and its interface descriptor based on the application type of the target logical link, where the interface descriptor represents the interface's identification information; invoking a target callback function to start the target logical link, where the target callback function is a link start function corresponding to the application type of the target logical link; and when the target logical link is started, completing the mapping between the link identifier of the target logical link and the interface descriptor of the target interface to achieve the mapping between the target logical link and the target interface.
[0133] Optionally, invoking a target callback function to start the target logical link includes: if the physical type of the target logical link is a network interface type, invoking the target callback function and obtaining a target signal, wherein the target signal is a listening signal or a connection signal, the listening signal is a signal to listen for whether an external connection signal has arrived, and the connection signal is a signal to confirm whether a successful connection to the target interface has been established; if the target signal is the listening signal and the listening signal is a signal indicating that an external connection signal has arrived, determining that the target logical link is started; if the target signal is the connection signal and the connection signal is a signal confirming that a successful connection to the target interface has been established, determining that the target logical link is started.
[0134] Optionally, before configuring the link identifier for each of the above-mentioned logical communication links, the method further includes: configuring callback functions for each of the above-mentioned application types, wherein one of the above-mentioned application types corresponds to a set of callback functions, and the set of above-mentioned callback functions includes at least: a link start function, a link stop function, a data send function, a data receive function, and a keep-alive function, wherein the link start function is used to start the above-mentioned logical communication link, the link stop function is used to stop the above-mentioned logical communication link, the data send function is used to send data through the above-mentioned logical communication link using an interface, the data receive function is used to receive data through the above-mentioned logical communication link using the above-mentioned interface, and the keep-alive function is used to monitor the connection status of the above-mentioned logical communication link.
[0135] Optionally, the above method further includes: processing the target data by calling the above callback function using a target processing method, wherein the target processing method is a first processing method or a second processing method, wherein the first processing method is one of the following: communication link establishment, data transmission processing, transmission exception handling, periodic keep-alive processing, and the second processing method is one of the following: listening signal management, connection signal management, link pool management, data reception processing, reception exception handling, wherein the above processing method corresponds to the above callback function.
[0136] Optionally, each of the above application types is stored in an application pool, and the interface identifier of each interface is stored in a link pool. The method further includes: when adding a new interface, obtaining the application type corresponding to the new interface and the link index corresponding to the new interface; if the application type corresponding to the new interface exists in the application pool, adding the interface identifier of the new interface and the link index corresponding to the new interface to the link pool to add the new interface; if the application type corresponding to the new interface does not exist in the application pool, adding the application type corresponding to the new interface to the application pool, and adding the interface identifier of the new interface and the link index corresponding to the new interface to the link pool to add the new interface.
[0137] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0138] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0139] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0140] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0141] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0142] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0143] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0144] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0145] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0146] As can be seen from the above description, the embodiments of this application achieve the following technical effects:
[0147] 1) The data transmission method described in this application first obtains data transmission information, which includes at least the target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link indicates the physical interface type corresponding to the target logical link, and the link index of the target logical link indicates the link number of the target logical link. Then, based on the physical type and link index of the target logical link, the application type of the target logical link is determined, which indicates the function of the logical link. Next, based on the application type of the target logical link, the target interface is determined to match the target logical link and the target interface. The target interface is used to transmit the target data. Finally, the target data is transmitted using the target logical link and the target interface. This method abstracts and unifies the link management process for different types of interfaces, reduces processing redundancy, uses link identifiers to represent unique communication links, and maps them to interface descriptors. This solves the problems of high redundancy in the processing of different types of interfaces in the prior art, and the complex processing when adding new interfaces.
[0148] 2) The data transmission apparatus of this application includes an acquisition unit, a first determination unit, a second determination unit, and a transmission unit. The acquisition unit is used to acquire data transmission information, which includes at least target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link indicates the physical interface type of the target logical link, and the link index of the target logical link indicates the link number of the target logical link. The first determination unit is used to determine the application type of the target logical link based on the physical type and the link index of the target logical link. The application type of the target logical link indicates the function of the logical link. The second determination unit is used to determine a target interface based on the application type of the target logical link to match the target logical link and the target interface. The target interface is used to transmit the target data. The transmission unit is used to transmit the target data using the target logical link and the target interface. This device abstracts and unifies the link management process for different types of interfaces, reducing processing redundancy. It uses link identifiers to represent unique communication links and maps them to interface descriptors, solving the problems of high redundancy in the processing of different types of interfaces in the prior art and the complexity of the processing when adding new interfaces.
[0149] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A data transmission method, characterized in that, include: Obtain data transmission information, which includes at least target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link represents the physical interface type corresponding to the target logical link. The link index of the target logical link represents the link number of the target logical link. Based on the physical type and link index of the target logical link, the application type of the target logical link is determined, and the application type of the target logical link represents the function of the logical link; Based on the application type of the target logical link, a target interface is determined to match the target logical link and the target interface, wherein the target interface is used to transmit the target data; The target data is transmitted using the target logical link and the target interface.
2. The data transmission method according to claim 1, characterized in that, Before acquiring data transmission information, the method further includes: Configure a link identifier for each logical communication link. The link identifier includes the application type of the logical communication link, the physical type of the logical communication link, and the link index of the logical communication link. The physical type of the logical communication link represents the physical interface type corresponding to the logical communication link. The link index of the logical communication link represents the link number of the logical communication link. The application type of the logical communication link represents the function of the logical communication link.
3. The data transmission method according to claim 2, characterized in that, Based on the application type of the target logical link, determine the target interface to match the target logical link and the target interface, including: Based on the application type of the target logical link, the target interface and the interface descriptor of the target interface are determined, and the interface descriptor represents the identification information of the interface; The target callback function is invoked to start the target logical link. The target callback function is a link start function, and the target callback function corresponds to the application type of the target logical link. The link start function is used to start the target logical link. When the target logical link is enabled, the mapping between the link identifier of the target logical link and the interface descriptor of the target interface is completed to realize the mapping between the target logical link and the target interface.
4. The data transmission method according to claim 3, characterized in that, Invoking the target callback function to initiate the target logic chain includes: If the physical type of the target logical link is a network interface type, the target callback function is called and the target signal is obtained. The target signal is either a listening signal or a connection signal. The listening signal is a signal to listen for whether an external connection signal has arrived, and the connection signal is a signal to confirm whether the connection to the target interface has been successfully established. If the target signal is the monitoring signal, and the monitoring signal is a signal indicating that an external connection signal has arrived, then the target logical link is determined to be open. If the target signal is the connection signal, and the connection signal is a signal confirming that the connection to the target interface has been successfully established, then the target logical link is determined to be enabled.
5. The data transmission method according to claim 2, characterized in that, Before configuring the link identifier for each of the logical communication links, the method further includes: Configure callback functions for each application type. Each application type corresponds to a set of callback functions. Each set of callback functions includes at least: a link start function, a link stop function, a data send function, a data receive function, and a keep-alive function. The link start function is used to start the logical communication link. The link stop function is used to stop the logical communication link. The data send function is used to send data through the logical communication link using an interface. The data receive function is used to receive data through the logical communication link using the interface. The keep-alive function is used to monitor the connection status of the logical communication link.
6. The data transmission method according to claim 5, characterized in that, The method further includes: By calling the callback function, the target data is processed using a target processing method, which is either a first processing method or a second processing method. The first processing method is one of the following: communication link establishment, data transmission processing, transmission exception handling, and periodic keep-alive processing. The second processing method is one of the following: listening signal management, connection signal management, link pool management, data reception processing, and reception exception handling. The processing method corresponds to the callback function.
7. The data transmission method according to any one of claims 1 to 6, characterized in that, Each application type is stored in an application pool, and the interface identifier of each interface is stored in a link pool. The method further includes: When adding a new interface, obtain the application type and the link index corresponding to the new interface. If the application type corresponding to the newly added interface exists in the application pool, the interface identifier of the newly added interface and the link index corresponding to the newly added interface are added to the link pool to add the newly added interface. If the application type corresponding to the newly added interface does not exist in the application pool, the application type corresponding to the newly added interface is added to the application pool, and the interface identifier of the newly added interface and the link index corresponding to the newly added interface are added to the link pool to add the newly added interface.
8. A data transmission device, characterized in that, include: The acquisition unit is used to acquire data transmission information, which includes at least target data, the physical type of the target logical link, and the link index of the target logical link. The target logical link is a logical communication link used to transmit the target data. The physical type of the target logical link represents the physical interface type of the target logical link, and the link index of the target logical link represents the link number of the target logical link. The first determining unit is configured to determine the application type of the target logical link based on the physical type of the target logical link and the link index of the target logical link, wherein the application type of the target logical link represents the function of the logical link; The second determining unit is used to determine the target interface according to the application type of the target logical link, so as to match the target logical link and the target interface, wherein the target interface is used to transmit the target data; A transmission unit is used to transmit the target data using the target logical link and the target interface.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device containing the computer-readable storage medium to perform the data transmission method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including methods for performing the data transfer method according to any one of claims 1 to 7.