Vehicle-based communication method and apparatus, vehicle, and storage medium
By determining the occupancy data length and bit field data structure of the semaphore in the vehicle communication system, and directly packaging and transmitting the semaphore data, the problem of tedious data processing and low efficiency is solved, and efficient vehicle communication is achieved.
Patent Information
- Application Number
- PCT/CN2023/122424
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-02
- Filing Date
- 2023-09-28
- Publication Date
- 2024-09-06
AI Technical Summary
The data processing in the vehicle communication system is cumbersome, resulting in low operating efficiency, especially when the data length of the semaphore does not match the preset message data length. Every time the semaphore changes, the relevant function needs to be called to update the entire message, which increases Code complexity and processing time.
By determining the placeholder data length and bit field data structure of the semaphore at the sending end, the semaphore data is directly packaged, omitting the masking and shifting steps, and the placeholder data is used to match the message structure to achieve efficient packaging and transmission of semaphore data. .
It simplifies the data processing process of the vehicle communication system, improves the operating efficiency, reduces the code complexity, and ensures the accurate transmission of semaphore data and the direct unpacking of the receiving end.
Smart Images

Figure CN2023122424_06092024_PF_FP
Abstract
Description
Vehicle-based communication method, device, vehicle and storage medium
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 2, 2023, with application number 202310192219.5, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of communication technology, for example, to a vehicle-based communication method, device, vehicle and storage medium. Background Art
[0003] With the continuous development of information technology, vehicle-mounted communication systems can solve communication problems encountered during driving, making driving safer and more convenient. Based on the development of intelligent transportation systems and sensor network technologies, vehicle-mounted communication systems can achieve highly information-based and intelligent transportation.
[0004] Currently, in-vehicle systems typically communicate via CAN (Controller Area Network) messages. Before data is transmitted to a receiving end, such as an onboard controller, the semaphores in each message are typically masked and shifted during packet packing and unpacking.
[0005] However, every time the semaphore changes, the relevant function must be called to update the semaphore in the entire message. This data processing method not only makes the code cumbersome, but also reduces the operating efficiency of the entire vehicle communication system.
[0006] Summary of the Invention
[0007] The present application provides a vehicle-based communication method, device, vehicle and storage medium to solve the problem of cumbersome data processing during vehicle communication.
[0008] In a first aspect, the present application provides a vehicle-based communication method, which is applied in a vehicle, wherein the vehicle includes a message sending end and a message receiving end, and the method includes:
[0009] The sending end determines message information including a plurality of semaphore information, wherein the semaphore information includes a starting position of semaphore data, a signal identifier of the semaphore, and a data length of the semaphore, and the starting position is determined based on a preset message data length;
[0010] The sending end determines, based on the message information and the preset message data length, a length of the placeholder data of the semaphore and a bit field data structure containing the placeholder data, wherein the length of the placeholder data is determined based on the starting position and the data length of the semaphore;
[0011] The sending end packages the multiple semaphores based on the bit field data structure to obtain a target message, and sends the target message to the receiving end.
[0012] In a second aspect, the present application provides a vehicle-based communication device, which is configured in a vehicle, wherein the vehicle includes a message sending end and a message receiving end, and the device includes:
[0013] a message information determination module, belonging to the transmitting end, configured to determine message information including a plurality of semaphore information, wherein the semaphore information includes a starting position of semaphore data, a signal identifier of the semaphore, and a data length of the semaphore, wherein the starting position is determined based on a preset message data length;
[0014] a result determination module, belonging to the transmitting end, configured to determine, based on the message information and the preset message data length, the length of the placeholder data of the semaphore and the bit field data structure containing the placeholder data, wherein the length of the placeholder data is determined based on the starting position and the data length of the semaphore;
[0015] A message sending module belongs to the sending end and is used to pack the multiple semaphores based on the bit field data structure to obtain a target message and send the target message to the receiving end.
[0016] In a third aspect, the present application provides a vehicle, comprising:
[0017] at least one processor;
[0018] and a memory communicatively coupled to the at least one processor;
[0019] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to perform the vehicle-based communication method of the first aspect.
[0020] In a fourth aspect, the present application provides a computer-readable storage medium storing computer instructions, which are used to enable a processor to implement the vehicle-based communication method of the first aspect when executed.
[0021] The vehicle-based communication solution provided by the present application, the sending end determines the message information containing multiple semaphore information, wherein the semaphore information includes the starting position of the semaphore data, the signal identifier of the semaphore and the data length of the semaphore, the starting position is determined based on the preset message data length, the sending end determines the length of the semaphore's placeholder data and the bit field data structure containing the placeholder data based on the message information and the preset message data length, wherein the length of the placeholder data is determined based on the starting position and the data length of the semaphore, the sending end packages the multiple semaphores based on the bit field data structure to obtain a target message, and sends the target message to the receiving end. By adopting the above technical solution, the transmitting end in the vehicle determines the length of the semaphore's placeholder data and the bit field data structure containing the placeholder data based on the message information and the preset message data length, and defines a data architecture (bit field data structure) that is consistent with the message structure. The data structure can be used to directly package the collected semaphore data into a message. By utilizing the placeholder data, it omits the masking and shifting steps in the message packing process, and solves the problem that each time the semaphore data changes, the relevant function must be called to update the semaphore in the entire message due to the mismatch between the semaphore data length and the preset message data length. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] FIG1 is a flow chart of a vehicle-based communication method provided according to a first embodiment of the present application;
[0023] FIG2 is a flow chart of a vehicle-based communication method provided according to a second embodiment of the present application;
[0024] FIG3 is a schematic structural diagram of a vehicle-based communication device provided according to a third embodiment of the present application;
[0025] FIG4 is a schematic structural diagram of a vehicle provided according to a fourth embodiment of the present application. DETAILED DESCRIPTION
[0026] It should be noted that the terms "first," "second," and the like in the specification and claims of this application and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In the description of this application, unless otherwise specified, "plurality" refers to two or more. "and / or" describes an association relationship between associated objects, indicating that three relationships can exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship. In addition, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or device.
[0027] Example 1
[0028] Figure 1 is a flowchart of a vehicle-based communication method provided in Example 1 of the present application. This embodiment is applicable to situations where communication is performed inside a vehicle. The method can be executed by a vehicle-based communication device. The vehicle-based communication device can be implemented in the form of hardware and / or software. The vehicle-based communication device can be configured in a vehicle, such as a vehicle computer. The vehicle includes a sending end and a receiving end of the message. The vehicle computer and other devices inside the vehicle (such as a controller, etc.) can all be sending ends and receiving ends. The vehicle can be composed of two or more physical entities.
[0029] As shown in FIG1 , the vehicle-based communication method provided in the first embodiment of the present application specifically includes the following steps:
[0030] S101. A sending end determines message information containing multiple semaphore information, wherein the semaphore information includes a starting position of semaphore data, a signal identifier of the semaphore, and a data length of the semaphore, and the starting position is determined based on a preset message data length.
[0031] In this embodiment, when communicating within the vehicle, the same device can be both a transmitter and a receiver. For example, when the vehicle computer sends a message, the vehicle computer is the transmitter, and when the vehicle computer receives a message, the vehicle computer is the receiver. The message information can be expressed in the form of the message information table shown in Table 1 below:
[0032] Table 1 Message information table
[0033] The sender of the message can determine the information of the message to be sent based on the data collected by the sensor or the message received, that is, the message information containing multiple semaphore information. As shown in Table 1, the column where Name is located in Table 1 is the signal identifier of the semaphore, the column where Bitpos is located is the starting position, and the column where Length is located is the data length. The semaphore can include wheel speed, door status, light status, and tire pressure, etc. The starting position of the semaphore data can be understood as the first bit position occupied by the semaphore data in the preset bit field corresponding to the preset message data length. If the preset bit field is 0-63 bits, the 5th bit is the starting position. The preset message data length can be understood as the length corresponding to the preset bit field. If the preset bit field is 0-63 bits, the preset message data length is 8 bytes (each byte has 8 bits). The preset bit field can be understood as the total bit field of all semaphore data in the message information.
[0034] S102. The sending end determines the length of the placeholder data of the semaphore and the bit field data structure containing the placeholder data based on the message information and the preset message data length, wherein the length of the placeholder data is determined based on the starting position and the data length of the semaphore.
[0035] In this embodiment, the transmitting end can determine the length of the semaphore's placeholder data based on the message information and the preset message data length. For example, if the preset message data length is 8 bytes, the preset bit field can be set to bits 0-63. If, among the multiple semaphore information included in the message information, the sum of the data length and the starting position of a semaphore corresponds to the 6th bit in the preset bit field, and the end position of the corresponding sub-bit field of the semaphore in the preset bit field is the 8th bit, then the difference between these two positions, 2, can be used as the length of the placeholder data, and the length of the placeholder data for each semaphore can be determined accordingly. The presence of a difference between these two positions indicates that the semaphore data cannot fully occupy the corresponding sub-bit field, i.e., there is a vacant position. Based on the message information and the length of the placeholder data, the bit field data structure containing the placeholder data can be determined, such as using the signal identifier in the message information as the identifier of a variable in the bit field data structure. The preset bit field can be divided into multiple sub-bit fields, the number of which can be the same as the number of semaphores. The preset bit field and sub-bit fields can be pre-set based on the communication protocol and the preset message data length. The placeholder data may be empty data with no content.
[0036] S103: The sending end packages the multiple semaphores based on the bit field data structure to obtain a target message, and sends the target message to the receiving end.
[0037] In this embodiment, the sending end can package the data in the semaphore, obtain the (target) message, and send it to the receiving end, thereby achieving communication between the receiving end and the sending end. Because the bitfield data structure contains placeholder data, this placeholder data can fill the vacant bits in the sub-bitfield corresponding to the semaphore data, so no shifting or masking operations are required during the packaging process. The packaging method can be: directly assign the data in the semaphore to the variables in the bitfield data structure.
[0038] In the vehicle-based communication method provided by an embodiment of the present application, a sending end determines message information containing multiple semaphore information, wherein the semaphore information includes the starting position of the semaphore data, the signal identifier of the semaphore, and the data length of the semaphore, and the starting position is determined based on a preset message data length. The sending end determines the length of the placeholder data of the semaphore and the bit field data structure containing the placeholder data based on the message information and the preset message data length, wherein the length of the placeholder data is determined based on the starting position and the data length of the semaphore. The sending end packages the multiple semaphores based on the bit field data structure to obtain a target message, and sends the target message to the receiving end. According to the technical solution of the embodiment of the present application, the transmitting end in the vehicle determines the length of the semaphore's placeholder data and the bit field data structure containing the placeholder data based on the message information and the preset message data length, and defines a data architecture (bit field data structure) that is consistent with the message structure. The data structure can be used to directly package the collected semaphore data into a message. By utilizing the placeholder data, the masking and shifting steps in the message packing process are omitted, thereby solving the problem that each time the semaphore data changes, the relevant function must be called to update the semaphore in the entire message due to the mismatch between the semaphore data length and the preset message data length.
[0039] Example 2
[0040] Figure 2 is a flow chart of a vehicle-based communication method provided in Example 2 of the present application. The technical solution of the embodiment of the present application is further refined on the basis of the above-mentioned optional technical solutions, and provides a specific method for internal communication in the vehicle.
[0041] Optionally, the sending end determines the length of the placeholder data of the semaphore and the bit field data structure containing the placeholder data based on the message information and the preset message data length, including: the sending end determines the first bit field of the semaphore based on the starting position of the semaphore data and the sum of the data length of the semaphore, wherein the starting position of the first bit field is the starting position of the data of the semaphore, and the ending position of the first bit field is the position corresponding to the sum value; the sending end determines multiple second bit fields based on the preset message data length, and determines the length of the placeholder data based on the bit field difference between the second bit field and the first bit field, wherein the sum of the length of the placeholder data and the data length of the semaphore is consistent with the length corresponding to the second bit field; the sending end determines the bit field data structure containing the placeholder data based on the message information and the length of the placeholder data. The advantage of this setting is that the length of the placeholder data can be accurately determined by using the bit field difference, thereby ensuring the accuracy of communication between the receiving end and the sending end.
[0042] Optionally, the sending end packages the plurality of semaphores based on the bit field data structure to obtain a target message, including: the sending end writes the value of the semaphore into a variable corresponding to a target semaphore identifier to obtain a target variable, and packages the target variable to obtain a target message, wherein the bit field data structure also includes the target semaphore identifier, and the target semaphore identifier is consistent with the signal identifier of the semaphore. The advantage of this setting is that by writing the value of the semaphore into the variable corresponding to the target semaphore identifier, the message can be packaged without calling an encoding function or other operations.
[0043] Optionally, after the transmitting end sends the target message to the receiving end, the method further includes: upon receiving the target message, the receiving end unpacks the target message and obtains the value of the target variable from the unpacked result, thereby controlling the driving state of the vehicle corresponding to the vehicle based on the value. This configuration has the advantage that the receiving end can complete message unpacking without calling a decoding function, making access to the semaphore straightforward.
[0044] As shown in FIG2 , a vehicle-based communication method provided in the second embodiment of the present application specifically includes the following steps:
[0045] S201: The sending end determines message information including multiple semaphore information.
[0046] S202: The transmitting end determines a first bit field of the semaphore according to a sum of a starting position of the semaphore data and a data length of the semaphore.
[0047] The starting position of the first bit field is the starting position of the data of the semaphore, and the ending position of the first bit field is the position corresponding to the sum value.
[0048] For example, if the starting position of the semaphore data is the 7th bit and the semaphore data length is 5 bits, the sum of the two is 12, and the corresponding first bit field is the 7th to 11th bits.
[0049] S203: The sending end determines a plurality of second bit fields according to a preset message data length, and determines a length of the placeholder data according to a difference between the second bit fields and the first bit fields.
[0050] The sum of the length of the placeholder data and the data length of the semaphore is consistent with the length corresponding to the second bit field.
[0051] Specifically, as described above, the preset bit field and the sub-bit field in the preset bit field may be determined according to the preset message data length and the number of semaphores, and the sub-bit field is the second bit field.
[0052] For example, if the preset message data length is 3 bytes, the preset bit field is 0 to 23 bits, the number of semaphores is 4, the 4 second bit fields are respectively 0 to 6, 7 to 12, 13 to 20, and 21 to 23, and the first bit field is respectively 0 to 6, 7 to 11, 13 to 20, and 21 to 23. Therefore, there is a bit field gap between the second bit field (7 to 12 bits) and the first bit field (7 to 11 bits), and the length difference corresponding to the bit field gap is 1, then the difference of 1 can be used as the length of the placeholder data.
[0053] S204: The sending end determines a bit field data structure containing the placeholder data according to the message information and the length of the placeholder data.
[0054] Specifically, in addition to the placeholder data, the bit field data structure may also include part of the message information, such as the signal identifier of the semaphore and the data length of the semaphore.
[0055] Optionally, the bit field data structure includes at least a target semaphore identifier, a target data length, and the placeholder data, wherein the sending end determines the bit field data structure containing the placeholder data based on the message information and the length of the placeholder data, including: the sending end determines the signal identifier of the semaphore as the target semaphore identifier, and determines the data length of the semaphore as the target data length; the sending end determines the bit field data structure containing the placeholder data based on the bit field gap and the length of the placeholder data. The advantage of this setting is that it makes the reading of the semaphore data more intuitive, the code becomes more concise, and the readability is higher.
[0056] Specifically, different bit field gaps correspond to different placeholder data lengths, and thus the corresponding bit field data structures will also be different. Therefore, the bit field data structure can be defined based on the size of the bit field gap and the length of the placeholder data. If there is no gap between the first and second bit fields corresponding to each semaphore, that is, the bit field gap is a null gap, the length of the placeholder data in the bit field data structure is zero.
[0057] For example, if the signal identifier of the semaphore is BCS_9_A_Checksum, the signal identifier can be determined as the target semaphore identifier in the bit field data structure; if the data length of the signal identifier is 8 bits, the data length can be determined as the target data length in the bit field data structure.
[0058] Furthermore, the sending end determines the bit field data structure containing the placeholder data based on the bit field gap and the length of the placeholder data, including: if the bit field gap is a non-empty gap, the sending end determines the length of the placeholder data corresponding to the non-empty gap as the target placeholder length of the semaphore corresponding to the bit field gap, wherein the types of the bit field gap include empty gaps and non-empty gaps, the empty gap indicates that the second bit field is consistent with the first bit field, and the length of the placeholder data corresponding to the empty gap is zero; the sending end determines the placeholder position of the placeholder data in the bit field data structure and the bit field data structure containing the placeholder data based on the non-empty gap and the target placeholder length. The advantage of this setting is that the placeholder position of the bit field data structure and its placeholder data is accurately determined, ensuring the reliability of communication.
[0059] For example, according to the message information shown in Table 1, the bit field data structure can be represented in code as follows:
[0060] Among them, the data between the target semaphore identifier and the target semaphore identifier is the placeholder data, such as uint8:4 between BCS_9_A_MsgCounter and BCS_FLWheelRotatedDirectionAPA, which represents 4-bit placeholder data. The length of the placeholder data of the semaphore with an empty bit field gap is zero, such as the semaphore corresponding to BCS_9_A_Checksum, so there is no placeholder data between BCS_9_A_Checksum and BCS_9_A_MsgCounter (the length of the placeholder data is zero). The number after the target semaphore identifier represents the target data length, such as BCS_9_A_MsgCounter:4 indicates that the data length of the semaphore corresponding to BCS_9_A_MsgCounter is 4 bits, occupying 4 bits.
[0061] S205. The sending end writes the value of the semaphore into a variable corresponding to the target semaphore identifier to obtain a target variable, packages the target variable to obtain a target message, and sends the target message to the receiving end.
[0062] The bit field data structure further includes the target semaphore identifier, and the target semaphore identifier is consistent with the signal identifier of the semaphore.
[0063] For example, the process of packaging the target variables can be expressed in the form of code, such as:
[0064] Among them, can_message.h is the name of the bit field data structure. The content between / *Assign semaphore* / and / *Encoding completed, send message* / is the process of writing the semaphore value into the variable corresponding to the target semaphore identifier.
[0065] S206. After receiving the target message, the receiving end unpacks the target message and obtains the value of the target variable from the unpacking result to control the driving state of the vehicle corresponding to the vehicle according to the value.
[0066] Specifically, after receiving the target message, the receiving end does not need to perform operations such as shifting and masking on the target message, and can directly read the value of the target variable, that is, the value of the semaphore, from the target message.
[0067] For example, the process of unpacking the target variable can be expressed in the form of code, such as:
[0068] The content below / *directly obtain the semaphore* / is the process of obtaining the value of the target variable from the unpacking result.
[0069] Optionally, the bit field data structure is determined based on the C or C++ programming language. The advantage of this arrangement is that it supports different forms of CAN messages and improves the compatibility of the vehicle communication system.
[0070] Specifically, there is a concept of bit field in C or C++ programming language, so the bit field data structure can be written in C or C++ programming language.
[0071] The vehicle-based communication method provided by the embodiment of the present application, the sending end in the vehicle first accurately determines the length of the placeholder data in the bit field data structure according to the starting position and data length of the semaphore in the message information, thereby ensuring the accuracy of communication between the receiving end and the sending end, and then writes the value of the semaphore into the variable corresponding to the target semaphore identifier, thereby achieving the packaging of the message and sending it to the receiving end without calling the encoding function and other operations. The receiving end can complete the unpacking of the message without calling the decoding function, making access to the semaphore direct, and making the code concise, improving the readability of the code, saving system resources, and improving the operating efficiency of the entire vehicle communication system. This method can also be extended to any scenario where compact coded data messages with bits as the basic unit are used for communication.
[0072] Example 3
[0073] FIG3 is a schematic diagram of the structure of a vehicle-based communication device provided in Example 3 of the present application. The device can be configured in a vehicle, which includes a message sending end and a message receiving end. As shown in FIG3 , the device includes: a message information determination module 301, a result determination module 302, and a message sending module 303, wherein:
[0074] a message information determination module, belonging to the transmitting end, configured to determine message information including a plurality of semaphore information, wherein the semaphore information includes a starting position of semaphore data, a signal identifier of the semaphore, and a data length of the semaphore, wherein the starting position is determined based on a preset message data length;
[0075] a result determination module, belonging to the transmitting end, configured to determine, based on the message information and the preset message data length, the length of the placeholder data of the semaphore and the bit field data structure containing the placeholder data, wherein the length of the placeholder data is determined based on the starting position and the data length of the semaphore;
[0076] A message sending module belongs to the sending end and is used to pack the multiple semaphores based on the bit field data structure to obtain a target message and send the target message to the receiving end.
[0077] The vehicle-based communication device provided by the embodiment of the present application, the sending end in the vehicle determines the length of the semaphore's placeholder data and the bit field data structure containing the placeholder data based on the message information and the preset message data length, and defines a data architecture (bit field data structure) that is consistent with the message structure. The data structure can be used to directly package the collected semaphore data into a message. By using the placeholder data, it omits the masking and shifting steps in the message packing process, and solves the problem that each time the semaphore data changes, the relevant function must be called to update the semaphore in the entire message due to the mismatch between the semaphore data length and the preset message data length.
[0078] Optionally, the result determination module includes:
[0079] a bit field determining unit, belonging to the transmitting end, configured to determine a first bit field of the semaphore according to a sum of a starting position of the semaphore data and a data length of the semaphore, wherein the starting position of the first bit field is the starting position of the semaphore data, and the ending position of the first bit field is the position corresponding to the sum;
[0080] a length determination unit, belonging to the transmitting end, configured to determine a plurality of second bit fields according to a preset message data length, and determine a length of the placeholder data according to a difference between the second bit fields and the first bit fields, wherein the sum of the length of the placeholder data and the data length of the semaphore is consistent with the length corresponding to the second bit fields;
[0081] The data structure determination unit belongs to the sending end and is used to determine the bit field data structure containing the placeholder data according to the message information and the length of the placeholder data.
[0082] Optionally, the bit field data structure includes at least a target semaphore identifier, a target data length, and the placeholder data, wherein the sending end determines the bit field data structure containing the placeholder data based on the message information and the length of the placeholder data, including: the sending end determines the signal identifier of the semaphore as the target semaphore identifier, and determines the data length of the semaphore as the target data length; the sending end determines the bit field data structure containing the placeholder data based on the bit field gap and the length of the placeholder data.
[0083] Furthermore, the sending end determines the bit field data structure containing the placeholder data based on the bit field gap and the length of the placeholder data, including: if the bit field gap is a non-empty gap, the sending end determines the length of the placeholder data corresponding to the non-empty gap as the target placeholder length of the semaphore corresponding to the bit field gap, wherein the types of the bit field gap include empty gaps and the non-empty gaps, the empty gap indicates that the second bit field is consistent with the first bit field, and the length of the placeholder data corresponding to the empty gap is zero; the sending end determines the placeholder position of the placeholder data in the bit field data structure and the bit field data structure containing the placeholder data based on the non-empty gap and the target placeholder length.
[0084] Optionally, the message sending module is specifically used to write the value of the semaphore into the variable corresponding to the target semaphore identifier to obtain the target variable, and package the target variable to obtain a target message, wherein the bit field data structure also includes the target semaphore identifier, and the target semaphore identifier is consistent with the signal identifier of the semaphore.
[0085] Optionally, the device further includes:
[0086] The target variable value determination module belongs to the receiving end and is used to unpack the target message after receiving it, and obtain the value of the target variable from the unpacking result to control the driving state of the vehicle corresponding to the vehicle according to the value.
[0087] Optionally, the bit field data structure is determined based on the C or C++ programming language.
[0088] The vehicle-based communication device provided in the embodiments of the present application can execute the vehicle-based communication method provided in any embodiment of the present application, and has the corresponding functional modules and beneficial effects of the execution method.
[0089] Example 4
[0090] 4 shows a schematic diagram of a vehicle 40 that can be used to implement an embodiment of the present application. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or claimed herein.
[0091] Vehicle 40 includes a message transmitter and receiver, both of which can be internal vehicle computers and other devices (such as controllers). As shown in Figure 4, vehicle 40 includes at least one processor 41 and memory, such as read-only memory (ROM) 42 and random access memory (RAM) 43, that is communicatively connected to the at least one processor 41. The memory stores computer programs that can be executed by the at least one processor. Processor 41 can perform various appropriate actions and processes based on the computer programs stored in read-only memory (ROM) 42 or loaded from storage unit 48 into random access memory (RAM) 43. RAM 43 can also store various programs and data required for the operation of vehicle 40. Processor 41, ROM 42, and RAM 43 are interconnected via bus 44. Input / output (I / O) interface 45 is also connected to bus 44.
[0092] Various components in the vehicle 40 are connected to the I / O interface 45, including an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a magnetic disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the vehicle 40 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0093] Processor 41 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any other suitable processor, controller, microcontroller, etc. Processor 41 executes the various methods and processes described above, such as the vehicle-based communication method.
[0094] In some embodiments, the vehicle-based communication method can be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 48. In some embodiments, part or all of the computer program can be loaded and / or installed on vehicle 40 via ROM 42 and / or communication unit 49. When the computer program is loaded into RAM 43 and executed by processor 41, one or more steps of the vehicle-based communication method described above can be performed. Alternatively, in other embodiments, processor 41 can be configured to execute the vehicle-based communication method in any other suitable manner (e.g., via firmware).
[0095] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0096] Computer programs for implementing the methods of the present application may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0097] The computer device provided above can be used to execute the vehicle-based communication method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0098] Example 5
[0099] In the context of the present application, a computer-readable storage medium may be a tangible medium, wherein the computer-executable instructions, when executed by a computer processor, are used to perform a vehicle-based communication method, the method being applied in a vehicle including a message transmitter and a message receiver, the method comprising:
[0100] The sending end determines message information including a plurality of semaphore information, wherein the semaphore information includes a starting position of semaphore data, a signal identifier of the semaphore, and a data length of the semaphore, and the starting position is determined based on a preset message data length;
[0101] The sending end determines, based on the message information and the preset message data length, a length of the placeholder data of the semaphore and a bit field data structure containing the placeholder data, wherein the length of the placeholder data is determined based on the starting position and the data length of the semaphore;
[0102] The sending end packages the multiple semaphores based on the bit field data structure to obtain a target message, and sends the target message to the receiving end.
[0103] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use with an instruction execution system, device or equipment or used in conjunction with an instruction execution system, device or equipment. A computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0104] The computer device provided above can be used to execute the vehicle-based communication method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0105] It is worth noting that in the above-mentioned embodiment of the vehicle-based communication device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application.
[0106] Note that the above are only optional embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application has been described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. A vehicle-based communication method, applied in a vehicle, wherein the vehicle includes a message sending end and a message receiving end, the method comprising: The sending end determines message information including a plurality of semaphore information, wherein the semaphore information includes a starting position of semaphore data, a signal identifier of the semaphore, and a data length of the semaphore, and the starting position is determined based on a preset message data length; The sending end determines the length of the placeholder data of the semaphore and the bit field data structure containing the placeholder data according to the message information and the preset message data length, wherein the length of the placeholder data is determined according to the starting position and the data length of the semaphore; The sending end packages the multiple semaphores based on the bit field data structure to obtain a target message, and sends the target message to the receiving end.
2. The method according to claim 1, wherein: The transmitting end determines the length of the placeholder data of the semaphore and the bit field data structure containing the placeholder data according to the message information and the preset message data length, including: The transmitting end determines the first bit field of the semaphore according to the sum of the starting position of the data of the semaphore and the data length of the semaphore, wherein the starting position of the first bit field is the starting position of the data of the semaphore, and the ending position of the first bit field is the position corresponding to the sum; The sending end determines a plurality of second bit fields according to a preset message data length, and determines a length of the placeholder data according to a bit field difference between the second bit field and the first bit field, wherein a sum of the length of the placeholder data and the data length of the semaphore is consistent with a length corresponding to the second bit field; The sending end determines a bit field data structure including the placeholder data according to the message information and the length of the placeholder data.
3. The method according to claim 2, wherein: The bit field data structure includes at least a target semaphore identifier, a target data length, and the placeholder data. The sending end determines the bit field data structure including the placeholder data according to the message information and the length of the placeholder data, including: The transmitting end determines the signal identifier of the semaphore as the target semaphore identifier, and determines the data length of the semaphore as the target data length; The sending end determines a bit field data structure including the placeholder data according to the bit field gap and the length of the placeholder data.
4. The method according to claim 3, wherein: The sending end determines a bit field data structure including the placeholder data according to the bit field gap and the length of the placeholder data, including: If the bit field gap is a non-empty gap, the sending end determines the length of the placeholder data corresponding to the non-empty gap as the target placeholder length of the semaphore corresponding to the bit field gap, wherein the type of the bit field gap includes an empty gap and the non-empty gap, the empty gap indicates that the second bit field is consistent with the first bit field, and the length of the placeholder data corresponding to the empty gap is zero; The sending end determines the placeholder position of the placeholder data in the bitfield data structure and the bitfield data structure containing the placeholder data according to the non-empty gap and the target placeholder length.
5. The method according to claim 1, wherein: The sending end packages the plurality of semaphores based on the bit field data structure to obtain a target message, including: The sending end writes the value of the semaphore into the variable corresponding to the target semaphore identifier to obtain the target variable, and packages the target variable to obtain a target message, wherein the bit field data structure also includes the target semaphore identifier, and the target semaphore identifier is consistent with the signal identifier of the semaphore.
6. The method according to claim 5, after the sending end sends the target message to the receiving end, further comprising: After receiving the target message, the receiving end unpacks the target message and obtains the value of the target variable from the unpacking result to control the driving state of the vehicle corresponding to the vehicle according to the value.
7. The method according to any one of claims 1 to 6, wherein: The bit field data structure is determined based on C or C++ programming language.
8. A vehicle-based communication device, configured in a vehicle, wherein the vehicle includes a message sending end and a message receiving end, and the device comprises: The message information determination module belongs to the sending end and is used to determine the message containing multiple signal quantity information. The semaphore information includes a starting position of the semaphore data, a signal identifier of the semaphore, and a data length of the semaphore, and the starting position is determined based on a preset message data length; a result determination module, belonging to the sending end, for determining the length of the placeholder data of the semaphore and the bit field data structure containing the placeholder data according to the message information and the preset message data length, wherein the length of the placeholder data is determined according to the starting position and the data length of the semaphore; The message sending module belongs to the sending end and is used to pack the multiple semaphores based on the bit field data structure to obtain the target message and send the target message to the receiving end.
9. A vehicle comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the vehicle-based communication method according to any one of claims 1 to 7. 10 . A computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a processor to implement the vehicle-based communication method according to any one of claims 1 to 7 when executed.
Citation Information
Patent Citations
Communication method and device based on vehicle, vehicle and storage medium
CN116192967A
Data processing method and related device
CN105450488A
Method and system for automatically generating source file of CAN signals
CN107479526A
CAN signal package method and apparatus, and CAN signal analysis method and apparatus
CN108471401A
Task processing method and apparatus
WO2023004801A1
