CN108199941B - CAN bus communication method based on CAN2.0B - Google Patents

CAN bus communication method based on CAN2.0B Download PDF

Info

Publication number
CN108199941B
CN108199941B CN201711478076.5A CN201711478076A CN108199941B CN 108199941 B CN108199941 B CN 108199941B CN 201711478076 A CN201711478076 A CN 201711478076A CN 108199941 B CN108199941 B CN 108199941B
Authority
CN
China
Prior art keywords
frame
command
communication
register
address
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
CN201711478076.5A
Other languages
Chinese (zh)
Other versions
CN108199941A (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.)
Nanovision Technology Beijing Co Ltd
Original Assignee
Nanovision Technology Beijing 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 Nanovision Technology Beijing Co Ltd filed Critical Nanovision Technology Beijing Co Ltd
Priority to CN201711478076.5A priority Critical patent/CN108199941B/en
Publication of CN108199941A publication Critical patent/CN108199941A/en
Application granted granted Critical
Publication of CN108199941B publication Critical patent/CN108199941B/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
    • H04L12/40006Architecture of a communication node
    • H04L12/40013Details regarding a bus controller
    • 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
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40143Bus networks involving priority mechanisms
    • 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

Abstract

The invention discloses a CAN bus communication method based on CAN2.0B, which comprises the following steps: the master device sends a communication frame with a frame sequence code to the slave device based on a CAN bus communication protocol; the slave equipment receives the communication frame, operates to the register position specified by the target register address of the master equipment according to the command type of the communication frame, and returns a response frame with the same frame sequence code to the master equipment; the master device stores the received response frame in the register location specified by the destination register address of the slave device. The method can distinguish the sequence of different command frames by specifying the frame sequence coding, simultaneously determines the response relation of the command by matching with the command type, and the sending and receiving ends can judge the historical relation of the message according to the identification code part for judging the successful receiving and sending state of the bus, thereby improving the execution efficiency of the application software and the reliability of information interaction.

Description

