Interface communication method, device and system, storage medium and electronic equipment

By adopting multi-threading technology in the master control device, processing multiple service instructions and interacting in parallel with external devices, the problem of inefficient communications of existing interfaces is solved and communication efficiency and performance is improved.

CN119440750AActive Publication Date: 2025-02-14BEIJING SMARTCHIP MICROELECTRONICS TECHNOLOGY CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411318411.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2025-02-14
Estimated Expiration
2044-09-20

AI Technical Summary

Technical Problem

The existing interface communication adopts a single task method, which is inefficient and cannot meet user needs.

Method used

Through multi-threading technology, the master control device obtains multiple business instructions, and determines the corresponding business threads in the preset business threads, and performs parallel data interaction with external devices through the driver interface.

Benefits of technology

Improves the performance and communication efficiency of data interaction, and realizes parallel access of multiple external devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440750A_ABST
    Figure CN119440750A_ABST
Patent Text Reader

Abstract

The invention provides an interface communication method, device and system, a storage medium and electronic equipment, and belongs to the technical field of communication. The interface communication method is applied to a main control device, the main control device is connected with a plurality of external devices through a communication interface, and the interface communication method comprises the steps that a plurality of service instructions are acquired, and each service instruction comprises external device information; a corresponding service thread is determined in a preset service thread set based on each service instruction, the preset service thread set comprises a plurality of service threads, and each service thread corresponds to one external device; and calling a driving interface by the corresponding service thread, and performing data interaction with corresponding external equipment through the driving interface. According to the technical scheme, automatic and reasonable multi-task scheduling processing is achieved, the requirement for automatically configuring and supporting data transmission of the multiple external devices is met, parallel access of the multiple external devices is achieved through the multi-thread technology, the data interaction performance is improved, and the communication efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to an interface communication method, an interface communication device, an interface communication system, a machine-readable storage medium and an electronic device. Background Art

[0002] Interface technology is a real-time interactive technology between computer main control software and various external devices of the computer. It is responsible for connecting the I / O circuit and peripheral devices together through the system bus of the main control device.

[0003] In order to enable each external device to interact with the main control device through the interface, multiple interfaces need to be set up, such as: Inter-Integrated Circuit (I2C) interface, Universal Asynchronous Receiver / Transmitter (UART) interface and Serial Peripheral Interface (SPI), etc. Different external devices use different interfaces for interaction.

[0004] The existing interface communication adopts a single-task mode, which requires waiting for a command to be sent and responded to before processing the second command. This communication mode is inefficient and cannot meet user needs. Summary of the invention

[0005] The purpose of the embodiments of the present invention is to provide an interface communication method, an interface communication device, an interface communication system, a machine-readable storage medium and an electronic device. The interface communication method completes parallel access to multiple external devices through multi-threading technology, increases the performance of data interaction, and improves communication efficiency.

[0006] In order to achieve the above-mentioned object, the first aspect of the present application provides an interface communication method, which is applied to a main control device, wherein the main control device is connected to multiple external devices through a communication interface, and the interface communication method includes:

[0007] Acquire multiple business instructions, each of which includes external device information;

[0008] Based on each service instruction, a corresponding service thread is determined in a preset service thread set, wherein the preset service thread set includes a plurality of service threads, and each service thread corresponds to an external device;

[0009] The corresponding service thread calls the driver interface and exchanges data with the corresponding external device through the driver interface.

[0010] In the embodiment of the present application, the obtaining of multiple service instructions includes:

[0011] The receiving thread obtains each service instruction respectively, and saves each service instruction into a corresponding list in the user RAM_BUF according to the external device information in each service instruction.

[0012] In the embodiment of the present application, the determining of corresponding service threads in a preset service thread set based on each service instruction respectively includes:

[0013] The service distribution thread determines the corresponding service thread in the preset service thread set according to the external device information in each service instruction, and distributes each service instruction to the corresponding service thread.

[0014] In the embodiment of the present application, the corresponding service thread calls the driver interface and performs data interaction with the corresponding external device through the driver interface, including:

[0015] The corresponding service thread calls the driver interface in a time slice scheduling manner, and performs data interaction with the corresponding external device through the driver interface.

[0016] In the embodiment of the present application, before obtaining multiple service instructions, the method further includes:

[0017] Obtaining a power-on instruction, wherein the power-on instruction includes power-on device information and rate parameter information;

[0018] In response to the power-on instruction, powering on the external device corresponding to the powered-on device information;

[0019] When it is determined that the external device corresponding to the powered-on device information is powered on completely, a drive interface corresponding to the external device is initialized based on the rate parameter information.

[0020] In the embodiment of the present application, it also includes:

[0021] Acquire a rate switching instruction, wherein the rate switching instruction includes switching device information and switching rate information;

[0022] Based on the switching device information, determine the external device to be switched;

[0023] Based on the switching rate information, a drive interface corresponding to the external device to be switched is updated.

