Can bus baud rate acquisition method, vehicle communication device, and storage medium
By recording the correspondence between the conventional pin pair and the baud rate when the automotive communication device is powered on, and monitoring the baud rate in the pin pair list when the detection instruction is received, the problem of failure to obtain the CAN bus baud rate in the prior art is solved, and the success rate is improved.
Patent Information
- Application Number
- PCT/CN2024/134028
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-11-28
- Filing Date
- 2024-11-23
- Publication Date
- 2025-06-05
AI Technical Summary
When obtaining the baud rate of the CAN bus, the prior art tends to fail to monitor or fail to obtain the correct baud rate, resulting in the automotive diagnostic equipment being unable to communicate with the vehicle normally.
By monitoring the baud rate on a regular pin pair when powered on a car communication device, and recording the correspondence in a global array. When a detection instruction is received, if there is no correspondence in the global array, the corresponding baud rate of the pin pairs in the list is monitored, and if the monitoring fails, the corresponding relationship is obtained.
Improves the success rate of obtaining the CAN bus baud rate and ensures that the vehicle diagnostic equipment can communicate normally with the vehicle.
Smart Images

Figure CN2024134028_05062025_PF_FP_ABST
Abstract
Description
CAN bus baud rate acquisition method, automobile communication equipment and storage medium
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on November 28, 2023, with application number 202311610714.X and application name “Method for obtaining CAN bus baud rate, automotive communication equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The embodiments of the present application relate to the field of automotive communication technology, and in particular to a method for obtaining a CAN bus baud rate, an automotive communication device, and a storage medium. Background Art
[0003] Currently, the Controller Area Network (CAN) bus protocol has become the standard bus for automotive computer control systems and embedded industrial control area networks. Various operating systems have integrated numerous board-level support packages, and many manufacturers have provided corresponding board-level drivers that support the CAN bus protocol, including character device drivers. However, the baud rate of the CAN bus is not unique. If the baud rate of the CAN bus and a specific CAN device does not match, normal communication will be impossible. Furthermore, when a vehicle and automotive diagnostic equipment communicate via the CAN bus, they must use the same baud rate. In practice, different CAN buses have different baud rates, and the vehicle's baud rate is typically fixed at the factory. If the baud rate of the CAN bus does not match the vehicle's baud rate, the automotive diagnostic equipment will not be able to communicate with the vehicle via the CAN bus.
[0004] To address the above problem, the solution in the existing technology is to adopt a monitoring mode, in which the confirmation signal from the automobile electronic control unit is monitored, and the detection signal is analyzed in sequence using multiple baud rates. When a certain baud rate correctly analyzes the confirmation signal, the baud rate is determined to be the baud rate corresponding to the automobile electronic control unit. However, this existing solution still has the problem of not being able to monitor or obtain the correct baud rate. Summary of the Invention
[0005] An embodiment of the present application provides a method for obtaining the baud rate of a CAN bus, an automotive communication device, and a storage medium. By monitoring the baud rate corresponding to a pin pair in a pin pair list, if the monitoring fails, the baud rate corresponding to the pin pair in the pin pair list is obtained. The present application can still obtain the baud rate of the CAN bus even if the monitoring fails, thereby improving the success rate of obtaining the baud rate of the CAN bus.
[0006] The embodiments of this application provide the following technical solutions:
[0007] In a first aspect, an embodiment of the present application provides a method for obtaining a baud rate of a CAN bus, which is applied to an automotive communication device. The CAN bus includes multiple pin pairs, and the multiple pin pairs include regular pin pairs. The method for obtaining the baud rate of the CAN bus includes:
[0008] When the automotive communication device is powered on, the baud rate on the regular pin pair is monitored, the corresponding relationship between the regular pin pair and the regular baud rate is obtained, and the corresponding relationship between the regular pin pair and the regular baud rate is recorded in a global array;
[0009] When the automobile communication device receives a detection instruction sent by the host computer, it obtains a pin pair list corresponding to the detection instruction, wherein the detection instruction includes the pin pair list, and the pin pair list includes at least one pin pair;
[0010] If the global array does not contain the corresponding relationship between the pin pair in the pin pair list and the baud rate, the baud rate corresponding to the pin pair in the pin pair list is monitored;
[0011] If monitoring fails, obtain the baud rate corresponding to the pin pair in the pin pair list.
[0012] By obtaining the baud rate corresponding to the pin pair in the pin pair list when monitoring fails, the present application can improve the success rate of obtaining the baud rate of the CAN bus.
[0013] In some embodiments, when the automotive communication device is powered on, the baud rate on the regular pin pair is monitored, the correspondence between the regular pin pair and the regular baud rate is obtained, and the correspondence between the regular pin pair and the regular baud rate is recorded in a global array, including:
[0014] When the car communication device is powered on, obtain a list of common pin pairs and common baud rates;
[0015] Select a pair of pins to be detected from the regular pin pair list as the first pin pair;
[0016] Determine whether the voltage of the first pin pair is the CAN bus voltage;
[0017] If the voltage of the first pin pair is the CAN bus voltage, then on the first pin pair, regular baud rates in the regular baud rate list are monitored in sequence, and a monitoring status of the regular baud rate is obtained, wherein the monitoring status includes a success status or a failure status;
[0018] If the monitoring state of a certain regular baud rate is a success state, the regular baud rate is determined as the baud rate on the first pin pair, and the corresponding relationship between the first pin pair and the regular baud rate is recorded in a global array.
[0019] By obtaining the correspondence between the first pin pair and the conventional baud rate when the automobile communication equipment is powered on and the automobile diagnostic equipment has not yet been connected, the present application can return the obtained correspondence between the first pin pair and the conventional baud rate to the host computer through the global array more quickly in the subsequent process of obtaining the baud rate.
[0020] In some embodiments, after obtaining the pin pair list corresponding to the detection instruction, the method further includes:
[0021] Select a pair of pins to be detected from the pin pair list as the second pin pair;
[0022] Call the global array and determine whether there is a corresponding relationship between the second pin pair and the baud rate in the global array;
[0023] If there is a correspondence between the second pin pair and the baud rate in the global array, the correspondence between the second pin pair and the baud rate in the global array is recorded in the return array, and the next pin pair to be detected is selected from the pin pair list as the second pin pair, wherein the return array is used to store the correspondence between the second pin pair and the baud rate.
[0024] By calling the global array, the correspondence between the detected second pin pair and the baud rate is directly recorded in the return array. This application can improve the efficiency of obtaining the CAN bus baud rate.
[0025] In some embodiments, the detection instruction further includes a baud rate list, wherein the baud rate list includes at least one baud rate. If the global array does not contain a corresponding relationship between a pin pair in the pin pair list and a baud rate, monitoring the baud rate corresponding to the pin pair in the pin pair list includes:
[0026] If there is no corresponding relationship between the second pin pair and the baud rate in the global array, the baud rates in the baud rate list are monitored in sequence on the second pin pair, and the monitoring status of the baud rate is obtained, where the monitoring status includes a success status or a failure status;
[0027] If the monitoring status of a certain baud rate is successful, the baud rate is determined to be the baud rate on the second pin pair;
[0028] Get the correspondence between the second pin pair and the baud rate, and record the correspondence between the second pin pair and the baud rate in the return array.
[0029] By first obtaining the correspondence between the second pin pair and the baud rate by monitoring on the second pin pair, rather than first sending a broadcast message to the vehicle electronic control unit, the present application can reduce the probability of coding in the vehicle.
[0030] In some embodiments, the method further comprises:
[0031] If the monitoring status of a certain baud rate does not exist in a successful state, it is determined that the monitoring has failed, and the baud rate corresponding to the pin pair in the pin pair list is obtained.
[0032] By obtaining the baud rate corresponding to the pin pair in the pin pair list when monitoring fails, the present application can improve the success rate of obtaining the baud rate of the CAN bus.
[0033] In some embodiments, the automotive communication device is communicatively connected to the automotive electronic control unit to obtain the baud rate corresponding to the pin pair in the pin pair list, including:
[0034] Get the current baud rate to be detected from the baud rate list;
[0035] Determining whether the baud rate to be detected is a regular baud rate in a first baud rate detection list, wherein the first baud rate detection list includes at least one regular baud rate;
[0036] If the baud rate to be detected is a regular baud rate in the first baud rate detection list, a broadcast message is sent to the vehicle electronic control unit on the second pin pair at the baud rate to be detected.
[0037] If a first confirmation signal returned by the vehicle electronic control unit is received, determining that the current baud rate to be detected is the baud rate on the second pin pair;
[0038] Get the correspondence between the second pin pair and the current baud rate to be detected, and record the correspondence in the return array.
[0039] By sending a broadcast message frame to the automobile electronic control unit and determining whether a first confirmation signal returned by the automobile electronic control unit is received, the present application can improve the success rate of obtaining the CAN bus baud rate.
[0040] In some embodiments, the method further comprises:
[0041] If the first confirmation signal returned by the vehicle electronic control unit is not received and the baud rate list has been traversed, a broadcast message is sent to the vehicle electronic control unit according to the second baud rate detection list to obtain the correspondence between the second pin pair and the current baud rate to be detected.
[0042] By sending a broadcast message to the vehicle electronic control unit according to the second baud rate detection list when the first confirmation signal returned by the vehicle electronic control unit is not received and the baud rate list has been traversed, the present application can improve the success rate of obtaining the CAN bus baud rate.
[0043] In some embodiments, sending a broadcast message to the vehicle electronic control unit according to the second baud rate detection list to obtain a correspondence between the second pin pair and the current baud rate to be detected includes:
[0044] Get the current baud rate to be detected from the baud rate list;
[0045] Determining whether the baud rate to be detected is an unconventional baud rate in a second baud rate detection list, wherein the second baud rate detection list includes at least one unconventional baud rate;
[0046] If the baud rate to be detected is an unconventional baud rate in the second baud rate detection list, a broadcast message is sent to the vehicle electronic control unit on the second pin pair at the baud rate to be detected.
[0047] If a second confirmation signal returned by the vehicle electronic control unit is received, determining that the unconventional baud rate to be detected is the baud rate on the second pin pair;
[0048] Get the correspondence between the second pin pair and the unconventional baud rate to be detected, record the correspondence in the return array, select the next pin pair to be detected from the pin pair list as the second pin pair, and continue to monitor the baud rate on the second pin pair until all pin pairs to be detected in the pin pair list are traversed.
[0049] By sending a broadcast message frame to the automobile electronic control unit and determining whether a second confirmation signal returned by the automobile electronic control unit is received, the present application can improve the success rate of obtaining the CAN bus baud rate.
[0050] In a second aspect, an embodiment of the present application provides an automotive communication device, including:
[0051] at least one processor; and
[0052] a memory communicatively connected to at least one processor; wherein,
[0053] The memory stores instructions that can be executed by at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to execute the method for obtaining the baud rate of the CAN bus as described in the first aspect.
[0054] In a third aspect, an embodiment of the present application provides a non-volatile computer-readable storage medium, in which computer-executable instructions are stored. When the computer program or instructions are executed, the method for obtaining the CAN bus baud rate as in the first aspect is implemented.
[0055] The present application provides a method for obtaining the baud rate of a CAN bus, which is applied to an automobile communication device. The CAN bus includes multiple pin pairs, and the multiple pin pairs include regular pin pairs. The method for obtaining the baud rate of the CAN bus includes: when the automobile communication device is powered on, monitoring the baud rate on the regular pin pair, obtaining the corresponding relationship between the regular pin pair and the regular baud rate, and recording the corresponding relationship between the regular pin pair and the regular baud rate in a global array; when the automobile communication device receives a detection instruction sent by a host computer, obtaining a pin pair list corresponding to the detection instruction, wherein the detection instruction includes a pin pair list, and the pin pair list includes at least one pin pair; if the global array does not contain a corresponding relationship between the pin pair in the pin pair list and the baud rate, monitoring the baud rate corresponding to the pin pair in the pin pair list; if the monitoring fails, obtaining the baud rate corresponding to the pin pair in the pin pair list. By monitoring the baud rate corresponding to the pin pair in the pin pair list, and if the monitoring fails, obtaining the baud rate corresponding to the pin pair in the pin pair list, the present application can still obtain the CAN bus baud rate even if the monitoring fails, thereby improving the success rate of obtaining the CAN bus baud rate. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] One or more embodiments are exemplarily illustrated by corresponding drawings, which do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings are represented as similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0057] FIG1 is a schematic diagram of an application environment provided by an embodiment of the present application;
[0058] FIG2 is a flow chart of a method for obtaining the baud rate of a CAN bus provided in an embodiment of the present application;
[0059] FIG3 is a schematic diagram of a detailed process of step S201 in FIG2 ;
[0060] FIG4 is a schematic diagram of a detailed process of step S203 in FIG2 ;
[0061] FIG5 is a schematic diagram of a detailed flow chart of step S205 in FIG2 ;
[0062] FIG6 is a schematic diagram of a detailed flow chart of step S208 in FIG2 ;
[0063] FIG7 is a schematic diagram of a detailed process of step S2089 in FIG6 ;
[0064] FIG8 is a schematic diagram of an overall process of monitoring the baud rate on a conventional pin pair provided by an embodiment of the present application;
[0065] FIG9 is a schematic diagram of an overall process of obtaining the baud rate corresponding to a pin pair in a pin pair list provided by an embodiment of the present application;
[0066] FIG10 is a schematic structural diagram of a device for obtaining a CAN bus baud rate according to an embodiment of the present application;
[0067] FIG11 is a schematic structural diagram of an automobile communication device provided in an embodiment of the present application.
[0068] Description of Figure Numbers: DETAILED DESCRIPTION
[0069] In order to facilitate understanding of the present application, the present application is described in more detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that when an element is described as "fixed to" another element, it can be directly on the other element, or there can be one or more centered elements therebetween. When an element is described as "connected to" another element, it can be directly connected to the other element, or there can be one or more centered elements therebetween. The terms "vertical", "horizontal", "left", "right" and similar expressions used in this specification are for illustrative purposes only.
[0070] Unless otherwise defined, all technical and scientific terms used in this specification have the same meanings as those commonly understood by those skilled in the art to which this application belongs. The terms used in this specification and in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" as used in this specification includes any and all combinations of one or more of the relevant listed items.
[0071] The technical solution of this application is described in detail below with reference to the accompanying drawings:
[0072] Please refer to FIG1 , which is a schematic diagram of an application environment provided by an embodiment of the present application;
[0073] As shown in Figure 1, the application environment 100 includes: a host computer 10, an automobile communication device 20, and an automobile electronic control unit 30, wherein the host computer 10 and the automobile communication device 20 are connected to each other via wired or wireless communication, wherein the wired connection includes a USB connection, and the wireless connection includes Bluetooth, WiFi and other connection methods, and the automobile communication device 20 and the automobile electronic control unit 30 are connected to each other via a CAN bus.
[0074] In the embodiment of the present application, the host computer 10 can be a tablet computer or other input device with a touch screen and buttons as the basic input device, and the present application does not limit this. In the vehicle diagnosis scenario, when it is necessary to obtain the CAN bus baud rate, the host computer 10 is used to send a command to the lower computer, where the lower computer includes an automobile communication device 20. For example, the host computer 10 sends a detection instruction to the automobile communication device 20 to obtain the baud rate of multiple pin pairs on the CAN bus; the host computer 10 is also used to receive and store the correspondence between the pin pairs and the baud rate returned by the automobile communication device 20 for use in subsequent vehicle diagnosis.
[0075] It can be understood that the host computer in the embodiment of the present application also includes a storage module, which includes but is not limited to: FLASH flash memory, NAND flash memory, vertical NAND flash memory (VNAND), NOR flash memory, resistive random access memory (RRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), spin transfer torque random access memory (STT-RAM) and other devices. One or more.
[0076] In the embodiment of the present application, the vehicle communication device 20 refers to a VCI (vehicle communication interface). After the vehicle communication device is connected to the vehicle's OBD (On-Board Diagnostics) diagnostic socket via wired connection, the vehicle diagnostic device can be connected to the vehicle communication device via wired or wireless means to diagnose the vehicle. The automobile communication device 20 is a lower computer of the upper computer 10. The automobile communication device 20 is used to monitor the baud rate on the conventional pin pair when the automobile communication device is powered on, obtain the correspondence between the conventional pin pair and the conventional baud rate, and record the correspondence between the conventional pin pair and the conventional baud rate in a global array; when the automobile communication device receives a detection instruction sent by the upper computer, it obtains a pin pair list corresponding to the detection instruction, wherein the detection instruction includes a pin pair list, and the pin pair list includes at least one pin pair; if the correspondence between the pin pair and the baud rate in the pin pair list does not exist in the global array, the baud rate corresponding to the pin pair in the pin pair list is monitored; if the monitoring fails, the baud rate corresponding to the pin pair in the pin pair list is obtained, and the automobile communication device 20 is also used to record the obtained correspondence between the pin pair and the baud rate in a return array, wherein the return array is used to return the correspondence between the pin pair and the baud rate to the upper computer.
[0077] In an embodiment of the present application, the automotive electronic control unit 30 is disposed inside the vehicle and is configured to communicate with the automotive communication device 20 via the CAN bus. For example, the automotive electronic control unit receives broadcast messages sent by the automotive communication device and returns an acknowledgment signal to the automotive communication device. The automotive electronic control unit can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. The automotive electronic control unit can also be any conventional processor, controller, microcontroller, or state machine. The automotive electronic control unit can also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors combined with a DSP and / or any other such configuration, or a combination of one or more of a microcontroller unit (MCU), a field-programmable gate array (FPGA), and a system-on-chip (SoC).
[0078] Please refer to FIG2 , which is a flow chart of a method for obtaining the baud rate of a CAN bus provided in an embodiment of the present application;
[0079] Among them, the method for obtaining the baud rate of the CAN bus is applied to automobile communication equipment. The CAN bus includes multiple pin pairs. In actual situations, the multiple pin pairs include regular pin pairs and unconventional pin pairs. Specifically, the executor of the method for obtaining the baud rate of the CAN bus is one or at least two processors of the automobile communication equipment.
[0080] As shown in FIG2 , the method for obtaining the baud rate of the CAN bus includes:
[0081] Step S201: When the automobile communication device is powered on, the baud rate on the regular pin pair is monitored, the corresponding relationship between the regular pin pair and the regular baud rate is obtained, and the corresponding relationship between the regular pin pair and the regular baud rate is recorded in a global array;
[0082] Please refer to FIG3 again, which is a detailed flowchart of step S201 in FIG2 ;
[0083] As shown in FIG3 , step S201: when the automotive communication device is powered on, the baud rate on the conventional pin pair is monitored, the correspondence between the conventional pin pair and the conventional baud rate is obtained, and the correspondence between the conventional pin pair and the conventional baud rate is recorded in a global array, including:
[0084] Step S2011: when the automotive communication device is powered on, obtaining a conventional pin pair list and a conventional baud rate list;
[0085] Specifically, when the automotive communication device is powered on, a regular pin pair list and a regular baud rate list are obtained, wherein the regular pin pair list and the regular baud rate list are pre-set according to actual needs. The regular pin pair list includes at least one pair of regular pin pairs, and the regular pin pairs include but are not limited to 0x060e, 0x030b, 0x0308, 0x0b0c, 0x080c, 0x0109, 0x0c0d, and 0x0d0c. The regular baud rate list includes at least one regular baud rate, and the regular baud rates include but are not limited to 500K, 250K, 125K, and 1M.
[0086] It should be noted that step S201 is used to monitor the regular baud rate on the regular pin pair, then obtain the correspondence between the regular pin pair and the regular baud rate, and finally record the correspondence in a global array, which can be called in subsequent steps to improve monitoring efficiency.
[0087] In an embodiment of the present application, when the automobile communication device is plugged into the vehicle and powered on, the diagnostic host computer is often not yet ready for connection. The time difference between the time when the automobile communication device is powered on and the time when the diagnostic host computer is not connected is used to monitor the regular baud rate on the regular pin pair. Generally, since the total detection time of the regular baud rate on the regular pin pair takes more than 1 minute, which is a long time, the regular baud rate on the regular pin pair is detected when the automobile communication device is plugged into the vehicle and powered on. After the diagnostic host computer is connected, the baud rate can be obtained more quickly. If the correspondence between the regular pin pair and the regular baud rate is obtained, then when subsequent services need to call the correspondence between the regular pin pair and the regular baud rate, time can also be saved to improve efficiency.
[0088] Step S2012: selecting a pair of pins to be detected from the regular pin pair list as the first pin pair;
[0089] Specifically, a pair of pins to be detected is selected from the regular pin pair list as the first pin pair, and the regular baud rate on the first pin pair needs to be detected in subsequent steps.
[0090] Step S2013: determining whether the voltage of the first pin pair is the CAN bus voltage;
[0091] In the embodiment of the present application, the CAN bus is also called the controller area network. It is a bus system that realizes communication through differential voltage signals. The types of CAN buses include high-speed CAN, single-wire CAN, CAN FD, low-speed fault-tolerant CAN, etc. Different types of CAN buses have different characteristics. The solution of the present application is to identify and judge the voltage of the high-speed CAN bus. The connection between the CAN bus devices is a shielded twisted pair. When the CAN bus type is high-speed CAN, the voltage value of the current in one twisted wire is high, ranging from 2.5V to 3.5V, and the voltage value of the current in the other twisted wire is low, ranging from 1.5V to 2.5V. The resulting differential voltage range is 0-2V, which is the range of the CAN bus voltage in this application.
[0092] Specifically, obtain the voltage of the first pin pair, and determine whether the voltage of the first pin pair is the CAN bus voltage, that is, determine whether the voltage of the first pin pair meets the range of the CAN bus voltage. If the voltage of the first pin pair is the CAN bus voltage, enter step S2014; if the voltage of the first pin pair is not the CAN bus voltage, enter step S2012 to select the next pin to be detected from the regular pin list as the first pin.
[0093] Step S2014: On the first pin pair, monitor the regular baud rates in the regular baud rate list in sequence, and obtain the monitoring status of the regular baud rates;
[0094] Specifically, on the first pin pair, the regular baud rates in the regular baud rate list are monitored in turn, and the monitoring status of the regular baud rate is obtained, where the monitoring status includes a success status and a failure status. For example, assuming that the regular pin pair list includes eight regular pin pairs: 0x060e, 0x030b, 0x0308, 0x0b0c, 0x080c, 0x0109, 0x0c0d, and 0x0d0c, and the regular baud rate list includes four regular baud rates: 500K, 250K, 125K, and 1M. Currently, 0x060e is selected as the first pin pair. At this time, it is necessary to monitor the four regular baud rates of 500K, 250K, 125K, and 1M on the pin pair 0x060e. Each monitoring of a regular baud rate will return a corresponding monitoring status.
[0095] Step S2015: Determine whether there is a monitoring state of a regular baud rate that is in a successful state;
[0096] Specifically, after obtaining the monitoring status of all regular baud rates on the first pin pair, it is determined whether there is a regular baud rate monitoring status that is in a successful state. If there is a regular baud rate monitoring status that is in a successful state, the process proceeds to step S2016. If there is no regular baud rate monitoring status that is in a successful state, that is, no baud rate is monitored on the first pin pair, the process returns to step S2012 to select the next pin pair to be detected from the regular pin pair list as the first pin pair, and repeat the process. Perform steps S2012 to S2016 until all regular pin pairs in the regular pin pair list are detected. For example, assuming that the regular pin pair list includes eight regular pin pairs, namely 0x060e, 0x030b, 0x0308, 0x0b0c, 0x080c, 0x0109, 0x0c0d, and 0x0d0c, and the regular baud rate list includes four regular baud rates, namely 500K, 250K, 125K, and 1M, there are a total of 32 combinations of regular pin pairs and regular baud rates.
[0097] Step S2016: determining the normal baud rate as the baud rate on the first pin pair, and recording the correspondence between the first pin and the normal baud rate in a global array;
[0098] Specifically, a successful monitoring state indicates successful monitoring, i.e., the CAN bus is detected to be non-silent within a fixed time, and a correct waveform can be parsed from the CAN bus signal. If a monitoring state of a regular baud rate is successful, the regular baud rate is determined as the baud rate of the first pin pair, and the correspondence between the first pin pair and the regular baud rate is recorded in a global array, so that the correspondence between the regular pin pair and the regular baud rate in the global array can be directly called later. The global array is used to record the correspondence between the first pin pair and the regular baud rate.
[0099] In an embodiment of the present application, after the correspondence between the first pin pair and the conventional baud rate is recorded in the global array, if all the conventional pin pairs in the conventional pin pair list are detected, the monitoring of the baud rate on the conventional pin pair is terminated; if all the conventional pin pairs in the conventional pin pair list are not detected, the process returns to step S2012 to select the next pin pair to be detected from the conventional pin pair list as the first pin pair, and repeats steps S2012 to S2016 until all the conventional pin pairs in the conventional pin pair list are detected.
[0100] Step S202: When the automobile communication device receives the detection instruction sent by the host computer, it obtains the pin pair list and baud rate list corresponding to the detection instruction;
[0101] Specifically, when the upper computer needs to obtain the baud rate on the pin pair, it sends a detection instruction to the automobile communication device. When the automobile communication device receives the detection instruction sent by the upper computer, it obtains the pin pair list corresponding to the detection instruction, wherein the detection instruction includes a pin pair list, and the pin pair list includes at least one pin pair. It should be noted that the pin pair list corresponding to the detection instruction is pre-set and sent to the automobile communication device through the detection instruction.
[0102] Step S203: determining whether the global array contains a corresponding relationship between the pin pair and the baud rate in the pin pair list;
[0103] Please refer to FIG4 again, which is a detailed flowchart of step S203 in FIG2 ;
[0104] As shown in FIG4 , step S203 : determining whether there is a corresponding relationship between the pin pair in the pin pair list and the baud rate in the global array, including:
[0105] Step S2031: selecting a pair of pins to be detected from the pin pair list as a second pin pair;
[0106] Specifically, a pair of pins to be detected is selected from the pin pair list as the second pin pair, so as to subsequently monitor the baud rate on the second pin pair and obtain the corresponding relationship between the second pin pair and the baud rate.
[0107] Step S2032: calling the global array and determining whether there is a corresponding relationship between the second pin pair and the baud rate in the global array;
[0108] Specifically, the global array obtained in step S201 is called, and it is determined whether there is a correspondence between the second pin pair and the baud rate in the global array. If there is a correspondence between the second pin pair and the baud rate in the global array, it means that the baud rate on the second pin pair has been obtained in step S201, and the process goes to step S2033; if there is no correspondence between the second pin pair and the baud rate in the global array, it means that the baud rate on the second pin pair has not been obtained in step S201, and the process goes to step S2034.
[0109] Step S2033: Determine whether there is a corresponding relationship between the second pin pair and the baud rate in the global array;
[0110] Specifically, when it is determined that there is a corresponding relationship between the second pin pair and the baud rate in the global array, the process proceeds to step S204.
[0111] Step S2034: determining that there is no corresponding relationship between the second pin pair and the baud rate in the global array;
[0112] Specifically, when it is determined that there is no corresponding relationship between the second pin pair and the baud rate in the global array, the process proceeds to step S205.
[0113] Step S204: Record the corresponding relationship between the baud rates of the pin pairs in the pin pair list into the returned array;
[0114] Specifically, since it has been determined that there is a correspondence between the second pin pair and the baud rate in the global array, the correspondence between the second pin pair and the baud rate is directly obtained from the global array, and the correspondence between the second pin pair and the baud rate is recorded in the return array, and the next pin pair to be detected is selected from the pin pair list as the second pin pair, wherein the return array is used to store the correspondence between the second pin pair and the baud rate. In the subsequent process, the automobile communication device can return the return array to the host computer so that the host computer can obtain the correspondence between the second pin pair and the baud rate.
[0115] Step S205: monitoring the baud rate corresponding to the pin pair in the pin pair list;
[0116] Please refer to FIG5 again, which is a detailed flowchart of step S205 in FIG2 ;
[0117] As shown in FIG5 , step S205 : monitoring the baud rate corresponding to the pin pair in the pin pair list, including:
[0118] Step S2051: On the second pin pair, monitor the baud rates in the baud rate list in sequence and obtain the monitoring status of the baud rates;
[0119] Specifically, when there is no corresponding relationship between the second pin pair and the baud rate in the global array, the baud rates in the baud rate list are monitored in sequence on the second pin pair, and the monitoring status of the currently monitored baud rate is obtained each time the monitoring is performed, where the monitoring status includes a success status and a failure status.
[0120] Step S206: Determine whether monitoring fails;
[0121] Specifically, determine whether the monitoring fails, that is, determine whether the monitoring status of a certain baud rate is a success state. Each baud rate in the baud rate list has a corresponding monitoring status. Determine whether the monitoring status of a certain baud rate is a success state. If the monitoring status of a certain baud rate is a success state, enter step S207; if the monitoring status of a certain baud rate is not a success state, enter step S208.
[0122] Step S2053: Determine the baud rate as the baud rate on the second pin pair;
[0123] Specifically, if the monitoring state of a certain baud rate is a success state, it means that the baud rate is the baud rate of the second pin pair, and the baud rate is determined as the baud rate of the second pin pair.
[0124] Step S2054: Obtain the correspondence between the second pin pair and the baud rate, and record the correspondence between the second pin pair and the baud rate in the returned array;
[0125] Specifically, the correspondence between the second pin pair and the baud rate is obtained, where the correspondence means that the second pin pair corresponds to the baud rate at which the monitoring state is a successful state, and the correspondence between the second pin pair and the baud rate is recorded in the return array to return the correspondence between the second pin pair and the baud rate to the host computer.
[0126] Step S2055: Determine that monitoring fails, and obtain the baud rate corresponding to the pin pair in the pin pair list;
[0127] Specifically, if the monitoring status of a certain baud rate does not exist in the success state, it means that the baud rate is not monitored on the second pin pair, that is, it is determined that the monitoring fails, and the baud rate corresponding to the pin pair in the pin pair list is obtained.
[0128] In an embodiment of the present application, when monitoring fails, the present application can obtain the CAN bus baud rate by sending a frame of broadcast message to the vehicle electronic control unit, thereby improving the success rate of obtaining the CAN bus baud rate.
[0129] Step S208: Obtain the baud rate corresponding to the pin pair in the pin pair list;
[0130] Please refer to FIG6 again, which is a detailed flowchart of step S208 in FIG2 ;
[0131] As shown in FIG6 , step S208: obtaining the baud rate corresponding to the pin pair in the pin pair list includes:
[0132] Step S2081: Obtain the current baud rate to be detected from the baud rate list;
[0133] Specifically, the baud rate to be detected is obtained from the baud rate list, so that in subsequent steps, a broadcast message is actively sent to the vehicle electronic control unit according to the baud rate in the first baud rate detection list.
[0134] Step S2082: determining whether the baud rate to be detected is a baud rate in the first baud rate detection list;
[0135] Specifically, the first baud rate detection list includes at least one regular baud rate. It should be noted that the regular baud rate includes but is not limited to 250K and 500K baud rates. It is determined whether the baud rate to be detected is a baud rate in the first baud rate detection list. If the baud rate to be detected is a baud rate in the first baud rate detection list, step S2083 is entered; if the baud rate to be detected is not a baud rate in the first baud rate detection list, step S2084 is entered.
[0136] In the embodiment of the present application, the manufacturing fault code is referred to as "manufacturing code". After actively sending a frame of data during baud rate detection, if the baud rate of this frame of data does not match the actual baud rate on the bus, manufacturing code will occur. For example, the baud rate of a pin pair on the CAN bus is actually 500K. If the automobile communication device actively sends a frame of broadcast message at a baud rate of 150K, then the automobile electronic control unit will parse the waveform of this frame of broadcast message according to the baud rate of 500K, and the data finally parsed is not the correct parsing result. This incorrect parsing result is likely to be treated by the automobile electronic control unit as an abnormality of the vehicle equipment, and may even cause some automobile electronic control units to malfunction. The first baud rate detection list is set according to actual needs. In order to avoid the above-mentioned manufacturing code phenomenon, it is preferred that a small number of commonly used baud rates are preset in the first baud rate detection list.
[0137] Step S2083: Send a broadcast message frame to the vehicle electronic control unit on the second pin pair at the current baud rate to be detected;
[0138] In an embodiment of the present application, a frame broadcast message represents a broadcast frame, which includes a four-byte frame ID and a broadcast frame content of up to eight bytes, wherein the frame ID represents the address and the content of the broadcast frame represents the physical meaning of the broadcast frame. For example, assuming that the format of the broadcast frame is 0x00, 0x00, 0x07, 0xDF 0x02, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, then 0x00, 0x00, 0x07, 0xDF are the first four bytes, representing the frame ID of the broadcast frame, and 0x02, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF are the last eight bytes, representing the content of the broadcast frame.
[0139] Specifically, a frame of broadcast message is sent to the vehicle electronic control unit on the second pin pair at the current baud rate to be detected. For example, if the current baud rate to be detected is 250K, the vehicle communication device actively sends a frame of broadcast message with a baud rate of 250K to the vehicle electronic control unit.
[0140] Step S2084: Obtain the next baud rate to be detected from the baud rate list;
[0141] Specifically, if the current baud rate to be detected is not a baud rate in the first baud rate detection list, the next baud rate to be detected is obtained from the baud rate list to continue to determine whether the next baud rate to be detected is a baud rate in the first baud rate detection list.
[0142] Step S2085: Determine whether a first confirmation signal returned by the vehicle electronic control unit is received;
[0143] Specifically, after sending a broadcast message frame to the vehicle's electronic control unit, a determination is made within a fixed time period whether a first confirmation signal from the vehicle's electronic control unit has been received. If the first confirmation signal from the vehicle's electronic control unit has been received, the process proceeds to step S2086; if the first confirmation signal from the vehicle's electronic control unit has not been received, the process proceeds to step S2088.
[0144] Step S2086: Determine that the current baud rate to be detected is the baud rate of the second pin pair;
[0145] In the embodiments of the present application, an ACK (Acknowledge character) is an acknowledgement signal. In data communications, it is a transmission control character sent by a receiving station to a sending station to indicate that the received data has been received correctly. For example, in the present application, the automotive electronic control unit represents the receiving station, and the automotive communication device represents the sending station.
[0146] Specifically, if the first confirmation signal returned by the automobile electronic control unit is received, it means that after the automobile electronic control unit receives the broadcast message, it parses the waveform according to the baud rate to be detected corresponding to the broadcast message. When the automobile electronic control unit is able to parse the correct waveform, it sets ACK to a high level. When the automobile communication device recognizes that ACK is a high level, it determines that the baud rate to be detected is the baud rate on the second pin pair.
[0147] Step S2087: Obtain the correspondence between the second pin pair and the current baud rate to be detected, and record the correspondence in the returned array;
[0148] Specifically, after determining that the current baud rate to be detected is the baud rate on the second pin pair, the correspondence between the second pin pair and the current baud rate to be detected is obtained, and the correspondence is recorded in the return array, which returns the correspondence between the second pin pair and the current baud rate to be detected to the host computer.
[0149] Step S2088: Determine whether the baud rate list has been traversed;
[0150] Specifically, if the first confirmation signal returned by the vehicle electronic control unit is not received, it means that the baud rate to be detected is not the baud rate on the second pin, that is, no detection result is detected and no recording is required. Then, it is determined whether the baud rate list has been traversed. If the baud rate list has been traversed, step S2089 is entered; if the baud rate list has not been traversed, step S2810 is entered.
[0151] Step S2089: starting to send a broadcast message to the vehicle electronic control unit according to the second baud rate detection list to obtain a correspondence between the second pin pair and the baud rate to be detected;
[0152] In this embodiment of the present application, since the preset baud rates in the preset baud rate list are all conventional baud rates, if the baud rate list has been traversed and the baud rate of the second pin pair has not been detected, it indicates that the baud rate of the second pin pair is an unconventional baud rate, and it is necessary to initiate the acquisition of the unconventional baud rate of the second pin pair according to the second baud rate detection list. Through the following step S2089, the present application can further obtain the CAN bus baud rate, thereby improving the success rate of obtaining the CAN bus baud rate.
[0153] Please refer to FIG. 7 again, which is a detailed flowchart of step S2089 in FIG. 6 ;
[0154] As shown in FIG7 , step S2089: sending a broadcast message to the vehicle electronic control unit according to the second baud rate detection list to obtain the correspondence between the second pin pair and the current baud rate to be detected, including:
[0155] Step S2891: Obtain the current baud rate to be detected from the baud rate list;
[0156] Specifically, if the first confirmation signal returned by the vehicle electronic control unit is not received and the baud rate list has been traversed, the current baud rate to be detected is obtained from the baud rate list.
[0157] Step S2892: determining whether the baud rate to be detected is an unconventional baud rate in the second baud rate detection list;
[0158] Specifically, the second baud rate detection list includes at least one unconventional baud rate. It should be noted that the unconventional baud rate includes but is not limited to the baud rate of 50K. It is determined whether the baud rate to be detected is an unconventional baud rate in the second baud rate detection list. If the baud rate to be detected is an unconventional baud rate in the second baud rate detection list, step S2893 is entered; if the baud rate to be detected is not an unconventional baud rate in the second baud rate detection list, step S2894 is entered.
[0159] Step S2893: Send a broadcast message frame to the vehicle electronic control unit on the second pin pair at the current baud rate to be detected;
[0160] Specifically, a frame of broadcast message is sent to the vehicle electronic control unit on the second pin pair at the current baud rate to be detected. For example, if the current baud rate to be detected is 50K, the vehicle communication device actively sends a frame of broadcast message with a baud rate of 50K to the vehicle electronic control unit.
[0161] Step S2894: Obtain the next baud rate to be detected from the baud rate list;
[0162] Specifically, if the current baud rate to be detected is not an unconventional baud rate in the second baud rate detection list, the next baud rate to be detected is obtained from the baud rate list to continue to determine whether the next baud rate to be detected is an unconventional baud rate in the second baud rate detection list.
[0163] Step S2895: Determine whether a second confirmation signal returned by the vehicle electronic control unit is received;
[0164] Specifically, after sending a broadcast message frame to the vehicle's electronic control unit at the current baud rate to be detected, a determination is made within a fixed time period as to whether a second confirmation signal is received from the vehicle's electronic control unit. If the second confirmation signal is received from the vehicle's electronic control unit, the process proceeds to step S2896; if the second confirmation signal is not received from the vehicle's electronic control unit, the process proceeds to step S2898.
[0165] Step S2896: Determine that the baud rate to be detected is the baud rate of the second pin pair;
[0166] Specifically, if the second confirmation signal returned by the automobile electronic control unit is received, it means that after the automobile electronic control unit receives the broadcast message, it parses the waveform according to the baud rate to be detected corresponding to the broadcast message. When the automobile electronic control unit is able to parse a normal waveform, it sets ACK to a high level. When the automobile communication device recognizes that ACK is a high level, it determines that the baud rate to be detected is the baud rate on the second pin pair.
[0167] Step S2897: Obtain the correspondence between the second pin pair and the current baud rate to be detected, and record the correspondence in the returned array;
[0168] Specifically, after determining that the current baud rate to be detected is the baud rate on the second pin pair, the correspondence between the second pin pair and the current baud rate to be detected is obtained, and the correspondence is recorded in a return array, which returns the correspondence between the second pin pair and the current unconventional baud rate to be detected to the host computer.
[0169] Step S2898: Determine whether the baud rate list has been traversed;
[0170] Specifically, if the second confirmation signal returned by the vehicle electronic control unit is not received, it means that the unconventional baud rate to be detected is not the baud rate on the second pin, that is, no detection result is detected and no recording is required. Then, it is determined whether the baud rate list has been traversed. If the baud rate list has been traversed, step S2899 is entered; if the baud rate list has not been traversed, step S2500 is entered.
[0171] Step S2899: Select the next pin pair to be detected from the pin pair list as the second pin pair, and continue to monitor the baud rate on the second pin pair until all pin pairs to be detected in the pin pair list are traversed;
[0172] Specifically, if the baud rate list has been traversed, the next pin pair to be detected is selected from the pin pair list as the second pin pair, and the baud rate on the second pin pair is continuously monitored until all the pin pairs to be detected in the pin pair list are traversed. It can be understood that after continuing to monitor the baud rate on the second pin pair, if the correspondence between the second pin pair and the current baud rate to be detected is still not obtained, step S208 is performed, and so on, until the pin pair list has been traversed, stop obtaining the correspondence between the second pin pair and the current baud rate to be detected, and return the return array to the host computer.
[0173] Step S2900: Obtain the next baud rate to be detected from the baud rate list;
[0174] Specifically, if the baud rate list has not been traversed, the next baud rate to be detected is obtained from the baud rate list, and steps S2891 to S2899 are repeated until the baud rate list has been traversed or the correspondence between the second pin pair and the current baud rate to be detected is obtained, and the correspondence is recorded in the return array.
[0175] In the embodiment of the present application, since there is a risk of coding when actively sending messages to the electronic control unit of the vehicle, a small number of commonly used regular baud rates are set in the first baud rate detection list, and a small number of commonly used unconventional baud rates are set in the second baud rate detection list, thereby reducing the probability of coding in the vehicle and improving the user experience.
[0176] Please refer to FIG8 again, which is a schematic diagram of the overall process of monitoring the baud rate on a conventional pin pair provided by an embodiment of the present application;
[0177] As shown in Figure 8, the overall process of monitoring the baud rate on a regular pin pair includes:
[0178] Step S801: The automobile communication device is powered on.
[0179] Step S802: Obtain a regular pin pair list and a regular baud rate list.
[0180] Step S803: Select a pair of pins to be detected from the regular pin pair list as the first pin pair.
[0181] Step S804: Determine whether the regular pin pair list has been traversed.
[0182] Step S805: Determine whether the voltage of the first pin pair is the CAN bus voltage.
[0183] Step S806: On the first pin pair, monitor the regular baud rates in the regular baud rate list in sequence, and obtain the monitoring status of the regular baud rates.
[0184] Step S807: Determine whether there is a monitoring state of a certain regular baud rate that is a success state.
[0185] Step S808: Record the correspondence between the first pin and the normal baud rate in a global array.
[0186] Step S809: End monitoring the baud rate on the regular pin pair.
[0187] Among them, steps S801-S809 have been described in detail in the above embodiment, and will not be described in detail here to avoid repetition.
[0188] Please refer to FIG9 again, which is a schematic diagram of an overall process of obtaining the baud rate corresponding to the pin pair in the pin pair list provided by an embodiment of the present application;
[0189] As shown in Figure 9, the overall process of obtaining the baud rate corresponding to the pin pair in the pin pair list includes:
[0190] Step S901: The automobile communication device receives a detection instruction sent by a host computer.
[0191] Step S902: Obtain a pin pair list and a baud rate list corresponding to the detection instruction.
[0192] Step S903: Take the next pin pair in the pin pair list as a detection object.
[0193] Step S904: Determine whether the pin pair list has been traversed.
[0194] Step S905: Determine whether there is a correspondence between the second pin pair and the baud rate in the global array.
[0195] Step S906: Record the correspondence between the second pin pair and the baud rate in the global array into the return array.
[0196] Step S907: On the second pin pair, monitor the baud rates in the baud rate list in sequence and obtain the monitoring status of the baud rates.
[0197] Step S908: Determine whether there is a baud rate monitoring state that is a success state.
[0198] Step S909: Record the correspondence between the second pin pair and the baud rate in the returned array.
[0199] Step S910: Send a broadcast message frame to the vehicle electronic control unit.
[0200] Step S911: Determine whether the baud rate list has been traversed.
[0201] Step S912: Determine whether the baud rate to be detected is a baud rate in the first baud rate detection list.
[0202] Step S913: Return the correspondence between the second pin pair and the baud rate to the host computer.
[0203] Step S914: Send a broadcast message frame on the pin pair at the current baud rate to be detected.
[0204] Step S915: Determine whether the first confirmation signal is received.
[0205] Step S916: Record the correspondence between the second pin pair and the current baud rate to be detected in the returned array.
[0206] Among them, steps S901-S916 have been described in detail in the above embodiment, and will not be described in detail here to avoid repetition.
[0207] In an embodiment of the present application, a method for obtaining the baud rate of a CAN bus is provided, which is applied to an automobile communication device. The CAN bus includes multiple pin pairs, and the multiple pin pairs include conventional pin pairs. The method for obtaining the baud rate of the CAN bus includes: when the automobile communication device is powered on, monitoring the baud rate on the conventional pin pair, obtaining the correspondence between the conventional pin pair and the conventional baud rate, and recording the correspondence between the conventional pin pair and the conventional baud rate in a global array; when the automobile communication device receives a detection instruction sent by a host computer, obtaining a pin pair list corresponding to the detection instruction, wherein the detection instruction includes a pin pair list, and the pin pair list includes at least one pin pair; if the correspondence between the pin pair and the baud rate in the pin pair list does not exist in the global array, monitoring the baud rate corresponding to the pin pair in the pin pair list; if the monitoring fails, obtaining the baud rate corresponding to the pin pair in the pin pair list. By monitoring the baud rate corresponding to the pin pair in the pin pair list, if the monitoring fails, the baud rate corresponding to the pin pair in the pin pair list is obtained. This application can still obtain the CAN bus baud rate when the monitoring fails, thereby improving the success rate of obtaining the CAN bus baud rate.
[0208] Please refer to FIG10 again, which is a schematic diagram of the structure of a device for obtaining the baud rate of a CAN bus provided in an embodiment of the present application;
[0209] The device for acquiring the baud rate of the CAN bus is applied to automobile communication equipment. Specifically, the device for acquiring the baud rate of the CAN bus is applied to one or more processors of the automobile communication equipment.
[0210] As shown in FIG7 , the CAN bus baud rate acquisition device 1000 includes:
[0211] The first monitoring unit 1001 is used to monitor the baud rate on the regular pin pair when the automobile communication device is powered on, obtain the corresponding relationship between the regular pin pair and the regular baud rate, and record the corresponding relationship between the regular pin pair and the regular baud rate in a global array;
[0212] The list acquisition unit 1002 is configured to acquire a pin pair list corresponding to a detection instruction when the automobile communication device receives a detection instruction sent by the host computer, wherein the detection instruction includes a pin pair list, and the pin pair list includes at least one pin pair;
[0213] The second monitoring unit 1003 is configured to monitor the baud rate corresponding to the pin pair in the pin pair list if the corresponding relationship between the pin pair in the pin pair list and the baud rate does not exist in the global array;
[0214] The baud rate detection unit 1004 is configured to obtain the baud rate corresponding to the pin pair in the pin pair list if the monitoring fails.
[0215] In the embodiment of the present application, the first monitoring unit 1001 is specifically configured to:
[0216] When the car communication device is powered on, obtain a list of common pin pairs and common baud rates;
[0217] Select a pair of pins to be detected from the regular pin pair list as the first pin pair;
[0218] Determine whether the voltage of the first pin pair is the CAN bus voltage;
[0219] If the voltage of the first pin pair is the CAN bus voltage, then on the first pin pair, regular baud rates in the regular baud rate list are monitored in sequence, and a monitoring status of the regular baud rate is obtained, wherein the monitoring status includes a success status or a failure status;
[0220] If the monitoring state of a certain regular baud rate is a success state, the regular baud rate is determined as the baud rate on the first pin pair, and the corresponding relationship between the first pin pair and the regular baud rate is recorded in a global array.
[0221] In the embodiment of the present application, the second monitoring unit 1003 is specifically configured to:
[0222] Select a pair of pins to be detected from the pin pair list as the second pin pair;
[0223] Call the global array and determine whether there is a corresponding relationship between the second pin pair and the baud rate in the global array;
[0224] If a correspondence between the second pin pair and the baud rate exists in the global array, the correspondence between the second pin pair and the baud rate in the global array is recorded in the return array, and the next pin pair to be detected is selected from the pin pair list as the second pin pair, wherein the return array is used to store the correspondence between the second pin pair and the baud rate;
[0225] If there is no corresponding relationship between the second pin pair and the baud rate in the global array, the baud rates in the baud rate list are monitored in sequence on the second pin pair, and the monitoring status of the baud rate is obtained, where the monitoring status includes a success status or a failure status;
[0226] If the monitoring status of a certain baud rate is successful, the baud rate is determined to be the baud rate on the second pin pair;
[0227] Get the correspondence between the second pin pair and the baud rate, and record the correspondence between the second pin pair and the baud rate in the return array.
[0228] In the embodiment of the present application, the baud rate detection unit 1004 is specifically used to:
[0229] Get the current baud rate to be detected from the baud rate list;
[0230] Determining whether the baud rate to be detected is a regular baud rate in a first baud rate detection list, wherein the first baud rate detection list includes at least one regular baud rate;
[0231] If the baud rate to be detected is a regular baud rate in the first baud rate detection list, a broadcast message is sent to the vehicle electronic control unit on the second pin pair at the baud rate to be detected.
[0232] If a first confirmation signal returned by the vehicle electronic control unit is received, determining that the current baud rate to be detected is the baud rate on the second pin pair;
[0233] Get the correspondence between the second pin pair and the current baud rate to be detected, and record the correspondence in the return array;
[0234] If the first confirmation signal returned by the vehicle electronic control unit is not received and the baud rate list has been traversed, a broadcast message is sent to the vehicle electronic control unit according to the second baud rate detection list to obtain a correspondence between the second pin pair and the current baud rate to be detected;
[0235] According to the second baud rate detection list, a broadcast message is sent to the vehicle electronic control unit to obtain a correspondence between the second pin pair and the current baud rate to be detected, including:
[0236] Get the current baud rate to be detected from the baud rate list;
[0237] Determining whether the baud rate to be detected is an unconventional baud rate in a second baud rate detection list, wherein the second baud rate detection list includes at least one unconventional baud rate;
[0238] If the baud rate to be detected is an unconventional baud rate in the second baud rate detection list, a broadcast message is sent to the vehicle electronic control unit on the second pin pair at the baud rate to be detected.
[0239] If a second confirmation signal returned by the vehicle electronic control unit is received, determining that the unconventional baud rate to be detected is the baud rate on the second pin pair;
[0240] Get the correspondence between the second pin pair and the unconventional baud rate to be detected, record the correspondence in the return array, select the next pin pair to be detected from the pin pair list as the second pin pair, and continue to monitor the baud rate on the second pin pair until all pin pairs to be detected in the pin pair list are traversed.
[0241] In the embodiments of the present application, the CAN bus baud rate acquisition device can also be constructed by hardware devices. For example, the CAN bus baud rate acquisition device can be constructed by one or more chips, and the chips can work in coordination with each other to complete the CAN bus baud rate acquisition method described in the above embodiments. For another example, the CAN bus baud rate acquisition device can also be constructed by various logic devices, such as a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components.
[0242] The device for obtaining the baud rate of the CAN bus in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), an ATM, or an kiosks, etc., which are not specifically limited in the embodiment of the present application.
[0243] The device for acquiring the CAN bus baud rate in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0244] The device for obtaining the baud rate of the CAN bus provided in the embodiment of the present application can implement each process implemented in Figure 2. To avoid repetition, it will not be described here.
[0245] It should be noted that the above-mentioned device for obtaining the CAN bus baud rate can execute the method for obtaining the CAN bus baud rate provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects of executing the method. For technical details not fully described in the embodiment of the device for obtaining the CAN bus baud rate, reference can be made to the method for obtaining the CAN bus baud rate provided in the above embodiment.
[0246] In an embodiment of the present application, a device for obtaining the baud rate of a CAN bus is provided, comprising: a first monitoring unit, for monitoring the baud rate on a conventional pin pair when the automobile communication device is powered on, obtaining the correspondence between the conventional pin pair and the conventional baud rate, and recording the correspondence between the conventional pin pair and the conventional baud rate in a global array; a list acquisition unit, for obtaining a pin pair list corresponding to the detection instruction when the automobile communication device receives a detection instruction sent by a host computer, wherein the detection instruction includes a pin pair list, and the pin pair list includes at least one pin pair; a second monitoring unit, for monitoring the baud rate corresponding to the pin pair in the pin pair list if the correspondence between the pin pair and the baud rate in the pin pair list does not exist in the global array; a baud rate detection unit, for obtaining the baud rate corresponding to the pin pair in the pin pair list if the monitoring fails. The present application can still obtain the CAN bus baud rate when the monitoring fails, thereby improving the success rate of obtaining the CAN bus baud rate.
[0247] Please refer to FIG11 again, which is a schematic structural diagram of an automotive communication device provided by an embodiment of the present application;
[0248] As shown in Figure 11, the automobile communication device 20 includes one or more processors 201 and a memory 202. Figure 11 takes one processor 201 as an example.
[0249] The processor 201 and the memory 202 may be connected via a bus or other means. FIG11 takes the bus connection as an example.
[0250] The processor 201 is used to provide computing and control capabilities to control the automotive communication device 20 to perform corresponding tasks, for example, controlling the automotive communication device 20 to perform the method for obtaining the CAN bus baud rate in any of the above-mentioned method embodiments, including: when the automotive communication device is powered on, monitoring the baud rate on the regular pin pair, obtaining the correspondence between the regular pin pair and the regular baud rate, and recording the correspondence between the regular pin pair and the regular baud rate in a global array; when the automotive communication device receives a detection instruction sent by the host computer, obtaining a pin pair list corresponding to the detection instruction, wherein the detection instruction includes a pin pair list, and the pin pair list includes at least one pin pair; if the correspondence between the pin pair in the pin pair list and the baud rate does not exist in the global array, monitoring the baud rate corresponding to the pin pair in the pin pair list; if the monitoring fails, obtaining the baud rate corresponding to the pin pair in the pin pair list.
[0251] By monitoring the baud rate corresponding to the pin pair in the pin pair list, if the monitoring fails, the baud rate corresponding to the pin pair in the pin pair list is obtained. This application can still obtain the CAN bus baud rate when the monitoring fails, thereby improving the success rate of obtaining the CAN bus baud rate.
[0252] Processor 201 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or any combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0253] The memory 202 is a non-transitory computer-readable storage medium that can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as the program instructions / modules corresponding to the method for obtaining the baud rate of the CAN bus in the embodiment of the present application. The processor 201 can implement the method for obtaining the baud rate of the CAN bus in any of the following method embodiments by running the non-transitory software programs, instructions and modules stored in the memory 202. Specifically, the memory 202 may include a volatile memory (VM), such as a random access memory (RAM); the memory 202 may also include a non-volatile memory (NVM), such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD) or other non-transitory solid-state storage device; the memory 202 may also include a combination of the above types of memory.
[0254] The memory 202 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some embodiments, the memory 202 may optionally include a memory remotely located relative to the processor 201, and such remote memory may be connected to the processor 201 via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0255] One or more modules are stored in the memory 202. When executed by one or more processors 201, the method for obtaining the CAN bus baud rate in any of the above-mentioned method embodiments is executed, for example, the various steps shown in FIG. 2 described above are executed; the functions of the various modules or units in FIG. 10 may also be realized.
[0256] In the embodiment of the present application, the automobile communication device 20 may also have components such as a wired or wireless network interface and an input / output interface for input and output. The automobile communication device 20 may also include other components for realizing the functions of the device, which will not be described in detail here.
[0257] The present application also provides a non-volatile computer-readable storage medium, such as a memory including program code, which can be executed by a processor to implement the method for obtaining the CAN bus baud rate in the above embodiment. For example, the non-volatile computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CDROM), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0258] The present application also provides a computer program product comprising one or more program codes stored in a non-volatile computer-readable storage medium. A processor of an electronic device reads the program code from the non-volatile computer-readable storage medium and executes the program code to perform the steps of the method for obtaining the CAN bus baud rate provided in the above embodiment.
[0259] Those skilled in the art will understand that all or part of the steps for implementing the above embodiments may be accomplished by hardware, or by hardware related to program code, and the program may be stored in a non-volatile computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk, or an optical disk, etc.
[0260] Through the description of the above embodiments, it is clear to those skilled in the art that each embodiment can be implemented by means of software plus a general hardware platform, or of course by hardware. It is understood by those skilled in the art that all or part of the processes in the above embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0261] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Based on the idea of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations in different aspects of the present application as mentioned above. For the sake of simplicity, they are not provided in detail. Although the present application has been described in detail with reference to the aforementioned embodiments, ordinary technicians in this field should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for obtaining the baud rate of a CAN bus, characterized in that: Applied to automobile communication equipment, the CAN bus includes a plurality of pin pairs, the plurality of pin pairs include conventional pin pairs, and the method includes: When the automobile communication device is powered on, monitoring the baud rate on the conventional pin pair, obtaining the corresponding relationship between the conventional pin pair and the conventional baud rate, and recording the corresponding relationship between the conventional pin pair and the conventional baud rate in a global array; When the automobile communication device receives a detection instruction sent by the host computer, the pin pair list corresponding to the detection instruction is obtained, wherein the detection instruction includes the pin pair list, and the pin pair list includes at least one pin pair; If the corresponding relationship between the pin pair in the pin pair list and the baud rate does not exist in the global array, monitoring the baud rate corresponding to the pin pair in the pin pair list; If the monitoring fails, the baud rate corresponding to the pin pair in the pin pair list is obtained.
2. The method according to claim 1, characterized in that: When the automobile communication device is powered on, the baud rate on the conventional pin pair is monitored, the corresponding relationship between the conventional pin pair and the conventional baud rate is obtained, and the corresponding relationship between the conventional pin pair and the conventional baud rate is recorded in a global array, including: When the automobile communication device is powered on, obtaining a conventional pin pair list and a conventional baud rate list; Selecting a pair of pins to be detected from the conventional pin pair list as a first pin pair; Determining whether the voltage of the first pin pair is a CAN bus voltage; If the voltage of the first pin pair is the CAN bus voltage, then on the first pin pair, the regular baud rates in the regular baud rate list are monitored in sequence, and the monitoring status of the regular baud rates is obtained, wherein the monitoring status includes a success status or a failure status; If there is a regular baud rate whose monitoring state is a success state, the regular baud rate is determined as the baud rate on the first pin pair, and the corresponding relationship between the first pin pair and the regular baud rate is recorded in a global array.
3. The method according to claim 1, characterized in that After obtaining the pin pair list corresponding to the detection instruction, the method further includes: Selecting a pair of pins to be detected from the pin pair list as a second pin pair; Calling the global array, and determining whether there is a corresponding relationship between the second pin pair and the baud rate in the global array; If there is a correspondence between the second pin pair and the baud rate in the global array, the correspondence between the second pin pair and the baud rate in the global array is recorded in a return array, and the next pin pair to be detected is selected from the pin pair list as the second pin pair, wherein the return array is used to store the correspondence between the second pin pair and the baud rate.
4. The method according to claim 3, characterized in that The detection instruction further includes a baud rate list, wherein the baud rate list includes at least one baud rate, and if the global array does not contain a corresponding relationship between the pin pair in the pin pair list and the baud rate, monitoring the baud rate corresponding to the pin pair in the pin pair list includes: If the corresponding relationship between the second pin pair and the baud rate does not exist in the global array, on the second pin pair, the baud rates in the baud rate list are monitored in sequence, and the monitoring status of the baud rate is obtained, wherein the monitoring status includes a success status or a failure status; If the monitoring state of a certain baud rate is in a successful state, the baud rate is determined as the baud rate on the second pin pair; The correspondence between the second pin pair and the baud rate is obtained, and the correspondence between the second pin pair and the baud rate is recorded in a returned array.
5. The method according to claim 4, characterized in that The method further comprises: If the monitoring status of a certain baud rate does not exist in a successful state, it is determined that the monitoring fails, and the baud rate corresponding to the pin pair in the pin pair list is obtained.
6. The method according to claim 3, characterized in that The automobile communication device is communicatively connected to the automobile electronic control unit, and the obtaining of the baud rate corresponding to the pin pair in the pin pair list includes: Obtaining the current baud rate to be detected from the baud rate list; Determine whether the current baud rate to be detected is a regular baud rate in a first baud rate detection list, wherein the first baud rate detection list includes at least one regular baud rate; If the current baud rate to be detected is a regular baud rate in the first baud rate detection list, sending a broadcast message frame to the automotive electronic control unit on the second pin pair at the current baud rate to be detected; If a first confirmation signal returned by the automotive electronic control unit is received, determining that the current baud rate to be detected is the baud rate of the second pin pair; Obtain a correspondence between the second pin pair and the current baud rate to be detected, and record the correspondence in the returned array.
7. The method according to claim 6, characterized in that The method further comprises: If the first confirmation signal returned by the automotive electronic control unit is not received and the baud rate list has been traversed, a broadcast message is sent to the automotive electronic control unit according to the second baud rate detection list to obtain the correspondence between the second pin pair and the current baud rate to be detected.
8. The method according to claim 7, characterized in that The sending of a broadcast message to the automotive electronic control unit according to the second baud rate detection list to obtain a corresponding relationship between the second pin pair and the current baud rate to be detected includes: Get the current baud rate to be detected from the baud rate list; Determining whether the current baud rate to be detected is an unconventional baud rate in the second baud rate detection list, wherein the second baud rate detection list includes at least one unconventional baud rate; If the current baud rate to be detected is an unconventional baud rate in the second baud rate detection list, sending a broadcast message frame to the automotive electronic control unit on the second pin pair at the current baud rate to be detected; If a second confirmation signal returned by the automotive electronic control unit is received, determining that the unconventional baud rate to be detected is the baud rate on the second pin pair; Obtain the correspondence between the second pin pair and the unconventional baud rate to be detected, record the correspondence in the returned array, select the next pin pair to be detected from the pin pair list as the second pin pair, and continue to monitor the baud rate on the second pin pair until all pin pairs to be detected in the pin pair list are traversed.
9. An automobile communication device, characterized in that: include: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for acquiring the baud rate of the CAN bus as described in any one of claims 1-8.
10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores a computer program or instruction. When the computer program or instruction is executed, the method for obtaining the baud rate of the CAN bus as described in any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Method for obtaining baud rate and device
CN105334768A
Baud rate acquiring method and device
CN109656172A
CAN bus baud rate acquisition method, automobile communication equipment and storage medium
CN117579419A
Automatic baud rate detection
US6072827A