A method, device, equipment and medium for converting effective bits of a byte sequence
Patent Information
- Application Number
- CN202311107459.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2043-08-30
AI Technical Summary
[0002]在DBC文件(Database Can,Can的数据库文件,或通信矩阵数据库文件)中,针对跨字节的信号,有大端序(Motorola)和小端序(Intel)两种字节序,由于不同的车厂商设计者风格不一,工程师拿到DBC文件时,可以发现小端序的信号起始位是最低有效位LSB(LeastSignificant Bit)的数值,但是大端序的信号,只能看到最高有效位MSB(MostSignificant Bit)的数值
[0035]As can be seen, this application proposes a method for converting the effective bit of a byte order, comprising: acquiring a target communication matrix database file, parsing the target communication matrix database file to obtain the byte order, signal length, and first effective bit value of the target signal; determining a signal layout list based on the message length and the byte order, and determining a second effective bit value from the signal layout list based on the signal length and the first effective bit value, so that the user can view it. In summary, since the byte order can include big-endian and little-endian, and the effective bits can include the most significant bit and the least significant bit, on the one hand, when the byte order in this application is big-endian, this application can obtain the most significant bit value, and then determine the signal layout list based on the message length and the big-endian, and then determine the least significant bit value from the signal layout list based on the signal length and the most significant bit value to obtain the true start bit of the signal. That is, this application does not need to determine whether the signal spans bytes, nor does it need to start each byte individually. On the other hand, when the byte order in this application is little-endian, this application can obtain the least significant bit value, and then determine the signal layout list based on the message length and the little-endian order. Then, based on the signal length and the least significant bit value, the most significant bit value is determined from the signal layout list, thus realizing the conversion between the least significant bit value and the most significant bit value. As can be seen from the above, the conversion process of the significant bits in this application does not require determining whether the signal spans bytes, reducing the conversion complexity and computational load.
Smart Images