CAN bus communication method based on CAN2.0B
Technical Field
The invention relates to a CAN bus communication method, in particular to a CAN bus communication method based on CAN2.0B, and belongs to the technical field of network communication.
Background
A CAN (Controller Area Network) bus CAN effectively support serial communication of distributed control or real-time control, and is widely applied to the fields of industrial automation, automobiles, ships, medical equipment, industrial equipment and the like. Compared with a common communication bus, the data communication based on the CAN bus has stronger reliability, instantaneity and flexibility.
In the CAN2.0 protocol, a 29-bit message identifier is specified for priority determination and reception filtering, and an 8-byte data field is used for communication data. However, in practical application, a suitable communication mechanism needs to be designed by using the message identification code and the data area, so as to specifically realize the CAN bus communication.
In the practical application of the CAN bus, the communication efficiency of the CAN bus is reduced due to improper processing of application software, and the real-time performance of the CAN bus is reduced, so that a set of communication mechanism with good reliability, high efficiency and excellent real-time performance is designed under the framework of the CAN bus to realize efficient and reliable communication, and the technical problem which needs to be solved urgently in the application of the CAN bus is solved.
Disclosure of Invention
In order to overcome the defects in the prior art, the invention provides a CAN bus communication method based on CAN2.0 b.
In order to achieve the purpose, the invention adopts the following technical scheme:
a CAN bus communication method based on CAN2.0B comprises the following steps:
the master device sends a communication frame with a frame sequence code to the slave device based on a CAN bus communication protocol;
the slave equipment receives the communication frame, operates to the register position specified by the target register address of the master equipment according to the command type of the communication frame, and returns a response frame with the same frame sequence code to the master equipment;
the master device stores the received response frame in the register location specified by the destination register address of the slave device.
Preferably, when the command type of the communication frame is a write command, the communication process includes the following steps:
the master device sends a communication frame with a frame sequence code to the slave device based on a CAN bus communication protocol;
the slave equipment receives the communication frame, acquires the command type of the communication frame as a write command, and stores the data in the data area in the communication frame to the register position specified by the target register address of the master equipment; and returning a response frame with the same frame order code to the master device;
the master device stores the received response frame in the register location specified by the destination register address of the slave device.
Preferably, when the command type of the communication frame is a read command, the communication process includes the following steps:
the master device sends a communication frame with a frame sequence code to the slave device based on a CAN bus communication protocol;
the slave equipment receives the communication frame, obtains the command type of the communication frame as a read command, obtains the target register address of the master equipment, obtains the data information of the register position specified by the target register address of the master equipment, and returns a response frame with the same frame sequence coding and data information to the master equipment;
the master device stores the received response frame in the register location specified by the destination register address of the slave device.
Preferably, when the burst state occurs, a burst command is generated, the slave device generates a burst communication frame containing the burst command, and the burst communication frame is transmitted to the master device according to the priority of the identification code part of the burst communication frame and the priority order; and the master device stores the content of the data area of the burst communication frame into a register position specified by the target register address of the slave device according to the target register address of the slave device.
Preferably, when the command type of the communication frame is a broadcast frame, the master device sends the broadcast frame to all slave devices with the same broadcast address at the same time, and the slave devices store the received data information in the register position specified by the target register address of the broadcast frame, and the broadcast frame does not need to respond.
Preferably, the CAN bus communication protocol based on CAN2.0b includes an identification code part and a data part.
Wherein preferably said identification code portion represents a priority of CAN communication; the smaller the value of the identification code portion, the higher the priority.
Preferably, the identification code part comprises a command level, a source device address, a target device address, a command type and a frame code;
the command level is Bit28-25 of the identification code part, which represents the communication priority;
the source equipment address is Bit24-17 of the identification code part and represents the source equipment address of the sending command;
the target device address is Bit16-9 of the identification code part and represents the address of the target device for receiving the command;
the command type is Bit8-6 of the identification code part and represents the command type of the command of the frame;
the frame order is encoded as Bit5-0 of the identification code part, indicating the order encoding of the present frame command.
Preferably, the lowest 16 addresses in the source device addresses are reserved for being used as broadcast frames, or used as debugging device addresses, and not used as common device addresses;
the lowest 16 addresses in the target device addresses are reserved for being used as broadcast frames or used as debugging device addresses, and are not used as common device addresses.
Preferably, the data portion includes a destination register address, a source register address, and a data region;
the target register address is Byte0-1 of the data part, which represents the target register address of the target device to be operated by the command, and the master device writes the register position specified by the target register address or reads the content of the register position;
the source register address is Byte2-3 of the data part, which represents the source register address of the master device sending the command, and the response frame writes the content of the response command into the register position corresponding to the source register address of the master device;
the data area is Byte4-7, which is the data portion, and is the data content of the register operation.
In the CAN bus communication method provided by the invention, the frame sequence coding is regulated, the sequence of different command frames CAN be distinguished, the response relation of the command is determined by matching with the command type, and the sending and receiving ends CAN judge the historical relation of the message according to the identification code part, so as to judge the successful receiving and sending state of the bus, improve the execution efficiency of application software and improve the reliability of information interaction. In addition, the method provides a register access based data communication mechanism, and a target register address and a source register address are specified in a data part, thereby facilitating the realization of RDMA (remote direct data access) function.
Drawings
Fig. 1 is a flowchart of a CAN bus communication method provided by the present invention.
Detailed Description
The technical contents of the invention are described in detail below with reference to the accompanying drawings and specific embodiments.
The CAN bus communication method provided by the invention is realized based on a CAN2.0B communication frame, and the format of the CAN2.0B frame is shown in the following table 1.
Figure GDA0003031531380000041
TABLE 1CAN2.0B frame format of communication frame
Wherein, byte 1 is frame information, including 8 bits.
Bit7 is FF, representing the frame format (FF 0 in the standard frame and FF 1 in the extended frame), in the embodiment provided by the present invention, the extended frame FF is 1;
bit6 is RTR: indicates the type of frame (RTR ═ 0 indicates a data frame, and RTR ═ 1 indicates a remote frame), where both frames are used;
bit3-0 is DLC, representing the actual data length when a data frame is sent.
Bytes 2-5 are message identification codes. The message identification code ID has 4 bytes, wherein the high 29 bits are effective, in the actual use, the message filtering function is realized by a receiving filter (ACR) and a shielding filter (AMR) (or both ACR filters), only the message conforming to the filter can be stored in the corresponding receiving buffer queue, otherwise, the message is ignored.
Bytes 6-13 are actual data of the data frame, and are invalid when the remote frame is used;
x in the frame format is an invalid bit.
The CAN bus communication method provided by the invention plans the division and the specific function definition of each field in the 29-bit message identification code, specifies the function definition of each byte in the data area, and specifies the specific access mechanism of the data area based on the register access. The execution efficiency and the bus utilization rate of software in the communication process are improved, and the difficulty of application software development is reduced.
In the embodiment provided by the present invention, a CAN bus communication protocol message format based on CAN2.0b is adopted, as shown in table 2 below.
Figure GDA0003031531380000051
TABLE 2 CAN BUS COMMUNICATION PROTOCOL MESSAGE FORMAT BASED ON CAN2.0B
The following describes the planned message format in detail with reference to table 2.
Identification code ID: the ID code represents the arbitration priority of the CAN communication, with smaller numbers being higher priority. The division and specific function definition of each field in the 29-bit message identification code (identification code) are planned.
Wherein, Bit28-25 is LEVEL.
The command level includes 16 levels 0-15, with 0 representing the highest level of instructions and 15 representing the lowest level of instructions.
Bit24-17 is DVSA source device address.
The source device address indicates the source device address of the sending command, and contains 256 device addresses 0-255 at most, wherein the lowest 16 addresses 0-15 are reserved for the use of broadcast frames or as debugging device addresses and not used as common device addresses.
Bit16-9 is the DVTA target device address.
The target device address indicates the target device address of the received command, and contains 256 device addresses 0-255 at most, wherein the lowest 16 addresses 0-15 are reserved for the use of broadcast frames or as debugging device addresses and not used as common device addresses.
Bit8-6 is TYPE command TYPE.
The command type indicates the command type of the present frame command, and 8 command types 0 to 7 are provided at the maximum.
Bit5-0 is FID frame coding.
The frame coding means that the order coding of the frame command is circularly used from 0 to 63, the device initiating the communication performs coding, and the frame coding of the response frame of the response device is the same as the received frame coding.
A functional definition of the bytes of the DATA area DATA is specified.
Byte0-1 is the RegTA, target register address.
The target register address represents the target register address of the target device to be operated by the command, the address is 16 bits and takes a value of 0-65535, and the register position can be written or the content of the register position can be read.
Byte2-3 is the RegSA, source register address.
The address of the source register is the address of the source register of the source equipment sending the command, the address is 16bit and takes the value of 0-65535, the register is the register position reserved for the response frame command by the source equipment, and the response frame writes the content of the response command into the register.
Byte4-7 is Data: and a data area.
The specific data content of the register operation is a fixed 32-bit length, and according to the specific definition of practical application, when the length of the register operation is less than 32 bits in practical application, the register operation needs to be completed by 32 bits.
According to the CAN bus communication protocol based on CAN2.0b, the CAN bus communication method based on CAN2.0b provided by the present invention will be explained with reference to a specific flowchart.
The CAN bus communication method provided by the invention comprises the following steps: the master device sends a communication frame with a frame sequence code to the slave device based on a CAN bus communication protocol; the slave equipment receives the communication frame, operates to the register position specified by the target register address of the specified master equipment according to the command type of the communication frame, and returns a response frame with the same frame sequence code to the master equipment; the master device stores the received response frame in the register position designated by the destination register address of the slave device, and one-time communication is finished. This process is explained in detail below.
CAN bus communication protocol based on CAN2.0b includes an identification code portion and a data portion. Wherein the identification code portion includes a command level, a source device address, a destination device address, a command type, and a frame encoding. The identification code part represents the arbitration priority of the CAN communication, and the smaller the numerical value, the higher the priority. The command level is Bit28-25 of the identification code part, specified as the communication priority, providing 16 priorities of 0-15, representing the instruction level. The source device address is Bit24-17 of the identification code part, which indicates the source device address of the sending command, and contains 256 device addresses 0-255 at most, wherein the lowest 16 addresses 0-15 are reserved for the use of broadcast frames or as debug device addresses and are not used as common device addresses. The target device address is Bit16-9 of the identification code part, which indicates the target device address of the received command, and contains 256 device addresses 0-255 at most, wherein the lowest 16 addresses 0-15 are reserved for use as broadcast frames or as debug device addresses and not as common device addresses. The command type is Bit8-6 of the identification code part, indicating the command type of the command of the present frame. The frame code is Bit5-0 of the identification code part, which represents the order code of the frame command, and is used from 0 to 63 in a circulating way, and is coded by the master device initiating the communication, and the frame code of the response frame of the responding slave device is the same as the received frame code. The response relation of each frame command can be determined by command type and frame order coding.
In the CAN bus communication protocol, the identification code ID represents the priority of occupying the bus, and the smaller the ID code, the higher the priority. The highest few bits in the ID code are instruction level, and the command level in burst mode is higher in applications than in master-slave mode (mainly including read, write and broadcast modes). Down again is the address of the source device that sent the command, and then the address of the target device that received the command, which means that the bus is occupied more preferentially by master-initiated communications on the bus. The end of the ID code is the frame type and frame order encoding, with the priority determined by these two fields being the lowest.
The DATA part specifies a functional definition of the bytes of the DATA part DATA, including the destination register address, the source register address and the DATA area. The target register address is Byte0-1 of the data part, which indicates the target register address of the target device to which the command is directed, and the register location can be written or the content of the register location can be read. The source register address is Byte2-3 of the data portion, indicating the source register address of the source device that sent the command, which is the register location reserved by the source device for the response frame command, to which the response frame writes the response command content. The data area is the Byte4-7 of the data portion, which is the specific data content for the register operation, fixed 32bit length. The CAN bus communication protocol is a register-based communication mechanism. Each device defines a plurality of 32-bit registers, the communication protocol command transmits communication information through a read-write register, the address of a target register in a data area is the register address of a slave device to be accessed by the device initiating the command, and the source address is the register address of the device receiving the response of the device initiating the command.
In the embodiment provided by the invention, the communication instructions are master-slave instructions, that is, the master device initiates the communication frame and the slave device returns the response frame, and one-time communication is completed. The response relation of the communication frame is determined by a frame TYPE (command TYPE) TYPE and a frame sequence code FID, and the master device sends the communication frame with the frame sequence code to the slave device through a CAN bus communication protocol; the slave equipment receives the communication frame, operates to the register position specified by the target register address of the master equipment according to the command type of the communication frame, and returns a response frame with the same frame sequence code to the master equipment; the master device stores the received response frame in the register position designated by the destination register address of the slave device, and one-time communication is finished. The FID of the response frame is the same as the FID of the received communication frame, so that the device initiating the communication can determine whether a specific frame command has been responded to by the frame TYPE and the frame order encoding FID. The process of re-verification can be reduced, the complexity of communication is reduced, and the efficiency of communication is improved.
In the embodiments provided herein, the command types of the communication frame include a write instruction and a read instruction. When the command type of the communication frame is a write command, register write and register write response are realized, and the communication process comprises the following steps:
the master device sends a communication frame with a frame sequence code to the slave device based on the CAN bus communication protocol, namely a register writing instruction is initiated by the master device.
The slave equipment receives the communication frame, acquires the command type of the communication frame as a write command, and stores the data in the data area in the communication frame to the register position specified by the target register address of the master equipment; and returns a response frame with the same frame order encoding to the master device. That is, after receiving the instruction, the slave device stores the 32-bit data in the data area in the instruction to the register position specified by the target register address. And simultaneously, the slave device sends a register write response instruction (namely a response frame) to the master device, at this time, the target register address in the register write response instruction sent by the slave device is the source register address in the register write instruction of the master device, and the source register address in the register write response instruction sent by the slave device is the target register address in the register write instruction of the master device. The data area of the response instruction may not be concerned or may add some status information depending on the application.
The master device stores the received response frame in the register position designated by the destination register address of the slave device, and one-time communication is finished. That is, the master device receives the response frame to indicate that the register write instruction operation is successful.
When the command type of the communication frame is a read command, register read and register read response are realized, and the communication process comprises the following steps:
the master device sends a communication frame with a frame sequence code to the slave device based on the CAN bus communication protocol, namely a register reading instruction is initiated by the master device.
The slave equipment receives the communication frame, obtains the command type of the communication frame as a read command, obtains the target register address of the master equipment, obtains the data information of the register position specified by the target register address of the master equipment, and returns a response frame with the same frame sequence coding and data information to the master equipment. Namely, the slave device may not pay attention to the 32-bit data information in the data area after receiving the command. The slave device sends a register read response instruction to the master device, a register position corresponding to a target register address in the register read response instruction is a register position corresponding to a source register address of the master device in the register read instruction, a register position corresponding to a source register address of the slave device is a register position corresponding to a target register address of the master device in the register read instruction, and 32-bit data information is information of a register position specified by the target register address in the register read instruction.
The master device stores the received response frame in the register position designated by the destination register address of the slave device, and one-time communication is finished. That is, the master device receives the response frame, and stores the 32-bit data information into the register position specified by the target register address in the register reading response instruction, which indicates that the register reading instruction operation is successful.
Through the source register address and the target register address of the master device and the source register address and the target register address of the slave device, the RDMA function planned by the CAN bus communication protocol, namely the remote direct data access function, CAN be realized. The command initiator specifies the register position where the command receiving terminal stores the return data, and after receiving the return instruction of the command receiving terminal, the command initiator can directly store the return data according to the target register address in the return instruction, so that the RDMA function improves the execution efficiency of software, the bus utilization rate and reduces the difficulty of application software development.
In the embodiment provided by the invention, the CAN bus communication method further comprises a broadcast instruction and a burst instruction, and communication is carried out in a mode of broadcasting frames and burst communication frames. When an emergency occurs, for example, the slave device generates an error, an alarm or other abnormal states, the slave device may actively upload error state information or other emergency information to the master device, the master device reserves a register position for storing the burst instruction in advance for the slave device, and the master device stores 32-bit data information into a register position specified by a target register address after receiving the burst instruction. The priority of the burst information is higher than the priority of the master-slave command. That is, when a burst state occurs, a burst command is generated, the slave device generates a burst communication frame including the burst command, and transmits the burst communication frame to the master device in order of priority based on the priority of the identification code portion of the burst communication frame. And the master device stores the content of the data area of the burst communication frame into a register specified by the target register address of the slave device according to the target register address of the slave device.
In the embodiment provided by the invention, the CAN bus communication protocol supports broadcast frames, at least 2 or more receiving filters of the devices are required, wherein at least 1 receiving filter is used for the broadcast frame, the address of the target device of the broadcast frame is reserved to be 0-15 and is not used as a fixed device address, and the broadcast frame does not need to be responded by the slave device and CAN update the content of the designated register. The broadcast frame is initiated by the master device, that is, when the command type of the communication frame is the broadcast frame, the master device simultaneously sends the broadcast frame to all slave devices with the same broadcast address, and the slave devices store the received data information into the register position specified by the target register address of the broadcast frame, and the broadcast frame does not need to respond.
In the embodiment provided by the present invention, during the communication process, a heartbeat mechanism needs to be established. For a slave device which is not accessed by the master device for a long time in the bus, the master device needs to send a status reading command to enable the slave device to respond to determine that the slave device is operated online, and the method specifically includes the following steps:
the master device regularly acquires the time length of each slave device which is not accessed, and judges whether the time length is greater than an access time threshold value or not;
when the time length is larger than the access time threshold, the master device sends a communication frame with a frame sequence code to the slave device of which the non-access time length exceeds the access time threshold based on a CAN bus communication protocol;
the slave equipment receives the communication frame, obtains the command type of the communication frame as a sending state reading command, and returns a response frame with the same frame sequence code to the master equipment;
and the master device stores the received response frame to a register position specified by the destination register address of the slave device, and determines that the slave device works online.
In summary, according to the CAN bus communication method based on CAN2.0b provided by the present invention, the master device sends the communication frame with the frame sequence code to the slave device based on the CAN bus communication protocol; the slave equipment receives the communication frame, operates to the register position specified by the target register address of the specified master equipment according to the command type of the communication frame, and returns a response frame with the same frame sequence code to the master equipment; the master device stores the received response frame in the register position designated by the destination register address of the slave device, and one-time communication is finished. The frame sequence coding is regulated, the sequence of different command frames can be distinguished, the response relation of the command is determined by matching with the command type, and the sending and receiving ends can judge the historical relation of the message according to the identification code part for judging the successful receiving and sending state of the bus, so that the execution efficiency of application software is improved, and the reliability of information interaction is improved. In addition, the method provides a register access based data communication mechanism, and a target register address and a source register address are specified in a data part, thereby facilitating the realization of RDMA (remote direct data access) function.
The foregoing has provided a detailed description of the present invention. Any obvious modifications to the invention, which would occur to those skilled in the art, without departing from the true spirit of the invention, would constitute a violation of the patent rights of the invention and would carry a corresponding legal responsibility.

