Data transmission method and device, equipment and storage medium

By setting preset mapping relationships in the HAL layer and processing data packets of CAN matrix changes, the problem of complex logic modifications in the application layer in the motor vehicle industry is solved, and the maintenanceability and development cost of the application layer code are achieved.

CN119697210APending Publication Date: 2025-03-25SAIC GM WULING AUTOMOBILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411586192.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-07
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

In the motor vehicle industry, different models of vehicles have different CAN matrix and functions, resulting in the application layer requiring complex and repetitive logical modifications to adapt to changes in the CAN matrix, resulting in large workload, low efficiency, unstable functions and difficult to maintain.

Method used

By setting a preset mapping relationship in the HAL layer, the MCU receives the packet and passes it to the HAL layer. The HAL layer converts the packet, determines the target function, and sends it to the application layer. This method does not require application layer changes, reducing development investment and resource waste.

Benefits of technology

The problems of differences in CAN matrix and functional differences in different models of vehicles are solved, which avoids design redundancy in the application layer, reduces development investment, and improves functional stability and maintenance efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119697210A_ABST
    Figure CN119697210A_ABST
Patent Text Reader

Abstract

The invention discloses a data transmission method and device, equipment and a storage medium, which are used for improving the data transmission efficiency. The method comprises the following steps: receiving a data packet by an MCU; if the MCU determines that the message identifier corresponding to the data packet is a specified type, the data packet is transmitted to an HAL layer in a transparent manner; the HAL layer performs conversion processing on the data type of the data in the data packet to obtain a target data packet; the HAL layer determines a target function corresponding to the target data packet based on the target data packet and a preset mapping relation; and the HAL layer sends the target function to an application layer. In the application, the preset mapping relationship is set in the HAL layer, and the function corresponding to each data packet can be obtained based on the preset mapping relationship. The problems that different models of vehicle models are different and different function differences are configured for the same model of vehicle models are solved, and a vehicle machine platform and an application program do not need to be changed. The application program does not need to be repeatedly developed, resource investment is reduced, cost is reduced, design redundancy of an application program layer is avoided, and development investment is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a data transmission method, device, equipment and storage medium. Background Art

[0002] With the rapid development of the motor vehicle industry, vehicles are experiencing explosive growth. In vehicles currently produced by the same brand, different Controller Area Network (CAN) matrices correspond to different application functions. And the functions in different models of vehicles are different. Therefore, if the CAN matrix is ​​adapted at the application layer, the CAN matrix changes, and each application involving related functions needs to be logically modified accordingly, and the modification logic of each application must be kept consistent, so as to ensure that different applications present the same function in a consistent manner.

[0003] However, this method has complex and repetitive workload, low efficiency, difficulty in maintaining functional stability, and difficulty in subsequent functional maintenance, which wastes manpower and material resources. Summary of the invention

[0004] In view of this, the present application provides a data transmission method, apparatus, device and storage medium to improve the efficiency of data transmission.

[0005] In a first aspect, an embodiment of the present application provides a data transmission method, the method comprising:

[0006] MCU receives data packets;

[0007] If the MCU determines that the message identifier corresponding to the data packet is of a specified type, the data packet is transparently transmitted to the HAL layer;

[0008] The HAL layer converts the data type of the data in the data packet to obtain a target data packet;

[0009] The HAL layer determines the target function corresponding to the target data packet based on the target data packet and the preset mapping relationship;

[0010] The HAL layer sends the target function to the application layer.

[0011] In this application, a preset mapping relationship is set in the HAL layer, and the function corresponding to each data packet can be obtained based on the preset mapping relationship. The problem of vehicle model differences and different functional differences of the same model with different vehicle configurations is solved, and the vehicle platform and application program do not need to be changed. The application program does not need to be repeatedly developed, which reduces resource investment, reduces costs, avoids design redundancy at the application program layer, and reduces development investment.

[0012] In some possible embodiments, before the HAL layer converts the data type of the data in the data packet, the method further includes:

