Inter-process communication method, device, electronic device, storage medium and vehicle computer platform
By defining packet class number and carrying algorithm data in inter-process communication, data loss and delay problems in single-send and periodic sending methods are solved, the accuracy and reliability of data interaction are achieved, and communication efficiency and exceptions are improved. Detection capability.
Patent Information
- Application Number
- CN202411237806.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-09-05
AI Technical Summary
The existing inter-process communication methods have problems such as difficult to detect data loss, high communication delay and low efficiency in single-send and periodic transmission methods, which makes it difficult to locate and correct software abnormalities.
By defining the data packet class number, distinguishing the data from the reply end and the sending end, carrying algorithm data in the data frame, calculating the waiting time, ensuring the accuracy and reliability of data interaction, increasing control capabilities, and controlling the duration of the response cycle data to improve the Interaction reliability.
It realizes accurate and effective data interaction, improves the reliability and efficiency of inter-process communication, and reduces the detection time of data loss and abnormal states.
Smart Images

Figure CN118764543B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of inter-process communication, and in particular to an inter-process communication method, an inter-process communication device, an electronic device, a storage medium and a vehicle computer platform. Background Art
[0002] Some custom lightweight inter-process communication protocols are often used to transmit control signals. The sending methods include single sending and periodic sending. The single sending method has the problem that the communication signal is lost but cannot be discovered. The periodic sending method has the problems of high communication delay and low efficiency. Only single sending or periodic sending will cause the software to occasionally have some abnormal situations that are difficult to locate, which requires a lot of time and effort to troubleshoot and correct.
[0003] Therefore, an inter-process communication method is needed to manage and control the data between the sender and the receiver to ensure the integrity and accuracy of data interaction. For example, the data waiting for feedback is used to predict whether the sent data is effectively processed. Summary of the invention
[0004] The purpose of the present invention is to provide an inter-process communication method, an inter-process communication device, an electronic device, a storage medium and a vehicle computer platform, which at least solves one of the technical problems of the problem of data loss not being detected, the problem of useless data occupying resources, and the problem of data processing results not being predictable.
[0005] The present invention provides the following scheme:
[0006] According to one aspect of the present invention, there is provided an inter-process communication method, the inter-process communication method comprising:
[0007] Obtain data packet feature information;
[0008] According to the characteristic information of the data packet, the data frame field is set;
[0009] The data frame field includes a data packet type number, first data, second data and third data;
[0010] The data packet class number includes the first class number and the second class number;
[0011] The responding end generates a data packet type number of the data frame field of the responding end according to the data frame field of the receiving sending end as a first type number;
[0012] The sending end generates a data packet type number of the data frame field of the sending end according to the data frame field of the receiving response end, which is a second type number;
[0013] The data packet type number of each data frame field of the responder and the sender is calculated from the data packet type number sent by the sender and responded by the responder in the previous round.
[0014] The data frame field of the sending end includes: the first data is content data, the second data is algorithm data, and the third data is result data;
[0015] Among them, the response end data frame field includes: the third data is the comparison result data.
[0016] Furthermore, it also includes:
[0017] The first type of numbering includes even numbers, and the second type of numbering includes odd numbers;
[0018] The responder determines whether the data packet type number of the data frame field is an odd number according to the received data frame field;
[0019] If is an odd number, the first data of the data frame field is extracted;
[0020] generating an instruction according to the content data of the first data;
[0021] According to the execution instruction, wait for the execution result data.
[0022] Furthermore, it also includes:
[0023] The responding end extracts the second data according to the data packet type number of the received data frame field being an odd number;
[0024] Obtaining a data packet class number of the responding end according to the algorithm data of the second data and the data packet class number of the received data frame field;
[0025] Determine whether the data packet class number obtained from the response end is an even number;
[0026] If , is an even number, wait for the response end to generate the third data;
[0027] Wherein, the algorithm data includes, preset response cycle data;
[0028] According to the waiting time for the response end to generate the third data being less than the waiting time calculated by the preset response cycle data conversion, determining whether the data packet class number of the response end is currently obtained;
[0029] If the data packet class number of the response end is obtained, the data frame field of the response end is sent.
[0030] Furthermore, it also includes:
[0031] The responding end extracts the third data according to the data packet type number of the received data frame field being an odd number;
[0032] Comparing the result data obtained according to the execution instruction with the result data of the third data to generate comparison result data;
[0033] Generating third data of the response end according to the comparison result data;
[0034] Generate a data frame field of the responding end according to the data packet class number of the responding end and the third data of the responding end;
[0035] Determine whether the waiting time for the response end to generate the third data is greater than the waiting time calculated by the preset response cycle data;
[0036] If, it is greater than, then the third data of the current response end is flushed according to the preset processing failure flag data;
[0037] Generate a data frame field of the answering end according to the data packet class number of the answering end and the third data of the answering end, and send it;
[0038] Among them, before sending, a response request is sent first to determine whether an instruction to allow the response is received;
[0039] If, within the preset first waiting time threshold, an instruction allowing a response is received, then sending;
[0040] If no instruction to allow a response is received within the preset first waiting time threshold or an instruction not to allow a response is received, the data frame field response is abandoned and the cache is cleared.
[0041] Furthermore, it also includes:
[0042] The transmitting end sets the storage address according to the data packet class number in the pre-sent data frame field and the algorithm data of the second data;
[0043] The transmitting end stores the pre-determined data according to the third data in the pre-sent data frame field according to the set storage address;
[0044] The waiting time calculated by the transmitting end according to the response cycle data preset in the algorithm data of the second data in the pre-sent data frame field;
[0045] According to the calculated waiting time, wait for the data frame field of the receiving end's response;
[0046] Determine whether the waiting time of the data frame field of the response receiving end is less than the converted waiting time;
[0047] If,is less than, then determine whether the data packet class number in the received data frame field is an even number;
[0048] If,is an even number, the storage address is queried according to the data packet class number in the received data frame field;
[0049] comparing the pre-judgment data stored at the storage address according to the third data in the received data frame field;
[0050] According to the result of comparing the pre-judgment data, the sender triggers the next round of sending or stops sending;
[0051] Among them, according to the sending end triggering the next round of sending, the sending end receives the data frame field of the response end in this round, and generates an odd number for the data packet type number of the data frame field of the sending end.
[0052] Furthermore, it also includes:
[0053] Determine whether the waiting time for the sending end to receive the data frame field of the response from the responding end is greater than the waiting time converted under the preset response cycle data;
[0054] If,is greater than, then determine whether the sender sends a new data frame field;
[0055] If,not sent, then determine whether the sending end has received the response request from the responding end;
[0056] If,received, then send a command to allow the response;
[0057] Determining whether a data frame field of the response end is received within a preset second waiting time threshold after sending the permission instruction;
[0058] If not received, an instruction not to allow response is sent, and the waiting for the data frame field of the response end to receive the response is ended.
[0059] According to two aspects of the present invention, there is provided an inter-process communication device, the inter-process communication device comprising:
[0060] A characteristic information module is used to obtain characteristic information of data packets;
[0061] A data frame setting module, used to set data frame fields according to data packet characteristic information;
[0062] A data frame structure module, wherein the data frame field includes a data packet type number, first data, second data and third data, and the data packet type number includes a first type number and a second type number;
[0063] The answering end numbering module is used for the answering end to generate the data packet type number of the data frame field of the answering end as the first type number according to the data frame field of the receiving sending end;
[0064] The sending end numbering module is used for the sending end to generate the data packet type number of the data frame field of the sending end as the second type number according to the data frame field of the receiving response end;
[0065] A number calculation module is used for the data packet type number of each data frame field of the responder and the sender, which is obtained by calculating the data packet type number sent by the sender and responded by the responder in the previous round;
[0066] A sending end data frame module, used for sending end data frame fields including: first data is content data, second data is algorithm data, and third data is result data;
[0067] The response end data frame module is used for the response end data frame field to include that the third data is the comparison result data.
[0068] According to three aspects of the present invention, there is provided an electronic device, comprising: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0069] A computer program is stored in the memory, and when the computer program is executed by the processor, the processor is caused to execute the steps of the inter-process communication method.
[0070] According to four aspects of the present invention, a computer-readable storage medium is provided, comprising: a computer program executable by an electronic device is stored therein, and when the computer program runs on the electronic device, the electronic device executes the steps of the inter-process communication method.
[0071] According to five aspects of the present invention, a vehicle computer platform is provided, including:
[0072] An electronic device, used to implement the steps of the inter-process communication method;
[0073] A processor, wherein the processor runs a program, and when the program runs, the steps of the inter-process communication method are executed from the data output by the electronic device;
[0074] The storage medium is used to store a program, and when the program is running, the program executes the steps of the inter-process communication method for data output from the electronic device.
[0075] Through the above scheme, the following beneficial technical effects are obtained:
[0076] The present application defines data packet class numbers to distinguish data between the responder and the sender, and ensures the accuracy and validity of the data based on the distinguished data.
[0077] The present application carries algorithm data through data frames, allowing the responding end to calculate the waiting time and the data packet class number, so that the responding end's response is less reliable and economical than single transmission and periodic transmission, and increases the control capability.
[0078] The present application controls the receiving and processing window of the responding end or the sending end for delayed data by comparing and judging the duration of the response cycle data, so that the data interaction between the sending end and the responding end is reliable and controllable. BRIEF DESCRIPTION OF THE DRAWINGS
[0079] Figure 1 The present invention is a flowchart of an inter-process communication method provided by one or more embodiments of the present invention.
[0080] Figure 2 It is a structural diagram of an inter-process communication device provided by one or more embodiments of the present invention.
[0081] Figure 3 It is a schematic diagram of a data packet frame structure of a specific embodiment of the present invention.
[0082] Figure 4 It is a schematic diagram of setting a data buffer according to a specific embodiment of the present invention.
[0083] Figure 5 It is a schematic diagram of a sending thread process according to a specific embodiment of the present invention.
[0084] Figure 6 It is a schematic diagram of a receiving thread process according to a specific embodiment of the present invention.
[0085] Figure 7 It is a structural block diagram of an electronic device according to an inter-process communication method provided by one or more embodiments of the present invention. DETAILED DESCRIPTION
[0086] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0087] Figure 1 The present invention is a flowchart of an inter-process communication method provided by one or more embodiments of the present invention.
[0088] like Figure 1 The inter-process communication methods shown include:
[0089] Step S1, obtaining data packet characteristic information;
[0090] Step S2, setting the data frame field according to the data packet characteristic information;
[0091] Step S3, the data frame field includes a data packet type number, first data, second data and third data;
[0092] Step S4, the data packet class number includes a first class number and a second class number;
[0093] Step S5, the responding end generates a data packet type number of the data frame field of the responding end as a first type number according to the data frame field of the receiving sending end;
[0094] Step S6, the sending end generates a data packet type number of the data frame field of the sending end as a second type number according to the data frame field of the receiving response end;
[0095] Step S7, the data packet type number of each data frame field of the responding end and the sending end is calculated and obtained by the data packet type number sent by the sending end and responded by the responding end in the previous round;
[0096] Step S8, the data frame field of the sending end includes: the first data is content data, the second data is algorithm data, and the third data is result data;
[0097] Step S9: the response end data frame field includes: the third data is comparison result data.
[0098] Specifically, for example, a custom lightweight inter-process communication protocol is often used to transmit control signals. The single-shot transmission method has the problem that communication signal loss is difficult to detect. The periodic transmission method has the problem of high communication delay and low efficiency.
[0099] In this embodiment, data packets are planned for data frames, and the data frame fields include data packet type number, first data, second data, and third data; the data packet type number is used to distinguish the data of the sending end from the data of the responding end, such as using an even number for the data packet type number, indicating that the data frame data comes from the responding end; such as using an odd number for the data packet type number, indicating that the data frame data comes from the sending end. The data packet type number does not only include the change of odd and even numbers, and it is not necessary that the sending end has an odd or even data packet type number. The specific rules depend on the preset algorithm module. In addition to the preset data packet type number when the sending end initiates, the data packet type number is obtained by calculation based on the interactive response after the data packet. The specific algorithm is obtained from the data packet type number in the previous round of received data and the second data algorithm data. For example, the responding end extracts the algorithm data of the second data according to the data frame field of the receiving sending end to calculate the data packet type number in the data frame field to obtain an even number. When the responding end feeds back the data packet to the sending end, the data packet type number in the data frame uses the even number. Correspondingly, after sending a data packet, the sending end pre-calculates that when the responding end feeds back a data packet to the sending end based on the data packet type number in the data frame and the algorithm data of the second data, the data packet type number in the data frame is the even number used to identify whether the received data packet feedback is in a corresponding relationship with the previously sent data packet.
[0100] The data frame field of the sending end includes: the first data is content data, the second data is algorithm data, and the third data is result data. The content data in the first data includes instruction data, parameter data, etc., which are mainly used for the control, command, data input, etc. of the sending end to the answering end. The second data is algorithm data, including an algorithm for calculating the type number of the data packet and an algorithm for waiting for the delay of the answering end to feedback. Since it takes a certain amount of time for the content data of the sending end to be fed back after being processed by the answering end, in order to distinguish between data response failure and data normal response, the reliability of obtaining the response feedback data of the answering end is increased by judging the time length. The third data is result data. After sending the content data, the sending end has an expectation of the processing result of the answering end. Usually, the expected result is a limited number of results. If the received feedback data does not belong to the expected result, it can be determined that the feedback data is not the data of the answering end or the answering end is abnormal, and there is no response feedback that is pre-judged for the corresponding data packet of the sending end.
[0101] The data frame field of the response end includes: the third data is comparison result data. The response end performs execution based on the content data of the sending end, and the execution has a result, such as the result that the instruction has been executed, or the result that the execution is completed.
[0102] In order to further simplify the description of the results, the third data in the data frame field of the sending end includes the predicted results. Through comparison, the comparison results are written in the third data of the responding end. For example, if the result data is the same as the result data of the third data of the sending end after comparison, or if the result data is different from the result data of the third data of the sending end after comparison, the comparison result can be written into the third data of the responding end, and the response is fed back to the sending end. The sending end further performs the next round of sending according to the preset program branch based on the result of the response feedback.
[0103] In this embodiment, it also includes:
[0104] The responder determines whether the data packet type number of the data frame field is an odd number according to the received data frame field;
[0105] If is an odd number, the first data of the data frame field is extracted;
[0106] generating an instruction according to the content data of the first data;
[0107] According to the execution instruction, wait for the execution result data.
[0108] Specifically, the responder filters and screens the received data. When the data packet type number of the received data frame field is an odd number, it means that the data frame is the data of the sender. According to the odd number identification predefined by the responder (including which specific odd number), the first data in the data frame is parsed for instructions, parameters, etc. for execution. By executing instructions, parameters, etc., result data is generated, and the result data is used to feed back to the sender. Before sending, it can be compared with the third data of the sender in advance, and the comparison result can be placed in the third data of the data frame to be sent by the responder, or the execution result can be directly placed in the third data of the data frame to be sent by the responder.
[0109] In this embodiment, it also includes:
[0110] The responding end extracts the second data according to the data packet type number of the received data frame field being an odd number;
[0111] Obtaining a data packet class number of the responding end according to the algorithm data of the second data and the data packet class number of the received data frame field;
[0112] Determine whether the data packet class number obtained from the response end is an even number;
[0113] If , is an even number, wait for the response end to generate the third data;
[0114] Wherein, the algorithm data includes, preset response cycle data;
[0115] According to the waiting time for the response end to generate the third data being less than the waiting time calculated by the preset response cycle data conversion, determining whether the data packet class number of the response end is currently obtained;
[0116] If the data packet class number of the response end is obtained, the data frame field of the response end is sent.
[0117] Specifically, the data packet type number in the data frame field sent by the sending end is an odd number. The answering end receives the second data from the sending end including algorithm data. The pre-stored algorithm item can be selected according to the algorithm data to calculate the data packet type number. If an even number is generated, it means that the answering end needs to feedback data to the sending end. If an odd number is generated, it means that the answering end does not need to feedback data to the sending end, or it acts as another sending end to send data frames to answering ends of other levels.
[0118] The algorithm data also includes preset response cycle data. If a pre-stored algorithm is selected according to the algorithm data, the data packet type number is calculated, and an even number is generated, the waiting time is further calculated based on the response cycle data in the algorithm data. If the result of executing the instruction is obtained within the time, the comparison result is fed back to the sending end through the data frame of the responding end directly or after comparison with the third data.
[0119] In this embodiment, it also includes:
[0120] The responding end extracts the third data according to the data packet type number of the received data frame field being an odd number;
[0121] Comparing the result data obtained according to the execution instruction with the result data of the third data to generate comparison result data;
[0122] Generating third data of the response end according to the comparison result data;
[0123] Generate a data frame field of the responding end according to the data packet class number of the responding end and the third data of the responding end;
[0124] Determine whether the waiting time for the response end to generate the third data is greater than the waiting time calculated by the preset response cycle data;
[0125] If, it is greater than, then the third data of the current response end is flushed according to the preset processing failure flag data;
[0126] Generate a data frame field of the answering end according to the data packet class number of the answering end and the third data of the answering end, and send it;
[0127] Among them, before sending, a response request is sent first to determine whether an instruction to allow the response is received;
[0128] If, within the preset first waiting time threshold, an instruction allowing a response is received, then sending;
[0129] If no instruction to allow a response is received within the preset first waiting time threshold or an instruction not to allow a response is received, the data frame field response is abandoned and the cache is cleared.
[0130] Specifically, the answering end extracts the third data in the data frame according to the odd number of the data packet type in the received data frame field, and the third data is the pre-judgment execution result of the second data executed by the sending end on the answering end. According to the result data of the third data, the execution result data is compared to generate the comparison result data; according to the comparison result data, the third data of the answering end is generated; according to the data packet type number of the answering end and the third data of the answering end, the data frame field of the answering end is generated; wherein, the answering end needs time to generate the feedback execution result data, and judges whether the waiting time for generating the third data of the answering end is greater than the time under the preset response cycle data. If it is greater than the time under the preset response cycle data, it means that the answering end may be abnormal, and the third data sent by the current answering end is rewritten according to the preset processing failure flag data. Since the waiting time for generating the third data sent by the answering end is greater than the time under the preset response cycle data, the sending end may no longer wait for the feedback of the answering end. In order to further judge whether the feedback of the answering end can still be carried out, it is necessary to send a response request to the sending end to judge whether the sending end has other tasks and whether it is still waiting for the feedback of the answering end. If the sending end responds with a command to allow a response, it means that despite the timeout, it is still waiting for the response end's feedback, and the response end responds with data frame data. If it receives a command not to allow a response, or does not receive a command to allow within the preset delay time threshold, the response end abandons sending the data frame field and clears the cache.
[0131] In this embodiment, it also includes:
[0132] The transmitting end sets the storage address according to the data packet class number in the pre-sent data frame field and the algorithm data of the second data;
[0133] The transmitting end stores the pre-determined data according to the third data in the pre-sent data frame field according to the set storage address;
[0134] The waiting time calculated by the transmitting end according to the response cycle data preset in the algorithm data of the second data in the pre-sent data frame field;
[0135] According to the calculated waiting time, wait for the data frame field of the receiving end's response;
[0136] Determine whether the waiting time of the data frame field of the response receiving end is less than the converted waiting time;
[0137] If,is less than, then determine whether the data packet class number in the received data frame field is an even number;
[0138] If,is an even number, the storage address is queried according to the data packet class number in the received data frame field;
[0139] comparing the pre-judgment data stored at the storage address according to the third data in the received data frame field;
[0140] According to the result of comparing the pre-judgment data, the sender triggers the next round of sending or stops sending;
[0141] Among them, according to the sending end triggering the next round of sending, the sending end receives the data frame field of the response end in this round, and generates an odd number for the data packet type number of the data frame field of the sending end.
[0142] Specifically, at the sending end, in order to verify that the data fed back by the answering end has a corresponding relationship with the data packet sent, after sending the data packet, the data packet class number in the data frame field and the algorithm data of the second data are used to set the storage address, and this storage address is equivalent to the data packet class number that can be calculated by the answering end. After receiving the data frame of the answering end, the data packet type number is used to directly address the storage address of the sending end. The sending end stores the pre-judgment data of the result data of the third data according to the set storage address, compares the third data sent by the answering end, and according to the comparison result, the sending end initiates the next round of data instructions, etc.
[0143] The sending end also sets the preset duration of the response cycle data based on the second data sent to the response end to determine whether the response end is abnormal, wherein the duration of the response cycle data calculated by the sending end is greater than the duration of the response cycle data calculated by the response end based on the same second data through control.
[0144] Determine whether the waiting time for the receiving response end to send the data frame field is less than the time under the preset response cycle data; if it is less than, determine whether the data packet class number in the received data frame field is an even number; if it is an even number, query the storage address according to the data packet class number in the received data frame field; compare the pre-judgment data stored under the storage address according to the third data in the received data frame field, and according to whether the comparison result is the same or different, the sending end starts the next instruction or ends this round and continues to send instructions to the response end, etc.
[0145] In addition to the data packet class number at the time of initiation, it can be specified as a second-class or first-class number, such as "1". In other interactive processes, new data packet class numbers are continuously generated based on the original data packet class numbers in the interactive process. By judging the data packet class number, it is known whether the progress of the response interaction is continuous and correct. If an abnormality occurs in the data packet class number, the interaction stage where the abnormal data packet number occurs can be used as the breakpoint of the data interaction. After restarting or resetting, the breakpoint of the data interaction can be continued, and the breakpoint of the data content can be continued. A new response interaction can also be initiated again. In this way, the reliability of each interactive response is improved to prevent missing data and missing the detection of abnormal status.
[0146] In this embodiment, it also includes:
[0147] Determine whether the waiting time for the sending end to receive the data frame field of the response from the responding end is greater than the waiting time converted under the preset response cycle data;
[0148] If,is greater than, then determine whether the sender sends a new data frame field;
[0149] If,not sent, then determine whether the sending end has received the response request from the responding end;
[0150] If,received, then send a command to allow the response;
[0151] Determining whether a data frame field of the response end is received within a preset second waiting time threshold after sending the permission instruction;
[0152] If not received, an instruction not to allow response is sent, and the waiting for the data frame field of the response end to receive the response is ended.
[0153] Specifically, when the waiting time for the data frame field sent by the receiving response end is longer than the time under the preset response cycle data, the sending end can end the waiting for the response end and transfer resources to other tasks. However, if the sending end has no new tasks, it can continue to wait for a while. If the request sent by the response end is received at this time, and the reply allows the response at this time, the response end sends the data frame field after the timeout. The sending end also needs to preset a time threshold for the data frame field after the timeout, and cannot wait indefinitely. According to the preset waiting time and working status of the sending end, the sending end feedbacks the instruction to allow the response or the instruction not to allow the response, or does not feedback any response-related instructions, and ends the current round of response interaction by delay. If the sending end needs to send new data packets to the same response end continuously, it needs to end the current round of response interaction as soon as possible by sending the instruction to allow the response or not to allow the response, and start the next round of interaction. If the sending end has been engaged in the work of interacting with other response ends, it can ignore the request of the old response end after the timeout.
[0154] In this embodiment, the sending end and the answering end can have multiple rounds of interactive responses, and each round generates a new data packet type number, and the calculation data of the newly generated data packet type number comes from the data packet type number received in the previous round. For example, the sending end initiates to send a data frame to the answering end, and the data packet type number is 1 at this time. In the answering end, the data frame with the data packet type number 1 is filtered out, and the answering end receives the data for receiving processing. When the answering end feeds back data, according to the plus-one algorithm, the data packet type number is 2. The sending end continues to add one to the data packet type number based on the data frame fed back and the data packet type number 2 therein, and the data packet type number is 3, and the next round of interaction begins, and so on. During this period, the current waiting time is continuously refreshed according to the algorithm data in the second data, and multiple rounds of interaction are performed until the sending end ends the data interaction. When the sending end needs to send a data packet again, it starts again from the data packet type number 1.
[0155] The algorithm rules for the data packet type numbering may include multiple types, not limited to the method of adding one. Multiple algorithm modules may be preset at the responding end and the sending end, and the pairing of the sending end and the responding end of different groups may be distinguished by triggering different algorithm modules.
[0156] Figure 2 It is a structural diagram of an inter-process communication device provided by one or more embodiments of the present invention.
[0157] like Figure 2 The inter-process communication device shown includes: a feature information module, a data frame setting module, a data frame structure module, a response end numbering module, a sending end numbering module, a number calculation module, a sending end data frame module, and a response end data frame module;
[0158] A characteristic information module is used to obtain characteristic information of data packets;
[0159] A data frame setting module, used to set data frame fields according to data packet characteristic information;
[0160] A data frame structure module, wherein the data frame fields include a data packet type number, first data, second data and third data, and the data packet type number includes a first type number and a second type number;
[0161] The answering end numbering module is used for the answering end to generate the data packet type number of the data frame field of the answering end as the first type number according to the data frame field of the receiving sending end;
[0162] The sending end numbering module is used for the sending end to generate the data packet type number of the data frame field of the sending end as the second type number according to the data frame field of the receiving response end;
[0163] A number calculation module is used for the data packet type number of each data frame field of the responder and the sender, which is obtained by calculating the data packet type number sent by the sender and responded by the responder in the previous round;
[0164] A sending end data frame module, used for sending end data frame fields including: first data is content data, second data is algorithm data, and third data is result data;
[0165] The response end data frame module is used for the response end data frame field to include that the third data is the comparison result data.
[0166] It is worth noting that although the present system only discloses the feature information module, the data frame setting module, the data frame structure module, the answering end numbering module, the sending end numbering module, the number calculation module, the sending end data frame module, and the answering end data frame module, it does not mean that the present device is limited to the above-mentioned basic functional modules. Rather, what the present invention wants to express is that, based on the above-mentioned basic functional modules, those skilled in the art can arbitrarily add one or more functional modules in combination with the prior art to form an infinite number of embodiments or technical solutions. In other words, the present system is open rather than closed. Because the present embodiment only discloses individual basic functional modules, it cannot be considered that the scope of protection of the claims of the present invention is limited to the above-mentioned basic functional modules.
[0167] Through the above scheme, the following beneficial technical effects are obtained:
[0168] The present application defines data packet class numbers to distinguish data between the responder and the sender, and ensures the accuracy and validity of the data based on the distinguished data.
[0169] The present application carries algorithm data through data frames, allowing the responding end to calculate the waiting time and the data packet class number, so that the responding end's response is less reliable and economical than single transmission and periodic transmission, and increases the control capability.
[0170] The present application controls the receiving and processing window of the responding end or the sending end for delayed data by comparing and judging the duration of the response cycle data, so that the data interaction between the sending end and the responding end is reliable and controllable.
[0171] Figure 3 It is a schematic diagram of a data packet frame structure of a specific embodiment of the present invention.
[0172] Figure 4 It is a schematic diagram of setting a data buffer according to a specific embodiment of the present invention.
[0173] Figure 5 It is a schematic diagram of a sending thread process according to a specific embodiment of the present invention.
[0174] Figure 6It is a schematic diagram of a receiving thread process according to a specific embodiment of the present invention.
[0175] In a specific embodiment, Figure 3 As shown, a customized lightweight inter-process communication protocol, a data frame includes a data packet number, data 1, data 2, and data 3.
[0176] Define the data packet number, where even numbers are sent packets and odd numbers are response packets. For example, if the ID (data packet number) of the sent packet is 2, then its response packet ID (data packet number) is 3, which is the sent packet ID + 1 (data packet number algorithm).
[0177] like Figure 4 As shown, in this embodiment, preparation work is performed before communication. The sender and the receiver respectively open up memory areas, which are divided into a sending area and a receiving area, and initialize pre-defined data packets to the sending area and the receiving area.
[0178] like Figure 5 As shown, after the sending end prepares to send data, it updates the data to the first field of the data packet with ID 2 in the sending area according to the pre-defined format. It determines whether the data with ID 2 in the sending area and ID 3 in the receiving area are the same (according to the preset algorithm, the responding end feeds back the data, and the data of the responding end is compared, and they are in a corresponding relationship). If they are different, the data of the sending area is sent and the 100ms timer is started. After the timer times out, it is determined again whether the data with ID 2 in the sending area and ID 3 in the receiving area are the same (according to the preset algorithm, the responding end feeds back the data, and the data of the responding end is compared, and they are in a corresponding relationship), until the same comparison result is obtained.
[0179] like Figure 6 As shown, the receiving end receives the data packet from the sending end and saves it in the receiving area, determines whether the received data packet ID is an even number, and if it is an even number, adds one to the data packet ID field, and puts the other fields as they are (after being processed by the responding end, they correspond to the original data) into the sending area and sends the data.
[0180] The solution in this embodiment can be applied to control signal communication between two systems, such as the communication between an MCU and a SOC, such as using IIC and SPI cross-chip communication, and can also be extended to control signal communication between two processes within a system.
[0181] The solution in this embodiment combines the characteristics of single transmission and periodic transmission, and realizes the advantages and avoids the disadvantages by adding a receiver response mechanism.
[0182] Figure 7 It is a structural block diagram of an electronic device according to an inter-process communication method provided by one or more embodiments of the present invention.
[0183] like Figure 7 As shown, the present application provides an electronic device, including: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus;
[0184] A computer program is stored in the memory. When the computer program is executed by the processor, the processor executes the steps of an inter-process communication method.
[0185] The present application also provides a computer-readable storage medium storing a computer program executable by an electronic device. When the computer program runs on the electronic device, the electronic device executes the steps of the inter-process communication method.
[0186] The present application also provides a vehicle computer platform, including:
[0187] An electronic device for implementing the steps of an inter-process communication method;
[0188] A processor, wherein the processor runs a program, and when the program runs, the steps of the inter-process communication method are executed from data output by the electronic device;
[0189] The storage medium is used to store a program, and when the program is running, the program executes the steps of the inter-process communication method for the data output from the electronic device.
[0190] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0191] The electronic device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory. The operating system can be any one or more computer operating systems that implement electronic device control through a process, such as a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system, or a Windows operating system. In addition, in an embodiment of the present invention, the electronic device can be a handheld device such as a smart phone or a tablet computer, or can be an electronic device such as a desktop computer or a portable computer, which is not particularly limited in the embodiment of the present invention.
[0192] The execution subject of the electronic device control in the embodiment of the present invention may be an electronic device, or a functional module in the electronic device that can call and execute a program. The electronic device may obtain the firmware corresponding to the storage medium. The firmware corresponding to the storage medium is provided by the supplier. The firmware corresponding to different storage media may be the same or different, which is not limited here. After the electronic device obtains the firmware corresponding to the storage medium, the firmware corresponding to the storage medium may be written into the storage medium, specifically, the firmware corresponding to the storage medium may be burned into the storage medium. The process of burning the firmware into the storage medium may be implemented using existing technology, which will not be described in detail in the embodiment of the present invention.
[0193] The electronic device may also obtain a reset command corresponding to the storage medium. The reset command corresponding to the storage medium is provided by the supplier. The reset commands corresponding to different storage media may be the same or different, and are not limited here.
[0194] At this time, the storage medium of the electronic device is a storage medium in which the corresponding firmware is written, and the electronic device can respond to the reset command corresponding to the storage medium in the storage medium in which the corresponding firmware is written, so that the electronic device resets the storage medium in which the corresponding firmware is written according to the reset command corresponding to the storage medium. The process of resetting the storage medium according to the reset command can be implemented by the existing technology and will not be described in detail in the embodiments of the present invention.
[0195] For the convenience of description, the above devices are described in terms of functions and are divided into various units and modules. Of course, when implementing the present application, the functions of each unit and module can be implemented in the same or multiple software and / or hardware.
[0196] Those skilled in the art will appreciate that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined.
[0197] For the method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0198] It can be known from the description of the above implementation modes that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to execute the methods described in the various implementation modes of the present application or certain parts of the implementation modes.
[0199] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An inter-process communication method, characterized in that: The inter-process communication method comprises: Obtain data packet feature information; According to the characteristic information of the data packet, the data frame field is set; The data frame field includes a data packet type number, first data, second data and third data; The data packet class number includes the first class number and the second class number; The responding end generates a data packet type number of the data frame field of the responding end according to the data frame field of the receiving sending end as a first type number; The sending end generates a data packet type number of the data frame field of the sending end according to the data frame field of the receiving response end, which is a second type number; The data packet type number of each data frame field at the responding end and the sending end is calculated from the data packet type number sent by the sending end and responded by the responding end in the previous round; The data frame field of the sending end includes: the first data is content data, the second data is algorithm data, and the third data is result data; Wherein, the response end data frame field includes: the third data is the comparison result data; Also includes: The answering end extracts the third data of the received data frame field; Comparing the result data obtained according to the execution instruction with the result data of the third data to generate comparison result data; Generating third data of the response end according to the comparison result data; Generate a data frame field of the responding end according to the data packet class number of the responding end and the third data of the responding end; Also includes: The transmitting end sets the storage address according to the data packet class number in the pre-sent data frame field and the algorithm data of the second data; The transmitting end stores the pre-judgment data according to the third data in the pre-sent data frame field according to the set storage address; The sending end receives the data frame field sent by the responding end; Query the storage address according to the data packet class number in the received data frame field; comparing the pre-judgment data stored at the storage address according to the third data in the received data frame field; Based on the result of comparing the pre-judgment data, the sending end triggers the next round of sending or stops sending.
2. The inter-process communication method according to claim 1, characterized in that: Also includes: The responder determines, based on the received data frame field, whether the data packet type number in the data frame field is a second type number; If it is the second type of number, extract the first data of the data frame field; generating an instruction according to the content data of the first data; Execute the instruction and wait for the result data of the execution.
3. The inter-process communication method according to claim 2, characterized in that: Also includes: The responding end extracts the second data according to the data packet type number of the received data frame field as the second type number; Obtaining a data packet class number of the responding end according to the algorithm data of the second data and the data packet class number of the received data frame field; Determine whether the data packet class number obtained from the response end is the first class number; If it is the first type of number, wait for the answering end to generate the third data; Wherein, the algorithm data includes, preset response cycle data; According to the waiting time for the response end to generate the third data being less than the waiting time calculated by the preset response cycle data conversion, determining whether the data packet class number of the response end is currently obtained; If the data packet class number of the response end is obtained, the data frame field of the response end is sent.
4. The inter-process communication method according to claim 3, characterized in that: Also includes: The responding end extracts the third data according to the second type number of the data packet type number in the received data frame field; Determine whether the waiting time for the response end to generate the third data is greater than the waiting time calculated by the preset response cycle data; If, it is greater than, then the third data of the current response end is flushed according to the preset processing failure flag data; Generate a data frame field of the answering end according to the data packet class number of the answering end and the third data of the answering end, and send it; Among them, before sending, a response request is sent first to determine whether an instruction to allow the response is received; If, within the preset first waiting time threshold, an instruction allowing a response is received, then sending; If no instruction to allow a response is received within the preset first waiting time threshold or an instruction not to allow a response is received, the data frame field response is abandoned and the cache is cleared.
5. The inter-process communication method according to claim 4, characterized in that: Also includes: The waiting time calculated by the transmitting end according to the response cycle data preset in the algorithm data of the second data in the pre-sent data frame field; According to the calculated waiting time, wait for the data frame field of the receiving end's response; Determine whether the waiting time of the data frame field of the response receiving end is less than the converted waiting time; If, is less than, then determine whether the data packet class number in the received data frame field is the first class number; If it is the first type number, the storage address is queried according to the data packet type number in the received data frame field; comparing the pre-judgment data stored at the storage address according to the third data in the received data frame field; According to the result of comparing the pre-judgment data, the sender triggers the next round of sending or stops sending; Among them, according to the sending end triggering the next round of sending, the sending end generates a data packet type number of the sending end's data frame field as the second type number according to the data frame field of the response end received in this round.
6. The inter-process communication method according to claim 5, characterized in that: Also includes: Determine whether the waiting time for the sending end to receive the data frame field of the response from the responding end is greater than the waiting time converted under the preset response cycle data; If,is greater than, then determine whether the sender sends a new data frame field; If,not sent, then determine whether the sending end has received the response request from the responding end; If,received, then send a command to allow the response; Determining whether a data frame field of the response end is received within a preset second waiting time threshold after sending the permission instruction; If not received, an instruction not to allow response is sent, and the waiting for the data frame field of the response end to receive the response is ended.
7. The inter-process communication method according to claim 6, characterized in that: Also includes: The first type of numbers includes even numbers, and the second type of numbers includes odd numbers.
8. An inter-process communication device, characterized in that: The inter-process communication device comprises: Characteristic information module, obtaining characteristic information of data packets; A data frame setting module sets data frame fields according to data packet characteristic information; A data frame structure module, wherein the data frame field includes a data packet type number, first data, second data and third data, and the data packet type number includes a first type number and a second type number; The answering end numbering module generates a first type number for the data packet type number of the data frame field of the answering end according to the data frame field of the receiving sending end; The sending end numbering module generates a data packet type number of the sending end data frame field as a second type number according to the receiving response end data frame field; The number calculation module calculates the data packet type number of each data frame field of the responder and the sender, which is calculated from the data packet type number sent by the sender and responded by the responder in the previous round; A sending end data frame module, wherein the sending end data frame field includes: first data is content data, second data is algorithm data, and third data is result data; A response end data frame module, wherein the response end data frame field includes: the third data is comparison result data; Also includes: The answering end extracts the third data of the received data frame field; Comparing the result data obtained according to the execution instruction with the result data of the third data to generate comparison result data; Generating third data of the response end according to the comparison result data; Generate a data frame field of the responding end according to the data packet class number of the responding end and the third data of the responding end; Also includes: The transmitting end sets the storage address according to the data packet class number in the pre-sent data frame field and the algorithm data of the second data; The transmitting end stores the pre-judgment data according to the third data in the pre-sent data frame field according to the set storage address; The sending end receives the data frame field sent by the responding end; Query the storage address according to the data packet class number in the received data frame field; comparing the pre-judgment data stored at the storage address according to the third data in the received data frame field; Based on the result of comparing the pre-judgment data, the sending end triggers the next round of sending or stops sending.
9. An electronic device, characterized in that: include: A processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; A computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the inter-process communication method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: include: It stores a computer program executable by an electronic device. When the computer program runs on the electronic device, the electronic device executes the steps of the inter-process communication method described in any one of claims 1 to 7.
11. A vehicle platform, characterized in that: include: An electronic device, used to implement the steps of the inter-process communication method according to any one of claims 1 to 7; A processor, wherein the processor runs a program, and when the program runs, data output from the electronic device executes the steps of the inter-process communication method according to any one of claims 1 to 7; A storage medium for storing a program, wherein when the program is run, the program executes the steps of the inter-process communication method according to any one of claims 1 to 7 for data output from an electronic device.
Citation Information
Patent Citations
UART communication method and device, equipment and storage medium
CN114666007A
Inter-process communication method and device, equipment and medium
CN115408172A