Data decoding method, data encoding method, device and terminal equipment
By obtaining the priorities of multiple preset parsing protocols and sequentially decoding the data to be decoded, and updating the decoding rules after successful decoding, the compatibility problem of terminal equipment during data decoding is solved and the decoding efficiency is improved.
Patent Information
- Application Number
- CN202011094119.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-14
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2040-10-14
AI Technical Summary
In the field of Internet of Vehicles technology, each terminal device lacks a selection process for the parsing protocol when decoding data, resulting in poor data processing compatibility.
By obtaining the current priorities of multiple preset parsing protocols, the data to be decoded is decoded in sequence, and the decoding rules are updated after successful decoding to improve data processing compatibility and decoding efficiency.
Improved data processing compatibility, reduced the number of preset parsing protocols tried in the next decoding cycle, and improved decoding efficiency.
Smart Images

Figure CN114430307B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of vehicle networking technology, and in particular to a data decoding method, a data encoding method, a device and a terminal device. Background Art
[0002] In the field of Internet of Vehicles technology, data can usually be exchanged between terminals such as people, vehicles, roads, and service platforms, which helps to solve road congestion problems, plan travel plans, or build smart cities. Taking the RoadSide Unit (RSU) as an example, the data received by the RSU from different vehicles may be encoded in different ways by each vehicle; similarly, taking the vehicle as an example, the vehicle may receive data from different terminals, and the encoding methods used by different terminals may also be different. In the prior art, each terminal lacks the process of selecting the parsing protocol when decoding data, resulting in poor data processing compatibility. Summary of the invention
[0003] The embodiments of the present invention provide a data decoding method, a data encoding method, an apparatus and a terminal device to solve the problem in the prior art that each terminal lacks a process for selecting a parsing protocol when decoding data, resulting in poor data processing compatibility.
[0004] In order to solve the above-mentioned technical problems, the present invention is achieved as follows:
[0005] In a first aspect, an embodiment of the present invention provides a data decoding method, including:
[0006] In one decoding cycle, the data to be decoded and the current decoding rule are obtained, wherein the current decoding rule includes the current priority of each of the N preset resolution protocols, and the current priority is used to determine the decoding order of the preset resolution protocols, where N is an integer greater than 1;
[0007] According to the current decoding rule, the to-be-decoded data is decoded in sequence using the N preset parsing protocols;
[0008] When the data to be decoded is successfully decoded, the current decoding rule is updated.
[0009] In a second aspect, an embodiment of the present invention further provides a data encoding method, comprising:
[0010] In one encoding cycle, the data to be encoded and the current encoding rule are obtained, wherein the current encoding rule corresponds to the updated current decoding rule obtained according to the steps in the above data decoding method in the decoding cycle matching the current encoding cycle;
[0011] According to the current encoding rule, the data to be encoded is encoded using a preset parsing protocol.
[0012] In a third aspect, an embodiment of the present invention further provides a data decoding device, including:
[0013] A first acquisition module, used to acquire to-be-decoded data and a current decoding rule within a decoding cycle, wherein the current decoding rule includes a current priority of each of N preset resolution protocols, wherein the current priority is used to determine a decoding order of the preset resolution protocols, and N is an integer greater than 1;
[0014] A decoding module, used to decode the to-be-decoded data in sequence using the N preset parsing protocols according to the current decoding rule;
[0015] The updating module is used to update the current decoding rule when the data to be decoded is successfully decoded.
[0016] In a fourth aspect, an embodiment of the present invention further provides a data encoding device, including:
[0017] A second acquisition module is used to acquire the data to be encoded and the current encoding rule in one encoding cycle, wherein the current encoding rule corresponds to the updated current decoding rule obtained by the above-mentioned data decoding device in the decoding cycle matching the current encoding cycle;
[0018] The encoding module is used to encode the data to be encoded using a preset parsing protocol according to the current encoding rule.
[0019] In a fifth aspect, an embodiment of the present invention further provides a terminal device, comprising the above-mentioned data decoding device and the above-mentioned data encoding device.
[0020] In a sixth aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the computer program.
[0021] In a seventh aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program implements the above method when executed by a processor.
[0022] In the data decoding method provided by the embodiment of the present invention, a current decoding rule including the current priority of each preset parsing protocol in N preset parsing protocols can be obtained, and according to the current decoding rule, the N preset parsing protocols are used to sequentially decode the acquired data to be decoded. When the data to be decoded is successfully decoded, the current decoding rule can be updated, so that the current decoding rule updated in the current decoding cycle can be used in the next decoding cycle. On the one hand, the embodiment of the present invention can use multiple preset parsing protocols to decode the data to be parsed in sequence to improve data processing compatibility. On the other hand, the current decoding rule will be updated according to the decoding success status of the data to be parsed, so that in the next decoding cycle, with a high probability, the data to be decoded can be successfully decoded with a smaller number of preset parsing protocol attempts, thereby helping to improve decoding efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 A flowchart of a data decoding method provided by an embodiment of the present invention;
[0024] Figure 2 A flowchart of decoding data to be decoded according to an embodiment of the present invention;
[0025] Figure 3 A flowchart of updating the priority of a preset resolution protocol in a specific application example of the present invention;
[0026] Figure 4 A flowchart of a protocol analysis thread processing decoded data in a specific application example of the present invention;
[0027] Figure 5 A flowchart of a data encoding method provided by an embodiment of the present invention;
[0028] Figure 6 It is a flow chart of a data sending process in a specific application example of the present invention;
[0029] Figure 7 A schematic diagram of the structure of a data decoding device provided by an embodiment of the present invention;
[0030] Figure 8 A schematic diagram of the structure of a data encoding device provided by an embodiment of the present invention;
[0031] Fig. 9 A schematic diagram of the structure of a terminal device provided by an embodiment of the present invention;
[0032] Fig.10 This is a structural diagram of a specific application example of the present invention when the terminal device is a roadside device. DETAILED DESCRIPTION
[0033] In order to make the technical problems, technical solutions and advantages to be solved by the present invention clearer, the following will be described in detail in conjunction with the accompanying drawings and specific embodiments. In the following description, specific details such as specific configurations and components are provided only to help fully understand the embodiments of the present invention. Therefore, it should be clear to those skilled in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. In addition, for clarity and brevity, the description of known functions and structures is omitted.
[0034] Unless otherwise defined, the technical or scientific terms used in the present invention shall have the common meanings understood by persons with ordinary skills in the field to which the present invention belongs. The words "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, the words "one" or "an" and similar words do not indicate a quantity limitation, but indicate the existence of at least one.
[0035] like Figure 1 As shown, the data decoding method provided by the embodiment of the present invention includes:
[0036] Step 101, in a decoding cycle, obtaining data to be decoded and a current decoding rule, wherein the current decoding rule includes a current priority of each of N preset resolution protocols, and the current priority is used to determine a decoding order of the preset resolution protocols, where N is an integer greater than 1;
[0037] Step 102, according to the current decoding rule, use the N preset parsing protocols to decode the data to be decoded in sequence;
[0038] Step 103: When the data to be decoded is successfully decoded, the current decoding rule is updated.
[0039] The data decoding method provided in the embodiment of the present invention can be applied to terminals such as road side units (RSU), cloud servers or vehicles, and is not specifically limited here. For example, the RSU may also exchange data with multiple vehicles within a certain distance range; for another example, a vehicle may also receive data from different RSUs or cloud servers. In this way, there may be a situation where a terminal may receive data from different terminals, and these data may be encoded through different parsing protocols. To simplify the description, the following mainly takes the above-mentioned data decoding method running on the RSU as an example for explanation.
[0040] RSU usually receives data from different terminals, such as vehicles, traffic equipment such as traffic lights, or cloud servers. These data are usually encoded by the sender. Therefore, in order to obtain the information carried in the data, RSU usually needs to use the corresponding parsing protocol to decode it first. Therefore, these data can be considered as data to be decoded. For the sake of convenience, the data interaction between vehicles and RSU is mainly described here.
[0041] In this embodiment, there are multiple preset resolution protocols in the RSU, namely the N preset resolution protocols mentioned above; when decoding the data to be decoded, the RSU will use a current decoding rule to determine the calling order of each preset resolution protocol. In other words, the current decoding rule mainly refers to the current priority of each preset resolution protocol in the N preset resolution protocols; the current priority is used to determine the decoding order of the preset resolution protocols. Generally speaking, the higher the current priority of a preset resolution protocol, the higher the order of calling it for decoding.
[0042] It is easy to understand that the current decoding rule can be variable, or continuously updated. At the same time, there is an update cycle for the update of the current decoding rule, which corresponds to the decoding cycle described above. The decoding cycle can be a fixed time, such as 30 seconds or 1 minute, or can refer to the number of decoded data to be decoded, etc., which is not specifically limited here. The following mainly takes the decoding cycle as a fixed time as an example for explanation.
[0043] For ease of understanding, in this embodiment, the steps performed in the data decoding method in a certain decoding cycle are taken as an example for explanation. In a decoding cycle, the RSU may receive a number of data to be decoded, for example, the RSU may receive 5 data to be decoded respectively sent by 5 vehicles; or it may only receive 1 data to be decoded sent by 1 vehicle. In other words, in step 101, the number of data to be decoded is not specifically limited.
[0044] Taking decoding of certain data to be decoded as an example, in this embodiment, according to the current priority of each preset parsing protocol in the current decoding rule, each preset parsing protocol may be tried in turn to parse the data to be decoded.
[0045] For example, assuming that there are preset resolution protocols A and B in the RSU, the current priorities corresponding to the two are represented by priority levels, which are 1 and 2 respectively, where the smaller the priority level value, the higher the priority. After receiving the data to be decoded, the RSU will first try to use the preset resolution protocol A to decode the data to be decoded. When the decoding is successful, the decoding of the data to be decoded is completed; when the decoding fails, it will further try to use the preset resolution protocol B to decode the data to be decoded.
[0046] Of course, the above is only an example of using different preset parsing protocols to sequentially decode the data to be decoded according to the current decoding rule. In actual applications, the current priority can also be represented by a score, or a similar identifier such as "primary", "secondary", etc. In addition, the number of preset parsing protocols can also be selected according to actual needs.
[0047] When the data to be decoded is successfully decoded, the current decoding rules can be updated. The update here mainly refers to updating the current priority of the preset resolution protocol. For example, taking the preset resolution protocol A and the preset resolution protocol B described above as an example, when the preset resolution protocol B successfully decodes the data to be decoded, it means that the preset resolution protocol B is a commonly used resolution protocol in vehicles in some time periods or some geographical areas. Therefore, the priority of the preset resolution protocol B can be increased at this time, so that in the next decoding cycle, the preset resolution protocol B is used first to try to decode the data to be decoded. Or, relatively speaking, the priority of the preset resolution protocol A can be lowered, so that in the next decoding cycle, the decoding order of the preset resolution protocol A is adjusted later. In this way, in the next decoding cycle, it is possible to achieve successful decoding of the data to be decoded with a high probability with fewer attempts of the preset resolution protocol, which helps to improve decoding efficiency.
[0048] It is easy to understand that if the current decoding cycle is the first decoding cycle of the RSU, the current decoding rule obtained may be a preset initial decoding rule.
[0049] Of course, in actual applications, there may be multiple data to be decoded, and there may be multiple preset parsing protocols that successfully decode the data to be decoded. The priorities of multiple preset parsing protocols can also be adjusted at the same time. The specific adjustment process is similar to the previous example and will not be repeated here.
[0050] In the data decoding method provided by the embodiment of the present invention, a current decoding rule including the current priority of each preset parsing protocol in N preset parsing protocols can be obtained, and according to the current decoding rule, the N preset parsing protocols are used to sequentially decode the acquired data to be decoded. When the data to be decoded is successfully decoded, the current decoding rule can be updated, so that the current decoding rule updated in the current decoding cycle can be used in the next decoding cycle. On the one hand, the embodiment of the present invention can use multiple preset parsing protocols to decode the data to be parsed in sequence to improve data processing compatibility. On the other hand, the current decoding rule will be updated according to the decoding success status of the data to be parsed, so that in the next decoding cycle, with a high probability, the data to be decoded can be successfully decoded with a smaller number of preset parsing protocol attempts, thereby helping to improve decoding efficiency.
[0051] Optionally, the above step 102, according to the current decoding rule, uses the N preset parsing protocols to sequentially decode the data to be decoded, including:
[0052] In a case where the data to be decoded exists in a first buffer corresponding to a first resolution protocol, decoding the data to be decoded using the first resolution protocol;
[0053] When the first parsing protocol fails to decode the data to be decoded, storing the data to be decoded in a second cache corresponding to a second parsing protocol;
[0054] The first resolution protocol and the second resolution protocol are any two preset resolution protocols with adjacent current priorities among the N preset resolution protocols, and the current priority of the first resolution protocol is greater than the current priority of the second resolution protocol.
[0055] It is easy to understand that decoding the data to be decoded using a certain parsing protocol can be implemented by a thread or process, etc. To simplify the description, the following mainly describes the thread as an example. Correspondingly, for example, for an RSU type terminal, in order to receive data from a vehicle, it can also have a thread for receiving data. To distinguish, the decoding thread is defined as a protocol analysis thread, and the thread for receiving data is defined as a receiving thread.
[0056] Each protocol analysis thread may correspond to a cache. Specifically, the cache may be used to store the data to be decoded, and each protocol analysis thread may read the data to be decoded from the corresponding cache. Similarly, a cache may correspond to a storage thread. Thus, in this embodiment, the process of sequentially decoding the data to be decoded using N preset analysis protocols may include the following steps: Figure 2 The process shown.
[0057] Specifically, see Figure 2 The first parsing protocol and the second parsing protocol can correspond to the protocol analysis thread 1 and the protocol analysis thread 2 shown in the figure respectively, and the first cache and the second cache can correspond to the storage thread 1 and the storage thread 2 respectively.
[0058] After the receiving thread receives the data sent by the vehicle, that is, the data to be decoded, it first stores all the data to be decoded in the first cache. The data structure in the first cache can be a circular queue or a linked list, etc., which is not specifically limited here. The following mainly uses the data structure of the circular queue as an example for explanation. The first cache can push the data pointer to the queue head of the circular queue, so that the circular queue in the first cache can correspond to Figure 2The queue for storing thread 1 parsing data pointers is shown in FIG. Similarly, the data structure in the second cache can also be a circular queue. The circular queue in the second cache corresponds to Figure 2 The queue for storing thread 2 parsed data pointers is shown in .
[0059] When there is data to be decoded in the queue storing the data pointer parsed by thread 1, protocol analysis thread 1 can extract the data to be decoded one by one from the queue storing the data pointer parsed by thread 1, and decode the data to be decoded according to the corresponding first parsing protocol. It is easy to understand that for the cache, the process of storing data can correspond to Figure 2 The process of data being extracted and popped up can be described as follows: Figure 2 Pop shown in .
[0060] The data to be decoded that cannot be successfully parsed by the protocol analysis thread 1 can be further pushed into the second cache, that is, the queue for storing the data parsing pointer of the thread 2 mentioned above. The protocol analysis thread 2 can then extract the data to be decoded one by one from the queue for storing the data parsing pointer of the thread 2, and decode the data to be decoded according to the corresponding second parsing protocol.
[0061] It is worth emphasizing that, in the present embodiment, the first resolution protocol and the second resolution protocol are any two preset resolution protocols with adjacent current priorities among the N preset resolution protocols; that is, when the number of preset resolution protocols is 3 or more, there may be a process in which multiple first resolution protocols and second resolution protocols attempt to decode the data to be parsed in turn; and in a certain decoding process, the second resolution protocol fails to successfully decode the data to be decoded, and the second resolution protocol is the preset resolution protocol with the lowest priority, indicating that the data to be decoded cannot be successfully decoded by the above-mentioned N preset resolution protocols.
[0062] In this embodiment, the data to be decoded is decoded in sequence according to the current priority of each preset parsing protocol. At the same time, a corresponding cache is configured for each preset parsing protocol, so that the processing path for the data to be decoded is clearer, effectively avoiding the situation where the data to be decoded is missed, and improving the data decoding effect.
[0063] In one example, when data exists in the cache corresponding to a preset resolution protocol, the protocol analysis thread corresponding to the preset resolution protocol can be awakened; correspondingly, when data does not exist in the cache corresponding to a preset resolution protocol, the corresponding protocol analysis thread can remain in a sleep state waiting to be awakened.
[0064] In another example, when a preset parsing protocol with a higher priority fails to successfully decode the data to be decoded, the protocol analysis thread corresponding to the preset parsing protocol with the next priority can be actively awakened.
[0065] Optionally, the above step 102, according to the current decoding rule, uses the N preset parsing protocols to sequentially decode the data to be decoded, including:
[0066] Decoding the data to be decoded using a third parsing protocol, and determining whether the initial decoded data satisfies a preset data condition when initial decoded data is obtained;
[0067] In the case where the initial decoded data meets the preset data condition, determining that the third parsing protocol successfully decodes the data to be decoded;
[0068] The third resolution protocol is any one of the N preset resolution protocols.
[0069] Normally, a preset parsing protocol fails to decode the data to be decoded, mainly due to protocol mismatch, and the data packet type in the preset parsing protocol is inconsistent with the data packet type of the data to be decoded. However, in some cases, the preset parsing protocol may unpack the data to be decoded normally, but some of the elements or parameters obtained are unreasonable. For example, the RSU located in a certain geographical location has a communication range of 800m with the vehicle. However, after decoding the data to be decoded sent by a certain vehicle, the distance between the geographical location of the vehicle and the RSU is 2km. This means that although the RSU uses a preset parsing protocol to decode the data to be decoded normally, the preset parsing protocol used may not be correct, and the decoding is not successful.
[0070] In order to avoid the above situation where the decoding is normal but not successful in essence, the present embodiment adopts a method of verifying the initial decoding data using a preset data condition.
[0071] Combined with the example of communication range in the above text, the above preset data conditions may include distance conditions. For example, the air interface data transmission range used between the RSU and the vehicle is within 800m. Taking into account the deviation, the distance condition may correspond to the distance between the RSU and the vehicle calculated by longitude, latitude and elevation within 1km. When the RSU decodes the data to be decoded and obtains that the distance data between the vehicle and the RSU is not greater than 1km, it means that the preset parsing protocol used has successfully decoded the data to be decoded.
[0072] Of course, in practical applications, the above distance condition can be determined according to the communication range of the communication protocol adopted by the RSU, or the set deviation size. In addition, the above preset data condition can also be a time condition, a motion data condition, a vehicle identity condition, etc., which can be set according to actual needs.
[0073] In actual applications, when the above-mentioned third parsing protocol decodes the data to be decoded, whether it is because of protocol mismatch or normal decoding but the initial decoded data does not meet the preset data conditions, it can be considered that the third parsing protocol has failed to successfully decode the data to be decoded. When the priority of the third parsing protocol is not the last priority, the preset parsing protocol of the next priority can be further used to decode the data to be decoded.
[0074] Optionally, the step 103, when the data to be decoded is successfully decoded, updating the current decoding rule includes:
[0075] Acquire a fourth parsing protocol for successfully decoding the data to be decoded in the current decoding cycle;
[0076] The current priority of the fourth resolution protocol is increased, and / or the current priority of the fifth resolution protocol is decreased, wherein the fifth resolution protocol is a preset resolution protocol other than the fourth resolution protocol among the N preset resolution protocols.
[0077] As described above, within a decoding cycle, there may be one or more data to be decoded. In this embodiment, as long as a preset resolution protocol successfully decodes one of the data to be decoded, it can be considered as the fourth resolution protocol; in other words, the number of fourth resolution protocols can be one or more. The fifth resolution protocol is a preset resolution protocol other than the fourth resolution protocol among the N preset resolution protocols; that is, the fifth resolution protocol can be considered as a preset resolution protocol that has not been able to successfully decode any data to be decoded within the decoding cycle. In a decoding cycle, the number of the fifth resolution protocol can be one or more. Currently, when all N preset resolution protocols have been successfully decoded, the number of the fifth resolution protocol can also be zero.
[0078] In this embodiment, updating the current decoding rules mainly refers to updating the current priority of the preset parsing protocol. Specifically, within a decoding cycle, the fourth parsing protocol has the situation of successfully decoding the data to be decoded, which means that the fourth parsing protocol may be a protocol that is currently used more frequently, and its priority can be increased so that it will be used in the next decoding cycle. The order of decoding the data to be decoded is a prerequisite; or, similarly, since the fifth parsing protocol failed to successfully decode any data to be decoded within a decoding cycle, it means that the fifth parsing protocol is currently used less, and its priority can be lowered, so that in the next decoding cycle, the order of using it to decode the data will be moved back. Of course, in actual applications, it is also possible to simultaneously increase the priority of the fourth parsing protocol and reduce the priority of the fifth parsing protocol.
[0079] In this embodiment, by updating the current priority of the fourth resolution protocol and / or the fifth resolution protocol, the current decoding rules are updated accordingly, and in the next decoding cycle, a more reasonable usage order of the preset resolution protocols can be obtained, thereby improving decoding efficiency.
[0080] The following describes the process of updating the current decoding rules in conjunction with a specific application example.
[0081] Combination Figure 3 In this application example, the priority of each preset parsing protocol, or the corresponding protocol processing thread, is represented by Priority. The update of Priority is performed by the priority maintenance thread according to a certain time period. The Priority range is [0, 5], and the lower the value, the higher the priority.
[0082] The initial state of the priority of each protocol processing thread in the protocol stack adopts a pre-set rule. When the device such as RSU performs protocol stack initialization configuration, the configuration items of each protocol file will be read. Taking actual usage as an example, the preset parsing protocol can be divided into the "three-span" standard message set protocol (national standard), the "four-span" demonstration activity message set protocol and a private customized message set for a project. At the time of initialization, the priority of the private customized message set is configured to 0 (the predicted usage rate is the highest, and the initial highest priority is assigned) according to the predicted usage. The priorities of "three-span" and "four-span" are configured to 1 and 2 respectively. During the first parsing, the private customized message set will be used to parse the information first, and then the "three-span" and "four-span" protocols will be used respectively; after a certain period of use, the priorities will change respectively, until there are multiple protocols (same priority) with the same priority, the priority attribute in the configuration will be used in the same priority to determine the order of parsing the protocols. For example, if the priorities of the three protocols all become 0 in real time, the priority in the configuration will still be adopted, that is, the private customized message set will be the highest priority strategy.
[0083] The priority maintenance thread execution cycle, that is, the above-mentioned decoding cycle arrives. When the protocol stack exists, the high-priority protocol processing method interface (including the UseFlag data member) will be obtained to determine the value of the data member UseFlag. When the value is 0, it indicates that no message has been processed using the protocol during the priority maintenance thread execution cycle, and the priority of the protocol processing needs to be lowered. When the Priority is less than 5 (5 is the lowest priority and no change is required), it will automatically increase by 1; otherwise, it means that the device has processed messages using the protocol during the priority maintenance thread execution cycle. When the Priority is greater than 0 (0 is the highest priority and no change is required), it will automatically decrease by 1.
[0084] After the priority maintenance thread determines that the processing thread is completed, it will reset the UseFlag, and then perform the value change and determination of the UseFlag of the next priority maintenance thread execution cycle. In this way, the efficiency of data parsing can be improved by changing the protocol processing priority in real time.
[0085] Of course, in practical applications, the value range of the Priority can be set accordingly according to the number of preset resolution protocols.
[0086] In a feasible implementation manner, when a fixed parsing protocol is limited to be used in a certain limited area or a certain limited time period, the current decoding rule may also be configured as a fixed protocol parsing mode.
[0087] Optionally, after sequentially decoding the data to be decoded using the N preset parsing protocols according to the current decoding rule, the method further includes:
[0088] In the case that each of the N preset parsing protocols fails to successfully decode the data to be decoded, the data to be decoded is discarded.
[0089] In this embodiment, for some data to be decoded, when all N preset parsing protocols cannot be successfully decoded, it can be directly discarded to avoid affecting the update of the current decoding rules and improve the efficiency of the entire data parsing process.
[0090] Of course, in some feasible implementations, the data to be decoded that failed to be successfully decoded can also be sent to other terminals such as cloud servers for decoding, or further recorded are the parsing protocols used in encoding the data to be decoded, and subsequently, the types of preset parsing protocols can be added to the protocol stack of terminals such as RSU.
[0091] refer to Figure 4 , Figure 4 The following is a diagram showing a process of processing decoded data using a preset parsing protocol or a protocol analysis thread as an example in a specific application example, specifically including:
[0092] Step 401, determining whether the message queue (i.e., the corresponding cache) corresponding to the protocol analysis thread is not empty, if so, executing step 402, if not, repeatedly executing step 401 until receiving a termination instruction;
[0093] Step 402, popping a data unit from the message queue, namely the data to be parsed;
[0094] Step 403, decoding the data unit using a preset parsing protocol corresponding to the protocol analysis thread;
[0095] Step 404, determine whether the decoding is correct, if so, execute step 405, if not, execute step 409;
[0096] Step 405, determining whether the decoded data meets the preset data condition, if yes, executing step 406, if no, executing step 409;
[0097] It is easy to understand that the decoded data may have some characteristic values, such as distance value, data transmission time, etc. These characteristic values can be read directly and obtained through certain processing. For example, in combination with an application scenario, the decoded data may be the position coordinate value of the vehicle. The distance between the vehicle and the RSU can be calculated based on the position coordinate value of the vehicle and the pre-stored position coordinate value of the RSU. For these characteristic values, they can be compared with the corresponding preset data conditions to determine whether the characteristic values meet the preset data conditions.
[0098] Step 406, determining that the decoding is successful, and the decoding process for the data to be decoded is completed;
[0099] Step 407, output the decoding result to the scene layer, wherein the scene layer includes a UseFlag data member, which is mainly used to record whether the protocol analysis thread has successfully performed decoding within the decoding cycle;
[0100] Step 408, set UseFlag to 1, and return to step 401;
[0101] Step 409, determining whether there is a preset parsing protocol for attempting to decode the data to be decoded, if so, executing step 410, if not, executing step 412;
[0102] Step 410, obtaining the next priority protocol message queue interface;
[0103] Step 411, push the data to be decoded into the above-mentioned next priority protocol message queue, and use the protocol analysis process corresponding to the preset parsing protocol of the next priority to attempt to decode the data to be decoded. The specific process is similar to the above steps (Note: Figure 4 Step 411 points to step 401, and the main pointer is similar to the processing flow of the decoded data, but in fact the preset parsing protocol used for decoding has changed);
[0104] Step 412: if the parsing fails, the data to be parsed is discarded, and the process returns to step 401.
[0105] In combination with the above specific application examples, the data analysis method provided in the embodiment of the present invention can maintain communication with vehicle-mounted equipment in multiple protocols through the reasonable layout of each link without sacrificing too much processing efficiency, thereby improving the protocol compatibility of equipment such as RSU, and greatly enhancing the environmental adaptability and intelligence of roadside equipment.
[0106] The embodiment of the present invention further provides a data encoding method, comprising:
[0107] Step 501, in one encoding cycle, obtaining the data to be encoded and the current encoding rule, wherein the current encoding rule corresponds to the updated current decoding rule obtained according to the steps in the data decoding method described in the above embodiment in the decoding cycle matching the current encoding cycle;
[0108] Step 502: Encode the data to be encoded using a preset parsing protocol according to the current encoding rule.
[0109] The data encoding method provided in the embodiment of the present invention is similar to the data parsing method in the above embodiment, and can also be applied to terminals such as RSU, cloud servers or vehicles. The following mainly describes the application in RSU as an example.
[0110] In this embodiment, during the data encoding process, a constantly updated current encoding rule will be used. The current encoding rule and the current decoding rule may have a certain reference relationship. Therefore, it is necessary to determine a matching relationship between the encoding cycle and the above-mentioned decoding cycle so that a suitable current decoding rule can be selected to determine the current encoding rule.
[0111] Taking the case where both the encoding cycle and the decoding cycle are time cycles, and the time cycle is 1 minute, on the time axis, the current encoding rule used in the encoding cycle corresponding to the time period of 1 to 2 minutes can correspond to the current decoding rule updated in the decoding cycle corresponding to the time period of 0 to 1 minute. It is easy to understand that the correspondence between the current encoding rule and the current decoding rule is mainly that the current priority of each preset resolution protocol can be kept consistent, but in the current encoding rule, the current priority of the preset resolution protocol is used to determine its encoding order.
[0112] Of course, in practical applications, the matching relationship between the encoding period and the decoding period can also be set according to actual needs.
[0113] Taking the communication between RSU and vehicle as an example, if RSU receives the data to be decoded sent by a vehicle and successfully decodes the data to be decoded through preset resolution protocol A, it means that the vehicle supports preset resolution protocol A. When the data to be encoded is subsequently sent to the vehicle, RSU can encode the data to be encoded using preset resolution protocol A, and after the vehicle receives the encoded data sent by RSU, it can also decode it using preset resolution protocol A. Therefore, the priority of the preset resolution protocol in the current decoding rule actually reflects the prevalence of the use of each preset resolution protocol by vehicles.
[0114] In this embodiment, during the encoding cycle, a suitable current decoding rule can be selected to determine the current encoding rule, thereby helping to further prioritize the data reception needs of most vehicles; in addition, different preset parsing protocols are used to encode the encoded data separately, which can ensure that different vehicles can receive data that can be successfully decoded.
[0115] Combined with the example of communication between the RSU and the vehicle, it can be seen that in actual applications, in the above step 502, after the data to be encoded is encoded using the preset parsing protocol according to the current encoding rule, the encoded data to be encoded can be further sent, thereby preferentially meeting the data receiving needs of most vehicles.
[0116] Optionally, encoding the data to be encoded using a preset parsing protocol according to the current encoding rule includes:
[0117] According to the current encoding rule, M target resolution protocols are determined from the N preset resolution protocols; N is an integer greater than 1, and M is a positive integer less than or equal to N;
[0118] The data to be encoded is encoded using each of the M target resolution protocols.
[0119] In this embodiment, the M target resolution protocols may refer to preset resolution protocols whose current priority meets certain conditions in the current encoding rules. Since the current encoding rules are dynamically changing, some preset resolution protocols with lower priority are usually preset resolution protocols that have not been used for a long time, that is, in a certain area or a certain time period, there may be no vehicles or other terminals using these preset resolution protocols. Therefore, during the encoding cycle, these preset resolution protocols may not be used to encode the data to be encoded, thereby improving data encoding efficiency and reducing the consumption of computing resources.
[0120] Of course, in practical applications, N preset parsing protocols may all be used within a period of time. Accordingly, within the encoding cycle, N preset parsing protocols may also be used to encode the data to be encoded respectively.
[0121] See also Figure 6 The data sending process in this embodiment is introduced below in conjunction with a specific application example.
[0122] When there is data to be sent (for example, roadside sensing data, traffic light cycle output data, etc.), the sending thread will be awakened. The entire sending process will consider the priority of each preset parsing protocol (corresponding to the Priority maintained in the data decoding process). The protocol with Priority 5 indicates that no external message based on the protocol has been received in multiple cycles, which is the lowest priority. At this time, the encoding and sending process will not be implemented through the protocol encoding method; otherwise, it is considered that there are vehicles with relevant protocols nearby and need to receive relevant protocol data. The protocol encoding method will be extracted in turn to implement message encoding and sending.
[0123] like Figure 7 As shown, the embodiment of the present invention further provides a data decoding device, including:
[0124] The first acquisition module 701 is used to acquire the data to be decoded and the current decoding rule within a decoding cycle, wherein the current decoding rule includes the current priority of each of the N preset resolution protocols, and the current priority is used to determine the decoding order of the preset resolution protocols, where N is an integer greater than 1;
[0125] A decoding module 702, configured to decode the to-be-decoded data in sequence using the N preset parsing protocols according to the current decoding rule;
[0126] The updating module 703 is configured to update the current decoding rule when the data to be decoded is successfully decoded.
[0127] Optionally, the decoding module 702 includes:
[0128] a decoding unit, configured to decode the data to be decoded using the first parsing protocol when the data to be decoded exists in a first buffer corresponding to the first parsing protocol;
[0129] a storing unit, configured to store the data to be decoded into a second cache corresponding to a second parsing protocol when the first parsing protocol fails to decode the data to be decoded;
[0130] The first resolution protocol and the second resolution protocol are any two preset resolution protocols with adjacent current priorities among the N preset resolution protocols, and the current priority of the first resolution protocol is greater than the current priority of the second resolution protocol.
[0131] Optionally, the decoding module 702 includes:
[0132] A judging unit, configured to decode the data to be decoded using a third parsing protocol, and, when initial decoded data is obtained, to judge whether the initial decoded data satisfies a preset data condition;
[0133] A determination unit, configured to determine that the third parsing protocol successfully decodes the data to be decoded if the initial decoded data meets the preset data condition;
[0134] The third resolution protocol is any one of the N preset resolution protocols.
[0135] Optionally, the updating module 703 includes:
[0136] An acquiring unit, used for acquiring a fourth parsing protocol used for successfully decoding the data to be decoded in the current decoding cycle;
[0137] An updating unit is used to increase the current priority of the fourth resolution protocol and / or reduce the current priority of the fifth resolution protocol, wherein the fifth resolution protocol is a preset resolution protocol other than the fourth resolution protocol among the N preset resolution protocols.
[0138] Optionally, the data decoding device further includes:
[0139] The discarding module is used to discard the data to be decoded when each of the N preset parsing protocols fails to successfully decode the data to be decoded.
[0140] It should be noted that the data decoding device is a device corresponding to the above-mentioned data decoding method, and all implementation methods in the above-mentioned method embodiment are applicable to the embodiment of the device and can achieve the same technical effect.
[0141] like Figure 8 As shown, an embodiment of the present invention further provides a data encoding device, comprising:
[0142] The second acquisition module 801 is used to acquire the data to be encoded and the current encoding rule in one encoding cycle, wherein the current encoding rule corresponds to the updated current decoding rule obtained by the above-mentioned data decoding device in the decoding cycle matching the current encoding cycle;
[0143] The encoding module 802 is used to encode the data to be encoded using a preset parsing protocol according to the current encoding rule.
[0144] Optionally, the data encoding device further includes:
[0145] A sending module is used to send the encoded data to be encoded.
[0146] Optionally, the encoding module 802 includes:
[0147] A determination unit, configured to determine M target resolution protocols from the N preset resolution protocols according to the current encoding rule; N is an integer greater than 1, and M is a positive integer less than or equal to N;
[0148] The encoding unit is used to encode the data to be encoded using each of the M target resolution protocols.
[0149] It should be noted that the data encoding device is a device corresponding to the above-mentioned data encoding method, and all implementation methods in the above-mentioned method embodiment are applicable to the embodiment of the device and can achieve the same technical effect.
[0150] It is worth emphasizing that, in the present embodiment, the data encoding device and the data decoding device may be located in the same terminal or in different terminals; when the two are located in different terminals, a communication connection may be established so that the data encoding device can receive information such as the updated current decoding rules and their decoding cycles transmitted by the data decoding device.
[0151] like Fig. 9 As shown, an embodiment of the present invention further provides a terminal device 900, including the above-mentioned data decoding device 901 and the above-mentioned data encoding device 902.
[0152] The terminal device 900 mentioned above may refer to an RSU, a cloud server or a vehicle, etc.
[0153] It is easy to understand that the data decoding device 901 and the data encoding device 902 are mainly associated through a protocol stack, and there may be N preset parsing protocols in the protocol stack, and the N preset parsing protocols can be used to decode the data to be decoded and can also be used to encode the data to be encoded. Through the data decoding device 901, the current priorities of the N preset parsing protocols can be updated, and the data encoding device 902 can select the preset parsing protocol for encoding and the encoding order based on the updated current priority.
[0154] The terminal device 900 provided in this embodiment includes the above-mentioned data decoding device 901 and data encoding device 902, and accordingly, can also obtain the technical effects that can be obtained by the above-mentioned data decoding device 901 and data encoding device 902; in other words, the terminal device provided in this embodiment can effectively improve the efficiency of data decoding and encoding, and help to further improve the data sending effect.
[0155] refer to Fig.10 In a specific application example, the terminal device 900 may be a roadside device 1000, that is, the RSU. By re-dividing or improving the various components of the roadside device 1000, the roadside device 1000 may include a receiving module 1001, a decoding module 1002, a roadside protocol stack 1003, an encoding module 1004, and a sending module 1005; wherein:
[0156] The receiving module 1001 is used to receive data sent from the vehicle. The data may be obtained after being encoded by the onboard unit (OBU) using a corresponding parsing protocol. The parsing protocol may be, for example, the above-mentioned "three-span" version, "four-span" version or a private customized version;
[0157] The decoding module 1002 is used to decode the data sent by the vehicle. Specifically, the decoding module 1002 can call various preset resolution protocols in the roadside protocol stack 1003 to decode the data sent by the vehicle. When decoding, the decoding module 1002 attempts to decode the data in sequence according to the priority of each preset resolution protocol; at the same time, the priority of each preset resolution protocol is modified according to the decoding result, so as to realize the dynamic change of the priority of the preset resolution protocol;
[0158] The roadside protocol stack 1003 is used to store preset resolution protocols and the current priority of each preset resolution protocol;
[0159] The encoding unit 1004 is used to use the preset parsing protocols in the roadside protocol stack 1003 and encode the data to be encoded according to the priority of each preset parsing protocol;
[0160] The sending module 1005 is used to send the encoded data to be encoded in a multicast manner, wherein the encoded data to be encoded may be of different types, and different types correspond to different parsing protocols used during encoding.
[0161] Optionally, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned data decoding method or the above-mentioned data encoding method when executing the computer program.
[0162] Optionally, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements the above-mentioned data decoding method or the above-mentioned data encoding method.
[0163] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A data decoding method, characterized in that: include: In one decoding cycle, the data to be decoded and the current decoding rule are obtained, wherein the current decoding rule includes the current priority of each of the N preset resolution protocols, and the current priority is used to determine the decoding order of the preset resolution protocols, where N is an integer greater than 1; According to the current decoding rule, the to-be-decoded data is decoded in sequence using the N preset parsing protocols; When the data to be decoded is successfully decoded, updating the current decoding rule; When the data to be decoded is successfully decoded, updating the current decoding rule includes: Acquire a fourth parsing protocol for successfully decoding the data to be decoded in the current decoding cycle; Raising the current priority of the fourth resolution protocol, and / or lowering the current priority of the fifth resolution protocol, wherein the fifth resolution protocol is a preset resolution protocol other than the fourth resolution protocol among the N preset resolution protocols; The decoding of the to-be-decoded data in sequence using the N preset parsing protocols according to the current decoding rule includes: Decoding the data to be decoded using a third analysis protocol, and determining whether the initial decoded data satisfies a preset data condition when initial decoded data is obtained, wherein the preset data condition includes a distance condition, and the distance condition is determined according to a communication range of a communication protocol adopted by the drive test unit or a set deviation size; the distance condition corresponds to a distance between the drive test unit and the vehicle calculated by longitude, latitude, and altitude being within a range of 1 kilometer; In the case where the initial decoded data meets the preset data condition, determining that the third parsing protocol successfully decodes the data to be decoded; The third resolution protocol is any one of the N preset resolution protocols.
2. The method according to claim 1, characterized in that The method of sequentially decoding the data to be decoded using the N preset parsing protocols according to the current decoding rule includes: In a case where the data to be decoded exists in a first buffer corresponding to a first resolution protocol, decoding the data to be decoded using the first resolution protocol; If the first parsing protocol fails to decode the data to be decoded, storing the data to be decoded in a second cache corresponding to a second parsing protocol; The first resolution protocol and the second resolution protocol are any two preset resolution protocols with adjacent current priorities among the N preset resolution protocols, and the current priority of the first resolution protocol is greater than the current priority of the second resolution protocol.
3. The method according to claim 1, characterized in that After decoding the data to be decoded in sequence using the N preset parsing protocols according to the current decoding rule, the method further includes: In the case that each of the N preset parsing protocols fails to successfully decode the data to be decoded, the data to be decoded is discarded.
4. A data encoding method, characterized in that: include: In one encoding cycle, the data to be encoded and the current encoding rule are obtained, wherein the current encoding rule corresponds to the updated current decoding rule obtained according to the steps in the data decoding method according to any one of claims 1 to 3 in the decoding cycle matching the current encoding cycle; According to the current encoding rule, the data to be encoded is encoded using a preset parsing protocol.
5. The method according to claim 4, characterized in that The step of encoding the data to be encoded using a preset parsing protocol according to the current encoding rule includes: According to the current encoding rule, M target resolution protocols are determined from the N preset resolution protocols; N is an integer greater than 1, and M is a positive integer less than or equal to N; The data to be encoded is encoded using each of the M target resolution protocols.
6. A data decoding device, characterized in that: include: A first acquisition module, used to acquire to-be-decoded data and a current decoding rule within a decoding cycle, wherein the current decoding rule includes a current priority of each of N preset resolution protocols, wherein the current priority is used to determine a decoding order of the preset resolution protocols, and N is an integer greater than 1; A decoding module, used to decode the to-be-decoded data in sequence using the N preset parsing protocols according to the current decoding rule; An updating module, configured to update the current decoding rule when the data to be decoded is successfully decoded; The update module comprises: An acquiring unit, used for acquiring a fourth parsing protocol used for successfully decoding the data to be decoded in the current decoding cycle; an updating unit, configured to increase the current priority of the fourth resolution protocol, and / or decrease the current priority of the fifth resolution protocol, wherein the fifth resolution protocol is a preset resolution protocol other than the fourth resolution protocol among the N preset resolution protocols; The decoding module comprises: a judgment unit, configured to decode the data to be decoded using a third analysis protocol, and, when obtaining initial decoded data, to judge whether the initial decoded data satisfies a preset data condition, wherein the preset data condition includes a distance condition, and the distance condition is determined according to a communication range of a communication protocol adopted by the drive test unit, or a set deviation size; the distance condition corresponds to a distance between the drive test unit and the vehicle calculated by longitude, latitude, and altitude being within a range of 1 kilometer; A determination unit is used to determine that the third analysis protocol successfully decodes the data to be decoded when the initial decoded data meets the preset data condition; wherein the third analysis protocol is any one of the N preset analysis protocols.
7. A data encoding device, characterized in that: include: A second acquisition module, configured to acquire, within a coding cycle, data to be encoded and a current coding rule, wherein the current coding rule corresponds to an updated current decoding rule obtained by the data decoding device according to claim 6 in a decoding cycle matching the current coding cycle; The encoding module is used to encode the data to be encoded using a preset parsing protocol according to the current encoding rule.
8. A terminal device, characterized in that: It comprises the data decoding device as claimed in claim 6 and the data encoding device as claimed in claim 7.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented, or the method according to claim 4 or 5 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented, or the method according to claim 4 or 5 is implemented.
