Embedded front and back end communication method and device, electronic equipment and storage medium

By adopting the FFI specification and Protobuf format bus transceiver module in embedded devices, the problem of unstable front-end and back-end communication in embedded devices is solved, achieving efficient and stable communication and resource saving.

CN116112552BActive Publication Date: 2026-02-03SHANGHAI DATANG MOBILE COMM EQUIP
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111327340.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-10
Publication Date
2026-02-03
Estimated Expiration
2041-11-10

AI Technical Summary

Technical Problem

In embedded devices, front-end and back-end communication is unstable and inefficient, and existing technologies struggle to achieve efficient and stable communication.

Method used

The bus transceiver module, which adopts the FFI specification, converts front-end request messages into internal messages and sends them when the back-end program is idle. It uses the Protobuf format for data transmission to avoid gateway congestion.

Benefits of technology

It improves the efficiency and stability of front-end and back-end communication, reduces hardware resource consumption, avoids gateway congestion, and achieves stable transmission under high concurrency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116112552B_ABST
    Figure CN116112552B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide an embedded front-end and back-end communication method and device, electronic equipment and storage medium, the embedded front-end and back-end communication method comprises: receiving the first request message sent by the front end, and converting the first request message into a first internal message;Wherein the first request message is used to request the back-end program processing;Judge whether the back-end program is in idle state, in the case where the back-end program is in idle state, the first internal message is sent to the back-end program for processing.The embedded front-end and back-end communication method, device, electronic equipment and storage medium provided by the embodiments of the present application, by uniformly converting the format of the request message into the format of the internal message, improve the efficiency of front-end and back-end communication transmission, by only sending internal message when the back-end program is idle, avoid the gateway jam, realize the stable transmission between front-end and back-end.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to an embedded front-end and back-end communication method, device, electronic device, and storage medium. Background Technology

[0002] As more and more embedded devices connected to the Internet appear in production and daily life, the backends of embedded devices are becoming more and more diverse, and the standards they follow are also different. Most of the various application and algorithm modules in the backend are written in backend languages ​​such as C, while the web frontend interface is generally written in frontend languages ​​such as Java, PHP, JS, and Lua.

[0003] Currently, in embedded devices, the interaction between front-end web pages and back-end algorithms often suffers from unstable communication and low efficiency. Therefore, how to achieve efficient and stable communication between the front-end and back-end in embedded devices has become an urgent problem to be solved. Summary of the Invention

[0004] To address the aforementioned problems in the existing technology, embodiments of this application provide an embedded front-end and back-end communication method, apparatus, electronic device, and storage medium.

[0005] In a first aspect, embodiments of this application provide an embedded front-end and back-end communication method, including:

[0006] Receive a first request message sent by the front end, the first request message being used to request the back end program to process;

[0007] Convert the first request message into a first internal message;

[0008] Determine whether the backend program is in an idle state. If the backend program is in an idle state, send the first internal message to the backend program for processing.

[0009] Optionally, according to an embodiment of the embedded front-end and back-end communication method of this application, determining whether the back-end program is in an idle state includes:

[0010] The system detects whether there are any internal messages waiting to be processed by the backend program in the bus message queue. If there are no internal messages waiting to be processed by the backend program in the bus message queue, it determines that the backend program is in an idle state.

[0011] Optionally, according to an embodiment of the embedded front-end and back-end communication method of this application, sending the first internal message to the back-end program includes:

[0012] Using a bus transceiver module that conforms to the External Function Call Interface (FFI) specification, the first internal message is queued in the bus message queue, and the backend program reads the first internal message from the bus message queue.

[0013] Optionally, the embedded front-end and back-end communication method according to one embodiment of this application further includes:

[0014] The program receives a second internal message returned by the backend program and converts the second internal message into a first return result, which is then processed by the frontend program.

[0015] Optionally, in an embedded front-end and back-end communication method according to an embodiment of this application, the first internal message and the second internal message conform to the Protobuf format.

[0016] Optionally, the embedded front-end and back-end communication method according to one embodiment of this application further includes:

[0017] The system receives a second request message sent by the front end, processes the second request message, generates a second return result, and uses the second return result for processing by the front end program.

[0018] Optionally, in an embodiment of the embedded front-end and back-end communication method of this application, the first request message and the second request message conform to the JSON format.