Claims (10)

1. A CAN bus communication method based on CAN2.0B is characterized by comprising the following steps:
the master device sends a communication frame with a command type and a frame sequence code to the slave device based on a CAN bus communication protocol; the command type is used for determining the response relation of the command, and the frame sequence coding is used for distinguishing the sequence of different command frames;
the slave equipment receives the communication frame, operates to the register position specified by the target register address of the master equipment according to the command type of the communication frame, and returns a response frame with frame sequence coding to the master equipment;
the master device stores the received response frame to a register position specified by a destination register address of the slave device; judging whether a certain frame command is responded or not according to the condition whether the command types and the frame sequence codes carried by the response frame and the communication frame are the same or not;
the communication frame and the response frame are CAN2.0B communication frames and are provided with message identification codes; and in the communication process, message filtering is realized through the receiving filter, only the message which is in accordance with the receiving filter is stored in the corresponding receiving cache queue, and otherwise, the message is ignored.
2. The CAN-bus communication method as set forth in claim 1, wherein when the command type of the communication frame is a write command, the communication process comprises the steps of:
the master device sends a communication frame with a frame sequence code to the slave device based on a CAN bus communication protocol;
the slave equipment receives the communication frame, acquires the command type of the communication frame as a write command, and stores the data in the data area in the communication frame to the register position specified by the target register address of the master equipment;
returning a response frame with frame order coding to the master device;
the master device stores the received response frame in the register location specified by the destination register address of the slave device.
3. The CAN-bus communication method as set forth in claim 1, wherein when the command type of the communication frame is a read command, the communication process comprises the steps of:
the method comprises the steps that a master device sends a read instruction communication frame with frame sequence codes to a slave device based on a CAN bus communication protocol;
the slave equipment receives the communication frame, obtains the command type of the communication frame as a read command, obtains the target register address of the master equipment, obtains the data information of the register position specified by the target register address of the master equipment, and returns a response frame with frame sequence coding and data information to the master equipment;
the master device stores the received response frame in the register location specified by the destination register address of the slave device.
4. The CAN bus communication method of claim 1, wherein:
when the burst state occurs, a burst instruction with priority higher than that of the master-slave command is generated, the slave equipment generates a burst communication frame containing the burst instruction, and the burst communication frame is sent to the master equipment according to the priority of the identification code part of the burst communication frame and the priority sequence; and the master device stores the content of the data area of the burst communication frame into a register position specified by the target register address of the slave device according to the target register address of the slave device.
5. The CAN bus communication method of claim 1, wherein:
when the command type of the communication frame is a broadcast frame, the master device simultaneously transmits the broadcast frame to all the slave devices with the same broadcast address, the slave devices store the received data information into the register position specified by the target register address of the broadcast frame, and the broadcast frame does not need to respond.
6. The CAN bus communication method of claim 1, wherein:
CAN bus communication protocol based on CAN2.0b includes an identification code portion and a data portion.
7. The CAN bus communication method of claim 6, wherein:
the identification code part represents the priority of CAN communication, and the smaller the value of the identification code part is, the higher the priority is.
8. The CAN bus communication method of claim 6, wherein:
the identification code part comprises a command grade, a source device address, a target device address, a command type and a frame sequence code;
the command level is Bit28-25 of the identification code part, which represents the communication priority;
the source equipment address is Bit24-17 of the identification code part and represents the source equipment address of the sending command;
the target equipment address is Bit16-9 of the identification code part and represents the target equipment address for receiving the command;
the command type is Bit8-6 of the identification code part and represents the command type of the command of the frame;
the frame order is encoded as Bit5-0 of the identification code part, indicating the order encoding of the present frame command.
9. The CAN bus communication method of claim 8, wherein:
the lowest 16 addresses in the source equipment addresses are reserved as broadcast frames or used as debugging equipment addresses, and are not used as common equipment addresses;
the lowest 16 addresses in the target device addresses are reserved for being used as broadcast frames or used as debugging device addresses, and are not used as common device addresses.
10. The CAN bus communication method of claim 6, wherein:
the data portion includes a target register address, a source register address, and a data region;
the target register address is Byte0-1 of the data part, which indicates the target register address of the target device to be operated by the command, and the slave device writes the register position specified by the target register address or reads the content of the register position;
the source register address is Byte2-3 of the data part, which represents the source register address of the master device sending the command, and the response frame writes the content of the response command into the register position corresponding to the source register address of the master device;
the data area is Byte4-7, which is the data portion, and is the data content of the register operation.
CN201711478076.5A 2017-12-29 2017-12-29 CAN bus communication method based on CAN2.0B Active CN108199941B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711478076.5A CN108199941B (en) 2017-12-29 2017-12-29 CAN bus communication method based on CAN2.0B

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711478076.5A CN108199941B (en) 2017-12-29 2017-12-29 CAN bus communication method based on CAN2.0B

