CN114050947A - Communication method and device based on vehicle-mounted SPI bus - Google Patents

Communication method and device based on vehicle-mounted SPI bus Download PDF

Info

Publication number
CN114050947A
CN114050947A CN202111320440.1A CN202111320440A CN114050947A CN 114050947 A CN114050947 A CN 114050947A CN 202111320440 A CN202111320440 A CN 202111320440A CN 114050947 A CN114050947 A CN 114050947A
Authority
CN
China
Prior art keywords
frame
slave node
master node
node
registration
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111320440.1A
Other languages
Chinese (zh)
Inventor
刘栋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingwei Hirain Tech Co Ltd
Original Assignee
Beijing Jingwei Hirain Tech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingwei Hirain Tech Co Ltd filed Critical Beijing Jingwei Hirain Tech Co Ltd
Priority to CN202111320440.1A priority Critical patent/CN114050947A/en
Publication of CN114050947A publication Critical patent/CN114050947A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/03Protocol definition or specification 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40267Bus for use in transportation systems
    • H04L2012/40273Bus for use in transportation systems the transportation system being a vehicle

Abstract

The invention discloses a communication method and a device of a vehicle-mounted SPI bus.A Master node sends a registration request frame to a Slave node so as to enable the Slave node to respond to the registration request frame and send a registration response frame to the Master node; under the condition that a registration response frame sent by a Slave node is received and the connection is normal, packaging the received application layer message into a data frame and sending the data frame to the Slave node; and after the data frame is transmitted, sending a de-registration frame to the Slave node so as to enable the Slave node to check the message validity of the de-registration frame, and closing the SPI communication function under the condition that the validity check is passed. The method adds the connection management of the Master node and the Slave node in the communication protocol, and can send data only under the condition of normal connection, thereby ensuring the reliability of the Master node and the Slave node in the communication process.

Description