[0019] Secondly, embodiments of this application also provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to perform the following operations:

[0020] Receive a first request message sent by the front end, the first request message being used to request the back end program to process;

[0021] Convert the first request message into a first internal message;

[0022] Determine whether the backend program is in an idle state. If the backend program is in an idle state, send the first internal message to the backend program for processing.

[0023] Optionally, in an electronic device according to an embodiment of this application, determining whether the backend program is in an idle state includes:

[0024] The system detects whether there are any internal messages waiting to be processed by the backend program in the bus message queue. If there are no internal messages waiting to be processed by the backend program in the bus message queue, it determines that the backend program is in an idle state.

[0025] Optionally, according to one embodiment of this application, the electronic device sends the first internal message to the backend program including:

[0026] Using a bus transceiver module that conforms to the External Function Call Interface (FFI) specification, the first internal message is queued in the bus message queue, and the backend program reads the first internal message from the bus message queue.

[0027] Optionally, in an electronic device according to one embodiment of this application, the processor further executes the program to perform the following operations:

[0028] The program receives a second internal message returned by the backend program and converts the second internal message into a first return result, which is then processed by the frontend program.

[0029] Optionally, in an electronic device according to one embodiment of this application, the first internal message and the second internal message conform to the Protobuf format.

[0030] Optionally, in an electronic device according to one embodiment of this application, the processor further executes the program to perform the following operations:

[0031] The system receives a second request message sent by the front end, processes the second request message, generates a second return result, and uses the second return result for processing by the front end program.

[0032] Optionally, in an electronic device according to one embodiment of this application, the first request message and the second request message conform to JSON format.

[0033] Thirdly, embodiments of this application also provide an embedded front-end and back-end communication device, comprising:

[0034] A receiving unit is used to receive a first request message sent by the front end, the first request message being used to request the back end program to process;

[0035] A conversion unit is configured to convert the first request message into a first internal message;

[0036] The sending unit is used to determine whether the backend program is in an idle state, and if the backend program is in an idle state, to send the first internal message to the backend program for processing.

[0037] Fourthly, embodiments of this application also provide a processor-readable storage medium storing a computer program for causing the processor to perform the steps of the embedded front-end and back-end communication method according to any embodiment of the first aspect.

[0038] The embedded front-end and back-end communication method, apparatus, electronic device, and storage medium provided in this application improve the efficiency of front-end and back-end communication by uniformly converting the format of request messages into the format of internal messages, and avoid gateway congestion by sending internal messages only when the back-end program is idle, thus achieving stable transmission between the front-end and back-end. Attached Figure Description

[0039] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0040] Figure 1 This is a flowchart illustrating a JNI calling method provided in an embodiment of this application;

[0041] Figure 2 This is a schematic diagram of an FDBus open-source architecture provided in an embodiment of this application;

[0042] Figure 3 This is one of the flowcharts illustrating an embedded front-end and back-end communication method provided in an embodiment of this application;

[0043] Figure 4 This is a block diagram of an embedded front-end and back-end communication method provided in an embodiment of this application;

[0044] Figure 5 This is a second flowchart illustrating an embedded front-end and back-end communication method provided in an embodiment of this application;

[0045] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0046] Figure 7 This is a schematic diagram of the structure of an embedded front-end and back-end communication device provided in an embodiment of this application. Detailed Implementation

[0047] In the embodiments of this application, the term "and / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following associated objects have an "or" relationship.

[0048] In the embodiments of this application, the term "multiple" refers to two or more, and other quantifiers are similar.

[0049] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0050] Figure 1 This is a flowchart illustrating the process of calling a method using JNI (Java Native Interface, a mechanism for communication between Java code and external native code). (Reference) Figure 1 This section provides a brief description of JNI calling methods. Java is an object-oriented programming language, characterized by its powerful features and ease of use. The Java framework includes a JNI mechanism, or Java Native Interface, which allows calling native C / C++ functions for efficient operations. Further references are available. Figure 1 JNI can interact with native programs in the following way: First, create a class (.java file) and declare native methods. Then, use the `javaC` command to compile the source file, i.e., the native functions declared in the .java file, to generate a .class file. The next steps can be divided into two parallel parts. The first part uses `javah-jni` (javaH) to generate a C header file (.h file), which contains the function prototypes of the native methods (the native functions implemented in the .c file). The second part involves writing the implementation of the function prototypes in C code within the Java Virtual Machine (JVM). Finally, the two parts are combined, and the C functions are compiled into a native library using a C compiler and linker. `System.loadLibrary()` is then created, and the created native library is added to the shared library.