[0024] A second aspect of the present application provides an interface communication system, comprising a host computer and a main control device, wherein the main control device is connected to a plurality of external devices via a communication interface;

[0025] The host computer is used to send each service instruction to the main control device respectively, and each service instruction includes external device information;

[0026] The main control device is used to obtain multiple business instructions issued by the upper computer, and based on each business instruction, determine the corresponding business thread in the preset business thread set, the preset business thread set includes multiple business threads, each business thread corresponds to an external device; the corresponding business thread calls the driver interface, and exchanges data with the corresponding external device through the driver interface.

[0027] In the embodiment of the present application, the main control device includes a receiving thread and a service distribution thread;

[0028] The receiving thread is used to obtain multiple business instructions issued by the host computer, and save the multiple business instructions to the user RAM_BUF;

[0029] The service distribution thread is used to determine the corresponding service thread in the preset service thread set according to each service instruction, and send each service instruction to the corresponding service thread respectively;

[0030] The corresponding service thread is used to call the driver interface, and perform data interaction with the corresponding external device through the driver interface, and save the data results received during the data interaction process into the user RAM_BUF.

[0031] In the embodiment of the present application, the main control device further includes a sending thread and a service sorting thread;

[0032] The business collating thread is used to move the data results received during the data interaction from the user RAM_BUF to the data transceiver RAM_BUF after completing the data interaction. The data transceiver RAM_BUF is a data transceiver buffer between the host computer and the master control device;

[0033] The sending thread is used to send the data result from the data transceiver RAM_BUF to the host computer.

[0034] A third aspect of the present application provides an interface communication device, which is applied to a main control device, wherein the main control device is connected to multiple external devices via a communication interface, and the interface communication device includes:

[0035] An acquisition module, used for acquiring multiple business instructions, each of which includes external device information;

[0036] A determination module, configured to determine a corresponding service thread in a preset service thread set based on each service instruction, wherein the preset service thread set includes a plurality of service threads, and each service thread corresponds to an external device;

[0037] The interaction module is used for the corresponding service thread to call the driver interface and perform data interaction with the corresponding external device through the driver interface.

[0038] In the embodiment of the present application, the acquisition module includes:

[0039] The receiving unit is used to obtain each service instruction by a receiving thread, and save each service instruction into a corresponding list in the user RAM_BUF according to the external device information in each service instruction.

[0040] In the embodiment of the present application, the determination module includes:

[0041] The distribution unit is used for determining the corresponding service thread in the preset service thread set according to the external device information in each service instruction by the service distribution thread, and distributing each service instruction to the corresponding service thread.

[0042] In the embodiment of the present application, the interaction module includes:

[0043] The mobilization unit is used to call the driver interface by the corresponding service thread according to the time slice scheduling method, and to perform data exchange with the corresponding external device through the driver interface.

[0044] A fourth aspect of the present application provides an electronic device, the electronic device comprising:

[0045] at least one processor;

[0046] a memory connected to the at least one processor;

[0047] The memory stores instructions that can be executed by the at least one processor, and the at least one processor implements the above-mentioned interface communication method by executing the instructions stored in the memory.

[0048] A fifth aspect of the present application provides a machine-readable storage medium having instructions stored thereon, which, when executed by a processor, configure the processor to execute the above-mentioned interface communication method.

[0049] Through the above technical solution, the main control device is connected to multiple external devices through the communication interface, and obtains multiple business instructions, each of which includes external device information; based on each business instruction, the corresponding business thread is determined in the preset business thread set, and the preset business thread set includes multiple business threads, each business thread corresponds to an external device; the corresponding business thread calls the driver interface, and exchanges data with the corresponding external device through the driver interface. By setting each business thread to correspond to an external device, the corresponding business thread is determined in the preset business thread set, and the corresponding business thread exchanges data with the corresponding external device, and automatically and reasonably multi-task scheduling is performed, and the requirements for data transmission of multiple external devices are automatically configured to be supported, thereby achieving parallel access to multiple external devices through multi-threading technology, increasing the performance of data interaction, and improving communication efficiency.

[0050] Other features and advantages of the embodiments of the present invention will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present invention, but do not constitute a limitation on the embodiments of the present invention. In the accompanying drawings:

[0052] Figure 1 A schematic diagram of a flow chart of an interface communication method according to an embodiment of the present application is shown;

[0053] Figure 2 A schematic diagram of the connection between the main control chip and the external device according to an embodiment of the present application is shown;

[0054] Figure 3 A schematic diagram of the processing flow between the host computer and the main device according to an embodiment of the present application is shown;

[0055] Figure 4 The following is a schematic diagram showing a flow chart of rate configuration according to an embodiment of the present application;

[0056] Figure 5 The structure block diagram of an interface communication system according to an embodiment of the present application is schematically shown;

[0057] Figure 6 A schematic diagram of a command sending format according to an embodiment of the present application is shown schematically;

[0058] Figure 7 The following schematically shows the format of the command return result according to an embodiment of the present application;