Communication method and device based on vehicle-mounted SPI bus
Technical Field
The invention relates to the technical field of automotive electronic communication, in particular to a communication method and device of a vehicle-mounted SPI bus.
Background
With the trend of new and diversified automobiles, the types of buses applied to automobile electronics are gradually enriched. The spi (serial peripheral interface) bus is widely applied to data transmission between the vehicle-mounted domain controller and the internal chips of the high-performance computing platform due to the characteristics of large bandwidth and good real-time performance.
However, the SPI bus only defines the communication specification related to the physical layer, and there is no upper layer message format definition and transmission protocol guarantee, and transmission between data is not limited, resulting in low reliability of data transmission between the Master node and the Slave node.
Disclosure of Invention
In view of this, the present invention provides a communication method and apparatus for a vehicle-mounted SPI bus, which are used to solve the problem that the reliability of data transmission between a Master node and a Slave node is low because the SPI bus only defines a communication specification related to a physical layer, does not have upper layer message format definition and transmission protocol guarantee, and cannot provide a reliable connection management function, and the specific scheme is as follows:
a communication method of a vehicle SPI bus, wherein the vehicle SPI bus comprises a target frame for a data link, and the target frame comprises: a registration request frame, a registration response frame, a data frame, and a de-registration frame, the target frame including: a frame header, a load field, and a CRC field, the frame header comprising: a message type field and a command type field, the target frame being determined based on the message type field and the command type field, the method comprising:
the Master node sends a registration request frame to a Slave node so as to enable the Slave node to respond to the registration request frame and send the registration response frame to the Master node;
the Master node receives a registration response frame sent by the Slave node, and packages the received application layer message into a data frame and sends the data frame to the Slave node under the condition that the Master node is normally connected with the Slave node;
and after the data frame is transmitted, the Master node sends a de-registration frame to the Slave node, so that the Slave node performs message validity check on the de-registration frame, and closes the SPI communication function under the condition that the validity check is passed.
Optionally, in the foregoing method, the sending, by the Master node, a registration request frame to the Slave node includes:
finishing initialization of the vehicle-mounted SPI bus within preset time length, setting the registration request frame, and sending the registration request frame according to the type of 0x00 and the Cmd of 0x00 within the preset time length;
and waiting for the Slave node to reply the initial response frame.
Optionally, in the foregoing method, the sending, by the Slave node, the registration response frame to the Master node in response to the registration request frame includes:
and the Slave node performs message validity check on the registration request frame, and sends the registration response frame to the Master node when the check is passed.
Optionally, in the method, a process of sending a registration request frame from the Master node to a Slave node and sending the registration response frame to the Master node consumes three message periods, and the method further includes:
and the Master node sends the registration request frame in a first message period, and the Slave node replies the registration response frame in a third message period.
In the foregoing method, optionally, the frame header further includes: and returning a status code, wherein after the Master node sends a registration request frame to the Slave node, under the condition that the Master node receives a registration response frame sent by the Slave node, the method further comprises the following steps:
carrying out message validity check on the registration response frame;
under the condition that the check fails, triggering the Master node to send a registration request frame to the Slave node again so as to reestablish connection;
and under the condition that the check is passed, acquiring the return state code in the registration response frame, and determining whether the connection between the Master node and the Slave node is normal or not based on the return state code.
Optionally, the determining, based on the return status code, whether the Master node and the Slave node are connected normally includes:
obtaining the value of the return state code;
under the condition that the value is 0x00, the Slave node completes initialization, and the Master node and the Slave node are normally connected;
and under the condition that the value is not 0x00, the Slave node is not initialized normally, and connection between the Master node and the Slave node is triggered to be established again.
Optionally, in the above method, after the Master node sends a registration request frame to the Slave node, if the Master node does not receive a registration response frame sent by the Slave node, the method further includes:
and triggering the Master node to send a registration request frame to the Slave node again so as to reestablish the connection.
Optionally, in the above method, after the Master node packs the received application layer message into a data frame and sends the data frame to the Slave node, the method includes:
responding to the data frame received by the Slave node, the Slave node performs message validity check on the data frame, and if the message validity check fails, discards the corresponding data frame;
and if the message validity check is passed, extracting the application layer message in the data frame, and transmitting the application layer message to an application layer.
Optionally, the method for checking the validity of the packet includes:
checking the message type field and the command type field;
performing CRC;
the timestamp is checked.
A communication device of a vehicle SPI bus comprising a target frame for a data link, wherein the target frame comprises: a registration request frame, a registration response frame, a data frame, and a de-registration frame, the target frame including: a frame header, a load field, and a CRC field, the frame header comprising: a message type field and a command type field, the target frame being determined based on the message type field and the command type field, the apparatus comprising:
a first sending module, configured to send a registration request frame to a Slave node by the Master node, so that the Slave node responds to the registration request frame and sends the registration response frame to the Master node;
a second sending module, configured to, when the Master node receives the registration response frame sent by the Slave node and is normally connected to the Slave node, the Master node packages the received application layer message into a data frame and sends the data frame to the Slave node;
and the third sending module is used for sending a de-registration frame to the Slave node by the Master node after the data frame is transmitted, so that the Slave node performs message validity check on the de-registration frame, and closes the SPI communication function when the validity check is passed.
Compared with the prior art, the invention has the following advantages:
the invention discloses a communication method and a device of a vehicle-mounted SPI bus, comprising the following steps: the Master node sends a registration request frame to the Slave node so as to enable the Slave node to respond to the registration request frame and send a registration response frame to the Master node; the Master node receives a registration response frame sent by the Slave node, and under the condition that the connection with the Slave node is normal, the Master node packs the received application layer message into a data frame and sends the data frame to the Slave node; and after the data frame is transmitted, the Master node sends a de-registration frame to the Slave node so as to enable the Slave node to check the message validity of the de-registration frame, and the SPI communication function is closed under the condition that the validity check is passed. In the process, the connection management of the Master node and the Slave node is added into the communication protocol, and the data can be sent only under the condition of normal connection, so that the reliability of the Master node and the Slave node in the communication process is ensured.
Of course, it is not necessary for any product in which the invention is practiced to achieve all of the above-described advantages at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic diagram of a general frame format structure disclosed in an embodiment of the present application;
fig. 2 is a schematic diagram of a data link layer communication mechanism disclosed in an embodiment of the present application;
fig. 3 is a flowchart of a communication method based on a vehicle SPI bus disclosed in the embodiment of the present application;
FIG. 4 is a timing diagram illustrating an initialization phase disclosed in an embodiment of the present application;
FIG. 5 is a timing diagram illustrating a data transmission phase according to an embodiment of the present disclosure;
FIG. 6 is a timing diagram illustrating an end phase disclosed in an embodiment of the present application;
FIG. 7 is a flowchart of a communication method based on the vehicle SPI bus according to the embodiment of the present application;
fig. 8 is a block diagram of a communication device based on a vehicle SPI bus according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The invention discloses a communication method and a device based on a vehicle-mounted SPI bus, which are applied to the communication process based on the SPI bus in the field of automotive electronics, and in the prior art, because the SPI bus only defines the communication specification related to a physical layer, and has no upper layer message format definition and transmission protocol guarantee, the transmission between data is not limited, and the reliability of data transmission between a Master node and a Slave node is low, in order to solve the problems, the embodiment of the invention provides the communication method of the vehicle-mounted SPI bus, the vehicle-mounted SPI bus comprises a target frame for a data link, and the target frame comprises: a registration request frame, a registration response frame, a data frame, and a de-registration frame, wherein the target frame is determined based on an SPI data link layer generic frame format, wherein the generic frame format is as shown in fig. 1, and includes: frame header, load field payload and Cyclic Redundancy Check (CRC) field, wherein the meaning and value of each field of the frame header are as follows:
version: the length is 1 byte, represents the version number, and is fixed to be 0x 01.
Type (1B): the length is 1 byte and represents a message type field, wherein 0x00 represents a REQUEST type, 0x01 represents a RESPONSE type, and 0x02 represents a NOTIFICATION type.
Cmd (1B): length 1 byte, representing a command type field, where 0x00 represents REGISTER type, 0x01 represents DATA type, and 0x02 represents UNREGISTER type.
Timestamp: the length is 8 bytes, which represents a timestamp, and a specific timing method is not limited in the embodiment of the present invention, and preferably, a UTC timing method may be adopted, and a value is a relative time based on 0 minutes and 0 seconds at 1 month and 1 day 0 in 1970, a value unit of the first 4 bytes is a second, a value unit of the last 4 bytes is a microsecond, and the time unit is only valid in a registration request frame and a data frame and is set to 0 in other types of frames.
Return code: the length is 1 byte, which represents the return status code, and represents the status of the receiving end, wherein 0x00 represents OK, and the other values represent NOK, and this field is valid only in the registration response frame and is set to 0x00 in the other type of frame.
Length: the length is 2 bytes, which represents the length of the payload field, and the unit is byte, and this field is only valid in the data frame, and is set to 0x00 in other types of frames.
The Payload field carries the Payload of the data link layer frame. In the embodiment of the invention, only the data frame does not contain the payload field, and other types of frames do not contain the payload field.
The CRC field is 2 bytes in length and is calculated using a cyclic redundancy check, preferably based on CRC 16. The calculation range comprises a head part and a payload part, and the specific parameters are as follows: 1. the check polynomial is 0x 1021; 2. the initial value is 0 xFFFF; XOR value 0x 0000.
In the embodiment of the present invention, target frames of four types, i.e., a registration request frame, a registration response frame, a data frame, and a de-registration frame, are respectively determined based on a message type field and a command type field in the general frame format shown in fig. 1, so as to implement connection management. The registration request frame is used for initializing connection, namely, the Master node initiates a connection establishment request to the Slave node. The registration response frame is used for responding the connection establishment request by the Slave node and returning to the state of the receiving end. The data frame carries data transmitted from the Master node to the slave node. And the deregistration frame is used for releasing the SPI communication connection between the Master and the slave node. The values of the Type and Cmd fields corresponding to the four functional frames are shown in table 1.
TABLE 1
Frame type Type value Cmd value
Registration request frame 0x00 0x00
Registration soundAnswer frame 0x01 0x00
Data frame 0x02 0x01
De-registration frame 0x02 0x02
In the embodiment of the present invention, a Data link layer communication mechanism based on the target frame is shown in fig. 2, and the overall communication process includes three stages, which are an initialization stage initialization, a Data Transfer stage, and a shutdown stage Finish. The initialization stage is mainly used for establishing connection between the Master and the Slave node. The initialization stage is only performed once after the vehicle is powered on in each power-on period, the data can be normally transmitted after the connection is established, the Master node initiates a registration request in the initialization stage, the Slave node replies a registration response frame Regrsp (OK) after receiving a registration request frame Reg, and the connection is established. In the Data transmission phase, the Master node packs the received application layer message into Data frames Data (1), Data (2) … Data (n), and sends the Data frames Data (1), Data (2) … Data (n) to the Slave node. And after the data transmission is finished, the Master node sends a deregistration frame UnReg, and enters an ending stage to release connection.
The processing flow of the communication method applied to the target frame in the Master node based on the communication mechanism is shown in fig. 3, and includes the steps of:
s101, the Master node sends a registration request frame to a Slave node so as to enable the Slave node to respond to the registration request frame and send a registration response frame to the Master node;
in the embodiment of the invention, the Master node has the following processing process: after starting, the SPI initialization process is completed, and the initialization process comprises the following steps: enabling a sending function, allocating a sending buffer, and the like, wherein an initialization process needs to be completed within tspinit time, where the tspinit time needs to be determined according to requirements of an application layer protocol in a real vehicle environment, which is not specifically limited in the embodiment of the present invention, preferably, the tspinit time is a value, for example, 0 to 500ms, a registration request frame is sent within the time specified by the tspinit according to a frame format defined in table 1, that is, Type is 0x00, and Cmd is 0x00, and a Slave node waits for a registration response frame to be replied by the Slave node.
The Master node and the Slave node need to consume three message cycles to establish a connection timing sequence logic, a connection timing sequence diagram in an initialization stage is shown in fig. 4, and for data sent by a Master device, a Slave device receives data mosi (Master input Slave output), and the Master node sends a registration request frame in a first message cycle, where the registration request frame includes: the method comprises the steps that RegFrame (22Byte) and the rest 22Byte length remaining bytes Don't care, further, for the data received by a Master device, a Slave device sends data miso (Master input Slave output) to enable the Slave node to perform message validity check on a registration request Frame, and if the check is passed, the Slave node sends a registration response Frame to the Master node, and the Slave node replies the registration response Frame in three message periods, wherein the registration response Frame comprises a RegRsp Frame (22Byte) and the rest 22Byte length remaining bytes Don't care.
S102, the Master node receives a registration response frame sent by the Slave node, and packages a received application layer message into a data frame and sends the data frame to the Slave node under the condition that the Master node is normally connected with the Slave node;
in this embodiment of the present invention, after the Master node sends the registration request frame, if the Master node does not receive the registration response frame, a problem may be caused because the Slave node has not started a communication function or other reasons, where reestablishment of a connection may be triggered; if a registration response frame sent by the Slave node is received, performing message validity check on the registration response frame, wherein the message validity check comprises:
(1) checking the frame Type, namely checking whether the frame Type is valid and consistent with the definitions in the table 1, mainly checking the Type and the Cmd field, if the value of the Type field is 0x01 and the value of the Cmd field is 0x00, indicating that the registration response frame is received, and entering a connection establishment state, otherwise, taking the frame as an illegal frame and discarding the frame;
(2) CRC check, namely checking a CRC field according to a CRC16 algorithm;
(3) and (4) time stamp checking, wherein when the difference value between the time stamp contained in the received frame type and the local time is more than 50ms, the message is regarded as an illegal frame and is discarded.
Extracting ReturnCode from the registration response frame under the condition that frame Type check, CRC check and timestamp check of the registration response frame pass, if ReturnCode is 0x00, indicating that the Slave node completes initialization, and under the condition that the Master node and the Slave node are normally connected, the Master node may start a data transmission process, and the timing logic of the data transmission stage is as shown in fig. 5, the device selects a signal line cs (chip select) to specify a device for data transmission, the Master device sends, the Slave device receives mosi Master Slave output and sends a DataFrame1(38KB) and a DataFrame2(38KB) to the data frame, wherein the data frame first Master node obtains an application message field from an application layer and assembles the application message field according to a frame format defined in table 1, namely Type is 0x02, and Cmd is 0x01, and the data frame may be of any Type, and preferably, in order to consider data transmission efficiency, from the functional point of view, the data frame is a notification-like message, and the sending logic of the data frame is triggered by an application layer. If the ReturnCode is not 0x00, it indicates that the Slave node is not initialized normally, and this triggers the connection to be reestablished.
Further, under the condition that the connection establishment fails, the Master node triggers retransmission in a preset period, wherein the preset period may be set based on experience or specific conditions, and the retransmission of the registration request frame is triggered without specific limitation in the embodiment of the present invention.
S103, after the data frame is transmitted, the Master node sends a de-registration frame to the Slave node, so that the Slave node performs message validity check on the de-registration frame, and the SPI communication function is closed under the condition that the validity check is passed.
In this embodiment of the present invention, in a case that a preset instruction or signal is received, it is determined that the Master node has no communication requirement, where the preset instruction or signal may be set based on experience or a specific situation, and this is not specifically limited in this embodiment of the present invention. Under the condition that the Master node has no communication requirement, that is, a timing diagram at an end stage is shown in fig. 6, a device selects a selection signal line cs (chip select) to designate a device for data transmission, a Master device sends the de-registration frame, a Slave device receives mosi (Master input Slave output), and sends the un regframe1 of 22Byte to the Slave node, wherein the Master node assembles and sends the de-registration frame to the Slave node according to a frame format defined in table 1, that is, Type is 0x02, and Cmd is 0x02, and the SPI communication function is closed by releasing SPI sending buffer, so that the Slave node closes the SPI communication function.
The invention discloses a communication method of a vehicle-mounted SPI bus, which comprises the following steps: the Master node sends a registration request frame to the Slave node so as to enable the Slave node to respond to the registration request frame and send a registration response frame to the Master node; the Master node receives a registration response frame sent by the Slave node, and under the condition that the connection with the Slave node is normal, the Master node packs the received application layer message into a data frame and sends the data frame to the Slave node; and after the data frame is transmitted, the Master node sends a de-registration frame to the Slave node so as to enable the Slave node to check the message validity of the de-registration frame, and the SPI communication function is closed under the condition that the validity check is passed. In the process, the connection management of the Master node and the Slave node is added into the communication protocol, and the data can be sent only under the condition of normal connection, so that the reliability of the Master node and the Slave node in the communication process is ensured.
The embodiment of the invention provides a communication method of a vehicle-mounted SPI bus, aiming at the execution flow of a Slave node, which is shown in a figure 7 and comprises the following steps:
s201, receiving a registration request frame sent by a Master node, and carrying out message validity check on the registration request frame;
in the embodiment of the present invention, the SPI initialization process is completed after power-on start, and the SPI initialization process includes: enabling a receiving function, allocating a receiving buffer and the like, wherein an initialization process needs to be completed within the tspaick time, wherein the tspaick time can be set based on experience or specific conditions, the embodiment of the invention is not specifically limited, and a message validity check is performed on a registration request frame under the condition that the registration request frame sent by a Master node is received, and a specific checking process is similar to a message validity checking process for a registration response frame, and the method comprises the following steps: the frame Type check, CRC check, and timestamp check distinguish the registration request frame matching the frame format defined in table 1 for the frame Type check, i.e., Type 0x00 and Cmd 0x 00.
S202, under the condition that the Master node and the Slave node are connected and connected normally, the Slave node receives a data frame sent by the Master node, performs message validity check on the data frame, extracts a load field in the data frame under the condition that the check is passed, and sends the load field to an application layer for processing;
in the embodiment of the present invention, if the check fails, the registration request frame is directly discarded, and if the check passes, a registration response frame is replied to the Master node according to a format defined in table 1, that is, a Type is 0x01, and a Cmd is 0x00, so that the Master node verifies the registration response frame, and whether the connection between the Master node and the Slave node is normal is determined, where a specific determination process is as described in S102.
Further, under the condition that the connection is normal, the Slave node receives the data frame sent by the Master node, and performs message validity check on the data frame, where a specific check process is similar to a message validity check process for the registration response frame, and the check process includes: the frame Type check, CRC check and timestamp check distinguish the data frame matching the frame Type check according to the frame format defined in table 1, i.e. Type 0x02, Cmd 0x 01. And if the check is passed, directly discarding the data frame, and if the check is passed, extracting the load field in the data frame, and sending the load field to an application layer for processing.
S203, under the condition that the unregistered frame sent by the Master node is received, message validity check is carried out on the unregistered frame, and under the condition that the check is passed, the SPI communication function is closed.
In the embodiment of the present invention, in a case where a deregistration frame sent by the Master node is received, a message validity check is performed on the deregistration frame, and a specific check process is similar to a message validity check process for the registration response frame, including: and checking a frame type, CRC (cyclic redundancy check) and a timestamp, wherein the frame type is distinguished from the unregistered frame which is matched with the frame format defined in the table 1 in the frame type checking process, if the frame type is not checked, the unregistered frame is directly discarded, and if the frame type is checked to be passed, the Slave node closes an SPI (serial peripheral interface) communication function, such as releasing an SPI (serial peripheral interface) receiving buffer, and the SPI transceiver enters a dormant state.
The invention discloses a communication method of a vehicle-mounted SPI bus, which comprises the steps of receiving a registration request frame sent by a Master node, and carrying out message validity check on the registration request frame; under the condition that the check is passed, sending a registration response frame to the Master node so as to enable the Master node to verify the registration response frame and judge whether the connection between the Master node and the Slave node is normal or not; under the condition of normal connection, the Slave node receives a data frame sent by the Master node, performs message validity check on the data frame, extracts a load field in the data frame under the condition of passing the check, and sends the load field to an application layer for processing; and under the condition of receiving a de-registration frame sent by the Master node, carrying out message validity check on the de-registration frame, and under the condition of passing the check, closing the SPI communication function. In the process, the SPI bus provides judgment for message validity check of the registration request frame, the data frame and the de-registration frame, error check of the messages is achieved, early warning under the condition of poor network quality can be achieved, transmission reliability is improved, furthermore, the Master node and the Slave node are only in an enabling state under the condition of connection establishment, once the SPI communication function is closed, the Master node and the Slave node are not in the enabling state any more, waste of computing resources and power supplies is reduced, and energy management of the whole vehicle is facilitated.
Compared with the traditional SPI bus communication form, the communication method provided by the embodiment of the invention has the advantages that the function of connection management is added, and the synchronization function can be provided for communication between the controllers in the vehicle. Meanwhile, the invention provides an error checking function, which can check the data content accuracy and the timestamp rationality, ensure the data transmission reliability and enrich the function of the SPI bus. In addition, the communication protocol of the data link layer provides a connection release function, and the controller can close SPI communication enabling under the scene without communication requirements, so that the efficiency of energy management of the whole vehicle is improved.
Based on the above-mentioned communication method for the vehicle SPI bus, the vehicle SPI bus includes the target frame for the data link, and the embodiment of the present invention further provides a communication device for the vehicle SPI bus, the vehicle SPI bus includes the target frame for the data link, wherein the target frame includes: a registration request frame, a registration response frame, a data frame, and a de-registration frame, the target frame including: a frame header, a load field, and a CRC field, the frame header comprising: a message type field and a command type field, and determining the target frame based on the message type field and the command type field, wherein a block diagram of the apparatus is shown in fig. 8, and includes:
a first sending module 301, a second sending module 302 and a third sending module 303.
Wherein the content of the first and second substances,
the first sending module 301 is configured to send a registration request frame to a Slave node by the Master node, so that the Slave node responds to the registration request frame and sends the registration response frame to the Master node;
the second sending module 302 is configured to, when the Master node receives the registration response frame sent by the Slave node and is normally connected to the Slave node, the Master node packages the received application layer message into a data frame and sends the data frame to the Slave node;
the third sending module 303 is configured to send, by the Master node, a de-registration frame to the Slave node after the data frame is transmitted, so that the Slave node performs message validity check on the de-registration frame, and closes the SPI communication function when the validity check passes.
The invention discloses a communication device of a vehicle-mounted SPI bus, comprising: the Master node sends a registration request frame to the Slave node so as to enable the Slave node to respond to the registration request frame and send a registration response frame to the Master node; the Master node receives a registration response frame sent by the Slave node, and under the condition that the connection with the Slave node is normal, the Master node packs the received application layer message into a data frame and sends the data frame to the Slave node; and after the data frame is transmitted, the Master node sends a de-registration frame to the Slave node so as to enable the Slave node to check the message validity of the de-registration frame, and the SPI communication function is closed under the condition that the validity check is passed. In the process, the connection management of the Master node and the Slave node is added into the communication protocol, and the data can be sent only under the condition of normal connection, so that the reliability of the Master node and the Slave node in the communication process is ensured.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. For the device-like embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functions of the units may be implemented in the same software and/or hardware or in a plurality of software and/or hardware when implementing the invention.
From the above description of the embodiments, it is clear to those skilled in the art that the present invention can be implemented by software plus necessary general hardware platform. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which may be stored in a storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
The above detailed description is provided for the communication method and device of the vehicle-mounted SPI bus, and a specific example is applied in this document to explain the principle and the implementation of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A communication method of a vehicle SPI bus is characterized in that the vehicle SPI bus comprises a target frame for a data link, wherein the target frame comprises: a registration request frame, a registration response frame, a data frame, and a de-registration frame, the target frame including: a frame header, a load field, and a CRC field, the frame header comprising: a message type field and a command type field, the target frame being determined based on the message type field and the command type field, the method comprising:
the Master node sends a registration request frame to a Slave node so as to enable the Slave node to respond to the registration request frame and send the registration response frame to the Master node;
the Master node receives a registration response frame sent by the Slave node, and packages the received application layer message into a data frame and sends the data frame to the Slave node under the condition that the Master node is normally connected with the Slave node;
and after the data frame is transmitted, the Master node sends a de-registration frame to the Slave node, so that the Slave node performs message validity check on the de-registration frame, and closes the SPI communication function under the condition that the validity check is passed.
2. The method of claim 1, wherein the Master node sending a registration request frame to the Slave node comprises:
finishing initialization of the vehicle-mounted SPI bus within preset time length, setting the registration request frame, and sending the registration request frame according to the type of 0x00 and the Cmd of 0x00 within the preset time length;
and waiting for the Slave node to reply the initial response frame.
3. The method of claim 2, wherein the Slave node sending the registration response frame to the Master node in response to the registration request frame, comprises:
and the Slave node performs message validity check on the registration request frame, and sends the registration response frame to the Master node when the check is passed.
4. The method according to claim 1, wherein a process of sending a registration request frame from the Master node to a Slave node to send the registration response frame to the Master node consumes three message cycles, and the method further comprises:
and the Master node sends the registration request frame in a first message period, and the Slave node replies the registration response frame in a third message period.
5. The method of claim 1, wherein the frame header further comprises: and returning a status code, wherein after the Master node sends a registration request frame to the Slave node, under the condition that the Master node receives a registration response frame sent by the Slave node, the method further comprises the following steps:
carrying out message validity check on the registration response frame;
under the condition that the check fails, triggering the Master node to send a registration request frame to the Slave node again so as to reestablish connection;
and under the condition that the check is passed, acquiring the return state code in the registration response frame, and determining whether the connection between the Master node and the Slave node is normal or not based on the return state code.
6. The method of claim 5, wherein determining whether the Master node and the Slave node are connected normally based on the return status code comprises:
obtaining the value of the return state code;
under the condition that the value is 0x00, the Slave node completes initialization, and the Master node and the Slave node are normally connected;
and under the condition that the value is not 0x00, the Slave node is not initialized normally, and connection between the Master node and the Slave node is triggered to be established again.
7. The method according to claim 1, wherein in a case that after the Master node sends a registration request frame to a Slave node, the Master node does not receive a registration response frame sent by the Slave node, the method further comprises:
and triggering the Master node to send a registration request frame to the Slave node again so as to reestablish the connection.
8. The method of claim 1, wherein after the Master node packages the received application layer message into a data frame and sends the data frame to the Slave node, the method comprises:
responding to the data frame received by the Slave node, the Slave node performs message validity check on the data frame, and if the message validity check fails, discards the corresponding data frame;
and if the message validity check is passed, extracting the application layer message in the data frame, and transmitting the application layer message to an application layer.
9. The method according to any of claims 1-8, wherein the message validity check comprises:
checking the message type field and the command type field;
performing CRC;
the timestamp is checked.
10. A communication device of a vehicle SPI bus, characterized in that the vehicle SPI bus comprises a target frame for a data link, wherein the target frame comprises: a registration request frame, a registration response frame, a data frame, and a de-registration frame, the target frame including: a frame header, a load field, and a CRC field, the frame header comprising: a message type field and a command type field, the target frame being determined based on the message type field and the command type field, the apparatus comprising:
a first sending module, configured to send a registration request frame to a Slave node by the Master node, so that the Slave node responds to the registration request frame and sends the registration response frame to the Master node;
a second sending module, configured to, when the Master node receives the registration response frame sent by the Slave node and is normally connected to the Slave node, the Master node packages the received application layer message into a data frame and sends the data frame to the Slave node;
and the third sending module is used for sending a de-registration frame to the Slave node by the Master node after the data frame is transmitted, so that the Slave node performs message validity check on the de-registration frame, and closes the SPI communication function when the validity check is passed.
CN202111320440.1A 2021-11-09 2021-11-09 Communication method and device based on vehicle-mounted SPI bus Pending CN114050947A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111320440.1A CN114050947A (en) 2021-11-09 2021-11-09 Communication method and device based on vehicle-mounted SPI bus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111320440.1A CN114050947A (en) 2021-11-09 2021-11-09 Communication method and device based on vehicle-mounted SPI bus