[0051] However, Linux systems are widely used in embedded devices. Due to limitations in the memory, CPU, and hard drive resources of these devices, and the resource-intensive nature of large Java frameworks, embedded devices often cannot use mature Java frameworks like Spring and Hibernate to call C programs via JNI. Furthermore, when calling C programs through JNI, the process resources used by the C program are managed by the JVM, which can easily lead to instability in the embedded system.

[0052] Another approach for embedded systems is the LuCI framework within the open-source router framework OpenWrt (Open Wireless Router, a Linux distribution used by various routers). LuCI is the web management interface for OpenWrt, employing a three-tier MVC (Model-View-Controller) architecture and developed using Lua scripts. Developing LuCI configuration interfaces requires no HTML editing; the framework allows for the transfer of web page interactions to C program execution. However, while LuCI development is convenient, its application is limited to the OpenWrt framework, restricting its use cases. Furthermore, web front-ends implemented using Lua are often not mainstream, and many new web technologies cannot be supported immediately.

[0053] Figure 2 This is a schematic diagram of an open-source fdbus (Fast Distributed Bus) architecture. (See reference) Figure 2This section provides a brief description of the FDBus message middleware. Linux systems offer various effective communication solutions, such as the FDBus open-source framework, which easily enables bus-based communication between C programs (and only between C / C++ programs). A middleware layer developed based on FDBus consists of multiple processes. Each process can run multiple threads, and FDBus runs a specific event loop on top of these threads, including worker threads capable of executing transactions. The two communicating parties in FDBus—the server and the client—are collectively referred to as endpoints. Endpoints can be deployed on different worker threads; multiple endpoints can also share the same worker thread. Middleware developers can use a single worker thread to handle events from multiple endpoints, avoiding excessive thread consumption and the "concurrency disaster" caused by multithreading. Developers can also use multiple worker threads to serve a single endpoint; for example, an endpoint can create worker threads to perform time-consuming operations such as file downloads, video encoding / decoding, and peripheral I / O. A more important function of FDBus is inter-process communication. Processes cannot directly pass objects; they can only interact through messages, and message transmission requires serialization, while receiving messages requires deserialization. Inter-process communication uses sockets, including UDS (Unix Domain Socket) and TCP (Transmission Control Protocol) sockets. The system automatically selects the appropriate type based on the server and client deployments. Currently, it supports diverse communication modes, such as synchronous request-response with timeouts, asynchronous request-response with timeouts, command requests without responses, register-publish patterns, and multicasting. However, the fdbus open-source framework exists only in C programs, meaning it cannot be applied to the front end beyond the backend algorithm.

[0054] Some products also use point-to-point custom sockets for communication between C and the front end, but none of them have formed a universal mode that is particularly suitable for embedded devices.

[0055] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0056] Figure 3 This is one of the flowcharts illustrating an embedded front-end and back-end communication method provided in an embodiment of this application. (Refer to...) Figure 3 The embedded front-end and back-end communication method provided in this application includes:

[0057] Step 310: Receive a first request message sent by the front end, the first request message being used to request the back end program to process;

[0058] Step 320: Convert the first request message into a first internal message;

[0059] In embedded front-end and back-end communication, the front-end, such as the browser, sends request data. The request data is often in character format, which is easy to process directly. However, when the front-end and back-end interact to complete data processing, the character format of the request data is not conducive to transmission and has poor coupling. Therefore, it is necessary to convert the data format of the request message.

[0060] Step 330: Determine whether the backend program is in an idle state. If the backend program is in an idle state, send the first internal message to the backend program for processing.

[0061] The embedded front-end and back-end communication method provided in this application embodiment combines the advantages of various communication schemes. Optionally, PHP (Hypertext Preprocessor) is used as the front-end design language, and the calling method adopts the socket communication method with the lowest coupling. Unlike many front-end and back-end communication schemes, this embodiment does not use the PHP language to directly send and receive socket messages, because doing so would make the PHP program independent of bus control.

[0062] This application embodiment improves system communication reliability by integrating front-end and back-end communication into the system bus and judging the status of back-end programs, thus avoiding message congestion.

