Interface Communication Method, Apparatus, System, Storage Medium, and Electronic Device

Through multi-threading technology, multiple external devices are obtained in parallel access to the main control device, solving the problem of inefficient communication of existing interfaces, and achieving efficient data interaction and automatic adaptation of external devices.

CN119440750BActive Publication Date: 2025-08-01BEIJING SMARTCHIP MICROELECTRONICS TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The existing interface communication method adopts a single task method, resulting in low communication efficiency and inability to 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, uses the driver interface to interact with the external device to achieve parallel access to multiple external devices.

Benefits of technology

It improves the performance and communication efficiency of data interaction, supports automatic configuration and data transmission of multiple external devices, and is suitable for external devices with different speed requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440750B_ABST
    Figure CN119440750B_ABST
Patent Text Reader

Abstract

The present invention provides an interface communication method, apparatus, system, storage medium and electronic device, belonging to the field of communication technology. The interface communication method is applied to a master device, and the master device is connected with a plurality of external devices through a communication interface, including: obtaining a plurality of service instructions, each service instruction including external device information; respectively determining corresponding service threads in a preset service thread set based on each service instruction, the preset service thread set including a plurality of service threads, each service thread corresponding to an external device; and calling a driver interface by the corresponding service thread and performing data interaction with the corresponding external device through the driver interface. Automatic and reasonable multi-task scheduling processing is carried out to meet the requirement of automatically configuring data transmission for multiple external devices, thereby realizing parallel access to multiple external devices through multi-threading technology, increasing the performance of data interaction and improving the communication efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technologies, 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 interaction technology for a computer main control software with various external devices of a computer, and is responsible for connecting an I / O circuit and a peripheral device together through a system bus by a main control device.

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

[0004] The existing interface communication adopts a single-task mode, and it is necessary to wait for a command to be sent and responded before processing the second command. This communication method has low efficiency and cannot meet user requirements. 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] To achieve the above purpose, a first aspect of the present application provides an interface communication method, which is applied to a main control device. The main control device is connected with multiple external devices through a communication interface. The interface communication method includes:

[0007] Obtain multiple service instructions, and each service instruction includes external device information;

[0008] Based on each service instruction, respectively determine a corresponding service thread in a preset service thread set. The preset service thread set includes multiple service threads, and each service thread corresponds to an external device;

[0009] The corresponding service thread calls a driver interface, and data interaction is performed with the corresponding external device through the driver interface.

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

[0011] Each service instruction is obtained by a receiving thread, and according to the external device information in each service instruction, each service instruction is respectively saved to a corresponding list in the user RAM_BUF.

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

[0013] A service distribution thread determines corresponding service threads from a preset set of service threads according to the external device information in each service instruction, and distributes each service instruction to the corresponding service thread.

[0014] In an embodiment of the present application, the corresponding service thread calls a driver interface and performs data interaction with a 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 an embodiment of the present application, before obtaining multiple service instructions, it further includes:

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

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

[0019] When it is determined that the power-on of the external device corresponding to the power-on device information is completed, initialize the driver interface corresponding to the external device based on the rate parameter information.

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

[0021] Obtain a rate switching instruction, where 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, update the driver interface corresponding to the external device to be switched.

[0024] A second aspect of the present application provides an interface communication system, including a host computer and a main control device, where the main control device is connected with a plurality of external devices through a communication interface;

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

[0026] The master control device is used to obtain a plurality of service instructions sent by the host computer, and respectively determine corresponding service threads in a preset service thread set based on each service instruction. 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 performs data interaction with the corresponding external device through the driver interface.

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

[0028] The receiving thread is used to obtain a plurality of service instructions sent by the host computer and save the plurality of service instructions to the user RAM_BUF;

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

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

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

[0032] The service sorting thread is used to move the data result received during the data interaction process from the user RAM_BUF to the data transceiver RAM_BUF after the data interaction is completed. 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 applied to a master control device. The master control device is connected with a plurality of external devices through a communication interface. The interface communication device includes:

[0035] An acquisition module, configured to acquire a plurality of service instructions, and each service instruction includes external device information;

[0036] A determination module, configured to respectively determine corresponding service threads from a preset service thread set based on each service instruction, where the preset service thread set includes multiple service threads, and each service thread corresponds to an external device;