[0059] Figure 8 The structure block diagram of an interface communication device according to an embodiment of the present application is schematically shown;

[0060] Fig. 9 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown.

[0061] Description of Reference Numerals

[0062] 410 - acquisition module; 420 - determination module; 430 - interaction module; A01 - processor; A02 - network interface; A03 - internal memory; A04 - display screen; A05 - input device; A06 - non-volatile storage medium; B01 - operating system; B02 - computer program. DETAILED DESCRIPTION

[0063] The specific implementation of the embodiment of the present invention is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described here is only used to illustrate and explain the embodiment of the present invention, and is not used to limit the embodiment of the present invention.

[0064] Please see Figure 1 , Figure 1 The present invention schematically shows a flow chart of an interface communication method according to an embodiment of the present application. This embodiment provides an interface communication method, which is applied to a main control device, wherein the main control device is connected to multiple external devices via a communication interface, and the interface communication method comprises the following steps:

[0065] Step 210: Acquire multiple service instructions, each service instruction including external device information;

[0066] In this embodiment, the above-mentioned main control device may refer to a device, chip or component that plays a major control function in a system or device, such as a security chip. The functions of the main control device may include data processing, instruction transmission, device control, etc. The above-mentioned main control device has a variety of interfaces to enable the main control chip to connect the input / output (I / O) circuit and the peripheral device through the system bus, so as to facilitate communication with multiple external devices. The above-mentioned communication interface may be a USB interface, an I2C interface, a UART interface, an SPI interface, etc., and the speed of each communication interface may also be different, which may be tens of Kbps (kilobits per second), several Mbps (megabits per second), more than ten Mbps, etc. The above-mentioned connection of multiple external devices may be a communication interface connecting one or more external devices. It should be noted that when a communication interface is connected to multiple external devices, the main control device may be a device that selects to communicate with each interface through a chip select signal.

[0067] For example: See Figure 2 , Figure 2 The schematic diagram of the connection between the main control chip and the external device according to the embodiment of the present application is schematically shown. In order to enable each external device to interact with the main control chip through an interface, the main control device may include: a USB interface, an I2C interface, a UART interface, and an SPI interface, etc., the external device 1 is connected to the main control device through the I2C interface, the external device 2 is connected to the main control device through the USB interface, the external device 3 is connected to the main control device through the SPI interface, and the external device 4 is connected to the main control device through the UART interface.

[0068] The above-mentioned business instructions can be obtained by inputting into the main control device by the user, or can be obtained by sending to the main control device by other external devices or systems. The above-mentioned business instructions include information such as external device information and command data, so that the main control device determines which external device to interact with and what kind of data according to the business instructions. The above-mentioned external device information can be the name, number or interface index number of the external device.

[0069] In some embodiments, the acquiring of multiple service instructions includes: acquiring each service instruction respectively by a receiving thread, and saving each service instruction respectively into a corresponding list in the user RAM_BUF according to the external device information in each service instruction.

[0070] In this embodiment, a receiving thread can be pre-set in the main control device, and the receiving thread is responsible for processing the acquired business instructions, saving the business instructions to the user RAM_BUF, and waiting for processing. The user RAM_BUF refers to a buffer in the user space, which is usually used to store data that the user program needs to process. RAM_BUF can be an array, a pointer, or a structure of other data types, which is used to temporarily store data or calculation results in the user program.

[0071] For example, see Figure 3 , Figure 3 The schematic diagram of the processing flow between the host computer and the main device according to the embodiment of the present application is schematically shown. Taking the host computer sending external data (i.e., business instructions) to the main control device (i.e., the main control device) as an example, the host computer is connected to the main control device through a network port, and the external data is sent from the host computer to the main control device. It can be that each time a business instruction is sent, the main control device network port driver receives an interrupt signal, releases the signal amount of the network port driver transceiver processing thread, and triggers the transceiver thread. The main control device network port driver module determines whether the NET RAM (network memory) of the network port receiving data has a free area. If so, the main control device stores the received data in the corresponding NET RAM space and returns a successful reception. The receiving thread moves the instruction number in the external data in the NET RAM to different lists in the user RAM_BUF.

[0072] The business instructions are saved to the user RAM_BUF through the receiving thread to facilitate the subsequent reading of the business instructions.

[0073] Step 220: Based on each service instruction, determine a corresponding service thread in a preset service thread set, wherein the preset service thread set includes a plurality of service threads, and each service thread corresponds to an external device;

[0074] In this embodiment, the preset service thread set is pre-set with multiple service threads, each service thread exchanges the received data with the corresponding external device through the corresponding driver module, and saves the received data result. Since the service instruction contains the external device information, the service thread corresponding to the service instruction can be determined according to the external device information. Each service thread corresponds to a driver function module, and the driver module is used to exchange command data with an external device.

[0075] In some embodiments, the corresponding business thread is determined in a preset business thread set based on each business instruction, including: a business distribution thread determines the corresponding business thread in a preset business thread set according to external device information in each business instruction, and distributes each business instruction to the corresponding business thread.

