Method and system for data conversion between can bus and mvb bus and storage medium
Patent Information
- Application Number
- CN202311416800.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-30
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2043-10-30
AI Technical Summary
[0016] In summary, the CAN bus to MVB bus data conversion method, system, and storage medium provided in this application, based on the transmission source corresponding to the data transmission command, obtains the parameter group number in the first data whose transmission source is the CAN bus and conforms to the preset communication standard. For parameter group numbers that have a corresponding parameter group number in the preset configuration list, the corresponding MVB port is obtained from the preset mapping table as the first switching port, the first data is filled into the first switching port, and sent to the MVB bus. For second data whose transmission source is the MVB bus and whose corresponding MVB port matches the preset mapping table, the parameter group number corresponding to its MVB port in the preset mapping table is obtained as the first switching number, the second data is written into the data buffer corresponding to the first switching number, and sent to the CAN bus. Thus, by pre-determining the preset mapping table of corresponding parameter group numbers and MVB ports, data conversion between the CAN bus and the MVB bus is achieved without additional data rewriting or other processing, effectively realizing data conversion to meet control requirements.
Smart Images

Figure CN117614766B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data network technology, and in particular to a method, system and storage medium for converting data between CAN bus and MVB bus. Background Technology
[0002] A bus is a set of common information transmission lines that provide services to various components. It can send and receive information from each component in a time-division multiplexing manner, serving as a common channel for transmitting address, data, and control information between components of a computer system. Almost all buses transmit three types of information: data, address, and control / status signals. Accordingly, each bus can be considered to consist of a data bus, an address bus, and a control bus. The data bus is used to transmit data information between various components / devices. The address bus is used to transmit address information between the CPU (or DMA controller) and memory / I / O interfaces. The control bus is used to transmit control and status information between the CPU (or DMA controller) and memory / I / O interfaces.
[0003] Currently, CAN bus and MVB bus are two commonly used data buses in the field of industrial control. CAN bus is a high-speed, low-cost, low-complexity, and versatile fieldbus technology, widely used, especially in automotive and industrial automation. MVB bus, on the other hand, is a data communication method specifically designed for locomotive control systems, primarily used for locomotive data communication and signal control. While CAN and MVB buses differ significantly in function, speed, transmission methods, and physical connections, their applications are increasingly overlapping in practice, necessitating data conversion to meet specific control requirements.
[0004] Therefore, in order to solve the above problems, it is an urgent problem for those skilled in the art to provide a CAN bus to MVB bus data conversion method, system and storage medium that can effectively realize data conversion to meet control requirements. Summary of the Invention
[0005] In order to effectively achieve data conversion and thus meet control requirements, this application provides a CAN bus to MVB bus data conversion method, system and storage medium.
[0006] In one aspect, this application provides a data conversion method between CAN bus and MVB bus, including the following steps: Obtain data transmission and reception instructions and their corresponding sources; If the transmission source is a CAN bus, then determine whether the first data read from the CAN bus conforms to the preset communication standard; If the preset communication standard is met, the message identifier of the first data is parsed to obtain the parameter group number; If the parameter group number is in the preset configuration list, the corresponding MVB port is obtained as the first switching port according to the preset mapping table; Fill the first data corresponding to the parameter group number into the first switching port; Obtain the MVB port data from the first switching port and send it to the MVB bus; If the transmission source is an MVB bus, then determine whether the MVB port corresponding to the second data read from the MVB bus matches the preset mapping table; If the preset mapping table is matched, the parameter group number corresponding to the MVB port in the preset mapping table is obtained as the first switching number; Write the second data into the data cache corresponding to the first exchange number; The CAN data in the data cache is acquired and sent to the CAN bus; The preset mapping table is a pre-set mapping relationship between the parameter group number and the MVB port, and the preset configuration list is a pre-set list including the known parameter group numbers.
[0007] Optionally, before obtaining the data transmission and reception instructions and the corresponding transmission source, the method further includes: Obtain all parameter group numbers from the preset configuration list, along with their corresponding number periods and number data lengths; Numbers in parameter groups with the same number period are grouped into i number groups; Each of the number groups is sequentially assigned a number of MVB ports that meet a preset period requirement, forming i allocation groups; Based on the number data length in each allocation group and the data length of the MVB port, a mapping relationship between the parameter group number and the MVB port is formed according to a preset length requirement; Based on the mapping relationship, a preset mapping table is formed that maps the MVB port to all the parameter group numbers in the preset configuration list.
[0008] Optionally, the preset period requirement is T1=2^t≤T2, where T1 is the port period of the MVB port, T2 is the number period, 0≤t≤10 and t takes the maximum value.
[0009] Optionally, the preset length requirement is that the sum of the number data lengths of the parameter group numbers is less than or equal to the sum of the data lengths of the corresponding MVB ports.
[0010] Optionally, the step of sequentially allocating a plurality of MVB ports that meet a preset periodic requirement to each of the number groups to form i allocation groups includes: Obtain the number period of the j-th number group, where 1 ≤ j < i; The MVB port that meets the preset period requirement is selected as the MVB port according to the number period. The selected MVB port is combined with the parameter group number corresponding to the number period to form the j-th allocation group; The step of obtaining the number period of the j-th number group is repeated until the updated j equals i.
[0011] Optionally, the step of forming the mapping relationship between the parameter group number and the MVB port according to the number data length in each of the allocation groups and the data length of the MVB port, and in accordance with a preset length requirement, includes: Obtain the data length of all numbers and the MVB port in the kth allocation group, where 1 ≤ k < i; Obtain the data length of the MVB port; According to the number data length from largest to smallest, the remaining MVB ports are allocated the longest data length in accordance with the preset length requirement; The k-th mapping is formed based on the corresponding parameter group number and the MVB port; Use k+1 as the updated k and return to the step of obtaining the length of all the number data and the MVB port in the kth allocation group, looping until the updated k equals i; All the mappings are combined to form the mapping relationship between the parameter group number and the MVB port.
[0012] Optionally, after parsing the message identifier of the first data to obtain the parameter group number if the preset communication standard is met, the method further includes: If the parameter group number is not found in the preset configuration list, then the parameter group number will be used as the feedback number. Determine if the preset configuration list has an updated version; If there is no updated version, the number to be fed back and the corresponding first data are recorded to form a first feedback record; If an updated version is available, the preset configuration list is updated accordingly. In the updated preset configuration list, determine whether the parameter group number corresponds to the number to be fed back; If so, proceed to the step of obtaining the corresponding MVB port as the first switching port according to the preset mapping table if the corresponding parameter group number is in the preset configuration list; If not, the number to be fed back and the corresponding first data are recorded to form the first feedback record.
[0013] Optionally, after determining whether the MVB port corresponding to the second data read from the MVB bus matches the preset mapping table if the transmission source is an MVB bus, the method further includes: If the preset mapping table is not matched, the MVB port will be used as the port to be confirmed. Record the port to be confirmed and store the corresponding second data to form a second feedback record; Obtain the number of ports to be confirmed as described in the second feedback record; If the number of occurrences exceeds a preset occurrence threshold, the corresponding port to be confirmed will be designated as the port to be updated. Obtain the second data corresponding to the port to be updated in the second feedback record as the judgment data; If the determination data conforms to the preset determination rules, then the preset mapping table is updated according to the port to be updated; If the judgment data does not conform to the preset judgment rule, then the corresponding second data and the corresponding record of the port to be confirmed are deleted from the second feedback record.
[0014] Secondly, this application also provides a CAN bus to MVB bus data conversion system, including: The first acquisition module is used to acquire data transmission and reception instructions and their corresponding transmission sources; If the transmission source is a CAN bus, the first judgment module is used to determine whether the first data read from the CAN bus conforms to a preset communication standard. If the first parsing module conforms to the preset communication standard, then the first parsing module is used to parse the message identifier of the first data to obtain the parameter group number; If the parameter group number is in the preset configuration list, the second acquisition module is used to obtain the corresponding MVB port as the first switching port according to the preset mapping table. The first filling module is used to fill the first data corresponding to the parameter group number into the first switching port; The first transmitting module is used to acquire the MVB port data of the first switching port and send it to the MVB bus; If the sending source is an MVB bus, the second judgment module is used to determine whether the MVB port corresponding to the second data read from the MVB bus matches the preset mapping table. If the third acquisition module matches the preset mapping table, the third acquisition module is used to acquire the parameter group number corresponding to the MVB port in the preset mapping table as the first exchange number; The first writing module is used to write the second data into the data cache corresponding to the first exchange number; The second transmitting module is used to acquire the CAN data in the data buffer and transmit it to the CAN bus; The preset mapping table is a pre-set mapping relationship between the parameter group number and the MVB port, and the preset configuration list is a pre-set list including the known parameter group numbers.
[0015] Thirdly, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the CAN bus to MVB bus data conversion method as described in any of the above claims.
[0016] In summary, the CAN bus to MVB bus data conversion method, system, and storage medium provided in this application, based on the transmission source corresponding to the data transmission command, obtains the parameter group number in the first data whose transmission source is the CAN bus and conforms to the preset communication standard. For parameter group numbers that have a corresponding parameter group number in the preset configuration list, the corresponding MVB port is obtained from the preset mapping table as the first switching port, the first data is filled into the first switching port, and sent to the MVB bus. For second data whose transmission source is the MVB bus and whose corresponding MVB port matches the preset mapping table, the parameter group number corresponding to its MVB port in the preset mapping table is obtained as the first switching number, the second data is written into the data buffer corresponding to the first switching number, and sent to the CAN bus. Thus, by pre-determining the preset mapping table of corresponding parameter group numbers and MVB ports, data conversion between the CAN bus and the MVB bus is achieved without additional data rewriting or other processing, effectively realizing data conversion to meet control requirements. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating one implementation of the CAN bus to MVB bus data conversion method according to an embodiment of this application. Figure 2 This is a flowchart illustrating one implementation of the CAN bus to MVB bus data conversion method according to an embodiment of this application. Figure 3This is a flowchart illustrating one implementation of the CAN bus to MVB bus data conversion method according to an embodiment of this application. Figure 4 This is a flowchart illustrating one implementation of the CAN bus to MVB bus data conversion method according to an embodiment of this application. Figure 5 This is a flowchart illustrating one implementation of the CAN bus to MVB bus data conversion method according to an embodiment of this application. Figure 6 This is a flowchart illustrating one implementation of the CAN bus to MVB bus data conversion method according to an embodiment of this application. Figure 7 This is a schematic diagram of a module of one embodiment of the CAN bus to MVB bus data conversion system of this application. Detailed Implementation
[0018] To enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this application.
[0019] Firstly, this application provides a method for data conversion between CAN bus and MVB bus, such as... Figure 1 As shown, it includes the following steps: S101. Obtain data transmission and reception instructions and their corresponding transmission sources; S102. If the source of transmission is the CAN bus, determine whether the first data read from the CAN bus conforms to the preset communication standard; S103. If the preset communication standard is met, the message identifier of the first data is parsed to obtain the parameter group number; S104. If there is a corresponding parameter group number in the preset configuration list, then obtain the corresponding MVB port as the first switching port according to the preset mapping table; S105. Fill the first data corresponding to the parameter group number into the first switching port; S106. Obtain the MVB port data of the first switching port and send it to the MVB bus; S107. If the source of transmission is the MVB bus, determine whether the MVB port corresponding to the second data read from the MVB bus matches the preset mapping table; S108. If a preset mapping table is matched, the parameter group number corresponding to the MVB port in the preset mapping table is obtained as the first switching number; S109. Write the second data into the data cache corresponding to the first exchange number; S110. Obtain the CAN data from the data buffer and send it to the CAN bus; The preset mapping table is a pre-set mapping relationship between parameter group numbers and MVB ports, and the preset configuration list is a pre-set list including known parameter group numbers.
[0020] It should be noted that the data conversion method in this application is applied at the protocol layer. Whether it is CAN or MVB communication, it is a carrier sense communication method, that is, all devices can receive data in the protocol layer bus, so there is no need to additionally determine the receiving address or receiving destination.
[0021] The data transmission and reception command in step S101 refers to the command corresponding to the request to send data and expect it to be received. The corresponding transmission source refers to the source of the data transmission, and the corresponding conversion method needs to be determined based on the transmission source. In this embodiment, the transmission source is a CAN bus or an MVB bus, and the receiver is correspondingly an MVB bus or a CAN bus. Data conversion between the CAN bus or MVB bus and other buses is not within the scope of this application.
[0022] If the source of the transmission is a CAN bus, it indicates that the receiver is an MVB bus. Therefore, step S102 is executed to determine whether the first data read from the CAN bus conforms to a preset communication standard. Only first data conforming to the preset communication standard can have its parameter group number obtained by parsing the message identifier. The preset communication standard is a pre-set standard for determining whether the first data conforms to specific communication requirements. In this embodiment, the preset communication standard is the J1939 communication standard.
[0023] It should be noted that since the CAN protocol operates in a multi-master mode, any node on the network can actively send information to other nodes on the network at any time. The parameter group number, or PGN, is very important for the CAN protocol. Many electronic control units (ECUs) identify the parameter group number rather than the message ID when receiving messages. Therefore, for data or messages sent from the CAN bus, the most important parameter or information is the parameter group number.
[0024] If the default communication standard is not met, it means that the parameter group number cannot be obtained by parsing the message identifier. In this case, the corresponding first data can be processed according to actual needs, such as being discarded directly or transferred to other storage space for confirmation of subsequent processing. This will not be elaborated here.
[0025] If the communication meets the preset standard, it means that the parameter group number can be obtained by parsing the message identifier. Therefore, step S103 is executed to parse the message identifier of the first data to obtain the parameter group number, and it is determined whether the parameter group number corresponds to one in the preset configuration list. The preset configuration list is a pre-set list that includes known parameter group numbers.
[0026] If a corresponding parameter group number exists in the preset configuration list, it indicates that this parameter group number is a known parameter group number. Then, step S104 is executed to obtain the corresponding MVB port as the first switching port based on the preset mapping table. The preset mapping table is a pre-set mapping relationship between parameter group numbers and MVB ports; that is, it pre-maps each known parameter group number to each known MVB port.
[0027] After obtaining the first switching port corresponding to the parameter group number in step S104, step S105 is executed to fill the first data corresponding to the parameter group number into the first switching port. Therefore, step S106 can be executed directly to obtain the MVB port data of the first switching port and send it to the MVB bus, so that the demand side can directly read the first data of the CAN bus from the MVB port data.
[0028] If the source of transmission is the MVB bus, it means that the receiver is the CAN bus. Then, in step S107, it is determined whether the MVB port corresponding to the second data read from the MVB bus matches the preset mapping table. Only the MVB port that matches the preset mapping table can obtain the corresponding parameter group number.
[0029] If a preset mapping table is matched, then step S108 is executed to obtain the parameter group number corresponding to the MVB port in the preset mapping table as the first exchange number. The same data pass-through method is used, and step S109 is executed to write the second data into the data buffer corresponding to the first exchange number. Then step S110 is executed directly to obtain the CAN data from the data buffer and send it to the CAN bus, so that the demand side can directly read the second data of the MVB bus from the CAN data and send it to the CAN bus.
[0030] It should be noted that in this embodiment, when data is filled or data is cached, the corresponding parameter group number and the mapping relationship of the MVB port are directly obtained based on the preset mapping table. No additional processing is required on the data itself. Therefore, the data pass-through method can be used. After being read, the data can be directly obtained and the control requirements can be implemented.
[0031] The data conversion method provided in this embodiment obtains the parameter group number from the first data whose transmission source is a CAN bus and conforms to a preset communication standard, based on the transmission source corresponding to the data transmission command. For parameter group numbers that have a corresponding parameter group number in a preset configuration list, the corresponding MVB port is obtained from a preset mapping table as the first switching port. The first data is then filled into the first switching port and sent to the MVB bus. For second data whose transmission source is an MVB bus and whose corresponding MVB port matches the preset mapping table, the parameter group number corresponding to its MVB port in the preset mapping table is obtained as the first switching number. The second data is written into the data buffer corresponding to the first switching number and sent to the CAN bus. Thus, by pre-determining the preset mapping table of corresponding parameter group numbers and MVB ports, data conversion between the CAN bus and the MVB bus is achieved without additional data rewriting or other processing, effectively realizing data conversion to meet control requirements.
[0032] In one embodiment of this example, such as Figure 2 As shown, before step S101, which involves obtaining the data transmission and reception instructions and the corresponding transmission source, the process also includes: S201. Obtain all parameter group numbers in the preset configuration list, as well as the corresponding number period and number data length; S202. Group the parameter groups with the same number period into i number groups; S203. Assign several MVB ports that meet the preset period requirements to each number group in sequence to form i allocation groups; S204. Based on the number data length in each allocation group and the data length of the MVB port, form a mapping relationship between parameter group numbers and MVB ports according to the preset length requirements; S205. Based on the mapping relationship, form a preset mapping table between the MVB port and all parameter group numbers in the preset configuration list.
[0033] As mentioned earlier, the preset mapping table needs to be set in advance. The key in the preset mapping table in this embodiment is the parameter group number corresponding to CAN and the MVB port corresponding to MVB. To design the mapping between the parameter group number and the MVB port, it is necessary to select the common parameters or common indexes of the parameter group number and the MVB port. In this embodiment, the period and data length of the two are used as the mapping basis.
[0034] In practical applications, step S201 is executed first to obtain all parameter group numbers in the preset configuration list, as well as the corresponding number period and number data length. The number period is the period corresponding to the parameter group number as determined by the J1939 communication standard, and the number data length is the data length corresponding to each parameter group number.
[0035] Since the port period of the MVB port is 1, 2, 4, 8…1024 (2^n, 0≤n≤10) milliseconds, while the number period of the parameter group number in the J1939 communication standard is not limited and can be any non-zero time period, the port period needs to be used as the first requirement factor. Step S202 is executed first, that is, the parameter group numbers with the same number period are treated as the same number group, forming i number groups. By grouping the same number period into the same number group, all parameter group numbers are divided into i number groups.
[0036] After forming i groups of number groups with the same number period, it is necessary to allocate MVB ports to the parameter group numbers within these groups. At this point, step S203 is executed, which sequentially allocates several MVB ports that meet the preset period requirements to each number group, forming i allocation groups. Thus, each allocation group already has several parameter group numbers and MVB ports that meet the preset period requirements. The preset period requirements are pre-set matching requirements between the number period and the port period.
[0037] However, simply assigning several parameter group numbers and MVB ports to the same allocation group based on the cycle is insufficient to achieve data conversion. This is because, in practical applications, the data length of an MVB port is 2, 4, 8…32 (2^x, 1≤x≤5), and the data length of a parameter group number is 0-1785. Both have limited data lengths, requiring further matching according to preset length requirements. Therefore, step S204 involves establishing a mapping relationship between parameter group numbers and MVB ports based on the data lengths of the numbers in each allocation group and the data lengths of the MVB ports, according to preset length requirements. This ensures that each parameter group number has a unique mapping relationship with each MVB port, ultimately forming the preset mapping table between the MVB ports and all parameter group numbers in the preset configuration list, as described in step S205.
[0038] The data conversion method provided in this embodiment first assigns number groups of parameter group numbers with the same number period to MVB ports that meet the preset period requirements to form allocation groups. Then, according to the number data length and MVB port data length in each allocation group, a mapping relationship between parameter group numbers and MVB ports is formed according to the preset length requirements, thereby forming a preset mapping table, so as to achieve the effect that each parameter group number and each MVB port can have a unique corresponding mapping relationship.
[0039] In one embodiment of this example, the preset period requirement is T1=2^t≤T2, where T1 is the port period of the MVB port, T2 is the number period, 0≤t≤10 and t takes the maximum value.
[0040] In practical use, different preset period requirements can be set as needed. In this embodiment, the preset period requirement is T1=2^t≤T2 and t takes the maximum value. For example, when the number period is 100ms, the port period should be 2^6=64ms, that is, t takes the value of 6.
[0041] It should be noted that the above description does not limit parameter group numbers with the same number period to only one MVB port; it may also correspond to multiple MVB ports with the same port period.
[0042] In one embodiment of this example, the preset length requirement is that the sum of the lengths of the number data in the parameter group is less than or equal to the sum of the lengths of the corresponding MVB ports.
[0043] In practical use, different preset length requirements can be set as needed. In this embodiment, the preset length requirement is that the sum of the data lengths of the parameter group numbers is less than or equal to the sum of the data lengths of the corresponding MVB ports. For example, if the data lengths of the three parameter group numbers are 1 byte, 2 bytes, and 5 bytes respectively, then the corresponding MVB port is 8 bytes, i.e., the value of x in 2^x is 3. Of course, there may also be cases where the data lengths of the three parameter group numbers are 1 byte, 2 bytes, and 3 bytes respectively. In this case, the corresponding MVB port is still 8 bytes, but the actual data only includes the first 6 bytes of this MVB port, and the last 2 bytes will be set to 0 and left empty.
[0044] Therefore, the above allocation can also be further understood as first allocating a parameter group number whose number data length is exactly equal to the data length of one MVB port, then allocating multiple parameter group numbers whose sum of number data length is equal to the data length of one MVB port, then allocating multiple parameter group numbers whose sum of number data length is equal to the sum of the data lengths of multiple MVB ports, and finally allocating multiple parameter group numbers whose sum of number data length is less than the sum of the data lengths of multiple MVB ports, and setting the MVB ports to 0 and leaving them empty.
[0045] In one embodiment of this example, such as Figure 3 As shown, step S203 involves sequentially allocating several MVB ports that meet the preset period requirements to each number group, forming i allocation groups, including: S301. Obtain the number cycle of the j-th number group, where 1≤j<i; S302. Obtain an MVB port that meets the preset period requirements based on the number period as the selected MVB port; S303. Combine the parameter group numbers corresponding to the selected MVB port and the number period to form the j-th allocation group; S304. Use j+1 as the updated j and return to the step of obtaining the number period of the j-th number group, repeating until the updated j equals i.
[0046] Since there are multiple number groups, such as i number groups, it is necessary to sequentially allocate several MVB ports that meet the preset period requirements to these numbers, ultimately forming i allocation groups. In practical applications, since the number periods of each number group are different, a cyclic setting method can be used to sequentially allocate MVB ports corresponding to the required port periods by combining different number periods with the preset period requirements.
[0047] Steps S301 to S304 describe one cycle, and the condition for the cycle to end is that j equals i in the last update. At this time, the cycle ends, and the allocation group obtained by each cycle is the required parameter group number with different number periods and the port period of the MVB port in it meets the preset period requirement.
[0048] In one embodiment of this example, such as Figure 4 As shown, step S204, which involves forming a mapping relationship between parameter group numbers and MVB ports according to the data length of the numbers in each allocation group and the data length of the MVB ports, and in accordance with preset length requirements, includes: S401. Obtain the data length and MVB port of all numbers in the kth allocation group, where 1≤k<i; S402. Get the data length of the MVB port; S403. Based on the number data length from largest to smallest, allocate the remaining MVB ports with the longest data length according to the preset length requirements; S404. Form the kth group mapping based on the corresponding parameter group number and the MVB port; S405. Use k+1 as the updated k and return to the step of obtaining the data length of all numbers and MVB ports in the kth allocation group, looping until the updated k equals i; S406. Combine all mappings to form a mapping relationship between parameter group numbers and MVB ports.
[0049] After the parameter group numbers and MVB ports in each allocation group meet the preset period requirements, they only achieve matching of their respective periods. However, the direct mapping relationship between the parameter group numbers and the MVB ports cannot be met. In practical applications, since the data lengths of the parameter group numbers and the MVB ports are different, a cyclic setting method can be adopted. The parameter group numbers in each allocation group are allocated according to their data length from largest to smallest, combined with the preset length requirements, to the MVB ports corresponding to the required data lengths as the allocation method.
[0050] Steps S401 to S405 describe one loop, and the loop ends when the last update obtains k equal to i. At this time, the loop ends, and the mappings obtained from each loop are substituted into step S406 to combine all the mappings to form the mapping relationship between parameter group number and MVB port, and finally form the mapping relationship required by the data conversion method of this application.
[0051] In one embodiment of this example, such as Figure 5 As shown, after step S103, i.e., if the preset communication standard is met, the message identifier of the first data is parsed to obtain the parameter group number, the following steps are also included: S501. If there is no corresponding parameter group number in the preset configuration list, the parameter group number will be used as the feedback number. S502. Determine if the preset configuration list has an updated version; S503. If there is no updated version, record the number to be fed back and the corresponding first data to form the first feedback record; S504. If there is an updated version, update the preset configuration list according to the updated version; S505. Determine whether the parameter group number in the updated preset configuration list corresponds to the number to be fed back; S506. If so, proceed to the step of obtaining the corresponding MVB port as the first switching port according to the preset mapping table if there is a corresponding parameter group number in the preset configuration list. S507. If not, record the number to be fed back and the corresponding first data to form the first feedback record.
[0052] In practical applications, although the preset configuration list theoretically includes all known parameter group numbers, with technological updates, newly added parameter group numbers may not be added to the preset configuration list in a timely manner, or due to some abnormal reasons, such as the loss of some data when reading the preset configuration list, or the failure to read and resulting in a blank list, there may also be situations where the parameter group numbers in the first data obtained from the CAN bus do not appear in the preset configuration list.
[0053] If there is no corresponding parameter group number in the preset configuration list, then the parameter group number is used as the feedback number in step S501, and the specific processing of the feedback number is selected according to the judgment result of step S502, which determines whether the preset configuration list has an updated version.
[0054] If there is no updated version, then the step S503 is executed to record the number to be fed back and the corresponding first data to form a first feedback record, so that the managers or operators can perform subsequent processing on the number to be fed back and the corresponding first data based on the first feedback record.
[0055] It should be noted that an updated version can be determined by the version number. For example, if the current preset configuration list version number is 1.1, while the preset configuration list stored on the server or host computer has a version number of 1.2, then an updated version exists. Alternatively, it can be determined by the amount of data. For example, if the current preset configuration list has 1123 data entries, while the preset configuration list stored on the server or host computer has 1241 data entries, then an updated version is also considered to exist. Furthermore, it can even be determined by the size of the space occupied by the preset configuration list itself. For example, if the current preset configuration list occupies 1.54MB of space, while the preset configuration list stored on the server or host computer occupies 1.61MB of space, then an updated version is also considered to exist.
[0056] If an updated version is available, then step S504 is executed to update the preset configuration list according to the updated version, that is, to update the current preset configuration list. In step S505, it is determined whether the updated preset configuration list corresponds to the parameter group number to be fed back. Based on the determination result, step S506 or step S507 is selected to proceed.
[0057] If so, proceed to step S506, which involves entering the step "If there is a corresponding parameter group number in the preset configuration list, then obtain the corresponding MVB port as the first switching port according to the preset mapping table". That is, if there is a corresponding parameter group number in the updated preset mapping table, then obtain the corresponding first switching port according to the preset mapping table and execute the corresponding subsequent steps.
[0058] If not, then the process of recording the feedback number and the corresponding first data in step S507 is executed to form a first feedback record, so that the management personnel or the actual operator can perform subsequent processing on the feedback number and the corresponding first data based on the first feedback record.
[0059] The data conversion method provided in this embodiment determines whether there is an updated version of the preset configuration list when there is no corresponding parameter group number in the preset configuration list. Depending on whether there is an updated version, it chooses to either re-determine whether the updated version has a corresponding parameter group number or record the number to be fed back and the corresponding first data to form a first feedback record. This allows for the determination of whether there is a corresponding parameter group number based on the latest or valid preset configuration list, thereby improving the real-time performance of the data conversion method.
[0060] It should be added that in practical applications, there may be multiple updated versions available, and the specific selection will vary depending on the situation. Therefore, if an updated version is available, the preset configuration list should be updated accordingly, including: If there are multiple preset configuration lists that meet the criteria for updating the version, since updating the preset configuration list requires certain system and network resources, it is determined whether the current resources exceed the resource threshold, and the subsequent execution steps are selected based on the determination result.
[0061] If the resource size is not greater than the resource threshold, it means that the current resources cannot support the resources required to update the preset configuration list. In this case, a preset configuration list with a space occupied less than the space occupied is obtained as a candidate preset configuration list. That is, the preset configuration list corresponding to a space occupied smaller than the expected space allowed by the space occupied is selected, where the space occupied is the minimum available space occupied.
[0062] After obtaining the list of candidate preset configurations, the preset configuration list with the highest version number is selected as the update version. This means that the space occupied is the primary consideration, while the version number is the secondary consideration. In this way, even if resources do not support it, it is still possible to obtain the preset configuration list corresponding to the maximum space occupied and the latest version number that meets the space occupation threshold. This serves as the update version, ensuring the success rate of the update while also taking into account the matching success rate of parameter group numbers or the information content in the first feedback record.
[0063] If the resource threshold is exceeded, it means that the current resources can support the resources required to update the preset configuration list. In this case, the preset configuration list with the largest space is obtained as the update version, so that the updated preset configuration list can have the most data, improve the matching success rate of parameter group numbers, or increase the information content in the first feedback record.
[0064] If there is only one preset configuration list that meets the criteria for an updated version, then this preset configuration list will be considered the updated version.
[0065] Once a definite and unique updated version can be obtained in all the above situations, the preset configuration list is updated according to the updated version.
[0066] In one embodiment of this example, such as Figure 6 As shown, after step S107, i.e., if the transmission source is the MVB bus, determining whether the MVB port corresponding to the second data read from the MVB bus matches the preset mapping table, the method further includes: S601. If the preset mapping table does not match, the MVB port will be used as the port to be confirmed. S602. Record the port to be confirmed and store the corresponding second data to form a second feedback record; S603. Obtain the number of ports to be confirmed in the second feedback record; S604. If the number of occurrences exceeds the preset occurrence threshold, the corresponding port to be confirmed will be designated as the port to be updated. S605. Obtain the second data corresponding to the port to be updated in the second feedback record as the judgment data; S606. If the judgment data meets the preset judgment rules, then update the preset mapping table according to the port to be updated; S607. If the judgment data does not conform to the preset judgment rules, delete the corresponding second data and the corresponding record of the port to be confirmed from the second feedback record.
[0067] In practical applications, newly added MVB ports may not be added to the preset mapping table in a timely manner, or due to some abnormal reasons, such as the loss of some data when reading the preset mapping table, or the failure of reading resulting in a blank mapping table, there may also be situations where the MVB ports in the second data obtained from the MVB bus do not appear in the preset mapping table.
[0068] If the preset mapping table is not matched, step S601 is executed to designate the MVB port as the port to be confirmed, and step S602 is executed to record the port to be confirmed and store the corresponding second data, forming a second feedback record. This allows administrators or operators to perform subsequent processing on the port to be confirmed and the corresponding second data based on the second feedback record. The subsequent processing includes step S603, which involves obtaining the number of ports to be confirmed in the second feedback record and determining whether the number exceeds a preset threshold. Based on the determination result, step S604 or other steps are selected for execution.
[0069] If the number of occurrences is less than or equal to the preset threshold, it means that the corresponding port to be confirmed has not yet reached the expected level that requires additional processing. In this case, the second feedback record will be stored for further processing.
[0070] If the number of occurrences exceeds the preset threshold, it indicates that the corresponding port to be confirmed has reached the expected level requiring additional processing. That is, the corresponding MVB port may have an actual need, or the preset mapping table has an anomaly. In this case, step S604 is executed to treat the corresponding port to be confirmed as the port to be updated, and step S605 is executed to obtain the second data corresponding to the port to be updated in the second feedback record as the judgment data, and to determine whether the judgment data conforms to the preset judgment rules.
[0071] It should be noted that the preset judgment rules are pre-set rules used to determine whether a corresponding port to be confirmed requires special processing based on the judgment data. Specific judgment factors may include whether the judgment data conforms to the general data transmission rules of MVB ports, whether the corresponding port already exists in the general MVB port or preset mapping table, etc. Special cases include the need to add the port to be confirmed to the preset mapping table, or the need to reread the preset mapping table.
[0072] If the data matches the preset judgment rules, it means that the corresponding MVB port is confirmed to need to be added to the preset mapping table, or the preset mapping table has an error and needs to be read again. Then, step S606 is executed to update the preset mapping table according to the port to be updated.
[0073] If the judgment data does not conform to the preset judgment rules, it means that the corresponding MVB port confirmation does not need to be added to the preset mapping table, or the preset mapping table has no abnormality and does not need to be read again. Then, the corresponding second data and the corresponding record of the port to be confirmed are deleted from the second feedback record in step S607.
[0074] The data conversion method provided in this embodiment records the corresponding port to be confirmed and stores the corresponding second data to form a second feedback record when the MVB port corresponding to the second data does not match the preset mapping table. By judging whether the number of ports to be confirmed in the second feedback record is greater than a preset occurrence threshold, and judging whether the second data corresponding to the ports to be confirmed with a number greater than the preset occurrence threshold meets the preset judgment rule, the method selects whether to update the preset mapping table based on this MVB port or delete the corresponding second data and the corresponding record of the port to be confirmed from the second feedback record. This allows for further judgment on the corresponding second data and the preset judgment rule when the MVB port does not match the preset mapping table, confirming whether the preset mapping table needs to be updated, thereby improving the adaptability of the data conversion method.
[0075] Secondly, this application provides a CAN bus to MVB bus data conversion system, comprising: The first acquisition module 1 is used to acquire data transmission and reception instructions and the corresponding transmission sources; If the source of the transmission is the CAN bus, the first judgment module 2 is used to determine whether the first data read from the CAN bus conforms to the preset communication standard. If the first parsing module 3 conforms to the preset communication standard, then the first parsing module 3 is used to parse the message identifier of the first data to obtain the parameter group number; If the preset configuration list contains a corresponding parameter group number, the second acquisition module 4 is used to obtain the corresponding MVB port as the first switching port according to the preset mapping table. The first filling module 5 is used to fill the first data corresponding to the parameter group number into the first switching port; The first transmitting module 6 is used to acquire the MVB port data of the first switching port and send it to the MVB bus; If the sending source is the MVB bus, the second judgment module 7 is used to determine whether the MVB port corresponding to the second data read from the MVB bus matches the preset mapping table. If the third acquisition module 8 matches the preset mapping table, then the third acquisition module 8 is used to obtain the parameter group number corresponding to the MVB port in the preset mapping table as the first exchange number; The first writing module 9 is used to write the second data into the data cache corresponding to the first exchange number; The second transmitting module 10 is used to acquire the CAN data in the data buffer and send it to the CAN bus; The preset mapping table is a pre-set mapping relationship between parameter group numbers and MVB ports, and the preset configuration list is a pre-set list including known parameter group numbers.
[0076] It should be noted that the data transmission relationships or logical connections between the various functional modules mentioned above can be determined according to the corresponding steps in their respective CAN bus and MVB bus data conversion methods, and will not be elaborated further here. The data transmission relationships or logical connections between the functional modules are only for understanding the CAN bus and MVB bus data conversion system and are not specifically limited.
[0077] The CAN bus to MVB bus data conversion system provided in this embodiment obtains the parameter group number from the first data whose transmission source is the CAN bus and conforms to a preset communication standard, based on the transmission source corresponding to the data transmission command. For parameter group numbers that have a corresponding parameter group number in the preset configuration list, the corresponding MVB port is obtained from the preset mapping table as the first switching port. The first data is then filled into the first switching port and sent to the MVB bus. For second data whose transmission source is the MVB bus and whose corresponding MVB port matches the preset mapping table, the parameter group number corresponding to its MVB port in the preset mapping table is obtained as the first switching number. The second data is written into the data buffer corresponding to the first switching number and sent to the CAN bus. Thus, by pre-determining the preset mapping table of corresponding parameter group numbers and MVB ports, data conversion between the CAN bus and the MVB bus is achieved without additional data rewriting or other processing, effectively realizing data conversion to meet control requirements.
[0078] Furthermore, the CAN bus to MVB bus data conversion system provided in this embodiment can also be equipped with other functional modules as needed, or the above functional modules can be divided into multiple functional units, so as to achieve the technical effects corresponding to any of the aforementioned CAN bus to MVB bus data conversion methods.
[0079] Thirdly, this application provides a computer-readable storage medium storing computer instructions. When the computer instructions are loaded and executed by a processor, they employ the CAN bus to MVB bus data conversion method described above, which can achieve the technical effects corresponding to the CAN bus to MVB bus data conversion method described above.
[0080] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order constraint on the execution of these steps; they can be executed in other orders, meaning the execution order can be reasonably arranged according to actual needs. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0081] It should also be noted that, in this specification, 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.
[0082] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for data conversion between CAN bus and MVB bus, characterized in that, Includes the following steps: Obtain data transmission and reception instructions and their corresponding sources; If the transmission source is a CAN bus, then determine whether the first data read from the CAN bus conforms to the preset communication standard; If the preset communication standard is met, the message identifier of the first data is parsed to obtain the parameter group number; If the parameter group number is in the preset configuration list, the corresponding MVB port is obtained as the first switching port according to the preset mapping table; Fill the first data corresponding to the parameter group number into the first switching port; Obtain the MVB port data from the first switching port and send it to the MVB bus; If the transmission source is an MVB bus, then determine whether the MVB port corresponding to the second data read from the MVB bus matches the preset mapping table; If the preset mapping table is matched, the parameter group number corresponding to the MVB port in the preset mapping table is obtained as the first switching number; Write the second data into the data cache corresponding to the first exchange number; The CAN data in the data cache is acquired and sent to the CAN bus; The preset mapping table is a pre-set mapping relationship between the parameter group number and the MVB port, and the preset configuration list is a pre-set list including the known parameter group numbers; The step of parsing the message identifier of the first data to obtain the parameter group number if the preset communication standard is met further includes: If the parameter group number is not found in the preset configuration list, then the parameter group number will be used as the feedback number. Determine if the preset configuration list has an updated version; If there is no updated version, the number to be fed back and the corresponding first data are recorded to form a first feedback record; If an updated version is available, the preset configuration list is updated accordingly. In the updated preset configuration list, determine whether the parameter group number corresponds to the number to be fed back; If so, proceed to the step of obtaining the corresponding MVB port as the first switching port according to the preset mapping table if the corresponding parameter group number is in the preset configuration list; If not, record the number to be fed back and the corresponding first data to form the first feedback record; If an updated version is available, the preset configuration list will be updated accordingly, including: If there are multiple preset configuration lists that meet the criteria for the updated version, then determine whether the current resource exceeds the resource threshold. If the space occupied is not greater than the resource threshold, then the list of preset configurations with space occupied less than the threshold is obtained as the list of candidate preset configurations. The space occupied threshold is the minimum available space occupied. After obtaining the list of candidate preset configurations, select the preset configuration with the highest version number from the list of candidate preset configurations as the update version; If the resource limit is exceeded, the preset configuration list with the largest space usage is retrieved as the updated version. If there is only one preset configuration list that meets the criteria for an updated version, then this preset configuration list will be considered the updated version.
2. The data conversion method according to claim 1, characterized in that, Before obtaining the data transmission and reception instructions and the corresponding transmission source, the method further includes: Obtain all parameter group numbers from the preset configuration list, along with their corresponding number periods and number data lengths; Numbers in parameter groups with the same number period are grouped into i number groups; Each of the number groups is sequentially assigned a number of MVB ports that meet the preset period requirements, forming i allocation groups; Based on the number data length in each allocation group and the data length of the MVB port, a mapping relationship between the parameter group number and the MVB port is formed according to a preset length requirement; Based on the mapping relationship, a preset mapping table is formed that maps the MVB port to all the parameter group numbers in the preset configuration list.
3. The data conversion method according to claim 2, characterized in that, The preset period requirement is T1 = 2^t ≤ T2, where T1 is the port period of the MVB port, T2 is the number period, 0 ≤ t ≤ 10, and t takes the maximum value.
4. The data conversion method according to claim 2, characterized in that, The preset length requirement is that the sum of the number data lengths of the parameter group numbers is less than or equal to the sum of the data lengths of the corresponding MVB ports.
5. The data conversion method according to claim 2, characterized in that, The step of sequentially allocating a plurality of MVB ports that meet a preset period requirement to each of the number groups to form i allocation groups includes: Obtain the number period of the j-th number group, where 1 ≤ j < i; The MVB port that meets the preset period requirement is selected as the MVB port according to the number period. The selected MVB port is combined with the parameter group number corresponding to the number period to form the j-th allocation group; The step of obtaining the number period of the j-th number group is repeated until the updated j equals i.
6. The data conversion method according to claim 2, characterized in that, The step of forming the mapping relationship between the parameter group number and the MVB port according to the number data length in each of the allocation groups and the data length of the MVB port, and in accordance with a preset length requirement, includes: Obtain the data length of all numbers and the MVB port in the kth allocation group, where 1 ≤ k < i; Obtain the data length of the MVB port; According to the number data length from largest to smallest, the remaining MVB ports are allocated the longest data length in accordance with the preset length requirement; The k-th mapping is formed based on the corresponding parameter group number and the MVB port; Use k+1 as the updated k and return to the step of obtaining the length of all the number data and the MVB port in the kth allocation group, looping until the updated k equals i; All the mappings are combined to form the mapping relationship between the parameter group number and the MVB port.
7. The data conversion method according to claim 1, characterized in that, After determining whether the MVB port corresponding to the second data read from the MVB bus matches the preset mapping table if the transmission source is an MVB bus, the method further includes: If the preset mapping table is not matched, the MVB port will be used as the port to be confirmed. Record the port to be confirmed and store the corresponding second data to form a second feedback record; Obtain the number of ports to be confirmed as described in the second feedback record; If the number of occurrences exceeds a preset occurrence threshold, the corresponding port to be confirmed will be designated as the port to be updated. Obtain the second data corresponding to the port to be updated in the second feedback record as the judgment data; If the determination data conforms to the preset determination rules, then the preset mapping table is updated according to the port to be updated; If the judgment data does not conform to the preset judgment rule, then the corresponding second data and the corresponding record of the port to be confirmed are deleted from the second feedback record.
8. A CAN bus to MVB bus data conversion system, characterized in that, include: The first acquisition module is used to acquire data transmission and reception instructions and their corresponding transmission sources; If the transmission source is a CAN bus, the first judgment module is used to determine whether the first data read from the CAN bus conforms to a preset communication standard. If the first parsing module conforms to the preset communication standard, then the first parsing module is used to parse the message identifier of the first data to obtain the parameter group number; If the parameter group number is in the preset configuration list, the second acquisition module is used to obtain the corresponding MVB port as the first switching port according to the preset mapping table. The first filling module is used to fill the first data corresponding to the parameter group number into the first switching port; The first transmitting module is used to acquire the MVB port data of the first switching port and send it to the MVB bus; If the sending source is an MVB bus, the second judgment module is used to determine whether the MVB port corresponding to the second data read from the MVB bus matches the preset mapping table. If the third acquisition module matches the preset mapping table, the third acquisition module is used to acquire the parameter group number corresponding to the MVB port in the preset mapping table as the first exchange number; The first writing module is used to write the second data into the data cache corresponding to the first exchange number; The second transmitting module is used to acquire the CAN data in the data buffer and transmit it to the CAN bus; The preset mapping table is a pre-set mapping relationship between the parameter group number and the MVB port, and the preset configuration list is a pre-set list including the known parameter group numbers; The step of parsing the message identifier of the first data to obtain the parameter group number if the preset communication standard is met further includes: If the parameter group number is not found in the preset configuration list, then the parameter group number will be used as the feedback number. Determine if the preset configuration list has an updated version; If there is no updated version, the number to be fed back and the corresponding first data are recorded to form a first feedback record; If an updated version is available, the preset configuration list is updated accordingly. In the updated preset configuration list, determine whether the parameter group number corresponds to the number to be fed back; If so, proceed to the step of obtaining the corresponding MVB port as the first switching port according to the preset mapping table if the corresponding parameter group number is in the preset configuration list; If not, record the number to be fed back and the corresponding first data to form the first feedback record; If an updated version is available, the preset configuration list will be updated accordingly, including: If there are multiple preset configuration lists that meet the criteria for the updated version, then determine whether the current resource exceeds the resource threshold. If the space occupied is not greater than the resource threshold, then the list of preset configurations with space occupied less than the threshold is obtained as the list of candidate preset configurations. The space occupied threshold is the minimum available space occupied. After obtaining the list of candidate preset configurations, select the preset configuration with the highest version number from the list of candidate preset configurations as the update version; If the resource limit is exceeded, the preset configuration list with the largest space usage is retrieved as the updated version. If there is only one preset configuration list that meets the criteria for an updated version, then this preset configuration list will be considered the updated version.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the CAN bus to MVB bus data conversion method as described in any one of claims 1 to 7.