[0013] The HAL layer performs conversion processing on the message identifier of the data packet to obtain a processed data packet;

[0014] The HAL layer converts the data type of the data in the data packet to obtain a target data packet, including:

[0015] The HAL layer converts the data type in the processed data packet to obtain a target data packet.

[0016] In some possible embodiments, the HAL layer performs conversion processing on the message identifier of the data packet, including:

[0017] The message identifier of the data packet is replaced with a preset message identifier.

[0018] In some possible embodiments, the HAL layer converts the data type of the data in the data packet, including:

[0019] The data in the data packet is converted into data of a preset type.

[0020] In some possible embodiments, the preset type includes: integer int.

[0021] In some possible embodiments, the method further includes:

[0022] In response to an adding operation triggered based on the preset mapping relationship, determining a function to be added and a character string to be added;

[0023] The function to be added and the character string to be added are added to the preset mapping relationship table.

[0024] In a second aspect, an embodiment of the present application provides a data transmission device, the device comprising:

[0025] MCU, used to receive data packets;

[0026] The MCU is further configured to, if it is determined that the message identifier corresponding to the data packet is of a specified type, transparently transmit the data packet to the HAL layer;

[0027] The HAL layer is used to convert the data type of the data in the data packet to obtain a target data packet;

[0028] The HAL layer is further used to determine the target function corresponding to the target data packet based on the target data packet and the preset mapping relationship;

[0029] The HAL layer is further used to send the target function to the application layer.

[0030] In some possible embodiments, the HAL layer is further used for:

[0031] The HAL layer performs conversion processing on the message identifier of the data packet to obtain a processed data packet;

[0032] The HAL layer is specifically used for:

[0033] The HAL layer converts the data type in the processed data packet to obtain a target data packet.

[0034] In some possible embodiments, the HAL layer is specifically used to: replace the message identifier of the data packet with a preset message identifier.

[0035] In some possible embodiments, the HAL layer is specifically used to: convert the data in the data packet into data of a preset type.

[0036] In some possible embodiments, the preset type includes: integer int.

[0037] In some possible embodiments, the HAL layer is further used to: determine the function to be added and the string to be added in response to an adding operation triggered based on the preset mapping relationship; and add the function to be added and the string to be added to the preset mapping relationship table.

[0038] In the third aspect, another embodiment of the present application also provides an electronic device, comprising at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any method provided in the embodiment of the first aspect of the present application.

[0039] In a fourth aspect, another embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is used to enable a computer to execute any method provided in the embodiment of the first aspect of the present application.

[0040] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0042] Figure 1 An Android architecture diagram of a data transmission method provided in an embodiment of the present application;

[0043] Figure 2 A schematic diagram of communication via a CAN matrix in the related technology provided in an embodiment of the present application;

[0044] Figure 3 A schematic diagram of a data transmission method provided in an embodiment of the present application for unified adaptation at the HAL layer;

[0045] Figure 4 A schematic diagram of the overall process of a data transmission method provided in an embodiment of the present application;

[0046] Figure 5 A schematic diagram of a preset mapping relationship of a data transmission method provided in an embodiment of the present application;

[0047] Figure 6 Another schematic diagram of a data transmission method provided in an embodiment of the present application;

[0048] Figure 7 A schematic diagram of a preset mapping relationship after adding a data transmission method provided in an embodiment of the present application;

[0049] Figure 8 A schematic diagram of a preset mapping relationship after deletion of a data transmission method provided in an embodiment of the present application;

[0050] Fig. 9 A schematic diagram of the definition of a CAN communication matrix of a data transmission method provided in an embodiment of the present application;

[0051] Fig.10 A schematic diagram of the relationship between bits and bytes of a data transmission method provided in an embodiment of the present application;

[0052] Fig.11 A schematic diagram of the sequence of bits and bytes of a data transmission method provided in an embodiment of the present application;

[0053] Fig.12 A schematic diagram of data information in a data packet of a data transmission method provided in an embodiment of the present application;