[0076] In this embodiment, a service distribution thread can be pre-set in the main control device, and the service distribution thread is responsible for determining which service thread the current service belongs to according to the service instruction, and then distributing the service instruction to the relevant service thread. By setting the service distribution thread, the service distribution thread can quickly determine the corresponding service thread.

[0077] Step 230: The corresponding service thread calls the driver interface and exchanges data with the corresponding external device through the driver interface.

[0078] In this embodiment, each service instruction corresponds to a corresponding service thread, and accordingly, the service thread performs data exchange with the external device through the driver interface.

[0079] In some embodiments, the corresponding business thread calls the driver interface and interacts with the corresponding external device through the driver interface, including: the corresponding business thread calls the driver interface according to a time slice scheduling method, and interacts with the corresponding external device through the driver interface.

[0080] In this embodiment, the service thread calls the driver interface to interact with the external device through the time slice scheduling method. The service thread is responsible for processing the application logic, while the driver interface is responsible for communicating with the hardware device. Through the time slice scheduling method, the system can effectively manage the execution order of multiple service threads, thereby realizing concurrent access and control of external devices.

[0081] In the above implementation process, the main control device is connected to multiple external devices through a communication interface, and obtains multiple business instructions, each of which includes external device information; based on each business instruction, the corresponding business thread is determined in the preset business thread set, and the preset business thread set includes multiple business threads, each of which corresponds to an external device; the corresponding business thread calls the driver interface, and exchanges data with the corresponding external device through the driver interface. By setting each business thread to correspond to an external device, the corresponding business thread is determined in the preset business thread set, and the corresponding business thread exchanges data with the corresponding external device, and automatically and reasonably multi-task scheduling is performed, the requirements for automatically configuring and supporting data transmission of multiple external devices are realized, thereby achieving parallel access to multiple external devices through multi-threading technology, increasing the performance of data interaction, and improving communication efficiency.

[0082] For any common interface function in the main control device, data interaction with multiple external devices can be completed, and the external devices of each interface can be automatically adapted, so that it can be applied to the scenario of a single drive interface.

[0083] In some embodiments, depending on the external devices that interact with the main control device through the communication interface, there may be different rate requirements. The rate configuration of the interface driver of the main control device can be completed through instructions to automatically adapt to the requirements of the external devices. Specifically, before obtaining multiple service instructions, the following steps can be performed:

[0084] First, a power-on instruction is obtained, wherein the power-on instruction includes power-on device information and rate parameter information;

[0085] In this embodiment, the power-on instruction can be obtained by a user inputting into the main control device, or can be obtained by other external devices or systems sending to the main control device. For example, the power-on instruction can be sent by the host computer. It should be noted that the command format of the power-on instruction can be the same as the format of the business command, which will not be repeated here.

[0086] Then, in response to the power-on instruction, power on the external device corresponding to the powered-on device information;

[0087] In this embodiment, after receiving the power-on instruction, the corresponding external device can be powered on.

[0088] Finally, when it is determined that the external device corresponding to the powered-on device information has been powered on, the drive interface corresponding to the external device is initialized based on the rate parameter information.

[0089] In this embodiment, the above initialization can be to write the rate parameter information to the driver so as to communicate at the corresponding rate to meet the needs of the external device. For example, in the above example, the network port protocol of the master control device (master control device) receives the power-on command sent by the host computer, and then determines which SPI interface corresponds to the external device, and then the master control device powers on the external device of the corresponding interface through the relevant general-purpose input / output (GPIO) pin. Then initialize the SPI driver interface according to the relevant SPI rate parameters in the power-on command, and finally return the command processing result to the host computer to end the rate setting.

[0090] By initializing the driver interface and completing the rate configuration after the interface device is powered on according to the data content in the power-on command, dynamic rate management is achieved to increase the scope of application for external devices. The rates of different external devices can be automatically configured without modifying the device driver function, meeting the needs of more external devices with different rates.

[0091] In some embodiments, during the communication process, a rate change requirement scenario may occur, so the method further includes the following steps:

[0092] First, a rate switching instruction is obtained, wherein the rate switching instruction includes switching device information and switching rate information;

[0093] In this embodiment, the rate switching instruction may be obtained by a user inputting into the main control device, or may be obtained by other external devices or systems sending to the main control device. For example, a power-on instruction may be sent by a host computer. It should be noted that the command format of the rate switching instruction may be the same as the format of the service command, which will not be described in detail here.

[0094] Then, based on the switching device information, determine the external device to be switched;

[0095] Finally, based on the switching rate information, the drive interface corresponding to the external device to be switched is updated.

[0096] In this embodiment, after the external device to be switched is determined, the drive interface is determined, and accordingly, the rate of the drive interface can be updated so that the drive interface can communicate at a new rate to meet various demand scenarios.

