Method and apparatus for data frame sending based on SPI communication, communication method, and system

By introducing sending frame number and receiving frame number in SPI communication, and using cache pool management and response information adjustment strategies, the problems of frame order errors, frame repetition errors and frame loss in SPI communication are solved, and the reliability and security of communication are improved.

WO2025148320A1PCT designated stage expired Publication Date: 2025-07-17CHINA FAW CO LTD +1
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/112988
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-01-08
Filing Date
2024-08-19
Publication Date
2025-07-17

AI Technical Summary

Technical Problem

Existing SPI communications cannot effectively identify frame sequence errors, frame duplication errors and frame loss errors in cars, resulting in functional abnormalities and even safety accidents.

Method used

Introduce sending frame numbers and receiving frame numbers in SPI communication, adjusting the sending strategy through cache pool management and response information to ensure the correct order of data frames and retransmission mechanism.

Benefits of technology

Accurate identification and correction of frame sequence errors, frame repetition errors and frame loss errors during SPI communication is realized, and the reliability and security of communication are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024112988_17072025_PF_FP_ABST
    Figure CN2024112988_17072025_PF_FP_ABST
Patent Text Reader

Abstract

The present application discloses a method and apparatus for data frame sending based on SPI communication, a communication method, and a system. The method for data frame sending based on SPI communication comprises: step 1: from a cache pool, caching at least one effective data frame to be sent, the effective data frame to be sent comprising a sending frame sequence number and a receiving frame sequence number; step 2: sending cached effective data frames to be sent to a peripheral in sequence on the basis of the order of entering the cache pool, while simultaneously receiving response information returned by the peripheral during each instance of sending, and, on the basis of response information obtained each time, adjusting the effective data frames to be sent in the cache pool and a sending policy for sending to the peripheral. According to the method for data frame sending based on SPI communication in the present application, two data fields, namely a sending frame sequence number and a receiving frame sequence number, are added to a conventional communication data packet, so that when transmitting data by means of an SPI, a host can, on the basis of response information generated by a peripheral on the basis of the added sending frame sequence number and the receiving frame sequence number, accurately identify various errors occurring during transmission.
Need to check novelty before this filing date? Find Prior Art

Description

Data frame sending method, device, communication method and system based on SPI communication Technical Field

[0001] The present application relates to the field of automotive SPI communication technology, and in particular to a data frame sending method based on SPI communication, a communication host based on SPI communication, a communication method based on SPI communication, and a communication system based on SPI communication. Background Art

[0002] As advances in computer and integrated circuit technologies have permeated all industrial sectors, the demand for the safety and reliability of electronic and electrical appliances has become increasingly stringent. This is particularly true in the automotive industry, where electric vehicles are gaining increasing market share, and intelligent vehicle head units are replacing traditional ones. Regardless of technological advancements, the safety and reliability of automotive electronics and appliances cannot be compromised. Currently, electric vehicles are typically equipped with intelligent vehicle head units, which typically contain multiple processors such as an MCU and a SoC. These devices typically communicate using SPI as the primary method. Unrecognized errors during communication can lead to malfunctions and even safety incidents. We need to design a method that can transmit data reliably via SPI, accurately identify various transmission errors, and retransmit erroneous data through a retransmission mechanism.

[0003] As shown in Figure 1, the existing technology uses SPI communication within a typical vehicle controller to directly send and read data periodically, and checks the CRC of the data on the receiving end to see if it is correct, while monitoring whether the data reception interval has timed out. This method can detect integrity errors and communication timeout errors in data transmission, but since there is no retransmission mechanism, the data can only be discarded. If there are frame sequence errors (the order in which frames are received and sent is different), frame duplication errors (the same transmitted frame is received multiple times), or frame loss (one frame is not received) in the transmission, these errors cannot be detected.

[0004] Therefore, it is hoped that there will be a technical solution to solve or at least alleviate the above-mentioned deficiencies in the prior art.

[0005] Summary of the Invention

[0006] The object of the present invention is to provide a data frame sending method based on SPI communication to solve at least one of the above technical problems.

[0007] One aspect of the present invention provides a method for transmitting a data frame based on SPI communication, the method comprising:

[0008] Step 1: Buffer at least one valid data frame to be sent from a buffer pool, where the valid data frame to be sent includes a sending frame sequence number and a receiving frame sequence number;

[0009] Step 2: Send the cached valid data frames to be sent to the slave in the order in which they enter the cache pool, and receive the response information returned by the slave at the same time during each transmission. Adjust the valid data frames to be sent in the cache pool and the sending strategy to the slave according to the response information obtained each time.