[0063] Optionally, in one embodiment of this application, determining whether the backend program is in an idle state includes:

[0064] The system detects whether there are any internal messages waiting to be processed by the backend program in the bus message queue. If there are no internal messages waiting to be processed by the backend program in the bus message queue, it determines that the backend program is in an idle state.

[0065] Specifically, backend algorithm programs generally have long processing times. Without message queue management, as the number of concurrent requests from the frontend increases, the gateway may become completely blocked and unresponsive. One reason for this is that PHP's own thread pool management program cannot control the state of the algorithm program.

[0066] In this embodiment, by detecting whether there are internal messages waiting to be processed by the backend program in the bus message queue, it can be determined whether the backend program is in an idle state, which can avoid gateway congestion and achieve stable transmission between the frontend and the backend.

[0067] Optionally, in one embodiment of this application, sending the first internal message to the backend program includes:

[0068] The bus transceiver module, which conforms to the Foreign Function Interface (FFI) specification, queues the first internal message into the bus message queue, and the backend program reads the first internal message from the bus message queue.

[0069] Specifically, this embodiment adopts the bus management model of the Linux system and designs a bus transceiver C module that conforms to the FFI (Functional Functionality) specification, so that the PHP program has the same form as the C algorithm program. All requests coming from the web (web page) front-end are converted into bus message streams and queued in order according to the processing status of each module's C program. In some embodiments, other specifications different from the FFI specification may also be used.

[0070] The embodiments of this application make the use of hardware resources more reasonable through the above-described solution, without the need for locking.

[0071] Figure 4 This is a block diagram of an embedded front-end and back-end communication method provided in an embodiment of this application. (Refer to...) Figure 4 This paper further elaborates on the embedded front-end and back-end communication method provided in the embodiments of this application. The PHP process includes an interface rendering module 410, a communication module 411, an FFI language interaction interface 412, a database operation module 413, and other transaction modules 414. Specifically, the FFI language interaction interface is connected not only to the communication module 411 but also to the bus transceiver C module 415, which sends and receives sockets. The sockets are transmitted to the C algorithm process via the bus. The C algorithm process includes a TensorRT engine 420, an algorithm operation unit 421, and various worker threads 422, including threads for file downloading, video decoding, and peripheral I / O. Messages received by the bus are converted into transactions by the interaction instruction processing module 423 and then processed by the worker threads to complete the back-end program's work. The bus transceiver C module also includes an algorithm mode change module 424. The TensorRT engine is a high-performance deep learning inference acceleration engine that enables low-latency, high-throughput deployment of deep learning models on GPUs. The TensorRT engine is developed in C++ and provides a C++ API interface.

[0072] This application's embodiment adopts the FFI external interface pattern in its call design to make the interaction between the virtual machine and the underlying binary code smooth and natural. In this embodiment, instead of using a JNI-like calling method, the socket message sending and receiving module is placed within it. This significantly reduces the PHP process scheduling load, integrates the entire message interaction control within the Linux bus, and fully decouples the front-end and back-end, resulting in a very simple system framework.

[0073] Optionally, in one embodiment of this application, the embedded front-end and back-end communication method further includes:

[0074] The program receives a second internal message returned by the backend program and converts the second internal message into a first return result, which is then processed by the frontend program.

[0075] Specifically, after the backend processes the request, the returned result can be transmitted to the frontend through the frontend-backend communication method provided in this application embodiment, so that the processing result can be displayed on the frontend.

[0076] Optionally, in one embodiment of this application, the first internal message and the second internal message conform to the Protobuf format.

[0077] Specifically, this application embodiment uses the Protobuf binary format for internal messages, significantly improving overall transmission efficiency. Protobuf is a data exchange format, also known as PB encoding, open-sourced by Google. Internally, it is a pure binary format, primarily used for data serialization and deserialization. The embedded front-end and back-end communication method provided in this application allows for the automatic generation of source code in multiple languages ​​via a Protobuf compiler by customizing the required data format once. This facilitates convenient reading and writing of custom-formatted data and is applicable to multiple languages ​​and platforms. Furthermore, it can update existing data formats based on older formats without altering the original data format. In some embodiments, other formats different from Protobuf can also be used.

[0078] Optionally, in one embodiment of this application, the embedded front-end and back-end communication method further includes:

[0079] The system receives a second request message sent by the front end, processes the second request message, generates a second return result, and uses the second return result for processing by the front end program.