[0097] Please see Figure 4 , Figure 4 The schematic diagram of the flow chart of the rate configuration according to the embodiment of the present application is schematically shown. The rate switching process is illustrated below by taking the SPI interface mode as an example. It should be noted that the rate switching process of other interface modes, such as UART, I2C, etc., is the same as that of SPI, which will not be repeated here.

[0098] After the master device is powered on, it completes SPI initialization at the default rate. After receiving the command data from the host computer, it determines whether the command data is a rate switching command. If so, the master device re-initializes SPI according to the new rate data. After the data transmission is completed, the master device is powered off and the negotiation rate is restored to the default value. It should be noted that the rate adjustment generally corresponds to external devices. If each external device requires a rate, an independent SPI interface is required for the master device to connect. If an independent SPI interface corresponds to multiple external devices, after switching the rate, all external devices also switch the rate at the same time.

[0099] Please see Figure 5 , Figure 5 The structure block diagram of an interface communication system according to an embodiment of the present application is schematically shown. This embodiment provides an interface communication system, including a host computer and a main control device, wherein the main control device is connected to multiple external devices via a communication interface;

[0100] The host computer is used to send each service instruction to the main control device respectively, and each service instruction includes external device information;

[0101] The main control device is used to obtain multiple business instructions issued by the upper computer, and based on each business instruction, determine the corresponding business thread in the preset business thread set, the preset business thread set includes multiple business threads, each business thread corresponds to an external device; the corresponding business thread calls the driver interface, and exchanges data with the corresponding external device through the driver interface.

[0102] In this embodiment, the host computer can be connected to the main control device through a network interface. After the business instruction sends the data to the main control device through the interface of the host computer, the main control device sends the data to the specified external device according to the relevant protocol requirements, and returns the result data processed by the external device to the host computer. The host computer sends the business command to the main control device, and the main control device sends it to the relevant external device through the interface to complete the data interaction between the host computer and the external device. It should be noted that when a communication interface is connected to multiple external devices, the main control device can select the device to communicate with each interface through the chip select signal.

[0103] For example: the host computer sends external data to the master device through the network port. The master device receives the data through the network port driver, determines the data format, determines which external device corresponding to the SPI interface the data is interacting with, and then starts the service thread of the SPI interface, and interacts with the corresponding external device through the SPI driver interface. Then, after the processing is completed, the master device starts the service thread to receive the result data and sends the result data to the host computer.

[0104] In some embodiments, see Figure 6 , Figure 6 The schematic diagram of the command sending format according to the embodiment of the present application is schematically shown. In order to facilitate reading of instruction information, the command format of the above-mentioned business instruction may include the following fields: starting byte (1Byte), length (2Byte), interface index (2Byte), instruction number (2Byte), data (XByte) and check byte (1Byte). Among them, Byte represents byte, the starting byte can be fixed to 0xAD, occupying 1 byte length; the length represents the number of bytes of all data lengths from the starting byte to the data, occupying 2 bytes in length, and stored in big-endian mode; the interface index represents which interface the command data is sent to, occupying 2 bytes in length, and stored in big-endian mode, for example, it is an SPI interface, that is, an SPI interface index. In this embodiment, the above-mentioned external device information may be stored in this field. The instruction number indicates what command the current command is, occupies 2 bytes in length, and is stored in big-endian mode. The data represents the subsequent command data of the current instruction, occupies X bytes in length, and is stored in big-endian mode. The check byte represents the integrity detection value of the current command data, and all data from the starting byte to the data are subjected to byte XOR operation, and the result is negated, occupying 1 byte in length. By designing the command format of business instructions, it is convenient for the main control device to obtain command information from the host computer.

[0105] Wherein, the main control device includes a receiving thread and a service distribution thread;

[0106] The receiving thread is used to obtain multiple business instructions issued by the host computer, and save the multiple business instructions to the user RAM_BUF;

[0107] The service distribution thread is used to determine the corresponding service thread in the preset service thread set according to each service instruction, and send each service instruction to the corresponding service thread respectively;

[0108] The corresponding service thread is used to call the driver interface, and perform data interaction with the corresponding external device through the driver interface, and save the data results received during the data interaction process into the user RAM_BUF.

[0109] In this embodiment, the main control device may pre-set a receiving thread, which is responsible for processing the acquired service instructions and saving the service instructions to the user RAM_BUF for processing. The user RAM_BUF refers to a buffer in the user space, which is usually used to store data that the user program needs to process.

[0110] The RAM_BUF mentioned in this embodiment can be an array, a pointer, or a structure of other data types, which is used to temporarily store data or calculation results in the user program. A service distribution thread can be set in advance in the main control device. The service distribution thread is responsible for determining which service thread the current service belongs to based on the service instruction, and then distributing the service instruction to the relevant service thread. By setting the service distribution thread, the service distribution thread can quickly determine the corresponding service thread.

[0111] Wherein, the main control device also includes a sending thread and a business sorting thread;

