A bus decoding method, device, equipment and medium
By determining the specific level value in the bus data and calculating the decoding parameters in the bus decoding method, the problem of how to perform correct bus decoding when the parameters are unknown is solved, and an automated and efficient decoding process is achieved.
Patent Information
- Application Number
- CN202410715145.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-06-04
AI Technical Summary
How to correctly perform bus decoding when the parameters are unknown, especially in CAN bus, LIN bus and FlexRay bus used in automotive network communication.
By obtaining the bus data of the target bus, determine the first electric level value of less than the third electricity value and the largest number of times and the second electric level value greater than the third electric level value and the most number of times. Calculating the decoding parameter , Potter rate and signal type, then decoding.
In the case of a Potter rate and signal type that does not need to know in advance, automatically calculate the decoding parameter and perform correct decoding to improve the efficiency and accuracy of the understanding code.
Smart Images

Figure CN118764334B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of digital signal processing and provides a bus decoding method, device, equipment and medium. Background Art
[0002] CAN bus, LIN bus and FlexRay bus are all protocols used for automotive network communication. They play different roles in automotive electronic systems and are suitable for different application scenarios.
[0003] When decoding the data of these buses, it is necessary to know the specific information of the measured signal, such as baud rate, signal type, decoding threshold and other parameters. If these parameters are unknown, correct decoding cannot be performed. Summary of the invention
[0004] The present application provides a bus decoding method, apparatus, device and medium for solving the problem of how to perform bus decoding when parameters are unknown.
[0005] In a first aspect, a bus decoding method is provided, comprising:
[0006] Obtaining bus data of a target bus; the target bus adopts a differential signal transmission mode and uses a non-return-to-zero code;
[0007] Determine a first level value in the bus data that is less than a third level value and occurs most frequently, and a second level value in the bus data that is greater than the third level value and occurs most frequently;
[0008] Calculating a decoding parameter according to the first level value and the second level value;
[0009] The bus data is decoded according to the decoding parameters to obtain a decoding result.
[0010] Optionally, determining a first level value in the bus data that is less than a third level value and occurs most frequently, and a second level value in the bus data that is greater than the third level value and occurs most frequently, comprises:
[0011] Performing histogram statistics on the bus data to obtain statistical data;
[0012] Dividing the elements of the statistical data evenly into a first array and a second array;
[0013] Performing filtering and normalization processing on the first array to obtain a first target index;
[0014] Performing filtering and normalization processing on the second array to obtain a second target index;
[0015] Determine the element corresponding to the first target index in the bus data as the first level value in the bus data that is less than the third level value and has the largest number of occurrences;
[0016] The element corresponding to the third target index in the bus data is determined to be a second level value in the bus data that is greater than the third level value and has the largest number of occurrences; the third target index is determined based on the second target index.
[0017] Optionally, the decoding parameters include a decoding threshold, a baud rate, and a signal type; and calculating the decoding parameters according to the first level value and the second level value includes:
[0018] Calculating the decoding threshold and the baud rate according to the first level value and the second level value;
[0019] Determine the data width of each bit as a ratio between the sampling rate of the bus data and the baud rate;
[0020] Comparing the intermediate data of each bit with the decoding threshold to obtain the value of each bit; the intermediate data of each bit is determined according to the data width of each bit;
[0021] The idle time is determined according to the number of consecutive bits being 1, and the signal type is determined if the first bit of the signal being 0 appears after the idle time.
[0022] Optionally, calculating the decoding threshold and the baud rate according to the first level value and the second level value includes:
[0023] According to the first level value and the second level value, the formula for calculating the decoding threshold is as follows:
[0024]
[0025] Among them, X ref is the decoding threshold, x H is the second level value, x L is the first level value, max indicates taking the maximum value, and abs indicates taking the absolute value.
[0026] Optionally, calculating the decoding threshold and the baud rate according to the first level value and the second level value includes:
[0027] According to the first level value and the second level value, a calculation formula for determining an intermediate level value is as follows:
[0028]
[0029] Among them, Xmid is the intermediate level value, x H is the second level value, x L is the first level value;
[0030] According to the intermediate level value, the calculation formula for determining the reference position of each edge is as follows:
[0031]
[0032] Among them, Tref k is the reference position of the kth edge, X mid is the intermediate level value, i is the sequence number of the first data in the bus data that is greater than the intermediate level value, and x i is the ith data in the bus data, x i+1 is the i+1th data in the bus data;
[0033] According to the reference position of each edge, the interval values between all two adjacent edges are calculated;
[0034] The baud rate is calculated according to the interval values between all two adjacent edges.
[0035] Optionally, the baud rate is calculated according to the interval between two adjacent edges, including:
[0036] Sorting the interval values of all two adjacent edges to obtain sorted interval data;
[0037] According to formula (4), the minimum interval value is estimated:
[0038]
[0039] Among them, S′ min is the estimated minimum interval value, N is the number of intervals in the sorted interval data, S′ k is the k+1th interval value in the sorted interval data; S′0 is the first interval value in the sorted interval data, and Round means rounding to the nearest integer;
[0040] Judge S′ min Is it equal to S′0? If so, change S′ min Determine the minimum interval value for the best estimate; if not, set S′0 = S′ min Substitute into formula (4) and re-estimate the minimum interval value until the estimated S min Compared with the last estimated S′ min until they are equal, the estimated S min The minimum interval value determined as the best estimate;
[0041] Determine the number of bits of two adjacent edges according to the ratio between the interval values of all two adjacent edges and the best estimated minimum interval value;
[0042] A linear fit is performed according to the number of bits of the two adjacent edges, and the product of the slope of the fitted line and the sampling rate is determined as the baud rate.
[0043] Optionally, the target bus is a FlexRay bus; and determining the signal type according to a signal in which the first bit is 0 after the idle time includes:
[0044] Determine whether a complete FlexRay frame header can be parsed from 67 bits after the first bit is 0 after the idle time;
[0045] If yes, then determine that the signal type is the bus negative pole BM;
[0046] If not, it is determined that the signal type is bus positive BP.
[0047] In a second aspect, a bus decoding device is provided, comprising:
[0048] An acquisition module, used for acquiring bus data of a target bus; the target bus adopts a differential signal transmission mode and uses a non-return-to-zero code;
[0049] a determination module, configured to determine a first level value in the bus data that is less than a third level value and occurs most frequently, and a second level value in the bus data that is greater than the third level value and occurs most frequently;
[0050] A calculation module, configured to calculate a decoding parameter according to the first level value and the second level value;
[0051] The obtaining module is used to decode the bus data according to the decoding parameters to obtain a decoding result.
[0052] In a third aspect, the present application provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program file, and the processor executes the computer program file to implement the bus decoding method described in the first aspect.
[0053] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program file is stored, and a processor executes the computer program file to implement the bus decoding method described in the first aspect.
[0054] Compared with the prior art, the beneficial effects of the embodiments of the present application are as follows:
[0055] The present application provides a bus decoding method, which includes: obtaining bus data of a target bus; the target bus adopts a differential signal transmission mode and uses a non-return-to-zero code; determining a first level value in the bus data that is less than a third level value and occurs the most times, and a second level value in the bus data that is greater than the third level value and occurs the most times; calculating a decoding parameter according to the first level value and the second level value; decoding the bus data according to the decoding parameter to obtain a decoding result. In the present application, it is not necessary to know the baud rate and signal type of the measured signal in advance, and it is not necessary for the user to manually match the decoding threshold parameters. The decoding parameters can be intelligently calculated according to the bus data, thereby realizing fast and intelligent decoding according to the decoding parameters, thereby improving decoding efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0057] Attached Figure 1 A schematic diagram of the computer device structure of the hardware operating environment involved in the embodiments of the present application;
[0058] Attached Figure 2 A schematic diagram of a process flow of a bus decoding method provided in an embodiment of the present application;
[0059] Attached Figure 3 A schematic diagram of the principle of the ratio method provided in the embodiment of the present application;
[0060] Attached Figure 4 Another flow chart of the bus decoding method provided in the embodiment of the present application;
[0061] Attached Figure 5 A schematic diagram of a decoding result provided in an embodiment of the present application;
[0062] Attached Figure 6 Another schematic diagram of a decoding result provided in an embodiment of the present application;
[0063] Attached Figure 7 A schematic diagram of the structure of a bus decoding device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other arbitrarily. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0065] In order to solve the problem of how to perform bus decoding when the parameters are unknown, the embodiment of the present application provides a bus decoding method, which can be executed by a computer device. Figure 1 , attached Figure 1 A schematic diagram of the computer device structure of the hardware operating environment involved in the embodiment of the present application.
[0066] The computer device may include: a processor 101, such as a central processing unit (CPU), a communication bus 102, a network interface 103, a user interface 104, and a memory 105. The communication bus 102 is used to realize the connection and communication between these components. The user interface 104 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 104 may also include a standard wired interface and a wireless interface. The network interface 103 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 105 may optionally be a storage device independent of the aforementioned processor 101. The memory 105 may be a high-speed random access memory (RAM) memory, or it may be a stable non-volatile memory (NVM), such as at least one disk storage; the processor 101 may be a general-purpose processor, including a central processing unit, a network processor, etc., or it may be a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component.
[0067] Those skilled in the art will appreciate that Figure 1 The structure shown in the figure does not constitute a limitation on the computer device, and may include more or less components than shown in the figure, or combine some components, or arrange the components differently.
[0068] As attached Figure 1 As shown, the memory 105 as a storage medium may include an operating system, a network communication module, a user interface module and a bus decoding device.
[0069] In the attached Figure 1 In the computer device shown, the network interface 103 is mainly used for data communication with the network server; the user interface 104 is mainly used for data interaction with the user; the processor 101 and the memory 105 in the present application can be set in the computer device, and the computer device calls the bus decoding device stored in the memory 105 through the processor 101, and executes the bus decoding method provided in the embodiment of the present application.
[0070] Refer to the attached Figure 2 Based on the hardware device of the aforementioned embodiment, the embodiment of the present application provides a bus decoding method, comprising the following steps:
[0071] S201, obtaining bus data of the target bus.
[0072] In the specific implementation process, the data acquisition device collects the bus data of the target bus at a preset sampling rate and then sends it to the computer device. The data acquisition device is, for example, an oscilloscope, an acquisition card, etc. Since the bus data collected by the data acquisition device is an analog signal, the computer device can convert the bus data from an analog signal into a digital signal after acquiring the bus data of the target bus. i , i∈[1,N], N is the number of sampling points.
[0073] The target bus adopts the transmission mode of differential signal and uses non-return-to-zero code, which can be CAN bus, LIN bus, FlexRay bus, etc. These buses are introduced below.
[0074] 1. CAN bus (Controller Area Network)
[0075] CAN bus is a real-time communication protocol widely used in automotive and industrial control fields. It has the characteristics of high reliability and strong anti-interference ability, and is suitable for networks connecting multiple microcontrollers and sensors and other devices. CAN bus is usually used to transmit real-time control data and diagnostic information, such as engine control, vehicle stability system, air conditioning control, etc.
[0076] 2. LIN bus (Local Interconnect Network)
[0077] LIN bus is a protocol designed for simpler slave devices and low-speed communication, and is often used to connect auxiliary devices and sensors in vehicles, such as wipers, window controllers, etc. LIN bus is relatively low in cost and complexity, and is suitable for applications that do not require high bandwidth and speed.
[0078] 3. FlexRay bus
[0079] FlexRay bus is a high-performance real-time communication protocol designed specifically for connecting high-bandwidth, high-real-time control systems in vehicles, such as electronic stability control, automatic transmission control, etc. FlexRay bus has the characteristics of high bandwidth, dual channels, flexible time slot arrangement, etc., and is suitable for complex real-time control scenarios.
[0080] S202: Determine a first level value in the bus data that is smaller than the third level value and appears the most times, and a second level value in the bus data that is larger than the third level value and appears the most times.
[0081] The third level value is equal to the difference between the maximum level value and the minimum level value in the bus data divided by 2, for example: Among them, x max is the bus data x i The maximum level value in x min is the bus data x i The minimum level value in . It should be noted that if If the value of is a decimal, it is rounded to an integer as the third level value.
[0082] In a possible embodiment, a histogram is performed on the bus data to obtain statistical data; the elements of the statistical data are evenly divided into a first array and a second array; the first array is filtered and normalized to obtain a first target index; the second array is filtered and normalized to obtain a second target index; the data corresponding to the first target index in the bus data is determined to be a first level value in the bus data that is less than a third level value and occurs the most times; the data corresponding to the third target index in the bus data is determined to be a second level value in the bus data that is greater than the third level value and occurs the most times; the third target index is determined based on the second target index.
[0083] In the specific implementation process, the bus data x of the digital signal i Make histogram statistics. The statistical interval is the difference between the maximum level value and the minimum level value in the bus data divided by 256. Count the number of level values in each scale coordinate Y j , j∈[0, 255], which is statistical data.
[0084] For example:
[0085]
[0086] Among them, Y j represents the number of data points in the jth scale coordinate, His represents the histogram statistics, x i Bus data representing digital signals, represents the statistical interval, x max is the maximum level value in the bus data, x min is the minimum level value in the bus data. If the value is a decimal, it will be rounded to an integer as the statistical interval.
[0087] Y j The first 128 elements in the first array Y Lj , j∈[0,127], the last 128 elements form the second array Y Hj , j∈[0,127], filter and normalize the first array to obtain the first target index, and filter and normalize the second array to obtain the second target index. The following takes the first array as an example to introduce the filtering and normalization process.
[0088] First, use the convolution feature to transform the first array Y Lj Perform filtering and smoothing to eliminate the error caused by abnormal signals. The calculation formula is:
[0089] Y Lj ′=Conn(Y Lj ,g(τ)) (6)
[0090] Among them, g(τ) represents the convolution kernel, with 4 sliding averages as reference, g(τ) = [0.25, 0.5, 0.25], Y Lj Represents the first array, Y Lj ′ represents the first array after filtering, and con represents the convolution operation.
[0091] Then, determine the first array Y Lj The index n corresponding to the maximum value of the element max With the first array Y after filtering Lj The index n corresponding to the maximum value of the element in ′ max ' are equal, if so, the first array Y Lj The index n corresponding to the maximum value of the element max Or the first array Y after filtering Lj The index n corresponding to the maximum value of the element in ′ max ’ is determined as the first target index.
[0092] If not, let Y Lj =Y Lj', and put it into formula (6), until the first array Y after this filtering Lj The index corresponding to the maximum value of the element in ′ is the same as the first array Y after the last filtering Lj ′, or the maximum number of filtering times is reached, for example, 5 times, and the first array Y after the last filtering is Lj The index corresponding to the maximum value of the elements in ′ is determined as the first target index.
[0093] Finally, according to the first target index, determine the first level value x in the bus data that is less than the third level value and has the largest number of occurrences L , the calculation formula is: Among them, n max1 is the first target index, Bus data x representing digital signals i The index value in is n max1 level value.
[0094] Similarly, the second array is subjected to the above filtering and normalization processing to obtain a second target index, and the second level value x that is greater than the third level value and has the largest number of occurrences in the bus data is determined according to the second target index. H , the calculation formula is: H =x(n max2 +128), where n max2 is the second target index, n max2 +128 is the third target index, x(n max2 +128) represents the bus data x of the digital signal i The index value in is n max2 A level value of +128.
[0095] S203: Calculate a decoding parameter according to the first level value and the second level value.
[0096] The decoding parameters include decoding threshold, baud rate and signal type.
[0097] In a possible embodiment, step S203 includes:
[0098] According to the first level value and the second level value, a decoding threshold and a baud rate are calculated; the ratio between the sampling rate and the baud rate of the bus data is determined as the data width of each bit; the intermediate data of each bit is compared with the decoding threshold to obtain the value of each bit; the intermediate data of each bit is determined according to the data width of each bit; the idle time is determined according to the number of consecutive bits that are 1, and the signal type is determined according to the signal in which the first bit is 0 after the idle time.
[0099] In the specific implementation process, after calculating the decoding threshold and the baud rate according to the first level value and the second level value, the sampling rate of the data acquisition device is divided by the baud rate to obtain the data width of each bit. The intermediate data of each bit is determined according to the data width of each bit, and the intermediate data of each bit is compared with the decoding threshold. If it is greater than the decoding threshold, the value of the bit, that is, the decoding result, is 1. If it is less than the decoding threshold, otherwise the value of the bit, that is, the decoding result, is 0.
[0100] The idle time levels of the CAN bus, LIN bus, and FlexRay bus are all determined by the bus terminals. According to the FlexRay transmission protocol, the maximum number of consecutive bits at the same level is the frame start sequence (FSS), and the maximum value is 15 bits. If it exceeds 15 bits, a level flip will occur. The idle time between two FlexRay frames is much longer than 30 bits. Therefore, for the FlexRay bus, if there are more than 30 consecutive bits that are 1, the time period is determined to be idle time.
[0101] In a possible embodiment, according to the first level value and the second level value, a formula for calculating the decoding threshold is as follows:
[0102]
[0103] Among them, X ref is the decoding threshold, x H is the second level value, x L is the first level value, max means taking the maximum value, abs means taking the absolute value. 0.1 means the redundancy ratio, adding 10% redundancy to increase the fault tolerance and stability of the signal.
[0104] In the traditional method, the tester manually defines the decoding threshold according to different signal types to find the decoding threshold with the best decoding result. In the embodiment of the present application, the decoding threshold is intelligently calculated through algorithms such as histogram statistics, convolution, and normalization.
[0105] As described above, how to calculate the decoding threshold is introduced. In addition, the baud rate of the target bus includes multiple types, such as the baud rate of the FlexRay bus signal, for example: 2.5Mbit / s, 5Mbit / s, 10Mbit / s, etc. In the traditional decoding process, the current signal rate must be known, otherwise the signal cannot be decoded correctly. The following describes how to calculate the baud rate.
[0106] In a possible embodiment, a calculation formula for determining an intermediate level value according to the first level value and the second level value is as follows:
[0107]
[0108] Among them, X mid is the middle level value, x H is the second level value, x L is the first level value;
[0109] According to the intermediate level value, the calculation formula for determining the reference position of each edge is as follows:
[0110]
[0111] Among them, Tref k is the reference position of the kth edge, X mid is the intermediate level value, i is the serial number of the first data in the bus data that is greater than the intermediate level value, and x i is the i-th data in the bus data, x i+1 is the i+1th data in the bus data;
[0112] According to the reference position of each edge, the intervals between all two adjacent edges are calculated;
[0113] The baud rate is calculated based on the intervals between all adjacent edges.
[0114] In the specific implementation process, in order to more accurately obtain the reference position of each edge, the ratio method is used to correct the position to reduce the error. Figure 3 , is a schematic diagram of the principle of the ratio method provided in the embodiment of the present application. Figure 3 The following formula can be obtained:
[0115]
[0116] Where P represents the calculated corrected position, x ref is the decoding threshold, i is the serial number of the first data in the bus data that is less than the decoding threshold, x i is the i-th data in the bus data, x i+1 It is the i+1th data in the bus data.
[0117] The formula for calculating the interval between two adjacent edges is as follows:
[0118] S k =Tref k+1 -Tref k (8)
[0119] Among them, S k is the kth interval value, Tref k is the reference position of the kth edge, Tref k+1 is the reference position of the k+1th edge.
[0120] In an embodiment of the present application, the reference position of the edge is corrected by the ratio method to reduce the error, which can improve the accuracy of the reference position of each edge. By improving the accuracy of the reference position, the error in the baud rate calculation can be reduced, thereby improving the accuracy of subsequent baud rate calculations.
[0121] In a possible embodiment, the reciprocal of the minimum value in the intervals between all two adjacent edges may be determined as the baud rate.
[0122] In another possible embodiment, the intervals between all two adjacent edges are sorted to obtain sorted interval data; and the minimum interval is estimated according to formula (4):
[0123]
[0124] Among them, S′ min is the estimated minimum interval value, N is the number of intervals in the sorted interval data, S k is the k+1th interval value in the sorted interval data; S′0 is the first interval value in the sorted interval data, and Round means rounding.
[0125] Determine whether S′min is equal to S′0. If so, change S′ min Determine the minimum interval value for the best estimate; if not, set S′0 = S′ min Substitute into formula (4) and re-estimate the minimum interval value until the estimated S′ is min Compared with the last estimated S′ min Until they are equal, the estimated S′ min The minimum interval value determined as the best estimate.
[0126] The number of bits between two adjacent edges is determined based on the ratio between the interval values of all two adjacent edges and the best estimated minimum interval; a linear fit is performed based on the number of bits between two adjacent edges, and the product of the slope of the fitted line and the sampling rate is determined as the baud rate.
[0127] For example:
[0128]
[0129] Among them, S k is the kth interval value, S′ min is the minimum interval value for the best estimate, Round means rounding, y k Indicates the number of bits between two adjacent edges.
[0130] (slope,intercept)=Linear(y k , z k ) (10)
[0131] Among them, y k represents the number of bits between two adjacent edges, z k represents the accumulation of the number of bits in the first k intervals, then z0 = 0, z k =y k +z k-1 ; Linear represents linear fitting, slope represents the slope of the linear fitting line, intercept represents the intercept of the linear fitting line, y k Indicates the number of bits between two adjacent edges.
[0132] R=slope×H (11)
[0133] Where R is the baud rate, slope is the slope of the linear fit line, and H is the sampling rate, which is determined by the data acquisition device.
[0134] Considering that the reciprocal of the minimum value of two adjacent intervals is directly used as the baud rate, the error introduced in the entire calculation process of this calculation method will cause a relatively large deviation in the calculation result. Therefore, in the embodiment of the present application, the multiple sampling results are averaged by multiple averaging method, thereby reducing the baud rate calculation error introduced by the single sampling error, and multiple averaging can effectively smooth the data, reduce the influence of random errors, and improve the accuracy of baud rate calculation. Then, the linear fitting method is used to help eliminate the influence of random errors and noise on the baud rate calculation, thereby obtaining a more accurate baud rate.
[0135] In a possible embodiment, the target bus is a FlexRay bus; according to a signal in which the first bit is 0 after an idle time, the step of determining the signal type includes:
[0136] It is determined whether the 67 bits after the first bit being 0 after the idle time can parse out a complete FlexRay frame header; if so, the signal type is determined to be the bus negative pole BM; if not, the signal type is determined to be the bus positive pole BP.
[0137] In the specific implementation process, it is determined whether the 67 bits (including this bit) after the first bit is 0 after the idle time are sufficient to contain the complete FlexRay frame header information. If so, it means that the 67 bits contain the complete FlexRay frame header, and the signal is determined to be BM. If not, it means that the 67 bits do not contain the complete FlexRay frame header, and the signal is determined to be BP.
[0138] In the embodiment of the present application, the signal type is determined by correctly parsing the FlexRay frame header. Determining the signal type can help the decoder correctly interpret the meaning and structure of the data, thereby helping to improve the accuracy of decoding.
[0139] It should be noted that the differential of the FlexRay bus is represented by BP and BM, BP is responsible for transmitting positive level signals, and BM is responsible for transmitting negative level signals. The differential of the CAN bus and the LIN bus is represented by CAN-H and CAN-L, CAN-H can be understood as BP, and CAN-L can be understood as BM. Similarly, according to the bus protocols corresponding to the CAN bus and the LIN bus, the signal type can be determined as CAN-H or CAN-L according to the signal with the first bit of 0 appearing after the idle time.
[0140] S204: Decode the bus data according to the decoding parameters to obtain a decoding result.
[0141] Specifically, decoding is performed according to the determined signal type and the frame encoding method specified by the protocol of the target bus. The decoding process is introduced below by taking the FlexRay bus as an example.
[0142] If the signal is BP, the collected data sequence is multiplied by -1 and converted into BM, and then the subsequent decoding is performed. First, the Transmission Start Sequence (TSS) is determined, the first Byte Start Sequence (BSS) is parsed, and then the frame header 40 bits of data is parsed, the data is parsed, and then the Frame End Sequence (FES) and Dynamic Trailing Sequence (DTS) are parsed, and then the next frame is parsed.
[0143] Please refer to the attached Figure 4 , is another flow chart of the bus decoding method provided by the embodiment of the present application. First, the bus data of the target bus is input, then the decoding threshold is calculated, the baud rate is calculated, the signal type is matched, and finally decoding is performed.
[0144] Decode the FlexRay bus signal with a baud rate of 2.5MHz, a level of Vpp=2.6V, a signal type of BM, and data of 0xAAAA, 0xAAAA, ... The sampling rate of the data acquisition device is 125MSa / s. The decoding results are shown in the attached figure. Figure 5 As shown in the figure, the frame header starting position is judged correctly, the frame header information is correct, and the decoded data is consistent with the input data.
[0145] Decode the FlexRay bus signal with a baud rate of 10MHz, a level of Vpp = 2.6V, a signal type of BM, and data of 0xAAAA, 0xAAAA, ... The sampling rate of the data acquisition device is 500MSa / s. The decoding results are shown in the attached figure. Figure 6 As shown in the figure, the frame header starting position is judged correctly, the frame header information is correct, and the decoded data is consistent with the input data.
[0146] To summarize, the embodiment of the present application also provides a bus decoding method. When decoding the CAN bus, LIN bus, and FlexRay bus, there is no need to know the baud rate and signal type of the measured signal in advance, and the user does not need to manually match the decoding threshold parameters. The decoding threshold, baud rate, signal type and other parameters required for decoding can be intelligently calculated based on the collected digital signal, thereby achieving correct decoding.
[0147] Based on the same inventive concept, as shown in the attached Figure 7 As shown, the embodiment of the present application also provides a bus decoding device, the device comprising:
[0148] The acquisition module is used to acquire bus data of the target bus; the target bus adopts a differential signal transmission mode and uses a non-return-to-zero code;
[0149] A determination module, used to determine a first level value in the bus data that is less than a third level value and occurs most frequently, and a second level value in the bus data that is greater than the third level value and occurs most frequently;
[0150] A calculation module, used for calculating a decoding parameter according to the first level value and the second level value;
[0151] The acquisition module is used to decode the bus data according to the decoding parameters to obtain the decoding results.
[0152] It should be noted that each module in the bus decoding device in this embodiment corresponds one-to-one to each step in the bus decoding method in the aforementioned embodiment. Therefore, the specific implementation of this embodiment can refer to the implementation of the aforementioned bus decoding method, which will not be repeated here.
[0153] In addition, in one embodiment, the present application also provides a computer device, which includes a processor, a memory, and a computer program file stored in the memory, and the computer program file implements the aforementioned bus decoding method when executed by the processor.
[0154] In addition, in one embodiment, the present application further provides a computer storage medium, on which a computer program file is stored, and the computer program file implements the aforementioned bus decoding method when executed by a processor.
[0155] In some embodiments, the computer readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or various devices including one or any combination of the above memories. The computer may be various computing devices including intelligent terminals and servers.
[0156] In some embodiments, executable instructions may be in the form of program files, software, software modules, scripts or codes, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone program files or as modules, components, subroutines or other units suitable for use in a computing environment.
[0157] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other program files or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program file in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutine files, or code portions).
[0158] By way of example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.
[0159] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0160] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0161] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a multimedia terminal device (which can be a mobile phone, a computer, a television receiver, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0162] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A bus decoding method, characterized in that: include: Get the bus data of the target bus; The target bus adopts a differential signal transmission mode and uses a non-return-to-zero code; Determine a first level value in the bus data that is less than a third level value and occurs most frequently, and a second level value in the bus data that is greater than the third level value and occurs most frequently; Calculating a decoding parameter according to the first level value and the second level value; Decoding the bus data according to the decoding parameters to obtain a decoding result; The decoding parameters include decoding threshold, baud rate and signal type; The calculating a decoding parameter according to the first level value and the second level value includes: Calculating the decoding threshold and the baud rate according to the first level value and the second level value; Determine the ratio between the sampling rate of the bus data and the baud rate as the data width of each bit; Comparing the intermediate data of each bit with the decoding threshold to obtain the value of each bit; the intermediate data of each bit is determined according to the data width of each bit; The idle time is determined according to the number of consecutive bits being 1, and the signal type is determined if the first bit of the signal being 0 appears after the idle time.
2. The bus decoding method according to claim 1, characterized in that: Determining a first level value in the bus data that is less than a third level value and occurs the most times, and a second level value in the bus data that is greater than the third level value and occurs the most times, comprises: Performing histogram statistics on the bus data to obtain statistical data; Dividing the elements of the statistical data evenly into a first array and a second array; Performing filtering and normalization processing on the first array to obtain a first target index; Performing filtering and normalization processing on the second array to obtain a second target index; Determine the element corresponding to the first target index in the bus data as the first level value in the bus data that is less than the third level value and has the largest number of occurrences; The element corresponding to the third target index in the bus data is determined to be a second level value in the bus data that is greater than the third level value and has the largest number of occurrences; the third target index is determined based on the second target index.
3. The bus decoding method according to claim 1, characterized in that: Calculating the decoding threshold and the baud rate according to the first level value and the second level value includes: According to the first level value and the second level value, the formula for calculating the decoding threshold is as follows: Among them, X ref is the decoding threshold, x H is the second level value, x L is the first level value, max indicates taking the maximum value, and abs indicates taking the absolute value.
4. The bus decoding method according to claim 1, characterized in that: Calculating the decoding threshold and the baud rate according to the first level value and the second level value includes: According to the first level value and the second level value, a calculation formula for determining an intermediate level value is as follows: Among them, X mid is the intermediate level value, x H is the second level value, x L is the first level value; According to the intermediate level value, the calculation formula for determining the reference position of each edge is as follows: Among them, Tref k is the reference position of the kth edge, X mid is the intermediate level value, i is the sequence number of the first data in the bus data that is greater than the intermediate level value, and x i is the ith data in the bus data, x i+1 is the i+1th data in the bus data; According to the reference position of each edge, the interval values between all two adjacent edges are calculated; The baud rate is calculated according to the interval values between all two adjacent edges.
5. The bus decoding method according to claim 4, characterized in that: The baud rate is calculated according to the interval between two adjacent edges, including: Sorting the interval values of all two adjacent edges to obtain sorted interval data; According to formula (4), the minimum interval value is estimated: Among them, S′ min is the estimated minimum interval value, N is the number of intervals in the sorted interval data, S′ k is the k+1th interval value in the sorted interval data; S′0 is the first interval value in the sorted interval data, and Round means rounding to the nearest integer; Judge S′ min Is it equal to S′0? If so, change S′ min Determine the minimum interval value for the best estimate; if not, set S′0 = S′ min Substitute into formula (4) and re-estimate the minimum interval value until the estimated S′ is min Compared with the last estimated S′ min Until they are equal, the estimated S′ min The minimum interval value determined as the best estimate; Determine the number of bits of two adjacent edges according to the ratio between the interval values of all two adjacent edges and the best estimated minimum interval value; A linear fit is performed according to the number of bits of the two adjacent edges, and the product of the slope of the fitted line and the sampling rate is determined as the baud rate.
6. The bus decoding method according to claim 4, characterized in that: The target bus is a FlexRay bus; Determining the signal type according to a signal in which the first bit is 0 after the idle time includes: Determine whether a complete FlexRay frame header can be parsed from 67 bits after the first bit is 0 after the idle time; If yes, then determine that the signal type is the bus negative pole BM; If not, it is determined that the signal type is bus positive BP.
7. A bus decoding device, characterized in that: include: An acquisition module, used for acquiring bus data of a target bus; The target bus adopts a differential signal transmission mode and uses a non-return-to-zero code; a determination module, configured to determine a first level value in the bus data that is less than a third level value and occurs most frequently, and a second level value in the bus data that is greater than the third level value and occurs most frequently; A calculation module, configured to calculate a decoding parameter according to the first level value and the second level value; An obtaining module, used for decoding the bus data according to the decoding parameters to obtain a decoding result; The decoding parameters include decoding threshold, baud rate and signal type; The method of calculating decoding parameters according to the first level value and the second level value includes: calculating the decoding threshold and the baud rate according to the first level value and the second level value; determining the ratio between the sampling rate of the bus data and the baud rate as the data width of each bit; comparing the intermediate data of each bit with the decoding threshold to obtain the value of each bit; the intermediate data of each bit is determined according to the data width of each bit; determining the idle time according to the number of consecutive bits that are 1, and determining the signal type by the first bit of the signal being 0 appearing after the idle time.
8. A computer device, characterized in that: The computer device comprises a memory and a processor, wherein the memory stores a computer program file, and the processor executes the computer program file to implement the bus decoding method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program file, and the processor executes the computer program file to implement the bus decoding method according to any one of claims 1 to 6.
Citation Information
Patent Citations
LIN bus decoding, triggering and analyzing technology
CN106021165A
Bus signal protocol decoding method
CN106850339A