Embedded device deployment method, distributed panel communication method and seat
By registering service functions in embedded devices and generating proxy functions, the RPC protocol components are simplified, solving the problem of large resource occupancy of the RPC protocol in embedded devices, achieving low resource occupancy and transparent calling, and is suitable for resources such as ergonomic chairs Restricted device.
Patent Information
- Application Number
- CN202410984195.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-07-22
AI Technical Summary
The existing RPC protocol takes up a lot of resources in embedded devices and requires the use of domain-specific languages to write remote service interfaces. It is difficult to apply to embedded devices with limited resources and no cross-platform requirements, such as ergonomic chairs.
By defining service functions during the program development process of the driver board and registering them to the user remote function list of the RPC protocol component, proxy functions with the same name as the service functions are generated, and these proxy functions are called in the main control board to achieve transparent calls and avoid Use the interface description language in traditional RPC protocol components to simplify RPC protocol components.
It realizes low resource occupation and transparent calling between the driver board and the main control board. It is suitable for embedded devices with limited resources and improves development efficiency.
Smart Images

Figure CN118502993B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of embedded communication technology, and in particular to a method for deploying embedded devices, a communication method for distributed panels, and a seat. Background Art
[0002] With the rapid development of intelligence, some ergonomic chairs have added intelligent configurations, such as electric adjustment of the lumbar support, sedentary reminders based on weight sensing, massage functions, etc. The implementation of these intelligent configurations requires corresponding driver boards and drivers. By setting a main control board in the ergonomic chair, the driver board is controlled to perform corresponding functions, and the main control board can also send requests to the driver board to obtain data.
[0003] In the field of Internet communications, the RPC (Remote Procedure Call) protocol can provide the most transparent calling mechanism and perfect fault-tolerant mechanism possible, reducing the difficulty of development for developers, so that developers do not need to directly face the complexity of underlying communication and data exchange. In the embedded field, multiple embedded devices usually communicate with each other through customized lightweight protocols, but the use of the RPC protocol needs to face the problem of the high resource consumption of the RPC protocol, and because the cross-platform capability of the RPC protocol needs to be realized, the remote service interface needs to be written in a specific domain language, which requires developers to learn related programming languages before they can use it. Obviously, it is not suitable for embedded devices such as ergonomic chairs, which have very limited resources and no cross-platform requirements. Summary of the invention
[0004] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
[0005] The embodiments of the present application provide a deployment method for an embedded device, a communication method for a distributed panel, and a seat, which can simplify the RPC framework and are suitable for embedded devices with very limited resources and no cross-platform requirements.
[0006] In a first aspect, an embodiment of the present application provides an automatic adjustment method for an ergonomic chair, which is applied to an embedded device of the ergonomic chair, wherein the embedded device includes a driver board as a server and a main control board as a client; the deployment method includes:
[0007] During the program development process of the driver board, receiving a service function input by a developer, wherein the service function includes a user-defined function name;
[0008] Calling the registration interface of the RPC protocol component, registering the service function as a user remote function into the user remote function list within the RPC protocol component;
[0009] During the program compilation process of the main control board, the proxy function generation script in the RPC protocol component is called, and a proxy function with the same name as the service function is generated in the program of the main control board through the proxy function generation script. The proxy function is used to add the number of the user remote function corresponding to the proxy function in the request message when the main control board sends a request message.
[0010] In some embodiments, the deployment method further comprises:
[0011] Determine the header file and function implementation file of the service function;
[0012] During the program compilation process of the driver board, the function implementation file of the service function is added to the compilation;
[0013] A proxy function implementation file corresponding to the header file of the service function is generated through the proxy function script in the RPC protocol component, and the proxy function implementation file is used to be compiled in the program compilation process of the main control board.
[0014] In some embodiments, the service function is registered as a user remote function in the user remote function list inside the RPC protocol component in the following manner:
[0015] The RPC protocol component checks the user remote function list and compares the user remote function name to be registered with the registered user remote function name;
[0016] If there is a function with the same name, the RPC protocol component returns a prompt message that a function with the same name has been registered;
[0017] If the same function name does not exist, the RPC protocol component adds a new line in the user remote function list to write the user remote function name to be registered, and assigns a corresponding number to the user remote function to be registered.
[0018] In some embodiments, the service function further includes a return code and a parameter list, and the format of the service function is:
[0019] Return code function name (input parameter buffer address, input parameter buffer effective length, output parameter buffer address, output parameter buffer effective length).
[0020] In some embodiments, the RPC protocol corresponding to the RPC protocol component defines the message format of the message exchanged between the driver board and the main control board, wherein:
[0021] The fields in the message format of the request message are: sequence number, request identifier, number of the user remote function, length of the call parameter, and value of the call parameter;
[0022] The fields in the registration format of the response message are: sequence number, response identifier, user remote function number, return code, length of the return parameter value, and return parameter value.
[0023] In a second aspect, an embodiment of the present application provides a communication method of a distributed panel, which is applied to an embedded device of an ergonomic chair deployed by the deployment method described in the first aspect; the communication method comprises:
[0024] The main control board generates a request message through the proxy function, and the request message includes the number of the user remote function corresponding to the proxy function;
[0025] The main control board serializes the request message, and sends the serialized request message to the driver board;
[0026] The driver board receives the request message through the communication interface of the RPC protocol component, deserializes and parses the received request message to obtain the number of the user remote function;
[0027] The driver board searches the user remote function list inside the RPC protocol component according to the number of the user remote function, and determines the service function corresponding to the number of the user remote function;
[0028] The driver board waits for the service function to return an execution result and then generates a response message, wherein the response message includes the number of the user remote function corresponding to the service function and the execution result;
[0029] The driver board serializes the response message and sends the serialized response message to the main control board;
[0030] The main control board deserializes and parses the received response message to obtain the execution result.
[0031] In some embodiments, the main control board generates a request message through the proxy function, including:
[0032] The main control board determines the proxy function corresponding to the currently initiated request;
[0033] The main control board determines the number of the corresponding user remote function according to the proxy function;
[0034] The main control board adds a serial number, a request identifier, a number of a user remote function corresponding to the proxy function, a length of a calling parameter and a value of the calling parameter to the message to generate a request message.
[0035] In some embodiments, the driver board deserializes and parses the received request message to obtain the number of the user remote function, including:
[0036] The driver board calls the serialization interface of the RPC protocol component to deserialize the received request message;
[0037] The driver board parses the serial number of the deserialized request message, determines that the request message of the main control board is complete according to the serial number of at least one received request message, and further determines the number of the user remote function located after the request identification field in the request message.
[0038] In some embodiments, the driver board waits for the service function to return an execution result and then generates a response message, including:
[0039] The driver board loads and executes the service function, and waits for the service function to return an execution result;
[0040] After receiving the execution result, the driver board determines the length and the return parameter value of the return parameter value in the execution result;
[0041] The driver board adds a return code, the number of the corresponding user remote function determined by the service function, the length of the return parameter value and the return parameter value in the message to generate a response message.
[0042] In some embodiments, the driver board adds a return code, the number of the corresponding user remote function determined by the service function, the length of the return parameter value and the return parameter value in the message, and generates a response message, including:
[0043] The driver board determines the number of response messages required to send the execution result, and generates a sequence number of a corresponding number sequence;
[0044] Fill the sequence numbers of the corresponding order in each response message according to the order of the sequence numbers, and set the return code in the last response message to the first value, and set the return code in the other response messages to the second value;
[0045] The response message is filled with the number of the user remote function corresponding to the service function, the length of the return parameter value and the return parameter value in the order of the response message.
[0046] In some embodiments, the main control board parses the deserialized response message to obtain the execution result, including:
[0047] The main control board fills the length of the return parameter value and the return parameter value in the deserialized response message into the output parameter buffer;
[0048] The main control board determines whether the initiated request is executed successfully according to the return code;
[0049] If it is determined that the initiated request is executed successfully and the return code includes the first value, the return parameter value is read from the output parameter buffer.
[0050] In some embodiments, if it is determined that the initiated request is executed successfully and the return code includes the first value, reading the return parameter value from the output parameter buffer includes:
[0051] The application of the main control board that initiates the request determines that the value of the return code is equal to the first value, then determines that the initiated request is executed successfully and a response message of the last sequence number is received;
[0052] The sequence number in the response message is checked to determine that all the response messages have been received, and the return parameter value is read from the output parameter buffer according to the length of the return parameter value.
[0053] The embedded device deployment method, distributed panel communication method and seat provided in the embodiments of the present application have at least the following beneficial effects: during the program development process of the driver board, the developer defines the service function and registers the service function as a user remote function in the user remote function list inside the RPC protocol component, and then calls the user remote function list inside the RPC protocol component during the program compilation process of the main control board to generate a proxy function with the same name as the service function, so that the main control board can call the service function with the same name when initiating a request to achieve transparent calling. Since the proxy function is deployed through the user remote function list and the driver board and the main control board belong to the same platform interaction, during the interaction between the driver board and the main control board of the present application, it is not necessary to use the interface description language in the traditional RPC protocol component to write the remote service interface. Therefore, the RPC protocol component of the present application has the advantages of small size and low resource occupation, and is particularly suitable for embedded devices with limited resources such as ergonomic chairs that do not require cross-platform development. A development model similar to the RPC framework can also be used, which can improve development efficiency.
[0054] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the examples of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0056] Figure 1 This is an overall flow chart of a method for deploying an embedded device provided by an embodiment of the present application;
[0057] Figure 2 is a flowchart of a compilation process provided by an embodiment of the present application;
[0058] Figure 3 This is a flowchart of RPC protocol component registration judgment provided by an embodiment of the present application;
[0059] Figure 4 It is an overall flow chart of a communication method of a distributed board provided by an embodiment of the present application;
[0060] Figure 5 It is a schematic diagram of communication interaction between a driver board and a main control board provided by an embodiment of the present application;
[0061] Figure 6 This is a flow chart of a main control board generating a request message provided by an embodiment of the present application;
[0062] Figure 7 This is a flow chart of a driver board processing a request message provided by an embodiment of the present application;
[0063] Figure 8 This is a flow chart of a driver board generating a response message provided by an embodiment of the present application;
[0064] Fig. 9 This is a flowchart of generating a response message based on a return code and a sequence number provided by an embodiment of the present application;
[0065] Fig.10 is a flowchart of reading a return parameter value based on a return code provided by an embodiment of the present application;
[0066] Fig.11 This is a flowchart of determining whether the response message reception is complete provided by an embodiment of the present application;
[0067] Fig.12 It is a schematic diagram of the connection structure of a controller provided in one embodiment of the present application. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. In addition, the characteristics, operations or features described in the specification can be combined in any appropriate manner to form various implementation methods. At the same time, the steps or actions in the method description can also be replaced or adjusted in order in a manner that is obvious to those skilled in the art. Therefore, the various sequences in the specification and the accompanying drawings are only for the purpose of clearly describing a certain embodiment and are not meant to be a necessary sequence, unless otherwise specified that a certain sequence must be followed.
[0069] In the description of this application, "several" means one or more, "more" means more than two, "greater than", "less than", "exceed", etc. are understood to exclude the number itself, and "above", "below", "within", etc. are understood to include the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0070] The serial numbers of the components in this document, such as "first", "second", etc., are only used to distinguish the objects described and do not have any order or technical meaning. The "connection" and "coupling" mentioned in this application, unless otherwise specified, include direct and indirect connections (couplings).
[0071] At present, the typical RPC protocol is applied to the Internet, requesting services from remote computer programs through the network without the need to understand the protocols of the underlying network technology locally. Therefore, the actual application of RPC is mainly in the interaction between the server and the client across the Internet platform. The client's request is converted based on the RPC protocol, and then the client's request is restored on the server based on the RPC protocol. The server performs the corresponding service based on the client's request, obtains the parameters to be returned, and sends them to the client after conversion based on the RPC protocol. The client obtains the parameters returned by the server after conversion based on the RPC protocol. In the OSI network communication model, the application of the RPC protocol spans the transport layer and the application layer, making it easier to develop applications including network distributed multi-programs. It can be seen that the client's remote call does not need to consider the protocol used by the transport layer, nor does it need to care about what language the server's application uses to run. At this time, the client's remote call method is almost the same as the local call method, which can realize transparent calls from the client. The RPC protocol needs to be connected to the client language and the server language. Therefore, typical RPC protocols are currently multi-language compatible. The remote service port of the RPC protocol is reflected as a client stub on the client and as a server stub on the server. Both the client stub and the server stub require a corresponding interface description language IDL (Interface description language). In order to achieve cross-platform compatibility, IDL has its own programming language, which requires users to learn related programming languages before using it. In addition, the use of IDL will make the RPC implementation technology relatively complex and occupy more resources. However, the computing performance and memory resources of Internet servers are relatively sufficient. Therefore, the RPC protocol can provide users with a calling mechanism that is as transparent as possible, a complete fault-tolerant mechanism, and cross-platform capabilities.
[0072] However, multiple devices in the embedded field usually communicate through customized lightweight protocols, but users are required to explicitly participate in the sending and receiving processes. Using RPC allows developers to focus more on the development of business logic without having to worry too much about the details of communication. Currently, relatively mature RPC middleware in the embedded field, such as Google's gRPC and NXP's eRPC, have the following shortcomings: In order to achieve more complete fault tolerance mechanisms and concurrency capabilities, these RPC protocols all include specific domain languages such as IDL to write remote service interfaces. The implementation technology is relatively complex and occupies relatively more resources. It is obviously not suitable for some embedded devices with very limited resources and no cross-platform requirements.
[0073] The modules of the electric control functions added to the ergonomic chair are usually implemented based on embedded devices, and multiple circuit boards are connected to the bus to display different functions. Since the interactive functions of each circuit board in the ergonomic chair are relatively simple, the use of RPC can reduce the burden on developers, but directly applying the traditional RPC protocol requires overcoming the problem that the RPC protocol occupies a lot of resources.
[0074] Based on this, the present application provides a deployment method for embedded devices, a communication method for distributed panels and a seat. During the program development process of the driver board, the developer defines a service function and registers the service function as a user remote function in the user remote function list inside the RPC protocol component. Then, during the program compilation process of the main control board, the user remote function list inside the RPC protocol component is called to generate a proxy function with the same name as the service function. In this way, the main control board can call the service function with the same name when initiating a request to achieve transparent calling. Since the proxy function is deployed through the user remote function list and the driver board and the main control board belong to the same platform interaction, during the interaction between the driver board and the main control board of the present application, there is no need to use the interface description language in the traditional RPC protocol component to write the remote service interface. Therefore, the RPC protocol component of the present application has the advantages of small size and low resource occupancy, and is particularly suitable for resource-constrained embedded devices such as ergonomic chairs that do not require cross-platform development. A development model similar to the RPC framework can also be used, which can improve development efficiency.
[0075] Reference Figure 1 As shown, the embodiment of the present application provides a method for deploying an embedded device, which is applied to an embedded device of an ergonomic chair, and the embedded device includes a driver board as a server and a main control board as a client; the deployment method includes but is not limited to the following steps:
[0076] Step S110, during the program development process of the driver board, receiving a service function input by a developer, the service function including a user-defined function name;
[0077] Step S120, calling the registration interface of the RPC protocol component, registering the service function as a user remote function into the user remote function list inside the RPC protocol component;
[0078] Step S130, during the program compilation process of the main control board, the proxy function generation script in the RPC protocol component is called, and a proxy function with the same name as the service function is generated in the program of the main control board through the proxy function generation script. The proxy function is used to add the number of the user remote function corresponding to the proxy function in the request message when the main control board sends a request message.
[0079] The embedded device of the ergonomic chair includes a main control board and at least one driver board. During use, the driver board and the main control board are connected to communicate via a bus. In order to improve communication efficiency and development efficiency, the programs of the driver board and the main control board are generally developed based on the same language, so there is no cross-platform application in the ergonomic chair. Considering that the application of the RPC protocol in the embedded device of the ergonomic chair needs to consider reducing the problem of large resource occupation, the embodiment of the present application does not adopt the interface description language in the traditional RPC protocol, simplifies the RPC protocol component, and defines the user remote function, so that the driver board and the main control board are called based on the same user remote function name, so that the entire embedded device can interact directly based on the user remote function name, which is suitable for resource-constrained embedded devices such as ergonomic chairs that do not require cross-platform. Therefore, the embodiment of the present application designs an RPC private protocol for information interaction between embedded devices. By writing the user remote service function in a specific format and registering it to the RPC protocol component, the business party or the server can call the service of the user remote function on other devices just like calling a local function, simplifying the process of information interaction between devices managed by the application layer and improving development efficiency.
[0080] Specifically, during the program development process of the driver board, the developer writes the service function according to certain rules and adds the name of the service function in the format of the service function. The name of the service function is a string customized by the developer. The service function is used to determine the service to be called. The driver board points to the function or task to be executed based on the service function, and returns the parameter value through the same service function after obtaining the execution result, and then sends the returned parameter value to the main control board or the request initiator.
[0081] All service functions in the embodiments of this application need to follow the following format (using C language as an example):
[0082] ret_code_t user_function(void* p_arg_buf, uint32_t arg_buf_len, void*p_ret_buf, uint32_t ret_buf_len)
[0083] The meanings of the various parts of the service function format are as follows:
[0084] ret_code_t: return code;
[0085] user_function: the function name of the user remote function;
[0086] p_arg_buf: input parameter buffer address;
[0087] arg_buf_len: valid length of input parameter buffer;
[0088] p_ret_buf: output parameter buffer address;
[0089] ret_buf_len: available length of the output parameter buffer;
[0090] It can be understood that the function name of the service function, the function name of the user remote function and the function name of the proxy function are the same. In this way, the application of the main control board basically calls the proxy function like a local call function, and then the driver board can also execute the service function with the same function name as the proxy function to achieve transparent calling.
[0091] The key point is that the RPC protocol component of the present application does not use an interface description language, so the remote service interface can use the same language as the development process. The interaction between the driver board and the main control board determines the request and response based on the function name of the user's remote function. When writing the program for the main control board, the developer directly writes the function name of the user's remote function without having to learn the interface description language, which reduces the burden on developers.
[0092] In order to provide the function name of the user remote function to the main control board to generate the proxy function, during the program development process of the driver board, the service function written by the developer according to the above rules is registered to the RPC protocol component. The RPC protocol component registers the service function as a user remote function to the internal user remote function list. In this way, the user remote function list of the RPC protocol component can provide the basis for generating the proxy function to the main control board.
[0093] As can be seen above, when developers are writing programs for the main control board, when it comes to calling user remote functions, they basically write them in the same way as calling local functions. Developers can refer to the function names of the service functions in the user remote function list to write the calls in the program. After that, when the program of the main control board is compiled, the proxy function is generated by referring to the user remote function list of the RPC protocol component. The function name of the generated proxy function has the same function name of the service function in the user remote function list. In this way, when the main control board executes the application program, the proxy function can be directly called, thereby transparently calling the service function in the driver board.
[0094] Among them, the proxy function is generated by the RPC protocol component through the proxy function generation script according to the data in the user remote function list. The proxy function generation script in the RPC protocol component of the embodiment of the present application is basically consistent with the proxy function generation strategy in the typical RPC framework, except that the user remote function list of the present application provides the function name of the service function, and the function name of the service function is also used as the function name of the proxy function. It is worth noting that when the main control board generates a request message, the function name of the proxy function can be directly added to the request message, or the number of the user remote function corresponding to the proxy function can be added. In the case of directly adding the function name of the proxy function, the service function itself can be directly registered in the user remote function list (that is, registered according to the function name of the service function), but this method may occupy part of the bytes of the request message and the response message. In order to save the byte length occupied by the function name, in addition to registering the service function itself, the user remote function list also uniquely numbers the service function respectively. At the same time, during the compilation process of the main control board program, the proxy function is assigned a number according to the number of the service function, so that the request message carries the number of the proxy function instead of the function name of the proxy function, and the response message carries the number of the service function instead of the function name of the service function.
[0095] Reference Figure 2 As shown, in some embodiments, the deployment method further includes:
[0096] Step S101, determining the header file and function implementation file of the service function;
[0097] Step S102, during the program compilation process of the driver board, the function implementation file of the service function is added to the compilation;
[0098] Step S103, generating a proxy function implementation file corresponding to the header file of the service function through the proxy function script in the RPC protocol component, and the proxy function implementation file is used to be compiled in the program compilation process of the main control board.
[0099] The service function of the driver board includes the header file Ah and the function implementation file Ac. After the application of the driver board is developed, it is compiled, the function implementation file Ac is added to the compilation process, and the proxy function generation script in the RPC protocol component is called, the header file Ah is input, and the proxy function entity is generated into the proxy function implementation file A1.c. In the development process of the main control board, the function declared in the header file Ah of the driver board is called normally, and then in the program compilation process of the main control board, the proxy function implementation file A1.c is added to the compilation process, so that the application of the main control board and the application of the driver board use the same header file Ah, and both sides have user remote functions with the same name, ensuring that the function name, parameters, return value, etc. are in the same format. However, when the main control board calls the function declared in the header file Ah, the actual calling object is the proxy function entity in the function implementation file A1.c. Therefore, the one-way request process from the main control board to the driver board can be summarized as main control board-->A1.c-->RPC-->driver board-->Ac, which realizes the transparent calling of the function implementation file Ac of the driver board by the main control board.
[0100] Reference Figure 3 As shown, in some embodiments, the service function is registered as a user remote function in the user remote function list inside the RPC protocol component in the following manner:
[0101] Step S210, the RPC protocol component checks the user remote function list and compares the user remote function name to be registered with the registered user remote function name;
[0102] Step S220, if there is a function with the same name, the RPC protocol component returns a prompt message indicating that a function with the same name has been registered;
[0103] Step S230: If there is no identical function name, the RPC protocol component adds a new line to the user remote function list to write the user remote function name to be registered, and assigns a corresponding number to the user remote function to be registered.
[0104] The RPC protocol component maintains a user remote function list. In this embodiment, the service function is recorded in the form of function name + number. When a new service function needs to be registered, the service function needs to be registered in the user remote function list as a user remote function to be registered. The RPC protocol component checks whether the function name of the user remote function to be registered is the same as the function name of the user remote function registered in the user remote function list. If there is a user remote function with the same name, the developer is prompted to rename the user remote function to be registered. If there is no user remote function with the same name, the name of the user remote function to be registered is written into the user remote function list, and a unique number is assigned to the user remote function to be registered.
[0105] It can be understood that the number assigned to the user remote function to be registered can be obtained by adding 1 to the maximum number in the user remote function list, that is, numbering is performed in a numerical manner, such as binary numbers, decimal numbers, hexadecimal numbers, etc., which are all suitable for automatic numbering + 1; the number can also be provided in the form of a string, and a random numerical module is used to generate a string as the number assigned to the user remote function to be registered. This number can be English characters, a combination of English characters and numeric characters, etc.
[0106] In some embodiments, the RPC protocol corresponding to the RPC protocol component defines the message format of the message exchanged between the driver board and the main control board, where:
[0107] The fields in the message format of the request message are: sequence number, request identifier, number of the user remote function, length of the call parameter, and value of the call parameter;
[0108] The fields in the registration format of the response message are: sequence number, response identifier, user remote function number, return code, length of the return parameter value, and return parameter value.
[0109] The private protocol message of the RPC protocol component of the embodiment of the present application has a corresponding message format. For the client, the proxy function will generate a request message and be able to parse the response message sent by the server; for the server, the RPC protocol component will respond to the request message and be able to generate a response message. Depending on the interaction scenario, the message format of the RPC protocol component may be different. The message format of the request message and the response message in the embodiment of the present application is as follows:
[0110] The message format of the request message is as follows:
[0111]
[0112] The message format of the response message is as follows:
[0113]
[0114] The sequence number assigns a unique number to each request and response. There may be multiple concurrent requests and responses between the client and the server, so the sequence number can ensure the order of the messages and ensure that these messages can be processed in the correct order during transmission and after reaching the target. The sequence number can also support retransmission and processing of duplicate messages.
[0115] The request ID is used to be added to the request message when the client initiates a request. The response ID is used to be added to the response message when the server generates a response message. The request ID is the same as the response ID. When the server sends a response message, it will use the same request ID as the original request message as the response ID, so that the client can find the same request ID based on the response ID to confirm which request the response message corresponds to. The return code is a code that indicates the result or status of the operation. The return code helps the client understand whether the request has been successfully processed or whether an error has occurred. As for the call parameter / return parameter, the value of the call parameter / return parameter and the length of the value of the call parameter / return parameter are recorded in the request message / response message.
[0116] It can be understood that the above embodiments actually correspond to the deployment of the driver board and the main control board and the scheme before deployment. The RPC protocol component adopts a private protocol to define the format of the service function and the format of the request message and the response message. Based on this, the name of the user remote function can be used to interact between the driver board and the main control board. For the development process, the service function defined by the developer is recorded in the user remote function list of the RPC protocol component. Then, during the compilation process of the main control board program, the user remote function in the user remote function list is generated as a proxy function, so that the main control board program generates a request message based on the proxy function when initiating a request. The server can also perform corresponding tasks based on the user remote function of the same name in the request message, and finally return the response message of the user remote function of the same name to the client. Therefore, it can be seen that the RPC protocol component of the present application is oriented to the driver board and the main control board of the same platform, so there is no need to write the remote service interface in the interface description language. It belongs to a simplified RPC protocol, which only uses a small amount of flash and ram resources, so that some resource-constrained embedded devices that do not need to be cross-platform can also use the development mode of the RPC framework of the present application to improve development efficiency.
[0117] Reference Figure 4 As shown, the present application also provides a communication method for a distributed panel, which is applied to an embedded device of an ergonomic chair deployed by the deployment method of any of the above embodiments; the communication method of the embodiment of the present application includes but is not limited to the following steps:
[0118] Step S310, the main control board generates a request message through the proxy function, and the request message includes the number of the user remote function corresponding to the proxy function;
[0119] Step S320, the main control board serializes the request message and sends the serialized request message to the driver board;
[0120] Step S330, the driver board receives the request message through the communication interface of the RPC protocol component, deserializes and parses the received request message to obtain the number of the user remote function;
[0121] Step S340, the driver board searches the user remote function list inside the RPC protocol component according to the number of the user remote function, and determines the service function corresponding to the number of the user remote function;
[0122] Step S350, the driver board waits for the service function to return the execution result and then generates a response message, the response message including the number and execution result of the user remote function corresponding to the service function;
[0123] Step S360, the driver board serializes the response message and sends the serialized response message to the main control board;
[0124] Step S370: The main control board deserializes and parses the received response message to obtain the execution result.
[0125] Ergonomic chairs achieve additional intelligent functions by setting up multiple driver boards, such as adding a driver board for a massage module at the lumbar support, setting a driver board for a heating module at the headrest, setting an electric lift driver board at the palm rest, etc. These driver boards are connected to the main control board through a bus, and the main control board uniformly controls each driver board to perform corresponding functions and receive data sent by each driver board. This distributed board arrangement method is conducive to ergonomic chair manufacturers to simply add or remove driver boards to add or delete functions when developing products. For example, replace the massage module at the lumbar support, and replace it with a heating module together with the driver board of the massage module. This new heating module is connected to the original bus and then connected to the main control board.
[0126] After the deployment is completed by the deployment method of the above embodiment, the driver board and the main control board are installed in the corresponding positions in the ergonomic chair, and a communication connection is established between the main control board and each driver board, so the driver board and the main control board are set in the form of distributed panels in the ergonomic chair. During the use of the ergonomic chair, the main control board can initiate a request message, and the main control board determines the user remote function to be called according to the request content, generates a request message through the proxy function, and adds the number of the user remote function to be called in the request message. The RPC protocol component also serializes the request message, converts it into a transmission form suitable for the remote service interface, and sends the serialized request message to the server through the bus. The server receives the serialized request message through the communication interface of the RPC protocol component, and then deserializes and restores it to obtain the request message, and parses the number of the user remote function corresponding to the proxy function in the request message. After obtaining the number of the user remote function, the number in the user remote function list of the RPC protocol component is searched, and the user remote function with the same number is determined, that is, the service function corresponding to the proxy function is searched, and the driver board then executes the corresponding service function.
[0127] The driver board waits for the execution result returned by the service function, adds the execution result to the response message after receiving the execution result, and adds the number corresponding to the service function, then calls the serialization interface of the RPC protocol component to serialize the response message, and sends the serialized response message to the main control board through the communication interface of the RPC protocol component. The main control board receives the serialized response message, deserializes it, obtains the response message, and parses the response message to obtain the execution result corresponding to the number of the proxy function.
[0128] The above process can refer to Figure 5 As shown, the RPC protocol component includes a communication interface / communication component, which is used to connect to the bus to send and receive request messages and response messages. The RPC protocol component also includes a serialization interface / serialization component. Since the driver board and the main control board are connected through an internal bus in the ergonomic chair, for example, through a CAN bus, the communication interfaces communicate on the same platform. The RPC protocol component can directly serialize or deserialize the request message and the response message. The processing process consumes little resources and is suitable for scenarios such as ergonomic chairs with limited storage space.
[0129] Reference Figure 6 As shown, in some embodiments, in the above step S310, the main control board generates a request message through a proxy function, including:
[0130] Step S410, the main control board determines the proxy function corresponding to the currently initiated request;
[0131] Step S420, the main control board determines the number of the corresponding user remote function according to the proxy function;
[0132] Step S430: the main control board adds the serial number, the request identifier, the number of the user remote function corresponding to the proxy function, the length of the calling parameter and the value of the calling parameter to the message to generate a request message.
[0133] The main control board determines the request to be executed and determines the corresponding proxy function for the request. In this process, the main control board calls the proxy function in the same way as calling the local function. The RPC protocol component determines the corresponding number based on the function name of the proxy function to be called. The main control board adds the number of the user remote function corresponding to the proxy function to the request message, and also adds the serial number, request identifier, length of the call parameter and the value of the call parameter to the request message. The message format of the request message follows the following:
[0134]
[0135] The main control board specifies the value of the call parameter and the length of the call parameter in the request message as the user remote function input parameter and the effective length of the input parameter, corresponding to the p_arg_buf and arg_buf_len of the format of the above service function.
[0136] Reference Figure 7 As shown, in some embodiments, in the above step S330, the driver board deserializes and parses the received request message to obtain the number of the user remote function, including:
[0137] Step S510, the driver board calls the serialization interface of the RPC protocol component to deserialize the received request message;
[0138] Step S520, the driver board parses the serial number of the deserialized request message, determines that the request message of the main control board is complete according to the serial number of at least one request message received, and further determines the number of the user remote function located after the request identification field in the request message.
[0139] The driver board performs deserialization conversion through the serialization interface of the RPC protocol component to obtain the request message and then parse the content in the request message. Serialization and deserialization are used to convert request messages and response messages so that the driver board and the main control board can process the converted messages. Even if the driver board and the main control board use the same language or data format, serialization and deserialization are still necessary in remote procedure calls because the memory space of the driver board and the main control board processes is isolated, and one process cannot directly access the memory space of another process. Therefore, when a process needs to pass data to another process, it needs to write the data to some form of shared storage space (such as files, sockets, etc.), which usually requires the data to exist in a serialized format. At the same time, the length of the parameters is specified in the request message and the response message, which can unify the format of the parameter interaction between the request message and the response message, facilitate the driver board and the main control board to process tasks, reduce the resource occupation of the RPC protocol component, and complete the user's remote function call task with only a simple conversion.
[0140] Among them, the sequence number assigns a unique number to each request and response. There may be multiple concurrent requests and responses between the client and the server. Therefore, the sequence number can ensure the order of the messages and ensure that these messages can be processed in the correct order during transmission and after reaching the target. The sequence number can also support retransmission and processing of duplicate messages. Through the sequence number, the main control board divides the data of a request into multiple request messages and fills in the sequence number in each request message in the order of the request message. In this way, the driver board can determine whether the message sent by the main control board for this request is complete according to the sequence number in the request message.
[0141] Reference Figure 8 As shown, in some embodiments, in the above step S350, the driver board generates a response message after waiting for the service function to return the execution result, including:
[0142] Step S610, the driver board loads and executes the service function, and waits for the service function to return the execution result;
[0143] Step S620, after receiving the execution result, the driver board determines the length and the return parameter value of the return parameter value in the execution result;
[0144] Step S630, the driver board adds the return code, the number of the corresponding user remote function determined by the service function, the length of the return parameter value and the return parameter value in the message, and generates a response message.
[0145] After the driver board determines the service function requested by the request message, it loads and executes the service function and waits for the service function to return the execution result; after the service function is executed, it feedbacks the return parameter value, and can also feedback the length of the return parameter value at the same time, or the driver board determines the length of the return parameter value based on the length of the call parameter value. The driver board adds the number corresponding to the service function in the response message, and also adds the return code, the length of the return parameter value, and the return parameter value. The message format of the response message follows the following:
[0146]
[0147] The driver board specifies the value of the return parameter and the length of the return parameter in the response message as the user remote function output parameter and the effective length of the output parameter, corresponding to the p_ret_buf and ret_buf_len of the format of the above service function.
[0148] Reference Fig. 9 As shown, in some embodiments, in the above step S630, the driver board adds a return code to the message, the service function determines the number of the corresponding user remote function, the length of the return parameter value and the return parameter value, and generates a response message, including:
[0149] Step S710, the driver board determines the number of response messages required to send the execution result, and generates a sequence number corresponding to the number sequence;
[0150] Step S720, filling in the corresponding sequence of sequence numbers in each response message according to the sequence number order, and setting the return code in the last response message to the first value, and setting the return code in other response messages to the second value;
[0151] Step S730, fill the response message with the number of the user remote function corresponding to the service function, the length of the return parameter value and the return parameter value in the order of the response message.
[0152] The driver board divides the data of this response into multiple response messages and sends them, determines multiple sequentially arranged serial numbers according to the data of the response message, and fills these serial numbers into these response messages in order, so that the main control board can determine whether the message of the driver board's response this time is complete according to the serial number in the response message. At the same time, in order for the main control board to determine that the request in the request message has been successfully processed, the driver board also adds a return code in the response message. The return code of the embodiment of the present application is different from the return code of the conventional RPC framework. The return code of the conventional RPC framework is used to indicate the code of the operation result or status, that is, the request has been successfully processed. Therefore, if the request is successfully processed in the conventional RPC framework, the return code is a numerical value, and if the request is not successfully processed, the return code is another numerical value; if the request is successfully processed in the RPC protocol component of the embodiment of the present application, the return code has a first numerical value and a second numerical value, which is combined with the serial number. In the last response message of the message sent by the driver board to respond, the return code is set to the first numerical value, and the serial number of this response message is also the last serial number. In other response messages before the last response message, the return code is set to the second numerical value. In this way, the main control board can know whether the last response message has been received through the return code. If the last response message has been received, it checks whether the sequence number is complete. When the sequence number is complete, it means that the response data has been received. If the sequence number is not complete, it means that part of the response message has not yet reached the main control board, and the main control board continues to wait for the response message to be received. Therefore, the combination of the sequence number and the return code can accurately determine the completeness of the response message and determine that the reception is smooth. If the request is not successfully processed in the RPC protocol component of the embodiment of the present application, the return code can set the third value (the last response message) and the fourth value. The above-mentioned first value, second value, third value and fourth value can be set according to actual needs, and the meaning represented by the agreed value in the RPC protocol component can be used.
[0153] Reference Fig.10 As shown, in some embodiments, in the above step S370, the main control board parses the deserialized response message to obtain the execution result, including:
[0154] Step S810, the main control board fills the length and return parameter value of the return parameter value in the deserialized response message into the output parameter buffer;
[0155] Step S820, the main control board determines whether the initiated request is executed successfully according to the return code;
[0156] Step S830: If it is determined that the initiated request is executed successfully and the return code includes the first value, read the return parameter value from the output parameter buffer.
[0157] The main control board deserializes the serialized response message, and parses the response message to obtain the return parameter value and the length of the return parameter value, and also obtains the sequence number and return code. According to the above, the sequence number and the return code cooperate with each other to determine the reception of the response message. If a received response message contains a first value, it means that this response message is the last message of the response data. At this time, check whether the sequence number is complete. When the sequence number is complete, it means that the response data has been received. If the sequence number is not complete, it means that part of the response message has not yet arrived at the main control board, and the main control board continues to wait for the response message. When the sequence number is complete and the return code of the first value is received, the return parameter value is read from the output parameter buffer, where the length of the return parameter value is used to pre-occupy a certain length of address in the output parameter buffer to ensure that the output parameter buffer can reserve enough space to receive the data of the response request.
[0158] Reference Fig.11 As shown, in some embodiments, in the above step S830, if it is determined that the initiated request is executed successfully and the return code includes the first value, reading the return parameter value from the output parameter buffer includes:
[0159] Step S910, the application of the main control board that initiated the request determines that the value of the return code is equal to the first value, and then determines that the initiated request is executed successfully and a response message of the last sequence number is received;
[0160] Step S920, checking the sequence number in the response message to determine whether all response messages have been received, and reading the return parameter value from the output parameter buffer according to the length of the return parameter value.
[0161] The above steps S910 and S920 are the same as the above description. When the serial number is complete and the return code of the first value is received, the return parameter value is read from the output parameter buffer, wherein the length of the return parameter value is used to pre-occupy an address of a certain length in the output parameter buffer to ensure that the output parameter buffer can reserve sufficient space to receive data in response to the request. It is also used for reading the return parameter value in the output parameter buffer. The main control board reads according to the length of the return parameter value to avoid reading errors.
[0162] In summary, during the program development process of the driver board, the developer defines the service function and registers the service function as a user remote function in the user remote function list inside the RPC protocol component, and then calls the user remote function list inside the RPC protocol component during the program compilation process of the main control board to generate a proxy function with the same name as the service function. In this way, the main control board can call the service function with the same name when initiating a request to achieve transparent calling. Since the proxy function is deployed through the user remote function list and the driver board and the main control board belong to the same platform interaction, during the interaction between the driver board and the main control board of the present application, there is no need to use the interface description language in the traditional RPC protocol component to write the remote service interface. Therefore, the RPC protocol component of the present application has the advantages of small size and low resource occupancy, and is especially suitable for resource-constrained embedded devices such as ergonomic chairs that do not require cross-platform development. A development model similar to the RPC framework can be used, which can improve development efficiency.
[0163] An embodiment of the present application also provides a controller, comprising at least one processor and a memory for communicating with the at least one processor; the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the aforementioned automatic adjustment method of the ergonomic chair.
[0164] Reference Fig.12 As shown, the control processor 1001 and the memory 1002 in the controller 1000 can be connected via a bus as an example. The memory 1002, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory 1002 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk memory, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 1002 may optionally include a memory remotely arranged relative to the control processor 1001, and these remote memories may be connected to the controller 1000 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0165] Those skilled in the art will understand that Fig.12 The device structure shown in the figure does not constitute a limitation on the controller 1000, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0166] An embodiment of the present application also provides a seat, including an embedded device, wherein the embedded device includes a driver board as a server and a main control board as a client, the driver board and the main control board are connected via an internal bus, the driver board and the main control board are deployed via the deployment method of the aforementioned embodiment, and the driver board and the main control board communicate via the communication method of the aforementioned embodiment.
[0167] The embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are executed by one or more control processors, for example, Fig.12 Executed by one of the control processors 1001, the one or more control processors may execute the automatic adjustment method of the ergonomic chair in the above method embodiment.
[0168] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0169] It will be appreciated by those skilled in the art that all or some of the steps and systems in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or transient medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0170] The above is a specific description of the preferred implementation of the present application, but the present application is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions without violating the spirit of the present application. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present application.
Claims
1. A method for deploying an embedded device, characterized in that: An embedded device applied to an ergonomic chair, the embedded device includes a driver board as a server and a main control board as a client; the deployment method includes: During the program development process of the driver board, receiving a service function input by a developer, wherein the service function includes a user-defined function name, a return code, and a parameter list; Calling the registration interface of the RPC protocol component, registering the service function as a user remote function into the user remote function list within the RPC protocol component; During the program compilation process of the main control board, a proxy function generation script in the RPC protocol component is called, and a proxy function with the same name as the service function is generated in the program of the main control board through the proxy function generation script, and the proxy function is used to add the number of the user remote function corresponding to the proxy function in the request message when the main control board sends a request message; The deployment method further comprises: Determine the header file and function implementation file of the service function; During the program compilation process of the driver board, the function implementation file of the service function is added to the compilation; Generate a proxy function implementation file corresponding to the header file of the service function through the proxy function script in the RPC protocol component, and the proxy function implementation file is used to add compilation to the program compilation process of the main control board; The RPC protocol component adopts a private protocol to define the format of the service function and the formats of the request message and the response message, wherein: The format of the service function is: return code function name (input parameter buffer address, input parameter buffer effective length, output parameter buffer address, output parameter buffer effective length); The fields in the message format of the request message are: sequence number, request identifier, number of the user remote function, length of the call parameter, and value of the call parameter; The fields in the registration format of the response message are: sequence number, response identifier, user remote function number, return code, length of the return parameter value, and return parameter value.
2. The deployment method according to claim 1, characterized in that: The service function is registered as a user remote function in the user remote function list inside the RPC protocol component in the following manner: The RPC protocol component checks the user remote function list and compares the user remote function name to be registered with the registered user remote function name; If there is a function with the same name, the RPC protocol component returns a prompt message that a function with the same name has been registered; If the same function name does not exist, the RPC protocol component adds a new line in the user remote function list to write the user remote function name to be registered, and assigns a corresponding number to the user remote function to be registered.
3. A communication method for distributed panels, characterized in that: An embedded device applied to an ergonomic chair deployed by the deployment method described in any one of claims 1 to 2; the communication method comprises: The main control board generates a request message through the proxy function, and the request message includes the number of the user remote function corresponding to the proxy function; The main control board serializes the request message, and sends the serialized request message to the driver board; The driver board receives the request message through the communication interface of the RPC protocol component, deserializes and parses the received request message to obtain the number of the user remote function; The driver board searches the user remote function list inside the RPC protocol component according to the number of the user remote function, and determines the service function corresponding to the number of the user remote function; The driver board waits for the service function to return an execution result and then generates a response message, wherein the response message includes the number of the user remote function corresponding to the service function and the execution result; The driver board serializes the response message and sends the serialized response message to the main control board; The main control board deserializes and parses the received response message to obtain the execution result.
4. The communication method according to claim 3, characterized in that: The main control board generates a request message through the proxy function, including: The main control board determines the proxy function corresponding to the currently initiated request; The main control board determines the number of the corresponding user remote function according to the proxy function; The main control board adds a serial number, a request identifier, a number of a user remote function corresponding to the proxy function, a length of a calling parameter and a value of the calling parameter to the message to generate a request message.
5. The communication method according to claim 3, characterized in that: The driver board deserializes and parses the received request message to obtain the number of the user remote function, including: The driver board calls the serialization interface of the RPC protocol component to deserialize the received request message; The driver board parses the serial number of the deserialized request message, determines that the request message of the main control board is complete according to the serial number of at least one received request message, and further determines the number of the user remote function located after the request identification field in the request message.
6. The communication method according to claim 3, characterized in that: The driver board waits for the service function to return the execution result and then generates a response message, including: The driver board loads and executes the service function, and waits for the service function to return an execution result; After receiving the execution result, the driver board determines the length and the return parameter value of the return parameter value in the execution result; The driver board adds a return code, the number of the corresponding user remote function determined by the service function, the length of the return parameter value and the return parameter value in the message to generate a response message.
7. The communication method according to claim 6, characterized in that: The driver board adds a return code, the number of the corresponding user remote function determined by the service function, the length of the return parameter value and the return parameter value to the message, and generates a response message, including: The driver board determines the number of response messages required to send the execution result, and generates a sequence number of a corresponding number sequence; Fill the sequence numbers of the corresponding order in each response message according to the order of the sequence numbers, and set the return code in the last response message to the first value, and set the return code in the other response messages to the second value; The response message is filled with the number of the user remote function corresponding to the service function, the length of the return parameter value and the return parameter value in the order of the response message.
8. The communication method according to claim 7, characterized in that: The main control board parses the deserialized response message to obtain the execution result, including: The main control board fills the length of the return parameter value and the return parameter value in the deserialized response message into the output parameter buffer; The main control board determines whether the initiated request is executed successfully according to the return code; If it is determined that the initiated request is executed successfully and the return code includes the first value, the return parameter value is read from the output parameter buffer.
9. The communication method according to claim 8, characterized in that: If it is determined that the initiated request is executed successfully and the return code includes the first value, reading the return parameter value from the output parameter buffer includes: The application of the main control board that initiates the request determines that the value of the return code is equal to the first value, then determines that the initiated request is executed successfully and a response message of the last sequence number is received; The sequence number in the response message is checked to determine that all the response messages have been received, and the return parameter value is read from the output parameter buffer according to the length of the return parameter value.
10. A seat, characterized in that: It comprises an embedded device, wherein the embedded device comprises a driver board as a server and a main control board as a client, wherein the driver board and the main control board are connected via an internal bus, wherein the driver board and the main control board are deployed via the deployment method described in any one of claims 1 to 2, and wherein the driver board and the main control board communicate via the communication method described in any one of claims 3 to 9.