[0054] Fig.13A schematic diagram of matrix information of a data transmission method provided in an embodiment of the present application;

[0055] Fig.14 A schematic diagram of data frame information of a data transmission method provided in an embodiment of the present application;

[0056] Fig.15 A schematic diagram of a device for a data transmission method provided in an embodiment of the present application;

[0057] Fig.16 A schematic diagram of an electronic device for a data transmission method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0058] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0059] It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0060] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0061] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0062] For ease of understanding, the following first describes the application and CAN matrix communication process in the relevant technology:

[0063] like Figure 1 As shown, it is an Android architecture diagram in an embodiment of the present application, and the architecture includes: a kernel layer (LINUX KERNEL), a hardware abstraction layer (HAL), an Android runtime library (Android Runtime), a native C / C++ shared library (LIBRARIES), a Java application programming interface framework layer (Java Application Programming InterfaceFRAMEWORK), and an application (APPLICATION).

[0064] The communication between the above layers is usually carried out layer by layer. Android applications need to call the API interface of the JavaAPI framework layer to communicate with other layers.

[0065] In CAN communication, the communication matrix is ​​a concept that represents the communication relationship between different CAN nodes. The communication matrix describes the situation in which data communication can be carried out between various CAN nodes. The CAN communication matrix can be a diagram or matrix form used to display the communication connection between nodes in the CAN network.

[0066] The above HAL layer includes RPC (remote procedure call), which allows a program to call a procedure or function in another address space (usually another machine on a shared network) without the programmer having to write additional network communication and data packaging / unpacking code for this remote call.

[0067] CAN matrix: A data structure that defines how the various Electronic Control Units (ECUs) in a vehicle network communicate with each other and specifies the rules for exchanging information between different controllers.

[0068] 1) Set up an RPC service on the Micro Control Unit (MCU), which is responsible for processing remote call requests from Android applications. The RPC service can accurately identify the signal and data format in the CAN matrix, and then correctly convert the Android application's request into a CAN message.

[0069] 2) Since the CAN bus protocol is different from the network communication protocol used by RPC (such as TCP / IP (Transmission Control Protocol / Internet Protocol), conversion interfaces are required to communicate between the CAN network and the RPC service. These conversion interfaces are responsible for converting CAN messages into data packets that can be transmitted on the network, and converting data packets from the network into CAN messages.

[0070] 3) In the Android application, use the RPC client library to call the RPC service set up above. The application needs to send the demand to the CAN matrix, which can then encapsulate the data into an RPC request and send the RPC request to the RPC service through the network. At the same time, the application can also receive the response from the RPC service and parse the data in it.

[0071] 4) When the RPC service receives a request from an Android application, it first parses the data in the request and converts it into a CAN message. The RPC service then sends the CAN message to the conversion interface, which then sends it to the CAN network.

[0072] 5) If an ECU in the CAN network responds to the received CAN message, the conversion interface converts the response CAN message back to a network data packet and sends it to the RPC service. The RPC service parses the response data packet into an RPC response and sends it back to the Android application.

[0073] In the related art, each vehicle model corresponds to a CAN matrix, and each CAN matrix corresponds to an RPC protocol. Figure 2 As shown, there is a CAN matrix A in vehicle model A, corresponding to RPC protocol A; there is a CAN matrix B in vehicle model B, corresponding to RPC protocol B; there is a CAN matrix C in vehicle model C, corresponding to RPC protocol C. When multiple APPs want to implement this function, each application needs to adapt the CAN matrix, each application needs to implement the same code logic A, and then transparently transmit the data to the MCU through the Framework layer and HAL layer, and communicate with the CAN matrix through the RPC protocol.

[0074] In the related technology, the Framework layer and the HAL layer only transparently transmit the data without processing the data. When the vehicle model changes, the corresponding CAN matrix will also change, so the corresponding RPC protocol will also change. At this time, if the application layer wants to implement the function, each application needs to modify the previous code logic A, and it is also necessary to ensure that the logic of each application modification is unified, which will cause code redundancy and difficult maintenance.

