CN111277455B - CAN network baud rate identification method, device, equipment and storage medium - Google Patents

CAN network baud rate identification method, device, equipment and storage medium Download PDF

Info

Publication number
CN111277455B
CN111277455B CN202010042180.5A CN202010042180A CN111277455B CN 111277455 B CN111277455 B CN 111277455B CN 202010042180 A CN202010042180 A CN 202010042180A CN 111277455 B CN111277455 B CN 111277455B
Authority
CN
China
Prior art keywords
baud rate
controller
data
preset
network
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010042180.5A
Other languages
Chinese (zh)
Other versions
CN111277455A (en
Inventor
刘均
陈质健
刘权列
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Launch Technology Co Ltd
Original Assignee
Shenzhen Launch Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Launch Technology Co Ltd filed Critical Shenzhen Launch Technology Co Ltd
Priority to CN202010042180.5A priority Critical patent/CN111277455B/en
Publication of CN111277455A publication Critical patent/CN111277455A/en
Application granted granted Critical
Publication of CN111277455B publication Critical patent/CN111277455B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0876Network utilisation, e.g. volume of load or congestion level
    • 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/4013Management of data rate on the bus
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40215Controller Area Network CAN
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40267Bus for use in transportation systems
    • H04L2012/40273Bus for use in transportation systems the transportation system being a vehicle
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Abstract

The application relates to a CAN network baud rate identification method, a device, equipment and a storage medium. The method comprises the following steps: setting the baud rate of the CAN controller according to a preset standard baud rate table; judging whether the CAN controller receives data in the CAN bus or not in a preset first time; when the CAN controller CAN receive data in a preset first time, identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate and recording the baud rate enabling the CAN controller to receive the data; and when the CAN controller cannot receive data in the preset first time and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the standard baud rate table.

Description

CAN network baud rate identification method, device, equipment and storage medium
Technical Field
The application relates to the technical field of vehicle CAN buses, in particular to a CAN network baud rate identification method, a device, equipment and a storage medium.
Background
Controller area network (Controller Area Network, CAN) communication is a method of communicating between microprocessor-based devices. Typically, the device includes a CAN controller communicatively coupled to the CAN bus. A typical CAN controller communicates with other devices at a fixed baud rate. Such as the communication between the various devices on the vehicle via a CAN bus. In an unknown CAN network, the baud rate of the CAN network needs to be identified, but in the prior art, the baud rate identification efficiency is inaccurate.
Therefore, how to provide a scheme capable of accurately identifying the baud rate is a technical problem to be solved by those skilled in the art.
Disclosure of Invention
The application provides a method, a device, equipment and a storage medium for identifying the baud rate of a CAN (controller area network) and aims to solve the technical problem of inaccurate baud rate identification.
In a first aspect, the present application provides a CAN network baud rate identifying method, where the CAN network baud rate identifying method includes:
setting the baud rate of the CAN controller according to a preset standard baud rate table;
judging whether the CAN controller receives data in a CAN bus or not in a preset first time;
when the CAN controller CAN receive data in a preset first time, identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate, and recording the baud rate enabling the CAN controller to receive the data;
and when the CAN controller cannot receive data in the preset first time and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
Preferably, before the baud rate of the CAN controller is set according to a preset standard baud rate table, the method further includes:
Setting an operation mode of a Controller Area Network (CAN) controller to be a limited operation mode, wherein when the CAN controller is in the limited operation mode, the CAN controller CAN receive data and cannot send data, and an error counter of the CAN controller does not count when the baud rate is set to be wrong;
and setting a filter of the CAN controller as an identity ID full-pass mode.
Preferably, before the setting the operation mode of the controller area network CAN controller to the limited operation mode, the method further includes:
initializing the CAN controller.
Preferably, when the baud rate in the standard baud rate table is used and the CAN controller cannot receive data within a preset first time, the method further includes:
when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, setting the baud rate of the CAN controller according to the preset standard baud rate table;
the CAN controller is controlled to send a frame of data to a CAN bus;
judging whether the CAN controller successfully transmits data or not after a preset second time;
when the CAN controller successfully transmits data, identifying that the baud rate enabling the CAN controller to successfully transmit the data is the correct baud rate, and recording the baud rate enabling the CAN controller to successfully transmit the data;
And when the CAN controller fails to send data and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
Preferably, before the setting the baud rate of the CAN controller according to the preset standard baud rate table, the method further includes:
and setting the operation mode of the CAN controller to be a non-retransmission mode, wherein the CAN controller only transmits once when transmitting data in the non-retransmission mode.
Preferably, before the setting the baud rate of the CAN controller according to the preset standard baud rate table, the method further includes:
and setting a filter of the CAN controller as an ID total non-passing mode.
Preferably, the baud rates in the standard baud rate table are arranged from large to small.
In a second aspect, the present application further provides a CAN network baud rate identifying device, where the CAN network baud rate identifying device includes:
the first baud rate setting module is used for setting the baud rate of the CAN controller according to a preset standard baud rate table;
the receiving judging module is used for judging whether the CAN controller receives data in the CAN bus or not in a preset first time;
The first identification module is used for identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate when the CAN controller CAN receive the data in a preset first time, and recording the baud rate enabling the CAN controller to receive the data;
the first baud rate setting module is further configured to, when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is not used, continue to set the baud rate of the CAN controller according to the preset standard baud rate table.
Preferably, the CAN network baud rate recognition device further includes:
the limited mode setting module is used for setting the operation mode of the controller area network CAN controller to be a limited operation mode, when the CAN controller is in the limited operation mode, the CAN controller CAN receive data and cannot send data, and an error counter of the CAN controller does not count when the baud rate is set to be wrong;
and the ID passing module is used for setting a filter of the CAN controller as an ID full-passing mode.
Preferably, the CAN network baud rate recognition device further includes:
and the use judging module is used for judging whether the baud rate in the standard baud rate table is used.
Preferably, the CAN network baud rate recognition device further includes:
and the initialization module is used for initializing the CAN controller.
Preferably, the CAN network baud rate recognition device further includes:
the second baud rate setting module is used for setting the baud rate of the CAN controller according to the preset standard baud rate table;
the sending control module is used for controlling the CAN controller to send one frame of data to the CAN bus;
the sending judging module is used for judging whether the CAN controller successfully sends data or not after a preset second time;
the second identification module is used for identifying that the baud rate of the CAN controller which CAN successfully send data is the correct baud rate and recording the baud rate of the CAN controller which CAN successfully send data when the CAN controller successfully sends data;
and the second baud rate setting module is further used for continuously setting the baud rate of the CAN controller according to the preset standard baud rate table when the CAN controller fails to send data and the baud rate in the standard baud rate table is not used.
Preferably, the CAN network baud rate recognition device further includes:
and the non-retransmission mode setting module is used for setting the operation mode of the CAN controller to be a non-retransmission mode when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, and the CAN controller only transmits once when transmitting the data in the non-retransmission mode.
Preferably, the CAN network baud rate recognition device further includes:
and the ID forbidding module is used for setting a filter of the CAN controller to be in an ID total non-passing mode.
In a third aspect, the present application further provides a CAN network baud rate identifying device, which is characterized in that the CAN network baud rate identifying device includes:
the memory is used for storing a CAN network baud rate identification program;
and the processor is used for realizing the CAN network baud rate identification method in the embodiment of the first aspect of the application when executing the CAN network baud rate identification program.
In a fourth aspect, the present application further provides a storage medium, where the storage medium is a computer readable storage medium, and is characterized in that a CAN network baud rate identification program is stored in the storage medium, where the CAN network baud rate identification program, when executed by a processor, implements the CAN network baud rate identification method according to the embodiment of the first aspect of the present application.
Compared with the prior art, the technical scheme provided by the application sets the baud rate of the CAN controller according to the preset standard baud rate table; judging whether the CAN controller receives data in a CAN bus or not in a preset first time; when the CAN controller CAN receive data in a preset first time, identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate, and recording the baud rate enabling the CAN controller to receive the data; when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is not used, the baud rate of the CAN controller is continuously set according to the preset standard baud rate table, the baud rate of an unknown CAN network CAN be intelligently and rapidly identified, the baud rate identification is accurate, and the identification efficiency is high.
Drawings
Fig. 1 is a flowchart of a CAN network baud rate identifying method according to a first embodiment of the present application.
Fig. 2 is a flowchart of a CAN network baud rate identifying method according to a second embodiment of the present application.
Fig. 3 is a flowchart of a CAN network baud rate identifying method according to a third embodiment of the present application.
Fig. 4 is a flowchart of a CAN network baud rate identifying method according to a fourth embodiment of the present application.
Fig. 5 is a schematic block diagram of a CAN network baud rate recognition device according to a fifth embodiment of the present application.
Fig. 6 is a schematic structural diagram of a CAN network baud rate identifying device according to a sixth embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
The terms "first," "second," "third," "fourth" and the like in the description and in the claims of this application and in the above-described figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments described herein may be implemented in other sequences than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that the description herein of "first," "second," etc. is for descriptive purposes only and is not to be construed as indicating or implying a relative importance or implying an indication of the number of technical features being indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In addition, the technical solutions of the embodiments may be combined with each other, but it is necessary to base that the technical solutions can be realized by those skilled in the art, and when the technical solutions are contradictory or cannot be realized, the combination of the technical solutions should be regarded as not exist and not within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a schematic diagram of a CAN network baud rate identifying method according to a first embodiment of the present application, where the CAN network baud rate identifying method may be performed by a CAN network baud rate identifying device, and the CAN network baud rate identifying device may be implemented by hardware and/or software, and is used for identifying the baud rate of a CAN network. The CAN network baud rate recognition device CAN be applied to CAN network baud rate recognition equipment. The CAN network baud rate identification method comprises the following steps:
S11: and setting the baud rate of the CAN controller according to a preset standard baud rate table.
The standard baud rate table is a list of baud rates that the CAN controller is allowed to set, and one baud rate in the standard baud rate table is correct. The standard baud rate table is stored in the CAN network baud rate recognition device in advance. When the baud rates of the CAN controllers are set according to the standard baud rate table, the method is set one by one, and when the baud rates of one CAN controller are set, the method proceeds to step S12. The baud rate set may or may not be correct. Preferably, the baud rates in the standard baud rate table are arranged from large to small.
S12: judging whether the CAN controller receives data in a CAN bus or not in a preset first time.
The length of the first time is not limited, and may be set as needed. The first time is at least one period of data transceiving in the CAN bus, so that the data CAN be received only when the baud rate of the CAN controller is set correctly. And when the CAN controller CAN receive data in the preset first time, the step S13 is entered. When the CAN controller cannot receive data within the preset first time, the step S14 is entered.
S13: when the CAN controller CAN receive data in a preset first time, the baud rate enabling the CAN controller to receive the data is identified to be the correct baud rate, and the baud rate enabling the CAN controller to receive the data is recorded.
When the CAN controller CAN receive data in a preset first time, the fact that the baud rate of the CAN controller is set correctly is indicated, the baud rate of the CAN controller which CAN receive the data is the correct baud rate CAN be identified, the baud rate of the CAN controller which CAN receive the data is the correct baud rate, the baud rate of the CAN controller which CAN receive the data is recorded, the recorded baud rate is the identified correct baud rate of the CAN network, and the identification of the baud rate CAN be finished.
S14: and when the CAN controller cannot receive data in the preset first time and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
If the CAN controller cannot receive data in the preset first time, the situation that the baud rate of the CAN controller is set incorrectly and the baud rate of the CAN controller needs to be set again is indicated. When the baud rate in the standard baud rate table is not used, the remaining baud rate in the standard baud rate table may be the correct baud rate, and the baud rate of the CAN controller needs to be set one by one according to the baud rate which is not used in the standard baud rate table. The baud rates in the standard baud rate table are arranged from large to small, and when the baud rates of the CAN controller are set one by one, the baud rates are set one by one from large to small.
Preferably, before continuing to set the baud rate of the CAN controller according to the preset standard baud rate table, the CAN network baud rate identifying method further includes:
and judging whether the baud rate in the standard baud rate table is used.
If each baud rate in the standard baud rate table is used for setting the baud rate of the CAN controller, the baud rate in the standard baud rate table is used.
According to the CAN network baud rate identification method provided by the embodiment, the baud rate of the CAN controller is set according to a preset standard baud rate table; judging whether the CAN controller receives data in a CAN bus or not in a preset first time; when the CAN controller CAN receive data in a preset first time, identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate, and recording the baud rate enabling the CAN controller to receive the data; when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is not used, the baud rate of the CAN controller is continuously set according to the preset standard baud rate table, the baud rate of an unknown CAN network CAN be intelligently and rapidly identified, the baud rate identification is accurate, and the identification efficiency is high.
Referring to fig. 2, fig. 2 is a schematic diagram of a method for identifying a baud rate of a CAN network according to a second embodiment of the present application,
s21: setting an operation mode of a CAN controller to be a limited operation mode, wherein the CAN controller CAN receive data when the CAN controller is in the limited operation mode, cannot send data and an error counter of the CAN controller does not count when the baud rate is set to be wrong.
The CAN controller is respectively connected with CAN bus communication of the CAN network baud rate identification equipment and the CAN network. The CAN controller includes an error counter, a filter, an error status register, and the like. The error counter is used for counting errors when the CAN controller transmits or receives data errors, the filter is used for filtering the identity (Identity document, ID) of other CAN controllers and the like, and the error state register is used for judging whether the CAN controller transmits the data or not. CAN registers, error counters, filters, error status registers are known in the art and will not be described in further detail per se.
The CAN network baud rate recognition equipment is in communication connection with the CAN controller, and CAN set the operation mode of the CAN controller, so that the CAN controller has the state of the corresponding operation mode. The limited operation mode of the CAN controller is similar to the silence listening mode of the CAN controller, except that the error counter does not count when the CAN controller transmits or receives data errors.
When the number of times of counting of the error counter of the CAN controller is too large, the error CAN be generated on the CAN network, and the CAN controller CAN be prevented from generating errors on the network due to the fact that the number of times of counting of the error counter is too large.
Preferably, before setting the operation mode of the CAN controller to the limited operation mode, the CAN network baud rate identifying method further includes:
initializing the CAN controller.
How to initialize a CAN controller is the prior art is not described in this application. The CAN controller is initialized, so that the normal work of the CAN controller CAN be ensured, and the limited operation mode CAN be successfully set.
S22: and setting a filter of the CAN controller as an identity ID full-pass mode.
The filter of the CAN controller is in an ID full-pass mode, namely, the ID filtering is not carried out on the received data, no matter which device in the CAN bus transmits the data, the CAN controller CAN receive the data when the baud rate is correct.
S23: and setting the baud rate of the CAN controller according to a preset standard baud rate table.
S24: judging whether the CAN controller receives data in a CAN bus or not in a preset first time.
S25: when the CAN controller CAN receive data in a preset first time, the baud rate enabling the CAN controller to receive the data is identified to be the correct baud rate, and the baud rate enabling the CAN controller to receive the data is recorded.
S26: and when the CAN controller cannot receive data in the preset first time and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
According to the CAN network baud rate identification method provided by the embodiment, the operation mode of the controller area network CAN controller is set to be a limited operation mode, when the CAN controller is in the limited operation mode, the CAN controller CAN receive data and cannot send the data, and an error counter of the CAN controller does not count when the baud rate is set to be wrong; setting a filter of the CAN controller as an identity ID full-pass mode; setting the baud rate of the CAN controller according to a preset standard baud rate table; judging whether the CAN controller receives data in a CAN bus or not in a preset first time; when the CAN controller CAN receive data in a preset first time, identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate, and recording the baud rate enabling the CAN controller to receive the data; when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is not used, the baud rate of the CAN controller is continuously set according to the preset standard baud rate table, the baud rate of an unknown CAN network CAN be intelligently and rapidly identified, the work of an error counter of the CAN controller cannot be influenced, and therefore the normal work of the network cannot be influenced.
Referring to fig. 3, a third embodiment of the present application also provides a method for identifying a baud rate of a CAN network, where the present embodiment provides a complementary scheme that the baud rate fails to be set successfully when an unexpected situation occurs based on the foregoing embodiment, and the method for identifying the baud rate of the CAN network includes:
s31: and setting the baud rate of the CAN controller according to a preset standard baud rate table.
S32: judging whether the CAN controller receives data in a CAN bus or not in a preset first time.
S33: when the CAN controller CAN receive data in a preset first time, the baud rate enabling the CAN controller to receive the data is identified to be the correct baud rate, and the baud rate enabling the CAN controller to receive the data is recorded.
S34: and when the CAN controller cannot receive data in the preset first time and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
S35: and when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, setting the baud rate of the CAN controller according to the preset standard baud rate table.
When the baud rate is set this time, even if the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, the baud rate in the standard baud rate table is used again before the operation mode of the CAN controller is set to be a non-retransmission mode, so that the baud rate of the CAN controller is set again. I.e. the baud rate is set after setting the operation mode of the CAN controller to the no-retransmission mode and the baud rate is set before setting the operation mode of the CAN controller to the no-retransmission mode. Preferably, the baud rates in the standard baud rate table are arranged from large to small.
S36: and controlling the CAN controller to send one frame of data to a CAN bus.
And judging whether the baud rate of the CAN controller is set correctly or not by judging whether the data CAN be successfully transmitted. When transmitting data, the data length of the CAN frame is set to 0, that is, the non-transmission data is set to 0, and the data frame ID is set to 0x7FF, thereby reducing the occurrence of network errors.
S37: and judging whether the CAN controller successfully transmits data or not after a preset second time.
The length of the preset second time is not limited, and the shortest time of the second time is the time required by the CAN controller to successfully send one frame of data. How to determine whether data is successfully transmitted is the prior art and is not specifically described in this application.
And when the data transmission is successful, the baud rate of the CAN controller is correctly set. And when the data transmission fails, the baud rate setting error of the CAN controller is indicated. The CAN controller is operated in a no-retransmission mode, and does not retransmit data even if data transmission fails.
S38: when the CAN controller successfully transmits data, identifying that the baud rate enabling the CAN controller to successfully transmit the data is the correct baud rate, and recording the baud rate enabling the CAN controller to successfully transmit the data.
When the data transmission is successful, the baud rate of the data received by the CAN controller is the correct baud rate, namely the baud rate of the data received by the CAN controller is identified as the correct baud rate, the baud rate of the data received by the CAN controller is recorded, and the recorded baud rate is the identified correct baud rate, namely the CAN network baud rate identification CAN be ended.
S39: and when the CAN controller fails to send data and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
If the CAN controller fails to send data, the baud rate setting error of the CAN controller is indicated, and the baud rate of the CAN controller needs to be set again. When the baud rate in the standard baud rate table is not used, the remaining baud rate in the standard baud rate table may be the correct baud rate, and then the baud rate of the CAN controller needs to be set one by one according to the baud rate which is not used in the standard baud rate table. The baud rates in the standard baud rate table are arranged from large to small, and when the baud rates of the CAN controller are set one by one, the baud rates are set one by one from large to small. Therefore, when the data is transmitted in the step S29, the data is transmitted at the set large baud rate, and the generation of network errors can be reduced.
Preferably, before the CAN controller fails to send data and the baud rate in the standard baud rate table is not used, the method further includes:
and judging whether the baud rate in the standard baud rate table is used.
If each baud rate in the standard baud rate table is used for setting the baud rate of the CAN controller, the baud rate in the standard baud rate table is used completely, and the CAN controller actively transmits data, so that the CAN controller CAN successfully transmit data as long as the baud rate of the CAN controller is correctly set, and the data transmission success of the CAN controller is ensured.
The CAN network baud rate identification method provided by the embodiment CAN ensure that the baud rate of the CAN controller is identified under the condition that no data is transmitted in the CAN bus.
Referring to fig. 4, a fourth embodiment of the present application also provides a method for identifying a baud rate of a CAN network, where the present embodiment provides a scenario solution for further reducing network errors based on the foregoing embodiment, and the method for identifying a baud rate of a CAN network includes:
s41: setting the baud rate of the CAN controller according to a preset standard baud rate table;
S42: judging whether the CAN controller receives data in a CAN bus or not in a preset first time;
s43: when the CAN controller CAN receive data in a preset first time, identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate, and recording the baud rate enabling the CAN controller to receive the data;
s44: when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table
S45: and when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, setting an operation mode of the CAN controller to be a non-retransmission mode, and when the CAN controller is in the non-retransmission mode, only transmitting the data once when the CAN controller transmits the data.
In the CAN network, when the baud rate is set to be wrong, the CAN controller CAN influence the CAN network when actively transmitting data, and when the baud rate is set to be wrong too many times, the CAN network CAN generate errors. When the operation mode of the CAN controller is a non-retransmission mode, the CAN controller CAN transmit data, but when the CAN controller transmits data, whether the data is successfully transmitted or not, the data is transmitted only once. Therefore, when the data is not successfully transmitted, the error counter of the CAN controller CAN be prevented from counting for a plurality of times, and the error caused by the fact that the CAN controller sets the baud rate error, so that the error counter CAN cause errors to the CAN network due to too many counting errors when the data is transmitted, and the error counter CAN reduce the occurrence of CAN network errors.
Preferably, before the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, the CAN network baud rate identification method further includes:
initializing the CAN controller.
Namely, the CAN controller is initialized again, so that the success of the non-retransmission mode setting of the CAN controller CAN be ensured.
S46: and setting a filter of the CAN controller as an ID total non-passing mode.
When the filter of the CAN controller is in an ID all-fail mode, no matter which device or equipment transmits data, the CAN controller does not receive the data even if the baud rate of the CAN controller is correctly set, so that the data transmitted by the CAN controller is not influenced, and the accuracy of the CAN network baud rate identification of the CAN controller is improved.
S47: setting the baud rate of the CAN controller according to the preset standard baud rate table;
s48: the CAN controller is controlled to send a frame of data to a CAN bus;
s49: judging whether the CAN controller successfully transmits data or not after a preset second time;
s410: when the CAN controller successfully transmits data, identifying that the baud rate enabling the CAN controller to successfully transmit the data is the correct baud rate, and recording the baud rate enabling the CAN controller to successfully transmit the data;
S411: and when the CAN controller fails to send data and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
The CAN network baud rate identification method provided by the embodiment CAN ensure that the baud rate of the CAN controller is identified under the condition that no data is transmitted in the CAN bus, and reduces the occurrence of CAN network errors.
Referring to fig. 5, a fifth embodiment of the present application provides a CAN network baud rate identifying apparatus 50 for a baud rate of an unknown CAN network. The CAN network baud rate recognition device 50 may be applied to the CAN network baud rate recognition device apparatus, and the CAN network baud rate recognition device 50 may implement the CAN network baud rate recognition method of the foregoing embodiment, and the CAN network baud rate recognition device 50 includes:
a first baud rate setting module 51, configured to set a baud rate of the CAN controller according to a preset standard baud rate table;
the receiving judging module 52 is configured to judge whether the CAN controller receives data in the CAN bus within a preset first time;
the first identifying module 53 is configured to identify, when the CAN controller CAN receive data in a preset first time, a baud rate that enables the CAN controller to receive data to be a correct baud rate, and record a baud rate that enables the CAN controller to receive data;
The first baud rate setting module 54 is further configured to continuously set the baud rate of the CAN controller according to a preset standard baud rate table when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is not used.
The CAN network baud rate recognition device provided by the embodiment sets the baud rate of the CAN controller according to a preset standard baud rate table; judging whether the CAN controller receives data in a CAN bus or not in a preset first time; when the CAN controller CAN receive data in a preset first time, identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate, and recording the baud rate enabling the CAN controller to receive the data; when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is not used, the baud rate of the CAN controller is continuously set according to the preset standard baud rate table, the baud rate of an unknown CAN network CAN be intelligently and rapidly identified, the baud rate identification is accurate, and the identification efficiency is high.
Preferably, the CAN network baud rate recognition device 50 further includes:
The limited mode setting module is used for setting the operation mode of the controller area network CAN controller to be a limited operation mode, when the CAN controller is in the limited operation mode, the CAN controller CAN receive data and cannot send data, and an error counter of the CAN controller does not count when the baud rate is set to be wrong;
and the ID passing module is used for setting a filter of the CAN controller as an ID full-passing mode.
Preferably, the CAN network baud rate recognition device 50 further includes:
and the use judging module is used for judging whether the baud rate in the standard baud rate table is used.
Preferably, the CAN network baud rate recognition device 50 further includes:
and the initialization module is used for initializing the CAN controller.
Preferably, the CAN network baud rate recognition device 50 further includes:
the second baud rate setting module is used for setting the baud rate of the CAN controller according to the preset standard baud rate table;
the sending control module is used for controlling the CAN controller to send one frame of data to the CAN bus;
the sending judging module is used for judging whether the CAN controller successfully sends data or not after a preset second time;
the second identification module is used for identifying that the baud rate of the CAN controller which CAN successfully send data is the correct baud rate and recording the baud rate of the CAN controller which CAN successfully send data when the CAN controller successfully sends data;
And the second baud rate setting module is further used for continuously setting the baud rate of the CAN controller according to the preset standard baud rate table when the CAN controller fails to send data and the baud rate in the standard baud rate table is not used.
Preferably, the CAN network baud rate recognition device 50 further includes:
and the non-retransmission mode setting module is used for setting the operation mode of the CAN controller to be a non-retransmission mode when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, and the CAN controller only transmits once when transmitting the data in the non-retransmission mode.
Preferably, the CAN network baud rate recognition device 50 further includes:
and the ID forbidding module is used for setting a filter of the CAN controller to be in an ID total non-passing mode.
The product can execute the method provided by any embodiment of the application, and has the corresponding functional modules and beneficial effects of the execution method.
Referring to fig. 6, a sixth embodiment of the present application further provides a CAN network baud rate identifying device and a storage medium, which all have the corresponding effects of the CAN network baud rate identifying method provided in the foregoing embodiments of the present application.
The device for identifying the baud rate of the CAN network provided in the embodiment of the present application includes a memory 61 and a processor 62, wherein the memory 61 stores a program for identifying the baud rate of the CAN network, and the processor 62 implements the following steps when executing the program for identifying the baud rate of the CAN network stored in the memory 61:
setting the baud rate of the CAN controller according to a preset standard baud rate table;
judging whether the CAN controller receives data in a CAN bus or not in a preset first time;
when the CAN controller CAN receive data in a preset first time, identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate, and recording the baud rate enabling the CAN controller to receive the data;
and when the CAN controller cannot receive data in the preset first time and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
Preferably, the processor of the CAN network baud rate recognition device executes the CAN network baud rate recognition program stored in the memory, further implementing the steps of: setting an operation mode of a Controller Area Network (CAN) controller to be a limited operation mode, wherein when the CAN controller is in the limited operation mode, the CAN controller CAN receive data and cannot send data, and an error counter of the CAN controller does not count when the baud rate is set to be wrong; and setting a filter of the CAN controller as an identity ID full-pass mode.
Preferably, the processor of the CAN network baud rate recognition device executes the CAN network baud rate recognition program stored in the memory, further implementing the steps of: and judging whether the baud rate in the standard baud rate table is used.
Preferably, the processor of the CAN network baud rate recognition device executes the CAN network baud rate recognition program stored in the memory, further implementing the steps of: initializing the CAN controller.
Preferably, the processor of the CAN network baud rate recognition device executes the CAN network baud rate recognition program stored in the memory, further implementing the steps of: when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, setting the baud rate of the CAN controller according to the preset standard baud rate table; the CAN controller is controlled to send a frame of data to a CAN bus; judging whether the CAN controller successfully transmits data or not after a preset second time; when the CAN controller successfully transmits data, identifying that the baud rate enabling the CAN controller to successfully transmit the data is the correct baud rate, and recording the baud rate enabling the CAN controller to successfully transmit the data; and when the CAN controller fails to send data and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
Preferably, the processor of the CAN network baud rate recognition device executes the CAN network baud rate recognition program stored in the memory, further implementing the steps of: and setting the operation mode of the CAN controller to be a non-retransmission mode, wherein the CAN controller only transmits once when transmitting data in the non-retransmission mode.
Preferably, the processor of the CAN network baud rate recognition device executes the CAN network baud rate recognition program stored in the memory, further implementing the steps of: and setting a filter of the CAN controller as an ID total non-passing mode.
The storage medium provided by the embodiment of the application is a computer readable storage medium, the computer readable storage medium stores a CAN network baud rate identification program, and the following steps are specifically implemented when the CAN network baud rate identification program is executed by a processor:
setting an operation mode of a Controller Area Network (CAN) controller to be a limited operation mode, wherein when the CAN controller is in the limited operation mode, the CAN controller CAN receive data and cannot send data, and an error counter of the CAN controller does not count when the baud rate is set to be wrong;
setting a filter of the CAN controller as an identity ID full-pass mode;
Setting the baud rate of the CAN controller according to a preset standard baud rate table;
judging whether the CAN controller receives data in a CAN bus or not in a preset first time;
when the CAN controller CAN receive data in a preset first time, identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate, and recording the baud rate enabling the CAN controller to receive the data;
and when the CAN controller cannot receive data in the preset first time and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
Preferably, the CAN network baud rate recognition program stored in the computer readable storage medium, when executed by the processor, specifically further implements the steps of: and judging whether the baud rate in the standard baud rate table is used.
Preferably, the CAN network baud rate recognition program stored in the computer readable storage medium, when executed by the processor, specifically implements the steps of: initializing the CAN controller.
Preferably, the CAN network baud rate recognition program stored in the computer readable storage medium, when executed by the processor, specifically implements the steps of: when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, setting an operation mode of the CAN controller to be a non-retransmission mode, wherein the CAN controller only transmits once when transmitting the data in the non-retransmission mode; setting the baud rate of the CAN controller according to the preset standard baud rate table; the CAN controller is controlled to send a frame of data to a CAN bus; judging whether the CAN controller successfully transmits data or not after a preset second time; when the CAN controller successfully transmits data, identifying that the baud rate enabling the CAN controller to successfully transmit the data is the correct baud rate, and recording the baud rate enabling the CAN controller to successfully transmit the data; and when the CAN controller fails to send data and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
Preferably, the CAN network baud rate recognition program stored in the computer readable storage medium, when executed by the processor, specifically implements the steps of:
and setting a filter of the CAN controller as an ID total non-passing mode.
The computer readable storage medium to which the present application relates includes random access Memory (Random Access Memory) RAM, memory, read-Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, compact disc Read-Only Memory (CD-ROM), or any other form of storage medium known in the art.
The description of the relevant parts in the method, the device, the equipment and the computer readable storage medium for identifying the baud rate of the CAN network provided in the embodiments of the present application refers to the detailed description of the corresponding parts in the method for identifying the baud rate of the CAN network provided in the foregoing embodiments of the present application, and will not be repeated herein. In addition, the parts of the above technical solutions provided in the embodiments of the present application, which are consistent with the implementation principles of the corresponding technical solutions in the prior art, are not described in detail, so that redundant descriptions are avoided.
The modules or units involved in the embodiments of the present application may be implemented by software, or may be implemented by hardware. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.
The foregoing description is only of the preferred embodiments of the present application, and is not intended to limit the scope of the present application, and all equivalent structures or equivalent processes using the descriptions and drawings of the present application, or direct or indirect application in other related technical fields, are included in the scope of the present application.

Claims (8)

1. The CAN network baud rate recognition method is characterized by comprising the following steps of:
setting the baud rate of the CAN controller according to a preset standard baud rate table;
judging whether the CAN controller receives data in a CAN bus or not in a preset first time;
when the CAN controller CAN receive data in a preset first time, identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate, and recording the baud rate enabling the CAN controller to receive the data;
when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table;
when the baud rate in the standard baud rate table is used and the CAN controller cannot receive data in a preset first time, the method further comprises:
When the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, setting the baud rate of the CAN controller according to the preset standard baud rate table;
the CAN controller is controlled to send a frame of data to a CAN bus;
when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, before the baud rate of the CAN controller is set according to the preset standard baud rate table, the method further comprises: setting the operation mode of the CAN controller to be a non-retransmission mode, wherein the CAN controller only transmits once when transmitting data in the non-retransmission mode; and setting a filter of the CAN controller as an ID total non-passing mode.
2. The CAN network baud rate recognition method of claim 1, wherein: before the baud rate of the CAN controller is set according to the preset standard baud rate table, the method further includes:
setting an operation mode of a Controller Area Network (CAN) controller to be a limited operation mode, wherein when the CAN controller is in the limited operation mode, the CAN controller CAN receive data and cannot send data, and an error counter of the CAN controller does not count when the baud rate is set to be wrong;
And setting a filter of the CAN controller as an identity ID full-pass mode.
3. The CAN network baud rate recognition method of claim 1, wherein: before setting the operation mode of the controller area network CAN controller to the limited operation mode, the method further comprises:
initializing the CAN controller.
4. The CAN network baud rate recognition method of claim 1, wherein:
judging whether the CAN controller successfully transmits data or not after a preset second time;
when the CAN controller successfully transmits data, identifying that the baud rate enabling the CAN controller to successfully transmit the data is the correct baud rate, and recording the baud rate enabling the CAN controller to successfully transmit the data;
and when the CAN controller fails to send data and the baud rate in the standard baud rate table is not used, continuously setting the baud rate of the CAN controller according to the preset standard baud rate table.
5. The CAN network baud rate recognition method of claim 4, wherein:
the baud rates in the standard baud rate table are arranged from large to small.
6. The CAN network baud rate recognition device is characterized by comprising:
The first baud rate setting module is used for setting the baud rate of the CAN controller according to a preset standard baud rate table;
the receiving judging module is used for judging whether the CAN controller receives data in the CAN bus or not in a preset first time;
the first identification module is used for identifying that the baud rate enabling the CAN controller to receive the data is the correct baud rate when the CAN controller CAN receive the data in a preset first time, and recording the baud rate enabling the CAN controller to receive the data;
the first baud rate setting module is further configured to continuously set the baud rate of the CAN controller according to a preset standard baud rate table when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is not used;
a non-retransmission mode setting module, configured to set an operation mode of the CAN controller to a non-retransmission mode when the CAN controller cannot receive data in a preset first time and the baud rate in the standard baud rate table is used, where the CAN controller only transmits data once when the CAN controller transmits data in the non-retransmission mode;
And the ID forbidding module is used for setting a filter of the CAN controller to be in an ID total non-passing mode.
7. A CAN network baud rate recognition device, characterized in that the CAN network baud rate recognition device comprises:
the memory is used for storing a CAN network baud rate identification program;
a processor for implementing the CAN network baud rate recognition method according to any one of claims 1 to 5 when executing the CAN network baud rate recognition program.
8. A storage medium, which is a computer-readable storage medium, characterized in that the storage medium has stored therein a CAN network baud rate identification program, which when executed by a processor, implements the CAN network baud rate identification method according to any one of claims 1 to 5.
CN202010042180.5A 2020-01-15 2020-01-15 CAN network baud rate identification method, device, equipment and storage medium Active CN111277455B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010042180.5A CN111277455B (en) 2020-01-15 2020-01-15 CAN network baud rate identification method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010042180.5A CN111277455B (en) 2020-01-15 2020-01-15 CAN network baud rate identification method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111277455A CN111277455A (en) 2020-06-12
CN111277455B true CN111277455B (en) 2023-05-12

Family

ID=71000309

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010042180.5A Active CN111277455B (en) 2020-01-15 2020-01-15 CAN network baud rate identification method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111277455B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112241158A (en) * 2020-10-20 2021-01-19 上海星融汽车科技有限公司 Vehicle OBD port CAN communication pin detection method, system and diagnosis equipment
CN113194016B (en) * 2021-04-15 2022-12-09 常州易控汽车电子股份有限公司 CAN bus baud rate self-adaption method and device based on TC387 chip and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN2768334Y (en) * 2004-12-29 2006-03-29 何崇中 Tyre pressure monitoring system based on can bus
CN102752084A (en) * 2012-07-27 2012-10-24 湖南先步信息股份有限公司 Multi-device controller area network (CAN) communication intelligent retransmission method
CN105960629A (en) * 2013-12-30 2016-09-21 施耐德电气It公司 System and method for automatically selecting baud rate in a can network

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7333536B2 (en) * 2003-10-09 2008-02-19 Stmicroelectronics Pvt. Ltd. System and method for auto baud rate detection in asynchronous serial communication
US20130044795A1 (en) * 2011-08-19 2013-02-21 Steven J. Busak System and method for automatic baud rate selection for facsimile transmit and receive
CN103777538B (en) * 2012-10-19 2016-03-30 重庆长安汽车股份有限公司 The baud rate automatic matching method of controller and CAN
US20140153623A1 (en) * 2012-11-30 2014-06-05 Dinkle Enterprise Co., Ltd. Device for auto baud rate detection
CN104199298B (en) * 2014-08-18 2016-10-26 广西师范大学 A kind of method of CAN baud rate self-adapting
CN106411641A (en) * 2016-09-20 2017-02-15 宁波中车时代传感技术有限公司 Method for automatically detecting Baud rate of CAN bus
CN109768907A (en) * 2019-01-09 2019-05-17 北京安控科技股份有限公司 A kind of CAN bus baud rate self-adapting setting method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN2768334Y (en) * 2004-12-29 2006-03-29 何崇中 Tyre pressure monitoring system based on can bus
CN102752084A (en) * 2012-07-27 2012-10-24 湖南先步信息股份有限公司 Multi-device controller area network (CAN) communication intelligent retransmission method
CN105960629A (en) * 2013-12-30 2016-09-21 施耐德电气It公司 System and method for automatically selecting baud rate in a can network

Also Published As

Publication number Publication date
CN111277455A (en) 2020-06-12

Similar Documents

Publication Publication Date Title
CN111277455B (en) CAN network baud rate identification method, device, equipment and storage medium
CN105786753A (en) Method and device for data transmission between master and slave devices on I2C bus
CN100365994C (en) Method and system for regulating ethernet
DE19900245A1 (en) System for transmission and reception of universal serial bus data
CN108052094B (en) Expansion card identification method and device and frequency converter
CN101150386A (en) Communication method for improving communication error and electronic device using the same
CN112069008A (en) Equipment debugging information acquisition method and device and equipment debugging information generation method
CN111224837B (en) Method and system for automatically identifying CAN communication baud rate of vehicle ECU
CN115687226A (en) I2c bus communication method, device and readable storage medium
CN114386366B (en) Automatic detection system and method for chip read-write performance in IC verification environment
US5459455A (en) Method and apparatus for data communication between transmission terminal and reception terminal of a network system
CN111984582B (en) PCIE link training method, equipment and medium
EP3534657B1 (en) Dynamic time allocation method and device
US10459816B2 (en) Communication setting notification apparatus
EP2988476A1 (en) Method and apparatus for processing operation on endpoint peripheral
US5003460A (en) Method for the transmission of connection data stored in a communication switching system to a data processing system
CN113556210A (en) Upper computer and method for establishing communication connection
CN109634906B (en) IC communication system and method
CN111240302A (en) Signal verification method and device, electronic equipment and storage medium
CN111431668A (en) Baud rate switching method based on multi-node UART communication, air conditioning system and processor
CN117075916A (en) Application deployment method, device, equipment and storage medium
US20050120028A1 (en) Method of automatically identify the tape of local management interface by data terminal equipment
CN217445384U (en) Data communication ID recognition device
CN106023997B (en) Data transmission method and transceiving device based on SPDIF protocol
CN108614751A (en) A kind of method of PCIE winding self-test

Legal Events

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