Publications (2)

Publication Number Publication Date
CN108199941A CN108199941A (en) 2018-06-22
CN108199941B true CN108199941B (en) 2022-03-08

Family

ID=62586544

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711478076.5A Active CN108199941B (en) 2017-12-29 2017-12-29 CAN bus communication method based on CAN2.0B

Country Status (1)

Country Link
CN (1) CN108199941B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111416722B (en) * 2019-01-04 2023-05-30 郭洪威 Communication method and device
CN112602287B (en) * 2019-07-19 2022-02-11 华为技术有限公司 CAN communication method, equipment and system
CN111586548A (en) * 2020-05-09 2020-08-25 惠州市德赛西威汽车电子股份有限公司 Method and system for realizing coding of multiple automobile sound equipment based on CAN bus
CN112835823B (en) * 2021-01-25 2022-03-01 无锡众星微系统技术有限公司 Storage controller response sending method
CN114221903B (en) * 2021-11-30 2024-03-12 新华三技术有限公司合肥分公司 Data transmission method and device
CN115529205B (en) * 2022-09-02 2023-08-11 上海精泰技术有限公司 Communication interaction method between motor drivers and two-for-one twister system

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107025203A (en) * 2017-03-31 2017-08-08 新华三技术有限公司 First board, the second board and a kind of equipment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8650356B2 (en) * 2009-05-28 2014-02-11 Microchip Technology Incorporated Microcontroller with CAN module
CN101626333B (en) * 2009-08-07 2011-11-23 北京和利时电机技术有限公司 Controller area network (CAN) bus system and application layer communication method in same
CN102932224A (en) * 2012-11-23 2013-02-13 哈尔滨工业大学 CAN network-based data communication system and data communication method based on same
CN107231698B (en) * 2016-03-25 2020-04-07 展讯通信(上海)有限公司 Data transmission method, terminal and base station in wireless cellular network

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107025203A (en) * 2017-03-31 2017-08-08 新华三技术有限公司 First board, the second board and a kind of equipment