[0112] The business collating thread is used to move the data results received during the data interaction from the user RAM_BUF to the data transceiver RAM_BUF after completing the data interaction. The data transceiver RAM_BUF is a data transceiver buffer between the host computer and the master control device;

[0113] The sending thread is used to send the data result from the data transceiver RAM_BUF to the host computer.

[0114] In this embodiment, the business sorting thread is a collection thread, which is responsible for moving the processed data from the user RAM_BUF to the data transceiver RAM_BUF; the sending thread is responsible for sending the result of the interaction processing of the master device to the host computer. It should be noted that the data transceiver RAM_BUF can be determined according to the way the data is interacted between the host computer and the master device. For example, if the data is interacted between the host computer and the master device through the network port driver, the data transceiver RAM_BUF is the network RAM_BUF. The above results can be sent to the host computer in the format of the command return result, please refer to Figure 7 , Figure 7The format diagram of the command return result according to the embodiment of the present application is schematically shown. The format of the command return result may include the following fields: starting byte (1 Byte), length (2 Byte), interface index (2 Byte), instruction number (2 Byte), return status (2 Byte), return data (X Byte) and check byte (1 Byte). Among them, the starting byte can be fixed to 0xAD, occupying 1 byte length; the length represents the number of bytes of all data lengths from the starting byte to the data, occupying 2 bytes in length, and stored in big-endian mode; the interface index indicates which interface the command data is sent to, occupies 2 bytes in length, and is stored in big-endian mode. For example, if it is an SPI interface, it is an SPI interface index. In this embodiment, the above external device information may be stored in this field. The instruction number indicates what command the current command is, occupies 2 bytes in length, and is stored in big-endian mode. The return status indicates the result of the current command execution, occupies 2 bytes in length, and is stored in big-endian mode. The return data indicates that when the current instruction execution result is successful, if there is data to be returned, it occupies X bytes in length and is stored in big-endian mode. The check byte indicates the integrity check value of the current command data. All data from the start byte to the data are XORed and the result is inverted, occupying 1 byte length. By designing the format of the command return result, it is convenient for the master device to transmit the result to the host computer.

[0115] For example, the threads of the master control device include: receiving thread, sending thread, business distribution thread, business thread 1, business thread 2, business thread 3, business thread 4 and business finishing thread, a total of 8 threads. Among them, the receiving thread and the sending thread have higher priority than the business thread. Each business thread corresponds to an SPI driver function module, which is used to interact with an external device for command data processing. The process of task scheduling includes:

[0116] (1) The receiving thread is responsible for processing the data sent from the host computer and saving the sent data to the user RAM_BUF, waiting for processing;

[0117] (2) The business distribution thread is responsible for determining which business thread the current data belongs to based on the SPI data index field of the sent data, and then distributing the data to the relevant business threads;

[0118] (3) Service threads 1 to 4, each thread exchanges the received data with the corresponding external device through the corresponding SPI driver module, and saves the received data results to the user RAM_BUF, waiting for the sending thread to send it to the host computer;

[0119] (4) The business finishing thread is a collection thread responsible for moving the processed data from the user RAM_BUF to the network RAM_BUF;

[0120] (5) The sending thread is responsible for sending the results of the interaction processing of the main control device to the host computer.

[0121] In the above implementation process, after the business instruction sends the data to the main control device through the interface of the host computer, the main control device sends the data to the designated external device according to the relevant protocol requirements, and returns the result data processed by the external device to the host computer. The main control device is connected to multiple external devices through the communication interface, and obtains multiple business instructions, each of which includes external device information; based on each business instruction, the corresponding business thread is determined in the preset business thread set, and the preset business thread set includes multiple business threads, each business thread corresponds to an external device; the corresponding business thread calls the driver interface, and exchanges data with the corresponding external device through the driver interface. By setting each business thread to correspond to an external device, the corresponding business thread is determined in the preset business thread set, and the corresponding business thread exchanges data with the corresponding external device, and automatically and reasonably multi-task scheduling is performed to realize the automatic configuration to support the data transmission requirements of multiple external devices, thereby realizing the parallel access of multiple external devices through multi-threading technology, increasing the performance of data interaction, and improving communication efficiency.

[0122] It should be noted that the above-mentioned master control device can also configure the interface driver rate of the master control device through instructions, so as to automatically adapt to the needs of the external device and update the rate of the driver interface. The specific implementation process is the same as the implementation process in the above-mentioned interface communication method, and will not be repeated here.

[0123] Please see Figure 8 , Figure 8 The structure block diagram of an interface communication device according to an embodiment of the present application is schematically shown. This embodiment provides an interface communication device, which is applied to a main control device, and the main control device is connected to multiple external devices through a communication interface. The interface communication device includes:

[0124] An acquisition module 410 is used to acquire multiple business instructions, each of which includes external device information;

[0125] A determination module 420, configured to determine a corresponding service thread in a preset service thread set based on each service instruction, wherein the preset service thread set includes a plurality of service threads, and each service thread corresponds to an external device;