[0075] The inventors found that with the rapid development of the motor vehicle industry, vehicles are experiencing explosive growth. In vehicles currently produced by the same brand, different CAN matrices correspond to different application functions. And the functions in different models of vehicles are different. Therefore, if the CAN matrix is ​​adapted at the application layer, the CAN matrix changes, and each application involving related functions needs to be logically modified accordingly, and the modification logic of each application must be kept consistent, so as to ensure that different applications have the same presentation effect on the same function.

[0076] However, this method is complex and repetitive, inefficient, difficult to maintain functional stability, and difficult to perform subsequent functional maintenance, wasting manpower and material resources.

[0077] In view of the above problems, the embodiments of the present application provide a data transmission method, device, equipment and storage medium for solving the above problems. The inventive concept of the present application can be summarized as follows: the MCU receives a data packet; if the MCU determines that the message identifier corresponding to the data packet is of a specified type, the data packet is transparently transmitted to the HAL layer; the HAL layer converts the data type of the data in the data packet to obtain a target data packet; the HAL layer determines the target function corresponding to the target data packet based on the target data packet and a preset mapping relationship; the HAL layer sends the target function to the application layer.

[0078] In this application, by setting a preset mapping relationship at the HAL layer, the function corresponding to each data packet can be obtained based on the preset mapping relationship. The problem of vehicle model differences and different functional differences of the same model with different vehicle configurations is solved, and the vehicle platform and application program do not need to be changed. The application program does not need to be repeatedly developed by each supplier, which reduces resource investment, reduces costs, avoids design redundancy at the application layer, and reduces development investment.

[0079] For ease of understanding, a data transmission method provided in an embodiment of the present application is described in detail below with reference to the accompanying drawings:

[0080] like Figure 3 As shown, in this application, the original adaptation of the CAN signal by each application has been changed to a unified adaptation at the HAL layer. After the adaptation is completed, a unified interface is provided for the application layer to call. Therefore, no matter how the CAN matrix corresponding to different car models changes, as long as the data conversion is performed when the data is transmitted to HAL, the converted data is transparently transmitted through the Framework layer, and the application that needs to implement this function can directly call the unified interface to implement it, and each application does not need to adapt one by one. When the CAN matrix changes, only the data conversion process of the HAL layer needs to be changed, which ensures the maintainability of the application layer code, and it is more effective to maintain the HAL layer code alone.

[0081] like Figure 4 FIG. 1 is a schematic diagram of an overall flow chart of a data transmission method provided in an embodiment of the present application, wherein:

[0082] In step 401: the MCU receives a data packet.

[0083] In the present application, a data packet is generated based on a function triggered by a user. For example, if a user steps on the brakes, a data packet may be generated based on the time and amplitude of the brake step.

[0084] In step 402: if the MCU determines that the message identifier corresponding to the data packet is of a specified type, the data packet is transparently transmitted to the HAL layer.

[0085] In this application, in order to facilitate the determination of which data packets need to be processed by the HAL and then sent to the application layer, the MCU needs to filter the message identifiers of the received data packets and transparently transmit the data packets of the specified type to the HAL layer.

[0086] For example: the message identifier of the specified type is 0x1B9, and the data packets received by the MCU include: data packet 1, data packet 2, and data packet 3; it is determined that the message identifier corresponding to data packet 1 is 0x1B9, the message identifier corresponding to data packet 2 is 0x2B9, and the message identifier corresponding to data packet 3 is 0x1B9; it can be determined that the MCU needs to transparently transmit data packet 1 and data packet 3 to the HAL layer.

[0087] In step 403: the HAL layer converts the data type of the data in the data packet to obtain a target data packet.

[0088] In the present application, a preset mapping relationship is set at the HAL layer, and the target function is determined based on the corresponding relationship between the data and the function in the preset mapping relationship. In order to reduce the memory occupied by the preset mapping relationship and to ensure the matching efficiency, it is necessary to convert the data type of the data in the data packet.