Figure CN117240842B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and in particular to a method, apparatus, device, and medium for converting the effective bits of byte order. Background Technology
[0002] In DBC files (Database Can, the database file for CAN, or the communication matrix database file), there are two byte orders for signals that span multiple bytes: big-endian (Motorola) and little-endian (Intel). Because different car manufacturers have different design styles, engineers receiving DBC files will find that the start bit of a little-endian signal is the value of its least significant bit (LSB), while for big-endian signals, only the most significant bit (MSB) is visible. On one hand, for big-endian signals, calculating the start bit requires determining whether the signal spans multiple bytes, and may even require calculating the start bit byte by byte. On the other hand, in practical applications, it is sometimes necessary to convert the significant bits under a certain byte order and provide the conversion result to the user.
[0003] Therefore, how to obtain the true start bit of the signal, and how to convert the most significant bit value and the least significant bit value of the byte order so that users can view them, are problems that urgently need to be solved in this field. Summary of the Invention
[0004] In view of this, the purpose of this invention is to provide a method, apparatus, device, and medium for converting the significant bit of a byte order, which can obtain the true start bit of a signal and convert the most significant bit value and the least significant bit value of the byte order for user viewing. The specific solution is as follows:
[0005] Firstly, this application discloses a method for valid bit conversion of byte order, including:
[0006] Obtain the target communication matrix database file and parse the target communication matrix database file to obtain the byte order, signal length and first effective bit value of the target signal;
[0007] A signal layout list is determined based on the message length and the byte order, and a second valid bit value is determined from the signal layout list based on the signal length and the first valid bit value, so that the user can view it.
[0008] Optionally, parsing the target communication matrix database file to obtain the byte order, signal length, and first significant bit value of the target signal includes:
[0009] The target communication matrix database file is parsed to obtain the big-endian order of the target signal, the length of the first signal, and the value of the most significant bit.
[0010] Optionally, determining the signal layout list based on the message length and the byte order includes:
[0011] The first traversal round and the range of values for the first variable of the first variable are determined based on the message length.
[0012] In each iteration, a value of the first variable is determined from the range of values of the first variable according to the first value order;
[0013] The current traversal range of the current traversal round is determined based on the value of the first variable, and traversal is performed according to the current traversal range. Then, the process jumps to the step of determining a value of the first variable from the value range of the first variable according to the first value order, until the traversal round reaches the first traversal round, and the first signal layout list is obtained.
[0014] Optionally, determining the second significant bit value from the signal layout list based on the signal length and the first significant bit value includes:
[0015] Determine the first value whose index is the most significant bit value from the first signal layout list;
[0016] Determine the first sum of the first value and the first signal length, and determine the difference between the first sum and 1 to obtain the index of the least significant bit value;
[0017] The least significant bit value is determined from the first signal layout list based on the index of the least significant bit value.
[0018] Optionally, parsing the target communication matrix database file to obtain the byte order, signal length, and first significant bit value of the target signal includes:
[0019] The target communication matrix database file is parsed to obtain the little-endian order, second signal length, and least significant bit value of the target signal.
[0020] Optionally, determining the signal layout list based on the message length and the byte order includes:
[0021] The second traversal round and the range of values for the second variable of the second variable are determined based on the message length.
[0022] In each iteration, a value of the second variable is determined from the range of values of the second variable according to the second value order;
[0023] The current traversal range of the current traversal round is determined based on the value of the second variable, and traversal is performed according to the current traversal range. Then, the process jumps to the step of determining a value of the second variable from the range of values of the second variable according to the second value order, until the traversal round reaches the second traversal round, and the second signal layout list is obtained.
[0024] Optionally, determining the second significant bit value from the signal layout list based on the signal length and the first significant bit value includes:
[0025] Determine a second value whose index is the least significant bit value from the second signal layout list;
[0026] Determine the second sum of the second value and the second signal length, and determine the difference between the second sum and 1 to obtain the index of the most significant bit value;
[0027] The high and low significant bits are determined from the second signal layout list based on the index of the highest significant bit value.
[0028] Secondly, this application discloses a byte order valid bit conversion device, comprising:
[0029] The parsing module is used to acquire the target communication matrix database file and parse the target communication matrix database file to obtain the byte order, signal length and first effective bit value of the target signal;
[0030] The valid bit conversion module is used to determine a signal layout list based on the message length and the byte order, and to determine a second valid bit value from the signal layout list according to the signal length and the first valid bit value, so that the user can view it.
[0031] Thirdly, this application discloses an electronic device, including:
[0032] Memory, used to store computer programs;
[0033] A processor is configured to execute the computer program to implement the aforementioned method for valid bit conversion of byte order.
[0034] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned method for valid bit conversion of byte order.
[0035] As can be seen, this application proposes a method for converting the effective bit of a byte order, comprising: acquiring a target communication matrix database file, parsing the target communication matrix database file to obtain the byte order, signal length, and first effective bit value of the target signal; determining a signal layout list based on the message length and the byte order, and determining a second effective bit value from the signal layout list based on the signal length and the first effective bit value, so that the user can view it. In summary, since the byte order can include big-endian and little-endian, and the effective bits can include the most significant bit and the least significant bit, on the one hand, when the byte order in this application is big-endian, this application can obtain the most significant bit value, and then determine the signal layout list based on the message length and the big-endian, and then determine the least significant bit value from the signal layout list based on the signal length and the most significant bit value to obtain the true start bit of the signal. That is, this application does not need to determine whether the signal spans bytes, nor does it need to start each byte individually. On the other hand, when the byte order in this application is little-endian, this application can obtain the least significant bit value, and then determine the signal layout list based on the message length and the little-endian order. Then, based on the signal length and the least significant bit value, the most significant bit value is determined from the signal layout list, thus realizing the conversion between the least significant bit value and the most significant bit value. As can be seen from the above, the conversion process of the significant bits in this application does not require determining whether the signal spans bytes, reducing the conversion complexity and computational load. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0037] Figure 1 This application discloses a flowchart of a method for converting the effective bits of a byte order.
[0038] Figure 2 This application discloses a flowchart of a specific byte order valid bit conversion method.
[0039] Figure 3 This is a schematic diagram of the structure of a byte order valid bit conversion device disclosed in this application;
[0040] Figure 4 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0041] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0042] On the one hand, for big-endian signals, when calculating the start bit of the signal, it is necessary to determine whether the signal spans bytes, or even to calculate the start bit one by one across bytes. On the other hand, in practical application scenarios, it is sometimes necessary to convert the valid bits under a certain byte order and provide the conversion results to the user.
[0043] Therefore, this application proposes a byte order significant bit conversion scheme, which can obtain the true start bit of the signal and convert the most significant bit value and the least significant bit value of the byte order for user viewing.
[0044] This application discloses a method for converting the effective bits of byte order. See also Figure 1 As shown, the method includes:
[0045] Step S11: Obtain the target communication matrix database file and parse the target communication matrix database file to obtain the byte order, signal length and first effective bit value of the target signal.
[0046] In this embodiment, a target communication matrix database file is obtained and parsed line by line using Python's `re` library (regularexpression, a support library for regular expressions). It should be noted that when opening the target communication matrix database file in text format, only the most significant bit value is visible for big-endian byte order. To extract a specific signal segment, the true start bit, i.e., the least significant bit value, is required. Therefore, a conversion of the significant bits is necessary. This conversion often involves calculating the start bit across bytes, increasing computational complexity and error rate. To address this, this application provides a conversion method capable of converting the significant bit values for both big-endian and little-endian byte order, as shown below:
[0047] In one specific implementation, the target communication matrix database file is parsed to obtain the big-endian order, first signal length, and most significant bit value of the target signal. The big-endian order, also known as big-endian mode, is the byte order defined in the DBC file, where the most significant bit is in the least significant byte and the least significant bit is in the most significant byte. The first signal length is the length of the target signal. For example, parsing the target communication matrix database file yields SG_SignalName:7|10@0+(0.01,0)[0|10.23]""ReceiveNodeName, where the 0 after the @ symbol indicates that the signal's byte order is big-endian. Based on this data, the first signal length is 10, and the most significant bit value is 7.
[0048] In another specific implementation, the target communication matrix database file is parsed to obtain the little-endian order, second signal length, and least significant bit value of the target signal. The little-endian order, also known as little-endian mode, is a byte order defined in the DBC file, corresponding to big-endian mode, where the least significant bit is in the least significant byte and the most significant bit is in the most significant byte. For example, parsing the target communication matrix database file yields SG_SignalName:28|12@1+(0.1,-200)[-200|209.5]""ReceiveNodeName, where the 1 after the @ symbol indicates that the signal's byte order is little-endian. Based on this data, the second signal length is also 12, and the least significant bit value is 28.
[0049] Step S12: Determine the signal layout list based on the message length and the byte order, and determine the second valid bit value from the signal layout list according to the signal length and the first valid bit value, so that the user can view it.
[0050] In one specific implementation, if the parsed result is the big-endian sequence of the target signal, the first signal length, and the most significant bit value (i.e., the first significant bit value in this embodiment), then the first traversal round and the range of values for the first variable are determined based on the message length. In each traversal round, a variable value for the first variable is determined from the range of values for the first variable according to the first value order. Further, the current traversal range of the current traversal round is determined based on the variable value of the first variable, and traversal is performed according to the current traversal range. Then, the process jumps to the step of determining a variable value for the first variable from the range of values for the first variable according to the first value order, until the traversal round reaches the first traversal round, thus obtaining the first signal layout list.
[0051] In one specific implementation, this embodiment performs a reverse traversal from i*8+7 to i*8-1. Reverse traversal refers to traversing from the maximum value to the minimum value within the traversal range. i is the first variable, and the value range of the first variable is controlled by the message length. Furthermore, the value of the first traversal round is also controlled by the message length. For example, assuming the message length is 8, the value range of the first variable is [0,7], i.e., i = 0, 1, 2…7, and the first traversal round is 8 times. Furthermore, in this embodiment, the first value selection order is an ascending value selection order. That is, in the first round of traversal, i = 0 is taken, and the traversal range of the first round is determined to be 7 to 0 based on i = 0. It should be noted that after substituting i = 0 into i*8+7 to i*8-1, the actual traversal range obtained is 7 to -1. However, in Python syntax, the left side of the traversal range, i.e., 7, can be traversed, while the right side of the traversal range traverses the position before -1, i.e., 0. Thus, in this embodiment, the first round of traversal result is from 7 to 0. Following the above pattern, in the second round of traversal, i = 1 is taken, and the second round of traversal result is 15 to 8. Further, the third round of traversal result is 23 to 16, the fourth round of traversal result is 31 to 24, the fifth round of traversal result is 39 to 32, the sixth round of traversal result is 47 to 40, the seventh round of traversal result is 55 to 48, and the eighth round of traversal result is 63 to 56. Finally, the first signal layout list obtained from the above traversal results is as follows:
[0052] [7,6,5,4,3,2,1,0,
[0053] 15,14,13,12,11,10,9,8,
[0054] 23,22,21,20,19,18,17,16,
[0055] 31,30,29,28,27,26,25,24,
[0056] 39,38,37,36,35,34,33,32,
[0057] 47,46,45,44,43,42,41,40,
[0058] 55,54,53,52,51,50,49,48,
[0059] 63,62,61,60,59,58,57,56).
[0060] Furthermore, after obtaining the first signal layout list, a first value with the index of the most significant bit value is determined from the first signal layout list, and a first sum of the first value and the first signal length is determined. Then, the difference between the first sum and 1 is determined to obtain the index of the least significant bit value. Finally, the least significant bit value is determined from the first signal layout list based on the index of the least significant bit value. For example, as can be seen from the foregoing, this embodiment obtains the most significant bit value as 7 by parsing the target communication matrix database file. Then, the first value "0" with the index 7 is obtained from the first layout list. 0 is added to the first signal length 10 to obtain a first sum of 10. Subtracting 1 from the first sum of 10 gives the index 9 of the least significant bit value. The value "14" of index 9 in the first layout list is obtained, which is the least significant bit value of the signal (i.e., the second significant bit value in this embodiment).
[0061] In another specific implementation, if the parsed result is the little-endian order of the target signal, the second signal length, and the least significant bit value (i.e., the first significant bit value in this embodiment), then the second traversal round and the range of values for the second variable are determined based on the message length. In each traversal round, a variable value of the second variable is determined from the range of values for the second variable according to the second value order. Further, the current traversal range of the current traversal round is determined based on the variable value of the second variable, and traversal is performed according to the current traversal range. Then, the process jumps to the step of determining a variable value of the second variable from the range of values for the second variable according to the second value order, until the traversal round reaches the second traversal round, thus obtaining the second signal layout list.
[0062] In one specific implementation, this embodiment traverses in ascending order from t*8 to t*8+8. Ascending order traversal refers to traversing from the minimum to the maximum value within the traversal range. t is a second variable, and the value range of the second variable is controlled by the message length. The value of the second traversal round is also controlled by the message length. For example, assuming the message length is 8, the value range of the second variable is [0,7], i.e., t = 0, 1, 2…7. Simultaneously, the second traversal round is 8 times. Furthermore, in this embodiment, the second value order is an ascending value order. That is, in the first round of traversal, t = 0 is taken, and the traversal range of the first round is determined to be 0 to 7 based on t = 0. It should be noted that after substituting t = 0 into t*8 to t*8+8, the actual traversal range obtained is 0 to 8. However, in Python syntax, the left side of the traversal range, i.e., 0, can be traversed, while the right side of the traversal range traverses the position before 8, i.e., 7. Thus, in this embodiment, the first round of traversal results from 0 to 7. Following the above pattern, in the second round of traversal, t = 1 is taken, and the second round of traversal results are 8 to 15, the third round of traversal results are 16 to 23, the fourth round of traversal results are 24 to 31, the fifth round of traversal results are 32 to 39, the sixth round of traversal results are 40 to 47, the seventh round of traversal results are 48 to 55, and the eighth round of traversal results are 56 to 63. Finally, the second signal layout list obtained from the above traversal results is as follows:
[0063] [0,1,2,3,4,5,6,7,
[0064] 8,9,10,11,12,13,14,15,
[0065] 16,17,18,19,20,21,22,23,
[0066] 24,25,26,27,28,29,30,31,
[0067] 32,33,34,35,36,37,38,39,
[0068] 40,41,42,43,44,45,46,47,
[0069] 48,49,50,51,52,53,54,55,
[0070] 56,57,58,59,60,61,62,63).
[0071] Furthermore, after obtaining the second signal layout list, a second value with the index of the least significant bit is determined from the second signal layout list, and a second sum of the second value and the second signal length is determined. Then, the difference between the second sum and 1 is determined to obtain the index of the most significant bit value. Finally, the high and low significant bits are determined from the second signal layout list based on the index of the most significant bit value. For example, as can be seen from the foregoing, this embodiment obtains the least significant bit value of 28 by parsing the target communication matrix database file. Then, the second value "28" with the index 28 is obtained from the second layout list. 28 is added to the second signal length 12 to obtain a second sum of 40. Subtracting 1 from the second sum of 40 gives the index 39 of the most significant bit value. The value "39" with index 39 in the second layout list is obtained, and this value is the most significant bit value of the signal (that is, the second significant bit value in this embodiment).
[0072] See Figure 2 As shown, Figure 2 This application discloses a specific method for converting the significant bit of a byte order. First, the target communication matrix database file is obtained and parsed. Then, it is determined whether the byte order is big-endian. If so, the most significant bit (LSB) value is obtained, and a first signal layout list is generated based on the message length and the LSB. The value corresponding to the LSB value at the index of the LSB value is obtained from the first signal layout list. This value is added to and subtracted from the signal length by 1 to obtain the index of the least significant bit value in the first signal layout list. Based on the obtained index, the value corresponding to that index in the first signal layout list is obtained; this value is the LSB value. If the byte order is little-endian, the LSB value is obtained, and a second signal layout list is generated based on the message length and the LSB. The value corresponding to the LSB value at the index of the LSB value is obtained from the second signal layout list. This value is added to and subtracted from the signal length by 1 to obtain the index of the LSB value in the second signal layout list. Based on the obtained index, the value corresponding to that index in the second signal layout list is obtained; this value is the LSB value. Finally, after the conversion is completed, the conversion result is stored in an Excel spreadsheet for user viewing.
[0073] As can be seen, this application proposes a method for converting the effective bit of a byte order, comprising: acquiring a target communication matrix database file, parsing the target communication matrix database file to obtain the byte order, signal length, and first effective bit value of the target signal; determining a signal layout list based on the message length and the byte order, and determining a second effective bit value from the signal layout list based on the signal length and the first effective bit value, so that the user can view it. In summary, since the byte order can include big-endian and little-endian, and the effective bits can include the most significant bit value and the least significant bit value, on the one hand, when the byte order in this application is big-endian, this application can obtain the most significant bit value, and then determine the signal layout list based on the message length and the big-endian order, and then determine the least significant bit value from the signal layout list based on the signal length and the most significant bit value to obtain the true start bit of the signal. That is, this application does not need to determine whether the signal spans bytes, nor does it need to start each byte individually. On the other hand, when the byte order in this application is little-endian, this application can obtain the least significant bit value, and then determine the signal layout list based on the message length and the little-endian order. Then, based on the signal length and the least significant bit value, the most significant bit value is determined from the signal layout list, thus realizing the conversion between the least significant bit value and the most significant bit value. As can be seen from the above, the conversion process of the significant bits in this application does not require determining whether the signal spans bytes, reducing the conversion complexity and computational load.
[0074] It should be noted that, in addition to the above-mentioned conversions, this application can also perform reverse conversion to obtain the most significant bit value when the least significant bit value is known in big-endian order, and reverse conversion to obtain the least significant bit value when the most significant bit value is known in little-endian order.
[0075] In one specific implementation, under big-endian order, the least significant bit value is obtained and converted to the most significant bit value. In this implementation, the process iterates in reverse order from i*8+7 to i*8-1, and after the reverse traversal is completed, the entire traversal result is arranged in reverse order. Specifically, x is a third variable, the value range of which is controlled by the message length, and the number of third traversal rounds is also controlled by the message length. For example, assuming the message length is 8, the value range of the third variable is [0,7], i.e., x = 0,1,2…7, and the number of third traversal rounds is 8. In the first round of traversal, x = 0 is chosen, and the traversal range for the first round is determined to be 7 to 0. Following the same pattern, in the second round of traversal, x = 1 is chosen, and the result for the second round is 15 to 8. Furthermore, the result for the third round is 23 to 16, the result for the fourth round is 31 to 24, the result for the fifth round is 39 to 32, the result for the sixth round is 47 to 40, the result for the seventh round is 55 to 48, and the result for the eighth round is 63 to 56. Finally, all the traversal results are reversed to obtain the third signal layout list, as shown below:
[0076] [56,57,58,59,60,61,62,63,
[0077] 48,49,50,51,52,53,54,55,
[0078] 40,41,42,43,44,45,46,47,
[0079] 32,33,34,35,36,37,38,39,
[0080] 24,25,26,27,28,29,30,31,
[0081] 16,17,18,19,20,21,22,23,
[0082] 8,9,10,11,12,13,14,15,
[0083] 0,1,2,3,4,5,6,7].
[0084] It should be noted that the reason for reversing the traversal results in this embodiment is that if the signal layout list before reversing the results is used for valid bit conversion, the conversion result will exceed the signal layout list. For example, the signal layout list before reversing the results is the first signal layout list in this application. Assuming that the least significant bit is known to be 56, the value "63" with index 56 is obtained from the signal layout list. Adding 63 to the signal length 10 and subtracting 1 gives the index of the most significant bit, which is 72. It can be seen that the highest index of the signal layout list is 63, and 72 exceeds the index specified by the signal layout list. Therefore, the signal layout list needs to be reversed to obtain the third signal layout list. According to the third signal layout list after reversing the results, when the least significant bit is known to be 56, the value "0" with index 56 is obtained from the third signal layout list. Adding 0 to the signal length 10 and subtracting 1 gives the index of the most significant bit, which is 9. Further, the value 49 with index 9 is obtained from the third signal layout list.
[0085] Furthermore, the least significant bit 14 is obtained from the most significant bit 7 in the first signal layout list. In this embodiment, with the least significant bit 14 obtained, the most significant bit 7 can be derived from the third signal layout list. Specifically, the value "54" with index 14 is obtained from the third signal layout list. 54 is added to the signal length 10 and subtracted by 1 to obtain the index 63 of the most significant bit. Based on the obtained index 63, the value "7" of that index is obtained from the third layout list. This value is the most significant bit value of the signal.
[0086] In another specific implementation, under little-endian order, the most significant bit value is obtained and converted into the least significant bit value of the LSB. In this embodiment, the traversal is performed in ascending order from i*8 to i*8+8. The specific content is as follows: y is the fourth variable, and the value range of the fourth variable is controlled by the message length. The number of the fourth traversal rounds is also controlled by the message length. For example, assuming the message length is 8, the value range of the fourth variable is [0,7], that is, y = 0,1,2…7. At the same time, the number of the fourth traversal rounds is 8. In the first round of traversal, y = 0 is taken, and the traversal range for the first round is determined to be 0 to 7. Following the same pattern, in the second round of traversal, y = 1 is taken, and the results for the second round are 8 to 15, the third round are 16 to 23, the fourth round are 24 to 31, the fifth round are 32 to 39, the sixth round are 40 to 47, the seventh round are 48 to 55, and the eighth round are 56 to 63. Finally, the fourth signal layout list obtained from the above traversal results is shown below:
[0087] [0,1,2,3,4,5,6,7,
[0088] 8,9,10,11,12,13,14,15,
[0089] 16,17,18,19,20,21,22,23,
[0090] 24,25,26,27,28,29,30,31,
[0091] 32,33,34,35,36,37,38,39,
[0092] 40,41,42,43,44,45,46,47,
[0093] 48,49,50,51,52,53,54,55,
[0094] [56,57,58,59,60,61,62,63];
[0095] Furthermore, the most significant bit 39 is obtained from the least significant bit 28 in the second signal layout list. In this embodiment, with the most significant bit 39 obtained, the least significant bit 28 can be derived from the fourth signal layout list. Specifically, the value "39" corresponding to index 39 is obtained in the fourth signal layout list. Subtracting 39 from the signal length 12 and adding 1 gives the index 28 of the least significant bit. Based on the obtained index 28, the value "28" of that index is obtained in the fourth signal layout list. This value is the least significant bit value of the signal.
[0096] Finally, after the conversion is complete, the conversion results are saved in an Excel spreadsheet for users to view.
[0097] In summary, this application, when calculating the start bit based on the most significant start bit value in big-endian mode, eliminates the need for the user to determine whether the signal spans bytes, or even multiple bytes, to calculate the start bit individually. It only requires the message length, signal byte order, signal length, and the read signal start bit to dynamically generate a layout list and automatically calculate the true start bit, eliminating the risk of errors. Furthermore, this application can reverse the conversion to obtain the most significant bit value when the byte order is big-endian and the least significant bit value is known; similarly, it can reverse the conversion to obtain the most significant bit value when the byte order is little-endian and the most significant bit value is known. In other words, this application can convert between the most significant and least significant bit values in big-endian and little-endian sequences. Moreover, the conversion process for the significant bits does not require determining whether the signal spans bytes, reducing conversion complexity and computational load.
[0098] Accordingly, embodiments of this application also disclose a byte order valid bit conversion device, see [link to relevant documentation]. Figure 3 As shown, the device includes:
[0099] The parsing module 11 is used to acquire the target communication matrix database file and parse the target communication matrix database file to obtain the byte order, signal length and first effective bit value of the target signal;
[0100] The valid bit conversion module 12 is used to determine a signal layout list based on the message length and the byte order, and to determine a second valid bit value from the signal layout list according to the signal length and the first valid bit value, so that the user can view it.
[0101] For more detailed information on the working process of each of the above modules, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0102] As can be seen, this application proposes a byte order valid bit conversion device, including: a parsing module 11, used to acquire a target communication matrix database file and parse the target communication matrix database file to obtain the byte order, signal length, and first valid bit value of the target signal; and a valid bit conversion module 12, used to determine a signal layout list based on the message length and the byte order, and determine a second valid bit value from the signal layout list based on the signal length and the first valid bit value, so that the user can view it. In summary, since the byte order can include big-endian and little-endian, and the valid bits can include the most significant bit and the least significant bit, on the one hand, when the byte order in this application is big-endian, this application can obtain the most significant bit value, and then determine the signal layout list based on the message length and the big-endian, and then determine the least significant bit value from the signal layout list based on the signal length and the most significant bit value to obtain the true start bit of the signal. That is, this application does not need to determine whether the signal spans bytes, nor does it need to start each byte individually. On the other hand, when the byte order in this application is little-endian, this application can obtain the least significant bit value, and then determine the signal layout list based on the message length and the little-endian order. Then, based on the signal length and the least significant bit value, the most significant bit value is determined from the signal layout list, thus realizing the conversion between the least significant bit value and the most significant bit value. As can be seen from the above, the conversion process of the significant bits in this application does not require determining whether the signal spans bytes, reducing the conversion complexity and computational load.
[0103] Furthermore, embodiments of this application also provide an electronic device. Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0104] Figure 4 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a display screen 23, an input / output interface 24, a communication interface 25, a power supply 26, and a communication bus 27. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the byte order valid bit conversion method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0105] In this embodiment, the power supply 26 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 25 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 24 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0106] Furthermore, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk, or optical disk, etc. The resources stored thereon may include computer programs 221, and the storage method may be temporary storage or permanent storage. The computer programs 221 may include, in addition to computer programs capable of performing the byte order valid bit conversion method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, computer programs capable of performing other specific tasks.
[0107] Furthermore, embodiments of this application also disclose a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned method for valid bit conversion of byte order.
[0108] For the specific steps of this method, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0109] The various embodiments in this application are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. For the same or similar parts between the various embodiments, refer to each other. As for the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and relevant parts can be referred to in the method section.
[0110] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0111] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0112] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0113] The foregoing has provided a detailed description of a byte order valid bit conversion method, apparatus, device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for converting the effective bit of a byte order, characterized in that, include: Obtain the target communication matrix database file and parse the target communication matrix database file to obtain the byte order, signal length and first effective bit value of the target signal; A signal layout list is determined based on the message length and the byte order, and a second valid bit value is determined from the signal layout list based on the signal length and the first valid bit value, so that the user can view it.
2. The byte order valid bit conversion method according to claim 1, characterized in that, The step of parsing the target communication matrix database file to obtain the byte order, signal length, and first significant bit value of the target signal includes: The target communication matrix database file is parsed to obtain the big-endian order of the target signal, the length of the first signal, and the value of the most significant bit.
3. The byte order valid bit conversion method according to claim 2, characterized in that, The determination of the signal layout list based on the message length and the byte order includes: The first traversal round and the range of values for the first variable of the first variable are determined based on the message length. In each iteration, a value of the first variable is determined from the range of values of the first variable according to the first value order; The current traversal range of the current traversal round is determined based on the value of the first variable, and traversal is performed according to the current traversal range. Then, the process jumps to the step of determining a value of the first variable from the value range of the first variable according to the first value order, until the traversal round reaches the first traversal round, and the first signal layout list is obtained.
4. The byte order valid bit conversion method according to claim 3, characterized in that, Determining the second significant bit value from the signal layout list based on the signal length and the first significant bit value includes: Determine the first value whose index is the most significant bit value from the first signal layout list; Determine the first sum of the first value and the first signal length, and determine the difference between the first sum and 1 to obtain the index of the least significant bit value; The least significant bit value is determined from the first signal layout list based on the index of the least significant bit value.
5. The byte order valid bit conversion method according to claim 1, characterized in that, The step of parsing the target communication matrix database file to obtain the byte order, signal length, and first significant bit value of the target signal includes: The target communication matrix database file is parsed to obtain the little-endian order, second signal length, and least significant bit value of the target signal.
6. The byte order valid bit conversion method according to claim 5, characterized in that, The determination of the signal layout list based on the message length and the byte order includes: The second traversal round and the range of values for the second variable of the second variable are determined based on the message length. In each iteration, a value of the second variable is determined from the range of values of the second variable according to the second value order; The current traversal range of the current traversal round is determined based on the value of the second variable, and traversal is performed according to the current traversal range. Then, the process jumps to the step of determining a value of the second variable from the range of values of the second variable according to the second value order, until the traversal round reaches the second traversal round, and the second signal layout list is obtained.
7. The byte order valid bit conversion method according to claim 6, characterized in that, Determining the second significant bit value from the signal layout list based on the signal length and the first significant bit value includes: Determine a second value whose index is the least significant bit value from the second signal layout list; Determine the second sum of the second value and the second signal length, and determine the difference between the second sum and 1 to obtain the index of the most significant bit value; The high and low significant bits are determined from the second signal layout list based on the index of the highest significant bit value.
8. A byte order valid bit conversion device, characterized in that, include: The parsing module is used to acquire the target communication matrix database file and parse the target communication matrix database file to obtain the byte order, signal length and first effective bit value of the target signal; The valid bit conversion module is used to determine a signal layout list based on the message length and the byte order, and to determine a second valid bit value from the signal layout list according to the signal length and the first valid bit value, so that the user can view it.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the byte order valid bit conversion method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when the computer program is executed by a processor, it implements the byte order valid bit conversion method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
DBC signal export start bit format conversion method and system
CN114691604A
Data communication method and device of vehicle, vehicle and storage medium
CN114928655A