Tlv data management method, system and electronic device thereof
Patent Information
- Application Number
- CN202311441907.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-01
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2043-11-01
AI Technical Summary
通过图1可见,基于现有规范内容所定义的结构体代码量庞大、重复代码过多、结构体所占用内存空间极大
Smart Images

Figure CN117609224B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of POS payment technology, and in particular to a TLV data management method, system and electronic device thereof. Background Technology
[0002] In the field of POS payment technology, POS terminal devices and IC cards exchange data using TLV format data. Within POS terminal devices, TLV data is stored and managed in the form of data structures, which are often defined based on certain specifications.
[0003] Figure 1 This is a code diagram illustrating a structure based on the "China Financial Integrated Circuit (IC) Card Specification" in related technologies. For example... Figure 1 As shown, taking the "China Financial Integrated Circuit (IC) Card Specification" as an example, this specification defines a large number of TLV format IC cards and financial terminal (e.g., POS machine) data sources. To enable financial terminals to support the various IC cards involved in the specification, many data attributes (also known as structure "members") are declared in the structure defined by the specification. The memory space occupied by the structure is defined based on the maximum data volume involved in the specification, so that the TLV data resources required by various IC cards can be stored simultaneously in this structure. Through... Figure 1 It is evident that the codebases defined based on existing specifications are massive, contain excessive code duplication, and consume a huge amount of memory. Furthermore, in practical applications, it has been found that whenever the specifications are updated (with additions, deletions, or modifications), the codebases defined based on those specifications need to be modified accordingly, often involving numerous changes, making them prone to errors, and resulting in high maintenance costs. Summary of the Invention
[0004] To effectively improve or even solve at least one of the technical problems existing in related technologies, this disclosure provides a TLV data management method, system, and electronic device thereof.
[0005] In a first aspect, embodiments of this disclosure provide a TLV data management method, including:
[0006] Determine a target TLV data list, wherein the target TLV data list includes at least one target TLV data;
[0007] Define a structure in memory for an independent data space corresponding to the target TLV data list. The members of the structure include: the maximum length configured for the independent data space, the used length of the independent data space, and a pointer to a subsequent TLV data list to be created and operated on, wherein the maximum length is greater than the length of the target TLV data list.
[0008] The target TLV data included in the target TLV data list is stored in the independent data space to obtain the TLV data list to be operated, which includes all TLV data stored in the independent data space.
[0009] Optionally, before the step of determining the target TLV data list, the following steps are also included:
[0010] Determine the target procedure to be selected;
[0011] The steps to determine the target TLV data list include:
[0012] Retrieve all target TLV data corresponding to the target program from the preset memory and construct a target TLV data list;
[0013] After determining the selected target program, and before the step of defining a structure in memory for an independent data space corresponding to the target TLV data list, the method further includes:
[0014] The maximum length of the data space corresponding to the target program is determined based on the pre-set correspondence data, which records different programs and their corresponding maximum data space lengths.
[0015] In the structure of the independent data space corresponding to the target TLV data list, the maximum length configured for the independent data space is the maximum length of the data space corresponding to the target program.
[0016] Optionally, the step of storing the target TLV data included in the target TLV data list into the independent data space includes:
[0017] Obtain data validity verification rule information corresponding to the target program;
[0018] Select the first target TLV data from the target TLV data list as the first TLV data to be verified;
[0019] The validity of the first TLV data to be verified is verified according to the data validity verification rule information.
[0020] When the first TLV data to be verified fails the validity verification, a first prompt message is generated to indicate that the data storage is abnormal.
[0021] When the first TLV data to be verified passes the validity verification, the first TLV data to be verified is stored in the independent data space, and it is detected whether the first TLV data to be verified is the last target TLV data in the target TLV data list.
[0022] If the first TLV data to be verified is detected to be the last target TLV data in the target TLV data list, a second prompt message is generated to indicate that the creation of the TLV data list to be operated on has been completed.
[0023] If it is detected that the first TLV data to be verified is not the last TLV data in the target TLV data list, then the next target TLV data in the target TLV data list that is the first TLV data to be verified is taken as the new first TLV data to be verified, and the step of verifying the validity of the first TLV data to be verified according to the data validity verification rule information is executed again.
[0024] Optionally, after the step of storing the target TLV data included in the target TLV data list into the independent data space, the method further includes:
[0025] Verifying whether the list of TLV data to be operated on is invalid data specifically includes:
[0026] A1. Create a data offset and assign it an initial value of 0;
[0027] A2. Select the first target TLV data from the list of TLV data to be operated as the second TLV data to be verified;
[0028] A3. Increment the data offset by 1 to update the data offset;
[0029] A4. Verify the validity of the second TLV data to be verified according to the preset data validity verification rules;
[0030] If the second TLV data to be verified fails the validity verification, proceed to step A5; if the second TLV data to be verified passes the validity verification, proceed to step A6.
[0031] A5. Delete the second TLV data to be verified from the list of TLV data to be operated on; after step A5 is completed, proceed to step A6;
[0032] A6. Detect whether the second TLV data to be verified is the last target TLV data in the list of TLV data to be operated;
[0033] If the second TLV data to be verified is not the last target TLV data in the list of TLV data to be operated, then proceed to step A7; if the second TLV data to be verified is the last target TLV data in the list of TLV data to be operated, then proceed to step A8.
[0034] A7. Take the next target TLV data in the target TLV data list that is located in the second TLV data to be verified as the new second TLV data to be verified; after step A8, execute step A3 again;
[0035] A8. Compare the length of the current TLV data list to be operated with the current data offset to see if they are equal;
[0036] If they are equal, the TLV data list to be operated on is verified as valid data; if they are not equal, the TLV data list to be operated on is verified as invalid data.
[0037] Optionally, after the step of storing the target TLV data included in the target TLV data list into the independent data space, the method further includes:
[0038] Receive a single data lookup instruction, wherein the single data lookup instruction contains the name of the independent data space, the data tag of the TLV data to be searched, and the search start address;
[0039] In response to the single data lookup instruction, starting from the lookup address, a lookup operation is performed on the list of TLV data to be operated on located in the independent data space according to the data tag of the TLV data to be searched, and the lookup result is returned.
[0040] Optionally, after the step of storing the target TLV data included in the target TLV data list into the independent data space, the method further includes:
[0041] Receive a multi-data search instruction, wherein the multi-data search instruction contains the name of the independent data space, the number of TLV data to be searched, and the data tag of each TLV data to be searched;
[0042] The multiple data lookup instructions are generated according to the multiple data lookup instructions, each corresponding to a TLV data to be looked up. Each single data lookup instruction contains the name of the independent data space and the data tag of the corresponding TLV data to be looked up.
[0043] For each of the single data lookup instructions, in response to the single data lookup instruction, a lookup operation is performed on the list of TLV data to be operated on located in the independent data space according to the data tag of the TLV data to be searched recorded in the single data lookup instruction, and the lookup result is returned.
[0044] Optionally, after the step of storing the target TLV data included in the target TLV data list into the independent data space, the method further includes:
[0045] Receive an add instruction, which contains the name of the independent data space and the TLV data to be added;
[0046] Detect whether there exists a target TLV data in the list of TLV data to be operated that has the same data tag as the data tag in the TLV data to be added;
[0047] If it is detected that there is a target TLV data in the list of TLV data to be operated that contains the same data tag as the data tag in the TLV data to be added, then the data length and data value of the target TLV data that contains the same data tag as the data tag in the TLV data to be added are modified to the data length and data value of the TLV data to be added, respectively.
[0048] If it is detected that there is no target TLV data in the list of TLV data to be operated that contains the same data label as the data label in the TLV data to be added, then the TLV data to be added is added to the end of the list of TLV data to be operated, and the used length of the independent data space is updated.
[0049] Optionally, after the step of storing the target TLV data included in the target TLV data list into the independent data space, the method further includes:
[0050] Receive a deletion instruction, wherein the deletion instruction contains the name of the independent data space and the data tag of the TLV data to be deleted;
[0051] Detect whether there exists a target TLV data in the list of TLV data to be operated on that has the same data tag as the data tag in the TLV data to be deleted;
[0052] If it is detected that there is no target TLV data in the list of TLV data to be operated that contains the same data tag as the data tag in the TLV data to be deleted, a fourth prompt message is generated to indicate that the data deletion has failed.
[0053] If it is detected that there is a target TLV data in the list of TLV data to be operated that contains the same data tag as the data tag in the TLV data to be deleted, then the target TLV data in the list of TLV data to be operated that contains the same data tag as the data tag in the TLV data to be deleted will be deleted, and the other target TLV tags in the list of TLV data to be operated that are located after the target TLV data in the list of TLV data to be operated that contains the same data tag as the data tag in the TLV data to be deleted will be moved to the front, and the used length of the independent data space will be updated.
[0054] In a second aspect, embodiments of this disclosure provide a TLV data management system, the system being configured to implement the method provided in the first aspect, the system comprising:
[0055] The determination module is configured to determine a target TLV data list, wherein the target TLV data list includes at least one target TLV data.
[0056] The definition module is configured to define a structure in memory that corresponds to the target TLV data list. The members of the structure include: the maximum length configured for the independent data space, the used length of the independent data space, and a pointer to the TLV data list to be created later. The maximum length is greater than the length of the target TLV data list.
[0057] The storage module is configured to store the target TLV data included in the target TLV data list into the independent data space to obtain the TLV data list to be operated, wherein the TLV data list to be operated includes all TLV data stored in the independent data space.
[0058] Thirdly, embodiments of this disclosure provide an electronic device, comprising:
[0059] One or more processors;
[0060] Memory, used to store one or more programs;
[0061] When the one or more programs are executed by the one or more processors, the one or more processors implement the method as provided in the first aspect. Attached Figure Description
[0062] Figure 1 This is a code diagram of a structure based on the "China Financial Integrated Circuit (IC) Card Specification" in related technologies;
[0063] Figure 2 A flowchart of a TLV data management method provided in this embodiment of the disclosure;
[0064] Figure 3 This is a code diagram illustrating a structure of an independent data space corresponding to the target TLV data list as defined in an embodiment of this disclosure.
[0065] Figure 4A A flowchart of another TLV data management method provided in this disclosure embodiment;
[0066] Figure 4B This is a flowchart of an optional implementation of step S3 in an embodiment of this disclosure;
[0067] Figure 5 A flowchart illustrating yet another TLV data management method provided in this disclosure embodiment;
[0068] Figure 6 This is a flowchart of an optional implementation of step S4 in an embodiment of this disclosure;
[0069] Figure 7 This is a code diagram of an iteration function in an embodiment of this disclosure;
[0070] Figure 8 A flowchart illustrating yet another TLV data management method provided in this disclosure embodiment;
[0071] Figure 9A This is a code diagram illustrating a lookup function in one of the embodiments disclosed herein;
[0072] Figure 9B This is a schematic diagram illustrating the distribution of data stored in an independent data space in an embodiment of this disclosure;
[0073] Figure 10 A flowchart illustrating yet another TLV data management method provided in this disclosure embodiment;
[0074] Figure 11 A flowchart illustrating yet another TLV data management method provided in this disclosure embodiment;
[0075] Figure 12 This is a code diagram illustrating the addition of a function in one embodiment of this disclosure;
[0076] Figure 13 A flowchart illustrating yet another TLV data management method provided in this disclosure embodiment;
[0077] Figure 14 This is a code diagram illustrating a deletion function in an embodiment of this disclosure;
[0078] Figure 15 A structural block diagram of a TLV data management system provided in this embodiment of the disclosure;
[0079] Figure 16 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0080] To enable those skilled in the art to better understand the technical solutions of this disclosure, the disclosure will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0081] Unless otherwise defined, the technical or scientific terms used in this disclosure shall have the ordinary meaning understood by one of ordinary skill in the art to which this disclosure pertains. The terms “first,” “second,” and similar terms used in this disclosure do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, the terms “an,” “a,” or “the,” and similar terms do not indicate a quantity limitation, but rather indicate the presence of at least one. The terms “including,” “comprising,” or “containing,” and similar terms mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. The terms “connected,” “linked,” or similar terms are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. The terms “upper,” “lower,” “left,” and “right,” etc., are used only to indicate relative positional relationships, and these relative positional relationships may change accordingly when the absolute position of the described object changes.
[0082] In the various figures, the same elements are represented by similar reference numerals. For clarity, not all parts in the figures are drawn to scale. Furthermore, some well-known parts may not be shown in the figures.
[0083] Many specific details of this disclosure, such as the structure, materials, dimensions, processing methods, and techniques of the components, are described below to provide a clearer understanding of the disclosure. However, as those skilled in the art will understand, this disclosure may be implemented without following these specific details.
[0084] Figure 2 A flowchart of a TLV data management method provided in an embodiment of this disclosure. Figure 3 This is a code diagram illustrating a structure of an independent data space corresponding to the target TLV data list as defined in an embodiment of this disclosure. For example... Figure 2 and Figure 3 As shown, the TLV data management method includes:
[0085] Step S1: Determine the target TLV data list, which includes at least one target TLV data.
[0086] Step S2: Define a structure in memory that corresponds to the independent data space of the target TLV data list.
[0087] The structure members include: the maximum length configured for the independent data space, the length already used for the independent data space, and a pointer to the list of TLV data to be created later; the maximum length is greater than the length of the target TLV data list.
[0088] Step S3: Store the target TLV data included in the target TLV data list into an independent data space to obtain the TLV data list to be operated. The TLV data list to be operated includes all TLV data stored in the independent data space.
[0089] It should be noted that the "length" of the data space or list involved in this disclosure specifically refers to the "number of TLV data entries" corresponding to the data space or list. A TLV data entry includes a data tag, a data length, and a data value. For example, the maximum length of an independent data space refers to the maximum number of TLV data entries that the independent data space can store, the used length of an independent data space refers to the number of TLV data entries already stored in the independent data space, and the length of a TLV data list refers to the number of TLV data entries included in the TLV data list.
[0090] Unlike related technologies that directly define structures for storing TLV data based on existing specifications, this disclosure generates a structure for a corresponding independent data space based on a selected target TLV data list. This structure includes only three members: `size` represents the maximum length of the independent data space, `used` represents the used length of the independent data space, and `*data` points to the list of TLV data to be created and operated on, specifically in the format T1.L1.V1.T2.L2.V2…Tn.Ln.Vn. Therefore, the structure defined in this disclosure has less code and is easier to maintain.
[0091] Furthermore, the structure in this disclosure is used to store the selected target TLV data list, meaning its maximum length (size) only needs to be greater than the length of the target TLV data list; therefore, size can be set relatively small. As an optional solution, size can be designed as a fixed value based on practical experience, which can meet the storage needs of various individual "target TLV data lists." For example, taking a POS machine supporting different IC cards as an example, the POS's preset memory pre-stores TLV data lists list_1 to list_n that are used for transactions with different IC cards, such as the TLV data list corresponding to transactions with VISA cards, the TLV data list corresponding to transactions with UnionPay cards, etc. The number of TLV data entries (also called TLV data length) contained in each of the TLV data lists list_1 to list_n is C1 to C_n, where the maximum value among C1 to C_n is denoted as Cmax. In this case, size can be set to Cmax or a value slightly larger than Cmax. As an optional approach, size can be determined based on the number of target TLV data included in the target TLV data list determined in step S1; for example, if the number of target TLV data included in the target TLV data list is C_c, size can be designed as C_c+m, where m is a preset threshold.
[0092] In related technologies, when defining a structure for storing TLV data based on existing specifications, the defined structure occupies C1 + C2 + ... + C_n memory space, and stores the TLV data list corresponding to all IC cards within the structure. Therefore, this structure consumes a large amount of memory. In contrast to related technologies, the technical solution of this disclosure defines the structure based on the actual TLV data list needed (i.e., the target data list), and the independent data space corresponding to this structure only stores the required TLV data, while unused TLV data does not occupy any content, thus saving memory space.
[0093] Figure 4A A flowchart illustrating another TLV data management method provided in this disclosure embodiment. Figure 4A As shown, this is a specific application scenario of the present disclosure, namely, defining the structure and writing the corresponding TLV data into memory based on the target program. This TLV data management method includes not only steps S1 to S3 in the previous embodiments, but also step S01.
[0094] Step S01: Determine the target program to be selected.
[0095] In practical applications, different card organizations require different processing programs. For example, to enable a POS machine to support both UnionPay and VISA cards, the POS machine will have pre-existing processing programs corresponding to UnionPay cards and VISA cards.
[0096] In actual transactions, users can select the corresponding target program on the POS machine based on the type of card to be interacted with, or the POS machine can automatically identify the type of card to be interacted with and then select the corresponding target program themselves.
[0097] As an example scenario, when a POS machine interacts with a UnionPay card, the user can select "UnionPay card" from the list displayed on the POS machine, and then the POS machine will initiate the UnionPay card processing program in response to the user's selection; or, the POS machine can identify the card to be interacted with as "UnionPay card" through contact or contactless identification technology, and then the POS machine will automatically initiate the UnionPay card processing program.
[0098] In some embodiments, step S1 specifically includes: obtaining all target TLV data corresponding to the target program from a preset memory, and forming a target TLV data list.
[0099] The preset memory stores the TLV data corresponding to each processing program (used to support the operation of the corresponding processing program). In response to the determination of the target program in step S01, all target TLV data corresponding to the target program will be automatically retrieved from the preset memory to obtain the target TLV data list. For example, if the target program is determined to be the "UnionPay Card" processing program in step S01, then all TLV data corresponding to the "UnionPay Card" processing program will be determined in step S1, and the TLV data list of the "UnionPay Card" processing program will be obtained.
[0100] In some embodiments, the preset memory includes flash memory.
[0101] In some embodiments, step S02a is included after step S1 and before step S2.
[0102] Step S02a: Determine the maximum length of the data space corresponding to the target program based on the pre-set correspondence data, which records different programs and their corresponding maximum lengths of data space.
[0103] At this point, during step S2, in the structure of the independent data space corresponding to the target TLV data list, the maximum length configured for the independent data space is the maximum length of the data space corresponding to the target program.
[0104] Unlike the previous embodiments where the maximum length of the data space is a fixed value or calculated by a certain algorithm based on the number of target TLV data C_c, in this embodiment, a correspondence between different processing programs and the maximum length of the data space is established in advance. Subsequently, the maximum length of the data space corresponding to the target program can be determined by querying the correspondence data, and this maximum length of the data space is used as the maximum length configured for the independent data space corresponding to the structure defined in step S2.
[0105] Figure 4B This is a flowchart illustrating an optional implementation of step S3 in an embodiment of this disclosure. For example... Figure 4B As shown, in some embodiments, step S3 optionally includes:
[0106] Step S301: Obtain the data validity verification rule information corresponding to the target program.
[0107] In practical applications, different target programs correspond to different types of cards, and each type of card is configured with corresponding TLV data validity verification rules. These rules define the validity requirements for at least one of the data types and / or value ranges of the corresponding TLV data (designed according to the specific circumstances). Based on the data validity verification rules corresponding to the target program, the validity of the corresponding TLV data can be verified.
[0108] Step S302: Select the first target TLV data from the target TLV data list as the first TLV data to be verified.
[0109] Step S303: Perform validity verification on the first TLV data to be verified according to the data validity verification rule information.
[0110] When the first TLV data to be verified fails the validity verification, a first prompt message is generated to indicate that the data was stored abnormally.
[0111] When the first TLV data to be verified passes the validity verification, step S304 is executed.
[0112] Step S304: Store the first TLV data to be verified in an independent data space.
[0113] After step S304 is completed, proceed to step S305.
[0114] Step S305: Detect whether the first TLV data to be verified is the last target TLV data in the target TLV data list.
[0115] If the first TLV data to be verified is detected as the last target TLV data in the target TLV data list, a second prompt message is generated to indicate that the creation of the TLV data list to be operated on has been completed.
[0116] If the first TLV data to be verified is not the last TLV data in the target TLV data list, then proceed to step S306.
[0117] Step S306: Take the next target TLV data in the target TLV data list that is next to the first TLV data to be verified as the new first TLV data to be verified.
[0118] After step S306 is completed, step S303 is executed again.
[0119] By following the steps above, each target TLV data written to the independent memory space can be verified one by one to ensure the validity of the TLV data in the independent memory space.
[0120] Figure 5 A flowchart illustrating yet another TLV data management method provided in this disclosure embodiment. (See flowchart for example.) Figure 5 As shown, another application scenario is to acquire an unknown TLV data segment and manage that unknown TLV data segment.
[0121] Step S1: Determine the target TLV data list, which includes at least one target TLV data.
[0122] The aforementioned acquired unknown TLV data constitutes the target TLV data list.
[0123] Step S2: Define a structure in memory that corresponds to the independent data space of the target TLV data list.
[0124] The structure members include: the maximum length (size) configured for the independent data space, the used length (used) of the independent data space, and a pointer (*data) to the list of TLV data to be created later. In this case, the maximum length (size) can be slightly larger than the length of the target TLV data list.
[0125] Step S3: Store the target TLV data included in the target TLV data list into an independent data space. All target TLV data stored in the independent data space constitute the TLV data list to be operated.
[0126] In step S3, the target TLV data in the target TLV data list is directly stored in an independent data space, and the validity verification is not performed using steps S301 to S306 in the previous embodiment.
[0127] At this point, step S4 is included after step S3.
[0128] Step S4: Verify whether the TLV data list to be operated on is invalid data.
[0129] Figure 6 This is a flowchart of an optional implementation of step S4 in an embodiment of this disclosure. Figure 7 This is a code illustration of an iteration function in an embodiment of this disclosure. For example... Figure 6 and Figure 7 As shown, based on Figure 7 The iterative function shown can achieve Figure 6 The method shown. Optionally, in some embodiments, step S4 includes:
[0130] A1. Create a data offset and assign it an initial value of 0.
[0131] A2. Select the first target TLV data from the list of TLV data to be operated on as the second TLV data to be verified.
[0132] A3. Increment the data offset by 1 to update the data offset.
[0133] A4. Verify the validity of the second TLV data to be verified according to the preset data validity verification rules.
[0134] The process of validating TLV data based on data validity verification rule information is a conventional technique in this field and will not be elaborated here.
[0135] If the second TLV data to be verified fails the validity verification, proceed to step A5; if the second TLV data to be verified passes the validity verification, proceed to step A6.
[0136] A5. Remove the second TLV data to be verified from the list of TLV data to be operated on.
[0137] After step A5 is completed, proceed to step A6.
[0138] A6. Check whether the second TLV data to be verified is the last target TLV data in the list of TLV data to be operated on.
[0139] If the second TLV data to be verified is not the last target TLV data in the list of TLV data to be operated, then proceed to step A7; if the second TLV data to be verified is the last target TLV data in the list of TLV data to be operated, then proceed to step A8.
[0140] A7. Take the next target TLV data in the target TLV data list that is next to the second TLV data to be verified as the new second TLV data to be verified; after step A8, execute step A3 again.
[0141] A8. Compare the length of the current TLV data list to be operated on with the current data offset to see if they are equal.
[0142] If they are equal, the TLV data list to be operated on is verified as valid; if they are not equal, the TLV data list to be operated on is verified as invalid.
[0143] Figure 8 A flowchart of another TLV data management method provided in an embodiment of this disclosure. Figure 9A This is a code diagram illustrating a lookup function in one of the embodiments disclosed herein. Figure 9B This is a schematic diagram illustrating the distribution of data stored in an independent data space according to an embodiment of this disclosure. For example... Figure 8 , Figure 9A , Figure 9B As shown, in some embodiments, this TLV data management method not only includes steps S1 to S3 in the preceding embodiments, but also includes steps S5a and S5b after step S3 to search for TLV data from the list of TLV data to be operated; based on Figure 9A The lookup function shown can search for TLV data from the list of TLV data to be operated on. Only steps S5a to S5b are described in detail below.
[0144] Step S5a: Receive a single data lookup instruction. The single data lookup instruction contains the name of the independent data space, the data tag of the TLV data to be searched, and the start address of the search.
[0145] Step S5b: In response to the single data lookup instruction, start from the lookup address and perform a lookup operation on the list of TLV data to be operated on in the independent data space according to the data tag of the TLV data to be searched, and return the lookup result.
[0146] Figure 9 is a schematic diagram illustrating the distribution of data stored in the independent data space according to an embodiment of this disclosure. As shown in Figure 9, in some embodiments, the independent data space includes not only the list of TLV data to be operated but also other information; for example, list information of the TLV data list to be operated, which records information such as the maximum length and current length of the TLV data list to be operated. This other information is located at the beginning of the independent data space, while the TLV data list to be operated is located after the other information. The search start address can characterize the starting position in the independent data space used to store the TLV data in the TLV data list to be operated. By identifying the search start address, the TLV data list to be operated can be quickly located during a TLV data search operation, which helps to improve the search speed.
[0147] It should be noted that in different application scenarios, the starting address for searching in independent data spaces can be the same or different.
[0148] Figure 10 A flowchart illustrating yet another TLV data management method provided in this disclosure embodiment. Figure 10 As shown, in some embodiments, the TLV data management method not only includes steps S1 to S3 in the previous embodiments, but also includes steps S6a to S6c after step S3.
[0149] Step S6a: Receive multiple data lookup instructions.
[0150] The multi-data lookup instruction contains the name of the independent data space, the number of TLV data to be searched, and the data label of each TLV data to be searched.
[0151] Step S6b: Generate multiple single data lookup instructions that correspond one-to-one with the TLV data to be searched, based on the multiple data lookup instructions.
[0152] The single data lookup instruction contains the name of the independent data space and the data tag of the corresponding TLV data to be searched.
[0153] In some embodiments, as described in the preceding embodiments, the single data lookup instruction also includes a lookup start address.
[0154] Step S6c: For each single data lookup instruction, in response to the single data lookup instruction, perform a lookup operation on the list of TLV data to be operated on located in the independent data space according to the data tag of the TLV data to be searched recorded in the single data lookup instruction, and return the lookup result.
[0155] In this embodiment of the disclosure, a multi-data lookup instruction can be decomposed into multiple single-data lookup instructions, and then each single-data lookup instruction can be executed to perform the corresponding lookup operation.
[0156] Figure 11 A flowchart of another TLV data management method provided in an embodiment of this disclosure. Figure 12 This is a code illustration illustrating the addition of a function in one embodiment of this disclosure. For example... Figure 11 and Figure 12 As shown, in some embodiments, the TLV data management method not only includes steps S1 to S3 in the preceding embodiments, but also includes steps S7a to S7d after step S3 to add TLV data to the TLV data list to be operated; based on Figure 12 The function shown can add TLV data to the TLV data list to be operated on. Only steps S7a to S7d are described in detail below.
[0157] Step S7a: Receive the add command.
[0158] The addition instruction contains the name of the independent data space and the TLV data to be added.
[0159] Step S7b: Detect whether there is a target TLV data in the list of TLV data to be operated that contains the same data label as the data label in the TLV data to be added.
[0160] If a target TLV data with the same data tag as the data tag in the TLV data to be added is detected in the list of TLV data to be operated, then proceed to step S7c. If a target TLV data with the same data tag as the data tag in the TLV data to be added is not detected in the list of TLV data to be operated, then proceed to step S7d.
[0161] Step S7c: Modify the data length and data value of the target TLV data that contain data tags that are the same as the data tags in the TLV data to be added, respectively, to the data length and data value in the TLV data to be added.
[0162] Step S7d: Add the TLV data to be added to the end of the list of TLV data to be operated on, and update the used length of the independent data space.
[0163] In some embodiments, before adding the TLV data to be added to the end of the TLV data list to be operated, it is necessary to determine whether the used length is equal to the maximum length size. If the two are equal, a third prompt message is generated to indicate that the independent data space is full. If the two are not equal, the step of adding the TLV data to be added to the end of the TLV data list to be operated is performed.
[0164] Figure 13 A flowchart of another TLV data management method provided in an embodiment of this disclosure. Figure 14 This is a code illustration of a deletion function in an embodiment of this disclosure. For example... Figure 13 and Figure 14 As shown, in some embodiments, the TLV data management method not only includes steps S1 to S3 in the preceding embodiments, but also includes steps S8a to S8c after step S3 to delete TLV data from the TLV data list to be operated; based on Figure 14 The deletion function shown can delete TLV data from the list of TLV data to be operated on. Only steps S8a to S8c are described in detail below.
[0165] Step S8a: Receive deletion command.
[0166] The deletion instruction contains the name of the independent data space and the data tag of the TLV data to be deleted.
[0167] Step S8b: Detect whether there is a target TLV data in the list of TLV data to be operated that contains the same data label as the data label in the TLV data to be deleted.
[0168] If it is detected that there is no target TLV data in the list of TLV data to be operated that contains the same data tag as the data tag in the TLV data to be added, a fourth prompt message is generated to indicate that the data deletion has failed.
[0169] If a target TLV with the same data label as the data label in the TLV data to be deleted is detected in the list of TLV data to be operated, then step S8c is executed.
[0170] Step S8c: Delete the target TLV data whose data labels in the TLV data list to be operated are the same as the data labels in the TLV data to be deleted, and move the other target TLV labels in the TLV data list to be operated before the target TLV data whose data labels are the same as the data labels in the TLV data to be deleted, and update the used length of the independent data space.
[0171] As can be seen from the preceding embodiments, the technical solution disclosed herein can perform operations such as adding, deleting, searching, and checking the validity of TLV data stored in an independent data space.
[0172] It should be noted that the different steps in the above-mentioned TLV data management method embodiments can be combined with each other, and the new technical solutions obtained by such combination should fall within the protection scope of this disclosure.
[0173] Figure 15 This is a structural block diagram of a TLV data management system provided in an embodiment of this disclosure. Figure 15As shown, based on the same inventive concept, this disclosure also provides a TLV data management system, which can be used to implement the TLV data management method provided in any of the preceding embodiments. The TLV data management system includes: a determination module 1, a definition module 2, and a storage module 3.
[0174] The determination module 1 is configured to determine the target TLV data list, which includes at least one target TLV data.
[0175] Module 2 is configured to define a structure in memory that provides an independent data space corresponding to the target TLV data list. The structure members include: the maximum length of the independent data space, the length of the independent data space already used, and a pointer to the TLV data list to be created later. The maximum length is greater than the length of the target TLV data list.
[0176] Storage module 3 is configured to store the target TLV data included in the target TLV data list into an independent data space to obtain the TLV data list to be operated. The TLV data list to be operated includes all TLV data stored in the independent data space.
[0177] For a detailed description of each of the above modules, please refer to the content in the previous embodiments, which will not be repeated here.
[0178] In some embodiments, the TLV data management system further includes an operation module 4, which can be used to perform operations such as adding, deleting, searching, and checking the validity of TLV data stored in an independent data space (i.e., performing some steps after step S3 in the previous embodiments).
[0179] Based on the same inventive concept, this disclosure also provides an electronic device. Figure 16 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Figure 16 As shown, this disclosure provides an electronic device including: one or more processors 101, a memory 102, and one or more I / O interfaces 103. The memory 102 stores one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement any of the TLV data management methods described in the above embodiments; the one or more I / O interfaces 103 are connected between the processor and the memory, configured to enable information interaction between the processor and the memory.
[0180] The processor 101 is a device with data processing capabilities, including but not limited to a central processing unit (CPU); the memory 102 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), and flash memory (FLASH); the I / O interface (read / write interface) 103 is connected between the processor 101 and the memory 102, and can realize information interaction between the processor 101 and the memory 102, including but not limited to a data bus (Bus).
[0181] In some embodiments, the processor 101, memory 102, and I / O interface 103 are interconnected via bus 104, and thus connected to other components of the computing device.
[0182] In some embodiments, the one or more processors 101 include a field-programmable gate array.
[0183] According to embodiments of this disclosure, a computer-readable medium is also provided. This computer-readable medium stores a computer program, which, when executed by a processor, implements the steps of any of the TLV data management methods described in the above embodiments.
[0184] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a machine-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), it performs the functions defined above in the system of this disclosure.
[0185] It should be noted that the computer-readable medium disclosed herein may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0186] It is understood that the above embodiments are merely exemplary embodiments used to illustrate the principles of this disclosure, and this disclosure is not limited thereto. For those skilled in the art, various modifications and improvements can be made without departing from the spirit and substance of this disclosure, and these modifications and improvements are also considered to be within the scope of protection of this disclosure.
Claims
1. A TLV data management method, characterized in that, include: Determine a target TLV data list, wherein the target TLV data list includes at least one target TLV data; Define a structure in memory for an independent data space corresponding to the target TLV data list. The members of the structure include: the maximum length configured for the independent data space, the used length of the independent data space, and a pointer to a subsequent TLV data list to be created and operated on, wherein the maximum length is greater than the length of the target TLV data list. The target TLV data included in the target TLV data list is stored in the independent data space to obtain the TLV data list to be operated, and the TLV data list to be operated includes all TLV data stored in the independent data space; Before determining the target TLV data list, the following steps are also included: Determine the target procedure to be selected; The steps to determine the target TLV data list include: Retrieve all target TLV data corresponding to the target program from the preset memory and construct a target TLV data list; After determining the selected target program, and before the step of defining a structure in memory for an independent data space corresponding to the target TLV data list, the method further includes: The maximum length of the data space corresponding to the target program is determined based on the pre-set correspondence data, which records different programs and their corresponding maximum data space lengths. In the structure of the independent data space corresponding to the target TLV data list, the maximum length configured for the independent data space is the maximum length of the data space corresponding to the target program; The step of storing the target TLV data included in the target TLV data list into the independent data space includes: Obtain data validity verification rule information corresponding to the target program; Select the first target TLV data from the target TLV data list as the first TLV data to be verified; The validity of the first TLV data to be verified is verified according to the data validity verification rule information. When the first TLV data to be verified fails the validity verification, a first prompt message is generated to indicate that the data storage is abnormal. When the first TLV data to be verified passes the validity verification, the first TLV data to be verified is stored in the independent data space, and it is detected whether the first TLV data to be verified is the last target TLV data in the target TLV data list. If the first TLV data to be verified is detected to be the last target TLV data in the target TLV data list, a second prompt message is generated to indicate that the creation of the TLV data list to be operated on has been completed. If it is detected that the first TLV data to be verified is not the last TLV data in the target TLV data list, then the next target TLV data in the target TLV data list that is the first TLV data to be verified is taken as the new first TLV data to be verified, and the step of verifying the validity of the first TLV data to be verified according to the data validity verification rule information is executed again.
2. The method according to claim 1, characterized in that, After the step of storing the target TLV data included in the target TLV data list into the independent data space, the method further includes: Verifying whether the list of TLV data to be operated on is invalid data specifically includes: A1. Create a data offset and assign it an initial value of 0; A2. Select the first target TLV data from the list of TLV data to be operated as the second TLV data to be verified; A3. Increment the data offset by 1 to update the data offset; A4. Verify the validity of the second TLV data to be verified according to the preset data validity verification rules; If the second TLV data to be verified fails the validity verification, proceed to step A5; if the second TLV data to be verified passes the validity verification, proceed to step A6. A5. Delete the second TLV data to be verified from the list of TLV data to be operated on; after step A5 is completed, proceed to step A6; A6. Detect whether the second TLV data to be verified is the last target TLV data in the list of TLV data to be operated; If the second TLV data to be verified is not the last target TLV data in the list of TLV data to be operated, then proceed to step A7; if the second TLV data to be verified is the last target TLV data in the list of TLV data to be operated, then proceed to step A8. A7. Take the next target TLV data in the target TLV data list that is located next to the second TLV data to be verified as the new second TLV data to be verified; after step A8, execute step A3 again; A8. Compare the length of the current TLV data list to be operated with the current data offset to see if they are equal; If they are equal, the TLV data list to be operated on is verified as valid data; if they are not equal, the TLV data list to be operated on is verified as invalid data.
3. The method according to claim 1 or 2, characterized in that, After the step of storing the target TLV data included in the target TLV data list into the independent data space, the method further includes: Receive a single data lookup instruction, wherein the single data lookup instruction contains the name of the independent data space, the data tag of the TLV data to be searched, and the search start address; In response to the single data lookup instruction, starting from the lookup start address, a lookup operation is performed on the list of TLV data to be operated on located in the independent data space according to the data tag of the TLV data to be searched, and the lookup result is returned.
4. The method according to claim 1 or 2, characterized in that, After the step of storing the target TLV data included in the target TLV data list into the independent data space, the method further includes: Receive a multi-data search instruction, wherein the multi-data search instruction contains the name of the independent data space, the number of TLV data to be searched, and the data tag of each TLV data to be searched; The multiple data lookup instructions are generated according to the multiple data lookup instructions, each corresponding to a TLV data to be looked up. Each single data lookup instruction contains the name of the independent data space and the data tag of the corresponding TLV data to be looked up. For each of the single data lookup instructions, in response to the single data lookup instruction, a lookup operation is performed on the list of TLV data to be operated on located in the independent data space according to the data tag of the TLV data to be searched recorded in the single data lookup instruction, and the lookup result is returned.
5. The method according to claim 1 or 2, characterized in that, After the step of storing the target TLV data included in the target TLV data list into the independent data space, the method further includes: Receive an add instruction, which contains the name of the independent data space and the TLV data to be added; Detect whether there exists a target TLV data in the list of TLV data to be operated that has the same data tag as the data tag in the TLV data to be added; If it is detected that there is a target TLV data in the list of TLV data to be operated that contains the same data tag as the data tag in the TLV data to be added, then the data length and data value of the target TLV data that contains the same data tag as the data tag in the TLV data to be added are modified to the data length and data value of the TLV data to be added, respectively. If it is detected that there is no target TLV data in the list of TLV data to be operated that contains the same data label as the data label in the TLV data to be added, then the TLV data to be added is added to the end of the list of TLV data to be operated, and the used length of the independent data space is updated.
6. The method according to claim 1, characterized in that, After the step of storing the target TLV data included in the target TLV data list into the independent data space, the method further includes: Receive a deletion instruction, wherein the deletion instruction contains the name of the independent data space and the data tag of the TLV data to be deleted; Detect whether there exists a target TLV data in the list of TLV data to be operated on that has the same data tag as the data tag in the TLV data to be deleted; If it is detected that there is no target TLV data in the list of TLV data to be operated that contains the same data tag as the data tag in the TLV data to be deleted, a fourth prompt message is generated to indicate that the data deletion has failed. If it is detected that there is a target TLV data in the list of TLV data to be operated that contains the same data tag as the data tag in the TLV data to be deleted, then the target TLV data in the list of TLV data to be operated that contains the same data tag as the data tag in the TLV data to be deleted will be deleted, and the other target TLV tags in the list of TLV data to be operated that are located after the target TLV data in the list of TLV data to be operated that contains the same data tag as the data tag in the TLV data to be deleted will be moved to the front, and the used length of the independent data space will be updated.
7. An electronic device, characterized in that, include: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and device for data transmission, readable storage medium and equipment
CN115277725A