[0089] In some possible embodiments, the HAL layer converts the data type of the data in the data packet, which can be specifically implemented as: converting the data in the data packet into data of a preset type, wherein the preset type includes but is not limited to: integer int, floating point type.

[0090] For example: the data in data packet 1 is xxxx, the data in data packet 2 is cccc, and the data in data packet 3 is vvvv. After the data in data packet 1 is converted to int type, the value is 1. After the data in data packet 2 is converted to int type, the value is 2. After the data in data packet 3 is converted to int type, the value is 3.

[0091] In step 404: the HAL layer determines the target function corresponding to the target data packet based on the target data packet and the preset mapping relationship.

[0092] In the present application, a preset mapping relationship is constructed in advance based on the corresponding relationship between data and function, and the target function can be obtained by matching the target data packet in the preset mapping relationship.

[0093] For example: data packet 1 is converted to target data packet 1, and the data included in target data packet 1 is 1; data packet 2 is converted to target data packet 2, and the data included in target data packet 2 is 2; data packet 3 is converted to target data packet 3, and the data included in target data packet 3 is 3; the preset mapping relationship is as follows Figure 5 As shown, based on Figure 5It can be determined that the function corresponding to data pack 1 is the economic driving mode, the function corresponding to data pack 2 is the standard driving mode, and the function corresponding to data pack 3 is the sports driving mode.

[0094] In step 405: the HAL layer sends the target function to the application layer.

[0095] In this application, the HAL layer directly sends the determined target function to the application layer, and the application layer does not need to process the data, so there is no need for adaptation at the application layer.

[0096] In some possible embodiments, in order to facilitate the technical personnel to manage the data packets, the present application also provides a data transmission method, such as Figure 6 As shown, where:

[0097] In step 601: the MCU receives a data packet.

[0098] The specific implementation of this step is the same as step 401 and will not be described again here.

[0099] In step 602: if the MCU determines that the message identifier corresponding to the data packet is of a specified type, the data packet is transparently transmitted to the HAL layer.

[0100] The specific implementation of this step is the same as step 402 and will not be described again here.

[0101] In step 603: the HAL layer performs conversion processing on the message identifier of the data packet to obtain a processed data packet.

[0102] In the present application, in order to facilitate technicians to manage data packets at the HAL layer, after receiving the data packet, the message identifier of the data packet can be converted into a preset message identifier.

[0103] For example: the message identifier corresponding to data packet 1 is 0x1B9, and the message identifier corresponding to data packet 3 is determined to be 0x1B9; the preset message identifier is 0y2A8, then the message identifier 0x1B9 corresponding to data packet 1 is replaced with 0y2A8, and the message identifier 0x1B9 corresponding to data packet 2 is replaced with 0y2A8.

[0104] In step 604: the HAL layer converts the data type in the processed data packet to obtain a target data packet.

[0105] The specific implementation of this step is the same as step 403 and will not be described again here.

[0106] In step 605: the HAL layer determines the target function corresponding to the target data packet based on the target data packet and the preset mapping relationship.

[0107] The specific implementation of this step is the same as step 404 and will not be described again here.

[0108] In step 606: the HAL layer sends the target function to the application layer.

[0109] The specific implementation of this step is the same as step 405 and will not be described again here.

[0110] In some possible embodiments, when applications are added or reduced in a vehicle, only the preset mapping relationship needs to be adjusted without modifying the application program. Specifically, it can be implemented as follows: in response to an add operation triggered based on a preset mapping relationship, determine the function to be added and the string to be added; add the function to be added and the string to be added to a preset mapping relationship table; or, in response to a delete operation triggered based on a preset mapping relationship, determine the function to be deleted and the string to be deleted; delete the function to be deleted and the string to be deleted from the preset mapping relationship table.