[0080] Specifically, when an external request enters the PHP program, the PHP program judges the request. If the backend algorithm process does not need to process it, the corresponding data operation or interface display can be performed directly.

[0081] Optionally, in one embodiment of this application, the first request message and the second request message conform to the JSON format.

[0082] Specifically, JSON (JavaScript Object Notation) is a lightweight data-interchange format that uses a text format completely independent of programming languages ​​to store and represent data. In this embodiment, the data formats that can be used for front-end and back-end interaction include JSON, XML, and forms. Web front-ends generally use JSON character type, which, although highly readable, results in very long messages and reduced transmission efficiency. Therefore, format conversion is necessary during front-end and back-end communication, converting JSON to Protobuf format.

[0083] Figure 5 This is a second flowchart illustrating an embedded front-end and back-end communication method provided in an embodiment of this application. (Refer to...) Figure 5 The embedded front-end and back-end communication method provided in the embodiments of this application will be further described.

[0084] From a data flow perspective, in step 510, the external HTTP request enters the PHP program. Since the web frontend uses JSON character format for transmission, the external HTTP request is in JSON character format. In some embodiments, the web frontend can also use XML format for transmission. XML, also known as Extensible Markup Language, is a cross-language data format.

[0085] Then, the PHP program determines whether the JSON content of the HTTP type needs to be processed by the backend algorithm process. For example, in step 520, if the PHP program determines that no algorithm process is needed, it can directly perform the corresponding data operations or display the interface. The result returned in step 521 is also in JSON format.

[0086] When the PHP program determines that algorithm processing is required, it converts the JSON message into a Protobuf binary message format in step 511 and transmits it to the bus message queue in step 512. The algorithm and other C programs then receive and execute the messages sequentially. The FFI interface C module determines whether the backend program is idle.

[0087] After the intelligent algorithm module finishes processing, it returns the result in Protobuf binary message format generated by the algorithm in step 513. In step 514, the PHP program converts the Protobuf format result into JSON format content and then returns it to the front end.

[0088] The embedded front-end and back-end communication method provided in this application has advantages such as lightweight, high performance, and high concurrency queues.

[0089] The embedded front-end and back-end communication method provided in this application embodiment has the advantages of small size, low resource consumption, and greater simplicity compared to the existing mature frameworks for traditional front-end and back-end systems.

[0090] The embedded front-end and back-end communication method provided in this application uses binary transmission for internal transmission, which greatly reduces the amount of data compared to the original JSON format, effectively utilizes the bandwidth on the bus, and significantly improves performance.

[0091] The embedded front-end and back-end communication method provided in this application differs from general algorithm front-end web. The gateway designed in this application has a significantly reduced load, all messages are executed sequentially without interference between them, and message switching takes almost no time, greatly improving the utilization of hardware.

[0092] The embedded front-end and back-end communication method provided in this application does not use third-party libraries that large frameworks rely on, but only uses the classic bus framework on embedded Linux. This means that the web front-end and back-end do not need to add extra overhead, making it very suitable for the resource-constrained embedded field. Since the entire transmission mechanism is close to the original communication method of binary C programs, even if there is a virtual machine for a high-level language like PHP, due to the decoupling relationship, the internal messages are unified as binary streams, and the performance is well guaranteed. One of the advantages of the embedded front-end and back-end communication method provided in this application is that there is no need to worry too much about the blocking problem introduced by front-end concurrency. Hardware performance bottlenecks will only cause the message return time to increase, but will not cause gateway abnormalities. During development, only the algorithm processing performance needs to be considered.

[0093] Figure 6 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 6 As shown, the electronic device may include a processor 610, a transceiver 620, a memory 630, and a bus interface 640. The processor 610, transceiver 620, and memory 630 communicate with each other via the bus interface 640.

[0094] The processor 610 can call logical instructions in the memory 630 to execute an embedded front-end and back-end communication method. The method includes: receiving a first request message sent by the front-end, the first request message being used to request the back-end program to process; converting the first request message into a first internal message; determining whether the back-end program is in an idle state, and if the back-end program is in an idle state, sending the first internal message to the back-end program for processing.