[0010] Optionally, the step 2: sending the cached valid data frames to be sent to the slave in sequence according to the order of the frame sequence numbers, and receiving the response information returned by the slave at the same time during each sending, and adjusting the sending strategy of the valid data frames to be sent in the cache pool and the sending to the slave according to the response information obtained each time includes:

[0011] Step 201: Send the valid data frame to be sent that first enters the buffer pool to the slave and obtain the response information transmitted by the slave;

[0012] Step 202: Determine whether the slave has obtained the valid data frame to be sent that first enters the buffer pool according to the response information. If so,

[0013] Step 203: Delete the valid data frame to be sent that has been sent and obtain a new valid data frame to be sent.

[0014] Optionally, the step 2: sending the cached valid data frames to be sent to the slave in sequence according to the order of the frame sequence numbers, and receiving the response information returned by the slave at the same time during each sending, and adjusting the sending strategy of the valid data frames to be sent in the cache pool and the sending to the slave according to the response information obtained each time further includes:

[0015] Step 204: Determine whether the slave has obtained the valid data frame to be sent that first enters the buffer pool according to the response information. If not,

[0016] Step 205: sending the next valid data frame to be sent that enters the buffer pool after the valid data frame to be sent that has been sent to the slave in the order of the valid data frames to be sent that enter the buffer pool, and obtaining the response information transmitted by the slave;

[0017] Step 206: Determine whether the slave has obtained the valid data frame to be sent obtained from step 205 according to the response information. If yes,

[0018] Step 207: Delete the valid data frame to be sent that has been sent and obtain a new valid data frame to be sent.

[0019] Optionally, step 206 further includes:

[0020] If the judgment is no, then

[0021] Step 208: Periodically repeat steps 205 to 206. If the answer in any step 206 is yes, stop periodically repeating steps 205 to 206 and proceed to step 207.

[0022] Optionally, step 208 further includes:

[0023] If the answer in step 206 is yes at any time, step 205 is repeated after a preset time.

[0024] Optionally, the response information includes an empty response signal. When the response signal is an empty response signal, the judgment results in step 204 and step 206 are no.

[0025] Optionally, the response information further includes a retransmission signal. When the response information is a retransmission signal, step 2: sending the cached valid data frames to be sent to the slave in sequence according to the order of the frame sequence numbers, and receiving the response information returned by the slave at the same time during each transmission, and adjusting the valid data frames to be sent in the cache pool and the sending strategy to the slave according to the response information obtained each time further includes:

[0026] Before executing step 204, step 209 is added: resending the valid data frame to be sent that first enters the buffer pool to the slave and obtaining response information transmitted by the slave.

[0027] The present application also provides a communication host based on SPI communication, and the communication host based on SPI communication includes:

[0028] A module for acquiring a valid data frame to be sent, the module being configured to cache at least one valid data frame to be sent from a buffer pool, the valid data frame to be sent including a sending frame sequence number and a receiving frame sequence number;

[0029] A sending execution module is used to send the cached valid data frames to be sent to the slave in the order in which they enter the cache pool, and receive the response information returned by the slave at the same time during each sending, and adjust the sending strategy of the valid data frames to be sent in the cache pool and the sending to the slave according to the response information obtained each time.

[0030] The present application also provides a communication method based on SPI communication, the communication method based on SPI communication comprising:

[0031] The host buffers at least one valid data frame to be sent from the buffer pool, where the valid data frame to be sent includes a sending frame sequence number and a receiving frame sequence number;

[0032] The host sends the cached valid data frames to be sent to the slaves in the order in which they enter the cache pool;

[0033] The slave sends the generated response information to the host each time the host sends a valid data frame to be sent;

[0034] After receiving the response information returned by the slave each time, the host adjusts the valid data frames to be sent in the buffer pool and the sending strategy for the next sending to the slave according to the response information obtained each time.

[0035] The present application also provides a communication system based on SPI communication, wherein the communication system based on SPI communication includes a host and a slave, wherein the host and the slave cooperate to implement the communication method based on SPI communication as claimed in claim 9. Beneficial effects

[0036] The data frame sending method based on SPI communication of the present application adds two data fields, namely the sending frame sequence number and the receiving frame sequence number, to the conventional communication data packet. Therefore, when transmitting data through SPI, the host can accurately identify various errors occurring during the transmission process according to the response information generated by the slave based on the added frame sequence number and the receiving frame sequence number, and adjust the valid data frames to be sent in the buffer pool and the sending strategy to the slave through the response information obtained each time. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] FIG1 is a schematic diagram of the structure of a data frame in the prior art.

[0038] FIG2 is a flow chart of a data frame sending method based on SPI communication in an embodiment of the present application.

[0039] FIG3 is a schematic diagram of a system device for implementing the opponent simulation module shown in FIG1 .

