CN115174304B - CAN bus communication method with sectional self-definition identifier - Google Patents

CAN bus communication method with sectional self-definition identifier Download PDF

Info

Publication number
CN115174304B
CN115174304B CN202210721381.7A CN202210721381A CN115174304B CN 115174304 B CN115174304 B CN 115174304B CN 202210721381 A CN202210721381 A CN 202210721381A CN 115174304 B CN115174304 B CN 115174304B
Authority
CN
China
Prior art keywords
message
communication
packet
frame
bit
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.)
Active
Application number
CN202210721381.7A
Other languages
Chinese (zh)
Other versions
CN115174304A (en
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.)
Nanjing Guodian Nanzi Weimeide Automation Co ltd
Original Assignee
Nanjing Guodian Nanzi Weimeide Automation 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 Nanjing Guodian Nanzi Weimeide Automation Co ltd filed Critical Nanjing Guodian Nanzi Weimeide Automation Co ltd
Priority to CN202210721381.7A priority Critical patent/CN115174304B/en
Publication of CN115174304A publication Critical patent/CN115174304A/en
Application granted granted Critical
Publication of CN115174304B publication Critical patent/CN115174304B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • 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
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/26Special purpose or proprietary protocols or architectures
    • 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/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40215Controller Area Network CAN

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computing Systems (AREA)
  • Small-Scale Networks (AREA)

Abstract

The invention discloses a CAN bus communication method with a sectional user-defined identifier, which aims to solve the technical problems of low utilization rate of CAN communication frames and frame loss of an application layer in the prior art. It comprises the following steps: utilizing an arbitration field in the CAN communication frame as a segmentation self-defining main body; segmenting the identifier ID of the arbitration field according to a preset rule, and defining the meaning of each segment of identifier ID to obtain a CAN communication frame with self-defined semantics; and carrying out packet transmission on the message through the CAN communication frame with the custom semantics, carrying out data retransmission on the frame loss message, and carrying out packet communication among communication nodes. The invention CAN improve the utilization rate of the communication frame and the reliability and the communication efficiency of CAN bus communication.

Description