[0037] An interaction module, configured to call a driver interface by the corresponding service thread and perform data interaction with the corresponding external device through the driver interface.

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

[0039] A receiving unit, configured to respectively acquire each service instruction by a receiving thread, and save each service instruction to a corresponding list in a user RAM_BUF according to the external device information in each service instruction.

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

[0041] A distribution unit, configured to determine a corresponding service thread from a preset service thread set according to the external device information in each service instruction by a service distribution thread, and distribute each service instruction to the corresponding service thread.

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

[0043] A mobilization unit, configured to call a driver interface by the corresponding service thread according to a time slice scheduling method and perform data interaction with the corresponding external device through the driver interface.

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

[0045] At least one processor;

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

[0047] Wherein, the memory stores instructions executable by the at least one processor, and the at least one processor implements the above 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, on which instructions are stored, and when the instructions are executed by a processor, the processor is configured to execute the above interface communication method.

[0049] Through the above technical solution, the master device is connected with multiple external devices through a communication interface, and by obtaining multiple service instructions, each service instruction includes external device information; respectively based on each service instruction, a corresponding service thread is determined in a preset service thread set, the preset service thread set includes multiple service threads, and each service thread corresponds to an external device; the corresponding service thread calls a driver interface and performs data interaction with the corresponding external device through the driver interface. By setting each service thread to correspond to an external device, determining the corresponding service thread in the preset service thread set, and performing data interaction between the corresponding service thread and the corresponding external device, automatic and reasonable multi-task scheduling processing is realized, meeting the requirement of automatically configuring data transmission for multiple external devices, 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 specific implementation part. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0052] Figure 1 Schematically shows a flowchart of an interface communication method according to an embodiment of the present application;

[0053] Figure 2 Schematically shows a connection diagram of a main control chip and an external device according to an embodiment of the present application;

[0054] Figure 3 Schematically shows a processing flow diagram from a host computer to a main device according to an embodiment of the present application;

[0055] Figure 4 Schematically shows a flowchart of rate configuration according to an embodiment of the present application;

[0056] Figure 5 Schematically shows a structural block diagram of an interface communication system according to an embodiment of the present application;

[0057] Figure 6 Schematically shows a schematic diagram of a command sending format according to an embodiment of the present application;

[0058] Figure 7 Schematically shows a format diagram of a command return result according to an embodiment of the present application;

[0059] Figure 8 Schematically shows a structural block diagram of an interface communication device according to an embodiment of the present application;

[0060] Figure 9 Schematically shows an internal structure diagram of a computer device according to an embodiment of the present application.

[0061] Description of the 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 implementation manners

[0063] The following will describe in detail the specific implementation manners of the embodiments of the present invention with reference to the accompanying drawings. It should be understood that the specific implementation manners described herein are only used to illustrate and explain the embodiments of the present invention, and are not used to limit the embodiments of the present invention.

[0064] Please refer to Figure 1 , Figure 1 Schematically shows a flowchart 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 master device. The master device is connected with a plurality of external devices through a communication interface. The interface communication method includes the following steps: < / /

[0065] Step 210: Acquire a plurality of service instructions, and each service instruction includes external device information;

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

[0067] For example: Please refer to Figure 2 ,Figure 2 Schematically shows a connection diagram of a main control chip and external devices according to an embodiment of the present application. 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, an SPI interface, etc. External device 1 is connected to the main control device through the I2C interface, external device 2 is connected to the main control device through the USB interface, external device 3 is connected to the main control device through the SPI interface, and external device 4 is connected to the main control device through the UART interface.

[0068] The above business instructions may be obtained by a user inputting to the main control device, or may be obtained by other external devices or systems sending them to the main control device. The above business instructions include information such as external device information and command data, so that the main control device determines which external device to perform which data interaction according to the business instructions. The above external device information may be an external device name, number, or interface index number, etc.

[0069] In some embodiments, the obtaining of multiple business instructions includes: the receiving thread respectively obtains each business instruction, and according to the external device information in each business instruction, saves each business instruction to a corresponding list in the user RAM_BUF.

[0070] In this embodiment, a receiving thread may be preset in the main control device. The receiving thread is responsible for processing the obtained 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 needs to be processed by the user program. The RAM_BUF may be an array, a pointer, or a structure of other data types, and is used to temporarily store data or calculation results in the user program.