[0126] The interaction module 430 is used for the corresponding service thread to call the driver interface and perform data interaction with the corresponding external device through the driver interface.

[0127] The acquisition module 410 includes:

[0128] The receiving unit is used to obtain each service instruction by a receiving thread, and save each service instruction into a corresponding list in the user memory according to the external device information in each service instruction.

[0129] Wherein, the determination module 420 includes:

[0130] The distribution unit is used for determining the corresponding service thread in the preset service thread set according to the external device information in each service instruction by the service distribution thread, and distributing each service instruction to the corresponding service thread.

[0131] The interaction module 430 includes:

[0132] The mobilization unit is used to call the driver interface by the corresponding service thread according to the time slice scheduling method, and to perform data exchange with the corresponding external device through the driver interface.

[0133] The interface communication device includes a processor and a memory. The acquisition module 410, the determination module 420 and the interaction module 430 are all stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions.

[0134] The processor contains a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and by adjusting the kernel parameters, parallel access to multiple external devices can be achieved through multi-threading technology, which increases the performance of data interaction and improves communication efficiency.

[0135] The memory may include non-permanent memory in a computer-readable medium, 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.

[0136] An embodiment of the present invention provides a machine-readable storage medium on which a program is stored. When the program is executed by a processor, the interface communication method is implemented.

[0137] An embodiment of the present invention provides a processor, which is used to run a program, wherein the interface communication method is executed when the program is running.

[0138] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor A01, a network interface A02, a display screen A04, an input device A05 and a memory (not shown in the figure) connected through a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A06. The non-volatile storage medium A06 stores an operating system B01 and a computer program B02. The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A06. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor A01, an interface communication method is implemented. The display screen A04 of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device A05 of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0139] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0140] In one embodiment, the interface communication device provided by the present application can be implemented in the form of a computer program. The computer program can be Fig. 9 The computer device shown in the figure is run. The memory of the computer device can store various program modules constituting the interface communication device, such as: Figure 8 The acquisition module 410, determination module 420 and interaction module 430 are shown. The computer program composed of various program modules enables the processor to execute the steps of the interface communication method of each embodiment of the present application described in this specification.

[0141] Fig. 9 The computer device shown can be Figure 8 In the interface communication device shown, the acquisition module 410 executes step 210 , the determination module 420 executes step 220 , and the interaction module 430 executes step 230 .

[0142] The embodiment of the present application provides a device, which includes a processor, a memory, and a program stored in the memory and executable on the processor, and is applied to a main control device, wherein the main control device is connected to a plurality of external devices via a communication interface, and the processor implements the following steps when executing the program:

[0143] Acquire multiple business instructions, each of which includes external device information;

[0144] Based on each service instruction, a corresponding service thread is determined in a preset service thread set, wherein the preset service thread set includes a plurality of service threads, and each service thread corresponds to an external device;

[0145] The corresponding service thread calls the driver interface and exchanges data with the corresponding external device through the driver interface.

[0146] In one embodiment, the obtaining of multiple service instructions includes:

[0147] The receiving thread obtains each service instruction respectively, and saves each service instruction into a corresponding list in the user RAM_BUF according to the external device information in each service instruction.

[0148] In one embodiment, the determining of corresponding service threads from a preset service thread set based on each service instruction respectively includes:

[0149] The service distribution thread determines the corresponding service thread in the preset service thread set according to the external device information in each service instruction, and distributes each service instruction to the corresponding service thread.

[0150] In one embodiment, the corresponding service thread calling the driver interface and performing data interaction with the corresponding external device through the driver interface includes:

[0151] The corresponding service thread calls the driver interface in a time slice scheduling manner, and performs data interaction with the corresponding external device through the driver interface.

[0152] In one embodiment, before obtaining the multiple service instructions, the method further includes:

[0153] Obtaining a power-on instruction, wherein the power-on instruction includes power-on device information and rate parameter information;

[0154] In response to the power-on instruction, powering on the external device corresponding to the powered-on device information;

[0155] When it is determined that the external device corresponding to the powered-on device information is powered on completely, a drive interface corresponding to the external device is initialized based on the rate parameter information.

[0156] In one embodiment, it further includes:

[0157] Acquire a rate switching instruction, wherein the rate switching instruction includes switching device information and switching rate information;

[0158] Based on the switching device information, determine the external device to be switched;

[0159] Based on the switching rate information, a drive interface corresponding to the external device to be switched is updated.

[0160] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0161] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0162] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0163] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0164] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0165] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0166] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules 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 technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0167] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0168] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. An interface communication method, characterized in that: Applied to a main control device, the main control device is connected to multiple external devices via a communication interface, and the interface communication method includes: Acquire multiple business instructions, each of which includes external device information; Based on each service instruction, a corresponding service thread is determined in a preset service thread set, wherein the preset service thread set includes a plurality of service threads, and each service thread corresponds to an external device; The corresponding service thread calls the driver interface and exchanges data with the corresponding external device through the driver interface.