[0040] FIG4 is a schematic diagram of the structure of a data frame in the data frame sending method based on SPI communication shown in FIG1 .

[0041] FIG5 is a schematic diagram of a normal transmission process in the data frame sending method based on SPI communication shown in FIG1 .

[0042] FIG6 is a schematic diagram of a transmission process in the case where a response is lost in the data frame sending method based on SPI communication shown in FIG1 .

[0043] FIG7 is a schematic diagram of the transmission process in the case of transmission blocking and response timeout in the data frame transmission method based on SPI communication shown in FIG1 .

[0044] FIG8 is a schematic diagram of a transmission process in a case where data needs to be retransmitted in the data frame sending method based on SPI communication shown in FIG1 .

[0045] FIG9 is a schematic diagram of a transmission process in a case of repeated transmission in the data frame sending method based on SPI communication shown in FIG1 . DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solutions and advantages of the implementation of this application clearer, the technical solutions in the embodiments of this application will be described in more detail below in conjunction with the drawings in the embodiments of this application. In the drawings, the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The described embodiments are part of the embodiments of this application, not all of the embodiments. The embodiments described below with reference to the drawings are exemplary and are intended to be used to explain this application, and should not be understood as limitations on this application. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. The embodiments of this application are described in detail below in conjunction with the drawings.

[0047] FIG2 is a flow chart of a data frame sending method based on SPI communication in an embodiment of the present application.

[0048] The data frame sending method based on SPI communication as shown in FIG2 includes:

[0049] Step 1: Buffer at least one valid data frame to be sent from a buffer pool, where the valid data frame to be sent includes a sending frame sequence number and a receiving frame sequence number;

[0050] Step 2: Send the cached valid data frames to be sent to the slave in the order in which they enter the cache pool, and receive the response information returned by the slave at the same time during each transmission. Adjust the valid data frames to be sent in the cache pool and the sending strategy to the slave according to the response information obtained each time.

[0051] The data frame sending method based on SPI communication of the present application adds two data fields, namely the sending frame sequence number and the receiving frame sequence number, to the conventional communication data packet. Therefore, when transmitting data through SPI, the host can accurately identify various errors occurring during the transmission process according to the response information generated by the slave based on the added frame sequence number and the receiving frame sequence number, and adjust the valid data frames to be sent in the buffer pool and the sending strategy to the slave through the response information obtained each time.

[0052] Referring to FIG3 , in this embodiment, the data frame of the present application adds three data fields, namely, frame type, transmission frame sequence number, and reception frame sequence number, to the conventional communication data packet. The detailed fields are described as follows.

[0053] Total packet frame header: 0xA (fixed)

[0054] Frame length: the total number of bytes from the packet header to the CRC check (excluding CRC check).

[0055] Frame Type:

[0056] Valid data frame: The data frame segment is filled with non-periodic data, and each frame requires a corresponding response.

[0057] ACK frame: used to fill the buffer when there is an ACK to be actively responded, or when there is no valid data frame but communication is to be carried out (SPI only).

[0058] Periodic frames: such as periodic data frames, various heartbeat frames, etc. These frames do not require response or retransmission.

[0059] Retransmission frame: When receiving a valid data frame with a jump in the sending frame sequence number, CRC check error, or frame header error, retransmission is requested.

[0060] Sending frame sequence number: 0~7 are sent cyclically.

[0061] Response frame sequence number: 0 to 7 are sent cyclically.

[0062] CRC check: CRC value of all bytes from the total packet header to before CRC check (excluding CRC check) to ensure the validity of the data.

[0063] In this embodiment, the data frame sending method based on SPI communication of the present application is used to describe how to send a valid data frame. The sending method of other types of frames is the same as that of the prior art and will not be described in detail here.

[0064] In this embodiment, the step 2: sending the cached valid data frames to be sent to the slave in sequence according to the order of the frame sequence numbers, and receiving the response information returned by the slave at the same time during each transmission, and adjusting the sending strategy of the valid data frames to be sent in the cache pool and the sending to the slave according to the response information obtained each time includes:

[0065] Step 201: Send the valid data frame to be sent that first enters the buffer pool to the slave and obtain the response information transmitted by the slave;

[0066] Step 202: Determine whether the slave has obtained the valid data frame to be sent that first enters the buffer pool according to the response information. If so,

[0067] Step 203: Delete the valid data frame to be sent that has been sent and obtain a new valid data frame to be sent.

[0068] In this embodiment, the step 2: sending the cached valid data frames to be sent to the slave in sequence according to the order of the frame sequence numbers, and receiving the response information returned by the slave at the same time during each transmission, and adjusting the sending strategy of the valid data frames to be sent in the cache pool and the sending to the slave according to the response information obtained each time further includes:

[0069] Step 204: Determine whether the slave has obtained the valid data frame to be sent that first enters the buffer pool according to the response information. If not,

[0070] Step 205: sending the next valid data frame to be sent that enters the buffer pool after the valid data frame to be sent that has been sent to the slave in the order of the valid data frames to be sent that enter the buffer pool, and obtaining the response information transmitted by the slave;

[0071] Step 206: Determine whether the slave has obtained the valid data frame to be sent obtained from step 205 according to the response information. If yes,

[0072] Step 207: Delete the valid data frame to be sent that has been sent and obtain a new valid data frame to be sent.

[0073] In this embodiment, step 206 further includes:

[0074] If the judgment is no, then

[0075] Step 208: Periodically repeat steps 205 to 206. If the answer in any step 206 is yes, stop periodically repeating steps 205 to 206 and proceed to step 207.

[0076] In this embodiment, step 208 further includes:

[0077] If the answer in step 206 is yes at any time, step 205 is repeated after a preset time.

[0078] In this embodiment, the response information includes a null response signal. When the response signal is a null response signal, the judgment results in step 204 and step 206 are no.

[0079] In this embodiment, the response information further includes a retransmission signal. When the response information is a retransmission signal, step 2: sending the cached valid data frames to be sent to the slave in sequence according to the order of the frame sequence numbers, and receiving the response information returned by the slave at the same time during each transmission, and adjusting the valid data frames to be sent in the cache pool and the sending strategy to the slave according to the response information obtained each time further includes:

[0080] Before executing step 204, step 209 is added: resending the valid data frame to be sent that first enters the buffer pool to the slave and obtaining response information transmitted by the slave.

[0081] The present application also provides a communication host based on SPI communication, which includes a valid data frame acquisition module to be sent and a sending execution module, wherein:

[0082] The valid data frame to be sent acquiring module is used to cache at least one valid data frame to be sent from the buffer pool, wherein the valid data frame to be sent includes a sending frame sequence number and a receiving frame sequence number;

[0083] The sending execution module is used to send the cached valid data frames to be sent to the slave in the order in which they enter the cache pool, and receive the response information returned by the slave at the same time during each sending, and adjust the sending strategy of the valid data frames to be sent in the cache pool and the sending to the slave according to the response information obtained each time.

[0084] The present application also provides a communication method based on SPI communication, the communication method based on SPI communication comprising:

[0085] The host buffers at least one valid data frame to be sent from the buffer pool, where the valid data frame to be sent includes a sending frame sequence number and a receiving frame sequence number;

[0086] The host sends the cached valid data frames to be sent to the slaves in the order in which they enter the cache pool;

[0087] The slave sends the generated response information to the host each time the host sends a valid data frame to be sent;

[0088] After receiving the response information returned by the slave each time, the host adjusts the valid data frames to be sent in the buffer pool and the sending strategy for the next sending to the slave according to the response information obtained each time.

[0089] The present application also provides a communication system based on SPI communication, wherein the communication system based on SPI communication includes a host and a slave, wherein the host and the slave cooperate to implement the communication method based on SPI communication as described above.

[0090] The present application is further described in detail below by way of examples. It should be understood that the examples do not constitute any limitation to the present application.

[0091] In this embodiment, the host may be an MCU or a SOC. It can be understood that when the host is an MCU, the slave is an SOC, and when the host is an SOC, the slave is an MCU.

[0092] In this embodiment, since communication is bidirectional, the following examples only describe the scenario of unidirectional transmission of valid frames (i.e., transmission from the host to the slave). The principle of bidirectional transmission is the same and will not be described repeatedly.

[0093] Step 1: Buffer at least one valid data frame to be sent from a buffer pool, where the valid data frame to be sent includes a sending frame sequence number and a receiving frame sequence number;

[0094] In this embodiment, the host needs to cache 5 frames in the cache pool. It is understandable that the number of cached frames can be set according to user needs, and can also be 6 frames or 7 frames.

[0095] In this embodiment, the buffered frames must be valid data frames to be sent, and response frames, periodic frames, and retransmitted frames do not need to be buffered.

[0096] In this embodiment, step 2: the cached valid data frames to be sent are sent to the slave machine in sequence according to the order in which they enter the cache pool, and the response information returned by the slave machine is received at the same time during each transmission. The valid data frames to be sent in the cache pool and the sending strategy to the slave machine are adjusted according to the response information obtained each time.