[0071] For example, please refer to Figure 3 , Figure 3 Schematically shows a processing flow diagram between the host computer and the main device according to an embodiment of the present application. 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 and the main control device are connected through a network port. When the external data is sent from the host computer to the main control device, it may be to send one business instruction each time. After the main control device network port driver receives an interrupt signal, it releases the semaphore of the network port driver transceiver processing thread and triggers the transceiver thread. The main control device network port driver module determines whether there is a free area in the NET RAM (network memory) for receiving data. If so, the main control device stores the received data into the corresponding NET RAM space and returns a successful reception. The receiving thread moves the instruction numbers in the external data in the NET RAM to different lists in the user RAM_BUF.

[0072] Save the service instruction to the user RAM_BUF through the receiving thread for easy reading of the service instruction later.

[0073] Step 220: Based on each service instruction respectively, determine the corresponding service thread in the preset service thread set. The preset service thread set includes multiple service threads, and each service thread corresponds to an external device.

[0074] In this embodiment, multiple service threads are preset in the above-mentioned preset service thread set. Each service thread performs data interaction between the received data and the corresponding external device through the corresponding driver module and saves the received data result. Since the service instruction contains 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 this driver module is used to perform command data interaction processing with an external device.

[0075] In some embodiments, the determining the corresponding service thread in the 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.

[0076] In this embodiment, a service distribution thread can be preset in the main control device. The service distribution thread is responsible for judging 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 corresponding service thread can be quickly determined by the service distribution thread.

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

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

[0079] In some embodiments, the corresponding service thread calls the driver interface and performs data interaction with the corresponding external device through the driver interface includes: 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.

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

[0081] In the above implementation process, the master device is connected with multiple external devices through a communication interface, and by obtaining multiple service instructions, each service instruction includes external device information; respectively based on each service instruction, the corresponding service thread is determined in the preset service thread set, and the preset service thread set includes multiple service threads, and each service thread corresponds to an external device; the corresponding service thread calls the driver interface and interacts with the corresponding external device through the driver interface. By setting each service thread to correspond to an external device, determining the corresponding service thread in the preset service thread set, and having the corresponding service thread interact with the corresponding external device, automatic and reasonable multitasking scheduling processing is realized, meeting the requirement of automatically configuring data transmission for multiple external devices, thereby achieving parallel access to multiple external devices through multithreading technology, increasing the performance of data interaction, and improving communication efficiency.

[0082] For any general interface function in the master device, it can complete data interaction with multiple external devices and automatically adapt to the external devices of each interface, so it can be applicable to the scenario of a single driver interface.

[0083] In some embodiments, according to the situation that external devices interacting with the master device through the communication interface have different rate requirements, the rate of the interface driver of the master device can be configured through instructions to facilitate automatic adaptation to the needs of external devices. Specifically, before obtaining multiple service instructions, the following steps can be executed:

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

[0085] In this embodiment, the above power-on instruction can be obtained by the user inputting it to the master device, or can be obtained by other external devices or systems sending it to the master device. For example, the power-on instruction can be sent by the upper computer. It should be noted that the command format of the above power-on instruction can be the same as that of the above service command, and will not be elaborated here.

[0086] Then, in response to the power-on instruction, power on the external device corresponding to the power-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 power-on of the external device corresponding to the power-on device information is completed, based on the rate parameter information, initialize the drive interface corresponding to the external device.

[0089] In this embodiment, the above initialization can be to write the rate parameter information into the driver, so as to communicate at the corresponding rate to meet the requirements of the external device. For example, in the above example, the network port protocol of the master device (master device) receives the power-on instruction sent by the host computer, then determines which external device corresponds to the SPI interface, and then the master device powers on the external device corresponding to the corresponding interface through relevant General-purpose input / output (GPIO) pins. Then, initialize the SPI drive 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 according to the data content in the power-on command, after the interface device is powered on, initialize the drive interface and complete the rate configuration, so as to realize the dynamic management of the rate and increase the applicable range of external devices. The rates of different external devices can be automatically configured without modifying the device driver function, meeting more external devices with different rates.

[0091] In some embodiments, during the communication process, there may be a demand scenario for rate change. Therefore, the method further includes the following steps:

[0092] First, obtain a rate switching instruction, where the rate switching instruction includes switching device information and switching rate information;

[0093] In this embodiment, the above rate switching instruction can be obtained by the user inputting it to the master device, or can be obtained by other external devices or systems sending it to the master device. For example, it can be the host computer sending a power-on instruction. It should be noted that the command format of the above rate switching instruction can be the same as the format of the above service command, which will not be elaborated here.

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

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

[0096] In this embodiment, after determining the external device to be switched, that is, determining the drive interface, correspondingly, 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 refer to Figure 4 , Figure 4 which schematically shows a flowchart of the configuration of the rate according to an embodiment of the present application. The rate switching process will be exemplified below in the SPI interface mode. It should be noted that for other interface modes, such as UART, I2C, etc., the rate switching process is the same as that of SPI, and will not be elaborated here.

[0098] After the master device is powered on and starts up, it completes the 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 the SPI according to the new rate data. After the data transmission ends, the power-down negotiation rate of the master device returns to the default value. It should be noted that the rate adjustment generally corresponds to external devices. If each external device requires a certain rate, for the master device, an independent SPI interface is required for docking. If an independent SPI interface corresponds to multiple external devices, after the rate is switched, all external devices will also switch the rate simultaneously.

[0099] Please refer to Figure 5 , Figure 5 which schematically shows a block diagram of the structure of an interface communication system according to an embodiment of the present application. This embodiment provides an interface communication system, including a host computer and a main control device, and the main control device is connected with a plurality of external devices through a communication interface;

[0100] The host computer is used to issue 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 a plurality of service instructions issued by the host computer, and respectively determine corresponding service threads in a preset service thread set based on each service instruction. 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 performs data interaction 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 service instruction sends the data to the main control device through the interface of the host computer, the main control device sends this 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. By sending a service command from the host computer to the main control device, and the main control device sends it to the relevant external device through the interface, the data interaction between the host computer and the external device is completed. It should be noted that in the case where a communication interface is connected to a plurality of external devices, the main control device can select the device communicating with each interface through a chip select signal.

[0103] For example, the host computer sends external data to the master control device end through the network port. The master control device end drives the received data through the network port, judges the data format, determines which external device corresponding to the SPI interface the data interacts with, then starts the service thread of this SPI interface, and performs data interaction processing with the corresponding external device through the SPI driver interface. Then, after the processing is completed, the master control device starts this service thread to receive the result data and sends the result data to the host computer.

[0104] In some embodiments, please refer to Figure 6 , Figure 6 which schematically shows a schematic diagram of the command sending format according to an embodiment of the present application. To facilitate reading of the instruction information, the command format of the above service instruction may include the following fields: start byte (1Byte), length (2Byte), interface index (2Byte), instruction number (2Byte), data (XByte), and check byte (1Byte). Among them, Byte represents a byte. The start byte can be fixed as 0xAD and occupies 1 byte length; the length represents the number of bytes of all data lengths from the start byte to the data, occupies 2 byte lengths, and is stored in big-endian mode; the interface index represents which interface the command data is sent to, occupies 2 byte lengths, and is stored in big-endian mode. For example, if it is an SPI interface, it is the SPI interface index. In this embodiment, the above external device information can be stored in this field. The instruction number represents what command the current command is, occupies 2 byte lengths, and is stored in big-endian mode. The data represents the command data following the current instruction, occupies X byte lengths, and is stored in big-endian mode. The check byte represents the integrity detection value of the current command data. All data from the start byte to the data is subjected to a byte exclusive OR operation, and the result is inverted, occupying 1 byte length. By designing the command format of the service instruction, it is convenient for the master control device to obtain command information from the host computer.

[0105] Among them, the master control device includes a receiving thread and a service distribution thread;

[0106] The receiving thread is used to obtain a plurality of service instructions sent by the host computer and save the plurality of service 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, perform data interaction with the corresponding external device through the driver interface, and save the data result received during the data interaction process to the user RAM_BUF.

[0109] In this embodiment, a receiving thread can be preset in the master device. The receiving thread is responsible for processing the obtained service instructions, saving the service 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 needs to be processed by the user program.