2. The interface communication method according to claim 1, characterized in that: The obtaining of multiple business instructions includes: The receiving thread obtains each service instruction respectively, and saves each service instruction into a corresponding list in the user RAM_BUF according to the external device information in each service instruction.

3. The interface communication method according to claim 2, characterized in that: The determining of corresponding service threads from a preset service thread set based on each service instruction respectively includes: The service distribution thread determines the corresponding service thread in the preset service thread set according to the external device information in each service instruction, and distributes each service instruction to the corresponding service thread.

4. The interface communication method according to claim 3, characterized in that: The corresponding service thread calls the driver interface and performs data interaction with the corresponding external device through the driver interface, including: The corresponding service thread calls the driver interface in a time slice scheduling manner, and performs data interaction with the corresponding external device through the driver interface.

5. The interface communication method according to claim 1, characterized in that: Before obtaining multiple business instructions, it also includes: Obtaining a power-on instruction, wherein the power-on instruction includes power-on device information and rate parameter information; In response to the power-on instruction, powering on the external device corresponding to the powered-on device information; When it is determined that the external device corresponding to the powered-on device information is powered on completely, a drive interface corresponding to the external device is initialized based on the rate parameter information.

6. The interface communication method according to claim 1, characterized in that: Also includes: Acquire a rate switching instruction, wherein the rate switching instruction includes switching device information and switching rate information; Based on the switching device information, determine the external device to be switched; Based on the switching rate information, a drive interface corresponding to the external device to be switched is updated.

7. An interface communication system, characterized in that: It includes a host computer and a main control device, wherein the main control device is connected to multiple external devices via a communication interface; The host computer is used to send each service instruction to the main control device respectively, and each service instruction includes external device information; The main control device is used to obtain multiple business instructions issued by the upper computer, and based on each business instruction, determine the corresponding business thread in the preset business thread set, the preset business thread set includes multiple business threads, each business thread corresponds to an external device; the corresponding business thread calls the driver interface, and exchanges data with the corresponding external device through the driver interface.

8. The interface communication system according to claim 7, characterized in that: The main control device includes a receiving thread and a service distribution thread; The receiving thread is used to obtain multiple business instructions issued by the host computer, and save the multiple business instructions to the user RAM_BUF; The service distribution thread is used to determine the corresponding service thread in the preset service thread set according to each service instruction, and send each service instruction to the corresponding service thread respectively; The corresponding service thread is used to call the driver interface, and perform data interaction with the corresponding external device through the driver interface, and save the data results received during the data interaction process into the user RAM_BUF.

9. The interface communication system according to claim 8, characterized in that: The main control device also includes a sending thread and a business sorting thread; The business collating thread is used to move the data results received during the data interaction from the user RAM_BUF to the data transceiver RAM_BUF after completing the data interaction. The data transceiver RAM_BUF is a data transceiver buffer between the host computer and the master control device; The sending thread is used to send the data result from the data transceiver RAM_BUF to the host computer.

10. An interface communication device, characterized in that: Applied to a main control device, the main control device is connected to multiple external devices via a communication interface, and the interface communication device includes: An acquisition module, used for acquiring multiple business instructions, each of which includes external device information; A determination module, configured to determine a corresponding service thread in a preset service thread set based on each service instruction, wherein the preset service thread set includes a plurality of service threads, and each service thread corresponds to an external device; The interaction module is used for the corresponding service thread to call the driver interface and perform data interaction with the corresponding external device through the driver interface.

11. The interface communication device according to claim 10, characterized in that: The acquisition module comprises: The receiving unit is used to obtain each service instruction by a receiving thread, and save each service instruction into a corresponding list in the user RAM_BUF according to the external device information in each service instruction.

12. The interface communication device according to claim 11, characterized in that: The determination module comprises: The distribution unit is used for determining the corresponding service thread in the preset service thread set according to the external device information in each service instruction by the service distribution thread, and distributing each service instruction to the corresponding service thread.

13. The interface communication device according to claim 12, characterized in that: The interaction module includes: The mobilization unit is used to call the driver interface by the corresponding service thread according to the time slice scheduling method, and to perform data exchange with the corresponding external device through the driver interface.

14. An electronic device, characterized in that: The electronic device includes: at least one processor; a memory connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the at least one processor implements the interface communication method according to any one of claims 1 to 6 by executing the instructions stored in the memory.

15. A machine-readable storage medium having instructions stored thereon, characterized in that: When the instruction is executed by a processor, the processor is configured to execute the interface communication method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Switch interface rate self-adaptive tuning system and method, equipment and medium

    CN110880952A

  • Asynchronous calling method and device, storage medium and electronic equipment

    CN112988356A

  • Concurrent transaction method, device and equipment and readable storage medium

    CN116719757A

  • Data synchronization processing method and device, server and storage medium

    CN117763043A

  • Communication Methods and Systems, Electronic Devices, and Computer Clusters

    US20190140982A1