[0097] In this embodiment, in order for the valid data frame to be sent to communicate normally, the frame sequence number must be continuously incremented by 1 each time it is sent, and the number of the frame sequence number must be continuously incremented by 1 each time it is sent, and the number of the frame sequence number received must be 0 to 7, and the number of the "next frame" after the received "send frame sequence number" (the received, correct, continuous, and latest send frame sequence number). This indicates (notifying the sender) that the 5 frames before the send frame sequence number have been correctly received.

[0098] For example, suppose there are 5 frames in a buffer pool, and the frame numbers are 0, 1, 2, 3, and 4. When sending, they will be sent in order from 0 to 4, that is, frame 0 will be sent to the slave first.

[0099] In this embodiment, when communicating via SPI, sending and receiving are simultaneous, that is, when frame 0 is sent to the slave, the slave returns a response message. Under correct communication conditions, the slave sends the next frame of 0, that is, 1 as a response message.

[0100] Referring to FIG5 , in this embodiment, the step 2 of sending the cached valid data frames to be sent to the slave in sequence according to the order of the frame sequence numbers, and receiving the response information returned by the slave at the same time during each transmission, and adjusting the valid data frames to be sent in the cache pool and the sending strategy to the slave according to the response information obtained each time includes:

[0101] Step 201: Send the valid data frame to be sent that first enters the buffer pool to the slave and obtain the response information transmitted by the slave;

[0102] Step 202: Determine whether the slave has obtained the valid data frame to be sent that first enters the buffer pool according to the response information. If so,

[0103] Step 203: Delete the valid data frame to be sent that has been sent and obtain a new valid data frame to be sent.

[0104] Taking the above-mentioned buffer pool with five frames and frame numbers 0, 1, 2, 3, and 4 as an example, for example, the valid data frame to be sent that first enters the buffer pool is sent to the slave and the response information transmitted by the slave is obtained. The order of the frames entering the buffer pool is 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2 in a reciprocating order. That is to say, in this buffer pool, the valid data frame to be sent with frame number 0 enters the buffer pool first.

[0105] The valid data frame to be sent with the frame sequence number 0 is sent to the slave and the response information transmitted by the slave is obtained.

[0106] It is determined based on the response information whether the slave has obtained the valid data frame to be sent that first enters the buffer pool.

[0107] In this embodiment, if the information fed back in the response information includes a frame sequence number of 1, it is considered that the valid data frame to be sent that first enters the cache pool is obtained. At this time, the valid data frame to be sent that has been sent is deleted and a new valid data frame to be sent is obtained.

[0108] That is, the valid data frame to be sent with the frame sequence number 0 is deleted from the buffer pool, and the valid data frame to be sent with the frame sequence number 5 is put into the buffer pool. At this time, the frame sequence numbers of the valid data frames to be sent in the buffer pool become 1, 2, 3, 4, and 5.

[0109] After step 203, steps 201 and 202 may be repeated. As long as the result of step 202 is yes for each frame, the transmission is considered normal and the transmission is continued until the end.

[0110] Referring to FIG6 , in this embodiment, a response loss may occur. In this case, the following operations are required:

[0111] Step 204: Determine whether the slave has obtained the valid data frame to be sent that first enters the buffer pool according to the response information. If not,

[0112] Step 205: sending the next valid data frame to be sent that enters the buffer pool after the valid data frame to be sent that has been sent to the slave in the order of the valid data frames to be sent that enter the buffer pool, and obtaining the response information transmitted by the slave;

[0113] Step 206: Determine whether the slave has obtained the valid data frame to be sent obtained from step 205 according to the response information. If yes,

[0114] Step 207: Delete the valid data frame to be sent that has been sent and obtain a new valid data frame to be sent.

[0115] For example, it is determined based on the response information whether the slave has obtained the valid data frame to be sent that first enters the buffer pool. For example, if the frame sequence number sent is 0, and theoretically the frame sequence number in the response information is 1, but the frame actually sent is 0, then it is considered that the valid data frame to be sent with the frame sequence number 0 is lost. In this case, step 205 is performed: according to the order of the valid data frames to be sent entering the buffer pool, the next valid data frame to be sent entering the buffer pool after the valid data frame to be sent that has been sent is sent to the slave and the response information transmitted by the slave is obtained;

[0116] In this embodiment, since the frame number 0 has been sent, the frame number 1 is sent at this time.

[0117] Step 206: Determine whether the slave has obtained the valid data frame to be sent obtained from step 205 according to the response information. If yes,

[0118] Step 207: Delete the valid data frame to be sent that has been sent and obtain a new valid data frame to be sent.

[0119] Specifically, when sending a valid data frame to be sent with frame number 1, the response information theoretically obtained should include information with frame number 2. If the response information obtained in step 206 includes information with frame number 2, it is determined that the valid data frame to be sent obtained from step 205 is obtained.