[0095] Among them, Figure 6In this configuration, bus interface 640 may include any number of interconnected buses and bridges, specifically linking various circuits of one or more processors represented by processor 610 and memory represented by memory 630 together. The bus architecture may also link various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. Transceiver 620 provides an interface. For different devices, transceiver 620 may also be an interface capable of connecting external or internal devices, including but not limited to keypads, displays, speakers, microphones, joysticks, etc.

[0096] The processor 610 is responsible for managing the bus architecture and general processing, while the memory 630 can store the data used by the processor 610 during operation.

[0097] Optionally, the processor 610 can be a CPU (Central Processing Unit), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array), or CPLD (Complex Programmable Logic Device), and the processor can also adopt a multi-core architecture.

[0098] The processor 610 executes any of the methods described in the embodiments of this application according to the obtained executable instructions by calling a computer program stored in memory. The processor and memory may also be physically separated.

[0099] Optionally, in one embodiment of this application, determining whether the backend program is in an idle state includes:

[0100] The system detects whether there are any internal messages waiting to be processed by the backend program in the bus message queue. If there are no internal messages waiting to be processed by the backend program in the bus message queue, it determines that the backend program is in an idle state.

[0101] Optionally, in one embodiment of this application, sending the first internal message to the backend program includes:

[0102] Using a bus transceiver module that conforms to the External Function Call Interface (FFI) specification, the first internal message is queued in the bus message queue, and the backend program reads the first internal message from the bus message queue.

[0103] Optionally, in one embodiment of this application, the processor further executes the program to perform the following operations:

[0104] The program receives a second internal message returned by the backend program and converts the second internal message into a first return result, which is then processed by the frontend program.

[0105] Optionally, in one embodiment of this application, the first internal message and the second internal message conform to the Protobuf format.

[0106] Optionally, in one embodiment of this application, the processor further executes the program to perform the following operations:

[0107] The system receives a second request message sent by the front end, processes the second request message, generates a second return result, and uses the second return result for processing by the front end program.

[0108] Optionally, in one embodiment of this application, the first request message and the second request message conform to the JSON format.

[0109] It should be noted that the electronic device provided in this embodiment of the invention can implement all the method steps implemented in the above method embodiment and achieve the same technical effect. Therefore, the parts and beneficial effects that are the same as those in the method embodiment will not be described in detail here.

[0110] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0111] Figure 7 This is a schematic diagram of an embedded front-end and back-end communication device provided in an embodiment of this application. (Refer to...) Figure 7 The embedded front-end and back-end communication device provided in this application embodiment includes:

[0112] The receiving unit 710 is used to receive a first request message sent by the front end, the first request message being used to request the back end program to process;

[0113] The conversion unit 720 is used to convert the first request message into a first internal message;

[0114] The sending unit 730 is used to determine whether the backend program is in an idle state, and if the backend program is in an idle state, to send the first internal message to the backend program for processing.

[0115] It should be noted that the division of units in the embodiments of this application is illustrative and only represents one logical functional division. In actual implementation, other division methods may be used. Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units described above can be implemented in hardware or as software functional units.

[0116] It should be noted that the apparatus provided in this embodiment of the invention can implement all the method steps implemented in the above method embodiment and can achieve the same technical effect. Therefore, the parts and beneficial effects that are the same as those in the method embodiment will not be described in detail here.

[0117] On the other hand, the present invention also provides a computer program product, the computer program product including a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, and when the program instructions are executed by a computer, the computer is able to execute the embedded front-end and back-end communication method provided by the above methods, the method including: receiving a first request message sent by a front-end, the first request message being used to request a back-end program to process; converting the first request message into a first internal message; determining whether the back-end program is in an idle state, and if the back-end program is in an idle state, sending the first internal message to the back-end program for processing.

[0118] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the aforementioned embedded front-end and back-end communication methods. The method includes: receiving a first request message sent by a front-end, the first request message being used to request processing by a back-end program; converting the first request message into a first internal message; determining whether the back-end program is in an idle state, and if the back-end program is in an idle state, sending the first internal message to the back-end program for processing.

[0119] The processor-readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to magnetic memory (e.g., floppy disk, hard disk, magnetic tape, magneto-optical disk (MO)), optical memory (e.g., CD, DVD, BD, HVD), and semiconductor memory (e.g., ROM, EPROM, EEPROM, non-volatile memory (e.g., NAND flash), solid-state drive (SSD)).

[0120] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.