[0111] For example: The preset mapping relationship is as follows Figure 5 As shown in FIG. 1 , based on the adding operation, it is determined that the function to be added is adaptive cruise control, and the string to be added is 5, then “adaptive cruise control” and “5” are added to the preset mapping relationship, and the following is obtained: Figure 7 Based on the deletion operation, it is determined that the function to be deleted is the economic driving mode, the string to be deleted is determined to be 1, and the function to be deleted and the string to be deleted are changed from Figure 5 , and the following is obtained: Figure 8 The preset mapping relationship table shown.

[0112] In order to further understand a data transmission method provided in an embodiment of the present application, an example is given below to illustrate:

[0113] With the preset mapping relationship as Figure 5 Taking the example shown above, the ECU responsible for controlling the driving mode will report the current driving mode to the vehicle-side software. The vehicle-side software will display the acquired driving mode, making it easier for users to perceive the current driving mode.

[0114] In the preset mapping relationship, 1 is defined as the economic driving mode, 2 is defined as the standard driving mode, 3 is defined as the sports driving mode, and 4 is defined as the economic + driving mode. Fig. 9 As shown in the CAN communication matrix, the message identifier of the data packet received by the HAL layer is defined as 0x1B9, the message length is 8, the start byte is 3, the start bit is 3, and the signal length is 4. It is important to know that Fig. 9 The information in the CAN communication matrix shown can be defined by technicians according to needs.

[0115] In a communication data frame, each signal occupies a certain number of bits. The relationship between bits and bytes is as follows: Fig.10 As shown in the figure, Byte0 is the first byte transmitted and received in each frame of data. If the length of the transmitted data is 8 bytes, bit7 is transmitted first, then bit6... and finally bit56. The data stream sequence during transmission is: 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 23,... 40, 55, 54, 53, 52, 51, 50, 49, 48, 63, 62, 61, 60, 59, 58, 57, 56.

[0116] The order of bits and bytes in the CAN matrix is ​​as follows Fig.11 As shown, when the HAL layer receives a frame of information, the first bit received should be placed at bit7, the second bit received should be placed at bit6, the third bit should be placed at bit5, and so on.

[0117] Assuming that the driving mode triggered by the user is the economic mode, the data information in the data packet is as follows: Fig.12 As shown: Because the starting byte in the CAN matrix information is 3, the starting bit is 3, and the signal length is 4, so starting from byte 2, count the third and fill 4 bits; because 1 is the economic mode, the binary representation is 0001, and fill in sequentially.

[0118] In the related technology, when the ECU reports the data information in this data packet, the MCU will transparently transmit the data packet to the HAL layer; then the HAL layer distinguishes the instructions corresponding to the data packet according to the message identifier 0x1B9, that is, it can be determined that the data packet is a control instruction about the driving mode, and then the message identifier 0x1B9 will be converted to its own preset identifier 0x44, and finally the data will be transparently transmitted to the framework layer, the framework layer will perform type conversion on the data, convert it to int type, and then the application layer can obtain the corresponding information by calling the custom interface in the framework layer. For example: the parameters of the application layer are as follows: public final static int A = 0x01; / / Economic driving mode; public final static int B = 0x01 << 1; / / Standard driving mode; public final static int C = 0x01 << 2; / / Sports driving mode; public final static int D = 0x01 << 3; / / Economic + driving mode. The information in the data packet received by the application layer is 1, and its own logic is: if (int=1) return A; If (int=2) return B; If (int=3) return C; If (int=4) return D. The application layer uses the return value determined by the data information in the received data packet to display the corresponding driving mode, taking the display of the specific driving mode button currently in use as an example. That is, if the return value is A, the application displays the economic driving mode button; if it is B, the application displays the standard driving mode button; if it is C, the application displays the sports driving mode button; if it is D, the application displays the economic + driving mode button.

[0119] That is, in the related technology, the logical processing of the application to determine the driving mode based on the return value needs to be implemented according to the specific needs of the application. Assuming that each application needs to implement this requirement, then all applications need to make the same set of logical judgments, which will lead to duplication of workload.