[0120] At this time, step 207 is performed to delete the valid data frame to be sent that has been sent and obtain a new valid data frame to be sent.

[0121] That is, during the sending process, if only one or more responses are lost, but the subsequent responses are normal, it is considered to be in a normal state.

[0122] A problem is considered to have occurred only if all 0, 1, 2, 3, and 4 are lost when sent.

[0123] Referring to FIG. 7 , in this embodiment, step 206 further includes:

[0124] If the judgment is no, then

[0125] Step 208: Periodically repeat steps 205 to 206. If the answer in any step 206 is yes, stop periodically repeating steps 205 to 206 and proceed to step 207.

[0126] For example, in this embodiment, there are a total of 5 valid data frames to be sent in a buffer pool. For example, the frame numbers of the valid data frames to be sent are 0, 1, 2, 3, and 4 respectively. At this time, step 204 is performed first, and then it is judged as no. At this time, step 205 is performed, that is, the frame with frame number 1 is also sent. If step 206 is still judged as no at this time, then steps 205 to 206 are repeated, that is, after sending frame number 1, the valid data frame to be sent with frame number 2 is sent, and then the response information is obtained. If step 206 is still judged as no, after sending frame number 2, the valid data frame to be sent with frame number 3 is sent, and so on, until it is judged as yes in step 206 or all the valid data frames to be sent in the entire buffer pool are sent.

[0127] The advantage of adopting this method is that even if all frames 0, 1, 2, and 3 are lost when being sent, if the response information obtained when sending frame 4 includes information with frame number 5, it is considered to be a normal state.

[0128] For example, in this embodiment, it is assumed that all valid data frames to be sent corresponding to frame numbers 0, 1, 2, and 3 are lost. If the response information obtained when sending a valid data frame with frame number 4 includes information with frame number 5, it is considered to be a normal state. At this time, step 207 is performed. At this time, step 207 is: delete 0, 1, 2, 3, and 4 from the cache, and obtain new valid data frames to be sent. Because the frame number of this application goes back and forth from 0 to 7, the frame numbers in the updated cache pool should be 5, 6, 7, 0, and 1.

[0129] In another embodiment, it is assumed that all valid data frames to be sent corresponding to frame numbers 0, 1, and 2 are lost when they are sent. If the response information obtained when the frame number is 3 includes information with frame number 4, it is considered to be a normal state. At this time, step 207 is performed. At this time, step 207 is: all valid data frames to be sent corresponding to frame numbers 0, 1, 2, and 3 are deleted from the cache, and new valid data frames to be sent are obtained. Because the frame number of this application goes back and forth from 0 to 7, the frame numbers of the valid data frames to be sent in the updated cache pool should be 4, 5, 6, 7, and 0.

[0130] In this embodiment, if all the results of step 206 are negative, that is, frames 0, 1, 2, 3, and 4 are lost when they are sent, then the transmission is discontinued and the waiting period is maintained, i.e., step 205 is repeated after a preset time. For example, if no correct response information is received after 50 ms of data transmission, all frames after the unacknowledged frame are retransmitted. When the received response frame sequence number is the expected value, it is sent according to the normal process.

[0131] Referring to FIG8 , in this embodiment, the response information further includes a retransmission signal. When the response information is a retransmission signal before executing step 204, step 2: sending the cached valid data frames to be sent to the slave in sequence according to the order of the frame sequence numbers, and receiving the response information returned by the slave at the same time during each transmission, and adjusting the valid data frames to be sent in the cache pool and the sending strategy to the slave according to the response information obtained each time further includes:

[0132] Before executing step 204, step 209 is added: resending the valid data frame to be sent that first enters the buffer pool to the slave and obtaining response information transmitted by the slave.

[0133] In this embodiment, the response information further includes a retransmission signal. When the response information is a retransmission signal before executing step 206, step 2: sending the cached valid data frames to be sent to the slave in sequence according to the order of the frame sequence numbers, and receiving the response information returned by the slave at the same time during each transmission, and adjusting the valid data frames to be sent in the cache pool and the sending strategy to the slave according to the response information obtained each time further includes:

[0134] Before executing step 206, step 210 is added: sending the valid data frame to be sent before resending the retransmission signal to the slave and obtaining the response information transmitted by the slave.

[0135] For example, in some cases, the host sends a valid data frame to be sent to the slave (for example, a valid data frame to be sent with a sending frame number of 1). At this time, the slave obtains and parses the valid data frame to be sent and finds that the received "sending frame" number is not the expected frame number (for example, the frame number to be received should theoretically be 1, but the result is 3) or the received data is abnormal (CRC check error), and discards the entire frame (the valid data frame to be sent with a frame number of 1), and replies to the retransmission frame with an acknowledgement message. After receiving the frame, the host resends the valid data frame to be sent that has just been sent to the slave and obtains the response information transmitted by the slave. Figure 7 shows that the host receives the frame 0 sent by the slave with a data check error.