[0121] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-executable instructions. These computer-executable instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0122] These processor-executable instructions may also be stored in a processor-readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the processor-readable memory produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0123] These processors can execute instructions that can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0124] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. An embedded front-end and back-end communication method, characterized in that, include: Receive a first request message sent by the front end, the first request message being used to request the back end program to process; Determine whether backend processing is required. If so, convert the first request message into a first internal message. The first request message conforms to JSON format, and the first internal message conforms to Protobuf format. Determine whether the backend program is in an idle state. If the backend program is in an idle state, send the first internal message to the backend program for processing. Receive the second request message sent by the front end; When it is determined that the second request message does not need to be processed by the backend program, the second request message is processed by the PHP program to generate a second return result, which is then used by the frontend program for processing. The second request message conforms to JSON format, and the second return result conforms to JSON format.

2. The embedded front-end and back-end communication method according to claim 1, characterized in that, The determination of whether the backend program is in an idle state includes: The system detects whether there are any internal messages waiting to be processed by the backend program in the bus message queue. If there are no internal messages waiting to be processed by the backend program in the bus message queue, it determines that the backend program is in an idle state.

3. The embedded front-end and back-end communication method according to claim 2, characterized in that, Sending the first internal message to the backend program includes: Using a bus transceiver module that conforms to the External Function Call Interface (FFI) specification, the first internal message is queued in the bus message queue, and the backend program reads the first internal message from the bus message queue.

4. The embedded front-end and back-end communication method according to claim 1, characterized in that, Also includes: The program receives a second internal message returned by the backend program and converts the second internal message into a first return result, which is then processed by the frontend program.

5. The embedded front-end and back-end communication method according to claim 4, characterized in that, The second internal message conforms to the Protobuf format.

6. An electronic device, comprising a memory, a transceiver, and a processor: A memory for storing computer programs; a transceiver for sending and receiving data under the control of the processor; and a processor for reading the computer programs from the memory and performing the following operations: Receive a first request message sent by the front end, the first request message being used to request the back end program to process; Determine whether backend processing is required. If so, convert the first request message into a first internal message. The first request message conforms to JSON format, and the first internal message conforms to Protobuf format. Determine whether the backend program is in an idle state. If the backend program is in an idle state, send the first internal message to the backend program for processing. Receive the second request message sent by the front end; When it is determined that the second request message does not need to be processed by the backend program, the second request message is processed by the PHP program to generate a second return result, which is then used by the frontend program for processing. The second request message conforms to JSON format, and the second return result conforms to JSON format.

7. The electronic device according to claim 6, characterized in that, The determination of whether the backend program is in an idle state includes: The system detects whether there are any internal messages waiting to be processed by the backend program in the bus message queue. If there are no internal messages waiting to be processed by the backend program in the bus message queue, it determines that the backend program is in an idle state.

8. The electronic device according to claim 7, characterized in that, Sending the first internal message to the backend program includes: Using a bus transceiver module that conforms to the External Function Call Interface (FFI) specification, the first internal message is queued in the bus message queue, and the backend program reads the first internal message from the bus message queue.

9. The electronic device according to claim 6, characterized in that, The processor also executes the program to perform the following operations: The program receives a second internal message returned by the backend program and converts the second internal message into a first return result, which is then processed by the frontend program.

10. The electronic device according to claim 9, characterized in that, The first internal message and the second internal message conform to the Protobuf format.

11. An embedded front-end and back-end communication device, characterized in that, include: A receiving unit is used to receive a first request message sent by the front end, the first request message being used to request the back end program to process; The conversion unit is used to determine whether backend program processing is required. If so, it converts the first request message into a first internal message. The first request message conforms to JSON format, and the first internal message conforms to Protobuf format. The sending unit is used to determine whether the backend program is in an idle state, and if the backend program is in an idle state, to send the first internal message to the backend program for processing. The receiving unit is further configured to: receive a second request message sent by the front end; The generation unit is used to process the second request message using a PHP program and generate a second return result when it is determined that the second request message does not need to be processed by the backend program. The second return result is used for processing by the frontend program. The second request message conforms to JSON format, and the second return result conforms to JSON format.

12. A processor-readable storage medium, characterized in that, The processor-readable storage medium stores a computer program that causes the processor to perform the steps of the embedded front-end and back-end communication method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data format conversion method and equipment,and controller management system using data format conversion equipment

    US20040006401A1