[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 preset in the master device. The service distribution thread is responsible for judging which service thread the current service belongs to according to the service instructions, and then distributing the service instructions to the relevant service threads. By setting the service distribution thread, the corresponding service thread can be quickly determined by the service distribution thread.

[0111] Among them, the master device further includes a sending thread and a service sorting thread;

[0112] The service sorting thread is used to move the data result received during the data interaction from the user RAM_BUF to the data transceiver RAM_BUF after the data interaction is completed. The data transceiver RAM_BUF is a data transceiver buffer between the host computer and the master 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 above service sorting thread is a gathering 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 above data transceiver RAM_BUF can be determined according to the data interaction method between the host computer and the master device. For example, if the data interaction between the host computer and the master device is through a network interface driver, the data transceiver RAM_BUF is the network RAM_BUF. The above result is sent to the host computer can be transmitted in the format of the command return result, please refer to Figure 7 , Figure 7A schematic diagram showing the format of the command return result according to an embodiment of the present application is shown. The format of the above command return result may include the following fields: start byte (1Byte), length (2Byte), interface index (2Byte), instruction number (2Byte), return status (2Byte), return data (XByte), and check byte (1Byte). Among them, the start byte can be fixed to 0xAD and occupies 1 byte in length; the length represents the number of bytes of all data lengths from the start byte to the data, occupies 2 bytes in length, and is 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 the SPI interface index. In this embodiment, the above external device information can 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 represents the result of the execution of the current command, occupies 2 bytes in length, and is stored in big-endian mode; the return data represents the data that needs to be returned if the execution result of the current instruction is successful, 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. All data from the start byte to the data is subjected to a byte exclusive OR operation, and the result is inverted, occupying 1 byte in 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 device include: a receiving thread, a sending thread, a service distribution thread, service thread 1, service thread 2, service thread 3, service thread 4, and a service sorting thread, a total of 8 threads. Among them, the receiving thread and the sending thread have higher priorities than the service threads. Each service thread corresponds to an SPI driver function module, and this driver module 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, saving the sent data to the user RAM_BUF, and waiting for processing;

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

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

[0119] (4) The service sorting thread is a converging 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 master device's interaction processing to the host computer.

[0121] In the above implementation process, after the service instruction sends data to the master device through the interface of the host computer, the master device sends this data to the specified external device according to the requirements of relevant protocols, and returns the result data processed by the external device to the host computer. The master device is connected to multiple external devices through a communication interface, and by obtaining multiple service instructions, each service instruction includes external device information; respectively based on each service instruction, a corresponding service thread is determined in a preset service thread set, and the preset service thread set includes multiple service threads, and each service thread corresponds to an external device; the corresponding service thread calls the driver interface and performs data interaction with the corresponding external device through the driver interface. By setting each service thread to correspond to an external device, determining the corresponding service thread in the preset service thread set, and performing data interaction between the corresponding service thread and the corresponding external device, automatic and reasonable multitasking scheduling processing is achieved, meeting the requirement of automatically configuring data transmission for multiple external devices, thereby realizing parallel access to 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 master device can also complete the configuration of the rate of the interface driver of the master device through instructions, so as to automatically adapt to the requirements of external devices and update the rate of the driver interface. The specific implementation process is the same as that in the above interface communication method and will not be elaborated here.

[0123] Please refer to Figure 8 , Figure 8 which schematically shows a structural block diagram of an interface communication device according to an embodiment of the present application. This embodiment provides an interface communication device applied to a master device. The master device is connected to multiple external devices through a communication interface. The interface communication device includes:

[0124] An acquisition module 410, configured to acquire multiple service instructions, and each service instruction includes external device information;

[0125] A determination module 420, configured to respectively determine corresponding service threads in a preset service thread set based on each service instruction. The preset service thread set includes multiple service threads, and each service thread corresponds to an external device;

[0126] An interaction module 430 is used to be called by the corresponding service thread to drive an interface and perform data interaction with a corresponding external device through the drive interface.

[0127] Among them, the obtaining module 410 includes:

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

[0129] Among them, the determining module 420 includes:

[0130] A distribution unit is used to determine a corresponding service thread from a preset set of service threads by a service distribution thread according to the external device information in each service instruction, and distribute each service instruction to the corresponding service thread.

[0131] Among them, the interaction module 430 includes:

[0132] A mobilizing unit is used to call the drive interface by the corresponding service thread in a time slice scheduling manner and perform data interaction with a corresponding external device through the drive interface.

[0133] The interface communication device includes a processor and a memory. The above-mentioned obtaining module 410, determining module 420, interaction module 430, etc. are all stored in the memory as program units, and the corresponding functions are realized by the processor executing the above program units stored in the memory.

[0134] The processor contains a kernel, and the kernel is used to retrieve 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 is completed through multi-threading technology, which increases the performance of data interaction and improves the communication efficiency.

[0135] The memory may include non-permanent memory in a computer-readable medium, forms such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM), and the memory includes at least one storage chip.

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

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