[0136] Referring to Figure 9, in one embodiment, the master may also repeat transmissions. For example, the master first sends a valid data frame with a transmission frame number of 1, and then sends a valid data frame with a transmission frame number of 1 again. At this time, the slave receives a duplicate frame number and discards the frame without processing. For example, after the slave receives valid data frames with sequence numbers 0 and 1, and then receives a valid data frame with sequence number 1, it expects to receive a valid data frame with sequence number 2. In this case, the slave discards frame 1 and treats it as if it had not received it. The response frame number of the next frame remains unchanged.

[0137] It should be noted that the aforementioned explanation of the method embodiment is also applicable to the system of this embodiment and will not be repeated here.

[0138] The present application also provides a communication host based on SPI communication, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor. When the processor executes the computer program, the above-mentioned data frame sending method based on SPI communication is implemented.

[0139] The present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it can implement the above-mentioned data frame sending method based on SPI communication.

[0140] FIG3 is an exemplary structural diagram of an electronic device capable of implementing the data frame sending method based on SPI communication provided according to an embodiment of the present application.

[0141] As shown in Figure 3, the electronic device includes an input device 501, an input interface 502, a central processing unit 503, a memory 504, an output interface 505, and an output device 506. The input interface 502, the central processing unit 503, the memory 504, and the output interface 505 are interconnected via a bus 507. The input device 501 and the output device 506 are connected to the bus 507 via the input interface 502 and the output interface 505, respectively, and are then connected to other components of the electronic device. Specifically, the input device 504 receives input information from the outside and transmits the input information to the central processing unit 503 via the input interface 502; the central processing unit 503 processes the input information based on the computer-executable instructions stored in the memory 504 to generate output information, temporarily or permanently stores the output information in the memory 504, and then transmits the output information to the output device 506 via the output interface 505; the output device 506 outputs the output information to the outside of the electronic device for use by the user.

[0142] That is, the electronic device shown in FIG3 can also be implemented to include: a memory storing computer-executable instructions; and one or more processors, which, when executing the computer-executable instructions, can implement the data frame sending method based on SPI communication described in conjunction with FIG1.

[0143] In one embodiment, the electronic device shown in Figure 3 can be implemented to include: a memory 504, configured to store executable program code; one or more processors 503, configured to run the executable program code stored in the memory 504 to execute the data frame sending method based on SPI communication in the above embodiment.

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

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

[0146] Computer-readable media include permanent and non-permanent, removable and non-removable media, and media can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), data versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

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

[0148] In addition, it is obvious that the word "comprising" does not exclude other units or steps. Multiple units, modules or devices recited in the device claims can also be implemented by one unit or the entire device through software or hardware.

[0149] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and a part of the module, program segment or code includes one or more executable instructions for realizing the prescribed logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes identified in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or overall flow chart can be implemented using a dedicated hardware-based system that performs the prescribed function or operation, or can be implemented using a combination of dedicated hardware and computer instructions.

[0150] The processor referred to in this embodiment may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0151] The memory can be used to store computer programs and / or modules. The processor implements various functions of the device / terminal equipment by running or executing the computer programs and / or modules stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area. The program storage area can store an operating system and at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created based on the use of the mobile phone (such as audio data, a phone book, etc.). In addition, the memory can include high-speed random access memory and non-volatile memory, such as a hard disk, internal memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0152] In this embodiment, if the module / unit integrated in the device / terminal equipment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. Although the present application is disclosed as above with reference to preferred embodiments, it is not intended to limit the present application. Any person skilled in the art may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.

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

[0154] In addition, it is obvious that the word "comprising" does not exclude other units or steps. Multiple units, modules or devices recited in the device claims can also be implemented by one unit or the entire device through software or hardware.

[0155] Although the present invention has been described in detail above using general descriptions and specific embodiments, it will be apparent to those skilled in the art that modifications and improvements may be made based on the present invention. Therefore, such modifications and improvements, which do not depart from the spirit of the present invention, are intended to be within the scope of protection claimed herein.

Claims

1. A data frame sending method based on SPI communication, characterized in that, The data frame sending method based on SPI communication includes: Step 1: Cache at least one valid data frame to be sent in a cache pool, where the valid data frame to be sent includes a sending frame sequence number and a receiving frame sequence number; Step 2: Send the cached valid data frames to be sent to the slave in the order in which they enter the cache pool, and simultaneously receive the response information returned by the slave each time a frame is sent. Adjust the valid data frames to be sent in the cache pool and the sending strategy for sending to the slave according to the response information obtained each time.

2. The data frame sending method based on SPI communication according to claim 1, wherein The Step 2: Send the cached valid data frames to be sent to the slave in the order of the frame sequence numbers, and simultaneously receive the response information returned by the slave each time a frame is sent. Adjust the valid data frames to be sent in the cache pool and the sending strategy for sending to the slave according to the response information obtained each time includes: Step 201: Send the valid data frame to be sent that first enters the cache pool to the slave and obtain the response information transmitted by the slave; Step 202: Judge whether the slave has obtained the valid data frame to be sent that first enters the cache pool according to the response information. If so, then Step 203: Delete the valid data frame to be sent that has been sent and obtain a new valid data frame to be sent.

3. The data frame sending method based on SPI communication according to claim 2, wherein, The Step 2: Send the cached valid data frames to be sent to the slave in the order of the frame sequence numbers, and simultaneously receive the response information returned by the slave each time a frame is sent. Adjust the valid data frames to be sent in the cache pool and the sending strategy for sending to the slave according to the response information obtained each time further includes: Step 204: Judge whether the slave has obtained the valid data frame to be sent that first enters the cache pool according to the response information. If not, then Step 205: In the order of the valid data frames to be sent that enter the cache pool, send the next valid data frame to be sent that enters the cache pool after the valid data frame to be sent that has been sent to the slave and obtain the response information transmitted by the slave; Step 206: Judge whether the slave has obtained the valid data frame to be sent obtained from Step 205 according to the response information. If the judgment is yes, then Step 207: Delete the valid data frame to be sent that has been sent and obtain a new valid data frame to be sent.

4. The data frame sending method based on SPI communication according to claim 3, characterized in that, The Step 206 further includes: If the judgment is no, then Step 208: Periodically repeat Steps 205 to 206. If the judgment in any Step 206 is yes, stop periodically repeating Steps 205 to 206 and perform Step 207.

5. The data frame sending method based on SPI communication according to claim 4, characterized in that, The Step 208 further includes: If the judgment in any Step 206 is not yes, repeat Step 205 after a preset time.

6. The data frame sending method based on SPI communication according to claim 5, wherein The response information includes an empty response signal. When the response signal is an empty response signal, the judgment results in Steps 204 and 206 are no.

7. The data frame sending method based on SPI communication according to claim 5, wherein The response information further includes a retransmission signal. When the response information is a retransmission signal before performing step 204, step 2: sequentially send the cached valid data frames to be sent to the slave according to the order of frame sequence numbers, and simultaneously receive the response information returned by the slave each time of sending, and adjust the valid data frames to be sent in the cache pool and the sending strategy to the slave according to the response information obtained each time further includes: Before performing step 204, add step 209: Resend the valid data frame to be sent that first enters the cache pool to the slave and obtain the response information transmitted by the slave.

8. A communication host based on SPI communication, characterized in that, The communication host based on SPI communication includes: A valid data frame to be sent acquisition module, which is used to cache at least one valid data frame to be sent in the cache pool, and the valid data frame to be sent includes a sending frame sequence number and a receiving frame sequence number; A sending execution module, which is used to sequentially send the cached valid data frames to be sent to the slave according to the order of entering the cache pool, and simultaneously receive the response information returned by the slave each time of sending, and adjust the valid data frames to be sent in the cache pool and the sending strategy to the slave according to the response information obtained each time.

9. A communication method based on SPI communication, characterized in that, The communication method based on SPI communication includes: The host caches at least one valid data frame to be sent in the cache pool, and the valid data frame to be sent includes a sending frame sequence number and a receiving frame sequence number; The host sequentially sends the cached valid data frames to be sent to the slave according to the order of entering the cache pool; The slave sends the generated response information to the host each time the host sends a valid data frame to be sent; wherein, The host adjusts the valid data frames to be sent in the cache pool and the sending strategy for the next time to be sent to the slave according to the response information obtained each time after receiving the response information returned by the slave each time.

10. A communication system based on SPI communication, characterized in that, The communication system based on SPI communication includes a host and a slave, wherein the host and the slave cooperate to implement the communication method based on SPI communication as described in claim 9.

Citation Information

Patent Citations

  • Data sending and receiving method and device for point-to-point communication, and communication terminal

    CN115801797A

  • Flow control method and device for SPI communication, terminal equipment and storage medium

    CN115941382A

  • Data transmission method, communication equipment, system, electronic device and storage medium

    CN116366223A

  • Data transmission method, storage medium and equipment

    CN117220837A

  • Data frame sending method and device based on SPI communication and communication method and system

    CN117978327A