WO2016131404A1 - New type can frame based communication method, device and system - Google Patents

New type can frame based communication method, device and system Download PDF

Info

Publication number
WO2016131404A1
WO2016131404A1 PCT/CN2016/073765 CN2016073765W WO2016131404A1 WO 2016131404 A1 WO2016131404 A1 WO 2016131404A1 CN 2016073765 W CN2016073765 W CN 2016073765W WO 2016131404 A1 WO2016131404 A1 WO 2016131404A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
bus
frame
bus mode
preset
Prior art date
Application number
PCT/CN2016/073765
Other languages
French (fr)
Chinese (zh)
Inventor
王海峰
方庆银
王伶俐
邝育军
Original Assignee
华为技术有限公司
复旦大学
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 华为技术有限公司, 复旦大学 filed Critical 华为技术有限公司
Publication of WO2016131404A1 publication Critical patent/WO2016131404A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • 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/403Bus networks with centralised control, e.g. polling

Definitions

  • Embodiments of the present invention relate to communication technologies, and in particular, to a data communication method, apparatus, and system in a bus.
  • Controller Area Network is a standardized serial communication bus protocol with a maximum physical layer (PHY) rate of 1 Mbps/s.
  • PHY physical layer
  • CAN-FD Flexible Data Rate
  • CAN-FD node works with the existing CAN 2.0 node
  • the CAN 2.0 node will have a data padding error and a Cyclic Redundancy Check (CRC) when processing the data of the CAN-FD node.
  • CRC Cyclic Redundancy Check
  • the error is detected, causing the CAN 2.0 node to interrupt the current CAN communication. Therefore, CAN-FD cannot be compatible with the existing CAN bus mode.
  • the embodiment of the invention provides a data communication method, device and system in a bus, so as to realize that the node of the first bus mode is compatible with the existing bus mode while improving the rate of the PHY, and the data occurs when the two bus modes coexist.
  • an embodiment of the present invention provides a data communication method in a bus, where the method is applicable to a controller area network CAN including at least one node of a first bus mode and at least one node of a second bus mode, Methods include:
  • the frame format of the preset bus frame includes a first frame format and a second frame format, where the first frame format corresponds to the first bus mode,
  • the second frame format corresponds to the second bus mode
  • the preset bus frame includes an identity identifier, and the identifier has a preset number of bits for identifying the frame format;
  • the node communicates with a frame format corresponding to the determined bus mode of the data communication.
  • the node is a master node
  • the node determines a bus manner of data communication according to a preset bus frame, including:
  • the node communicates with a frame format corresponding to the bus mode of the data communication, including:
  • the node communicates with a frame format corresponding to the bus mode of the data communication at a time when the preset polling time has not arrived.
  • the node is a node in the first bus mode
  • the node polls all other nodes by using the preset bus frame in the first frame format at a time when the preset polling time arrives;
  • the node polls other nodes except the node determined to be the first bus mode by using the preset bus frame in the second frame format at a time when the preset polling time arrives. ;
  • the node is configured to communicate with the data at a time when the preset polling time is not reached. Communication in the frame format corresponding to the bus mode, including:
  • the node communicates with the node of the first bus mode by using the first frame format by the first frame format at a time when the preset polling time has not arrived; and/or,
  • the node communicates with the node of the second bus mode in the second bus mode by using the second frame format at a time when the preset polling time has not arrived.
  • the node is a node of the second bus mode
  • the node polls all other nodes by using the preset bus frame in the second frame format at a time when the preset polling time arrives;
  • the node is configured to communicate with the data at a time when the preset polling time is not reached. Communication in the frame format corresponding to the bus mode, including:
  • the node communicates with the node of the second bus mode in the second bus mode by using the second frame format at a time when the preset polling time has not arrived.
  • the determining, by the node, the bus mode of the data communication according to the preset bus frame ,Also includes:
  • the node starts a polling task and periodically determines whether the preset polling time has arrived.
  • the node is a slave node
  • the node determines a bus manner of data communication according to a preset bus frame, including:
  • the node actively initiates a handshake communication to the primary node, and determines a bus manner of the data communication according to the preset bus frame.
  • the node is a node of the first bus mode
  • the node actively initiates a handshake communication to the master node, and determines a bus manner of the data communication according to the preset bus frame, including:
  • the node determines that the master node is a node of the first bus mode, and communicates with the master node by using the first bus mode.
  • the node is a node of the first bus mode
  • the node actively initiates a handshake communication to the master node, and determines a bus manner of the data communication according to the preset bus frame, including:
  • the node After the preset timeout has not received the fourth information response sent by the primary node, the node determines that the primary node is a node in the second bus mode, and sends the node to the primary node. Transmitting the preset bus frame of the second frame format;
  • the node determines to communicate with the master node by using the second bus mode.
  • the node is a node of the second bus mode
  • the node actively initiates a handshake communication to the master node, and determines a bus manner of the data communication according to the preset bus frame, including:
  • the node determines to communicate with the master node by using the second bus mode.
  • an embodiment of the present invention provides a controller area network (CAN) CAN node, that is, a CAN device that performs communication based on a new CAN frame, where the CAN includes at least one node of the first bus mode and at least one node of the second bus mode.
  • the node includes:
  • a determining module configured to determine a bus manner of data communication according to a preset bus frame, where a frame format of the preset bus frame includes a first frame format and a second frame format, and the first frame format and the first bus mode Correspondingly, the second frame format is corresponding to the second bus mode, and the preset bus frame includes an identity identifier, where the preset identifier has a plurality of bits for identifying the frame format;
  • a communication module configured to communicate by using a frame format corresponding to the determined bus mode of the data communication.
  • the node is a master node
  • the determining module is specifically configured to determine, according to the preset bus frame, a bus manner of the data communication, when a preset polling time arrives;
  • the communication module is specifically configured to perform communication by using a frame format corresponding to the bus mode of the data communication when the preset polling time has not arrived.
  • the node is a node of the first bus mode
  • the determining module is configured to: when the preset polling time arrives, use the preset bus frame in the first frame format to poll all other nodes; receive the first information response, The first information response is the first frame format; the identity identifier of the node that sends the first information response is obtained according to the first information response, and the node that sends the first information response is determined as The node of the first bus mode determines that the first bus mode is used to communicate with the node of the first bus mode; when the preset polling time arrives, the second frame format is adopted.
  • the preset bus frame polls other nodes except the node determined to be the first bus mode; receiving a second information response, the second information response being the second frame format;
  • the second information response acquires the identity identifier of the node that sends the second information response, and determines the node that sends the second information response as the node of the second bus mode, and determines to adopt the And second bus node of the second embodiment mode communication bus.
  • the communication module is specifically configured to: when the preset polling time is not reached, pass the The first frame format communicates with the node of the first bus mode in the first bus manner; and/or, at a time when the preset polling time has not arrived, by the second frame format The second bus mode communicates with the nodes of the second bus mode.
  • the node is a node of the second bus mode
  • the determining module is configured to: when the preset polling time arrives, use the preset bus frame in the second frame format to poll all other nodes; receive a third information response, The third information response is the second frame format; the identity identifier of the node that sends the third information response is obtained according to the third information response, and the node that sends the third information response is determined as The node of the second bus mode determines to communicate with the node of the second bus mode by using the second bus mode.
  • the communication module is specifically configured to: when the preset polling time is not reached, The second frame format communicates with the nodes of the second bus mode in the second bus mode.
  • the method further includes:
  • the determining module is configured to start a polling task, and periodically determine whether the preset polling time arrives.
  • the node is a slave node
  • the determining module is specifically configured to initiate a handshake communication to the primary node, and determine a bus manner of the data communication according to the preset bus frame.
  • the node is a node of the first bus mode
  • the determining module is configured to send the preset bus frame in the first frame format to the primary node, receive a fourth information response sent by the primary node, and the fourth information response is the a first frame format; determining that the master node is a node of the first bus mode, and communicating with the master node by using the first bus mode.
  • the node is a node of the first bus mode
  • the determining module is specifically configured to send the preset bus frame in the first frame format to the primary node; after receiving the preset timeout, the fourth information response sent by the primary node is not received yet, And the node determines that the primary node is the node of the second bus mode, and sends the preset bus frame in the second frame format to the primary node; and receives the fifth information sent by the primary node. Responding, and the fifth information response is in the second frame format; determining to communicate with the master node by using the second bus mode.
  • the node is a node of the second bus mode
  • the determining module is specifically configured to send the preset bus frame in the second frame format to the primary node, receive a sixth information response sent by the primary node, and the sixth information response is the In the second frame format, the master node includes the node of the first bus mode and the node of the second bus mode; determining to communicate with the master node by using the second bus mode.
  • an embodiment of the present invention provides a controller area network (CAN) system, including: at least one node of a first bus mode and at least one node of a second bus mode, wherein the first bus mode
  • the node adopts the second aspect, the first to third of the second aspect, and the sixth to the ninth possible
  • the data communication method, device and system in the bus of the embodiment of the invention enable the node in the CAN to determine the bus mode for communication by presetting the bus frame, so that the node of the first bus mode is compatible with the existing bus while increasing the transmission rate. In the way, when the two bus modes coexist, data filling error and CRC check error will occur, which causes the CAN2.0 node to interrupt the current CAN communication problem.
  • FIG. 1 is a schematic structural view of an embodiment of a CAN system according to the present invention.
  • 1A is a schematic diagram of a bus frame format in an embodiment of the present invention.
  • FIG. 2 is a flow chart of an embodiment of a data communication method in a bus according to the present invention.
  • FIG. 3 is a flow chart of another embodiment of a data communication method in a bus of the present invention.
  • FIG. 4 is a flow chart of still another embodiment of a data communication method in a bus according to the present invention.
  • FIG. 5 is a flow chart of a fourth embodiment of a data communication method in a bus according to the present invention.
  • FIG. 6 is a flowchart of a fifth embodiment of a data communication method in a bus according to the present invention.
  • FIG. 7 is a flow chart of a sixth embodiment of a data communication method in a bus according to the present invention.
  • FIG. 8 is a schematic structural diagram of an embodiment of a CAN node according to the present invention.
  • FIG. 9 is a schematic structural diagram of another embodiment of a CAN node according to the present invention.
  • FIG. 10 is a schematic structural view of another embodiment of a CAN system according to the present invention.
  • FIG. 11 is a schematic structural diagram of an embodiment of a node in a first bus mode according to the present invention.
  • FIG. 12 is a schematic structural diagram of another embodiment of a node in a first bus mode according to the present invention.
  • CAN 2.0 includes two technical specifications, namely CAN 2.0A and CAN 2.0B, in which CAN 2.0A provides a standard format using an 11-bit ID; CAN 2.0B is extended on a standard format using a 29-bit ID. Since the two have some small differences in the format definition, the rest of the processing is basically the same. Therefore, for convenience of description, the following embodiments of the present invention do not strictly distinguish between CAN 2.0A and CAN 2.0B, and uniformly use CAN 2.0. Be explained. For some specific examples, the default is to use CAN 2.0B as an example, and those skilled in the art can implement CAN 2.0A without any creative work.
  • Embodiments of the present invention disclose a method for communication based on a novel CAN frame, which is applied to a CAN network as shown in FIG. 1, the CAN network including one or more conventional CAN 2.0 nodes (eg, node 3, node 4) And one or more new CAN (CAN-HW) nodes provided by this embodiment, such as node 1, node 2). Each node is connected by a printed circuit board PCB trace or cable to implement bus communication.
  • the CAN differential line matching resistors shown in the figure are set in the same manner as in the prior art, and are not described here.
  • the communication in the CAN network is performed based on the CAN frame.
  • the new CAN-HW node can use the new CAN frame to communicate with other CAN-HW nodes faster than the existing CAN 2.0 rate, and at the same time, It can avoid the various errors produced by CAN-FD mentioned in the background technology when working with CAN 2.0 nodes, and achieve compatibility with existing CAN2.0 implementation.
  • a method for performing communication based on a novel CAN frame includes the following steps:
  • the new CAN frame is generated based on the frame format of the CAN 2.0 frame.
  • "based on” refers to the content of the modification (such as the definition of some fields) described in the following embodiments, and the rest can be performed by referring to the frame format defined by the existing CAN 2.0 protocol.
  • FIG. 1A a schematic diagram of a format of a CAN 2.0 frame and a novel CAN frame (CAN-HW) frame according to the present embodiment.
  • the new CAN frame includes a new data domain and a new check domain (ie, the CRC field in the figure), and the new data domain and the new check domain are respectively modified by modifying the data domain and the check domain based on the CAN 2.0 frame. get.
  • the new data domain includes a user data subdomain and a fixed data subdomain, where:
  • the user data subdomain functions as the data field in the existing CAN 2.0, and is used to transmit real user data, but in this embodiment, the number of bits of the user data subfield is larger than the data field in the CAN 2.0 frame.
  • the number of bits; in another embodiment, the number of bits of the user data subfield may be approximately equal to an integer multiple of the number of existing CAN 2.0 maximum data bits. For example, suppose the existing CAN 2.0 frame supports a maximum of 8 bytes of 64-bit data, then the user data sub-field can be 128 bits (16 bytes), or 512 bits (64 bytes), or 1024 bits (128). Bytes) and so on.
  • “about equal” means that the actual is not required to be strictly equal, and may be slightly less than the integer multiple, and a small portion is used for the fixed data subdomain or other subdomains that need to be expanded.
  • the fixed data subfield includes a plurality of first fixed bit groups, each of the first fixed bit groups includes one or more consecutive first fixed bits (0 or 1) having the same value, and the plurality of first fixed bit groups are one by one Set the sampled position when multiple CAN 2.0 data fields can be sampled by a CAN 2.0 device based on the CAN 2.0 protocol (such as node 3, node 4 in Figure 1); preferably, the number of first fixed bit groups is the same as CAN The number of bits of the data bit data to be sampled by the 2.0 device is the same. For example, assuming that the data field in the CAN 2.0 frame has 64 bits of data, then in the new CAN frame, 64 sets of the first fixed bit group are set accordingly.
  • the "CAN 2.0 device based on the CAN 2.0 protocol” refers to various devices capable of processing the CAN 2.0 protocol, such as node 3 and node 4 in FIG. 1, and these CAN 2.0 devices do not recognize the new CAN.
  • each first fixed bit group is set one by one at a position where a plurality of CAN 2.0 devices sample the CAN 2.0 data field, that is, each first fixed bit group corresponds to a sampling time of one CAN 2.0 device, when After the CAN 2.0 device receives the new CAN frame, if it is sampled according to the way defined by the CAN 2.0 device, then the sampled is the value of each first fixed bit group (defined as the value of any bit in the group, due to the first
  • the fixed bit group includes the same value of one or more first fixed bits, and therefore, the value of this first fixed bit group can be represented by "a value of any one bit".
  • CAN 2.0 devices can be configured to be sampled at a specific frequency during sampling, and at which relative time to sample.
  • a CAN 2.0 device can be configured to transmit and sample at a frequency of 1 MHz, and the sampling time is at 2/3 of the signal waveform corresponding to this data bit, in which case, in the network,
  • the data field in the CAN 2.0 frame is 64 bits, and the number of bits in the new data field is expanded by 8 times, which is equivalent to each number in the original CAN 2.0 frame.
  • the data is split into 8 copies in the same time.
  • 1us transmits a data in the CAN 2.0 device.
  • the new CAN device needs to transmit 8 data for 1us. Since it is sampled at 2/3, after calculation, 2/3 of 1us is equal to 0.667us, which corresponds to the 6th bit, then a fixed bit can be set in the 6th bit (set to a fixed value of 0 as shown in Figure 1A). .
  • each data bit in the original CAN 2.0 frame is split more in the same time (for example, split into 32 In this case, in order to prevent the CAN 2.0 device clock from being inaccurate enough to accurately sample at 2/3, you can add some more bits around 2/3, so that even if CAN 2.0 samples early, or late The value of the fixed bit can be sampled at a time.
  • this embodiment also performs similar modifications to the check field (or also referred to as the CRC field) in the CAN 2.0 frame.
  • the new check field number in the modified CAN frame is larger than the number of check fields in the CAN 2.0 frame.
  • the new check field includes a user data check subfield and a fixed data check subfield, wherein the user data is corrected.
  • the value of the test field is the first check value after verifying the user data sub-domain; the fixed data check sub-domain is the second check value obtained by verifying the value of each first fixed bit group, fixed
  • the data check subfield includes a plurality of second fixed bit groups, each second fixed bit group includes one or more consecutive second fixed bits of the same value, and the value of each second fixed bit group (ie, any one of the groups)
  • the fixed bit value constitutes the second check value;
  • the plurality of second fixed bit groups are one-to-one set at a position that can be sampled by the CAN 2.0 device when the CAN 2.0 check field is sampled, and the specific setting method and the new data field are set.
  • the setting method of the first fixed bit group is similar, and will not be described here.
  • the number of bits is increased, and in order to realize high-speed transmission, the extended fields are transmitted at a higher frequency. For example, if you expand to 8 times, you can also increase the frequency to 8 times. If you expand to 16 times, the frequency can be increased to 16 times. Of course, in practice, it is not necessary to accurately increase to 8 or 16 times, as long as the extended data bits can be transmitted, other transmission frequencies are also possible.
  • the new CAN 2.0 device is equivalent to two registers to control the transmission rate, one register for controlling the number of bits to be expanded, the frequency of transmission and reception of the domain to be transmitted and received, and the other register to the existing CAN 2.0. Like the rate control register, it is used to control the transceiving rate of the unmodified domain.
  • the new CAN frame is sent to the CAN network, other new CAN devices can correctly receive the frame because they can recognize the frame, and since the number of bits of the data field of the CAN 2.0 frame has been expanded at the time of transmission, and The frequency is transmitted, thus increasing the transmission rate.
  • the existing CAN 2.0 device can receive the frame. The sample is still sampled in the original sampling mode. Since this embodiment has fixed values in the CAN 2.0 sample data field and the check field position, the CAN 2.0 samples the value of the fixed data subfield and performs check calculation. After that, its value must be consistent with the second check value indicated by the sampled fixed data check subfield, so that no check error will occur, thus achieving compatibility with CAN 2.0 devices.
  • the present embodiment further describes the solution.
  • the new CAN frame may further include: a type indicating subfield for indicating a CAN frame type. Used to indicate that it is a CAN 2.0 frame, or a new frame.
  • the type indicator subdomain can be implemented by reserved bits in the arbitration domain, for example, using reserved two bits, 00 for CAN 2.0 frames, and 11 for new frames, of course, in this case, CAN 2.0 software also needs these The reserved bits are judged to determine which frame format is received.
  • the type indicator subfield may also be implemented by at least one of two bits R1, R0 in the control domain in the CAN 2.0 frame, with at least one of the two bits being the subtype of the type indication.
  • the new CAN frame may further include: a bit indication information subfield for indicating the number of bits of the user data subfield in the new data domain.
  • the number of bits indicates that the information sub-domain can be implemented by extending the data bits in the control domain in CAN2.0.
  • the principle is similar to that of extending the data field. Since it is extended, it is necessary to upgrade this part later. Transceiver rate. In addition, if it is identified by a reserved bit table in other domains, there is no need to increase the transmission and reception rate of the domain.
  • the new data field in the new CAN frame corresponds to the edge change between the two bits in the data field of the CAN 2.0 device.
  • the new CAN frame extends the data field of the CAN 2.0 frame by a factor of eight, assuming that the first 8 bits of the CAN 2.0 frame data field are extended to A1-A8, and the second bit of the CAN 2.0 frame data field is expanded by 8 Bits B1-B8, you can set the transition edge between the two bits A8 and B1, then the corresponding two, also need to be set to a fixed value.
  • Setting the hard resynchronization can check the frequency to prevent sampling errors caused by the frequency deviation being accumulated.
  • the first bus mode is a newly designed bus mode, which may be referred to as CAN-HW
  • the second bus mode is an existing bus mode, that is, CAN 2.0, first.
  • the frame format of the bus mode is compatible with the frame format of the second bus mode, that is, the frame format of the former is the same as the frame format of the latter, and the difference is that the content filled in the frame format is different, so the node of the second bus mode can receive
  • the two bus mode frames are parsed and the frame is identified by the bit type of the bus type identifying the node, and the node of the first bus mode can also receive the frames of the two bus modes, and the communication is determined according to the bus type corresponding to the frame.
  • the way of the bus The first bus mode node can adopt two bus modes at the same time, and is compatible with the existing bus protocol while improving the transmission rate, thereby realizing data communication of the two bus mode hybrid networks.
  • FIG. 2 is a flowchart of an embodiment of a data communication method in a bus of the present invention. As shown in FIG. 2, the method in this embodiment is applicable to the application scenario shown in FIG. 1, and the method may include:
  • Step 101 The node determines a bus manner of data communication according to the preset bus frame.
  • the frame format of the preset bus frame includes a first frame format and a second frame format, where the first frame format corresponds to the first bus mode, and the second frame format and the first frame format Corresponding to the two-bus mode, the preset bus frame includes an identity identifier, and the identifier has a preset number of bits for identifying the frame format.
  • the execution subject node may be any one of the nodes in FIG.
  • the first frame format of the present invention is designed: the arbitration field, the Acknowledgement (ACK) field and the frame end bit in the first frame format are compatible with the corresponding fields of the second frame format (CAN 2.0 format);
  • the reserved bits of the control domain and the arbitration domain in the format enable the nodes of the first bus mode to automatically recognize the bus type function and perform frame format switching; design the data domain and the CRC domain in the first frame format, and the PHY can be
  • the rate is increased by N times (N can be 1, 2, 3...); when designing the data field and the CRC field, the second frame format is fixed bit-filled to ensure that the second bus mode is not caused.
  • the node incorrectly generates a bit error and a CRC check error, thereby causing a communication interruption.
  • the preset bus frame has two formats, which respectively correspond to the above two bus modes, and the corresponding bus mode can be determined by presetting the bus frame node.
  • Step 102 The node performs communication by using a frame format corresponding to the determined bus mode of the data communication.
  • the bus mode can be adopted, and the frame format corresponding to the bus mode is used to communicate with other nodes, that is, if the node is a node of the first bus mode, the node can adopt the first bus mode. Sending a preset bus frame of the first frame format to the nodes of the other first bus mode, and sending the preset bus frame of the second frame format to the nodes of the other second bus mode by using the second bus mode; if the node is the first Two-bus mode Node, the node can only send the preset bus frame of the second frame format to other nodes by using the second bus mode. Since the nodes of the first bus mode can communicate in two bus modes, other nodes here may include the A bus mode node and a second bus mode node.
  • the node in the CAN determines the bus mode for communication, and the node of the first bus mode is compatible with the existing bus mode while improving the rate of the PHY, and solves the problem that the two bus modes coexist.
  • a data fill error and a CRC check error occurred, causing the CAN 2.0 node to interrupt the current CAN communication problem.
  • the node in the foregoing embodiment is a master node
  • the specific implementation method of step 101 may be: the node determines the bus of the data communication according to the preset bus frame at a time when the preset polling time arrives.
  • the specific implementation method of step 102 may be: the node communicates with a frame format corresponding to the bus mode of the data communication when the preset polling time has not arrived.
  • the above process may have two implementation processes depending on the node. The details are explained below.
  • the node is a node of the first bus mode, and the node adopts the preset bus frame pair of the first frame format at a time when the preset polling time arrives. All other nodes perform polling; the node receives a first information response, the first information response is in the first frame format; and the node acquires a node that sends the first information response according to the first information response Determining, by the node that sends the first information response, the node in the first bus mode, and determining to communicate with the node in the first bus mode by using the first bus mode; The node polls other nodes except the node determined to be the first bus mode by using the preset bus frame in the second frame format at a time when the preset polling time arrives.
  • the node receives the second information response, the second information response is the second frame format, and the node obtains the identity identifier of the node that sends the second information response according to the second information response.
  • the second node transmitting the response information is determined as a node of the second embodiment of the bus, the second bus mode is determined using the second bus node communication mode.
  • the node communicates with the node of the first bus mode by using the first frame format by the first frame format at a time when the preset polling time does not arrive; and/or, the node is When the preset polling time has not arrived, the second bus format communicates with the node of the second bus mode by using the second bus mode.
  • FIG. 3 is a flowchart of another embodiment of the data communication method in the bus of the present invention. As shown in FIG. 3, the method in this embodiment is applicable to the application scenario shown in FIG. 1, and the node 1 in the first bus mode is used as the main Node, the method can include:
  • node 1 starts a polling task, and periodically determines whether the preset polling time arrives;
  • Node 1 When the node of the first bus mode acts as the master node, the token is used to communicate with other nodes in the CAN.
  • Node 1 initiates the timed polling addressing function through the application layer software.
  • the startup mode can be power-on startup or timer timing.
  • Node 1 polls all addresses in the CAN at the time when the polling time arrives. All addresses correspond to All nodes in CAN.
  • Node 1 polls node 2 (3, 4) by using a preset bus frame in a first frame format at a time when the preset polling time arrives;
  • the node 1 first polls all the nodes in the first frame format.
  • the preset bus frame in the first frame format is sent to the node 2 (3, 4).
  • Node 2 sends a first information response to node 1 in a first frame format.
  • the node 2 can simultaneously receive and parse the first frame format and the second frame format, and determine the received first frame format according to the bus type bit in the preset bus frame, so the node 2 automatically sets the first frame format to the node. 1 Send the first message response.
  • node 3 (4) does not respond to the preset bus frame of the first frame format sent by the node 1;
  • the node 3 (4) After receiving the preset bus frame of the first frame structure, the node 3 (4) passes the ID filtering function, and does not process the preset bus frame of the first frame structure from the node 1, and may directly discard the frame, and the preset is not The bus frame is answered.
  • the node 1 obtains the ID of the node 2 that sends the first information response according to the first information response, and determines the node 2 as the node of the first bus mode, and determines to communicate with the node 2 by using the first bus mode;
  • the application software on the node 1 extracts the first information response in the CAN, and obtains the ID of the node 2 that sends the first information response.
  • the node 1 can classify all the nodes that send the first information response into the first bus mode by means of table construction.
  • Node, table A, in this embodiment is node 2, node 1 refreshes the newly inserted or deleted node in CAN by the change of table A.
  • Node 1 polls node 3 (4) by using a preset bus frame in a second frame format at a time when the preset polling time arrives;
  • the node 1 then uses the second frame format to poll the node except the node in the table A.
  • the preset bus frame in the second frame format is sent to the node 3 (4).
  • node 3 (4) sends a second information response to node 1 in a second frame format
  • Node 3 (4) can parse the preset bus frame of the second frame format, so node 3 (4) sends a second information response to node 1 in the second frame format.
  • the node 1 obtains the ID of the node 3(4) that sends the second information response according to the second information response, and determines the node 3(4) as the node of the second bus mode, and determines to adopt the second bus mode and the node 3 ( 4) conducting communication;
  • the application software on the node 1 extracts the second information response in the CAN, and obtains the ID of the node 3 (4) that sends the second information response.
  • the node 1 can also classify all the nodes that send the second information response by the method of establishing the table.
  • the node of the two bus mode, the table B is constructed, in this embodiment, the node 3 (4), and the node 1 refreshes the newly inserted or deleted node in the CAN by the change of the table B.
  • node 1 communicates with node 2 in a first bus manner by using a first frame format at a time when the preset polling time has not arrived;
  • the application layer software on the node 1 determines that the polling is not started. If the node 1 communicates with the node (node 2) in the table A, the first frame format can be used to communicate with the node 2 by the software actively setting the frame format.
  • Node 1 communicates with node 3 (4) in a second bus mode by using a second frame format at a time when the preset polling time has not arrived.
  • the application layer software on node 1 determines that polling is not started. If node 1 is in communication with the node in node B (node 3 (4)), the second frame format and node 3 (4) can be adopted by the software to actively set the frame format. Communicate.
  • the node is a node of the second bus mode, and the node adopts the preset bus frame of the second frame format at a time when the preset polling time arrives. Polling all other nodes; the node receives a third information response, the third information response is in the second frame format; and the node acquires the third information response according to the third information response Determining the identity of the node, and determining, by the node that sends the third information response, a node of the second bus mode, and determining to communicate with the node of the second bus mode by using the second bus mode . The node communicates with the node of the second bus mode in the second bus mode by using the second frame format at a time when the preset polling time has not arrived.
  • FIG. 4 is a flowchart of still another embodiment of the data communication method in the bus of the present invention. As shown in FIG. 4, the method in this embodiment is applicable to the application scenario shown in FIG. 1, and the node 3 in the second bus mode is used as the main Node, the method can include:
  • node 3 starts a polling task, and periodically determines whether the preset polling time arrives;
  • Node 3 When the node of the second bus mode acts as the master node, the token is used to communicate with other nodes in the CAN.
  • Node 3 initiates a timed polling addressing function through the application layer software.
  • the startup mode may be a power-on startup or a timer timing.
  • Node 3 polls all addresses in the CAN at the time when the polling time arrives, and all addresses correspond to All nodes in CAN.
  • the node 3 polls the node 1 (2, 4) by using a preset bus frame in the second frame format at a time when the preset polling time arrives;
  • the node 3 is a node of the second bus mode and only supports the second frame format. Therefore, the node 3 polls all the nodes in the second frame format. In this embodiment, the second frame format is sent to the node 1 (2, 4). Preset bus frame.
  • node 1 (2) sends a third information response to node 3 in a second frame format
  • Node 1 (2) can simultaneously receive and parse the first frame format and the second frame format, and determine the received second frame format according to the bus type bits in the preset bus frame, so node 1 (2) is automatically set to The second frame format sends a third information response to node 3.
  • the node 4 sends a third information response to the node 3 by using the second frame format
  • the node 4 can only process the second frame format, and determines the received second frame format according to the bus type bits in the preset bus frame, so the node 4 automatically sets the second frame format to send the third information response to the node 3.
  • the node 3 obtains the ID of the node 1 (2, 4) that sends the third information response according to the third information response, and determines to communicate with the node 1 (2, 4) by using the second bus mode;
  • the application software on the node 3 extracts the third information response in the CAN, acquires the ID of the node 1 (2, 4) that sends the third information response, and the node 3 can classify all the nodes that send the third information response by means of table construction.
  • the node of the second bus mode, the table C is constructed, in this embodiment, the node 1 (2, 4), and the node 3 refreshes the newly inserted or deleted node in the CAN by the change of the table C.
  • the node 3 communicates with the node 1 (2, 4) in a second bus manner by using the second frame format at a time when the preset polling time has not arrived.
  • the application layer software on node 3 determines that polling is not started, and node 3 communicates with the node (1 (2, 4)) in table C, and the second frame format and node 1 can be adopted by the software to actively set the frame format (2, 4). ) to communicate.
  • the node in the foregoing embodiment is a slave node
  • the specific implementation method of step 101 may be: the node actively initiates a handshake communication to the master node, and determines a bus mode of the data communication according to the preset bus frame.
  • the above process may have three implementation processes depending on the node. The details are explained below.
  • the node is a slave node and is a node of the first bus mode, and the node sends the preset bus frame in the first frame format to the master node; the node receives the master The fourth information sent by the node is replied, and the fourth information response is in the first frame format; the node determines that the primary node is a node in the first bus mode, and adopts the first bus mode and The master node communicates.
  • the master node is the node of the first bus mode.
  • the slave node of the first bus mode actively initiates the handshake communication, it does not know what type of node the master node is, so the first frame format pre-transmission can be sent first.
  • Setting a bus frame if the slave node of the first bus mode receives the fourth information response of the first frame format sent by the master node, The master node can parse the preset bus frame sent by the slave node, and the node can only be implemented by the node of the first bus mode, so the slave node can communicate with the master node in the first bus mode.
  • FIG. 5 is a flowchart of a fourth embodiment of the data communication method in the bus of the present invention. As shown in FIG. 5, the method in this embodiment is applicable to the application scenario shown in FIG.
  • the slave node, the node 2 of the first bus mode is used as the master node, and the method may include:
  • the master node 2 sends a fourth information response to the slave node 1 in a first frame format.
  • the slave node 1 communicates with the master node 2 by using the first bus mode.
  • the master node 2 can communicate with the slave node 1 according to the type of the preset bus frame of the slave node 1 received last time.
  • the node is a slave node and is a node of the first bus mode, and the node sends the preset bus frame in the first frame format to the master node; the node is preset After the timeout has not received the fourth information response sent by the primary node, the node determines that the primary node is a node of the second bus mode, and sends the second frame to the primary node.
  • the preset bus frame of the format; the node receives a fifth information response sent by the primary node, and the fifth information response is in the second frame format; the node determines to adopt the second bus mode Communicate with the master node.
  • the master node is a node in the second bus mode.
  • the preset bus frame in the first frame format is sent first, and the slave node still after the preset timeout.
  • the master node does not receive a response, indicating that the master node does not respond to the preset bus frame of the first frame structure sent from the node.
  • the slave node can start at the same time as the preset bus frame in the first frame format. Timer.
  • the second bus mode node cannot parse the second frame structure, so the slave node can consider the master node to be the second bus mode node, and send the preset bus frame of the second frame structure to the master.
  • the node After receiving the preset bus frame, the node identifies the frame according to the bus type bit in the ID and sends a fifth information response of the second frame structure. After receiving the fifth information response from the node, the node may adopt the first The second bus mode communicates with the master node.
  • FIG. 6 is a flowchart of a fifth embodiment of a data communication method in a bus according to the present invention. As shown in FIG. 6, the method in this embodiment is applicable to the application scenario shown in FIG.
  • the slave node, the node 3 of the second bus mode is used as the master node, and the method may include:
  • S501 Initiating a handshake communication from the node 1, and sending, to the master node 3, a preset bus frame in a first frame format;
  • S502 The master node 3 does not respond to the preset bus frame of the first frame format sent from the node 1;
  • the slave node 1 After the preset timeout, the slave node 1 sends the preset bus frame of the second frame format to the master node 3;
  • the master node 3 sends a fifth information response to the slave node 1 by using a second frame format.
  • the slave node 1 communicates with the master node 3 by using the second bus mode.
  • the node is a slave node and is a node of the second bus mode
  • the node sends the preset bus frame in the second frame format to the master node
  • the node receives the The sixth information sent by the primary node is responsive, and the sixth information response is in the second frame format, and the primary node includes the node in the first bus mode and the node in the second bus mode; Determining to communicate with the master node by using the second bus mode.
  • the master node in this case can be either the first bus mode node or the second bus mode node.
  • the slave node in the second bus mode actively initiates the handshake communication, only the second frame structure pre-transmission can be sent.
  • Set the bus frame If the master node is the node of the first bus mode, after receiving the preset bus frame of the second frame structure sent from the node, it may be correspondingly set to the second bus mode, and return to the second frame format.
  • Six information response if the master node is a node of the second bus mode, after receiving the preset bus frame of the second frame structure sent by the slave node, it can be identified and parsed, so the second frame format can also be returned.
  • Six information responses The slave node communicates with the master node using the second bus mode.
  • FIG. 7 is a flowchart of a sixth embodiment of a data communication method in a bus according to the present invention. As shown in FIG. 7, the method in this embodiment is applicable to the application scenario shown in FIG. 1, and the node 3 in the second bus mode is used as The slave node, the node 1 of the first bus mode is used as the master node, and the method may include:
  • S601 initiating handshake communication from node 3, and sending a preset bus frame in a second frame format to the master node 1;
  • the master node 1 is configured to send a sixth information response to the slave node 3 in a second frame format.
  • the slave node 3 communicates with the master node 1 by using the second bus mode.
  • node of the second bus mode is both the master node and the slave node is a prior art, and details are not described herein again.
  • FIG. 8 is a schematic structural diagram of an embodiment of a CAN node according to the present invention. As shown in FIG. 8, the node in this embodiment is any node in the application scenario shown in FIG. 1. The node in this embodiment may include: determining a module.
  • a communication module 12 wherein the determining module 11 is configured to determine a bus manner of data communication according to the preset bus frame, where the frame format of the preset bus frame includes a first frame format and a second frame format, where the first a frame format corresponding to the first bus mode, the second frame format corresponding to the second bus mode, the preset bus frame including an identity identifier, the identity tag A predetermined number of bits are used to identify the frame format, and the communication module 12 is configured to communicate by using a frame format corresponding to the determined bus mode of the data communication.
  • the node of this embodiment may be used to implement the technical solution of the method embodiment shown in FIG. 2, and the implementation principle and the technical effect are similar, and details are not described herein again.
  • the node is a slave node; the determining module 11 is specifically configured to initiate a handshake communication to the master node, and determine a bus mode of the data communication according to the preset bus frame.
  • the node is a node of the first bus mode
  • the determining module 11 is specifically configured to send the preset bus frame in the first frame format to the primary node; and receive the primary node Transmitting the fourth information response, and the fourth information response is the first frame format; determining that the primary node is the node of the first bus mode, and adopting the first bus mode and the primary node Communicate.
  • the foregoing node may be used to implement the technical solution of the method embodiment shown in FIG. 5, and the implementation principle and the technical effect are similar, and details are not described herein again.
  • the node is a node of the first bus mode; the determining module 11 is specifically configured to send the preset bus frame in the first frame format to the primary node; after a preset timeout Receiving the fourth information response sent by the primary node, the node determines that the primary node is a node in the second bus mode, and sends the second frame format to the primary node.
  • the preset bus frame receives a fifth information response sent by the master node, and the fifth information response is in the second frame format; determining to communicate with the master node by using the second bus mode.
  • the foregoing node may be used to implement the technical solution of the method embodiment shown in FIG. 6, and the implementation principle and the technical effect are similar, and details are not described herein again.
  • the node is a node of the second bus mode; the determining module 11 is specifically configured to send the preset bus frame in the second frame format to the primary node; and receive the primary node Sending the sixth information response, and the sixth information response is in the second frame format, the primary node includes the first bus mode node and the second bus mode node; determining to adopt the first The second bus mode communicates with the master node.
  • the foregoing node may be used to implement the technical solution of the method embodiment shown in FIG. 7.
  • the implementation principle and the technical effect are similar, and details are not described herein again.
  • FIG. 9 is a schematic structural diagram of another embodiment of a CAN node according to the present invention.
  • the node in this embodiment is any node in the application scenario shown in FIG. 1
  • the node in this embodiment is in FIG. 8 .
  • the method further includes: a determining module 13 configured to start a polling task, and periodically determine whether the preset polling time arrives.
  • the node is a node of the first bus mode; the determining module 11 is specifically configured to use the preset bus frame pair of the first frame format at a time when the preset polling time arrives The other node performs the polling; the first information response is received, the first information response is the first frame format; and the identity identifier of the node that sends the first information response is obtained according to the first information response, and Determining, by the node that sends the first information response, as a node of the first bus mode, determining to use the first bus mode to communicate with a node of the first bus mode; in the preset polling At a time when the time arrives, the preset bus frame in the second frame format is used to poll other nodes except the node determined to be the first bus mode; and receive a second information response, the first The second information response is the second frame format; the identity identifier of the node that sends the second information response is obtained according to the second information response, and the node that sends the second information response is determined as Said
  • the communication module 12 is configured to communicate with the node of the first bus mode by using the first frame format by the first frame format at a time when the preset polling time is not reached; and Or, when the preset polling time has not arrived, communicating with the node of the second bus mode in the second bus mode by using the second frame format.
  • the foregoing node may be used to implement the technical solution of the method embodiment shown in FIG. 3, and the implementation principle and the technical effect are similar, and details are not described herein again.
  • the node is a node of the second bus mode; the determining module 11 is specifically configured to use the preset bus frame pair of the second frame format at a time when the preset polling time arrives The other node performs polling; receives a third information response, the third information response is in the second frame format; and acquiring, according to the third information response, the identity identifier of the node that sends the third information response, and Determining, by the node transmitting the third information response, a node of the second bus mode, and determining to communicate with the node of the second bus mode by using the second bus mode.
  • the communication module 12 is configured to communicate with the node of the second bus mode in the second bus mode by using the second frame format at a time when the preset polling time is not reached.
  • the foregoing node may be used to implement the technical solution of the method embodiment shown in FIG. 4, and the implementation principle and the technical effect are similar, and details are not described herein again.
  • FIG. 10 is a schematic structural diagram of an embodiment of a CAN system according to the present invention.
  • the system of this embodiment includes: at least one node 1 and 12 of a first bus mode and at least one node 13 of a second bus mode.
  • the structure of the device embodiment shown in FIG. 8 or FIG. 9 is used in the first bus mode, and the technical solution of any of the method embodiments in FIG. 2 to FIG.
  • the implementation principle and the technical effect are similar, and are not described herein again;
  • the nodes 13 and 14 of the second bus mode adopt the structure of the device embodiment shown in FIG. 8 or FIG.
  • the technical solution of the method embodiment in any of the embodiments of FIG. 2 is performed, and the implementation principle and technical effects are similar, and details are not described herein again.
  • FIG. 11 is a schematic structural diagram of an embodiment of a node in a first bus mode according to the present invention.
  • the node 10 of this embodiment may include: a controller 11 and a CAN driver 12, where the controller 11 may be micro A control unit (Micro Control Unit, MCU for short) or a Field Programmable Gate Array (FPGA) for performing the technical solution of any one of the method embodiments of FIG. 2 to FIG.
  • the CAN driver 12 converts the output of the controller 11 into a signal of a CAN differential line, outputs it to the CAN bus, or converts the signal input on the CAN bus to the controller 11 to implement the node of the first bus mode and the CAN bus. Network data interaction.
  • FIG. 12 is a schematic structural diagram of another embodiment of a node in a first bus mode according to the present invention.
  • a controller of a node of a first bus mode is hung on an Advanced High Performance Bus (abbreviation: AHB).
  • AHB Advanced High Performance Bus
  • the AHB bus is connected to the control register, and the controller of the node of the first bus mode may include: a data sending module 11, a data receiving module 12, and a control module 13, wherein the data sending module 11 may further include: a sending buffer
  • the module 111 is configured to receive and buffer the data to be sent from the AHB, and perform parallel-to-serial conversion on the transmission data.
  • the protocol selection module 112 selects a frame format used by the transmission data according to the control register command, and according to the determined frame format. Transmitting the data for encoding; the sending module 113 sends the encoded transmission data to the CAN driver according to the control register command; the data receiving module 12 may further include: a data frame identification module 121, configured to receive the data sent by the CAN driver, and receive the data Data is arbitrated, data frame type is recognized, and the processing result is fed back to the control register.
  • the control register determines whether the data transmitting module 11 continues to transmit; the protocol selection module 122 performs sampling and demodulation on the received data according to the control frame command by using a corresponding frame format; and the receiving buffer module 123 is configured to demodulate the protocol selection module. Receiving data for serial-to-parallel conversion and buffering, and providing AHB bus access function; control module 13 for implementing AHB access control, sending frame format transmission, transmission rate setting, and receiving data status query function.
  • the aforementioned program can be stored in a computer readable storage medium.
  • the program when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes various media that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.

Abstract

Provided in embodiments of the present invention are a new type CAN frame based communication method, device and system. The method comprises: expanding a data field of an original CAN 2.0 frame in size to enable more data to be transmitted by the expanded data field. Further, fixed values are added to fixed positions of the data field and a check field of the new type of frame for a CAN 2.0 device to sample the fixed values and complete an error correction check, thereby avoiding errors, and providing compatibility with the existing CAN 2.0 devices.

Description

基于新型CAN帧进行通信的方法、装置及系统Method, device and system for communicating based on novel CAN frame
本申请要求于2015年2月17日提交中国专利局、申请号为201510086524.1、发明名称为“基于新型CAN帧进行通信的方法、装置及系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 201510086524.1, entitled "Method, Apparatus and System for Communication Based on New CAN Frames", filed on February 17, 2015, the entire contents of which are incorporated by reference. Combined in this application.
技术领域Technical field
本发明实施例涉及通信技术,尤其涉及一种总线中的数据通讯方法、装置及系统。Embodiments of the present invention relate to communication technologies, and in particular, to a data communication method, apparatus, and system in a bus.
背景技术Background technique
控制器局域网络(Controller Area Network,简称:CAN)是标准化的串行通信总线协议,其最高物理层(Physical layer,简称:PHY)速率为1Mbps/s。灵活数据速率的CAN(CAN with Flexible Data rate,简称:CAN-FD)通过对CAN的PHY的速率提升实现1Mbps/s以上的总线通讯速率。Controller Area Network (CAN) is a standardized serial communication bus protocol with a maximum physical layer (PHY) rate of 1 Mbps/s. CAN with Flexible Data Rate (CAN-FD) achieves a bus communication rate of 1 Mbps/s or more by increasing the rate of the PHY of the CAN.
但是CAN-FD节点与现有的CAN 2.0节点共同工作时,CAN 2.0节点在处理CAN-FD节点的数据时会出现数据填充错误、循环冗余校验码(Cyclic Redundancy Check,简称:CRC)校验错误,导致CAN 2.0节点中断当前CAN通讯,因此,CAN-FD不能与现有的CAN总线方式兼容。However, when the CAN-FD node works with the existing CAN 2.0 node, the CAN 2.0 node will have a data padding error and a Cyclic Redundancy Check (CRC) when processing the data of the CAN-FD node. The error is detected, causing the CAN 2.0 node to interrupt the current CAN communication. Therefore, CAN-FD cannot be compatible with the existing CAN bus mode.
发明内容Summary of the invention
本发明实施例提供一种总线中的数据通讯方法、装置及系统,以实现第一总线方式的节点在提升PHY的速率的同时兼容现有的总线方式,解决两种总线方式共存时会出现数据填充错误、CRC校验错误,导致CAN 2.0节点中断当前CAN通讯的问题。The embodiment of the invention provides a data communication method, device and system in a bus, so as to realize that the node of the first bus mode is compatible with the existing bus mode while improving the rate of the PHY, and the data occurs when the two bus modes coexist. A fill error, CRC check error, causing the CAN 2.0 node to interrupt the current CAN communication problem.
第一方面,本发明实施例提供一种总线中的数据通讯方法,所述方法适用于包括至少一个第一总线方式的节点和至少一个第二总线方式的节点的控制器局域网络CAN,所述方法包括:In a first aspect, an embodiment of the present invention provides a data communication method in a bus, where the method is applicable to a controller area network CAN including at least one node of a first bus mode and at least one node of a second bus mode, Methods include:
节点根据预设总线帧确定数据通讯的总线方式,所述预设总线帧的帧格式包括第一帧格式和第二帧格式,所述第一帧格式与所述第一总线方式对应,所述第二帧格式与所述第二总线方式对应,所述预设总线帧包括身份标识,所述身份标识中有预设个数个比特位用于标识所述帧格式;Determining, by the node, a bus mode of the data communication according to the preset bus frame, where the frame format of the preset bus frame includes a first frame format and a second frame format, where the first frame format corresponds to the first bus mode, The second frame format corresponds to the second bus mode, the preset bus frame includes an identity identifier, and the identifier has a preset number of bits for identifying the frame format;
所述节点采用与确定的所述数据通讯的总线方式对应的帧格式进行通讯。 The node communicates with a frame format corresponding to the determined bus mode of the data communication.
结合第一方面,在第一方面的第一种可能的实现方式中,所述节点为主节点;With reference to the first aspect, in a first possible implementation manner of the first aspect, the node is a master node;
所述节点根据预设总线帧确定数据通讯的总线方式,包括:The node determines a bus manner of data communication according to a preset bus frame, including:
所述节点在预设轮询时间到达的时刻,根据所述预设总线帧确定所述数据通讯的总线方式;Determining, by the node, a bus manner of the data communication according to the preset bus frame at a time when a preset polling time arrives;
所述节点采用与所述数据通讯的总线方式对应的帧格式进行通讯,包括:The node communicates with a frame format corresponding to the bus mode of the data communication, including:
所述节点在所述预设轮询时间未到达的时刻,采用与所述数据通讯的总线方式对应的帧格式进行通讯。The node communicates with a frame format corresponding to the bus mode of the data communication at a time when the preset polling time has not arrived.
结合第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述节点为所述第一总线方式的节点;With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the node is a node in the first bus mode;
所述节点在预设轮询时间到达的时刻,根据所述预设总线帧确定所述数据通讯的总线方式,包括:Determining, by the node, the bus mode of the data communication according to the preset bus frame, when the preset polling time arrives, including:
所述节点在所述预设轮询时间到达的时刻,采用所述第一帧格式的所述预设总线帧对所有其他节点进行轮询;The node polls all other nodes by using the preset bus frame in the first frame format at a time when the preset polling time arrives;
所述节点接收第一信息应答,所述第一信息应答为所述第一帧格式;Receiving, by the node, a first information response, where the first information response is in the first frame format;
所述节点根据所述第一信息应答获取发送所述第一信息应答的节点的所述身份标识,并将所述发送所述第一信息应答的节点确定为所述第一总线方式的节点,确定采用所述第一总线方式与所述第一总线方式的节点进行通讯;Determining, by the node, the identity identifier of the node that sends the first information response according to the first information, and determining, by the node that sends the first information response, the node in the first bus mode, Determining to communicate with the node of the first bus mode by using the first bus mode;
所述节点在所述预设轮询时间到达的时刻,采用所述第二帧格式的所述预设总线帧对除所述确定为所述第一总线方式的节点外的其他节点进行轮询;The node polls other nodes except the node determined to be the first bus mode by using the preset bus frame in the second frame format at a time when the preset polling time arrives. ;
所述节点接收第二信息应答,所述第二信息应答为所述第二帧格式;Receiving, by the node, a second information response, where the second information response is in the second frame format;
所述节点根据所述第二信息应答获取发送所述第二信息应答的节点的所述身份标识,并将所述发送所述第二信息应答的节点确定为所述第二总线方式的节点,确定采用所述第二总线方式与所述第二总线方式的节点进行通讯。Determining, by the node, the identity identifier of the node that sends the second information response according to the second information, and determining, by the node that sends the second information response, the node in the second bus mode, Determining to communicate with the node of the second bus mode by using the second bus mode.
结合第一方面的第二种可能的实现方式,在第一方面的第三种可能的实现方式中,所述节点在所述预设轮询时间未到达的时刻,采用与所述数据通讯的总线方式对应的帧格式进行通讯,包括:In conjunction with the second possible implementation of the first aspect, in a third possible implementation manner of the first aspect, the node is configured to communicate with the data at a time when the preset polling time is not reached. Communication in the frame format corresponding to the bus mode, including:
所述节点在所述预设轮询时间未到达的时刻,通过所述第一帧格式以所述第一总线方式与所述第一总线方式的节点进行通讯;和/或,And the node communicates with the node of the first bus mode by using the first frame format by the first frame format at a time when the preset polling time has not arrived; and/or,
所述节点在所述预设轮询时间未到达的时刻,通过所述第二帧格式以所述第二总线方式与所述第二总线方式的节点进行通讯。 The node communicates with the node of the second bus mode in the second bus mode by using the second frame format at a time when the preset polling time has not arrived.
结合第一方面的第一种可能的实现方式,在第一方面的第四种可能的实现方式中,所述节点为所述第二总线方式的节点;In conjunction with the first possible implementation of the first aspect, in a fourth possible implementation manner of the first aspect, the node is a node of the second bus mode;
所述节点在预设轮询时间到达的时刻,根据所述预设总线帧确定所述数据通讯的总线方式,包括:Determining, by the node, the bus mode of the data communication according to the preset bus frame, when the preset polling time arrives, including:
所述节点在所述预设轮询时间到达的时刻,采用所述第二帧格式的所述预设总线帧对所有其他节点进行轮询;The node polls all other nodes by using the preset bus frame in the second frame format at a time when the preset polling time arrives;
所述节点接收第三信息应答,所述第三信息应答为所述第二帧格式;Receiving, by the node, a third information response, where the third information response is in the second frame format;
所述节点根据所述第三信息应答获取发送所述第三信息应答的节点的所述身份标识,并将所述发送所述第三信息应答的节点确定为所述第二总线方式的节点,确定采用所述第二总线方式与所述第二总线方式的节点进行通讯。Determining, by the node, the identity identifier of the node that sends the third information response according to the third information response, and determining, by the node that sends the third information response, the node in the second bus mode, Determining to communicate with the node of the second bus mode by using the second bus mode.
结合第一方面的第四种可能的实现方式,在第一方面的第五种可能的实现方式中,所述节点在所述预设轮询时间未到达的时刻,采用与所述数据通讯的总线方式对应的帧格式进行通讯,包括:In conjunction with the fourth possible implementation of the first aspect, in a fifth possible implementation manner of the first aspect, the node is configured to communicate with the data at a time when the preset polling time is not reached. Communication in the frame format corresponding to the bus mode, including:
所述节点在所述预设轮询时间未到达的时刻,通过所述第二帧格式以所述第二总线方式与所述第二总线方式的节点进行通讯。The node communicates with the node of the second bus mode in the second bus mode by using the second frame format at a time when the preset polling time has not arrived.
结合第一方面的第一种至第五种中任一种可能的实现方式,在第一方面的第六种可能的实现方式中,所述节点根据预设总线帧确定数据通讯的总线方式之前,还包括:With reference to the possible implementation manners of any one of the first to fifth aspects of the first aspect, in a sixth possible implementation manner of the first aspect, the determining, by the node, the bus mode of the data communication according to the preset bus frame ,Also includes:
所述节点启动轮询任务,并周期判断所述预设轮询时间是否到达。The node starts a polling task and periodically determines whether the preset polling time has arrived.
结合第一方面,在第一方面的第七种可能的实现方式中,所述节点为从节点;With reference to the first aspect, in a seventh possible implementation manner of the first aspect, the node is a slave node;
所述节点根据预设总线帧确定数据通讯的总线方式,包括:The node determines a bus manner of data communication according to a preset bus frame, including:
所述节点主动向主节点发起握手通讯,根据所述预设总线帧确定所述数据通讯的总线方式。The node actively initiates a handshake communication to the primary node, and determines a bus manner of the data communication according to the preset bus frame.
结合第一方面的第七种可能的实现方式,在第一方面的第八种可能的实现方式中,所述节点为所述第一总线方式的节点;In conjunction with the seventh possible implementation of the first aspect, in an eighth possible implementation manner of the first aspect, the node is a node of the first bus mode;
所述节点主动向主节点发起握手通讯,根据所述预设总线帧确定所述数据通讯的总线方式,包括:The node actively initiates a handshake communication to the master node, and determines a bus manner of the data communication according to the preset bus frame, including:
所述节点向所述主节点发送所述第一帧格式的所述预设总线帧;Sending, by the node, the preset bus frame in the first frame format to the primary node;
所述节点接收所述主节点发送的第四信息应答,且所述第四信息应答为所述第一帧格式; Receiving, by the node, a fourth information response sent by the primary node, and the fourth information response is in the first frame format;
所述节点确定所述主节点为所述第一总线方式的节点,并采用所述第一总线方式与所述主节点进行通讯。The node determines that the master node is a node of the first bus mode, and communicates with the master node by using the first bus mode.
结合第一方面的第七种可能的实现方式,在第一方面的第九种可能的实现方式中,所述节点为所述第一总线方式的节点;With reference to the seventh possible implementation of the first aspect, in a ninth possible implementation manner of the first aspect, the node is a node of the first bus mode;
所述节点主动向主节点发起握手通讯,根据所述预设总线帧确定所述数据通讯的总线方式,包括:The node actively initiates a handshake communication to the master node, and determines a bus manner of the data communication according to the preset bus frame, including:
所述节点向所述主节点发送所述第一帧格式的所述预设总线帧;Sending, by the node, the preset bus frame in the first frame format to the primary node;
所述节点在预设超时之后还没有接收到所述主节点发送的所述第四信息应答,则所述节点确定所述主节点为所述第二总线方式的节点,并向所述主节点发送所述第二帧格式的所述预设总线帧;After the preset timeout has not received the fourth information response sent by the primary node, the node determines that the primary node is a node in the second bus mode, and sends the node to the primary node. Transmitting the preset bus frame of the second frame format;
所述节点接收所述主节点发送的第五信息应答,且所述第五信息应答为所述第二帧格式;Receiving, by the node, a fifth information response sent by the primary node, and the fifth information response is in the second frame format;
所述节点确定采用所述第二总线方式与所述主节点进行通讯。The node determines to communicate with the master node by using the second bus mode.
结合第一方面的第七种可能的实现方式,在第一方面的第十种可能的实现方式中,所述节点为所述第二总线方式的节点;With reference to the seventh possible implementation of the first aspect, in a tenth possible implementation manner of the first aspect, the node is a node of the second bus mode;
所述节点主动向主节点发起握手通讯,根据所述预设总线帧确定所述数据通讯的总线方式,包括:The node actively initiates a handshake communication to the master node, and determines a bus manner of the data communication according to the preset bus frame, including:
所述节点向所述主节点发送所述第二帧格式的所述预设总线帧;Sending, by the node, the preset bus frame in the second frame format to the primary node;
所述节点接收所述主节点发送的第六信息应答,且所述第六信息应答为所述第二帧格式,所述主节点包括所述第一总线方式的节点和所述第二总线方式的节点;Receiving, by the node, a sixth information response sent by the primary node, and the sixth information response is in the second frame format, where the primary node includes the first bus mode node and the second bus mode Node
所述节点确定采用所述第二总线方式与所述主节点进行通讯。The node determines to communicate with the master node by using the second bus mode.
第二方面,本发明实施例提供一种控制器局域网络CAN节点,即基于新型CAN帧进行通信的CAN设备,所述CAN包括至少一个第一总线方式的节点和至少一个第二总线方式的节点,所述节点包括:In a second aspect, an embodiment of the present invention provides a controller area network (CAN) CAN node, that is, a CAN device that performs communication based on a new CAN frame, where the CAN includes at least one node of the first bus mode and at least one node of the second bus mode. The node includes:
确定模块,用于根据预设总线帧确定数据通讯的总线方式,所述预设总线帧的帧格式包括第一帧格式和第二帧格式,所述第一帧格式与所述第一总线方式对应,所述第二帧格式与所述第二总线方式对应,所述预设总线帧包括身份标识,所述身份标识中有预设个数个比特位用于标识所述帧格式;a determining module, configured to determine a bus manner of data communication according to a preset bus frame, where a frame format of the preset bus frame includes a first frame format and a second frame format, and the first frame format and the first bus mode Correspondingly, the second frame format is corresponding to the second bus mode, and the preset bus frame includes an identity identifier, where the preset identifier has a plurality of bits for identifying the frame format;
通讯模块,用于采用与确定的所述数据通讯的总线方式对应的帧格式进行通讯。And a communication module, configured to communicate by using a frame format corresponding to the determined bus mode of the data communication.
结合第二方面,在第二方面的第一种可能的实现方式中,所述节点为主节点; With reference to the second aspect, in a first possible implementation manner of the second aspect, the node is a master node;
所述确定模块,具体用于在预设轮询时间到达的时刻,根据所述预设总线帧确定所述数据通讯的总线方式;The determining module is specifically configured to determine, according to the preset bus frame, a bus manner of the data communication, when a preset polling time arrives;
所述通讯模块,具体用于在所述预设轮询时间未到达的时刻,采用与所述数据通讯的总线方式对应的帧格式进行通讯。The communication module is specifically configured to perform communication by using a frame format corresponding to the bus mode of the data communication when the preset polling time has not arrived.
结合第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述节点为所述第一总线方式的节点;With reference to the first possible implementation of the second aspect, in a second possible implementation manner of the second aspect, the node is a node of the first bus mode;
所述确定模块,具体用于在所述预设轮询时间到达的时刻,采用所述第一帧格式的所述预设总线帧对所有其他节点进行轮询;接收第一信息应答,所述第一信息应答为所述第一帧格式;根据所述第一信息应答获取发送所述第一信息应答的节点的所述身份标识,并将所述发送所述第一信息应答的节点确定为所述第一总线方式的节点,确定采用所述第一总线方式与所述第一总线方式的节点进行通讯;在所述预设轮询时间到达的时刻,采用所述第二帧格式的所述预设总线帧对除所述确定为所述第一总线方式的节点外的其他节点进行轮询;接收第二信息应答,所述第二信息应答为所述第二帧格式;根据所述第二信息应答获取发送所述第二信息应答的节点的所述身份标识,并将所述发送所述第二信息应答的节点确定为所述第二总线方式的节点,确定采用所述第二总线方式与所述第二总线方式的节点进行通讯。The determining module is configured to: when the preset polling time arrives, use the preset bus frame in the first frame format to poll all other nodes; receive the first information response, The first information response is the first frame format; the identity identifier of the node that sends the first information response is obtained according to the first information response, and the node that sends the first information response is determined as The node of the first bus mode determines that the first bus mode is used to communicate with the node of the first bus mode; when the preset polling time arrives, the second frame format is adopted. The preset bus frame polls other nodes except the node determined to be the first bus mode; receiving a second information response, the second information response being the second frame format; The second information response acquires the identity identifier of the node that sends the second information response, and determines the node that sends the second information response as the node of the second bus mode, and determines to adopt the And second bus node of the second embodiment mode communication bus.
结合第二方面的第二种可能的实现方式,在第二方面的第三种可能的实现方式中,所述通讯模块,具体用于在所述预设轮询时间未到达的时刻,通过所述第一帧格式以所述第一总线方式与所述第一总线方式的节点进行通讯;和/或,在所述预设轮询时间未到达的时刻,通过所述第二帧格式以所述第二总线方式与所述第二总线方式的节点进行通讯。With reference to the second possible implementation of the second aspect, in a third possible implementation manner of the second aspect, the communication module is specifically configured to: when the preset polling time is not reached, pass the The first frame format communicates with the node of the first bus mode in the first bus manner; and/or, at a time when the preset polling time has not arrived, by the second frame format The second bus mode communicates with the nodes of the second bus mode.
结合第二方面的第一种可能的实现方式,在第二方面的第四种可能的实现方式中,所述节点为所述第二总线方式的节点;With reference to the first possible implementation of the second aspect, in a fourth possible implementation manner of the second aspect, the node is a node of the second bus mode;
所述确定模块,具体用于在所述预设轮询时间到达的时刻,采用所述第二帧格式的所述预设总线帧对所有其他节点进行轮询;接收第三信息应答,所述第三信息应答为所述第二帧格式;根据所述第三信息应答获取发送所述第三信息应答的节点的所述身份标识,并将所述发送所述第三信息应答的节点确定为所述第二总线方式的节点,确定采用所述第二总线方式与所述第二总线方式的节点进行通讯。 The determining module is configured to: when the preset polling time arrives, use the preset bus frame in the second frame format to poll all other nodes; receive a third information response, The third information response is the second frame format; the identity identifier of the node that sends the third information response is obtained according to the third information response, and the node that sends the third information response is determined as The node of the second bus mode determines to communicate with the node of the second bus mode by using the second bus mode.
结合第二方面的第四种可能的实现方式,在第二方面的第五种可能的实现方式中,所述通讯模块,具体用于在所述预设轮询时间未到达的时刻,通过所述第二帧格式以所述第二总线方式与所述第二总线方式的节点进行通讯。With reference to the fourth possible implementation of the second aspect, in a fifth possible implementation manner of the second aspect, the communication module is specifically configured to: when the preset polling time is not reached, The second frame format communicates with the nodes of the second bus mode in the second bus mode.
结合第二方面的第一种至第五种中任一种可能的实现方式,在第二方面的第六种可能的实现方式中,还包括:With reference to the possible implementation of any one of the first to the fifth aspects of the second aspect, in a sixth possible implementation manner of the second aspect, the method further includes:
判断模块,用于启动轮询任务,并周期判断所述预设轮询时间是否到达。The determining module is configured to start a polling task, and periodically determine whether the preset polling time arrives.
结合第二方面,在第二方面的第七种可能的实现方式中,所述节点为从节点;With reference to the second aspect, in a seventh possible implementation manner of the second aspect, the node is a slave node;
所述确定模块,具体用于主动向主节点发起握手通讯,根据所述预设总线帧确定所述数据通讯的总线方式。The determining module is specifically configured to initiate a handshake communication to the primary node, and determine a bus manner of the data communication according to the preset bus frame.
结合第二方面的第七种可能的实现方式,在第二方面的第八种可能的实现方式中,所述节点为所述第一总线方式的节点;With reference to the seventh possible implementation of the second aspect, in an eighth possible implementation manner of the second aspect, the node is a node of the first bus mode;
所述确定模块,具体用于向所述主节点发送所述第一帧格式的所述预设总线帧;接收所述主节点发送的第四信息应答,且所述第四信息应答为所述第一帧格式;确定所述主节点为所述第一总线方式的节点,并采用所述第一总线方式与所述主节点进行通讯。The determining module is configured to send the preset bus frame in the first frame format to the primary node, receive a fourth information response sent by the primary node, and the fourth information response is the a first frame format; determining that the master node is a node of the first bus mode, and communicating with the master node by using the first bus mode.
结合第二方面的第七种可能的实现方式,在第二方面的第九种可能的实现方式中,所述节点为所述第一总线方式的节点;With reference to the seventh possible implementation of the second aspect, in a ninth possible implementation manner of the second aspect, the node is a node of the first bus mode;
所述确定模块,具体用于向所述主节点发送所述第一帧格式的所述预设总线帧;在预设超时之后还没有接收到所述主节点发送的所述第四信息应答,则所述节点确定所述主节点为所述第二总线方式的节点,并向所述主节点发送所述第二帧格式的所述预设总线帧;接收所述主节点发送的第五信息应答,且所述第五信息应答为所述第二帧格式;确定采用所述第二总线方式与所述主节点进行通讯。The determining module is specifically configured to send the preset bus frame in the first frame format to the primary node; after receiving the preset timeout, the fourth information response sent by the primary node is not received yet, And the node determines that the primary node is the node of the second bus mode, and sends the preset bus frame in the second frame format to the primary node; and receives the fifth information sent by the primary node. Responding, and the fifth information response is in the second frame format; determining to communicate with the master node by using the second bus mode.
结合第二方面的第七种可能的实现方式,在第二方面的第十种可能的实现方式中,所述节点为所述第二总线方式的节点;With reference to the seventh possible implementation of the second aspect, in a tenth possible implementation manner of the second aspect, the node is a node of the second bus mode;
所述确定模块,具体用于向所述主节点发送所述第二帧格式的所述预设总线帧;接收所述主节点发送的第六信息应答,且所述第六信息应答为所述第二帧格式,所述主节点包括所述第一总线方式的节点和所述第二总线方式的节点;确定采用所述第二总线方式与所述主节点进行通讯。The determining module is specifically configured to send the preset bus frame in the second frame format to the primary node, receive a sixth information response sent by the primary node, and the sixth information response is the In the second frame format, the master node includes the node of the first bus mode and the node of the second bus mode; determining to communicate with the master node by using the second bus mode.
第三方面,本发明实施例提供一种控制器局域网络CAN系统,其特征在于,包括:至少一个第一总线方式的节点和至少一个第二总线方式的节点,其中,所述第一总线方式的节点采用第二方面、第二方面的第一种至第三种、第六种至第九种中任一种可能的 实现方式所述的节点,所述第二总线方式的节点采用第二方面、第二方面的第一种、第四种至第七种、第十种中任一种可能的实现方式所述的节点。In a third aspect, an embodiment of the present invention provides a controller area network (CAN) system, including: at least one node of a first bus mode and at least one node of a second bus mode, wherein the first bus mode The node adopts the second aspect, the first to third of the second aspect, and the sixth to the ninth possible The node described in the implementation manner, wherein the node in the second bus mode adopts the second aspect, the first aspect of the second aspect, the fourth to the seventh, and the possible implementation manner of any one of the tenth node.
本发明实施例总线中的数据通讯方法、装置及系统,通过预设总线帧使得CAN中的节点确定进行通讯的总线方式,实现第一总线方式的节点在提升传输速率的同时兼容现有的总线方式,解决两种总线方式共存时会出现数据填充错误、CRC校验错误,导致CAN2.0节点中断当前CAN通讯的问题。The data communication method, device and system in the bus of the embodiment of the invention enable the node in the CAN to determine the bus mode for communication by presetting the bus frame, so that the node of the first bus mode is compatible with the existing bus while increasing the transmission rate. In the way, when the two bus modes coexist, data filling error and CRC check error will occur, which causes the CAN2.0 node to interrupt the current CAN communication problem.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description of the drawings used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any inventive labor.
图1为本发明CAN系统的一个实施例的结构示意图;1 is a schematic structural view of an embodiment of a CAN system according to the present invention;
图1A为本发明实施例中的总线帧格式示意图;1A is a schematic diagram of a bus frame format in an embodiment of the present invention;
图2为本发明总线中的数据通讯方法的一个实施例的流程图;2 is a flow chart of an embodiment of a data communication method in a bus according to the present invention;
图3为本发明总线中的数据通讯方法的另一个实施例的流程图;3 is a flow chart of another embodiment of a data communication method in a bus of the present invention;
图4为本发明总线中的数据通讯方法的又一个实施例的流程图;4 is a flow chart of still another embodiment of a data communication method in a bus according to the present invention;
图5为本发明总线中的数据通讯方法的第四个实施例的流程图;5 is a flow chart of a fourth embodiment of a data communication method in a bus according to the present invention;
图6为本发明总线中的数据通讯方法的第五个实施例的流程图;6 is a flowchart of a fifth embodiment of a data communication method in a bus according to the present invention;
图7为本发明总线中的数据通讯方法的第六个实施例的流程图;7 is a flow chart of a sixth embodiment of a data communication method in a bus according to the present invention;
图8为本发明CAN节点的一个实施例的结构示意图;8 is a schematic structural diagram of an embodiment of a CAN node according to the present invention;
图9为本发明CAN节点的另一个实施例的结构示意图;9 is a schematic structural diagram of another embodiment of a CAN node according to the present invention;
图10为本发明CAN系统的另一个实施例的结构示意图;10 is a schematic structural view of another embodiment of a CAN system according to the present invention;
图11为本发明第一总线方式的节点的一个实施例的结构示意图;11 is a schematic structural diagram of an embodiment of a node in a first bus mode according to the present invention;
图12为本发明第一总线方式的节点的另一个实施例的结构示意图。FIG. 12 is a schematic structural diagram of another embodiment of a node in a first bus mode according to the present invention.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技 术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. General techniques in the art based on embodiments in the present invention All other embodiments obtained by the skilled person without creative efforts are within the scope of the present invention.
为了更方便理解以下各实施例,这里先对CAN协议进行一些简单介绍。经过多年的发展,现有业界所指的CAN协议以及本发明所指的CAN协议都是指CAN 2.0协议(以下简称“CAN 2.0”),CAN 2.0包括两个技术规范,分别是CAN 2.0A以及CAN 2.0B,其中,CAN 2.0A提供了标准的格式,使用11位ID;CAN 2.0B在标准格式上进行了扩展,使用29位ID。由于两者除在格式定义有一些小差别之外,其余处理基本一致,因此,为了说明方便,本发明以下各实施例中并不严格区分CAN 2.0A和CAN 2.0B,而统一使用CAN 2.0来进行说明。对于一些具体的举例说明,默认都是以CAN 2.0B为例,本领域技术人员可以在不付出创造性劳动的情况下基于CAN 2.0A来实现。In order to more easily understand the following embodiments, here is a brief introduction to the CAN protocol. After years of development, the existing CAN protocol and the CAN protocol referred to in the present invention refer to the CAN 2.0 protocol (hereinafter referred to as "CAN 2.0"). CAN 2.0 includes two technical specifications, namely CAN 2.0A and CAN 2.0B, in which CAN 2.0A provides a standard format using an 11-bit ID; CAN 2.0B is extended on a standard format using a 29-bit ID. Since the two have some small differences in the format definition, the rest of the processing is basically the same. Therefore, for convenience of description, the following embodiments of the present invention do not strictly distinguish between CAN 2.0A and CAN 2.0B, and uniformly use CAN 2.0. Be explained. For some specific examples, the default is to use CAN 2.0B as an example, and those skilled in the art can implement CAN 2.0A without any creative work.
下面将通过各实施例来对本发明方案进行具体描述。The solution of the present invention will be specifically described below by way of various embodiments.
实施例一 Embodiment 1
本发明实施例公开了一种基于新型CAN帧进行通信的方法,该方法应用于如图1所示的CAN网络,该CAN网络包括一个或多个传统的CAN 2.0节点(如节点3、节点4)以及本实施例所提供的一个或多个新型CAN(CAN-HW)节点,如节点1、节点2)。各个节点通过印刷电路板PCB走线或线缆连接在一起,实现总线通讯。图中所示的CAN差分线匹配电阻设置方式跟现有技术相同,这里不再赘述。Embodiments of the present invention disclose a method for communication based on a novel CAN frame, which is applied to a CAN network as shown in FIG. 1, the CAN network including one or more conventional CAN 2.0 nodes (eg, node 3, node 4) And one or more new CAN (CAN-HW) nodes provided by this embodiment, such as node 1, node 2). Each node is connected by a printed circuit board PCB trace or cable to implement bus communication. The CAN differential line matching resistors shown in the figure are set in the same manner as in the prior art, and are not described here.
CAN网络中的通信是基于CAN帧来进行,本发明实施例中,新型CAN-HW节点可以使用新的CAN帧与其他CAN-HW节点进行比现有CAN 2.0速率更快的通信,同时,又能够避免背景技术中提到的CAN-FD在与CAN 2.0节点共同工作时产出的各种错误,实现与现有的CAN2.0实现兼容。The communication in the CAN network is performed based on the CAN frame. In the embodiment of the present invention, the new CAN-HW node can use the new CAN frame to communicate with other CAN-HW nodes faster than the existing CAN 2.0 rate, and at the same time, It can avoid the various errors produced by CAN-FD mentioned in the background technology when working with CAN 2.0 nodes, and achieve compatibility with existing CAN2.0 implementation.
具体的,本发明实施例一种基于新型CAN帧进行通信的方法包括如下步骤:Specifically, a method for performing communication based on a novel CAN frame according to an embodiment of the present invention includes the following steps:
S11、生成新型CAN帧;S11. Generate a new CAN frame.
其中,新型CAN帧基于CAN 2.0帧的帧格式生成。这里的“基于”是指除本实施例下文所描述的进行了修改的内容(如某些域的定义)外,其余都可以参见现有的CAN 2.0协议定义的帧格式来进行。Among them, the new CAN frame is generated based on the frame format of the CAN 2.0 frame. Herein, "based on" refers to the content of the modification (such as the definition of some fields) described in the following embodiments, and the rest can be performed by referring to the frame format defined by the existing CAN 2.0 protocol.
参见图1A,为本实施例CAN 2.0帧以及新型CAN帧(CAN-HW)帧的格式示意图。其中,新型CAN帧包括新型数据域以及新型校验域(即图中的CRC域),新型数据域以及新型校验域分别通过对所述基于CAN 2.0帧的数据域以及校验域进行修改后得到。Referring to FIG. 1A, a schematic diagram of a format of a CAN 2.0 frame and a novel CAN frame (CAN-HW) frame according to the present embodiment. Among them, the new CAN frame includes a new data domain and a new check domain (ie, the CRC field in the figure), and the new data domain and the new check domain are respectively modified by modifying the data domain and the check domain based on the CAN 2.0 frame. get.
具体的,新型数据域包括用户数据子域以及固定数据子域,其中: Specifically, the new data domain includes a user data subdomain and a fixed data subdomain, where:
用户数据子域的作用跟现有CAN 2.0中的数据域一样,都是用于传输真正的用户数据,但在本实施例中,用户数据子域的位数大于CAN 2.0帧中的数据域的位数;在另一实施例中,用户数据子域的位数可以约等于现有CAN 2.0最大数据位个数的整数倍。例如,假设现有CAN 2.0帧最大支持8字节共64位数据,那么用户数据子域的位数可以是128位(16字节)、或者512位(64字节),或者1024位(128字节)等等。这里的“约等于”表示实际中并不要求严格相等,可以比整数倍略少,少的部分被用于固定数据子域或者其他需要扩展的子域。The user data subdomain functions as the data field in the existing CAN 2.0, and is used to transmit real user data, but in this embodiment, the number of bits of the user data subfield is larger than the data field in the CAN 2.0 frame. The number of bits; in another embodiment, the number of bits of the user data subfield may be approximately equal to an integer multiple of the number of existing CAN 2.0 maximum data bits. For example, suppose the existing CAN 2.0 frame supports a maximum of 8 bytes of 64-bit data, then the user data sub-field can be 128 bits (16 bytes), or 512 bits (64 bytes), or 1024 bits (128). Bytes) and so on. Here, "about equal" means that the actual is not required to be strictly equal, and may be slightly less than the integer multiple, and a small portion is used for the fixed data subdomain or other subdomains that need to be expanded.
固定数据子域包括多个第一固定位组,每个第一固定位组包括一个或多个连续的值相同的第一固定位(0或1),多个第一固定位组被一一设置在多个能被基于CAN 2.0协议的CAN 2.0设备(如图1中的节点3、节点4)采样CAN 2.0数据域时的采样到的位置;优选地,第一固定位组的数量跟CAN 2.0设备要采样的数据位数据的位数一样,例如,假设CAN 2.0帧中的数据域有64位数据,那么在新型CAN帧中,相应地设置64组第一固定位组。需要说明的是,本实施例中的“第一固定位组”中的前缀“第一”仅用于区分后续提到的用于其他地方(如校验域)中的固定位组,并无其他特殊含义,同理,后续提到的“第二”、“第三”之类的前缀也表示类似的含义。The fixed data subfield includes a plurality of first fixed bit groups, each of the first fixed bit groups includes one or more consecutive first fixed bits (0 or 1) having the same value, and the plurality of first fixed bit groups are one by one Set the sampled position when multiple CAN 2.0 data fields can be sampled by a CAN 2.0 device based on the CAN 2.0 protocol (such as node 3, node 4 in Figure 1); preferably, the number of first fixed bit groups is the same as CAN The number of bits of the data bit data to be sampled by the 2.0 device is the same. For example, assuming that the data field in the CAN 2.0 frame has 64 bits of data, then in the new CAN frame, 64 sets of the first fixed bit group are set accordingly. It should be noted that the prefix “first” in the “first fixed bit group” in this embodiment is only used to distinguish the fixed bit groups mentioned in the following for other places (such as the check field), and Other special meanings, similarly, the prefixes such as "second" and "third" mentioned later also have similar meanings.
本实施例中,“基于CAN 2.0协议的CAN 2.0设备”是指现有的能够处理CAN 2.0协议的各种设备,如图1中的节点3、节点4,这些CAN 2.0设备并不认识新型CAN帧的帧格式,对应于这些设备来讲,无论实际上接收到的是新型CAN设备(如节点1)发送的新型CAN帧,还是CAN 2.0设备发送的CAN 2.0帧,都按照处理CAN 2.0协议帧的方式来进行处理。本实施例中,由于每个第一固定位组被一一设置在多个CAN 2.0设备采样CAN 2.0数据域时的位置,即每个第一固定位组对应一个CAN 2.0设备的采样时刻,当CAN 2.0设备收到新型CAN帧后,如果按照CAN 2.0设备定义的方式去采样,那么采样到的就是各个第一固定位组的值(定义为该组中的任意一位的值,由于第一固定位组包括的一个或多个第一固定位的值都相同,因此,可以用“任意一位的值”来表示这个第一固定位组的值)。In this embodiment, the "CAN 2.0 device based on the CAN 2.0 protocol" refers to various devices capable of processing the CAN 2.0 protocol, such as node 3 and node 4 in FIG. 1, and these CAN 2.0 devices do not recognize the new CAN. The frame format of the frame, corresponding to these devices, whether it is actually receiving a new CAN frame sent by a new CAN device (such as Node 1) or a CAN 2.0 frame sent by a CAN 2.0 device, is processed according to the CAN 2.0 protocol frame. The way to handle it. In this embodiment, since each first fixed bit group is set one by one at a position where a plurality of CAN 2.0 devices sample the CAN 2.0 data field, that is, each first fixed bit group corresponds to a sampling time of one CAN 2.0 device, when After the CAN 2.0 device receives the new CAN frame, if it is sampled according to the way defined by the CAN 2.0 device, then the sampled is the value of each first fixed bit group (defined as the value of any bit in the group, due to the first The fixed bit group includes the same value of one or more first fixed bits, and therefore, the value of this first fixed bit group can be represented by "a value of any one bit".
下面来介绍如何设置第一固定位组的位置以及包括的固定位的个数,使得第一固定位组能够被CAN 2.0设备采样到。具体的,现有的CAN 2.0设备在采样时,可以通过配置让其以某个特定频率进行采样,并且,还可以配置在哪个相对时刻进行采样。例如,参见图1A,可以配置让CAN 2.0设备其以1MHz的频率进行发送及采样,并且,采样时刻在这个数据位所对应的信号波形的2/3处,在这种情况下,假设网络中CAN 2.0帧中的数据域为64位,新型数据域的位数经扩展后为原来的8倍,相当于原来CAN 2.0帧中的每一数 据位在相同时间内被拆分成8份,这样,在CAN 2.0设备中1us传输一个数据,经过拆分后,新型CAN设备要做到1us传输8个数据。由于在2/3处采样,经计算后,1us的2/3约等于0.667us,即对应于第6位,则可以在第6位设置固定位(如图1A所示设为固定值0)。如果新型CAN 2.0帧对原有的数据域的位数扩展得更多,此时,相当于原来CAN 2.0帧中的每个数据位在相同时间内被拆分得更多(例如拆分成32倍),此时,为了防止CAN 2.0设备时钟不够精确导致无法精确地在2/3处采样,则可以在2/3附近再增加一些位数,这样,即使CAN 2.0早采样一点时间,或者晚采样一点时间都可以把固定位的值采样到。The following describes how to set the position of the first fixed bit group and the number of fixed bits included so that the first fixed bit group can be sampled by the CAN 2.0 device. Specifically, existing CAN 2.0 devices can be configured to be sampled at a specific frequency during sampling, and at which relative time to sample. For example, referring to FIG. 1A, a CAN 2.0 device can be configured to transmit and sample at a frequency of 1 MHz, and the sampling time is at 2/3 of the signal waveform corresponding to this data bit, in which case, in the network, The data field in the CAN 2.0 frame is 64 bits, and the number of bits in the new data field is expanded by 8 times, which is equivalent to each number in the original CAN 2.0 frame. The data is split into 8 copies in the same time. In this way, 1us transmits a data in the CAN 2.0 device. After the split, the new CAN device needs to transmit 8 data for 1us. Since it is sampled at 2/3, after calculation, 2/3 of 1us is equal to 0.667us, which corresponds to the 6th bit, then a fixed bit can be set in the 6th bit (set to a fixed value of 0 as shown in Figure 1A). . If the new CAN 2.0 frame expands the number of bits in the original data field more, at this time, each data bit in the original CAN 2.0 frame is split more in the same time (for example, split into 32 In this case, in order to prevent the CAN 2.0 device clock from being inaccurate enough to accurately sample at 2/3, you can add some more bits around 2/3, so that even if CAN 2.0 samples early, or late The value of the fixed bit can be sampled at a time.
与上述对CAN 2.0帧中的数据域进行修改类似,本实施例也对CAN 2.0帧中的校验域(或者也称CRC域)进行类似的修改。修改后新型CAN帧中的新型校验域位数大于CAN 2.0帧中的校验域的位数,新型校验域包括用户数据校验子域以及固定数据校验子域,其中,用户数据校验子域的值为对用户数据子域进行校验后的第一校验值;固定数据校验子域为对各个第一固定位组的值进行校验得到的第二校验值,固定数据校验子域包括多个第二固定位组,每个第二固定位组包括一个或多个连续的值相同的第二固定位,各个第二固定位组的值(即组中任意一个固定位值)构成上述第二校验值;多个第二固定位组被一一设置在多个能被CAN 2.0设备采样CAN 2.0校验域时采样到的位置,具体设置方法跟新型数据域中对第一固定位组的设置方法类似,这里不再赘述。Similar to the above modification of the data field in the CAN 2.0 frame, this embodiment also performs similar modifications to the check field (or also referred to as the CRC field) in the CAN 2.0 frame. The new check field number in the modified CAN frame is larger than the number of check fields in the CAN 2.0 frame. The new check field includes a user data check subfield and a fixed data check subfield, wherein the user data is corrected. The value of the test field is the first check value after verifying the user data sub-domain; the fixed data check sub-domain is the second check value obtained by verifying the value of each first fixed bit group, fixed The data check subfield includes a plurality of second fixed bit groups, each second fixed bit group includes one or more consecutive second fixed bits of the same value, and the value of each second fixed bit group (ie, any one of the groups) The fixed bit value constitutes the second check value; the plurality of second fixed bit groups are one-to-one set at a position that can be sampled by the CAN 2.0 device when the CAN 2.0 check field is sampled, and the specific setting method and the new data field are set. The setting method of the first fixed bit group is similar, and will not be described here.
S12、发送所述新型CAN帧,其中,所述新型数据域以及所述新型校验域以高于CAN 2.0协议定义的最高发送速率发送。S12. Send the new CAN frame, wherein the new data domain and the new check domain are sent at a highest transmission rate than defined by the CAN 2.0 protocol.
由于本实施例对CAN 2.0帧中的数据域以及校验域进行了扩展,增加了位数,为了实现高速传输,对这些进行扩展了的域以更高的频率进行发送。例如,如果扩展到8倍,则也可以将频率提升到8倍,如果扩展到16倍,相应的,频率也可提升到16倍。当然,实际中也可以不必精确地提升到8倍或16倍,只要能够将扩展的数据位数进行发送,那么其他发送频率也是可以的。Since the data field and the check field in the CAN 2.0 frame are expanded in this embodiment, the number of bits is increased, and in order to realize high-speed transmission, the extended fields are transmitted at a higher frequency. For example, if you expand to 8 times, you can also increase the frequency to 8 times. If you expand to 16 times, the frequency can be increased to 16 times. Of course, in practice, it is not necessary to accurately increase to 8 or 16 times, as long as the extended data bits can be transmitted, other transmission frequencies are also possible.
对于其他数据域,如果没有进行扩展,则仍然按CAN 2.0协议规定的发送速率进行发送。在具体实现上,新型CAN 2.0设备相当于需要有两个寄存器来控制发送速率,一个寄存器用于控制扩展了位数,需要提升收发频率的域的收发频率,另一个寄存器跟现有的CAN 2.0速率控制寄存器一样,用于控制未进行修改的域的收发速率。For other data fields, if there is no extension, it will still be sent at the transmission rate specified by the CAN 2.0 protocol. In terms of implementation, the new CAN 2.0 device is equivalent to two registers to control the transmission rate, one register for controlling the number of bits to be expanded, the frequency of transmission and reception of the domain to be transmitted and received, and the other register to the existing CAN 2.0. Like the rate control register, it is used to control the transceiving rate of the unmodified domain.
通过将新型CAN帧发送到CAN网络后,其他新型CAN设备由于能够识别该帧,因此,可以正确接收,并且,由于在发送的时候已经扩展了CAN 2.0帧的数据域的位数,并且加大频率发送,因此,增了传输速率。同时,现有的CAN 2.0设备在接收到该帧后,可 以仍然按原来的采样方式进行采样,由于本实施例在CAN 2.0采样数据域以及校验域的位置处都是固定值,这样,CAN 2.0采样到固定数据子域的值,并进行校验计算后,其值必定与采样到的固定数据校验子域所指示的第二校验值一致,这样,就不会发生校验错误,从而实现了与CAN 2.0设备的兼容。After the new CAN frame is sent to the CAN network, other new CAN devices can correctly receive the frame because they can recognize the frame, and since the number of bits of the data field of the CAN 2.0 frame has been expanded at the time of transmission, and The frequency is transmitted, thus increasing the transmission rate. At the same time, the existing CAN 2.0 device can receive the frame. The sample is still sampled in the original sampling mode. Since this embodiment has fixed values in the CAN 2.0 sample data field and the check field position, the CAN 2.0 samples the value of the fixed data subfield and performs check calculation. After that, its value must be consistent with the second check value indicated by the sampled fixed data check subfield, so that no check error will occur, thus achieving compatibility with CAN 2.0 devices.
实施例二Embodiment 2
基于实施例一,本实施例对本方案进行更进一步的说明。Based on the first embodiment, the present embodiment further describes the solution.
由于在图1所示的组网中有两种CAN帧(CAN设备),为了区分这两种帧,本实施例中,新型CAN帧还可以包括:用于指示CAN帧类型的类型指示子域,用于表明是CAN 2.0帧,或者新型帧。Since there are two CAN frames (CAN devices) in the networking shown in FIG. 1, in order to distinguish the two frames, in this embodiment, the new CAN frame may further include: a type indicating subfield for indicating a CAN frame type. Used to indicate that it is a CAN 2.0 frame, or a new frame.
类型指标子域可以由仲裁域中预留位来实现,例如,利用预留的两位,00表示CAN 2.0帧,11表示新型帧,当然,在这种情况下,CAN 2.0软件也需要对这些预留位进行判断,以判断接收到的是哪种帧格式。The type indicator subdomain can be implemented by reserved bits in the arbitration domain, for example, using reserved two bits, 00 for CAN 2.0 frames, and 11 for new frames, of course, in this case, CAN 2.0 software also needs these The reserved bits are judged to determine which frame format is received.
类型指标子域也可以由CAN 2.0帧中的控制域中的R1、R0两位中的至少一位来实现,通过这两位中的至少一位作为所述类型指示子域。The type indicator subfield may also be implemented by at least one of two bits R1, R0 in the control domain in the CAN 2.0 frame, with at least one of the two bits being the subtype of the type indication.
由于此时并没有对这些域的位数进行扩展,因此,这些域仍然按CAN 2.0定义的速率发送。Since the number of bits in these fields is not extended at this time, these fields are still sent at the rate defined by CAN 2.0.
本实施例中,新型CAN帧还可以包括:用于指示新型数据域中的用户数据子域位数数量的位数指示信息子域。In this embodiment, the new CAN frame may further include: a bit indication information subfield for indicating the number of bits of the user data subfield in the new data domain.
位数指示信息子域可以通过对CAN2.0中的控制域中的数据位进行扩展的方式来实现,其原理同扩展数据域的方式类似,由于进行了扩展,因此,后续也需要提升这部分的收发速率。此外,如果通过其他域中的预留位表标识,那么则不需要提升该域的收发速率。The number of bits indicates that the information sub-domain can be implemented by extending the data bits in the control domain in CAN2.0. The principle is similar to that of extending the data field. Since it is extended, it is necessary to upgrade this part later. Transceiver rate. In addition, if it is identified by a reserved bit table in other domains, there is no need to increase the transmission and reception rate of the domain.
本发明实施例中,还设置硬重同步,具体可以在新型CAN帧中的新型数据域中对应于CAN 2.0设备数据域中两位之间设置沿变。例如,新型CAN帧对CAN 2.0帧的数据域扩展了8倍,假设对CAN 2.0帧数据域第1位扩展后的8位为A1-A8,对CAN 2.0帧数据域第2位扩展后的8位为B1-B8,则可以在A8与B1这两位之间设置跳变沿,那么对应的,这两位也需要设置成固定值。In the embodiment of the present invention, hard resynchronization is also set, and specifically, the new data field in the new CAN frame corresponds to the edge change between the two bits in the data field of the CAN 2.0 device. For example, the new CAN frame extends the data field of the CAN 2.0 frame by a factor of eight, assuming that the first 8 bits of the CAN 2.0 frame data field are extended to A1-A8, and the second bit of the CAN 2.0 frame data field is expanded by 8 Bits B1-B8, you can set the transition edge between the two bits A8 and B1, then the corresponding two, also need to be set to a fixed value.
设置硬重同步可以对频率进行校验,防止由于频率偏差不停累加后导致的采样错误。 Setting the hard resynchronization can check the frequency to prevent sampling errors caused by the frequency deviation being accumulated.
实施例三Embodiment 3
基于上述各实施例,本发明实施例对具体的应用场景进行介绍。参见图1,如前述两实施例所示,第一总线方式为本发明新设计的总线方式,可以称之为CAN-HW,第二总线方式为现有的总线方式,即CAN 2.0,第一总线方式的帧格式与第二总线方式的帧格式可以兼容,即前者的帧格式与后者的帧格式相同,区别在于帧格式中填入的内容不同,因此第二总线方式的节点可以接收到两种总线方式的帧并进行解析,通过标识节点的总线类型的比特位区分帧,而第一总线方式的节点也可以接收到两种总线方式的帧,并且根据帧对应的总线类型确定进行通讯的总线方式。第一总线方式的节点可以同时采用两种总线方式,在提升传输速率的同时又兼容现有总线协议,从而实现两种总线方式混合网络的数据通讯。Based on the foregoing embodiments, the specific application scenarios are introduced in the embodiment of the present invention. Referring to FIG. 1, as shown in the foregoing two embodiments, the first bus mode is a newly designed bus mode, which may be referred to as CAN-HW, and the second bus mode is an existing bus mode, that is, CAN 2.0, first. The frame format of the bus mode is compatible with the frame format of the second bus mode, that is, the frame format of the former is the same as the frame format of the latter, and the difference is that the content filled in the frame format is different, so the node of the second bus mode can receive The two bus mode frames are parsed and the frame is identified by the bit type of the bus type identifying the node, and the node of the first bus mode can also receive the frames of the two bus modes, and the communication is determined according to the bus type corresponding to the frame. The way of the bus. The first bus mode node can adopt two bus modes at the same time, and is compatible with the existing bus protocol while improving the transmission rate, thereby realizing data communication of the two bus mode hybrid networks.
图2为本发明总线中的数据通讯方法的一个实施例的流程图,如图2所示,本实施例的方法适用于图1所示的应用场景,该方法可以包括:2 is a flowchart of an embodiment of a data communication method in a bus of the present invention. As shown in FIG. 2, the method in this embodiment is applicable to the application scenario shown in FIG. 1, and the method may include:
步骤101、节点根据预设总线帧确定数据通讯的总线方式;Step 101: The node determines a bus manner of data communication according to the preset bus frame.
本实施例中,所述预设总线帧的帧格式包括第一帧格式和第二帧格式,所述第一帧格式与所述第一总线方式对应,所述第二帧格式与所述第二总线方式对应,所述预设总线帧包括身份标识,所述身份标识中有预设个数个比特位用于标识所述帧格式。执行主体节点可以是图1中的任意一个节点。本发明设计第一帧格式:第一帧格式中的仲裁域、确认字符(Acknowledgement,简称:ACK)域和帧结束位与第二帧格式(CAN 2.0格式)相应的域兼容;设计第一帧格式中的控制域和仲裁域的预留比特位,使得第一总线方式的节点可以自动识别总线类型功能,并进行帧格式切换;设计第一帧格式中的数据域和CRC域,可以将PHY的速率提升为原来的N倍(N可以为1、2、3…);在设计数据域和CRC域时,对第二帧格式采用固定位置填充比特位的方式确保不会导致第二总线方式的节点误产生比特位错误、CRC校验错误,从而引发通讯中断。预设总线帧有两种格式,分别与上述两种总线方式对应,通过预设总线帧节点即可确定其对应的总线方式。In this embodiment, the frame format of the preset bus frame includes a first frame format and a second frame format, where the first frame format corresponds to the first bus mode, and the second frame format and the first frame format Corresponding to the two-bus mode, the preset bus frame includes an identity identifier, and the identifier has a preset number of bits for identifying the frame format. The execution subject node may be any one of the nodes in FIG. The first frame format of the present invention is designed: the arbitration field, the Acknowledgement (ACK) field and the frame end bit in the first frame format are compatible with the corresponding fields of the second frame format (CAN 2.0 format); The reserved bits of the control domain and the arbitration domain in the format enable the nodes of the first bus mode to automatically recognize the bus type function and perform frame format switching; design the data domain and the CRC domain in the first frame format, and the PHY can be The rate is increased by N times (N can be 1, 2, 3...); when designing the data field and the CRC field, the second frame format is fixed bit-filled to ensure that the second bus mode is not caused. The node incorrectly generates a bit error and a CRC check error, thereby causing a communication interruption. The preset bus frame has two formats, which respectively correspond to the above two bus modes, and the corresponding bus mode can be determined by presetting the bus frame node.
步骤102、所述节点采用与确定的所述数据通讯的总线方式对应的帧格式进行通讯。Step 102: The node performs communication by using a frame format corresponding to the determined bus mode of the data communication.
节点在确定了总线方式后,即可采用该总线方式,并用该总线方式对应的帧格式与其他节点进行通讯,即若该节点是第一总线方式的节点,则该节点可以采用第一总线方式向其他第一总线方式的节点发送第一帧格式的预设总线帧,还可以采用第二总线方式向其他第二总线方式的节点发送第二帧格式的预设总线帧;若该节点是第二总线方式的 节点,则该节点只可以采用第二总线方式向其他节点发送第二帧格式的预设总线帧,由于第一总线方式的节点可以以两种总线方式进行通讯,因此这里的其他节点可以包括第一总线方式的节点和第二总线方式的节点。After the node determines the bus mode, the bus mode can be adopted, and the frame format corresponding to the bus mode is used to communicate with other nodes, that is, if the node is a node of the first bus mode, the node can adopt the first bus mode. Sending a preset bus frame of the first frame format to the nodes of the other first bus mode, and sending the preset bus frame of the second frame format to the nodes of the other second bus mode by using the second bus mode; if the node is the first Two-bus mode Node, the node can only send the preset bus frame of the second frame format to other nodes by using the second bus mode. Since the nodes of the first bus mode can communicate in two bus modes, other nodes here may include the A bus mode node and a second bus mode node.
本实施例,通过预设总线帧使得CAN中的节点确定进行通讯的总线方式,实现第一总线方式的节点在提升PHY的速率的同时兼容现有的总线方式,解决两种总线方式共存时会出现数据填充错误、CRC校验错误,导致CAN 2.0节点中断当前CAN通讯的问题。In this embodiment, by presetting the bus frame, the node in the CAN determines the bus mode for communication, and the node of the first bus mode is compatible with the existing bus mode while improving the rate of the PHY, and solves the problem that the two bus modes coexist. A data fill error and a CRC check error occurred, causing the CAN 2.0 node to interrupt the current CAN communication problem.
进一步的,上述实施例中的节点为主节点,则步骤101具体的实现方法可以是:所述节点在预设轮询时间到达的时刻,根据所述预设总线帧确定所述数据通讯的总线方式;步骤102具体的实现方法可以是:所述节点在所述预设轮询时间未到达的时刻,采用与所述数据通讯的总线方式对应的帧格式进行通讯。Further, the node in the foregoing embodiment is a master node, and the specific implementation method of step 101 may be: the node determines the bus of the data communication according to the preset bus frame at a time when the preset polling time arrives. The specific implementation method of step 102 may be: the node communicates with a frame format corresponding to the bus mode of the data communication when the preset polling time has not arrived.
具体来讲,上述过程根据节点的不同,可以有两种实现流程。下面详细说明。Specifically, the above process may have two implementation processes depending on the node. The details are explained below.
一种是所述节点为主节点且为所述第一总线方式的节点,所述节点在所述预设轮询时间到达的时刻,采用所述第一帧格式的所述预设总线帧对所有其他节点进行轮询;所述节点接收第一信息应答,所述第一信息应答为所述第一帧格式;所述节点根据所述第一信息应答获取发送所述第一信息应答的节点的所述身份标识,并将所述发送所述第一信息应答的节点确定为所述第一总线方式的节点,确定采用所述第一总线方式与所述第一总线方式的节点进行通讯;所述节点在所述预设轮询时间到达的时刻,采用所述第二帧格式的所述预设总线帧对除所述确定为所述第一总线方式的节点外的其他节点进行轮询;所述节点接收第二信息应答,所述第二信息应答为所述第二帧格式;所述节点根据所述第二信息应答获取发送所述第二信息应答的节点的所述身份标识,并将所述发送所述第二信息应答的节点确定为所述第二总线方式的节点,确定采用所述第二总线方式与所述第二总线方式的节点进行通讯。所述节点在所述预设轮询时间未到达的时刻,通过所述第一帧格式以所述第一总线方式与所述第一总线方式的节点进行通讯;和/或,所述节点在所述预设轮询时间未到达的时刻,通过所述第二帧格式以所述第二总线方式与所述第二总线方式的节点进行通讯。One is that the node is a node of the first bus mode, and the node adopts the preset bus frame pair of the first frame format at a time when the preset polling time arrives. All other nodes perform polling; the node receives a first information response, the first information response is in the first frame format; and the node acquires a node that sends the first information response according to the first information response Determining, by the node that sends the first information response, the node in the first bus mode, and determining to communicate with the node in the first bus mode by using the first bus mode; The node polls other nodes except the node determined to be the first bus mode by using the preset bus frame in the second frame format at a time when the preset polling time arrives. The node receives the second information response, the second information response is the second frame format, and the node obtains the identity identifier of the node that sends the second information response according to the second information response. The second node transmitting the response information is determined as a node of the second embodiment of the bus, the second bus mode is determined using the second bus node communication mode. And the node communicates with the node of the first bus mode by using the first frame format by the first frame format at a time when the preset polling time does not arrive; and/or, the node is When the preset polling time has not arrived, the second bus format communicates with the node of the second bus mode by using the second bus mode.
图3为本发明总线中的数据通讯方法的另一个实施例的流程图,如图3所示,本实施例的方法适用于图1所示的应用场景,第一总线方式的节点1作为主节点,该方法可以包括:FIG. 3 is a flowchart of another embodiment of the data communication method in the bus of the present invention. As shown in FIG. 3, the method in this embodiment is applicable to the application scenario shown in FIG. 1, and the node 1 in the first bus mode is used as the main Node, the method can include:
s201、节点1启动轮询任务,周期判断预设轮询时间是否到达; S201, node 1 starts a polling task, and periodically determines whether the preset polling time arrives;
当第一总线方式的节点作为主节点,采用令牌方式与CAN中其他节点通讯。节点1通过应用层软件启动定时轮询寻址功能,启动方式可以是上电启动或定时器计时,节点1在轮询时间到达的时刻即对CAN中的所有地址进行轮询,所有地址对应于CAN中的所有节点。When the node of the first bus mode acts as the master node, the token is used to communicate with other nodes in the CAN. Node 1 initiates the timed polling addressing function through the application layer software. The startup mode can be power-on startup or timer timing. Node 1 polls all addresses in the CAN at the time when the polling time arrives. All addresses correspond to All nodes in CAN.
s202、节点1在预设轮询时间到达的时刻,采用第一帧格式的预设总线帧对节点2(3、4)进行轮询;S202: Node 1 polls node 2 (3, 4) by using a preset bus frame in a first frame format at a time when the preset polling time arrives;
节点1首先采用第一帧格式轮询所有的节点,本实施例中即为向节点2(3、4)发送第一帧格式的预设总线帧。The node 1 first polls all the nodes in the first frame format. In this embodiment, the preset bus frame in the first frame format is sent to the node 2 (3, 4).
s203、节点2采用第一帧格式向节点1发送第一信息应答;S203. Node 2 sends a first information response to node 1 in a first frame format.
节点2可以同时接收并解析第一帧格式和第二帧格式,根据预设总线帧中的总线类型比特位确定接收到的第一帧格式的,因此节点2自动设置成第一帧格式向节点1发送第一信息应答。The node 2 can simultaneously receive and parse the first frame format and the second frame format, and determine the received first frame format according to the bus type bit in the preset bus frame, so the node 2 automatically sets the first frame format to the node. 1 Send the first message response.
s204、节点3(4)不对节点1发送的第一帧格式的预设总线帧进行应答;S204, node 3 (4) does not respond to the preset bus frame of the first frame format sent by the node 1;
节点3(4)收到第一帧结构的预设总线帧后通过ID滤波功能,不对来自节点1的第一帧结构的预设总线帧进行处理,可以直接丢弃该帧,并且不对该预设总线帧进行应答。After receiving the preset bus frame of the first frame structure, the node 3 (4) passes the ID filtering function, and does not process the preset bus frame of the first frame structure from the node 1, and may directly discard the frame, and the preset is not The bus frame is answered.
s205、节点1根据第一信息应答获取发送第一信息应答的节点2的ID,并将节点2确定为第一总线方式的节点,确定采用第一总线方式与节点2进行通讯;S205, the node 1 obtains the ID of the node 2 that sends the first information response according to the first information response, and determines the node 2 as the node of the first bus mode, and determines to communicate with the node 2 by using the first bus mode;
节点1上应用软件提取CAN中的第一信息应答,获取发送第一信息应答的节点2的ID,节点1可以通过建表的方式将所有发送第一信息应答的节点归为第一总线方式的节点,建表A,本实施例中即为节点2,节点1由表A的变化刷新CAN中新插入或删除节点。The application software on the node 1 extracts the first information response in the CAN, and obtains the ID of the node 2 that sends the first information response. The node 1 can classify all the nodes that send the first information response into the first bus mode by means of table construction. Node, table A, in this embodiment is node 2, node 1 refreshes the newly inserted or deleted node in CAN by the change of table A.
s206、节点1在预设轮询时间到达的时刻,采用第二帧格式的预设总线帧对节点3(4)进行轮询;S206: Node 1 polls node 3 (4) by using a preset bus frame in a second frame format at a time when the preset polling time arrives;
节点1再采用第二帧格式轮询除表A中的节点外的节点,本实施例中即为向节点3(4)发送第二帧格式的预设总线帧。The node 1 then uses the second frame format to poll the node except the node in the table A. In this embodiment, the preset bus frame in the second frame format is sent to the node 3 (4).
s207、节点3(4)采用第二帧格式向节点1发送第二信息应答;S207, node 3 (4) sends a second information response to node 1 in a second frame format;
节点3(4)可以对第二帧格式的预设总线帧进行解析,因此节点3(4)采用第二帧格式向节点1发送第二信息应答。Node 3 (4) can parse the preset bus frame of the second frame format, so node 3 (4) sends a second information response to node 1 in the second frame format.
s208、节点1根据第二信息应答获取发送第二信息应答的节点3(4)的ID,并将节点3(4)确定为第二总线方式的节点,确定采用第二总线方式与节点3(4)进行通讯; S208. The node 1 obtains the ID of the node 3(4) that sends the second information response according to the second information response, and determines the node 3(4) as the node of the second bus mode, and determines to adopt the second bus mode and the node 3 ( 4) conducting communication;
节点1上应用软件提取CAN中的第二信息应答,获取发送第二信息应答的节点3(4)的ID,节点1同样可以通过建表的方式将所有发送第二信息应答的节点归为第二总线方式的节点,建表B,本实施例中即为节点3(4),节点1由表B的变化刷新CAN中新插入或删除节点。The application software on the node 1 extracts the second information response in the CAN, and obtains the ID of the node 3 (4) that sends the second information response. The node 1 can also classify all the nodes that send the second information response by the method of establishing the table. The node of the two bus mode, the table B is constructed, in this embodiment, the node 3 (4), and the node 1 refreshes the newly inserted or deleted node in the CAN by the change of the table B.
s209、节点1在预设轮询时间未到达的时刻,通过第一帧格式以第一总线方式与节点2进行通讯;S209, node 1 communicates with node 2 in a first bus manner by using a first frame format at a time when the preset polling time has not arrived;
节点1上应用层软件判断未启动轮询,节点1如果是与表A中节点(节点2)通讯,可以通过软件主动设置帧格式的方式采用第一帧格式与节点2进行通讯。The application layer software on the node 1 determines that the polling is not started. If the node 1 communicates with the node (node 2) in the table A, the first frame format can be used to communicate with the node 2 by the software actively setting the frame format.
s210、节点1在预设轮询时间未到达的时刻,通过第二帧格式以第二总线方式与节点3(4)进行通讯。S210: Node 1 communicates with node 3 (4) in a second bus mode by using a second frame format at a time when the preset polling time has not arrived.
节点1上应用层软件判断未启动轮询,节点1如果是与表B中节点(节点3(4))通讯,可以通过软件主动设置帧格式的方式采用第二帧格式与节点3(4)进行通讯。The application layer software on node 1 determines that polling is not started. If node 1 is in communication with the node in node B (node 3 (4)), the second frame format and node 3 (4) can be adopted by the software to actively set the frame format. Communicate.
另一种是所述节点为主节点且为所述第二总线方式的节点,所述节点在所述预设轮询时间到达的时刻,采用所述第二帧格式的所述预设总线帧对所有其他节点进行轮询;所述节点接收第三信息应答,所述第三信息应答为所述第二帧格式;所述节点根据所述第三信息应答获取发送所述第三信息应答的节点的所述身份标识,并将所述发送所述第三信息应答的节点确定为所述第二总线方式的节点,确定采用所述第二总线方式与所述第二总线方式的节点进行通讯。所述节点在所述预设轮询时间未到达的时刻,通过所述第二帧格式以所述第二总线方式与所述第二总线方式的节点进行通讯。The other is that the node is a node of the second bus mode, and the node adopts the preset bus frame of the second frame format at a time when the preset polling time arrives. Polling all other nodes; the node receives a third information response, the third information response is in the second frame format; and the node acquires the third information response according to the third information response Determining the identity of the node, and determining, by the node that sends the third information response, a node of the second bus mode, and determining to communicate with the node of the second bus mode by using the second bus mode . The node communicates with the node of the second bus mode in the second bus mode by using the second frame format at a time when the preset polling time has not arrived.
图4为本发明总线中的数据通讯方法的又一个实施例的流程图,如图4所示,本实施例的方法适用于图1所示的应用场景,第二总线方式的节点3作为主节点,该方法可以包括:4 is a flowchart of still another embodiment of the data communication method in the bus of the present invention. As shown in FIG. 4, the method in this embodiment is applicable to the application scenario shown in FIG. 1, and the node 3 in the second bus mode is used as the main Node, the method can include:
s301、节点3启动轮询任务,周期判断预设轮询时间是否到达;S301, node 3 starts a polling task, and periodically determines whether the preset polling time arrives;
当第二总线方式的节点作为主节点,采用令牌方式与CAN中其他节点通讯。节点3通过应用层软件启动定时轮询寻址功能,启动方式可以是上电启动或定时器计时,节点3在轮询时间到达的时刻即对CAN中的所有地址进行轮询,所有地址对应于CAN中的所有节点。When the node of the second bus mode acts as the master node, the token is used to communicate with other nodes in the CAN. Node 3 initiates a timed polling addressing function through the application layer software. The startup mode may be a power-on startup or a timer timing. Node 3 polls all addresses in the CAN at the time when the polling time arrives, and all addresses correspond to All nodes in CAN.
s302、节点3在预设轮询时间到达的时刻,采用第二帧格式的预设总线帧对节点1(2、4)进行轮询; S302: The node 3 polls the node 1 (2, 4) by using a preset bus frame in the second frame format at a time when the preset polling time arrives;
节点3是第二总线方式的节点,只支持第二帧格式,因此节点3采用第二帧格式轮询所有的节点,本实施例中即为向节点1(2、4)发送第二帧格式的预设总线帧。The node 3 is a node of the second bus mode and only supports the second frame format. Therefore, the node 3 polls all the nodes in the second frame format. In this embodiment, the second frame format is sent to the node 1 (2, 4). Preset bus frame.
s303、节点1(2)采用第二帧格式向节点3发送第三信息应答;S303, node 1 (2) sends a third information response to node 3 in a second frame format;
节点1(2)可以同时接收并解析第一帧格式和第二帧格式,根据预设总线帧中的总线类型比特位确定接收到的第二帧格式的,因此节点1(2)自动设置成第二帧格式向节点3发送第三信息应答。Node 1 (2) can simultaneously receive and parse the first frame format and the second frame format, and determine the received second frame format according to the bus type bits in the preset bus frame, so node 1 (2) is automatically set to The second frame format sends a third information response to node 3.
s304、节点4采用第二帧格式向节点3发送第三信息应答;S304, the node 4 sends a third information response to the node 3 by using the second frame format;
节点4只能处理第二帧格式,根据预设总线帧中的总线类型比特位确定接收到的第二帧格式的,因此节点4自动设置成第二帧格式向节点3发送第三信息应答。The node 4 can only process the second frame format, and determines the received second frame format according to the bus type bits in the preset bus frame, so the node 4 automatically sets the second frame format to send the third information response to the node 3.
s305、节点3根据第三信息应答获取发送第三信息应答的节点1(2、4)的ID,并确定采用第二总线方式与节点1(2、4)进行通讯;S305, the node 3 obtains the ID of the node 1 (2, 4) that sends the third information response according to the third information response, and determines to communicate with the node 1 (2, 4) by using the second bus mode;
节点3上应用软件提取CAN中的第三信息应答,获取发送第三信息应答的节点1(2、4)的ID,节点3可以通过建表的方式将所有发送第三信息应答的节点归为第二总线方式的节点,建表C,本实施例中即为节点1(2、4),节点3由表C的变化刷新CAN中新插入或删除节点。The application software on the node 3 extracts the third information response in the CAN, acquires the ID of the node 1 (2, 4) that sends the third information response, and the node 3 can classify all the nodes that send the third information response by means of table construction. The node of the second bus mode, the table C is constructed, in this embodiment, the node 1 (2, 4), and the node 3 refreshes the newly inserted or deleted node in the CAN by the change of the table C.
s306、节点3在预设轮询时间未到达的时刻,通过第二帧格式以第二总线方式与节点1(2、4)进行通讯。S306. The node 3 communicates with the node 1 (2, 4) in a second bus manner by using the second frame format at a time when the preset polling time has not arrived.
节点3上应用层软件判断未启动轮询,节点3与表C中节点(1(2、4))通讯,可以通过软件主动设置帧格式的方式采用第二帧格式与节点1(2、4)进行通讯。The application layer software on node 3 determines that polling is not started, and node 3 communicates with the node (1 (2, 4)) in table C, and the second frame format and node 1 can be adopted by the software to actively set the frame format (2, 4). ) to communicate.
进一步的,上述实施例中的节点为从节点,则步骤101具体的实现方法可以是:所述节点主动向主节点发起握手通讯,根据所述预设总线帧确定所述数据通讯的总线方式。Further, the node in the foregoing embodiment is a slave node, and the specific implementation method of step 101 may be: the node actively initiates a handshake communication to the master node, and determines a bus mode of the data communication according to the preset bus frame.
具体来讲,上述过程根据节点的不同,可以有三种实现流程。下面详细说明。Specifically, the above process may have three implementation processes depending on the node. The details are explained below.
一种是所述节点为从节点且为所述第一总线方式的节点,所述节点向所述主节点发送所述第一帧格式的所述预设总线帧;所述节点接收所述主节点发送的第四信息应答,且所述第四信息应答为所述第一帧格式;所述节点确定所述主节点为所述第一总线方式的节点,并采用所述第一总线方式与所述主节点进行通讯。One is that the node is a slave node and is a node of the first bus mode, and the node sends the preset bus frame in the first frame format to the master node; the node receives the master The fourth information sent by the node is replied, and the fourth information response is in the first frame format; the node determines that the primary node is a node in the first bus mode, and adopts the first bus mode and The master node communicates.
这种情况是主节点为第一总线方式的节点,当第一总线方式的从节点主动发起握手通讯的时候,还不知道主节点是什么类型的节点,因此可以先发送第一帧格式的预设总线帧,如果第一总线方式的从节点收到了主节点发送的第一帧格式的第四信息应答,说 明主节点是可以解析出从节点发送的预设总线帧的,而这种节点只有第一总线方式的节点才可以做到,因此从节点就可以以第一总线方式与主节点进行通讯。In this case, the master node is the node of the first bus mode. When the slave node of the first bus mode actively initiates the handshake communication, it does not know what type of node the master node is, so the first frame format pre-transmission can be sent first. Setting a bus frame, if the slave node of the first bus mode receives the fourth information response of the first frame format sent by the master node, The master node can parse the preset bus frame sent by the slave node, and the node can only be implemented by the node of the first bus mode, so the slave node can communicate with the master node in the first bus mode.
图5为本发明总线中的数据通讯方法的第四个实施例的流程图,如图5所示,本实施例的方法适用于图1所示的应用场景,第一总线方式的节点1作为从节点,第一总线方式的节点2作为主节点,该方法可以包括:FIG. 5 is a flowchart of a fourth embodiment of the data communication method in the bus of the present invention. As shown in FIG. 5, the method in this embodiment is applicable to the application scenario shown in FIG. The slave node, the node 2 of the first bus mode is used as the master node, and the method may include:
s401、从节点1发起握手通讯,向主节点2发送第一帧格式的预设总线帧;S401. Initiating a handshake communication from the node 1, and sending a preset bus frame in a first frame format to the master node 2;
s402、主节点2采用第一帧格式向从节点1发送第四信息应答;S402. The master node 2 sends a fourth information response to the slave node 1 in a first frame format.
s403、从节点1确定主节点2为第一总线方式的节点;S403. Determine, from the node 1, that the master node 2 is a node in a first bus mode;
s404、从节点1采用第一总线方式与主节点2进行通讯。S404, the slave node 1 communicates with the master node 2 by using the first bus mode.
优选的,主节点2可以根据最近的一次收到的从节点1的预设总线帧的类型与从节点1进行通讯。Preferably, the master node 2 can communicate with the slave node 1 according to the type of the preset bus frame of the slave node 1 received last time.
另一种是所述节点为从节点且为所述第一总线方式的节点,所述节点向所述主节点发送所述第一帧格式的所述预设总线帧;所述节点在预设超时之后还没有接收到所述主节点发送的所述第四信息应答,则所述节点确定所述主节点为所述第二总线方式的节点,并向所述主节点发送所述第二帧格式的所述预设总线帧;所述节点接收所述主节点发送的第五信息应答,且所述第五信息应答为所述第二帧格式;所述节点确定采用所述第二总线方式与所述主节点进行通讯。The other is that the node is a slave node and is a node of the first bus mode, and the node sends the preset bus frame in the first frame format to the master node; the node is preset After the timeout has not received the fourth information response sent by the primary node, the node determines that the primary node is a node of the second bus mode, and sends the second frame to the primary node. The preset bus frame of the format; the node receives a fifth information response sent by the primary node, and the fifth information response is in the second frame format; the node determines to adopt the second bus mode Communicate with the master node.
这种情况是主节点为第二总线方式的节点,当第一总线方式的从节点主动发起握手通讯的时候,先发送第一帧格式的预设总线帧,而从节点在预设超时之后还是没有收到主节点的应答,说明主节点没有对从节点发送的第一帧结构的预设总线帧进行应答,优选的,从节点在发出第一帧格式的预设总线帧的同时即可启动定时器。通常情况下第二总线方式的节点是无法对第二帧结构进行解析处理的,因此从节点可以认为主节点是第二总线方式的节点,向其发送第二帧结构的预设总线帧,主节点收到该预设总线帧后根据其ID中的总线类型比特位识别出该帧并发送第二帧结构的第五信息应答,当从节点收到该第五信息应答后,即可采用第二总线方式与主节点进行通讯。In this case, the master node is a node in the second bus mode. When the slave node in the first bus mode actively initiates the handshake communication, the preset bus frame in the first frame format is sent first, and the slave node still after the preset timeout. The master node does not receive a response, indicating that the master node does not respond to the preset bus frame of the first frame structure sent from the node. Preferably, the slave node can start at the same time as the preset bus frame in the first frame format. Timer. Generally, the second bus mode node cannot parse the second frame structure, so the slave node can consider the master node to be the second bus mode node, and send the preset bus frame of the second frame structure to the master. After receiving the preset bus frame, the node identifies the frame according to the bus type bit in the ID and sends a fifth information response of the second frame structure. After receiving the fifth information response from the node, the node may adopt the first The second bus mode communicates with the master node.
图6为本发明总线中的数据通讯方法的第五个实施例的流程图,如图6所示,本实施例的方法适用于图1所示的应用场景,第一总线方式的节点1作为从节点,第二总线方式的节点3作为主节点,该方法可以包括:FIG. 6 is a flowchart of a fifth embodiment of a data communication method in a bus according to the present invention. As shown in FIG. 6, the method in this embodiment is applicable to the application scenario shown in FIG. The slave node, the node 3 of the second bus mode is used as the master node, and the method may include:
s501、从节点1发起握手通讯,向主节点3发送第一帧格式的预设总线帧;S501: Initiating a handshake communication from the node 1, and sending, to the master node 3, a preset bus frame in a first frame format;
s502、主节点3不对从节点1发送的第一帧格式的预设总线帧进行应答; S502: The master node 3 does not respond to the preset bus frame of the first frame format sent from the node 1;
s503、从节点1在预设超时后再向主节点3发送第二帧格式的预设总线帧;S503. After the preset timeout, the slave node 1 sends the preset bus frame of the second frame format to the master node 3;
s504、主节点3采用第二帧格式向从节点1发送第五信息应答;S504. The master node 3 sends a fifth information response to the slave node 1 by using a second frame format.
s505、从节点1确定主节点3为第二总线方式的节点;S505, determining, from the node 1, that the master node 3 is a node in a second bus mode;
s506、从节点1采用第二总线方式与主节点3进行通讯。S506, the slave node 1 communicates with the master node 3 by using the second bus mode.
还有一种是所述节点为从节点且为所述第二总线方式的节点,所述节点向所述主节点发送所述第二帧格式的所述预设总线帧;所述节点接收所述主节点发送的第六信息应答,且所述第六信息应答为所述第二帧格式,所述主节点包括所述第一总线方式的节点和所述第二总线方式的节点;所述节点确定采用所述第二总线方式与所述主节点进行通讯。Still another is that the node is a slave node and is a node of the second bus mode, the node sends the preset bus frame in the second frame format to the master node; the node receives the The sixth information sent by the primary node is responsive, and the sixth information response is in the second frame format, and the primary node includes the node in the first bus mode and the node in the second bus mode; Determining to communicate with the master node by using the second bus mode.
这种情况的主节点既可以是第一总线方式的节点,也可以是第二总线方式的节点,当第二总线方式的从节点主动发起握手通讯的时候,只能发送第二帧结构的预设总线帧,如果主节点是第一总线方式的节点,在收到从节点发送的第二帧结构的预设总线帧后,可以相应的设置为第二总线方式,返回第二帧格式的第六信息应答,如果主节点是第二总线方式的节点,在收到从节点发送的第二帧结构的预设总线帧后,可以对其识别并解析,因此也可以返回第二帧格式的第六信息应答。从节点则采用第二总线方式与主节点进行通讯。The master node in this case can be either the first bus mode node or the second bus mode node. When the slave node in the second bus mode actively initiates the handshake communication, only the second frame structure pre-transmission can be sent. Set the bus frame. If the master node is the node of the first bus mode, after receiving the preset bus frame of the second frame structure sent from the node, it may be correspondingly set to the second bus mode, and return to the second frame format. Six information response, if the master node is a node of the second bus mode, after receiving the preset bus frame of the second frame structure sent by the slave node, it can be identified and parsed, so the second frame format can also be returned. Six information responses. The slave node communicates with the master node using the second bus mode.
图7为本发明总线中的数据通讯方法的第六个实施例的流程图,如图7所示,本实施例的方法适用于图1所示的应用场景,第二总线方式的节点3作为从节点,第一总线方式的节点1作为主节点,该方法可以包括:FIG. 7 is a flowchart of a sixth embodiment of a data communication method in a bus according to the present invention. As shown in FIG. 7, the method in this embodiment is applicable to the application scenario shown in FIG. 1, and the node 3 in the second bus mode is used as The slave node, the node 1 of the first bus mode is used as the master node, and the method may include:
s601、从节点3发起握手通讯,向主节点1发送第二帧格式的预设总线帧;S601, initiating handshake communication from node 3, and sending a preset bus frame in a second frame format to the master node 1;
s602、主节点1设置成第二帧格式向从节点3发送第六信息应答;S602. The master node 1 is configured to send a sixth information response to the slave node 3 in a second frame format.
s603、从节点3确定主节点1为第二总线方式的节点;S603, determining, from the node 3, that the master node 1 is a node of the second bus mode;
s604、从节点3采用第二总线方式与主节点1进行通讯。S604, the slave node 3 communicates with the master node 1 by using the second bus mode.
另外,第二总线方式的节点既是主节点,又是从节点的情况是现有技术,此处不再赘述。In addition, the case where the node of the second bus mode is both the master node and the slave node is a prior art, and details are not described herein again.
图8为本发明CAN节点的一个实施例的结构示意图,如图8所示,本实施例中的节点为图1所示应用场景中的任一节点,本实施例的节点可以包括:确定模块11和通讯模块12,其中,确定模块11,用于根据预设总线帧确定数据通讯的总线方式,所述预设总线帧的帧格式包括第一帧格式和第二帧格式,所述第一帧格式与所述第一总线方式对应,所述第二帧格式与所述第二总线方式对应,所述预设总线帧包括身份标识,所述身份标 识中有预设个数个比特位用于标识所述帧格式;通讯模块12,用于采用与确定的所述数据通讯的总线方式对应的帧格式进行通讯。FIG. 8 is a schematic structural diagram of an embodiment of a CAN node according to the present invention. As shown in FIG. 8, the node in this embodiment is any node in the application scenario shown in FIG. 1. The node in this embodiment may include: determining a module. And a communication module 12, wherein the determining module 11 is configured to determine a bus manner of data communication according to the preset bus frame, where the frame format of the preset bus frame includes a first frame format and a second frame format, where the first a frame format corresponding to the first bus mode, the second frame format corresponding to the second bus mode, the preset bus frame including an identity identifier, the identity tag A predetermined number of bits are used to identify the frame format, and the communication module 12 is configured to communicate by using a frame format corresponding to the determined bus mode of the data communication.
本实施例的节点,可以用于执行图2所示方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述。The node of this embodiment may be used to implement the technical solution of the method embodiment shown in FIG. 2, and the implementation principle and the technical effect are similar, and details are not described herein again.
进一步的,所述节点为从节点;所述确定模块11,具体用于主动向主节点发起握手通讯,根据所述预设总线帧确定所述数据通讯的总线方式。Further, the node is a slave node; the determining module 11 is specifically configured to initiate a handshake communication to the master node, and determine a bus mode of the data communication according to the preset bus frame.
进一步的,所述节点为所述第一总线方式的节点;所述确定模块11,具体用于向所述主节点发送所述第一帧格式的所述预设总线帧;接收所述主节点发送的第四信息应答,且所述第四信息应答为所述第一帧格式;确定所述主节点为所述第一总线方式的节点,并采用所述第一总线方式与所述主节点进行通讯。Further, the node is a node of the first bus mode; the determining module 11 is specifically configured to send the preset bus frame in the first frame format to the primary node; and receive the primary node Transmitting the fourth information response, and the fourth information response is the first frame format; determining that the primary node is the node of the first bus mode, and adopting the first bus mode and the primary node Communicate.
上述节点可以用于执行图5所示方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述。The foregoing node may be used to implement the technical solution of the method embodiment shown in FIG. 5, and the implementation principle and the technical effect are similar, and details are not described herein again.
进一步的,所述节点为所述第一总线方式的节点;所述确定模块11,具体用于向所述主节点发送所述第一帧格式的所述预设总线帧;在预设超时之后还没有接收到所述主节点发送的所述第四信息应答,则所述节点确定所述主节点为所述第二总线方式的节点,并向所述主节点发送所述第二帧格式的所述预设总线帧;接收所述主节点发送的第五信息应答,且所述第五信息应答为所述第二帧格式;确定采用所述第二总线方式与所述主节点进行通讯。Further, the node is a node of the first bus mode; the determining module 11 is specifically configured to send the preset bus frame in the first frame format to the primary node; after a preset timeout Receiving the fourth information response sent by the primary node, the node determines that the primary node is a node in the second bus mode, and sends the second frame format to the primary node. The preset bus frame receives a fifth information response sent by the master node, and the fifth information response is in the second frame format; determining to communicate with the master node by using the second bus mode.
上述节点可以用于执行图6所示方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述。The foregoing node may be used to implement the technical solution of the method embodiment shown in FIG. 6, and the implementation principle and the technical effect are similar, and details are not described herein again.
进一步的,所述节点为所述第二总线方式的节点;所述确定模块11,具体用于向所述主节点发送所述第二帧格式的所述预设总线帧;接收所述主节点发送的第六信息应答,且所述第六信息应答为所述第二帧格式,所述主节点包括所述第一总线方式的节点和所述第二总线方式的节点;确定采用所述第二总线方式与所述主节点进行通讯。Further, the node is a node of the second bus mode; the determining module 11 is specifically configured to send the preset bus frame in the second frame format to the primary node; and receive the primary node Sending the sixth information response, and the sixth information response is in the second frame format, the primary node includes the first bus mode node and the second bus mode node; determining to adopt the first The second bus mode communicates with the master node.
上述节点可以用于执行图7所示方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述。The foregoing node may be used to implement the technical solution of the method embodiment shown in FIG. 7. The implementation principle and the technical effect are similar, and details are not described herein again.
图9为本发明CAN节点的另一个实施例的结构示意图,如图9所示,本实施例中的节点为图1所示应用场景中的任一节点,本实施例的节点在图8所示节点结构的基础上,进一步地,还可以包括:判断模块13,用于启动轮询任务,并周期判断所述预设轮询时间是否到达。 FIG. 9 is a schematic structural diagram of another embodiment of a CAN node according to the present invention. As shown in FIG. 9 , the node in this embodiment is any node in the application scenario shown in FIG. 1 , and the node in this embodiment is in FIG. 8 . Based on the structure of the node, the method further includes: a determining module 13 configured to start a polling task, and periodically determine whether the preset polling time arrives.
所述节点为所述第一总线方式的节点;所述确定模块11,具体用于在所述预设轮询时间到达的时刻,采用所述第一帧格式的所述预设总线帧对所有其他节点进行轮询;接收第一信息应答,所述第一信息应答为所述第一帧格式;根据所述第一信息应答获取发送所述第一信息应答的节点的所述身份标识,并将所述发送所述第一信息应答的节点确定为所述第一总线方式的节点,确定采用所述第一总线方式与所述第一总线方式的节点进行通讯;在所述预设轮询时间到达的时刻,采用所述第二帧格式的所述预设总线帧对除所述确定为所述第一总线方式的节点外的其他节点进行轮询;接收第二信息应答,所述第二信息应答为所述第二帧格式;根据所述第二信息应答获取发送所述第二信息应答的节点的所述身份标识,并将所述发送所述第二信息应答的节点确定为所述第二总线方式的节点,确定采用所述第二总线方式与所述第二总线方式的节点进行通讯。所述通讯模块12,具体用于在所述预设轮询时间未到达的时刻,通过所述第一帧格式以所述第一总线方式与所述第一总线方式的节点进行通讯;和/或,在所述预设轮询时间未到达的时刻,通过所述第二帧格式以所述第二总线方式与所述第二总线方式的节点进行通讯。The node is a node of the first bus mode; the determining module 11 is specifically configured to use the preset bus frame pair of the first frame format at a time when the preset polling time arrives The other node performs the polling; the first information response is received, the first information response is the first frame format; and the identity identifier of the node that sends the first information response is obtained according to the first information response, and Determining, by the node that sends the first information response, as a node of the first bus mode, determining to use the first bus mode to communicate with a node of the first bus mode; in the preset polling At a time when the time arrives, the preset bus frame in the second frame format is used to poll other nodes except the node determined to be the first bus mode; and receive a second information response, the first The second information response is the second frame format; the identity identifier of the node that sends the second information response is obtained according to the second information response, and the node that sends the second information response is determined as Said node of the second embodiment of the bus, the second bus determined using means of communication with a node of the second embodiment of the bus. The communication module 12 is configured to communicate with the node of the first bus mode by using the first frame format by the first frame format at a time when the preset polling time is not reached; and Or, when the preset polling time has not arrived, communicating with the node of the second bus mode in the second bus mode by using the second frame format.
上述节点可以用于执行图3所示方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述。The foregoing node may be used to implement the technical solution of the method embodiment shown in FIG. 3, and the implementation principle and the technical effect are similar, and details are not described herein again.
所述节点为所述第二总线方式的节点;所述确定模块11,具体用于在所述预设轮询时间到达的时刻,采用所述第二帧格式的所述预设总线帧对所有其他节点进行轮询;接收第三信息应答,所述第三信息应答为所述第二帧格式;根据所述第三信息应答获取发送所述第三信息应答的节点的所述身份标识,并将所述发送所述第三信息应答的节点确定为所述第二总线方式的节点,确定采用所述第二总线方式与所述第二总线方式的节点进行通讯。所述通讯模块12,具体用于在所述预设轮询时间未到达的时刻,通过所述第二帧格式以所述第二总线方式与所述第二总线方式的节点进行通讯。The node is a node of the second bus mode; the determining module 11 is specifically configured to use the preset bus frame pair of the second frame format at a time when the preset polling time arrives The other node performs polling; receives a third information response, the third information response is in the second frame format; and acquiring, according to the third information response, the identity identifier of the node that sends the third information response, and Determining, by the node transmitting the third information response, a node of the second bus mode, and determining to communicate with the node of the second bus mode by using the second bus mode. The communication module 12 is configured to communicate with the node of the second bus mode in the second bus mode by using the second frame format at a time when the preset polling time is not reached.
上述节点可以用于执行图4所示方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述。The foregoing node may be used to implement the technical solution of the method embodiment shown in FIG. 4, and the implementation principle and the technical effect are similar, and details are not described herein again.
图10为本发明CAN系统的一个实施例的结构示意图,如图10所示,本实施例的系统包括:至少一个第一总线方式的节点11、12和至少一个第二总线方式的节点13、14,其中,所述第一总线方式的节点11、12采用图8或图9所示装置实施例的结构,其对应地,可以执行图2~图7中任一方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述;所述第二总线方式的节点13、14采用图8或图9所示装置实施例的结构,其对应 地,可以执行图2~图7中任一方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述。10 is a schematic structural diagram of an embodiment of a CAN system according to the present invention. As shown in FIG. 10, the system of this embodiment includes: at least one node 1 and 12 of a first bus mode and at least one node 13 of a second bus mode. The structure of the device embodiment shown in FIG. 8 or FIG. 9 is used in the first bus mode, and the technical solution of any of the method embodiments in FIG. 2 to FIG. The implementation principle and the technical effect are similar, and are not described herein again; the nodes 13 and 14 of the second bus mode adopt the structure of the device embodiment shown in FIG. 8 or FIG. The technical solution of the method embodiment in any of the embodiments of FIG. 2 is performed, and the implementation principle and technical effects are similar, and details are not described herein again.
图11为本发明第一总线方式的节点的一个实施例的结构示意图,如图11所示,本实施例的节点10可以包括:控制器11和CAN驱动器12,其中,控制器11可以是微控制单元(Micro Control Unit,简称:MCU)或现场可编程门阵列(Field Programmable Gate Array,简称:FPGA),用于执行图2~图7中任一方法实施例的技术方案,此处不再赘述,CAN驱动器12将控制器11的输出转换成CAN差分线的信号,输出至CAN总线,或者将CAN总线上输入的信号转换后反馈给控制器11,实现第一总线方式的节点与CAN总线网络数据交互。FIG. 11 is a schematic structural diagram of an embodiment of a node in a first bus mode according to the present invention. As shown in FIG. 11, the node 10 of this embodiment may include: a controller 11 and a CAN driver 12, where the controller 11 may be micro A control unit (Micro Control Unit, MCU for short) or a Field Programmable Gate Array (FPGA) for performing the technical solution of any one of the method embodiments of FIG. 2 to FIG. As described above, the CAN driver 12 converts the output of the controller 11 into a signal of a CAN differential line, outputs it to the CAN bus, or converts the signal input on the CAN bus to the controller 11 to implement the node of the first bus mode and the CAN bus. Network data interaction.
图12为本发明第一总线方式的节点的另一个实施例的结构示意图,如图12所示,第一总线方式的节点的控制器挂在高级高性能总线(Advanced High Performance Bus,简称:AHB)总线上,而AHB总线与控制寄存器连接,第一总线方式的节点的控制器可以包括:数据发送模块11、数据接收模块12以及控制模块13,其中,数据发送模块11还可以包括:发送缓存模块111,用于接收并缓存来自AHB的即要发送的数据,并对发送数据进行并串转换;协议选择模块112,根据控制寄存器命令选择发送数据采用的帧格式,并根据确定的帧格式对发送数据进行编码;发送模块113,根据控制寄存器命令将编码后的发送数据发给CAN驱动器;数据接收模块12还可以包括:数据帧识别模块121,用于接收CAN驱动器发送的数据,并对接收数据进行仲裁、数据帧类型识别,将处理结果反馈给控制寄存器,以使控制寄存器决定数据发送模块11是否继续发送;协议选择模块122,根据控制寄存器命令对接收数据采用对应的帧格式进行采样解调;接收缓存模块123,用于将协议选择模块解调后的接收数据进行串并转换和缓存,并提供AHB总线访问功能;控制模块13,用于实现AHB访问控制、发送帧格式发送、发送速率设置、接收数据状态查询功能。12 is a schematic structural diagram of another embodiment of a node in a first bus mode according to the present invention. As shown in FIG. 12, a controller of a node of a first bus mode is hung on an Advanced High Performance Bus (abbreviation: AHB). On the bus, the AHB bus is connected to the control register, and the controller of the node of the first bus mode may include: a data sending module 11, a data receiving module 12, and a control module 13, wherein the data sending module 11 may further include: a sending buffer The module 111 is configured to receive and buffer the data to be sent from the AHB, and perform parallel-to-serial conversion on the transmission data. The protocol selection module 112 selects a frame format used by the transmission data according to the control register command, and according to the determined frame format. Transmitting the data for encoding; the sending module 113 sends the encoded transmission data to the CAN driver according to the control register command; the data receiving module 12 may further include: a data frame identification module 121, configured to receive the data sent by the CAN driver, and receive the data Data is arbitrated, data frame type is recognized, and the processing result is fed back to the control register. The control register determines whether the data transmitting module 11 continues to transmit; the protocol selection module 122 performs sampling and demodulation on the received data according to the control frame command by using a corresponding frame format; and the receiving buffer module 123 is configured to demodulate the protocol selection module. Receiving data for serial-to-parallel conversion and buffering, and providing AHB bus access function; control module 13 for implementing AHB access control, sending frame format transmission, transmission rate setting, and receiving data status query function.
本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。One of ordinary skill in the art will appreciate that all or part of the steps to implement the various method embodiments described above may be accomplished by hardware associated with the program instructions. The aforementioned program can be stored in a computer readable storage medium. The program, when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes various media that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。 Finally, it should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that The technical solutions described in the foregoing embodiments may be modified, or some or all of the technical features may be equivalently replaced; and the modifications or substitutions do not deviate from the technical solutions of the embodiments of the present invention. range.

Claims (20)

  1. 一种基于新型CAN帧进行通信的方法,其特征在于,包括:A method for communicating based on a novel CAN frame, comprising:
    生成新型CAN帧;Generating a new CAN frame;
    其中,所述新型CAN帧基于CAN 2.0帧的帧格式生成,所述新型CAN帧包括新型数据域以及新型校验域,所述新型数据域以及新型校验域分别通过对所述基于CAN 2.0帧的数据域以及校验域进行修改后得到;Wherein, the new CAN frame is generated based on a frame format of a CAN 2.0 frame, the new CAN frame includes a novel data domain and a new check domain, and the new data domain and the new check domain respectively pass through the CAN 2.0 frame. The data field and the verification field are modified;
    所述新型数据域包括用户数据子域以及固定数据子域,所述用户数据子域的位数大于所述CAN 2.0帧中的数据域的位数;所述固定数据子域包括多个第一固定位组,每个所述第一固定位组包括一个或多个连续的值相同的第一固定位,多个第一固定位组被一一设置在多个能被基于CAN 2.0协议的CAN 2.0设备采样CAN 2.0数据域时采样到的位置;The new data field includes a user data sub-domain and a fixed data sub-domain, the user data sub-domain has a number of bits greater than a number of data fields in the CAN 2.0 frame; the fixed data sub-domain includes a plurality of first a fixed bit group, each of the first fixed bit groups includes one or more consecutive first fixed bits having the same value, and the plurality of first fixed bit groups are one by one set in a plurality of CANs capable of being CAN 2.0 based The location where the 2.0 device samples the CAN 2.0 data field;
    新型校验域包括用户数据校验子域以及固定数据校验子域,其中,用户数据校验子域的值为对所述用户数据子域进行校验后的第一校验值;所述固定数据校验子域为对各个第一固定位组的值进行校验得到的第二校验值,其中,所述固定数据校验子域包括多个第二固定位组,每个第二固定位组包括一个或多个连续的值相同的第二固定位,各个第二固定位组的值构成上述第二校验值;多个第二固定位组被一一设置在多个能被CAN 2.0设备采样CAN 2.0校验域时采样到的位置;The new check field includes a user data check subfield and a fixed data check subfield, where the value of the user data check subfield is a first check value after verifying the user data subdomain; The fixed data check subfield is a second check value obtained by verifying values of the respective first fixed bit groups, wherein the fixed data check subfield includes a plurality of second fixed bit groups, each second The fixed bit group includes one or more consecutive second fixed bits having the same value, and the values of the respective second fixed bit groups constitute the second check value; the plurality of second fixed bit groups are one-to-one set in a plurality of The position sampled by the CAN 2.0 device when sampling the CAN 2.0 check field;
    发送所述新型CAN帧,其中,所述新型数据域以及所述新型校验域以高于所述CAN 2.0协议定义的最高发送速率发送。The novel CAN frame is transmitted, wherein the new data field and the new check field are transmitted at a higher transmission rate than defined by the CAN 2.0 protocol.
  2. 如权利要求1所述的方法,其特征在于,所述新型CAN帧还包括:The method of claim 1 wherein said new CAN frame further comprises:
    用于指示发送的CAN帧类型的类型指示子域。A type indicating subfield for indicating the type of CAN frame to be transmitted.
  3. 如权利要求1-2任一所述的方法,其特征在于:类型指标子域可以由仲裁域中预留位来实现;或者由CAN 2.0帧中的控制域中的R1、R0两位中的至少一位来实现。A method according to any of claims 1-2, characterized in that the type indicator subfield can be implemented by reserved bits in the arbitration domain; or by two bits of R1, R0 in the control domain in the CAN 2.0 frame. At least one to achieve.
  4. 如权利要求1-3任一所述的方法,其特征在于:所述新型CAN帧还包括:用于指示新型数据域中的用户数据子域位数数量的位数指示信息子域。The method of any of claims 1-3, wherein the new CAN frame further comprises: a bit number indicating information subfield for indicating the number of bits of the user data subfield in the new data field.
  5. 如权利要求4所述的方法,其特征在于:位数指示信息子域可以通过对CAN2.0中的控制域中的数据位进行扩展的方式来实现,发送所述新型帧时,对扩展后的控制域采用提升后的速率进行发送。The method according to claim 4, wherein the number of bits indicating information subfield can be implemented by expanding data bits in the control domain in CAN2.0, and when the new frame is transmitted, The control domain is sent at an elevated rate.
  6. 如权利要求1-5任一所述的方法,其特征在于: A method according to any of claims 1-5, wherein:
    在发送的时候通过寄存器设置的值来确定发送的速率,包括两个寄存器,其中一个用于配置提速后发送速率;另一个用于配置基于CAN 2.0的发送速率。The rate of transmission is determined by the value set by the register at the time of transmission, including two registers, one for configuring the rate of transmission after speeding up and the other for configuring the transmission rate based on CAN 2.0.
  7. 如权利要求1-6任一所述的方法,其特征在于,还包括:设置硬重同步。The method of any of claims 1-6, further comprising: setting hard resynchronization.
  8. 如权利要求7所述的方法,其特征在于,设置硬重同步包括:在新型CAN帧中的新型数据域中对应于CAN 2.0设备数据域中两位之间设置沿变。The method of claim 7 wherein setting the hard resynchronization comprises: setting a change between two bits in a data field of the CAN 2.0 device in a new data field in the new CAN frame.
  9. 一种控制器局域网络CAN节点,其特征在于,所述CAN包括至少一个第一总线方式的节点和至少一个第二总线方式的节点,所述节点包括:A controller area network CAN node, characterized in that the CAN comprises at least one node of a first bus mode and at least one node of a second bus mode, the node comprising:
    确定模块,用于根据预设总线帧确定数据通讯的总线方式,所述预设总线帧的帧格式包括第一帧格式和第二帧格式,所述第一帧格式与所述第一总线方式对应,所述第二帧格式与所述第二总线方式对应,所述预设总线帧包括身份标识,所述身份标识中有预设个数个比特位用于标识所述帧格式;a determining module, configured to determine a bus manner of data communication according to a preset bus frame, where a frame format of the preset bus frame includes a first frame format and a second frame format, and the first frame format and the first bus mode Correspondingly, the second frame format is corresponding to the second bus mode, and the preset bus frame includes an identity identifier, where the preset identifier has a plurality of bits for identifying the frame format;
    通讯模块,用于采用与确定的所述数据通讯的总线方式对应的帧格式进行通讯。And a communication module, configured to communicate by using a frame format corresponding to the determined bus mode of the data communication.
  10. 根据权利要求9所述的节点,其特征在于,所述节点为主节点;The node according to claim 9, wherein the node is a master node;
    所述确定模块,具体用于在预设轮询时间到达的时刻,根据所述预设总线帧确定所述数据通讯的总线方式;The determining module is specifically configured to determine, according to the preset bus frame, a bus manner of the data communication, when a preset polling time arrives;
    所述通讯模块,具体用于在所述预设轮询时间未到达的时刻,采用与所述数据通讯的总线方式对应的帧格式进行通讯。The communication module is specifically configured to perform communication by using a frame format corresponding to the bus mode of the data communication when the preset polling time has not arrived.
  11. 根据权利要求10所述的节点,其特征在于,所述节点为所述第一总线方式的节点;The node according to claim 10, wherein said node is a node of said first bus mode;
    所述确定模块,具体用于在所述预设轮询时间到达的时刻,采用所述第一帧格式的所述预设总线帧对所有其他节点进行轮询;接收第一信息应答,所述第一信息应答为所述第一帧格式;根据所述第一信息应答获取发送所述第一信息应答的节点的所述身份标识,并将所述发送所述第一信息应答的节点确定为所述第一总线方式的节点,确定采用所述第一总线方式与所述第一总线方式的节点进行通讯;在所述预设轮询时间到达的时刻,采用所述第二帧格式的所述预设总线帧对除所述确定为所述第一总线方式的节点外的其他节点进行轮询;接收第二信息应答,所述第二信息应答为所述第二帧格式;根据所述第二信息应答获取发送所述第二信息应答的节点的所述身份标识,并将所述发送所述第二信息应答的节点确定为所述第二总线方式的节点,确定采用所述第二总线方式与所述第二总线方式的节点进行通讯。 The determining module is configured to: when the preset polling time arrives, use the preset bus frame in the first frame format to poll all other nodes; receive the first information response, The first information response is the first frame format; the identity identifier of the node that sends the first information response is obtained according to the first information response, and the node that sends the first information response is determined as The node of the first bus mode determines that the first bus mode is used to communicate with the node of the first bus mode; when the preset polling time arrives, the second frame format is adopted. The preset bus frame polls other nodes except the node determined to be the first bus mode; receiving a second information response, the second information response being the second frame format; The second information response acquires the identity identifier of the node that sends the second information response, and determines the node that sends the second information response as the node of the second bus mode, and determines to adopt the And second bus node of the second embodiment mode communication bus.
  12. 根据权利要求11所述的节点,其特征在于,所述通讯模块,具体用于在所述预设轮询时间未到达的时刻,通过所述第一帧格式以所述第一总线方式与所述第一总线方式的节点进行通讯;和/或,在所述预设轮询时间未到达的时刻,通过所述第二帧格式以所述第二总线方式与所述第二总线方式的节点进行通讯。The node according to claim 11, wherein the communication module is specifically configured to use the first frame format and the first bus mode at a time when the preset polling time has not arrived. a node of the first bus mode performs communication; and/or, at a time when the preset polling time has not arrived, the second bus mode and the second bus mode node by the second frame format Communicate.
  13. 根据权利要求10所述的节点,其特征在于,所述节点为所述第二总线方式的节点;The node according to claim 10, wherein said node is a node of said second bus mode;
    所述确定模块,具体用于在所述预设轮询时间到达的时刻,采用所述第二帧格式的所述预设总线帧对所有其他节点进行轮询;接收第三信息应答,所述第三信息应答为所述第二帧格式;根据所述第三信息应答获取发送所述第三信息应答的节点的所述身份标识,并将所述发送所述第三信息应答的节点确定为所述第二总线方式的节点,确定采用所述第二总线方式与所述第二总线方式的节点进行通讯。The determining module is configured to: when the preset polling time arrives, use the preset bus frame in the second frame format to poll all other nodes; receive a third information response, The third information response is the second frame format; the identity identifier of the node that sends the third information response is obtained according to the third information response, and the node that sends the third information response is determined as The node of the second bus mode determines to communicate with the node of the second bus mode by using the second bus mode.
  14. 根据权利要求12所述的节点,其特征在于,所述通讯模块,具体用于在所述预设轮询时间未到达的时刻,通过所述第二帧格式以所述第二总线方式与所述第二总线方式的节点进行通讯。The node according to claim 12, wherein the communication module is specifically configured to use the second frame format to use the second bus mode at a time when the preset polling time has not arrived. The nodes of the second bus mode communicate.
  15. 根据权利要求10~14中任一项所述的节点,其特征在于,还包括:The node according to any one of claims 10 to 14, further comprising:
    判断模块,用于启动轮询任务,并周期判断所述预设轮询时间是否到达。The determining module is configured to start a polling task, and periodically determine whether the preset polling time arrives.
  16. 根据权利要求9所述的节点,其特征在于,所述节点为从节点;The node according to claim 9, wherein said node is a slave node;
    所述确定模块,具体用于主动向主节点发起握手通讯,根据所述预设总线帧确定所述数据通讯的总线方式。The determining module is specifically configured to initiate a handshake communication to the primary node, and determine a bus manner of the data communication according to the preset bus frame.
  17. 根据权利要求16所述的节点,其特征在于,所述节点为所述第一总线方式的节点;The node according to claim 16, wherein said node is a node of said first bus mode;
    所述确定模块,具体用于向所述主节点发送所述第一帧格式的所述预设总线帧;接收所述主节点发送的第四信息应答,且所述第四信息应答为所述第一帧格式;确定所述主节点为所述第一总线方式的节点,并采用所述第一总线方式与所述主节点进行通讯。The determining module is configured to send the preset bus frame in the first frame format to the primary node, receive a fourth information response sent by the primary node, and the fourth information response is the a first frame format; determining that the master node is a node of the first bus mode, and communicating with the master node by using the first bus mode.
  18. 根据权利要求16所述的节点,其特征在于,所述节点为所述第一总线方式的节点;The node according to claim 16, wherein said node is a node of said first bus mode;
    所述确定模块,具体用于向所述主节点发送所述第一帧格式的所述预设总线帧;在预设超时之后还没有接收到所述主节点发送的所述第四信息应答,则所述节点确定所述主节点为所述第二总线方式的节点,并向所述主节点发送所述第二帧格式的所述预设总 线帧;接收所述主节点发送的第五信息应答,且所述第五信息应答为所述第二帧格式;确定采用所述第二总线方式与所述主节点进行通讯。The determining module is specifically configured to send the preset bus frame in the first frame format to the primary node; after receiving the preset timeout, the fourth information response sent by the primary node is not received yet, And the node determines that the primary node is a node of the second bus mode, and sends the preset total of the second frame format to the primary node. a line frame; receiving a fifth information response sent by the master node, and the fifth information response is in the second frame format; determining to communicate with the master node by using the second bus mode.
  19. 根据权利要求16所述的节点,其特征在于,所述节点为所述第二总线方式的节点;The node according to claim 16, wherein said node is a node of said second bus mode;
    所述确定模块,具体用于向所述主节点发送所述第二帧格式的所述预设总线帧;接收所述主节点发送的第六信息应答,且所述第六信息应答为所述第二帧格式,所述主节点包括所述第一总线方式的节点和所述第二总线方式的节点;确定采用所述第二总线方式与所述主节点进行通讯。The determining module is specifically configured to send the preset bus frame in the second frame format to the primary node, receive a sixth information response sent by the primary node, and the sixth information response is the In the second frame format, the master node includes the node of the first bus mode and the node of the second bus mode; determining to communicate with the master node by using the second bus mode.
  20. 一种控制器局域网络CAN系统,其特征在于,包括:至少一个第一总线方式的节点和至少一个第二总线方式的节点,其中,所述第一总线方式的节点采用权利要求9~12、15~18中任一项所述的节点,所述第二总线方式的节点采用权利要求9~10、13~16、19中任一项所述的节点。 A controller area network CAN system, comprising: at least one node of a first bus mode and at least one node of a second bus mode, wherein the node of the first bus mode adopts claims 9 to 12, The node according to any one of 15 to 18, wherein the node of the second bus mode adopts the node according to any one of claims 9 to 10, 13 to 16, and 19.
PCT/CN2016/073765 2015-02-17 2016-02-14 New type can frame based communication method, device and system WO2016131404A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510086524.1 2015-02-17
CN201510086524.1A CN104836636B (en) 2015-02-17 2015-02-17 The method, apparatus and system communicated based on novel CAN frame

Publications (1)

Publication Number Publication Date
WO2016131404A1 true WO2016131404A1 (en) 2016-08-25

Family

ID=53814297

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/073765 WO2016131404A1 (en) 2015-02-17 2016-02-14 New type can frame based communication method, device and system

Country Status (2)

Country Link
CN (1) CN104836636B (en)
WO (1) WO2016131404A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104836636B (en) * 2015-02-17 2019-02-26 华为技术有限公司 The method, apparatus and system communicated based on novel CAN frame
CN109905306B (en) * 2019-01-30 2021-05-18 北京深蓝同创科技有限公司 Low-cost multi-main-bus communication control system
CN111935728B (en) * 2020-07-10 2022-08-19 展讯半导体(成都)有限公司 Handshaking method, device, related equipment, storage medium and system
CN115278705A (en) * 2020-07-10 2022-11-01 展讯半导体(成都)有限公司 Communication time sequence planning method, device, related equipment, storage medium and system
CN116667971B (en) * 2023-07-28 2023-10-27 常州星宇车灯股份有限公司 CAN data message sending verification method and device, computer equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101808132A (en) * 2010-03-23 2010-08-18 武汉若比特机器人有限公司 Communication method of application layer in CAN bus system
KR20110057348A (en) * 2009-11-24 2011-06-01 한국전자통신연구원 Can communication security apparatus and can communication security method
CN104301177A (en) * 2014-10-08 2015-01-21 清华大学 CAN message abnormality detection method and system
CN104836636A (en) * 2015-02-17 2015-08-12 华为技术有限公司 Method, device and system for communication based on novel CAN frame

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1333376C (en) * 2004-03-04 2007-08-22 深圳市泛海三江电子有限公司 Fire alarm application layer data transmission method based on CAN2.0B

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20110057348A (en) * 2009-11-24 2011-06-01 한국전자통신연구원 Can communication security apparatus and can communication security method
CN101808132A (en) * 2010-03-23 2010-08-18 武汉若比特机器人有限公司 Communication method of application layer in CAN bus system
CN104301177A (en) * 2014-10-08 2015-01-21 清华大学 CAN message abnormality detection method and system
CN104836636A (en) * 2015-02-17 2015-08-12 华为技术有限公司 Method, device and system for communication based on novel CAN frame

Also Published As

Publication number Publication date
CN104836636B (en) 2019-02-26
CN104836636A (en) 2015-08-12

Similar Documents

Publication Publication Date Title
WO2016131404A1 (en) New type can frame based communication method, device and system
WO2021023093A1 (en) Sensing method and communication apparatus
CN101937253B (en) Method, device and system for clock synchronization
KR100792772B1 (en) Data transmission method and apparatus
US9674315B2 (en) Methods for dynamically binding header field identifiers in a network control protocol
RU2670605C9 (en) System and method for indicating type of response frame
US20130290580A1 (en) Method and device for serial data transmission at a switchable data rate
US11928068B2 (en) Method and apparatus for decoding oscilloscope signal and oscilloscope
WO2014173267A1 (en) Timestamp generating method, device and system
CN105893323A (en) Data reading method and data reading equipment
US10609633B2 (en) Method for triggering registrar protocol interaction, access point, and station
CN104750588A (en) Serial port communication based pressure testing method
CN108886713B (en) Data transmission method, data receiving equipment and data sending equipment
CN102546070A (en) Method and system for synchronizing a network using existing network cables
WO2016086890A1 (en) Method and device for detecting connectivity
CN106649165A (en) Method for establishingcommunication connection of embedded system and PC host
WO2015103763A1 (en) Configuration method, device and system for signalling resources
EP3662623A1 (en) Method and apparatus for conditional broadcasting of network configuration data
US7626937B2 (en) System and method for network connection detection
WO2018036421A1 (en) Network access method, access device and terminal device
US10631187B1 (en) Method and apparatus for ranging
TW201321242A (en) Digital signal transceiver, method and electrombile system thereof
WO2020030048A1 (en) Communication method and apparatus
CN106330357B (en) A kind of transfer check method, node and the system of SERDES
JP2015537437A (en) Method, apparatus, and system for obtaining an internet protocol address

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16751935

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16751935

Country of ref document: EP

Kind code of ref document: A1