Data conversion method and device
By splitting and re-encapsulating the messages, the communication problems caused by the different frame structures of the CAN bus and Ethernet are solved, data conversion is realized, and the communication between the CAN bus and Ethernet is ensured.
Patent Information
- Application Number
- CN202410843815.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-18
AI Technical Summary
Communication between CAN bus and Ethernet (based on SOMEIP protocol) is impossible due to different frame structures.
By splitting and re-encapsulating messages, data conversion methods are provided to ensure communication between the CAN bus and Ethernet, even if the frame structures are different. Specific steps include obtaining the message, splitting and encapsulating it according to the preset length, adding the preset header, and ensuring data type conversion.
It realizes communication between CAN bus and Ethernet, provides data conversion methods between different message types, and solves communication obstacles caused by differences in frame structure.
Smart Images

Figure CN118803084A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a data conversion method and device. Background Art
[0002] CAN bus communication is the most typical communication method in the field of automotive electronic control due to its perfect technology. However, with the increasing number of in-vehicle electronic products and increasingly complex functions, users have also put forward new requirements for in-vehicle communication technology. In-vehicle Ethernet communication can provide support for in-vehicle communication technology due to its advantages such as high bandwidth and high cost performance, and provide reliable, mature, low-cost and standardized solutions for in-vehicle communication technology. Ethernet communication is service-oriented communication.
[0003] However, since the frame structure of the CAN bus data transmission is different from the frame structure of the Ethernet (based on the SOMEIP protocol) data transmission, the CAN bus and the Ethernet (based on the SOMEIP protocol) cannot communicate with each other. Summary of the invention
[0004] The embodiments of the present application provide a data conversion method and device, which provide a data conversion method between different message types by splitting and repackaging the messages. Even if the frame structure of the CAN bus data transmission is different from the frame structure of the Ethernet (based on the SOMEIP protocol) data transmission, communication between the CAN bus and the Ethernet can be achieved through data conversion.
[0005] In a first aspect, an embodiment of the present application provides a data conversion method, comprising:
[0006] Obtaining a first message;
[0007] Splitting the first message according to a first preset length to obtain first signal segments of at least one data type;
[0008] Encapsulate the first signal segment of at least one data type according to a second preset length to obtain a second message;
[0009] The preset message header is added to the header of the second message to obtain a third message.
[0010] In one possible implementation, obtaining a first message includes:
[0011] When the fourth message is received, the first message satisfying the first preset identifier and the third preset length is screened out from the fourth message.
[0012] In a possible embodiment, the first preset identifier includes a first target preset identifier and a second target preset identifier, and when the fourth message is received, the first message that satisfies the first preset identifier and the third preset length is screened out from the fourth message, including:
[0013] When the fourth message is received, a first target message whose message identifier is consistent with the first target preset identifier is selected from the fourth message;
[0014] Filter out a second target message whose message identifier is consistent with a second target preset identifier from the first target message;
[0015] A first message satisfying a first preset length is screened out from the second target message.
[0016] In a possible implementation, before adding the preset message header to the header of the second message to obtain the third message, the method further includes:
[0017] Check if the socket adapter is open;
[0018] The preset message header is added to the header of the second message to obtain a third message, including:
[0019] If the socket adapter is in an open state, adding a preset message header to the header of the second message to obtain a third message;
[0020] If the socket adapter is in a closed state, the second message is deleted.
[0021] In a possible implementation, the first message includes a CAN message, and the third message includes an Ethernet message; after adding the preset message header to the header of the second message to obtain the third message, the method further includes:
[0022] A third message is sent to the Ethernet device.
[0023] In a second aspect, an embodiment of the present application provides a data conversion method, including:
[0024] Get the fifth message;
[0025] Identify a message header of the fifth message, and select a sixth message whose message header satisfies a preset message header from the fifth message;
[0026] According to a preset order, the messages after the message header of the sixth message are intercepted in sequence to obtain at least one second signal segment;
[0027] At least one second signal fragment is encapsulated respectively to obtain a seventh message.
[0028] In one possible implementation, obtaining the fifth message includes:
[0029] When the eighth message is received, a third target message having a message identifier consistent with the second preset identifier is selected from the eighth message;
[0030] A fifth message having media access control information consistent with preset media access control information is screened out from the third target message.
[0031] In a possible implementation, before sequentially intercepting the messages after the message header of the sixth message in a preset order to obtain at least one second signal segment, the method further includes:
[0032] Check if the socket adapter is open;
[0033] According to a preset order, the messages after the message header of the sixth message are intercepted in sequence to obtain at least one second signal segment, including:
[0034] If the socket adapter is in an open state, the messages after the message header of the sixth message are intercepted in sequence according to a preset order to obtain at least one second signal segment;
[0035] If the socket adapter is in a closed state, the sixth message is deleted.
[0036] In a possible implementation, the fifth message includes an Ethernet message, and the seventh message includes a CAN message; after encapsulating at least one second signal segment to obtain the seventh message, the method further includes:
[0037] Adding the third preset identifier to the seventh message respectively to obtain a ninth message;
[0038] A ninth message is sent to the controller corresponding to the third preset identifier.
[0039] In a third aspect, an embodiment of the present application provides a data conversion device, including:
[0040] An acquisition module, used for acquiring a first message;
[0041] A splitting module, used to split the first message according to a first preset length to obtain a first signal segment of at least one data type;
[0042] An encapsulation module, used to encapsulate a first signal segment of at least one data type according to a second preset length to obtain a second message;
[0043] The adding module is used to add a preset message header to the header of the second message to obtain a third message.
[0044] In a fourth aspect, an embodiment of the present application provides a data conversion device, including:
[0045] An acquisition module, used for acquiring a fifth message;
[0046] an identification module, used to identify a message header of the fifth message, and filter out a sixth message whose message header satisfies a preset message header from the fifth message;
[0047] An interception module, used to intercept the messages after the message header of the sixth message in sequence according to a preset order to obtain at least one second signal segment;
[0048] The encapsulation module is used to encapsulate at least one second signal segment respectively to obtain a seventh message.
[0049] In a fifth aspect, an embodiment of the present application provides an electronic device, the device comprising:
[0050] a processor and a memory storing computer program instructions;
[0051] When the processor executes the computer program instructions, any one of the above data conversion methods is implemented.
[0052] In a sixth aspect, an embodiment of the present application provides a computer storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, any of the above-mentioned data conversion methods is implemented.
[0053] In a seventh aspect, an embodiment of the present application provides a computer program product, characterized in that when instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the above-mentioned data conversion methods.
[0054] The data conversion method and device of the embodiment of the present application include: when receiving a first message, filtering out a second message that meets a first preset identifier and a first preset length from the first message; splitting the second message according to the second preset length to obtain a first signal segment of at least one data type; encapsulating the first signal segment of the at least one data type according to a third preset length to obtain a third message; adding a preset message header to the header of the third message to obtain a fourth message. In this way, by splitting and repackaging the message, a data conversion method between different message types is provided, and even if the frame structure of the CAN bus data transmission is different from the frame structure of the Ethernet (based on the SOMEIP protocol) data transmission, the communication between the CAN bus and the Ethernet can be realized through data conversion. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0056] Figure 1 is a schematic diagram of the structure of an AutoSAR system provided by an embodiment of the present application;
[0057] Figure 2 is a flowchart of a data conversion method provided by another embodiment of the present application;
[0058] Figure 3 is a flowchart of a data conversion method provided by another embodiment of the present application;
[0059] Figure 4 is a flowchart of a data conversion method provided in yet another embodiment of the present application;
[0060] Figure 5 is a flowchart of a data conversion method provided in yet another embodiment of the present application;
[0061] Figure 6 is a flowchart of a data conversion method provided in yet another embodiment of the present application;
[0062] Figure 7 is a structural schematic diagram of a data conversion device provided in yet another embodiment of the present application;
[0063] Figure 8 is a structural schematic diagram of a data conversion device provided in yet another embodiment of the present application;
[0064] Fig. 9 It is a structural diagram of an electronic device provided in yet another embodiment of the present application. DETAILED DESCRIPTION
[0065] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0066] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0067] CAN bus communication is the most typical communication method in the field of automotive electronic control due to its perfect technology. However, with the increasing number of in-vehicle electronic products and increasingly complex functions, users have also put forward new requirements for in-vehicle communication technology. In-vehicle Ethernet communication can provide support for in-vehicle communication technology due to its advantages such as high bandwidth and high cost performance, and provide reliable, mature, low-cost and standardized solutions for in-vehicle communication technology. Ethernet communication is service-oriented communication.
[0068] However, due to the different frame structures of CAN bus data transmission and Ethernet (based on SOMEIP protocol) data transmission, CAN bus and Ethernet (based on SOMEIP protocol) cannot communicate. SOMEIP (Scalable service-oriented MiddlewarE over IP) refers to scalable service-oriented middleware based on IP, which is a service-oriented automotive Ethernet communication protocol.
[0069] In order to solve the problems of the prior art, the embodiments of the present application provide a data conversion method and device, which are applied to the AutoSAR system. The full name of the AutoSAR system is Automotive Open System Architecture. Figure 1As shown, the AutoSAR system 100 includes a Can driver module 101, a Can interface abstraction layer 102, a communication module 103, a real-time operating environment module 104, a SomeIp serialization module 105, a big data communication module 106, a socket adapter (SOAD) 107, a TcpIp module 108, an Ethernet interface abstraction layer 109 and an Ethernet driver module 110. Among them, the Can driver module refers to the Can Driver module; the Can interface abstraction layer refers to the CAN Interface, the interface module CanIf of the Can (bus); the communication module refers to the Communication, COM module; the real-time operating environment module refers to the Run-TimeEnvironment, RTE module; the SomeIp serialization module refers to the SOMEIPXF module; the big data communication module refers to the Large DataCom, LdCom module; the TcpIp module refers to the Transmission Control Protocol / Internet Protocol (Transmission Control Protocol / Internet Protocol) module; the Ethernet interface abstraction layer refers to the Ethernet Interface, the interface module EthIf of Eth; and the Ethernet driver module refers to the Eth Driver module.
[0070] The following first introduces the data conversion method provided in the embodiment of the present application.
[0071] Figure 2 A flow chart of a data conversion method provided by an embodiment of the present application is shown.
[0072] like Figure 2 As shown, the data conversion method provided in the embodiment of the present application includes the following steps S210 to S240.
[0073] S210: Obtain a first message.
[0074] Here, the first message is a message received in the controller on the bus, which may be a bus message. The first message may also be a message of shorter length, and the length of the first message is less than a preset threshold. The first message reaches the communication module through the Can driver module and the Can interface abstraction layer.
[0075] S220. Split the first message according to a first preset length to obtain first signal segments of at least one data type.
[0076] Here, the first preset length is set in advance.
[0077] In some embodiments, the communication module includes a first preset length. Here, the first preset length may include at least one. Through the communication module, the first message is intercepted according to the first preset length, and the first message is split into at least one first signal segment of a data type.
[0078] It should be noted that the lengths of the first signal segments may be different. If the lengths of the signal segments are different, the data types are different, that is, at least one first signal segment of a data type is obtained. The length of the first signal segment may be represented by "bytes" or "bits".
[0079] S230. Encapsulate a first signal segment of at least one data type according to a second preset length to obtain a second message.
[0080] Here, the second preset length is set in advance.
[0081] In some embodiments, the first signal fragment of at least one data type is packaged and processed by the real-time operating environment module according to the second preset length. The first signal fragment of at least one data type is encapsulated into the serialization interface of the SomeIp serialization module according to the second preset length. For example, the second preset length is 8 bytes. Because this SomeIp serialization module adopts Setter (setting mode), it can be used to change Ethernet data.
[0082] In some embodiments, the specific signal value in the first signal segment can also be obtained through the signal receiving interface of the real-time operating environment module.
[0083] S240: Add a preset message header to the header of the second message to obtain a third message.
[0084] Here, the preset message header is set in advance. The third message may be an Ethernet message or a message with a longer length, and the length of the third message is not less than a preset threshold.
[0085] In some embodiments, after encapsulating the first signal fragment, the processing of the internal signal of the message is no longer involved. The SomeIp serialization module transmits a protocol data unit (PDU) to the TcpIp module through the sending function of the big data communication module and the socket adapter. The PDU includes the second message. The TcpIp module adds a preset message header to the header of the second message to obtain a third message.
[0086] In this way, by splitting and repackaging the messages, a data conversion method between different message types is provided. Even if the frame structure of the CAN bus data transmission is different from the frame structure of the Ethernet (based on the SOMEIP protocol) data transmission, communication between the CAN bus and the Ethernet can be achieved through data conversion.
[0087] Based on this, in some embodiments, such as Figure 3 As shown, the above S210 may specifically include:
[0088] S211. When a fourth message is received, select a first message that satisfies a first preset identifier and a third preset length from the fourth message.
[0089] In some embodiments, the fourth message is a message received in a controller on the bus. The fourth message reaches the communication module through the Can driver module and the Can interface abstract layer. The Can driver module and the Can interface abstract layer include a first preset identifier and a third preset length, and the fourth message is filtered to select the expected message from the fourth message, that is, the first message that meets the first preset identifier and the third preset length is selected from the fourth message. Here, the first preset identifier can be an ID. For example, for a bus message, it can be a CANID.
[0090] In some embodiments, if there are messages in the fourth message that do not meet the first preset identifier and the third preset length, the messages that do not meet the first preset identifier and the third preset length are discarded, and the messages that do not meet the first preset identifier and the third preset length are deleted.
[0091] In this way, messages that do not conform to the user's set format are discarded, preventing messages that do not conform to the settings from being converted into data, which in turn causes the in-vehicle device to receive an erroneous signal and perform an erroneous action.
[0092] Based on this, in some embodiments, the first preset identifier includes a first target preset identifier and a second target preset identifier, and the above S211 may specifically include:
[0093] When the fourth message is received, a first target message whose message identifier is consistent with the first target preset identifier is selected from the fourth message;
[0094] Filter out a second target message whose message identifier is consistent with a second target preset identifier from the first target message;
[0095] A first message satisfying a first preset length is screened out from the second target message.
[0096] In some embodiments, the fourth message passes through the Can driver module. The Can driver module includes a first target preset identifier, and the first target message whose message identifier is consistent with the first target preset identifier is filtered out from the fourth message through the interrupt service function of the Can driver module. The first target message passes through the Can interface abstraction layer, and the Can interface abstraction layer includes a second target preset identifier. The second target message whose message identifier is consistent with the second target preset identifier is filtered out from the first target message through the receiving indication function of the Can interface abstraction layer. The Can interface abstraction layer also includes a first preset length, and the first message that meets the first preset length is filtered out from the second target message through the Can interface abstraction layer. The first preset length can be the maximum length of the message, and meeting the first preset length means filtering out the first message that is less than the first preset length from the second target message; the first preset length can be the minimum length of the message, and meeting the first preset length means filtering out the first message that is greater than the first preset length from the second target message; the first preset length can be the length within a preset interval, and meeting the first preset length means filtering out the first message within the interval corresponding to the first preset length from the second target message. It should be noted that the first message is a message that needs to be routed. All other fourth messages that do not meet the conditions are discarded.
[0097] In this way, through two layers of screening, messages that do not conform to the user's set format are discarded, preventing messages that do not conform to the settings from undergoing data conversion, which would cause the in-vehicle equipment to receive incorrect signals and perform incorrect actions.
[0098] Based on this, in some embodiments, such as Figure 4 As shown, before the above S240, the method may further include:
[0099] S231, detecting whether the socket adapter is in an open state;
[0100] The above S240 may specifically include:
[0101] S241. If the socket adapter is in an open state, add a preset message header to the header of the second message to obtain a third message; if the socket adapter is in a closed state, delete the second message.
[0102] In some embodiments, before the second message passes through the socket adapter, it is detected whether the socket adapter is in an open state, and the socket connection state is judged. If the socket adapter is in an open state (Online state), the preset message header is added to the header of the second message to obtain a third message. If the socket adapter is in a closed state (Offline state), the second message is deleted.
[0103] In this way, if the socket adapter is in an inoperative state, the second message can only be discarded.
[0104] Based on this, in some embodiments, the first message includes a CAN message, and the third message includes an Ethernet message; after the above S240, the method may further include:
[0105] A third message is sent to the Ethernet device.
[0106] In some embodiments, the first message includes a CAN message, the third message includes an Ethernet message, and the Ethernet (Ethernet, Eth) interface module EthIf is called to send the third message to the Ethernet device through the Ethernet driver module using the Ethernet interrupt service function.
[0107] In this way, the third message after data conversion can be sent to the Ethernet device, so that the Ethernet device can identify the third message and take corresponding actions.
[0108] Figure 5 A flow chart of a data conversion method provided by an embodiment of the present application is shown.
[0109] like Figure 5 As shown, the data conversion method provided in the embodiment of the present application includes the following steps S310 to S340.
[0110] S310: Obtain a fifth message.
[0111] Here, the fifth message may be a message received on an Ethernet device, may be an Ethernet message, or may be a message with a longer length, and the length of the fifth message is not less than a preset threshold. The fifth message passes through the Ethernet switch and the Ethernet controller and reaches the receiving indication function of the Ethernet interface module.
[0112] S320: Identify the message header of the fifth message, and select a sixth message whose message header satisfies a preset message header from the fifth message.
[0113] Here, the default message header is set in advance.
[0114] In some embodiments, the Ethernet interface module identifies the message header of the fifth message, and enters the TcpIp module through the receiving function of the TcpIp module. The TcpIp module parses the message header of the fifth message, and selects the sixth message whose message header meets the preset message header from the fifth message. Messages that do not meet the preset message header are discarded.
[0115] S330. According to a preset order, intercept the messages after the message header of the sixth message in sequence to obtain at least one second signal segment.
[0116] In some embodiments, the TcpIp module transmits the sixth message to the real-time operating environment module through the socket adapter and the sending function of the big data communication module. The real-time operating environment module sequentially intercepts the messages after the message header of the sixth message in a preset order to obtain at least one second signal segment. The preset order may be from front to back.
[0117] S340. Encapsulate at least one second signal segment respectively to obtain a seventh message.
[0118] Here, the seventh message may be a bus message or a message of shorter length, and the length of the seventh message is less than a preset threshold.
[0119] In some embodiments, at least one second signal segment is respectively packaged and at least one second signal segment is respectively encapsulated by a communication module to obtain a seventh message.
[0120] In this way, by splitting and repackaging the messages, a data conversion method between different message types is provided. Even if the frame structure of the CAN bus data transmission is different from the frame structure of the Ethernet (based on the SOMEIP protocol) data transmission, communication between Ethernet and CAN bus can be achieved through data conversion.
[0121] Based on this, in some embodiments, the above S310 may specifically include:
[0122] When the eighth message is received, a third target message having a message identifier consistent with the second preset identifier is selected from the eighth message;
[0123] A fifth message having media access control information consistent with preset media access control information is screened out from the third target message.
[0124] Here, the eighth message may be a message received by an Ethernet device, and may be an Ethernet message. It may also be a message with a longer length, and the length of the eighth message is not less than a preset threshold. The second preset identifier may be an ID. For example, for an Ethernet message, the second preset identifier is a virtual local area network ID (VLAN ID).
[0125] In some embodiments, the preset media access control information (MAC) includes first preset media access control information and second preset media access control information. The fifth message passes through an Ethernet switch, the Ethernet switch includes a second preset identifier and the first preset media access control information, and the Ethernet switch filters out a third target message whose message identifier is consistent with the second preset identifier and whose media access control information is consistent with the first preset media access control information from the eighth message. The third target message passes through an Ethernet controller, the Ethernet controller includes the second preset media access control information, and the Ethernet controller filters out a fifth message whose media access control information is consistent with the second preset media access control information from the third target message.
[0126] In this way, messages that do not conform to the user's set format are discarded, preventing messages that do not conform to the settings from being converted into data, which in turn causes the in-vehicle device to receive an erroneous signal and perform an erroneous action.
[0127] Based on this, in some embodiments, such as Figure 6 As shown, before the above S330, the method may further include:
[0128] S321, detecting whether the socket adapter is in an open state;
[0129] The above S330 may specifically include:
[0130] S331. If the socket adapter is in an open state, intercept the messages after the message header of the sixth message in sequence according to a preset order to obtain at least one second signal segment; if the socket adapter is in a closed state, delete the sixth message.
[0131] In some embodiments, before the sixth message passes through the socket adapter, it is detected whether the socket adapter is in an open state, and the socket connection state is judged. If the socket adapter is in an open state, the messages after the message header of the sixth message are intercepted in sequence according to a preset order to obtain at least one second signal segment. If the socket adapter is in a closed state (Offline state), the sixth message is deleted.
[0132] In this way, if the socket adapter is in an inoperative state, the sixth message can only be discarded.
[0133] Based on this, in some embodiments, the fifth message includes an Ethernet message, and the seventh message includes a CAN message; after the above S340, the method may further include:
[0134] Adding the third preset identifier to the seventh message respectively to obtain a ninth message;
[0135] A ninth message is sent to the controller corresponding to the third preset identifier.
[0136] In some embodiments, the transmitted CAN message needs to be configured as a trigger mode in the communication module. Because the trigger mode is adopted, the CAN message will be triggered and sent only when the Ethernet message is received, so as to realize the routing function.
[0137] In some embodiments, the sending function of the Can interface abstraction layer is called. In the AutoSAR system, the seventh message of the Can interface abstraction layer needs to be connected with the seventh message transmitted by the communication module through the PDU router, mainly through the one-to-one correspondence between the communication module pre-set in the PDU router and the PduId in the Can interface abstraction layer, and the third preset identifier is indexed by PduId to form a complete frame of messages to obtain the ninth message. The ninth message is sent to the controller corresponding to the third preset identifier. The third preset identifier can be an ID. For example, for a bus message, it can be a CANID.
[0138] In some embodiments, the Can driver module has no filtering mechanism, and can send the ninth message on the bus as long as the bus is idle, thus forming a complete routing mechanism.
[0139] In this way, the ninth message after data conversion can be sent to the bus controller, so that the bus controller can identify the ninth message and take corresponding actions.
[0140] In the embodiments provided in the present application, for CAN messages and Ethernet messages, the identification of CANID and the serialization of Ethernet messages rely on the AutoSAR system. It is necessary to first correspond the CANID to the service. If the controller receives a non-routing CANID, it will perform filtering processing; only messages with the corresponding CANID will be routed. When the CAN message is converted to an Ethernet message, the controller on the bus acts as a client, and the Ethernet message field sent is a Setter, which can be sent by the client to the server (Ethernet device) to change the value of the server. When the Ethernet message is converted to a CAN message, because the controller on the bus acts as a client, the Ethernet message received from the server needs to be of Event type. When the subscription is successful, the server can actively send a publish message to the client.
[0141] The data conversion method provided in the embodiment of the present application can realize data interaction between CAN messages and Ethernet messages, can provide higher flexibility, and avoid frame loss during conversion.
[0142] Based on the data conversion method provided in the above embodiment, the present application also provides a specific implementation of a data conversion device. Please refer to the following embodiment.
[0143] See also Figure 7, the data conversion device 400 provided in the embodiment of the present application includes:
[0144] An acquisition module 410, configured to acquire a first message;
[0145] A splitting module 420, configured to split the first message according to a first preset length to obtain a first signal segment of at least one data type;
[0146] An encapsulation module 430, configured to encapsulate a first signal segment of at least one data type according to a second preset length to obtain a second message;
[0147] The adding module 440 is used to add a preset message header to the header of the second message to obtain a third message.
[0148] Based on this, in some embodiments, the acquisition module 410 may be specifically used to:
[0149] When the fourth message is received, the first message satisfying the first preset identifier and the third preset length is screened out from the fourth message.
[0150] Based on this, in some embodiments, the first preset identifier includes a first target preset identifier and a second target preset identifier, and the acquisition module 410 may include:
[0151] A screening unit, configured to screen out a first target message whose message identifier is consistent with a first target preset identifier from the fourth message when the fourth message is received;
[0152] The screening unit is further used to screen out a second target message whose message identifier is consistent with the second target preset identifier from the first target message;
[0153] The screening unit is further used to screen out the first message that meets the first preset length from the second target message.
[0154] Based on this, in some embodiments, the apparatus 400 may further include:
[0155] A detection module, used for detecting whether the socket adapter is in an open state before adding the preset message header to the header of the second message to obtain the third message;
[0156] The adding module 440 can be specifically used for:
[0157] If the socket adapter is in an open state, adding a preset message header to the header of the second message to obtain a third message;
[0158] If the socket adapter is in a closed state, the second message is deleted.
[0159] Based on this, in some embodiments, the first message includes a CAN message, and the third message includes an Ethernet message; the apparatus 400 may further include:
[0160] The sending module is used for adding a preset message header to the header of the second message to obtain the third message, and then sending the third message to the Ethernet device.
[0161] See also Figure 8 , the data conversion device 500 provided in the embodiment of the present application includes:
[0162] An acquisition module 510, configured to acquire a fifth message;
[0163] An identification module 520, configured to identify a message header of the fifth message, and select a sixth message whose message header satisfies a preset message header from the fifth message;
[0164] The interception module 530 is used to sequentially intercept the messages after the message header of the sixth message in a preset order to obtain at least one second signal segment;
[0165] The encapsulation module 540 is used to encapsulate at least one second signal segment respectively to obtain a seventh message.
[0166] Based on this, in some embodiments, the acquisition module 510 may be specifically used to:
[0167] When the eighth message is received, a third target message having a message identifier consistent with the second preset identifier is selected from the eighth message;
[0168] A fifth message having media access control information consistent with preset media access control information is screened out from the third target message.
[0169] Based on this, in some embodiments, the apparatus 500 may further include:
[0170] A detection module, configured to detect whether the socket adapter is in an open state before sequentially intercepting the messages after the message header of the sixth message in a preset order and obtaining at least one second signal segment;
[0171] The interception module 530 can be specifically used for:
[0172] If the socket adapter is in an open state, the messages after the message header of the sixth message are intercepted in sequence according to a preset order to obtain at least one second signal segment;
[0173] If the socket adapter is in a closed state, the sixth message is deleted.
[0174] Based on this, in some embodiments, the fifth message includes an Ethernet message, and the seventh message includes a CAN message; the apparatus 500 may further include:
[0175] An adding module, configured to, after encapsulating at least one second signal segment respectively to obtain a seventh message, add a third preset identifier to each of the seventh messages to obtain a ninth message;
[0176] The sending module is used to send a ninth message to the controller corresponding to the third preset identifier.
[0177] The various modules of the data conversion device provided in the embodiment of the present application can realize the functions of the various steps of the data conversion method provided above and achieve the corresponding technical effects, which will not be repeated here for the sake of concise description.
[0178] Based on the same inventive concept, an embodiment of the present application also provides an electronic device.
[0179] Fig. 9 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.
[0180] The electronic device may include a processor 901 and a memory 902 storing computer program instructions.
[0181] Specifically, the processor 901 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0182] The memory 902 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 902 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 902 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 902 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 902 is a non-volatile solid-state memory.
[0183] The memory may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of the present disclosure.
[0184] The processor 901 implements any one of the data conversion methods in the above embodiments by reading and executing computer program instructions stored in the memory 902 .
[0185] In one example, the electronic device may further include a communication interface 903 and a bus 910. Fig. 9 As shown, the processor 901, the memory 902, and the communication interface 903 are connected via a bus 910 and communicate with each other.
[0186] The communication interface 903 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0187] The bus 910 includes hardware, software or both, coupling the components of the electronic device to each other. For example, but not limitation, the bus may include an accelerated graphics port (Accelerated Graphics Port, AGP) or other graphics bus, an enhanced industry standard architecture (Extended Industry Standard Architecture, EISA) bus, a front side bus (Front Side Bus, FSB), a hypertransport (Hyper Transport, HT) interconnection, an industry standard architecture (Industry Standard Architecture, ISA) bus, an infinite bandwidth interconnection, a low pin count (Linear Predictive Coding, LPC) bus, a memory bus, a micro channel architecture (MicroChannel Architecture, MCA) bus, a peripheral component interconnect (Peripheral Component Interconnect, PCI) bus, a PCI-Express (Peripheral Component Interconnect-X, PCI-X) bus, a serial advanced technology attachment (Serial Advanced Technology Attachment, SATA) bus, a video electronics standard association local (VESA Local Bus, VLB) bus or other suitable bus or a combination of two or more of these. Where appropriate, the bus 910 may include one or more buses. Although the embodiments of the present application describe and illustrate a specific bus, the present application considers any suitable bus or interconnection. The electronic device can execute the data conversion method in the embodiments of the present invention, thereby realizing the above data conversion method.
[0188] In addition, in combination with the data conversion method in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the data conversion methods in the above embodiment is implemented.
[0189] The present application also provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes each process of implementing any one of the above-mentioned data conversion method embodiments.
[0190] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0191] The functional blocks shown in the structural block diagram described above can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), appropriate firmware, plug-in, function card, etc. When implemented in software, the elements of the present application are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or communication link by a data signal carried in a carrier. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, read-only memory (Read-Only Memory, ROM), flash memory, erasable read-only memory (Erasable ReadOnly Memory, EROM), floppy disks, compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM), optical discs, hard disks, optical fiber media, radio frequency (Radio Frequency, RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0192] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0193] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0194] The above are only specific implementation methods of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A data conversion method, characterized in that: include: Obtaining a first message; Splitting the first message according to a first preset length to obtain first signal segments of at least one data type; Encapsulate the first signal segment of the at least one data type according to a second preset length to obtain a second message; Add a preset message header to the header of the second message to obtain a third message.
2. The data conversion method according to claim 1, characterized in that: The obtaining of the first message includes: When the fourth message is received, the first message satisfying the first preset identifier and the third preset length is screened out from the fourth message.
3. The data conversion method according to claim 2, characterized in that: The first preset identifier includes a first target preset identifier and a second target preset identifier, and when the fourth message is received, filtering out a first message that satisfies the first preset identifier and the third preset length from the fourth message includes: When the fourth message is received, a first target message whose message identifier is consistent with the first target preset identifier is selected from the fourth message; Filtering out a second target message whose message identifier is consistent with a second target preset identifier from the first target message; A first message satisfying a first preset length is screened out from the second target message.
4. The data conversion method according to claim 1, characterized in that: Before adding the preset message header to the header of the second message to obtain the third message, the method further includes: Check if the socket adapter is open; The step of adding the preset message header to the header of the second message to obtain the third message includes: If the socket adapter is in an open state, adding a preset message header to the header of the second message to obtain a third message; If the socket adapter is in a closed state, the second message is deleted.
5. The data conversion method according to claim 1, characterized in that: The first message includes a CAN message, and the third message includes an Ethernet message; after adding a preset message header to a header of the second message to obtain the third message, the method further includes: Send the third message to the Ethernet device.
6. A data conversion method, characterized in that: include: Get the fifth message; Identify the message header of the fifth message, and select a sixth message whose message header satisfies a preset message header from the fifth message; According to a preset order, the messages after the message header of the sixth message are intercepted in sequence to obtain at least one second signal segment; The at least one second signal fragment is encapsulated respectively to obtain a seventh message.
7. The data conversion method according to claim 6, characterized in that: The obtaining of the fifth message includes: When the eighth message is received, a third target message having a message identifier consistent with the second preset identifier is selected from the eighth message; A fifth message whose media access control information is consistent with the preset media access control information is screened out from the third target message.
8. The data conversion method according to claim 6, characterized in that: Before sequentially intercepting the messages after the message header of the sixth message in a preset order to obtain at least one second signal segment, the method further includes: Check if the socket adapter is open; The method of sequentially intercepting the messages after the message header of the sixth message in a preset order to obtain at least one second signal segment includes: If the socket adapter is in an open state, the messages after the message header of the sixth message are intercepted in sequence according to a preset order to obtain at least one second signal segment; If the socket adapter is in a closed state, the sixth message is deleted.
9. The data conversion method according to claim 6, characterized in that: The fifth message includes an Ethernet message, and the seventh message includes a CAN message; after encapsulating the at least one second signal segment respectively to obtain the seventh message, the method further includes: Adding the third preset identifier to the seventh message respectively to obtain a ninth message; The ninth message is sent to the controller corresponding to the third preset identifier.
10. A data conversion device, characterized in that: include: An acquisition module, used for acquiring a first message; A splitting module, used to split the first message according to a first preset length to obtain a first signal segment of at least one data type; An encapsulation module, used to encapsulate the first signal segment of the at least one data type according to a second preset length to obtain a second message; An adding module is used to add a preset message header to the header of the second message to obtain a third message.