[0138] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structural diagram may be as shown in Figure 9 . 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 may be a liquid crystal display screen or an electronic ink display screen. The input device A05 of the computer device may be a touch layer covered on the display screen, or may be a button, a trackball, or a touchpad provided on the computer device housing, or may also be an external keyboard, touchpad, or mouse, etc.

[0139] Those skilled in the art can understand that Figure 9 the structure shown in is only a block diagram of some structures 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 some components, or have different component arrangements.

[0140] In one embodiment, the interface communication device provided by the present application may be implemented in the form of a computer program, and the computer program can run on a computer device as shown in Figure 9 . In the memory of the computer device, each program module constituting the interface communication device may be stored. For example, Figure 8 the acquisition module 410, the determination module 420, and the interaction module 430 shown in. The computer program composed of each program module enables the processor to execute the steps in the interface communication method of each embodiment of the present application described in this specification.

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

[0142] An 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. The device is applied to a master device, and the master device is connected with a plurality of external devices through a communication interface. When the processor executes the program, the following steps are implemented:

[0143] Obtain a plurality of service instructions, and each service instruction includes external device information;

[0144] Based on each service instruction respectively, determine the corresponding service thread in a preset service thread set. 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 performs data interaction with the corresponding external device through the driver interface.

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

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

[0148] In one embodiment, the determining of the corresponding service thread in the 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 calls the driver interface and performs 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 plurality of service instructions, it further includes:

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

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

[0155] When it is determined that the power-on of the external device corresponding to the power-on device information is completed, based on the rate parameter information, initialize the drive interface corresponding to the external device.

[0156] In one embodiment, it further includes:

[0157] Obtain a rate switching instruction, where 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, update the drive interface corresponding to the external device to be switched.

[0160] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.

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

[0162] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implements the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.

[0163] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide for implementing the steps in the process Figure 1 one process or multiple processes and / or blocks Figure 1 steps of the functions specified in one block or multiple blocks.

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

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

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

[0167] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the existence of additional identical elements in the process, method, commodity or device comprising the element.