[0120] If the matrix information is from Fig. 9 The transformation shown is Fig.13 As shown, when the driving mode is the economic driving mode, the data frame information will become as follows Fig.14As shown. Because the starting byte in the CAN matrix information is 2, the starting bit is 4, and the signal length is 4, so starting from byte3, count the 4th and fill in 4 bits; because 3 is the economic driving mode, the binary representation is 0011, and fill in in sequence, so the data information will change from 0001 to 0011. At this time, if all applications need to implement the same function in the above example, that is, display a specific driving mode button currently in use. Then when the data is uploaded to the application layer, the logic of each application needs to be modified. That is, the above logic is modified to: if (int = 3) return A; If (int = 1) return B; If (int = 5) return C; If (int = 4) return D.

[0121] In this application, a preset mapping relationship is set in the HAL layer. Similarly, in the CAN communication matrix, 1 is defined as the economic driving mode, 2 is the standard driving mode, 3 is the sports driving mode, 4 is the economic + driving mode, the CAN message identifier is 0x1B9, the message length is 8, the start byte is 3, the start bit is 3, and the signal length is 4. When the ECU reports the data packet, the MCU will transparently transmit the data information in the data packet to the HAL layer; the HAL layer determines that the data packet is a control instruction corresponding to the driving mode according to the message identifier 0x1B9, and converts the message identifier 0x1B9 to the preset identifier 0x44, and converts the binary data into an int type. The preset mapping relationship is defined in the HAL layer as: if (int = 1) return A; If (int = 2) return B; If (int = 3) return C; If (int = 4) return D; where A represents the economic driving mode, B represents the standard driving mode, C represents the sports driving mode, and D represents the economic + driving mode.

[0122] At this time, the HAL layer does not transmit the data information in the data packet to the application layer, but transmits the converted A / B / C / D values ​​to the framework layer. The upper-layer application obtains the current value by calling the custom interface in the framework layer. Each application can directly correspond its functions with the values ​​obtained from the framework layer according to its needs.

[0123] Even if the CAN matrix information changes, only the corresponding logic changes need to be made at the HAL layer, that is, the preset mapping relationship is modified to: if (int = 3) return A; If (int = 1) return B; If (int = 5) return C; If (int = 4) return D.

[0124] At this time, the interfaces and defined data in the upper-level application do not need to be modified. That is, in this application, if the matrix information changes, only the preset mapping relationship needs to be modified, and the platform and APP do not need to be changed. The APP does not require repeated development by each supplier, which reduces resource investment, reduces development costs, and can quickly respond to changes in demand and market demands; reduces the strong dependence of the APP on the system platform and completes APP reuse; avoids redundancy in the APP layer design, improves product diversification efficiency, and reduces development investment.

[0125] Based on the same inventive concept, after introducing a data transmission method provided by an embodiment of the present application, as shown in FIG. Fig.15 As shown, a data transmission device 1500 provided in an embodiment of the present application is described below, and the device includes:

[0126] MCU15001, used to receive data packets;

[0127] The MCU 15001 is also used to transparently transmit the data packet to the HAL layer 15002 if it is determined that the message identifier corresponding to the data packet is of a specified type;

[0128] The HAL layer 15002 is used to convert the data type of the data in the data packet to obtain a target data packet;

[0129] The HAL layer 15002 is further used to determine the target function corresponding to the target data packet based on the target data packet and the preset mapping relationship;

[0130] The HAL layer 15002 is also used to send the target function to the application layer.

[0131] In some possible embodiments, the HAL layer 15002 is further used for:

[0132] The HAL layer 15002 performs conversion processing on the message identifier of the data packet to obtain a processed data packet;

[0133] The HAL layer 15002 is specifically used for:

[0134] The HAL layer 15002 converts the data type in the processed data packet to obtain a target data packet.

[0135] In some possible embodiments, the HAL layer 15002 is specifically used to: replace the message identifier of the data packet with a preset message identifier.