Also Published As

Publication number Publication date
CN108199941A (en) 2018-06-22

Similar Documents

Publication Publication Date Title
CN108199941B (en) CAN bus communication method based on CAN2.0B
JP7024047B2 (en) EtherCAT master-slave integrated bridge controller and control method
US4949299A (en) Industrial control communication network and method
US5072374A (en) Method for communicating among a plurality of programmable logic controllers each having a dma controller
US7051143B2 (en) Method, system and program for the transmission of modbus messages between networks
CN101799795B (en) 1553B bus monitor and bus system with same
RU2596582C2 (en) Method and device for memory size adapted serial data transfer
RU2595962C2 (en) Method and device for adaptation of reliability of data transmission in serial bus system
CN103714029B (en) Novel two-line synchronous communication protocol and application
CN104995874B (en) Data Transport Protocol with protocol anomaly state
KR20120006485A (en) Method for concatenating can data payloads
JPH04245746A (en) Intelligent communication network interface circuit
CN111585697B (en) Communication method, device and multi-module communication system
CN103685578A (en) Data transmission method for master equipment and slave equipment
CN103558812A (en) MVB class 4 device network card based on FPGA and ARM
CN113051204A (en) Serial backplane bus communication method and system
CN101452427A (en) DMA data-transmission system and method, and central processing unit
CN107018151B (en) CAN-LonWorks protocol conversion method of programmable conversion logic
CN113688076A (en) EPA-based data communication method, computing device and medium
JP2003198572A (en) Deterministic field bas and process for management of such a bus
CN116743684A (en) PCIe switch with multiple non-transparent bridge ports and communication method thereof
CN113341853B (en) IP core, FPGA chip, alternating current servo driver and communication method
CN115422099A (en) Communication information sending method and device, electronic equipment and storage medium
CN114077562A (en) Protocol processing IP core of 1553B bus controller
US7443886B1 (en) Communication protocol system and method

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