Publications (1)

Publication Number Publication Date
CN114050947A true CN114050947A (en) 2022-02-15

Family

ID=80207722

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111320440.1A Pending CN114050947A (en) 2021-11-09 2021-11-09 Communication method and device based on vehicle-mounted SPI bus

Country Status (1)

Country Link
CN (1) CN114050947A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116055501A (en) * 2023-01-17 2023-05-02 深圳国际量子研究院 Link system for real-time communication between nodes

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180276157A1 (en) * 2017-03-24 2018-09-27 Analog Devices Global Serial peripheral interface daisy chain mode system and apparatus
CN112817886A (en) * 2021-02-04 2021-05-18 珠海全志科技股份有限公司 Master-slave communication method and device based on SPI

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180276157A1 (en) * 2017-03-24 2018-09-27 Analog Devices Global Serial peripheral interface daisy chain mode system and apparatus
CN112817886A (en) * 2021-02-04 2021-05-18 珠海全志科技股份有限公司 Master-slave communication method and device based on SPI

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
冯培德: "《民用飞机机载总线与网络》", 西安电子科学技术大学出版社, pages: 179 - 196 *
李民华: "综合智能配电终端研究与设计", 《中国优秀硕士学位论文全文数据库 工程科技Ⅱ辑》, 15 May 2016 (2016-05-15), pages 22 - 25 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116055501A (en) * 2023-01-17 2023-05-02 深圳国际量子研究院 Link system for real-time communication between nodes
CN116055501B (en) * 2023-01-17 2023-07-25 深圳国际量子研究院 Link system for real-time communication between nodes