[0136] In some possible embodiments, the HAL layer 15002 is specifically used to convert the data in the data packet into data of a preset type.

[0137] In some possible embodiments, the preset type includes: integer int.

[0138] In some possible embodiments, the HAL layer 15002 is further used to: determine the function to be added and the string to be added in response to an adding operation triggered based on the preset mapping relationship; and add the function to be added and the string to be added to the preset mapping relationship table.

[0139] Corresponding to the above embodiments, the present application also provides an electronic device. Fig.16 A schematic diagram of the structure of an electronic device provided in an embodiment of the present invention, the electronic device 1600 may include: a processor 1601, a memory 1602 and a communication unit 1603. These components communicate through one or more buses, and those skilled in the art can understand that the structure of the electronic device shown in the figure does not constitute a limitation on the embodiment of the present invention, it can be a bus structure or a star structure, and can also include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0140] The communication unit 1603 is used to establish a communication channel so that the electronic device can communicate with other devices, receive user data sent by other devices or send user data to other devices.

[0141] The processor 1601 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It runs or executes software programs and / or modules stored in the memory 1602, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 1601 can only include a central processing unit (CPU). In an embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.

[0142] The memory 1602 is used to store the execution instructions of the processor 1601. The memory 1602 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0143] When the execution instructions in the memory 1602 are executed by the processor 1601, the electronic device 1600 can execute Figure 7 Some or all of the steps in the illustrated embodiments.

[0144] In a specific implementation, the present invention further provides a computer storage medium, wherein the computer storage medium may store a program, and when the program is executed, the program may include some or all of the steps in each embodiment of the calling method provided by the present invention. The storage medium may be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0145] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention or some parts of the embodiments.

[0146] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the device embodiment and the terminal embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.

Claims

1. A data transmission method, characterized in that: The method comprises: MCU receives data packets; If the MCU determines that the message identifier corresponding to the data packet is of a specified type, the data packet is transparently transmitted to the HAL layer; The HAL layer converts the data type of the data in the data packet to obtain a target data packet; The HAL layer determines the target function corresponding to the target data packet based on the target data packet and the preset mapping relationship; The HAL layer sends the target function to the application layer.

2. The method according to claim 1, characterized in that Before the HAL layer converts the data type of the data in the data packet, the method further includes: The HAL layer performs conversion processing on the message identifier of the data packet to obtain a processed data packet; The HAL layer converts the data type of the data in the data packet to obtain a target data packet, including: The HAL layer converts the data type in the processed data packet to obtain a target data packet.

3. The method according to claim 2, characterized in that The HAL layer performs conversion processing on the message identifier of the data packet, including: The message identifier of the data packet is replaced with a preset message identifier.

4. The method according to claim 1, characterized in that: The HAL layer converts the data type of the data in the data packet, including: The data in the data packet is converted into data of a preset type.

5. The method according to claim 4, characterized in that The preset type includes: integer int.

6. The method according to claim 1, characterized in that The method further comprises: In response to an adding operation triggered based on the preset mapping relationship, determining a function to be added and a character string to be added; The function to be added and the character string to be added are added to the preset mapping relationship table.

7. A data transmission device, characterized in that: The device comprises: MCU, used to receive data packets; The MCU is further configured to, if it is determined that the message identifier corresponding to the data packet is of a specified type, transparently transmit the data packet to the HAL layer; The HAL layer is used to convert the data type of the data in the data packet to obtain a target data packet; The HAL layer is further used to determine the target function corresponding to the target data packet based on the target data packet and the preset mapping relationship; The HAL layer is further used to send the target function to the application layer.

8. The device according to claim 7, characterized in that The HAL layer is also used for: The HAL layer performs conversion processing on the message identifier of the data packet to obtain a processed data packet; The HAL layer is specifically used for: The HAL layer converts the data type in the processed data packet to obtain a target data packet.

9. An electronic device, characterized in that: The device comprises a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device is triggered to execute the method according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 6.