[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, various modifications and changes can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims

1. An interface communication method, characterized in that, Applied to a master device, the master device is connected with a plurality of external devices through a communication interface, the master device is a chip, and the interface communication method includes: Obtain a plurality of service instructions, and each service instruction includes external device information; the host computer is connected to the master device through a network port, and external data is sent from the host computer to the master device; after the master device network port driver receives an interrupt signal, it releases the semaphore of the network port driver transceiver processing thread and triggers the transceiver thread. The master device network port driver module determines whether there is a free area in the NET RAM network memory for receiving network data. If so, the master device stores the received data into the corresponding NET RAM space and returns a successful reception; the reception thread moves the instruction numbers in the external data in the NET RAM to different lists in the user RAM_BUF. Based on each service instruction, determine the corresponding service thread in a preset service thread set. The preset service thread set includes a plurality of service threads, and each service thread corresponds to an external device; each service thread performs data interaction between the received data and the corresponding external device through the corresponding driver module and saves the received data result; each service thread corresponds to a driver function module, and this driver module is used to perform command data interaction processing with an external device. The corresponding service thread calls the driver interface and performs data interaction with the corresponding external device through the driver interface.

2. The interface communication method according to claim 1, wherein The step of determining the corresponding service thread in the preset service thread set based on each service instruction 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.

3. The interface communication method according to claim 2, characterized in that The step of the corresponding service thread calling the driver interface and performing data interaction with the corresponding external device through the driver interface includes: 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.

4. The interface communication method according to claim 1, wherein Before obtaining a plurality of service instructions, it further includes: Obtain a power-on instruction, and the power-on instruction includes power-on device information and rate parameter information; In response to the power-on instruction, power on the external device corresponding to the power-on device information; When it is determined that the power-on of the external device corresponding to the power-on device information is completed, initialize the driver interface corresponding to the external device based on the rate parameter information.

5. The interface communication method according to claim 1, characterized in that It further includes: Obtain a rate switching instruction, and 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, update the driver interface corresponding to the external device to be switched.

6. An interface communication system, characterized in that, It includes a host computer and a master device. The master device is connected with a plurality of external devices through a communication interface, and the master device is a chip; The host computer is used to issue each service instruction to the master control device respectively, and each service instruction includes external device information; the host computer is connected to the master control device through a network port, and external data is sent from the host computer to the master control device; after the master control device network port driver receives an interrupt signal, it releases the semaphore of the network port driver transceiver processing thread and triggers the transceiver thread. The master control device network port driver module determines whether there is an idle area in the NET RAM network memory for receiving network data. If so, the master control device stores the received data into the corresponding NET RAM space and returns a successful reception; The receiving thread moves the instruction numbers in the external data in the NET RAM to different lists in the user RAM_BUF; The master control device is used to obtain multiple service instructions issued by the host computer, and respectively determine corresponding service threads in a preset service thread set based on each service instruction. The preset service thread set includes multiple service threads, and each service thread corresponds to an external device; each service thread performs data interaction between the received data and the corresponding external device through the corresponding driver module and saves the received data result; there is a corresponding driver function module in each service thread, and this driver module is used to perform command data interaction processing with an external device; the corresponding service thread calls the driver interface and performs data interaction with the corresponding external device through the driver interface.

7. The interface communication system according to claim 6, wherein The master control device further includes a sending thread and a service sorting thread; The service sorting thread is used to move the data result received during the data interaction process from the user RAM_BUF to the data transceiver RAM_BUF after the data interaction is completed. The data transceiver RAM_BUF is the 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.

8. An interface communication device, characterized in that, Applied to the master control device, the master control device is connected with multiple external devices through a communication interface. The master control device is a chip, and the interface communication device includes: An acquisition module, which is used to acquire multiple service instructions, and each service instruction includes external device information; the host computer is connected to the master control device through a network port, and external data is sent from the host computer to the master control device; after the master control device network port driver receives an interrupt signal, it releases the semaphore of the network port driver transceiver processing thread and triggers the transceiver thread. The master control device network port driver module determines whether there is an idle area in the NET RAM network memory for receiving network data. If so, the master control device stores the received data into the corresponding NET RAM space and returns a successful reception; the receiving thread moves the instruction numbers in the external data in the NET RAM to different lists in the user RAM_BUF; A determination module, configured to respectively determine corresponding service threads in a preset service thread set based on each service instruction, where the preset service thread set includes multiple service threads, and each service thread corresponds to an external device; each service thread performs data interaction between the received data and the corresponding external device through the corresponding driver module, and stores the received data result; each service thread corresponds to a driver function module, and this driver module is used to perform command data interaction processing with an external device. An interaction module, configured to be called by the corresponding service thread to call a driver interface, and perform data interaction with the corresponding external device through the driver interface.

9. The interface communication device according to claim 8, wherein, The determination module includes: A distribution unit, configured to determine corresponding service threads in a preset service thread set by a service distribution thread according to the external device information in each service instruction, and distribute each service instruction to the corresponding service thread.

10. The interface communication device according to claim 9, characterized in that, The interaction module includes: A scheduling unit, configured to be called by the corresponding service thread to call a driver interface in a time slice scheduling manner, and perform data interaction with the corresponding external device through the driver interface.

11. An electronic device, characterized in that, The electronic device includes: At least one processor; A memory, connected to the at least one processor; 12. A machine-readable storage medium having instructions stored thereon, characterized in that, Wherein, the memory stores instructions executable by the at least one processor, and the at least one processor implements the interface communication method according to any one of claims ͳ to ͷ by executing the instructions stored in the memory. When the instruction is executed by the processor, the processor is configured to execute the interface communication method according to any one of claims ͳ to ͷ.

Citation Information

Patent Citations

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

    CN116719757A

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

    CN117763043A