Similar Documents

Publication Publication Date Title
CN108965484B (en) Internet of things data transmission method, system and terminal
CA2362961C (en) Bridge for can to tcp/ip connection
WO2019010686A1 (en) Data processing method and data processing apparatus
CN110768882B (en) Data monitoring method and system, monitoring equipment and vehicle
CN108848025B (en) Data processing method, intelligent gateway and Internet of things system
WO2017095919A1 (en) Systems and methods for implementing a time-stamped controller area network (can) bus message
CN112075063B (en) Gateway for data communication in a vehicle
CN114050947A (en) Communication method and device based on vehicle-mounted SPI bus
WO2022017102A1 (en) Arbitration line-based full-duplex spi communication method
WO2022040847A1 (en) Communication data processing method and apparatus
US20010034799A1 (en) Packet transmission/reception processor
WO2021223247A1 (en) Device upgrading method, smart device, and computer readable storage medium
CN114095901A (en) Communication data processing method and device
CN101494565A (en) Method for processing node defect of distributed wireless access system
Goel et al. UVM based controller area network verification IP (VIP)
JP5888252B2 (en) Vehicle communication device and information processing device
CN113411198B (en) Communication method and device based on dual channels and RSSP-I, electronic equipment and storage medium
US20160364245A1 (en) Operation method of communication node in automotive network
CN204145528U (en) The how main real-time communication system of a kind of UART
CN105515925A (en) UART multi-master real-time communication system
CN109981660B (en) Information processing method and electronic equipment
CN110505641B (en) Method for improving ZigBee master-slave communication polling efficiency by utilizing full-duplex UART communication and coordinator thereof
WO2022062857A1 (en) Resource request method, resource configuration method, and related product
CN115100840B (en) Equipment control method, device, electronic equipment and storage medium
CN110876852A (en) Network game data processing method and system of micro-service

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination