CN115174304A - CAN bus communication method with self-defined identifier segments - Google Patents

CAN bus communication method with self-defined identifier segments Download PDF

Info

Publication number
CN115174304A
CN115174304A CN202210721381.7A CN202210721381A CN115174304A CN 115174304 A CN115174304 A CN 115174304A CN 202210721381 A CN202210721381 A CN 202210721381A CN 115174304 A CN115174304 A CN 115174304A
Authority
CN
China
Prior art keywords
message
packet
communication
frame
identifier
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.)
Granted
Application number
CN202210721381.7A
Other languages
Chinese (zh)
Other versions
CN115174304B (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

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
    • 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 self-defined identifier segments, 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 includes: an arbitration field in a CAN communication frame is used as a segmented 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 self-defined semantics, and carrying out data retransmission on the frame loss message to carry out packet communication among the 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 self-defined identifier segments
Technical Field
The invention relates to a CAN bus communication method with a self-defined identifier segment, belonging to the technical field of CAN bus communication.
Background
CAN is a short term for Controller Area Network (CAN), developed by BOSCH corporation of germany, which is known to develop and produce automotive electronics, and finally becomes an international standard (ISO 11898), which is one of the most widely used field buses internationally. The high performance and reliability of the CAN are agreed and widely applied to the aspects of industrial automation, ships, medical equipment, industrial equipment and the like, the CAN controller works in various modes, each node in the network CAN compete to send data to the bus in a bit-by-bit arbitration mode with a lossless structure according to bus access priority (depending on message identifiers), and the CAN has the capabilities of error control and data retransmission, so that the reliability of data communication among the nodes of the network formed by the CAN bus 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 end, and CAN be divided into a data frame and a remote control frame according to the frame purpose, and the data frame and the remote control frame both have a standard frame format and an extended frame format. For the requirement of realizing a specific communication protocol by the self-defined semantics, a data field is required to be sacrificed as a carrier of the self-defined semantics, and limited communication frame resources are occupied.
Although the reliability of communication is guaranteed by the physical layer, the transport layer and the object layer, the frame loss phenomenon is still inevitable due to the limitation of data processing capability of the application layer or the excessive communication load, and a data retransmission mechanism independent of the transport layer and the object layer is needed to guarantee 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 an identifier defined by segments.
In order to solve the technical problems, the invention adopts the following technical means:
the invention provides a CAN bus communication method with self-defined identifier segments, which comprises the following steps:
grouping and transmitting the messages through the CAN communication frame with the self-defined semantics;
carrying out data retransmission on the frame loss message through a self-defined semantic CAN communication frame;
carrying out grouping communication among communication nodes through a self-defined semantic CAN communication frame;
the method for self-defining the semantics of the CAN communication frame comprises the following steps:
an arbitration field in a CAN communication frame is used as a segmented self-defining main body;
and 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 self-defined semantics.
Further, the arbitration field includes 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 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 sequence numbers SEQ [4:0];
defining a 1-bit identifier ID21 as an acknowledgement flag ACK;
defining a 1-bit identifier ID20 as a message retransmission mark RP;
defining a 1-bit identifier ID19 as a packet end flag PE;
defining 3-bit identifiers ID 16-ID 18 as packet message number FAN [2:0];
defining 8-bit identifiers ID 8-ID 15 as destination addresses DST [7:0];
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 represents the front and back relative positions of a frame when a message is transmitted, the message frame sequence number SEQ starts to count up from 0, and returns to 0 to start counting again when the message frame sequence number SEQ reaches a preset maximum value; the response mark ACK marks the response message and the non-response message, when the ACK is '1', the response message is the response message, and when the ACK is '0', the non-response message is the response message; 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 needs to be retransmitted and the data is lost, and when the RP is '0', the message does not need to be retransmitted; the end mark PE of the packet is used for marking the last packet of a packet, when the PE is '1', the last packet is marked, and when the PE is '0', the non-last packet is marked; the packet number FAN is used for identifying the packet, and a plurality of packet numbers FAN of the same packet are the same; 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 self-defined semantics comprises the following steps:
grouping the messages according to the preset communication frame data length at a sender, configuring the same packet message number FAN for a plurality of packet messages separated from the same message, and setting a packet end mark PE of the last packet message separated from the same message as 1;
the CAN bus is utilized to send the packet messages to a receiver in sequence;
and the receiver caches the received packet messages until the packet messages with the PE of 1 are obtained, and integrates the packet messages with the same FAN number into a complete message according to the sequence of the message frame sequence SEQ.
Further, the method for retransmitting the data of the frame loss message through the CAN communication frame with the self-defined semantic comprises the following steps:
according to the message frame sequence number SEQ, sending a message to a receiving party 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 frame sequence number SEQ of the message is not continuous, the receiver replies a retransmission signal which is 'ACK =1, RP = 1' and contains the interrupt sequence number to the sender, and the sender retransmits the message according to the interrupt sequence number;
and if the sender does not receive the confirmation signal or the retransmission signal within the preset time span, the sender retransmits all the messages according to the message frame sequence number SEQ.
Further, the destination address DST includes multicast bits and multicast address bits, ID15 and ID14 are defined as the multicast bits, and ID13 to ID8 are defined as the multicast address bits; setting filtering rules of multicast bits and multicast address bits by configuring an identification register Filter code and a mask register Filter mask of the node, and filtering messages on the CAN bus according to the filtering rules to perform packet communication between communication nodes; the filtering rule of the multicast bit is a full match, and the filtering rule is set by the multicast address bit 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 self-defined semantic CAN communication frame, communication flow control is performed by using a sending window:
setting the size of a sending window of a CAN bus sender as N, sending messages to a receiver by the sender by using the CAN bus, wherein the number of the sent messages each time is not more than the size of the sending window;
when a sender sends a message, subtracting 1 from an available sending window, and when the sender receives an acknowledgement signal of 'ACK =1, RP = 0' from a receiver, increasing the available sending window according to the acknowledgement signal, wherein the available sending window does not exceed N;
when the size of the available transmission window is 1, the CAN bus adopts a communication mode of sending 1 answer by 1.
The following advantages can be obtained by adopting the technical means:
the invention provides a CAN bus communication method with self-defined identifier segments, which segments an arbitration field identifier under the premise of keeping an arbitration function, defines different semantics, and CAN realize functions of packet transmission, data retransmission, packet communication between communication nodes and the like by utilizing a self-defined semantic extended communication protocol. The invention places the self-defined semantics in the arbitration field, CAN realize the expansion of the communication protocol under the precondition of no loss of arbitration, improves the utilization rate of communication frames, CAN also provide 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 the steps of a CAN bus communication method with segment-defined identifiers according to the present invention;
FIG. 2 is a diagram of a format of a CAN communication frame in an embodiment of the present invention;
FIG. 3 is a block diagram illustrating the definition of arbitration field identifier ID segments according to an embodiment of the present invention;
fig. 4 is a flow chart of packet message sending and receiving in the embodiment of the present invention;
fig. 5 is a schematic diagram illustrating a process of data transmission acknowledgement between the master node M and the slave node S according to an embodiment of the present invention;
FIG. 6 is a diagram illustrating the segmentation and filtering of the destination address DST according to an embodiment of the present invention;
FIG. 7 is a diagram illustrating grouping of communication nodes in accordance with an embodiment of the present invention;
fig. 8 is a schematic diagram of a sliding type transmission window in an embodiment of the present invention.
Detailed Description
The technical scheme of the invention is further explained by combining the accompanying drawings as follows:
the CAN communication frame is composed of a frame start, an arbitration field, a control field, a data field, a CRC field, a response field, and a frame end, each of which is assigned a definite meaning. The CAN communication frame according to the frame use CAN be divided into a data frame and a remote control frame, the data frame and the remote control frame both have a standard format frame and an extended format frame, and the format of the extended communication frame is shown in fig. 2. When a plurality of nodes start transmitting at the same time, the communication generally uses the arbitration field to arbitrate different nodes according to the size of the identifier ID to decide who has the priority to occupy the bus, therefore, the arbitration field in the prior art only provides the arbitration basis. The arbitration field ABF contains a 29-bit ID identifier and a remote-send request bit RTR, and the data field DF is 0-8 bytes long and contains the contents of a communication data message, the length of which is determined by the DLC [3:0] in the control field CTRLF.
In order to solve the problem that the self-defined semantics occupies limited communication frame resources, the invention puts the self-defined semantics in an arbitration field, and provides a CAN bus communication method with segmented self-defined identifiers, as shown in FIG. 1, which specifically comprises the following steps:
step A, an arbitration field in a CAN communication frame is used as a segmented self-defining main body; and 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 self-defined 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 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 interrupt the message with low priority, and the message is transmitted preferentially in the CAN bus. In the communication process of the CAN bus, the arbitration execution unit starts to arbitrate from the first bit ID28 (namely PRI 0) of the arbitration segment, and the node which continuously outputs the most dominant level of '0' CAN be sent continuously by preferentially occupying the bus, so that the message with high real-time requirement CAN be defined as 0, the next message CAN be defined as 1, the common message CAN be defined as 2~3, and so on.
(2) The 5-bit identifiers ID 22-ID 26 are defined as the message frame number SEQ [4:0]. The message frame sequence number SEQ represents the front and back relative positions of a frame when a message is transmitted, the message frame sequence number SEQ starts to count up from 0, returns to 0 to start counting again after the message frame sequence number SEQ reaches a preset maximum value, and sends the message in the CAN bus according to the sequence of the SEQ.
(3) The 1-bit identifier ID21 is defined as an acknowledge flag ACK. The response flag ACK identifies the response message and the non-response message, and when the ACK is "1", the message is a response message for confirming information or status, and when the ACK is "0", the message is a non-response message.
(4) The 1-bit identifier ID20 is defined as the message retransmission flag RP. The message retransmission mark RP is used for marking whether the message needs to be retransmitted or not, the RP is usually sent to a sender by a receiver in two communication parties, and the receiver tells the sender whether the data is lost or not and whether the message needs to be retransmitted or not; when the RP is '1', the data loss is shown, the message needs to be retransmitted, the corresponding SEQ is the message serial number which needs to be retransmitted, and when the RP is '0', the message corresponding to the SEQ and the previous message are all correctly received, and the message does not need to be retransmitted.
(5) The 1-bit identifier ID19 is defined as the end of packet flag PE. The end of packet marker PE is used to identify the last packet of a packet, when PE is "1", the last packet is identified, and when PE is "0", the non-last packet is identified.
(6) The 3-bit identifiers ID 16-ID 18 are defined as packet message number FAN [2:0]. The packet number FAN is used for identifying the packet, packet transmission is required for long packets, and a plurality of packet packets separated from the same packet have the same packet number FAN, so that a receiver can conveniently judge packet grouping.
(7) The 8-bit identifiers ID 8-ID 15 are defined as the destination address DST [7:0]. The CAN has no address concept, so the invention CAN construct a virtual address by using an arbitration field identifier ID, and a destination address DST is used for identifying a node address of a message receiver.
(8) 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 step B, carrying out packet transmission on the message through the CAN communication frame with the self-defined semantics. In the CAN bus communication process, a sender maintains the SEQ serial number and the FAN number, adds 1 to the FAN number of each group of complete messages after sending, returns to 0 to restart counting after reaching the maximum value, and CAN realize grouping and synthesis of the messages by utilizing the FAN and the PE.
And step B01, grouping the messages according to the preset communication frame data length at a sender, configuring the same packet message number FAN for a plurality of packet messages separated from the same message, and setting a packet end mark PE of the last packet message separated from the same message to be 1.
And step B02, sequentially sending the packet messages to a receiving party by utilizing the CAN bus according to the message frame sequence number SEQ.
And step B03, the receiving party caches the received packet messages until the packet messages with the PE of 1 are obtained, integrates the packet messages with the same FAN number into messages with complete semantics according to the sequence of the message frame number SEQ, and sends the messages to an application layer for processing.
Fig. 4 shows a packet message sending and receiving process, in the embodiment of the present invention, the length of the communication frame data cannot exceed 8 bytes, and a packet that exceeds 8 bytes in length needs to be sent in a packet. Sending a preposed length variable Len and a message packet end mark PE to be 0, then carrying out packet sending according to the length not more than 8 bytes until the accumulated length exceeds the total length Frame _ Len of the message, and setting the message packet end mark PE to be 1 when the last packet is sent, which indicates that the transmission of the message packet is finished. The receiving party caches the received message packets until the PE mark is 1, and then synthesizes all packet messages with the same FAN number into a complete message according to the SEQ sequence to be delivered to the application for analysis.
And C, retransmitting data of the frame loss message through the CAN communication frame with the self-defined semantic meaning.
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 inevitable due to the limitation of data processing capacity of an application layer or the overlarge communication load, and the like, so a set of reliable communication mechanism, namely a sending-confirming mechanism, is established for two communication parties through the CAN communication frame with the self-defined semantics. The sending side sends the message with the SEQ, the receiving side replies the message with the ACK + RP + SEQ, and the reliability of communication can be improved by adopting the modes of sending-confirming and frame loss retransmission.
And step C01, sending the message to a receiver by utilizing 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 progressively according to 1, and the sender returns to 0 to restart counting after reaching the maximum value.
And step C02, carrying out continuity judgment on the received message frame sequence numbers SEQ, and judging whether the received SEQ sequence numbers are continuous or not. The receiver confirms the message frame number, and the confirmation includes two types: 1. and secondly, confirming the current sequence number and the subsequent lost frame.
And step C03, if the message frame sequence numbers SEQ are continuous, the receiver receives continuous and reliable message data, the receiver replies an acknowledgement signal of 'ACK =1 and RP = 0' to the sender to tell the sender that the latter message can be continuously sent, and the sender continuously sends the message according to SEQ.
And step C04, if the frame sequence number SEQ of the message is discontinuous, which indicates that a frame loss phenomenon exists, the receiving party replies a retransmission signal containing an interruption sequence number to the sending party, wherein the retransmission signal contains 'ACK =1, RP = 1', and the sending party retransmits the message according to the interruption 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 retransmits all the messages by adopting an overtime retransmission mechanism according to the message frame sequence number SEQ. In the embodiment of the present invention, the preset time period is 500ms.
In the embodiment of the invention, the receiver can confirm one received message at a time or confirm a plurality of messages at a time. When the receiver confirms a plurality of messages once, the specific process is as follows: the receiving side starts timing after receiving the first message, if no new message arrives within 5ms, the receiving side replies 'ACK =1, RP = 0' to confirm the message and the previous message, if new messages arrive within 5ms, whether the serial numbers of the previous and next messages are continuous is judged, if the serial numbers are discontinuous, the receiving side replies 'ACK =1, RP = 1' to tell the sending side that a point is lost, retransmission is started, if the serial numbers are continuous, the previous process is repeated, and the confirmation of a single message or the confirmation of a plurality of continuous messages is realized.
Fig. 5 shows a process of data transmission confirmation between the master node M and the slave node S, where the slave node S transmits a message with SEQ 1 to the master node M, the master node M receives the message 1 and then transmits a confirmation signal with SEQ 1 to the slave node S, 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 then transmits a confirmation signal with SEQ 4 to the slave node S, tells that the message 4 and the previous messages (i.e., the messages 2 and 3) have been correctly received by the slave node S, then the slave node S transmits a message 5,6,7 to the master node M, the master node M successfully receives the messages 5 and 7, and because some reason does not receive the message 6, the master node M transmits a retransmission signal with SEQ 6 to the slave node S, tells that the message 6 is lost by the slave node S to retransmit the message 6 and the subsequent messages.
And D, carrying out grouping communication among the communication nodes through the CAN communication frame with the self-defined semantics.
The devices in the CAN networking often have the requirement of packet communication, for example, a group of nodes CAN simultaneously respond to a communication request of another node, and the function CAN be realized by using a multicast technology. The CAN has no address concept, a virtual address CAN be constructed by using an arbitration field identifier, a destination address DST comprises multicast bits and multicast address bits, as shown in FIG. 6, 2 high bits DST [7:6] (namely ID15 and ID 14) in 8-bit DST are defined as the multicast bits, 4 multicast networks CAN be constructed, if the multicast bits CAN not be bit-expanded, 6 low bits DST [5:0] (namely ID 13-ID 8) are defined as the multicast address bits, the multicast bits and the multicast address bits form complete node address information, the DST multicast bits are similar to a network address in IP, and the DST multicast address bits are similar to a host address in IP.
And setting filtering rules of multicast bits and multicast address bits by configuring an identification register Filter code and a mask register Filter mask of the node, and filtering messages on the CAN bus according to the filtering rules to perform packet communication between the communication nodes.
A1 at a certain position of a mask register FilterMask indicates that the matching is required, namely a message identifier is required to be consistent with a corresponding bit of an identification register of a node, a 0 indicates that the matching is not required, 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 a received identification register FilterCode.
In the embodiment of the invention, the filtering rule of the multicast bit is fully matched, namely the mask registers M1 and M0 are set to be 1, so that the multicast message is only received by the group of nodes. The multicast address bit sets a filtering rule according to the principle that a mask register is consistent with an identification register, and the corresponding multicast address Mutiaddr can be represented as 8' bM 1 M 0 111111。
The communication nodes may be grouped according to fig. 7: the first group is multicast bit of 2' b00, the multicast address bits are set to 1 bit required match, 6 node addresses of 000001, 000010 and 000100 … … can be combined, corresponding masks are respectively 8' b11000001, 8' b11000010 and 8' b11000100 … …, and all nodes can recognize the multicast address of 8' b00111111; in the second group, the multicast bits are 2' b01, the multicast address bits are set to 2-bit required match, so that 15 node addresses 000011, 000110, 001100 … … can be combined, the corresponding masks are 8' b11000011, 8' b11000110, 8' b11001100 … …, and all nodes can recognize the multicast address 8' b01111111; in the third group, the multicast bits are 2' b10, the multicast address bits are set to 3-bit required match, so that 20 node addresses 000111, 001110 and 011100 … … can be combined, the corresponding masks are 8' b11000111, 8' b11001110 and 8' b11011100 … …, and all nodes can recognize the multicast address 8' b10111111; in the fourth group, the multicast bit is 2' b11, the multicast address bits are set to 4 bits to be matched, so that 15 node addresses 001111, 011110 and 111100 … … can be combined, the corresponding masks are respectively 8' b11001111, 8' b11011110 and 8' b11111100 … …, and all the nodes can recognize the broadcast address 8' b 11111111111111.
In the embodiment of the invention, when the packet transmission is carried out on the message through the CAN communication frame with the self-defined semantics, the sliding sending window is adopted for carrying out the communication flow control. The size of a sending window of a CAN bus sender is set to be N, the sender sends messages to a receiver by using the CAN bus, the number of the sent messages each time is not larger than the size of the sending window, and at most, N messages CAN be sent if an acknowledgement signal replied by the receiver is not received. When a sender sends a message, the available sending window is reduced by 1, when the sender receives an acknowledgement signal of 'ACK =1, RP = 0' from a 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 sending window is 1, the CAN bus is degenerated into a communication mode of sending 1 answer, namely only one message CAN be sent at a time, and one message is sent after a confirmation signal.
In the embodiment of the present invention, N =10, as shown in fig. 8, 3-9 are messages that have been sent but have not received an acknowledgement, the sender may also send 3 messages, and when receiving an acknowledgement message of SEQ 4, that is, after the messages 3 and 4 have been successfully received by the opposite party, the sending window moves to the right for 2 frames, and at this time, the sender may also continue to send 5 messages.
Compared with the prior art, the method utilizes the arbitration field identifier to define the semantics, CAN expand the communication protocol under the precondition of reserving the arbitration function, CAN realize the functions of packet transmission, data retransmission, packet communication between communication nodes and the like of the message, improves the utilization rate of the communication frame, CAN realize the data retransmission through the CAN communication frame with the 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 between the nodes. The method of the invention constructs the node virtual address by using the arbitration field identifier, defines the virtual address into the multicast bit and the multicast address bit in a segmentation way, and respectively sets the filtering rules, thereby realizing the packet communication technology and improving the communication efficiency between the nodes.
The above description is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, several modifications and variations can be made without departing from the technical principle of the present invention, and these modifications and variations should also be regarded as the protection scope of the present invention.

Claims (7)

1. A CAN bus communication method with self-defined identifier segments is characterized by comprising the following steps:
grouping and transmitting the messages through the CAN communication frame with the self-defined semantics;
retransmitting data of the frame loss message through a self-defined semantic CAN communication frame;
carrying out grouping communication among communication nodes through a self-defined semantic CAN communication frame;
the method for self-defining the semantics of the CAN communication frame comprises the following steps:
an arbitration field in a CAN communication frame is used as a segmented self-defining main body;
and 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 self-defined semantics.
2. The CAN bus communication method with a self-defined identifier segment as set forth in claim 1, wherein 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 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 sequence numbers SEQ [4:0];
defining a 1-bit identifier ID21 as an acknowledgement flag ACK;
defining a 1-bit identifier ID20 as a message retransmission mark RP;
defining a 1-bit identifier ID19 as a packet end flag PE;
defining 3-bit identifiers ID 16-ID 18 as packet message number FAN [2:0];
defining 8-bit identifiers ID 8-ID 15 as destination addresses DST [7:0];
8-bit identifiers ID0 to ID7 are defined as the source address SRC [7:0].
3. The CAN bus communication method of claim 2, wherein a priority PRI is used to identify the transmission priority of a message, and the smaller the PRI value is, the higher the transmission priority of the corresponding message is; the message frame sequence number SEQ represents the front and back relative positions of a frame when a message is transmitted, the message frame sequence number SEQ starts to count up from 0, and returns to 0 to start counting again when the message frame sequence number SEQ reaches a preset maximum value; the response mark ACK is used for marking a response message and a non-response message, when the ACK is '1', the response message is the response message, and when the ACK is '0', the non-response message is the non-response message; 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 needs to be retransmitted and the data is lost, and when the RP is '0', the message does not need to be retransmitted; the end mark PE of the packet is used for marking the last packet of a packet, when the PE is '1', the last packet is marked, and when the PE is '0', the non-last packet is marked; the packet number FAN is used for identifying the packet, and a plurality of packet numbers FAN of the same packet are the same; 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.
4. The CAN bus communication method defined by the identifier segments according to claim 2, wherein the packet transmission method for the message through the CAN communication frame with the defined semantics comprises the following steps:
grouping the messages according to the preset communication frame data length at a sender, configuring the same packet message number FAN for a plurality of packet messages separated from the same message, and setting a packet end mark PE of the last packet message separated from the same message as 1;
the CAN bus is utilized to send the packet messages to a receiver in sequence;
and the receiver caches the received packet messages until the packet messages with the PE of 1 are obtained, and integrates the packet messages with the same FAN number into a complete message according to the sequence of the message frame sequence number SEQ.
5. The CAN bus communication method defined by the identifier segment as claimed in claim 2, wherein the method for retransmitting the data of the frame loss message through the CAN communication frame with the defined semantic comprises the following steps:
according to the message frame sequence number SEQ, sending a message to a receiving party 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 frame sequence number SEQ of the message is not continuous, the receiver replies a retransmission signal which is 'ACK =1, RP = 1' and contains the interrupt sequence number to the sender, and the sender retransmits the message according to the interrupt sequence number;
and if the sender does not receive the confirmation signal or the retransmission signal within the preset time span, the sender retransmits all the messages according to the message frame sequence number SEQ.
6. The CAN bus communication method defined by the identifier segments according to claim 2, wherein the destination address DST comprises a multicast bit and a multicast address bit, ID15 and ID14 are defined as the multicast bit, and ID 13-ID 8 are defined as the multicast address bit; setting filtering rules of multicast bits and multicast address bits by configuring an identification register Filter code and a mask register Filter mask of the node, and filtering messages on the CAN bus according to the filtering rules to perform packet communication between communication nodes; the filtering rule of the multicast bit is a full match, and the filtering rule is set by the multicast address bit according to the principle that the mask register is consistent with the identification register.
7. The CAN bus communication method defined by the identifier segment as claimed in claim 2, wherein when packet transmission is performed on the packet through the CAN communication frame with the defined semantics, communication flow control is performed by using a transmission window:
setting the size of a sending window of a CAN bus sender as N, sending messages to a receiver by the sender by using the CAN bus, wherein the number of the sent messages each time is not more than the size of the sending window;
when a sender sends a message, the available sending window is reduced by 1, when the sender receives an acknowledgement signal of 'ACK =1, RP = 0' from a 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 sending window is 1, the CAN bus adopts a communication mode of sending 1 answer by 1.
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 true CN115174304A (en) 2022-10-11
CN115174304B 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 (21)

* 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
US20100017654A1 (en) * 2008-07-18 2010-01-21 Wishneusky John A Device-to-Device Communication Bus for Distributed Power Management
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

Patent Citations (21)

* 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
US20100017654A1 (en) * 2008-07-18 2010-01-21 Wishneusky John A Device-to-Device Communication Bus for Distributed Power Management
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
CN115174304B (en) 2023-12-22

Similar Documents

Publication Publication Date Title
US6301249B1 (en) Efficient error control for wireless packet transmissions
JP4005974B2 (en) COMMUNICATION DEVICE, COMMUNICATION METHOD, AND COMMUNICATION SYSTEM
JP3080991B2 (en) Packet transmission system
US7487424B2 (en) Bitmap manager, method of allocating a bitmap memory, method of generating an acknowledgement between network entities, and network entity implementing the same
JP2008508812A (en) System and method for variable length acknowledgment in a shared resource network
WO2006095385A1 (en) Wireless communication apparatus
US20030128704A1 (en) TCP/IP reordering
JP2002158675A (en) Method and protocol to adapting each unique connection in multi-node network to maximum data rate
KR20010111504A (en) Data transmission method and apparatus
US10959129B2 (en) Data transmission method, apparatus, and system, and device
US20210399919A1 (en) Error frame shielding unit for a user station of a serial bus system, and method for communicating in a serial bus system
US11729021B2 (en) User station for a serial bus system and method for communication in a serial bus system
JP2006211632A (en) Detection method of crc inspection error out of range
CN112702411B (en) Method for solving CANTP multi-frame packet loss retransmission
US20220070020A1 (en) Subscriber station for a serial bus system and method for communication in a serial bus system
US10230656B2 (en) Method and apparatus for controlling message over heterogeneous network
CN108667486A (en) A kind of reliable polling communication method of power line carrier
KR20210102408A (en) Subscriber stations for serial bus systems and methods of communication in serial bus systems
JP7219342B2 (en) Subscriber stations for serial bus systems and methods of communication in serial bus systems
EP3490293A1 (en) Data transmission method, data receiving device, and data sending device
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
KR20220063212A (en) Subscriber stations for serial bus systems and methods of communication in serial bus systems
CN113541874A (en) Data transmission method and network equipment
JP4444244B2 (en) Communication device

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