CAN bus communication method with sectional self-definition identifier
Technical Field
The invention relates to a CAN bus communication method with a sectional user-defined identifier, belonging to the technical field of CAN bus communication.
Background
CAN is an abbreviation for controller area network (Controller Area Network, CAN) developed by the germany BOSCH company known as developing and producing automotive electronics, and eventually becomes the international standard (ISO 11898), one of the most widely used fieldbuses internationally. The high performance and reliability of CAN have been recognized and widely used in industrial automation, ships, medical equipment, industrial equipment, etc., CAN controllers operate in various ways, nodes in a network CAN compete to transmit data to a bus according to bus access priority (depending on a message identifier) in a bit-by-bit arbitration manner with a lossless structure, and CAN itself has error control and data retransmission capabilities, so that the reliability of data communication between nodes in a network formed by CAN buses is high.
The CAN communication frame consists of a frame start, an arbitration field, a control field, a data field, a CRC field, a response field and a frame tail, and CAN be divided into a data frame and a remote control frame according to frame purposes, wherein the data frame and the remote control frame have standard frame formats and extended frame formats. For realizing the specific communication protocol requirement with the custom semantics, the data field needs to be sacrificed as a carrier of the custom semantics, thus occupying limited communication frame resources.
Although the CAN bus ensures the reliability of communication from the physical layer, the transmission layer and the object layer, the frame loss phenomenon is unavoidable due to the limitation of the data processing capacity of the application layer or the overlarge communication load, and a set of data retransmission mechanism independent of the transmission layer and the object layer is needed to ensure the integrity of data transmission between nodes.
Disclosure of Invention
In order to solve the problems of low utilization rate of CAN communication frames and frame loss of an application layer in the prior art, the invention provides a CAN bus communication method with sectional self-definition of identifiers, which utilizes self-definition semantics of arbitration field identifiers to improve the utilization rate of communication frames, utilizes the self-definition semantics to realize a communication protocol of data retransmission and recombination, avoids data loss caused by insufficient data processing capacity and the like, and further improves the reliability of communication.
In order to solve the technical problems, the invention adopts the following technical means:
the invention provides a CAN bus communication method with a sectional user-defined identifier, which comprises the following steps:
packet transmission is carried out on the message through a CAN communication frame with custom semantics;
retransmitting data of the frame loss message through a CAN communication frame with self-defined semantics;
packet communication among communication nodes is carried out through a CAN communication frame with custom semantics;
the method for the self-defining semantics of the CAN communication frame comprises the following steps:
utilizing an arbitration field in the CAN communication frame as a segmentation self-defining main body;
segmenting the identifier ID of the arbitration field according to a preset rule, and defining the meaning of each segment of identifier ID to obtain the CAN communication frame with the custom semantics.
Further, the arbitration field contains a 29-bit identifier ID and a remote transmission request bit RTR;
the method of segmenting the identifier ID of the arbitration field and defining the meaning of each segment of the identifier ID is as follows:
defining 2-bit identifiers ID27, ID28 as priority PRI [1:0];
defining 5-bit identifiers ID 22-ID 26 as message frame numbers SEQ [4:0];
defining a 1-bit identifier ID21 as an acknowledgement flag ACK;
defining the 1-bit identifier ID20 as a message retransmission flag RP;
defining a 1-bit identifier ID19 as a message packet end mark PE;
defining 3-bit identifiers ID 16-ID 18 as packet message numbers FAN [2:0];
defining 8-bit identifiers ID 8-ID 15 as destination addresses DST [7:0];
the 8-bit identifiers ID 0-ID 7 are defined as the source address SRC [7:0].
Further, the priority PRI is used for identifying the sending priority of the message, and the smaller the PRI value is, the higher the sending priority of the corresponding message is; the message frame sequence number SEQ indicates the relative position before and after the transmission of the message frame, the message frame sequence number SEQ is counted up from 0, and when the message frame sequence number SEQ reaches a preset maximum value, the counting is restarted from 0; the response mark ACK marks a response message and a non-response message, and is the response message when the ACK is 1 and is the non-response message when the ACK is 0; the message retransmission mark RP is used for marking whether the message needs to be retransmitted or not, when the RP is 1, the message is required to be retransmitted, and when the RP is 0, the message does not need to be retransmitted; the packet end mark PE is used for identifying the last packet of a packet, when the PE is 1, the last packet is identified, and when the PE is 0, the non-last packet is identified; the packet number FAN is used for identifying the packet, and a plurality of packet messages separated from the same packet have the same packet number FAN; the destination address DST and the source address SRC are used to identify the node address of the message receiver and the node address of the sender, respectively.
Further, the method for packet transmission of the message through the CAN communication frame with the custom semantics comprises the following steps:
at a sender, grouping the messages according to the preset communication frame data length, configuring the same grouping message number FAN for a plurality of grouping messages separated from the same message, and setting a message grouping end mark PE of the last grouping message separated from the same message as 1;
the CAN bus is utilized to sequentially send the packet messages to a receiver;
the receiving side caches the received packet until the packet with PE 1 is obtained, and integrates the packet with the same FAN number into a complete message according to the sequence of the message frame sequence number SEQ.
Further, the method for retransmitting the data of the frame loss message through the CAN communication frame with the custom semantics comprises the following steps:
according to the message frame sequence number SEQ, a message is sent to a receiver by using a CAN bus;
carrying out continuity judgment on the received message frame sequence number SEQ;
if the message frame sequence numbers SEQ are continuous, the receiver replies an acknowledgement signal of 'ACK=1 and RP=0' to the sender, and the sender continues to send the message;
if the message frame sequence number SEQ is discontinuous, the receiver replies a retransmission signal which is 'ACK=1, RP=1' and contains an interrupt sequence number to the sender, and the sender retransmits the message according to the interrupt sequence number;
if the sender does not receive the acknowledgement signal or the retransmission signal within the preset time length, the sender retransmits all the messages according to the message frame sequence number SEQ.
Further, the destination address DST comprises a multicast bit and a multicast address bit, wherein ID15 and ID14 are defined as multicast bits, and ID 13-ID 8 are defined as multicast address bits; setting a filtering rule of a multicast bit and a multicast address bit by configuring an identification register Filter code and a mask register Filter mask of a node, and filtering a message on a CAN bus according to the filtering rule to carry out packet communication among communication nodes; the filtering rule of the multicast bit is full matching, and the multicast address bit sets the filtering rule according to the principle that the mask register is consistent with the identification register.
Further, when packet transmission is performed on the message through the CAN communication frame with the custom semantics, the communication flow control is performed by using the sending window:
setting the size of a sending window of a CAN bus sender as N, and sending messages to a receiver by the sender by using the CAN bus, wherein the number of messages sent each time is not more than the size of the sending window;
subtracting 1 from an available transmission window when a sender sends a message, and increasing the available transmission window according to the acknowledgement signal when the sender receives an acknowledgement signal of 'ack=1 and rp=0' from a receiver, wherein the available transmission window does not exceed N;
when the size of the available transmission window is 1, the CAN bus adopts a 1-to-1 communication mode.
The following advantages can be obtained by adopting the technical means:
the invention provides a CAN bus communication method with a segmented and customized identifier, which is characterized in that the identifier of an arbitration field is segmented under the precondition of maintaining an arbitration function, and defined into different semantics, and the functions of packet transmission, data retransmission, packet communication among communication nodes and the like of a message CAN be realized by utilizing a customized semantic extension communication protocol. The invention puts the self-defined semantics in the arbitration field, CAN realize the expansion of the communication protocol on the premise of not losing arbitration, improves the utilization rate of communication frames, provides a set of independent data retransmission mechanism outside a transmission layer and an object layer, CAN solve the problem of frame loss of an application layer, ensures the integrity of data transmission between nodes, and further improves the reliability and the communication efficiency of CAN bus communication.
Drawings
FIG. 1 is a flow chart of steps of a method for CAN bus communication with segment customization of identifiers according to the invention;
FIG. 2 is a format diagram of a CAN communication frame in an embodiment of the invention;
FIG. 3 is a schematic diagram of an embodiment of an arbitration field identifier ID segment definition;
FIG. 4 is a flow chart of packet sending and receiving in an embodiment of the invention;
fig. 5 is a schematic diagram of a process of data transmission confirmation between a master node M and a slave node S in an embodiment of the present invention;
FIG. 6 is a schematic diagram illustrating the segmentation and filtering of a destination address DST according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a communication node packet in an embodiment of the present invention;
fig. 8 is a schematic diagram of a sliding transmission window according to an embodiment of the present invention.
Detailed Description
The technical scheme of the invention is further described below with reference to the accompanying drawings:
CAN communication frames consist of a frame start, an arbitration field, a control field, a data field, a CRC field, a response field, and a frame end, each field being given a clear meaning. The CAN communication frame according to the frame use CAN be divided into a data frame and a remote control frame, wherein the data frame and the remote control frame are provided with a standard format frame and an extended format frame, and the format of the extended communication frame is shown in figure 2. When multiple nodes start transmitting at the same time, communication typically uses an arbitration field to arbitrate different nodes according to the identifier ID size to determine who has priority to occupy the bus, so the arbitration field in the prior art only provides an arbitration basis. The arbitration field ABF contains a 29-bit ID identifier and remote transmission request bits RTR, the data field DF is 0-8 bytes in length, and contains the communication data message content, and the length of the communication data message content is determined by DLC [3:0] in the control field CTRLF.
In order to solve the problem that the custom semantics occupy limited communication frame resources, the invention puts the custom semantics in an arbitration field, and provides a CAN bus communication method with a segmented and customized identifier, as shown in fig. 1, and specifically comprises the following steps:
step A, utilizing an arbitration field in a CAN communication frame as a segmentation self-defining main body; segmenting the identifier ID of the arbitration field according to a preset rule, and defining the meaning of each segment of identifier ID to obtain the CAN communication frame with the custom semantics.
As shown in fig. 3, step a redefines the arbitration field identifier ID segment as:
(1) The 2-bit identifiers ID27, ID28 are defined as priority PRI [1:0]. The priority PRI is used for identifying the sending priority of the message, the priority is defined according to the degree of urgency of the message, the message with high real-time performance needs to be transmitted preferentially, the smaller the PRI value is, the higher the sending priority of the corresponding message is, the message with high priority CAN break the message with low priority, and the message with high priority is transmitted preferentially in the CAN bus. In the CAN bus communication process, the arbitration execution unit starts arbitration from the first bit ID28 (PRI 0) of the arbitration section, and the node with the largest dominant level of 0 is continuously output to occupy the bus with priority for continuous transmission, so that the message priority with high real-time requirement is defined as 0, the next message CAN be defined as 1, the common message priority CAN be defined as 2-3, and the like.
(2) The 5-bit identifiers ID 22-ID 26 are defined as message frame numbers SEQ [4:0]. The message frame sequence number SEQ indicates the relative position before and after the transmission of the message frame, the message frame sequence number SEQ is counted up from 0, and when the message frame sequence number SEQ reaches the preset maximum value, the message is returned to 0 to restart counting, and the message is sent in the CAN bus according to the sequence of SEQ.
(3) The 1-bit identifier ID21 is defined as an acknowledgement flag ACK. The response flag ACK identifies a response message and a non-response message, and when the ACK is '1', the message is the response message and is used for confirming information or state, and when the ACK is '0', the message is the non-response message.
(4) The 1-bit identifier ID20 is defined as the message retransmission flag RP. The message retransmission flag RP is used for identifying whether the message needs to be retransmitted or not, the RP is usually sent to a sender by a receiver in both communication parties, and the receiver tells the sender whether data is lost or not and whether the message needs to be retransmitted or not; when RP is '1', the data is lost, the message is required to be retransmitted, the corresponding SEQ is the message sequence number required to be retransmitted, and when RP is '0', the corresponding SEQ and the message before the corresponding SEQ are correctly received, and the message is not required to be retransmitted.
(5) The 1-bit identifier ID19 is defined as the packet end flag PE. The packet end flag PE is used to identify the last packet of a packet, when PE is "1", the last packet, and when PE is "0", the non-last packet.
(6) The 3-bit identifiers ID16 to ID18 are defined as packet message numbers FAN [2:0]. The packet number FAN is used for identifying the packet, and for long packets, packet transmission is required, and a plurality of packet messages separated from the same packet have the same packet number FAN, so that a receiving party can conveniently judge the packet.
(7) The 8-bit identifiers ID 8-ID 15 are defined as destination addresses DST [7:0]. CAN has no address concept, so the invention CAN construct virtual address by utilizing arbitration field identifier ID, and destination address DST is used for identifying node address of message receiver.
(8) The 8-bit identifiers ID 0-ID 7 are defined as the source address SRC [7:0]. The source address SRC is used to identify the node address of the sender of the message.
And B, carrying out packet transmission on the message through a CAN communication frame with custom semantics. In the CAN bus communication process, a sender maintains the SEQ sequence number and the FAN number, and after a group of complete message FAN numbers are added with 1, the count is restarted after reaching the maximum value, and the message grouping and synthesizing CAN be realized by utilizing FAN and PE.
And B01, grouping the messages according to the preset communication frame data length at a sender, configuring the same grouping message number FAN for a plurality of grouping messages separated from the same message, and setting a message grouping end mark PE of the last grouping message separated from the same message as 1.
And step B02, according to the message frame sequence number SEQ, the packet message is sequentially sent to a receiver by using the CAN bus.
And B03, the receiving party caches the received packet until the packet with PE of 1 is obtained, integrates the packet with the same FAN number into a message with complete semantics according to the sequence of the message frame sequence number SEQ, and gives the message to an application layer for processing.
Fig. 4 shows a packet message sending and receiving flow, and in the embodiment of the present invention, the data length of the communication frame cannot exceed 8 bytes, and a message with a length exceeding 8 bytes needs to be sent in a packet. And transmitting a pre-length variable Len and a message packet end mark PE (provider edge) to be 0, and then transmitting the packet according to the length of not more than 8 bytes until the accumulated length exceeds the total length of the message frame_Len, and setting the message packet end mark PE to be 1 when the last packet is the last packet, so as to indicate that the transmission of the message packet is finished. The receiving side caches the received message packets until the PE mark is checked to be 1, and then synthesizes the complete message into each packet message with the same FAN number according to the SEQ sequence and gives the complete message to the application for analysis.
And C, retransmitting the data of the frame loss message through the CAN communication frame with the custom semantics.
Although the CAN bus ensures the reliability of communication from a physical layer, a transmission layer and an object layer, the frame loss phenomenon is unavoidable due to the limitation of the data processing capacity of an application layer or the overlarge communication load, and the like, so that the invention establishes a set of reliable communication mechanism, namely a sending-confirming mechanism, for two communication parties through the CAN communication frame with the custom semantics. The sending side sends the message with SEQ, and the receiving side replies the message of ACK+RP+SEQ, so that the reliability of communication can be improved by adopting a mode of sending-confirming and frame loss retransmission.
And step C01, transmitting the message to the receiver by using the CAN bus according to the message frame sequence number SEQ. The sender maintains the message frame sequence number SEQ, the sequence number is increased by 1, and the message frame sequence number returns to 0 to restart counting after reaching the maximum value.
And C02, continuously judging the received message frame sequence number SEQ, and judging whether the received SEQ sequence number is continuous or not. The receiving side confirms the message frame sequence number, and the confirmation comprises two types of information: 1. and confirming that the current sequence number and the subsequent state are unknown, and secondly, confirming the current sequence number and the subsequent frame loss.
Step C03, if the message frame sequence numbers SEQ are continuous, which indicates that the receiving party receives continuous and reliable message data, the receiving party replies an acknowledgement response signal of 'ACK=1 and RP=0' to the sending party, and tells the sending party to continue sending the following messages, and the sending party continues sending the messages according to the SEQ.
Step C04, if the message frame sequence number SEQ is discontinuous, indicating that there is a frame loss phenomenon, the receiving side replies the transmitting side with a retransmission signal of "ack=1, rp=1" and containing the interrupt sequence number, and the transmitting side retransmits the message according to the interrupt sequence number.
And step C05, if the sender does not receive the acknowledgement signal or the retransmission signal within the preset time length, the sender adopts a timeout retransmission mechanism to retransmit all the messages according to the message frame sequence number SEQ. In the embodiment of the invention, the preset time length is 500ms.
In the embodiment of the invention, the receiver can confirm one received message at a time, and can confirm a plurality of messages at a time. When the receiver confirms a plurality of messages at a time, the specific process is as follows: the receiving side starts timing after receiving the first message, if no new message arrives within 5ms, it replies "ACK=1, RP=0" to acknowledge the message and the previous message, if there is new message arrival within 5ms, it judges whether the sequence numbers of the previous and the next messages are continuous, if not, it replies "ACK=1, RP=1" to tell the sending side that a point loss occurs, it starts retransmission, if continuous, it repeats the previous process, and it realizes the acknowledgement of single message or the acknowledgement of multiple continuous messages together.
Fig. 5 shows a process of data transmission acknowledgement between the master node M and the slave node S, where the slave node S transmits a message with a sequence of 1 to the master node M, the master node M transmits an acknowledgement signal with a sequence of 1 to the slave node S after receiving the message 1, then the slave node S transmits messages 2, 3 and 4 to the master node M, the master node M receives the messages 2, 3 and 4 and transmits an acknowledgement signal with a sequence of 4 to the slave node S, which tells the slave node S that the message 4 and the previous message (i.e. messages 2 and 3) have been correctly received, then the slave node S transmits messages 5,6 and 7 to the master node M, the master node M successfully receives the messages 5 and 7, and for some reason does not receive the message 6, the master node M transmits a retransmission signal with a sequence of 6 to the slave node S, which tells the slave node S that the message 6 is lost, and the slave node S that the message 6 and the following messages are retransmitted.
And D, carrying out packet communication among the communication nodes through the CAN communication frames with the custom semantics.
The devices of the CAN networking often have packet communication requirements, for example, a group of nodes CAN respond to a communication request of another node at the same time, and the function CAN be realized by using a multicast technology. CAN has no address concept, CAN construct a virtual address by using an arbitration field identifier, and a destination address DST comprises multicast bits and multicast address bits, as shown in FIG. 6, the upper 2 bits DST [7:6] (namely ID15, ID 14) in 8 bits DST are defined as multicast bits, 4 multicast networks CAN be constructed, if the multicast bits are not enough to be expanded, the lower 6 bits DST [5:0] (namely ID 13-ID 8) are defined as multicast address bits, the multicast bits and the multicast address bits form complete node address information, the DST multicast bits are similar to network addresses in IP, and the DST multicast address bits are similar to host addresses in IP.
And setting a filtering rule of a multicast bit and a multicast address bit by configuring an identification register Filter code and a mask register Filter mask of the node, and filtering a message on a CAN bus according to the filtering rule to carry out packet communication among the communication nodes.
The mask register FilterMask has a certain position of ' 1 ' which indicates ' must match ', namely the message identifier must be consistent with the corresponding bit of the identification register of the node, and ' 0 ' which indicates ' don't care ', namely the corresponding bit of the message identifier is not matched, and the node only receives the message with the consistent matching bit of the message identifier and the receiving identification register FilterCode.
In the embodiment of the present invention, the filtering rule of the multicast bit is a full match, that is, mask registers M1 and M0 are set to 1, so that the multicast message is only received by the nodes of the present group. The multicast address bit sets the filtering rule according to the principle that the mask register is consistent with the identification register, and the corresponding multicast address MutiAddr can be expressed as 8' bM 1 M 0 111111。
The communication nodes may be grouped according to fig. 7: the first group, the multicast bit is 2' b00, the multicast address bit is set to 1 bit and must be matched, so that 6 node addresses 000001, 000010, 000100 and … … can be combined, the corresponding masks are 8' b11000001, 8' b11000010 and 8' b11000100 … … respectively, and all nodes can recognize the multicast address 8' b00111111; the second group, the multicast bit is 2' b01, the multicast address bit is set to 2 bits and must be matched, thus 15 node addresses 000011, 000110, 001100 and … … can be combined, the masks corresponding to each are 8' b11000011, 8' b11000110 and 8' b11001100 … … respectively, and all nodes can recognize the multicast address 8' b01111111; the third group, the multicast bit is 2' b10, the multicast address bit is set to 3 bits and must match, so that 20 node addresses 000111, 001110, 01100 and … … can be combined, the masks corresponding to each are 8' b11000111, 8' b11001110 and 8' b11011100 … … respectively, and all nodes can recognize the multicast address 8' b10111111; in the fourth group, the multicast bit is 2' b11, and the multicast address bit is set to 4 bits and must be matched, so that 15 node addresses 001111, 01110, 111100 and … … can be combined, and the masks corresponding to the respective 15 node addresses are 8' b11001111, 8' b11011110 and 8' b11111100 … …, respectively, and all nodes can recognize the broadcast address 8' b11111111.
In the embodiment of the invention, when packet transmission is carried out on the message through the CAN communication frame with the custom semantics, a sliding type sending window is adopted for carrying out communication flow control. And setting the size of a sending window of the CAN bus sender as N, and sending messages to a receiver by the sender by using the CAN bus, wherein the number of messages sent each time is not greater than the size of the sending window, and if no acknowledgement signal replied by the receiver is received, only N messages CAN be sent at most. When the sender sends a message, the available sending window is subtracted by 1, and when the sender receives an acknowledgement signal of 'ack=1 and rp=0' from the receiver, the available sending window is increased according to the acknowledgement signal, and the available sending window does not exceed N. When the size of the available transmission window is 1, the CAN bus is degenerated into a communication mode of 1 transmission and 1 response, namely, only one message CAN be transmitted at a time, and one message is transmitted after the confirmation signal is reached.
In the embodiment of the present invention, n=10, as shown in fig. 8, 3 to 9 are messages that have been sent but have not yet received an acknowledgement, and the sender may also send 3 messages, and when receiving an acknowledgement message with SEQ being 4, that is, after messages 3 and 4 have been successfully received by the other party, the sending window moves to the right by 2 frames, and at this time, the sender may still send 5 messages.
Compared with the prior art, the method of the invention utilizes the self-defined semantics of the arbitration field identifier, CAN expand the communication protocol on the premise of keeping the arbitration function, CAN realize the functions of packet transmission, data retransmission, packet communication among communication nodes and the like of the message, improves the utilization rate of communication frames, CAN realize data retransmission through the CAN communication frames of the self-defined semantics, avoids data loss caused by insufficient data processing capacity and the like, further improves the reliability of communication and ensures the integrity of data transmission among nodes. The method constructs the node virtual address by utilizing the arbitration field identifier, defines the virtual address segment into the multicast bit and the multicast address bit, and respectively sets the filtering rule, thereby realizing the packet communication technology and improving the communication efficiency among the nodes.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that modifications and variations could be made by those skilled in the art without departing from the technical principles of the present invention, and such modifications and variations should also be regarded as being within the scope of the invention.

Claims (4)

1. The CAN bus communication method with the self-defined identifier segments is characterized by comprising the following steps:
packet transmission is carried out on the message through a CAN communication frame with custom semantics;
retransmitting data of the frame loss message through a CAN communication frame with self-defined semantics;
packet communication among communication nodes is carried out through a CAN communication frame with custom semantics;
the method for the self-defining semantics of the CAN communication frame comprises the following steps:
utilizing an arbitration field in the CAN communication frame as a segmentation self-defining main body;
segmenting the identifier ID of the arbitration field according to a preset rule, and defining the meaning of each segment of identifier ID to obtain a CAN communication frame with self-defined semantics;
the arbitration field comprises a 29-bit identifier ID and a remote transmission request bit RTR;
the method of segmenting the identifier ID of the arbitration field and defining the meaning of each segment of the identifier ID is as follows:
defining 2-bit identifiers ID27, ID28 as priority PRI [1:0];
defining 5-bit identifiers ID 22-ID 26 as message frame numbers SEQ [4:0];
defining a 1-bit identifier ID21 as an acknowledgement flag ACK;
defining the 1-bit identifier ID20 as a message retransmission flag RP;
defining a 1-bit identifier ID19 as a message packet end mark PE;
defining 3-bit identifiers ID 16-ID 18 as packet message numbers FAN [2:0];
defining 8-bit identifiers ID 8-ID 15 as destination addresses DST [7:0];
defining 8-bit identifiers ID 0-ID 7 as source addresses SRC [7:0];
the method for retransmitting the data of the frame loss message through the CAN communication frame with the custom semantics comprises the following steps:
according to the message frame sequence number SEQ, a message is sent to a receiver by using a CAN bus;
carrying out continuity judgment on the received message frame sequence number SEQ;
if the message frame sequence numbers SEQ are continuous, the receiver replies an acknowledgement signal of 'ACK=1 and RP=0' to the sender, and the sender continues to send the message;
if the message frame sequence number SEQ is discontinuous, the receiver replies a retransmission signal which is 'ACK=1, RP=1' and contains an interrupt sequence number to the sender, and the sender retransmits the message according to the interrupt sequence number;
if the sender does not receive the acknowledgement signal or the retransmission signal within the preset time length, the sender retransmits all the messages according to the message frame sequence number SEQ;
the PRI is used for identifying the sending priority of the message, and the smaller the PRI value is, the higher the sending priority of the corresponding message is; the message frame sequence number SEQ indicates the relative position before and after the transmission of the message frame, the message frame sequence number SEQ is counted up from 0, and when the message frame sequence number SEQ reaches a preset maximum value, the counting is restarted from 0; the response mark ACK is used for identifying a response message and a non-response message, and is the response message when the ACK is 1 and is the non-response message when the ACK is 0; the message retransmission mark RP is used for marking whether the message needs to be retransmitted or not, when the RP is 1, the message is required to be retransmitted, and when the RP is 0, the message does not need to be retransmitted; the packet end mark PE is used for identifying the last packet of a packet, when the PE is 1, the last packet is identified, and when the PE is 0, the non-last packet is identified; the packet number FAN is used for identifying the packet, and a plurality of packet messages separated from the same packet have the same packet number FAN; the destination address DST and the source address SRC are used to identify the node address of the message receiver and the node address of the sender, respectively.
2. The method for the CAN bus communication with the segmented customization of the identifier according to claim 1, wherein the method for packet transmission of the message through the CAN communication frame with the customization semantics is as follows:
at a sender, grouping the messages according to the preset communication frame data length, configuring the same grouping message number FAN for a plurality of grouping messages separated from the same message, and setting a message grouping end mark PE of the last grouping message separated from the same message as 1;
the CAN bus is utilized to sequentially send the packet messages to a receiver;
the receiving side caches the received packet until the packet with PE 1 is obtained, and integrates the packet with the same FAN number into a complete message according to the sequence of the message frame sequence number SEQ.
3. The CAN bus communication method of claim 1, wherein the destination address DST includes multicast bits and multicast address bits, ID15, ID14 are defined as multicast bits, and ID 13-ID 8 are defined as multicast address bits; setting a filtering rule of a multicast bit and a multicast address bit by configuring an identification register Filter code and a mask register Filter mask of a node, and filtering a message on a CAN bus according to the filtering rule to carry out packet communication among communication nodes; the filtering rule of the multicast bit is full matching, the full matching is to set mask registers M1 and M0 to 1, so that the multicast message is only received by the nodes of the group, and a certain position 1 in the mask register indicates that the message identifier is required to be consistent with the corresponding bit of the identification register of the node; the multicast address bits set the filtering rules according to the principle that the mask register is consistent with the identity register.
4. The CAN bus communication method of claim 1, wherein when packet transmission is performed on the message through a CAN communication frame of custom semantics, a transmission window is used to perform communication flow control:
setting the size of a sending window of a CAN bus sender as N, and sending messages to a receiver by the sender by using the CAN bus, wherein the number of messages sent each time is not more than the size of the sending window;
subtracting 1 from an available transmission window when a sender sends a message, and increasing the available transmission window according to the acknowledgement signal when the sender receives an acknowledgement signal of 'ack=1 and rp=0' from a receiver, wherein the available transmission window does not exceed N;
when the size of the available transmission window is 1, the CAN bus adopts a 1-to-1 communication mode.
CN202210721381.7A 2022-06-24 2022-06-24 CAN bus communication method with sectional self-definition identifier Active CN115174304B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210721381.7A CN115174304B (en) 2022-06-24 2022-06-24 CAN bus communication method with sectional self-definition identifier

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210721381.7A CN115174304B (en) 2022-06-24 2022-06-24 CAN bus communication method with sectional self-definition identifier

Publications (2)

Publication Number Publication Date
CN115174304A CN115174304A (en) 2022-10-11
CN115174304B true CN115174304B (en) 2023-12-22

Family

ID=83486693

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210721381.7A Active CN115174304B (en) 2022-06-24 2022-06-24 CAN bus communication method with sectional self-definition identifier

Country Status (1)

Country Link
CN (1) CN115174304B (en)

Citations (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2002015486A2 (en) * 2000-08-16 2002-02-21 Microchip Technology Incorporated Fully programmable device operation control to allow commands
KR20020042139A (en) * 2000-11-30 2002-06-05 이계안 Method for message frame operation of can system
US6510479B1 (en) * 1999-09-15 2003-01-21 Koninklijke Philips Electronics N.V. Transmit pre-arbitration scheme for a can device and a can device that implements this scheme
JP2005130243A (en) * 2003-10-24 2005-05-19 Fuji Xerox Co Ltd Communication system, controller, can bus connection node, can bus communicating method and program
KR20060026711A (en) * 2004-09-21 2006-03-24 인하대학교 산학협력단 The can message identifier allocation method and the can message transfer arbitration method for the humanoid robot
JP2006237832A (en) * 2005-02-23 2006-09-07 Toyota Motor Corp Apparatus and method for detecting fault in communication node
CN101662404A (en) * 2008-08-27 2010-03-03 上海海事大学 CAN bus-based communication method of control instruments of ship power station
CN101764730A (en) * 2009-12-18 2010-06-30 航天东方红卫星有限公司 CAN bus data transmission method
CN102164066A (en) * 2010-02-23 2011-08-24 周媛 Reliable data transmission method for CAN (control area network)-based measurement and control subsystem
CN102550020A (en) * 2009-10-02 2012-07-04 瑞典爱立信有限公司 Method for retransmission using checksums for identifying lost data packets
CN103067301A (en) * 2013-01-17 2013-04-24 广东石油化工学院 Fast and reliable congestion control improved algorithm based on user datagram protocol (UDP)
CN103281321A (en) * 2013-05-24 2013-09-04 航天东方红卫星有限公司 Satellite-borne FlexRay bus dynamic segment communication method
CN104333517A (en) * 2014-09-28 2015-02-04 航天科工深圳(集团)有限公司 Automation equipment communication method based on CAN bus
CN104780086A (en) * 2015-05-08 2015-07-15 中国电子科技集团公司第四十七研究所 CAN bus communication method and system for environment monitoring
CN106878128A (en) * 2017-02-22 2017-06-20 北京经纬恒润科技有限公司 A kind of collocation method and device of identifier receiving filter
CN107919947A (en) * 2017-11-28 2018-04-17 南瑞集团有限公司 A kind of coding method of CAN bus long message transmission
CN109189449A (en) * 2018-10-24 2019-01-11 天津津航计算技术研究所 A kind of CAN bus based more FPGA remote upgrade methods
DE102017012214A1 (en) * 2017-07-11 2019-01-17 Volkswagen Aktiengesellschaft Method for transmitting data via a serial communication bus, appropriately designed bus interface and computer program designed accordingly
CN112019440A (en) * 2020-07-27 2020-12-01 中国人民解放军海军工程大学 CAN bus multicast method based on identifier multiplexing
CN113452591A (en) * 2021-06-21 2021-09-28 合安科技技术有限公司 Loop control method and device based on CAN bus continuous data frame

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8239597B2 (en) * 2008-07-18 2012-08-07 Intersil Americas Inc. Device-to-device communication bus for distributed power management

Patent Citations (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6510479B1 (en) * 1999-09-15 2003-01-21 Koninklijke Philips Electronics N.V. Transmit pre-arbitration scheme for a can device and a can device that implements this scheme
WO2002015486A2 (en) * 2000-08-16 2002-02-21 Microchip Technology Incorporated Fully programmable device operation control to allow commands
KR20020042139A (en) * 2000-11-30 2002-06-05 이계안 Method for message frame operation of can system
JP2005130243A (en) * 2003-10-24 2005-05-19 Fuji Xerox Co Ltd Communication system, controller, can bus connection node, can bus communicating method and program
KR20060026711A (en) * 2004-09-21 2006-03-24 인하대학교 산학협력단 The can message identifier allocation method and the can message transfer arbitration method for the humanoid robot
JP2006237832A (en) * 2005-02-23 2006-09-07 Toyota Motor Corp Apparatus and method for detecting fault in communication node
CN101662404A (en) * 2008-08-27 2010-03-03 上海海事大学 CAN bus-based communication method of control instruments of ship power station
CN102550020A (en) * 2009-10-02 2012-07-04 瑞典爱立信有限公司 Method for retransmission using checksums for identifying lost data packets
CN101764730A (en) * 2009-12-18 2010-06-30 航天东方红卫星有限公司 CAN bus data transmission method
CN102164066A (en) * 2010-02-23 2011-08-24 周媛 Reliable data transmission method for CAN (control area network)-based measurement and control subsystem
CN103067301A (en) * 2013-01-17 2013-04-24 广东石油化工学院 Fast and reliable congestion control improved algorithm based on user datagram protocol (UDP)
CN103281321A (en) * 2013-05-24 2013-09-04 航天东方红卫星有限公司 Satellite-borne FlexRay bus dynamic segment communication method
CN104333517A (en) * 2014-09-28 2015-02-04 航天科工深圳(集团)有限公司 Automation equipment communication method based on CAN bus
CN104780086A (en) * 2015-05-08 2015-07-15 中国电子科技集团公司第四十七研究所 CAN bus communication method and system for environment monitoring
CN106878128A (en) * 2017-02-22 2017-06-20 北京经纬恒润科技有限公司 A kind of collocation method and device of identifier receiving filter
DE102017012214A1 (en) * 2017-07-11 2019-01-17 Volkswagen Aktiengesellschaft Method for transmitting data via a serial communication bus, appropriately designed bus interface and computer program designed accordingly
CN107919947A (en) * 2017-11-28 2018-04-17 南瑞集团有限公司 A kind of coding method of CAN bus long message transmission
CN109189449A (en) * 2018-10-24 2019-01-11 天津津航计算技术研究所 A kind of CAN bus based more FPGA remote upgrade methods
CN112019440A (en) * 2020-07-27 2020-12-01 中国人民解放军海军工程大学 CAN bus multicast method based on identifier multiplexing
CN113452591A (en) * 2021-06-21 2021-09-28 合安科技技术有限公司 Loop control method and device based on CAN bus continuous data frame

Also Published As

Publication number Publication date
CN115174304A (en) 2022-10-11

Similar Documents

Publication Publication Date Title
US11063884B2 (en) Ethernet enhancements
US7991351B2 (en) Extension of wired controller area networks to wireless personal area networks
US6301249B1 (en) Efficient error control for wireless packet transmissions
KR100792772B1 (en) Data transmission method and apparatus
US7013157B1 (en) Method for multicast delivery with designated acknowledgment
WO2006095385A1 (en) Wireless communication apparatus
JP2002158675A (en) Method and protocol to adapting each unique connection in multi-node network to maximum data rate
JP2008508812A (en) System and method for variable length acknowledgment in a shared resource network
JP7200374B2 (en) Error frame shielding unit for subscriber station of serial bus system and communication method in serial bus system
US6741566B1 (en) Remote management ethernet network and device
US11729021B2 (en) User station for a serial bus system and method for communication in a serial bus system
EP3490293A1 (en) Data transmission method, data receiving device, and data sending device
JP7219342B2 (en) Subscriber stations for serial bus systems and methods of communication in serial bus systems
CN113079074A (en) Protocol stack communication method, device and storage medium based on CAN bus
CN115174304B (en) CAN bus communication method with sectional self-definition identifier
CN114342325B (en) Subscriber station for a serial bus system and method for communication in a serial bus system
JP4220208B2 (en) Deterministic fieldbus and method of managing such a bus
CN113541874A (en) Data transmission method and network equipment
US8332707B2 (en) Method of transmission of large data amounts in sensor network based on MAC
JPH08251146A (en) Data transmission control system
US7334040B2 (en) Method of transmission between two processors of a radio communication unit
CN112039793A (en) Multicast communication method and multicast communication equipment
WO2023030166A1 (en) Communication method and apparatus
US20230412321A1 (en) Data transmission methods and devices
CN108255770B (en) Processing method based on 1394 bus event message response mechanism

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
GR01 Patent grant
GR01 Patent grant