CN106528053A - Terminal device and efficient data processing method thereof - Google Patents
Terminal device and efficient data processing method thereof Download PDFInfo
- Publication number
- CN106528053A CN106528053A CN201710003731.5A CN201710003731A CN106528053A CN 106528053 A CN106528053 A CN 106528053A CN 201710003731 A CN201710003731 A CN 201710003731A CN 106528053 A CN106528053 A CN 106528053A
- Authority
- CN
- China
- Prior art keywords
- instruction
- module
- current
- data
- command message
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000003672 processing method Methods 0.000 title abstract description 6
- 238000000034 method Methods 0.000 claims abstract description 85
- 230000008569 process Effects 0.000 claims abstract description 23
- 230000004044 response Effects 0.000 claims description 63
- 238000000926 separation method Methods 0.000 claims description 40
- 238000001514 detection method Methods 0.000 claims description 14
- 230000003993 interaction Effects 0.000 abstract description 8
- 238000010586 diagram Methods 0.000 description 2
- 238000005192 partition Methods 0.000 description 2
- 238000000547 structure data Methods 0.000 description 2
- 238000006467 substitution reaction Methods 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30003—Arrangements for executing specific machine instructions
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/10—Program control for peripheral devices
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer And Data Communications (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention discloses a terminal device and an efficient data processing method thereof, and belongs to the field of communication. The efficient data processing method of the terminal device comprises the steps of, by the terminal device, receiving a command message sent by an upper computer, reading instruction sequences in the command message, and carrying out corresponding operations sequentially based on the instruction sequences to obtain a series of operation results; or by the terminal device, reading the instruction sequences in the command message, sending the instruction sequences to a card sequentially, and receiving a series of operation results returned by the card; and when all the instruction sequences in the command message are processed, returning the operation results to the upper computer by the terminal device. According to the technical scheme of the invention, as multiple instructions are contained in one command message in the process of data interaction between the terminal device and the upper computer, processing of multiple instructions can be finished through one exchange, and the data processing efficiency of the terminal device is increased.
Description
Technical Field
The present invention relates to the field of communications, and in particular, to a method for efficiently processing data of a terminal device and a terminal device thereof.
Background
The data processing is the collection, storage, retrieval, processing, transformation and transmission of data, and the data is an expression form of facts, concepts or instructions and can be processed by manual or automatic devices; data processing is a basic link of upper computer engineering and automatic control, the data processing runs through various fields of social production and social life, and the development of a data processing technology and the application breadth and depth thereof greatly influence the development process of the human society.
In the prior art, in a data interaction system formed by a terminal device and an upper computer, a data processing process usually completes processing of one instruction by one-time interaction, and for a complex data processing process, multiple interactions need to be performed, so that more time is consumed, and the data processing efficiency is low.
Disclosure of Invention
The invention provides a terminal device and a high-efficiency data processing method thereof in order to overcome the defects of the prior art.
In one aspect, the present invention provides a method for processing high-efficiency data of a terminal device, including:
step S1: the terminal equipment receives a command message sent by an upper computer;
step S2: the terminal equipment reads the instruction sequence in the command message and sequentially executes corresponding operations according to the instruction sequence to obtain a series of operation results; or the terminal equipment reads the instruction sequence in the command message, sequentially sends the instruction sequence to a card and receives a series of operation results returned by the card;
step S3: and when the instruction sequence in the command message is completely processed, the terminal equipment returns the operation result to the upper computer.
Optionally, before the step S2, the method further includes: the terminal equipment judges whether the command message is correct or not, if so, the step S2 is executed; otherwise, returning an error code to the upper computer, and ending.
The terminal device judges whether the command message is correct, specifically:
the terminal equipment judges whether the length of data on a first preset byte in the command message is equal to the total length of each data element corresponding to the instruction sequence in the command message, if so, the command message is confirmed to be correct, otherwise, the command message is confirmed to be incorrect;
or,
and the terminal equipment judges whether the length of the data on the first preset byte in the command message is equal to the total length of the instruction sequence and each separation mark in the command message, if so, the command message is confirmed to be correct, and if not, the command message is confirmed to be incorrect.
Optionally, in step S2, the reading, by the terminal device, the instruction sequence in the command message includes:
the terminal equipment analyzes the command message to obtain each data element, and reads an instruction in each data element to obtain an instruction sequence;
or,
and the terminal equipment analyzes the command message to obtain each separation identifier, and reads an instruction according to each obtained separation identifier to obtain an instruction sequence.
Optionally, the step S2 specifically includes:
step W1: the terminal device takes an unread instruction in the instruction sequence in the command message as current data to be processed, reads a first instruction in the current data to be processed, and takes the first instruction as a current instruction;
step W2: the terminal equipment executes corresponding operation according to the current instruction to obtain an operation result; or sending the current instruction to a card and receiving an operation result returned by the card;
the step S3 specifically includes: the terminal equipment judges whether the current instruction is the last instruction in the current data to be processed, if so, the terminal equipment confirms that the instruction sequence in the command message is completely processed, and returns the operation result to the upper computer; otherwise, return to step W1.
Optionally, the step S2 specifically includes:
step Q1: the terminal device takes an unread instruction in the instruction sequence in the command message as current data to be analyzed, reads a first instruction in the current data to be analyzed, and stores the read instruction sequence in a preset storage area;
step Q2: the terminal equipment judges whether the read instruction is the last instruction in the current data to be analyzed, if so, the step Q3 is executed, otherwise, the step Q1 is returned;
step Q3: the terminal equipment takes the instruction in the preset storage area as current data to be processed, reads a first instruction in the current data to be processed as a current instruction, and executes corresponding operation according to the current instruction to obtain an operation result; or sending the current instruction to a card and receiving an operation result returned by the card;
step Q4: the terminal equipment removes the current instruction from the preset storage area;
the step S3 specifically includes: the terminal equipment judges whether instructions exist in the preset storage area or not, if yes, the step returns to the step Q3; and if not, confirming that the instruction sequence in the command message is completely processed, and returning the operation result to the upper computer.
Optionally, the step S2 of simultaneously running the first thread and the second thread in the terminal device specifically includes:
the terminal equipment runs the first thread and executes the following operations:
step H1: the terminal device takes an unread instruction in the instruction sequence in the command message as current data to be analyzed, reads a first instruction in the current data to be analyzed, and stores the read instruction sequence in a preset storage area;
step H2: the terminal equipment judges whether the read instruction is the last instruction in the current data to be analyzed, if so, the operation is finished, otherwise, the operation returns to the step H1;
the terminal equipment runs the second thread and executes the following operations:
step R1: the terminal device accesses the preset storage area, and when detecting that the preset storage area has an instruction, the step R2 is executed;
step R2: the terminal device takes the instruction in the preset storage area as current data to be processed, and reads a first instruction in the current data to be processed as a current instruction; executing corresponding operation according to the current instruction to obtain an operation result; or sending the current instruction to a card and receiving an operation result returned by the card;
step R3: the terminal equipment removes the current instruction from the preset storage area;
the step S3 specifically includes: the terminal equipment judges whether instructions exist in the preset storage area or not, if yes, the step R2 is returned; and if not, confirming that the instruction sequence in the command message is completely processed, and returning the operation result to the upper computer.
Optionally, in step S2, before the sending the instruction sequence to the card in sequence, the method further includes:
step D1: and the terminal equipment judges whether the data on the first byte in the data element corresponding to the current instruction to be sent is a first preset value, if so, the card resetting operation is executed, the operation result returned by the card is received, and if not, the current instruction to be sent is sent to the card, and the operation result returned by the card is received.
Optionally, in step S2, when the operation result returned by the card is an operation failure, the method further includes:
step F1: the terminal device judges whether the instruction corresponding to the operation failure result is the last instruction in the instruction sequence, if so, the terminal device confirms that all processing of the instruction sequence in the command message is completed, and step S3 is executed; otherwise, executing step F2;
step F2: and the terminal equipment judges whether to continuously read the unread instruction in the instruction sequence, if so, the step S2 is continuously executed, otherwise, the received operation result is returned to the upper computer, and the operation is finished.
Optionally, the determining, by the terminal device, whether to continue reading the unread instruction in the instruction sequence includes:
the terminal equipment performs AND operation on data on a third preset byte in a data element corresponding to the instruction corresponding to the operation failure result and a second preset value to obtain an operation result, converts the operation result into a binary representation, judges whether data on the highest position in the operation result of the binary representation is first preset data, if so, confirms to continuously read the unread instruction in the instruction sequence, and otherwise, confirms to not continuously read the unread instruction in the instruction sequence;
or,
and the terminal equipment judges whether the data on the fourth preset byte in the data element corresponding to the instruction corresponding to the operation failure result is a third preset value, if so, the terminal equipment confirms to continue to read the unread instruction in the instruction sequence, and otherwise, the terminal equipment confirms not to continue to read the unread instruction in the instruction sequence.
Optionally, the step S2, further includes: when one of the instructions in the instruction sequence fails to process, executing the step M;
step M: and the terminal equipment sequentially splices the currently obtained operation results or the currently received operation results, corresponds to the number of unprocessed instructions in the instruction sequence, fills second preset data with the same number after the spliced operation results to obtain a response message, and returns the response message to the upper computer.
Optionally, the step S2, further includes: when one of the instructions in the instruction sequence fails to process, executing the step N;
and step N: and the terminal equipment returns an error code to the upper computer, and the operation is finished.
Optionally, in step S2, after the terminal device reads the instruction sequence in the command message, the method further includes:
the terminal equipment updates the counting identification according to a preset mode;
when one of the instructions in the instruction sequence fails to process, executing the step L;
step L: and the terminal equipment returns a failure operation result and the current count value of the count identification to the upper computer together, and the operation is finished.
Optionally, in step S2, the method further includes: and when the operation result received by the terminal equipment is smaller than a fourth preset value, returning the received operation result to the upper computer, and ending.
Optionally, in step S2, when the terminal device reads the first instruction in the instruction sequence, before sending the read instruction to the card, the method further includes:
step P: the terminal equipment judges the card type, executes card selection operation according to the card type, and sends the read instruction to the card if the operation is successful; and if the operation fails, returning an error code to the upper computer, and ending.
Optionally, in step S3, the terminal device returns the operation result to the upper computer, specifically:
the terminal equipment sequentially splices the operation results of the series of data element structures to obtain a response message, and returns the response message to the upper computer;
or,
the terminal equipment sequentially splices the series of operation results, adds a preset separation mark between every two adjacent operation results to obtain a response message, and returns the response message to the upper computer;
or,
and the last operation result in the series of operation results of the terminal equipment is returned to the upper computer.
In another aspect, the present invention provides a high-efficiency data processing terminal device, including:
the device comprises a first receiving module, a first reading module, an executing module and a first sending module;
or,
the first receiving module, the first reading module, the first sending module, the second sending module and the second receiving module;
the first receiving module is used for receiving a command message sent by the upper computer;
the first reading module is used for reading the instruction sequence in the command message received by the first receiving module;
the execution module is used for sequentially executing corresponding operations according to the instruction sequence read by the first reading module to obtain a series of operation results;
the second sending module is used for sequentially sending the instruction sequence read by the first reading module to a card;
the second receiving module is used for receiving the operation result returned by the card;
and the first sending module is used for returning an operation result to the upper computer when the instruction sequence in the command message is completely processed.
Optionally, the terminal device further includes: a first judgment module;
the first judging module is configured to judge whether the command message received by the first receiving module is correct before the first reading module reads the instruction sequence in the command message received by the first receiving module;
the first reading module is specifically configured to: when the first judging module judges that the command message received by the first receiving module is correct, reading an instruction sequence in the command message received by the first receiving module;
and the first sending module is also used for returning an error code to the upper computer and ending when the first judging module judges that the command message received by the first receiving module is incorrect.
Optionally, the first determining module is specifically configured to:
judging whether the length of the data on the first preset byte in the command message is equal to the total length of each data element corresponding to the instruction sequence in the command message, if so, confirming that the command message is correct, otherwise, confirming that the command message is incorrect;
or,
and judging whether the length of the data on the first preset byte in the command message is equal to the total length of the instruction sequence and each separation mark in the command message, if so, determining that the command message is correct, and otherwise, determining that the command message is incorrect.
Optionally, the first reading module is specifically configured to:
analyzing the command message to obtain each data element, and reading an instruction in each data element to obtain an instruction sequence;
or,
and analyzing the command message to obtain each separation identifier, and reading an instruction according to each obtained separation identifier to obtain an instruction sequence.
Optionally, the terminal device further includes: a second judgment module;
the first reading module is specifically configured to: taking an unread instruction in an instruction sequence in the command message as current data to be processed, reading a first instruction in the current data to be processed, and taking the first instruction as a current instruction;
the execution module is specifically configured to: executing corresponding operation according to the current instruction to obtain an operation result;
the second sending module is specifically configured to: sending the current instruction to a card;
the second judgment module is specifically configured to: judging whether the current instruction is the last instruction in the current data to be processed;
the first sending module is specifically configured to: when the second judging module judges that the current instruction is the last instruction in the current data to be processed, the second judging module confirms that all instruction sequences in the command message are processed, and returns an operation result to the upper computer;
the first reading module is further configured to, when the second determining module determines that the current instruction is not the last instruction in the current data to be processed, take an instruction that is not read from the instruction sequence in the command message as the current data to be processed, and read the first instruction in the current data to be processed as the current instruction.
Optionally, the terminal device further includes: the device comprises a first storage module, a second judgment module, a second reading module, a first removal module and a third judgment module;
the first reading module is used for taking an unread instruction in the instruction sequence in the command message as current data to be analyzed and reading a first instruction in the current data to be analyzed;
the first storage module is used for storing the order of the instructions read by the first reading module into a preset storage area;
the second judging module is used for judging whether the instruction read by the first reading module is the last instruction in the current data to be analyzed;
the first reading module is further configured to, when the second determining module determines that the instruction read by the first reading module is not the last instruction in the current data to be analyzed, take an instruction not read in the instruction sequence in the command message as the current data to be analyzed, and read a first instruction in the current data to be analyzed;
the second reading module is configured to, when the second determining module determines that the instruction read by the first reading module is the last instruction in the current data to be analyzed, take the instruction in the preset storage area as the current data to be processed, and read the first instruction in the current data to be processed as the current instruction;
the execution module is used for executing corresponding operation according to the current instruction read by the second reading module to obtain an operation result;
the second sending module is specifically configured to: sending the current instruction read by the second reading module to a card;
the first removing module is used for removing the current instruction from the preset storage area after the executing module executes corresponding operation according to the current instruction to obtain an operation result; the second receiving module is further used for removing the current instruction from the preset storage area after receiving an operation result returned by the card;
the third judging module is used for judging whether the preset storage area has instructions after the current instructions are removed from the preset storage area by the first removing module;
the second reading module is further configured to, when the third determining module determines that there is an instruction in the preset storage area, take the instruction in the preset storage area as current data to be processed, and read a first instruction in the current data to be processed as a current instruction;
the first sending module is specifically configured to: and when the third judging module judges that no instruction exists in the preset storage area, the third judging module confirms that all instruction sequences in the instruction message are processed, and returns an operation result to the upper computer.
Optionally, the terminal device further includes: the device comprises a second storage module, a fourth judgment module, a detection module, a third reading module, a second removal module and a fifth judgment module;
the first reading module is used for taking an unread instruction in the instruction sequence in the command message as current data to be analyzed and reading a first instruction in the current data to be analyzed;
the second storage module is further configured to store the instruction sequence read by the first reading module into a preset storage area;
the fourth judging module is configured to judge whether the instruction read by the first reading module is the last instruction in the current data to be analyzed;
the first reading module is further configured to, when the fourth determining module determines that the instruction read by the first reading module is not the last instruction in the current data to be analyzed, take an instruction not read in the instruction sequence as the current data to be analyzed, and read the first instruction in the current data to be analyzed;
the terminal device operates the first reading module, the second storing module and the fourth judging module, and also operates the detecting module, the third reading module, the executing module, the second removing module and the fifth judging module; or, the detection module, the third reading module, the second sending module, the second removing module and the fifth judging module are also operated;
the detection module is used for accessing the preset storage area and detecting whether an instruction exists in the preset storage area;
the third reading module is configured to, when the detection module detects that there is an instruction in the preset storage area, take the instruction in the preset storage area as current data to be processed, and read a first instruction in the current data to be processed as a current instruction;
the execution module is specifically configured to: executing corresponding operation according to the current instruction read by the third reading module to obtain an operation result;
the second sending module is specifically configured to: sending the current instruction read by the third reading module to a card;
the second removing module is used for removing the current instruction from the preset storage area after the executing module executes corresponding operation according to the current instruction to obtain an operation result; the second receiving module is further used for removing the current instruction from the preset storage area after receiving an operation result returned by the card;
the fifth judging module is configured to judge whether there are any instructions in the preset storage area after the second removing module removes the current instruction from the preset storage area;
the third reading module is further configured to, when the fifth judging module judges that there are instructions in the preset storage area, take the instructions in the preset storage area as current data to be processed, and read a first instruction in the current data to be processed as a current instruction;
the first sending module is specifically configured to: and when the fifth judgment module judges that no instruction exists in the preset storage area, the fifth judgment module confirms that all instruction sequences in the instruction message are processed, and returns an operation result to the upper computer.
Optionally, the terminal device further includes: a sixth judging module and a second executing module;
the sixth judging module is configured to judge whether data on a first byte in a data element corresponding to a current instruction to be sent is a first preset value before the second sending module sends the instruction sequence to the card in sequence;
the second execution module is configured to execute a card reset operation when the sixth judgment module judges that data on a first byte in a data element corresponding to the current instruction to be sent is a first preset value;
the second sending module is specifically configured to: and when the sixth judging module judges that the data on the first byte in the data element corresponding to the current instruction to be sent is not the first preset value, sending the current instruction to be sent to the card.
Optionally, the terminal device further includes: a seventh judging module and an eighth judging module;
the seventh judging module is configured to, when the operation result returned by the card is an operation failure, judge whether an instruction corresponding to the operation failure result is a last instruction in the instruction sequence;
the first sending module is further configured to: when the seventh judging module judges that the instruction corresponding to the operation failure result is the last instruction in the instruction sequence, the instruction sequence in the command message is confirmed to be completely processed, and the operation result is returned to the upper computer;
the eighth judging module is configured to, when the seventh judging module judges that the instruction corresponding to the operation failure result is not the last instruction in the instruction sequence, judge whether to continue reading the instruction that is not read in the instruction sequence;
the first reading module is further configured to read the instruction sequence in the command message when the eighth determining module determines to continue reading the unread instruction in the instruction sequence;
and the first sending module is further used for returning the received operation result to the upper computer and ending when the eighth judging module judges that the unread instruction in the instruction sequence is not continuously read.
Optionally, the eighth determining module is specifically configured to:
performing AND operation on data on a third preset byte in a data element corresponding to the instruction corresponding to the operation failure result and a second preset value to obtain an operation result, converting the operation result into a binary representation, judging whether data on a highest position in the operation result of the binary representation is first preset data, if so, confirming to continue to read the unread instruction in the instruction sequence, and otherwise, confirming to not continue to read the unread instruction in the instruction message;
or,
and judging whether the data on the fourth preset byte in the data element corresponding to the instruction corresponding to the operation failure result is a third preset value, if so, confirming to continue reading the unread instruction in the instruction sequence, and otherwise, confirming not to continue reading the unread instruction in the instruction sequence.
Optionally, the first sending module is further configured to, when processing of one of the instructions in the instruction sequence fails, sequentially splice currently-obtained operation results or currently-received operation results, correspond to the number of unprocessed instructions in the instruction sequence, fill the same number of second preset data after the spliced operation results to obtain a response packet, and return the response packet to the upper computer.
And the first sending module is also used for returning an error code to the upper computer when one instruction of the instruction sequence fails to be processed.
Optionally, the terminal device further includes: an update module;
the updating module is used for updating the counting identifier according to a preset mode after the first reading module reads the instruction sequence in the command message;
optionally, the first sending module is further configured to, when processing of one of the instructions in the instruction sequence fails, return the failure operation result and the current count value of the count identifier to the upper computer together.
Optionally, the first sending module is further configured to return the received operation result to the upper computer when the operation result received by the second receiving module is smaller than a fourth preset value.
Optionally, the terminal device further includes: a ninth judging module and a card selecting module;
the ninth judging module is configured to judge a card type before the second sending module sends the instruction read by the first reading module to a card when the first reading module reads the first instruction in the instruction sequence;
the card selecting module is used for executing card selecting operation according to the card type judged by the ninth judging module;
the second sending module is specifically configured to: when the card selecting module is successfully operated, sending the instruction read by the first reading module to a card;
the first sending module is further used for returning an error code to the upper computer when the card selecting module fails to operate.
Optionally, the first sending module is specifically configured to:
splicing the operation results of the series of data element structures in sequence to obtain a response message, and returning the response message to the upper computer;
or,
sequentially splicing the series of operation results, adding a separation mark between every two adjacent operation results to obtain a response message, and returning the response message to the upper computer;
or,
and returning the last operation result in the series of operation results to the upper computer.
Compared with the prior art, the invention has the following advantages:
in the process of data interaction between the terminal equipment and the upper computer, one command message contains a plurality of instructions, so that the processing of the plurality of instructions can be completed by one-time exchange, and the data processing efficiency of the terminal equipment is improved.
Drawings
Fig. 1 is a flowchart of a method for efficiently processing data of a terminal device according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for efficiently processing data of a terminal device according to a second embodiment of the present invention;
fig. 3 and fig. 4 are flowcharts of a method for processing high-efficiency data of a terminal device according to a third embodiment of the present invention;
fig. 5 is a flowchart of a method for efficiently processing data of a terminal device according to a fourth embodiment of the present invention;
fig. 6 is a flowchart of a method for efficiently processing data of a terminal device according to a fifth embodiment of the present invention;
fig. 7 is a block diagram illustrating a module of a high-efficiency data processing terminal device according to a sixth embodiment of the present invention;
fig. 8 is a block diagram illustrating a module of a high-efficiency data processing terminal device according to a seventh embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
An embodiment of the present invention provides a method for efficiently processing data of a terminal device, as shown in fig. 1, including:
step 101: the terminal equipment receives a command message sent by an upper computer;
step 102: the terminal equipment reads the instruction sequence in the command message and sequentially executes corresponding operations according to the instruction sequence to obtain a series of operation results; or the terminal equipment reads the instruction sequence in the command message, sequentially sends the instruction sequence to the card and receives a series of operation results returned by the card;
step 103: and when the instruction sequence in the command message is completely processed, the terminal equipment returns the operation result to the upper computer.
In this embodiment, before step 102, the method further includes: and the terminal equipment judges whether the received command message is correct or not, if so, the step 102 is executed, otherwise, an error code is returned to the upper computer, and the operation is finished.
The terminal device determines whether the received command message is correct, specifically:
the terminal equipment judges whether the length of the data on the first preset byte in the received command message is equal to the total length of each data element corresponding to the instruction sequence in the command message, if so, the received command message is confirmed to be correct, otherwise, the received command message is confirmed to be incorrect;
or,
the terminal equipment judges whether the length of the data on the first preset byte in the received command message is equal to the total length of the instruction sequence and each separation mark in the command message, if so, the command message is confirmed to be correct, otherwise, the command message is confirmed to be incorrect.
Optionally, in this embodiment, the reading, by the terminal device, the instruction sequence in the command message specifically includes:
the terminal equipment analyzes the command message to obtain each data element, and reads the instruction in each data element to obtain an instruction sequence;
or,
the terminal equipment analyzes the command message to obtain each separation mark, and obtains an instruction sequence according to each obtained separation mark reading instruction.
Further, in this embodiment, step 102 specifically includes:
step W1: the terminal equipment takes an unread instruction in an instruction sequence in the command message as current data to be processed, reads a first instruction in the current data to be processed, and takes the first instruction as the current instruction;
step W2: the terminal equipment executes corresponding operation according to the current instruction to obtain an operation result; or sending the current instruction to the card and receiving an operation result returned by the card;
correspondingly, step 103 specifically includes: the terminal equipment judges whether the current instruction is the last instruction in the current data to be processed, if so, the terminal equipment confirms that the instruction sequence in the instruction message is completely processed, and returns the operation result to the upper computer; otherwise, return to step W1.
In this embodiment, step 102 may further specifically include:
step Q1: the terminal equipment takes an unread instruction in an instruction sequence in the command message as current data to be analyzed, reads a first instruction in the current data to be analyzed, and stores the read instruction sequence in a preset storage area;
step Q2: the terminal equipment judges whether the read instruction is the last instruction in the current data to be analyzed, if so, the step Q3 is executed, otherwise, the step Q1 is returned;
step Q3: the terminal equipment takes the instruction in the preset storage area as the current data to be processed, reads a first instruction in the current data to be processed as the current instruction, and executes corresponding operation according to the current instruction to obtain an operation result; or sending the current instruction to the card and receiving an operation result returned by the card;
step Q4: the terminal equipment removes the current instruction from a preset storage area;
correspondingly, step 103 specifically includes: the terminal equipment judges whether instructions exist in the preset storage area or not, if yes, the step returns to the step Q3; otherwise, the command sequence in the command message is confirmed to be completely processed, and the operation result is returned to the upper computer.
In this embodiment, the terminal device may further run a first thread and a second thread at the same time, and accordingly step 102 specifically includes:
the terminal equipment runs a first thread and executes the following operations:
step H1: the terminal equipment takes an unread instruction in an instruction sequence in the command message as current data to be analyzed, reads a first instruction in the current data to be analyzed, and stores the read instruction sequence in a preset storage area;
step H2: the terminal equipment judges whether the read instruction is the last instruction in the current data to be analyzed, if so, the operation is finished, otherwise, the operation returns to the step H1;
the terminal equipment runs a second thread and executes the following operations:
step R1: the terminal equipment accesses a preset storage area, and when detecting that the preset storage area has an instruction, executing a step R2;
step R2: the terminal equipment takes the instruction in the preset storage area as the current data to be processed, and reads a first instruction in the current data to be processed as the current instruction; executing corresponding operation according to the current instruction to obtain an operation result; or sending the current instruction to the card and receiving an operation result returned by the card;
step R3: the terminal equipment removes the current instruction from a preset storage area;
correspondingly, step 103 specifically includes: the terminal equipment judges whether instructions exist in the preset storage area or not, if yes, the step is returned to the step R2; otherwise, the command sequence in the command message is confirmed to be completely processed, and the operation result is returned to the upper computer.
Optionally, in step 102 of this embodiment, before sequentially sending the instruction sequence to the card, the method further includes:
step D1: and the terminal equipment judges whether the data on the first byte in the data element corresponding to the current instruction to be sent is a first preset value, if so, the card resetting operation is executed, the operation result returned by the card is received, otherwise, the current instruction to be sent is sent to the card, and the operation result returned by the card is received.
Preferably, in this embodiment, the first preset value is CC.
Optionally, in step 102 of this embodiment, when the operation result returned by the card is an operation failure, the method further includes:
step F1: the terminal device judges whether the instruction corresponding to the operation failure result is the last instruction in the instruction sequence, if so, the terminal device confirms that the instruction sequence in the command message is completely processed, and step 103 is executed; otherwise, executing step F2;
step F2: and the terminal equipment judges whether to continue reading the unread instruction in the instruction sequence, if so, the step 102 is continuously executed, otherwise, the received operation result is returned to the upper computer, and the operation is finished.
The method comprises the following steps that the terminal equipment judges whether to continue reading the instruction which is not read by the instruction sequence, and specifically comprises the following steps:
the terminal equipment performs AND operation on data on a third preset byte in a data element corresponding to the instruction corresponding to the operation failure result and a second preset value to obtain an operation result, converts the operation result into a binary representation, judges whether data on the highest position in the operation result of the binary representation is first preset data, if so, confirms to continuously read the unread instruction in the instruction sequence, and otherwise, confirms to not continuously read the unread instruction in the instruction sequence;
or,
and judging whether the data on the fourth preset byte in the data element corresponding to the instruction corresponding to the operation failure result is a third preset value, if so, confirming to continue reading the unread instruction in the instruction sequence, and otherwise, confirming not to continue reading the unread instruction in the instruction sequence.
Preferably, in this embodiment, the third preset byte is a1 st byte of a data element corresponding to an instruction corresponding to the operation failure result, the second preset value is 0x80, and the first preset data is 1; the fourth predetermined byte is the 3 rd byte of the data element corresponding to the instruction corresponding to the operation failure result, and the third predetermined value is 0x 01.
Optionally, in this embodiment, step 102 further includes: when one of the instructions in the instruction sequence fails to be processed, executing the step M;
step M: and the terminal equipment sequentially splices the currently obtained operation results or the currently received operation results, corresponds to the number of unprocessed instructions in the instruction sequence, fills the same number of second preset data after the spliced operation results to obtain a response message, and returns the response message to the upper computer.
Optionally, in this embodiment, step 102 further includes: when one of the instructions in the instruction sequence fails to be processed, executing the step N;
and step N: and the terminal equipment returns an error code to the upper computer, and the operation is finished.
Optionally, in step 102 of this embodiment, after the terminal device reads the instruction sequence in the command message, the method further includes:
the terminal equipment updates the counting identification according to a preset mode;
when one of the instructions in the instruction sequence fails to be processed, executing the step L;
step L: and the terminal equipment returns the failure operation result and the current count value of the count identification to the upper computer together, and the operation is finished.
Optionally, in step 102 of this embodiment, the method further includes: and when the operation result received by the terminal equipment is smaller than the fourth preset value, returning the received operation result to the upper computer, and ending.
Preferably, in this embodiment, the fourth preset value is 0x 1000.
Optionally, in step 102 of this embodiment, when the terminal device reads a first instruction in the instruction sequence, before sending the read instruction to the card, the method further includes:
step P: the terminal equipment judges the card type, executes card selection operation according to the card type, and sends the read instruction to the card if the operation is successful; and if the operation fails, returning an error code to the upper computer, and ending.
Optionally, in step 103, the terminal device returns the operation result to the upper computer, specifically:
the terminal equipment sequentially splices the operation results of a series of data element structures to obtain a response message, and returns the response message to the upper computer;
or,
the terminal equipment sequentially splices a series of operation results, adds a preset separation mark between every two adjacent operation results to obtain a response message, and returns the response message to the upper computer;
or,
and returning the last operation result in a series of operation results of the terminal equipment to the upper computer.
Example two
An embodiment of the present invention provides a method for efficiently processing data of a terminal device, as shown in fig. 2, including:
step 201: the terminal equipment receives a command message sent by an upper computer;
in this embodiment, the command packet includes an instruction sequence, and each instruction in the instruction sequence corresponds to a data element of a TLV (Type-Length-Value) structure, that is, a structure of "tag (1 byte) + data Length (one byte) + data (several bytes)"; wherein, all data on the V structure are instructions, or all data after the second byte in the V structure are instructions; preferably, in this embodiment, all data on the V structure is an instruction.
Particularly, when the data on the T structure is a first preset value, the L structure in the corresponding data element is 00, so that the corresponding instruction is a null instruction, and the terminal equipment executes the card resetting operation according to the type of the card; preferably, the first preset value is CC;
for example, the command message received by the terminal device is 7E50000017810C00a4040007a0000003330101CC 0002050084000008;
the included instruction sequences are instruction 00a4040007a0000003330101, an empty instruction, and instruction 0084000008, and correspond to TLV-structured data elements 810C00a4040007a0000003330101, CC00, and 02050084000008, respectively.
Step 202: the terminal equipment judges whether the received command message is correct or not, if so, step 203 is executed, otherwise, an error code is returned to the upper computer, and the operation is finished;
specifically, the terminal device determines whether the length indicated by the data on the first preset byte in the command message is equal to the total length of the data elements of each TLV structure corresponding to the instruction sequence in the command message, if so, determines that the received command message is correct, otherwise, determines that the received command message is incorrect; preferably, the first preset byte is a fifth byte;
more specifically, the terminal device reads data on a fifth byte of the command message to obtain a total length of each data element, sequentially reads data on an L structure in each data element from a sixth byte of the command message to obtain a length of a V structure of each data element, adds two bytes to the length of the V structure of each data element to obtain the length of each data element, adds and sums the lengths of the data elements, judges whether the sum obtained by adding is equal to the total length of each obtained data element, determines that the received command message is correct if the sum obtained by adding is equal to the total length of each data element, and determines that the received command message is incorrect if the sum obtained by adding is not equal to the total length of each obtained data element;
for example, in the above command message, data on the fifth byte is read as 17, and converted into decimal 23, that is, the length shown by the data on the fifth byte is 23 bytes; from the sixth byte, the data on the L structure in each data element is read in sequence to obtain the lengths of the V structures of the data elements which are respectively 0C, 00 and 05, the lengths of the data elements are respectively 0E, 02 and 07, the lengths of the data elements which are converted into decimal are respectively 14 bytes, 2 bytes and 7 bytes, the sum of the lengths of the data elements is 23 bytes, and the correctness of the command message is confirmed.
Step 203: the terminal device takes an unread instruction in the instruction sequence in the command message as current data to be processed, reads a first instruction in the current data to be processed, and takes the first instruction as the current instruction;
specifically, in this embodiment, the terminal device takes a data element corresponding to an unread instruction in an instruction sequence of the command packet as current data to be processed, reads a first data element in the current data to be processed as a current data element, and takes an instruction in the current data element as a current instruction;
more specifically, the terminal device reads data on a first byte in current data to be processed in the command message, namely, a T structure, to obtain a tag of a first data element in the current data to be processed, reads data on a second byte in the current data to be analyzed, namely, an L structure, to obtain a length of a V structure of the first data element in the current data to be processed, continues to read corresponding data after the second byte according to the read length to obtain the V structure of the first data element in the current data to be processed, reads all data as the first data element in the current data to be processed, takes the data as the current data element, and takes data on the V structure of the current data element as a current instruction.
For example, in the above instruction, the current data element read is 810C00A4040007A0000003330101, and the current instruction is 00A4040007A 0000003330101.
Step 204: the terminal device takes the tag of the data element corresponding to the current instruction as the current tag, and judges whether the current tag is a first preset value, if so, step 210 is executed, otherwise, step 205 is executed;
preferably, in this embodiment, the first preset value is CC.
Further, in this embodiment, when the current instruction is the first instruction in the instruction sequence, before step 205 and step 210 are executed in step 204, the method further includes:
step P: the terminal equipment judges the type of the card, executes card selection operation according to the type of the card, and continues if the operation is successful; if the operation fails, an error code is returned to the upper computer, and the operation is finished;
specifically, the terminal device determining whether the currently operated card is a contact card or a non-contact card includes:
step A1: the terminal device takes the card as a contact card, sends a current instruction to the card, judges whether a response returned by the card is received, if so, confirms that the card is the contact card, otherwise, executes the step A2:
specifically, the terminal device assumes that the card is a contact card and sends a current instruction to the card, and in particular, when the current tag is the first preset value, the terminal device sends a power-on instruction to the card, and when a response returned by the card is not received, it is determined that the card may be a contact card but in a power-off state, and the card may be a non-contact card or a no-card, so that step a2 is continuously executed.
Step A2: the terminal equipment acquires a first state identifier in the terminal equipment, judges whether the card is a contact card or not according to the first state identifier, if so, confirms that the card selection is successful, and otherwise, executes the step A3;
in this embodiment, the first status flag is used to identify the status of the contact card;
specifically, when the value of the first state flag is 0, it indicates that the card is not a contact card; when the value of the first state identification is 1, the card is a contact card and is in a power-on state; when the value of the first state flag is 2, it indicates that the card is a contact card and the card is in a power-down state.
Step A3: and the terminal equipment acquires a second state identifier in the terminal equipment, judges whether the card is a non-contact card or not according to the second state identifier, confirms that the card selection is successful if the card is judged to be the non-contact card, and returns a corresponding state code to the upper computer if the card is not judged to be the non-contact card.
In this embodiment, the second status flag is used to identify the status of the contactless card;
specifically, when the value of the second state flag is 1, the card is represented as a contactless card; when the value of the second state flag is 0, no card is indicated.
Step 205: the terminal equipment sends a current instruction to the card;
for example, in this embodiment, the read current instruction 00a4040007a0000003330101 is sent to the card, and the card performs the application selection operation.
Step 206: the terminal equipment receives the operation result, judges whether the card is operated successfully or not, if so, correspondingly stores the received operation result into a first storage area, and executes step 211; otherwise, go to step 207;
specifically, the terminal device receives the operation result, judges whether the received operation result is a third preset value, and if so, confirms that the card operation is successful; otherwise, confirming that the card operation fails;
preferably, in this embodiment, the third preset value is 0x 9000;
further, in this embodiment, the received operation result is correspondingly saved in the first storage area, and it is preferable that: organizing the operation result into corresponding TLV structure data elements and storing the TLV structure data elements into a first storage area, wherein the T structure of the organized data elements is the same as the T structure of the current data element corresponding to the current instruction;
for example, in this embodiment, if the card successfully performs the application selection operation according to the current instruction, and returns an operation result of 0x9000, the operation result is saved as 01029000, where a T structure, that is, data 01 in the first byte indicates that the operation result is the operation result of the first instruction in the instruction sequence of the command message, an L structure, that is, data 02 in the second byte indicates that the length of the V structure is 2 bytes, and a V structure, that is, data 9000 in the third byte and the fourth byte is the operation result.
Furthermore, in this embodiment, correspondingly saving the received operation result in the first storage area may further be: directly saving the received operation result into a first storage area; alternatively, the received operation results are organized into data elements of the LV structure and saved into the first storage area.
For example, the received operation result 0x9000 is directly saved into the first storage area, or 029000 is saved into the first storage area in accordance with the received operation result 0x 9000.
Step 207: the terminal equipment judges whether the received operation result is smaller than a fourth preset value, if so, the received operation result is returned to the upper computer, and the operation is finished, otherwise, the received operation result is correspondingly stored in a first storage area, and the step 208 is executed;
preferably, in this embodiment, the fourth preset value is 0x 1000;
specifically, when the operation result received by the terminal device is less than 0x1000, the operation result is an error code returned by the terminal device itself, and if the terminal device itself is judged to have an error, the data processing flow is exited, and the error code returned by the terminal device itself is sent to the upper computer, and the process is ended; when the operation result received by the terminal device is not less than 0x1000, it is determined that the operation result is an operation failure result returned by the card, and step 208 is executed.
Step 208: the terminal device judges whether the current instruction is the last instruction in the current data to be processed, if yes, step 212 is executed; otherwise, go to step 209;
in this embodiment, the terminal device determines whether the current instruction is the last instruction in the current data to be processed, specifically: and the terminal equipment judges whether data exist after the current data element corresponding to the current instruction, if so, the current instruction is determined not to be the last instruction in the current data to be processed, and if not, the current instruction is determined to be the last instruction in the current data to be processed.
Step 209: the terminal equipment judges whether to continue reading the unread instruction in the instruction sequence in the instruction message, if so, the step 203 is returned, otherwise, the step 212 is executed;
in this embodiment, the determining, by the terminal device, whether to continue reading the unread instruction in the instruction sequence in the command message specifically includes: the terminal equipment performs AND operation on data on a third preset byte in a data element corresponding to the current instruction and a second preset value to obtain an operation result, converts the operation result into a binary representation, judges whether data on the highest position in the operation result of the binary representation is second preset data, if so, confirms that the instruction which is not read in the instruction sequence of the command message is continuously read, and otherwise, confirms that the instruction which is not read in the instruction sequence of the command message is not continuously read;
preferably, the third preset byte is a1 st byte of a data element corresponding to the current instruction, i.e., a T structure, the second preset value is 0x80, and the second preset data is 1;
for example, in this embodiment, the data 0x81 and 0x80 on the 1 st byte of the data element corresponding to the current instruction are anded to obtain the operation result 0x80, the operation result is converted into a binary representation of 10000000, the data on the highest bit is 1, and the unread instruction in the instruction sequence of the command message is confirmed to be read continuously.
In this embodiment, when all data after the second byte in the V structure of the data element is an instruction, correspondingly, the terminal device determines whether to continue reading the instruction that is not read in the instruction sequence of the command packet, specifically: the terminal equipment judges whether the data on the fourth preset byte in the data element corresponding to the current instruction is a third preset value, if so, the terminal equipment confirms that the instruction which is not read in the instruction sequence of the command message is continuously read, and otherwise, the terminal equipment confirms that the instruction which is not read in the instruction sequence of the command message is not continuously read;
preferably, the fourth preset byte is the 3 rd byte of the data element corresponding to the current instruction, i.e. the 1 st byte in the V structure; the third preset value is 0x 01.
For example, the command packet received by the terminal device is 7E1601001C010D0100a4040007a000000333010102060100840000040306010084000008, the current instruction is 00a4040007a0000003330101, the corresponding data element is 010D0100a4040007a0000003330101, the data on the 3 rd byte is 01, and it is determined that the instruction that is not read in the instruction sequence of the command packet is continuously read.
Step 210: the terminal equipment executes the card resetting operation, receives the operation result returned by the card and judges whether the resetting operation is successful, if so, the received operation result is correspondingly stored in the first storage area, the step 211 is executed, otherwise, the error response data is returned to the upper computer, and the operation is finished;
specifically, when the card is a non-contact card, the terminal device controls the external field intensity through hardware to perform powering-off and powering-on operations on the card, so as to complete resetting of the card;
when the card is a contact card, the terminal equipment sends a corresponding power-off command and a corresponding power-on command to the card according to the type of the chip of the card, and the reset operation of the card is completed;
for example, when the chip of the card is a 9541 chip, the power-off command sent to the card by the terminal device is 63000000000000000000, and the power-on command is 62000000000000000000.
Step 211: the terminal device judges whether the current instruction is the last instruction in the current data to be processed, if yes, step 212 is executed; otherwise, returning to step 203;
in this embodiment, the method for the terminal device to determine whether the current instruction is the last instruction in the current data to be processed in this step is the same as the method described in step 208, and details are not repeated here.
Step 212: and the terminal equipment returns the operation result in the first storage area to the upper computer, and the operation is finished.
Specifically, the terminal equipment sequentially splices operation results of the data element structures in the first storage area to obtain response messages, and returns the response messages to the upper computer;
for example, the operation results of the TLV structure in the first storage area are 0103009000, 02029000, and 03029000, and the response message after splicing is 01030090000202900003029000; or the operation result of the LV structure in the first storage area is 03009000, 029000, 029000, and the spliced response message is 03009000029000029000.
Furthermore, when the terminal device directly stores the operation result into the first storage area, correspondingly, the operation result in the first storage area is returned to the upper computer, specifically: the terminal equipment sequentially splices the operation results in the first storage area, adds a preset separation mark between every two adjacent operation results to obtain a response message, and returns the response message to the upper computer;
preferably, the preset separation flag is 0x 2C;
for example, the operation results in the first storage area are 009000, 9000, and the response message after splicing is: 0090002C90002C 9000.
In this embodiment, returning the operation result in the first storage area to the upper computer may also be: the terminal equipment returns the last operation result in the operation results in the first storage area to the upper computer;
for example, the operation results in the first storage area are 0103009000, 02029000 and 03029000, and 03029000 is returned to the upper computer;
or,
the operation results in the first memory area are 009000, 9000, and 9000 is returned to the host computer.
Further, when step 212 is executed in step 209, the operation result in the first storage area is returned to the upper computer in step 212, which may be: sequentially splicing the operation results in the first storage area, wherein the operation results correspond to the number of unread instructions in the instruction sequence, filling the same number of second preset data after the spliced operation results to obtain a response message, and returning the obtained response message to the upper computer; preferably, the second preset data is 6D 00;
illustratively, each second preset datum corresponds to a data element of a TLV structure, and the T structure of the corresponding data element is the same as the T structure of the data element corresponding to an unread instruction in the instruction sequence;
for example, if the command sequence in the command message includes five commands, the card operation fails for the third command, and the unread command in the command sequence in the command message is no longer read, the data element corresponding to the first and second filled default data is 04026D00, and the data element corresponding to the second filled default data is 05026D00, corresponding to the fourth and fifth commands.
Optionally, in this embodiment, when one of the instruction operations in the instruction sequence fails, the terminal device may also directly return an error code to the upper computer, and the operation is ended;
optionally, in step 202, when the terminal device determines that the received command packet is correct, the method may further include:
step a 1: the terminal equipment takes an unread instruction in an instruction sequence in the command message as current data to be analyzed, reads a first instruction in the current data to be analyzed, and sequentially stores the read instructions in a second storage area;
step a 2: the terminal equipment judges whether the read instruction is the last instruction in the current data to be analyzed, if so, the step 203 is executed, otherwise, the step a1 is returned;
correspondingly, step 203 specifically includes:
step 203': the terminal equipment takes the instruction in the second storage area as the current data to be processed, reads the first instruction in the current data to be processed as the current instruction, and reads the label of the data element corresponding to the current instruction as the current label;
step 208, specifically:
step 208': the terminal equipment judges whether there is any instruction in the second storage area, if yes, step 209 is executed; otherwise, returning the operation result in the first storage area to the upper computer, and ending;
step 209, specifically:
step 209': the terminal equipment judges whether to continue reading the instruction in the second storage area, if yes, the step 203 is returned; otherwise, returning the operation result in the first storage area to the upper computer, and ending;
step 210, specifically:
step 210': the terminal equipment judges whether there is any instruction in the second storage area, if yes, the step is returned to 203; otherwise, returning the operation result in the first storage area to the upper computer, and ending;
according to the method in the embodiment, the command message received by the terminal device contains the instruction sequence, each instruction in the instruction sequence corresponds to one TLV-structured data element, the terminal device can analyze the command message, process one corresponding instruction every time the data element with one TLV structure is obtained, also can analyze the command message to obtain the data element with each TLV structure, and sequentially process the instructions corresponding to the data elements with each TLV structure, so that the purpose of completing the processing of multiple instructions through one-time interaction is achieved, and the data processing efficiency is improved.
EXAMPLE III
The third embodiment of the invention provides a high-efficiency data processing method for terminal equipment, wherein when the terminal equipment receives a command message sent by an upper computer, a first thread and a second thread are started and operated in the terminal equipment at the same time;
as shown in fig. 3, the terminal device executes the first thread to perform the following operations:
step 301: the terminal equipment judges whether the received command message is correct or not, if so, the step 302 is executed, otherwise, an error code is returned to the upper computer, and the operation is finished;
in this embodiment, the command message includes an instruction sequence, and each instruction in the instruction sequence corresponds to a data element of a TLV (Type-Length-Value) structure, that is, a structure of "tag (1 byte) + data Length (one byte) + data (several bytes)", where all data on the V structure is an instruction, or all data after the second byte in the V structure is an instruction; preferably, in this embodiment, all data on the V structure is an instruction;
particularly, when the data on the T structure is a first preset value, the L structure in the corresponding data element is 00, so that the corresponding instruction is a null instruction, and the terminal equipment executes the card resetting operation according to the type of the card; preferably, the first preset value is CC;
in this embodiment, the implementation method of step 301 is the same as that described in step 202 of the second embodiment, and is not described herein again.
Step 302: the terminal equipment takes an unread instruction in an instruction sequence in the command message as current data to be analyzed, reads a first instruction in the current data to be analyzed, and sequentially stores the read instructions in a third storage area;
specifically, the terminal device takes a data element corresponding to an unread instruction in an instruction sequence in the command message as current data to be processed, reads a first data element in the current data to be processed, and sequentially stores the read data elements in a third storage area;
more specifically, the terminal device reads data on a first byte in current data to be analyzed, namely a T structure, in a command message to obtain a tag of a first data element in the current data to be processed, reads data on a second byte in the current data to be analyzed, namely an L structure, to obtain a length of a V structure of the first data element in the current data to be processed, continues to read corresponding data after the second byte according to the read length to obtain the V structure of the first data element in the current data to be processed, reads all data as the first data element in the current data to be processed, and sequentially stores the read data elements in a third storage area;
for example, the received command message is 7E50000017810C00a4040007a0000003330101CC0002050084000008, the current data to be processed is 810C00a4040007a0000003330101CC0002050084000008, and the first read data element is 810C00a4040007a 0000003330101.
Step 303: the terminal equipment judges whether the read instruction is the last instruction in the current data to be analyzed, if so, the process is finished; otherwise, returning to step 302;
in this embodiment, the terminal device determines whether the read instruction is the last instruction in the current data to be analyzed, and specifically includes: and the terminal equipment judges whether data exist after the data element corresponding to the read instruction, if so, the read instruction is determined not to be the last instruction in the current data to be analyzed, otherwise, the read instruction is determined to be the last instruction in the current data to be analyzed.
In this embodiment, as shown in fig. 4, the terminal device executes the second thread to perform the following operations:
step 401: the terminal device accesses the third storage area, and when detecting that the third storage area has an instruction, step 402 is executed;
in particular, step 402 is performed when a data element is detected in the third storage area.
Step 402: the terminal device takes the instruction in the third storage area as the current data to be processed, reads the first instruction in the current data to be processed, and takes the first instruction as the current instruction;
specifically, the terminal device takes the data element in the third storage area as the current data to be processed, reads the first data element in the current data to be processed as the current data element, and takes the instruction in the current data element as the current instruction.
For example, the current data element read is 810C00A4040007A0000003330101, and the current instruction is 00A4040007A 0000003330101.
Step 403: the terminal device takes the label of the data element corresponding to the current instruction as a current label, and judges whether the current label is a first preset value, if so, the step 409 is executed, otherwise, the step 404 is executed;
preferably, in this embodiment, the first preset value is CC.
Further, in this embodiment, when the current instruction is the first instruction in the three memory areas, before the step 403 executes the step 404 and the step 410, the method further includes:
the terminal equipment judges the type of the card, executes card selection operation according to the type of the card, and continues if the card selection operation is successful; if the card selection operation fails, returning error response data to the upper computer, and ending;
in this embodiment, the implementation method for determining the type of the card by the terminal device is the same as the method for determining the type of the card by the terminal device described in step P of the second embodiment, and details are not repeated here.
Step 404: the terminal equipment sends a current instruction to the card;
step 405: the terminal equipment receives the operation result and judges whether the card is operated successfully, if so, the received operation result is stored in a fourth storage area, the current instruction is removed from the third storage area, and the step 410 is executed; otherwise, go to step 406;
specifically, the terminal device receives the operation result, and judges that the received operation result is a third preset value, if so, the card operation is confirmed to be successful, otherwise, the card operation is confirmed to be failed;
preferably, in this embodiment, the third preset value is 0x 9000.
Further, in this embodiment, the method for saving the received operation result in the fourth storage area is the same as the method for correspondingly saving the received operation result in the first storage area in step 206 of the embodiment, and is not described herein again.
Step 406: the terminal equipment judges whether the received operation result is smaller than a fourth preset value or not, if so, the received operation result is returned to the upper computer, and the operation is finished, otherwise, the received operation result is correspondingly stored in a fourth storage area, the current instruction is removed from the third storage area, and the step 407 is executed;
preferably, in this embodiment, the fourth preset value is 0x 1000;
specifically, when the operation result received by the terminal device is less than 0x1000, the operation result is an error code returned by the terminal device itself, and if the terminal device itself is judged to have an error, the data processing flow is exited, and the error code returned by the terminal device itself is sent to the upper computer, and the process is ended; when the operation result received by the second thread is not less than 0x1000, it is determined that the operation result is an operation failure result returned by the card, and step 407 is executed.
Step 407: the terminal equipment judges whether an instruction exists in the third storage area, if so, step 408 is executed, otherwise, step 411 is executed;
step 408: the terminal equipment judges whether to continue reading the instruction in the third storage area, if so, the step 402 is returned, otherwise, the step 411 is executed;
in this embodiment, the implementation method of step 408 is the same as the method for the terminal device to determine whether to continue reading the unread instruction in the instruction sequence in the command message in step 209 of the second embodiment, and is not described herein again.
Step 409: the terminal equipment executes the card resetting operation, receives the operation result returned by the card and judges whether the resetting operation is successful, if so, the received operation result is correspondingly stored in a fourth storage area, the current instruction is cleared from the third storage area, the step 410 is executed, otherwise, an error code is returned to the upper computer, and the operation is finished;
specifically, when the card is a non-contact card, the second thread executes powering-off and powering-on operations on the card through the control of the terminal equipment hardware on the external field intensity to complete the resetting of the card;
when the card is a contact card, the second thread sends a corresponding power-off command and a corresponding power-on command to the card according to the type of the chip of the card, and the reset operation of the card is completed;
for example, when the chip of the card is 9541 chip, the power-down command sent by the second thread to the card is 63000000000000000000, and the power-up command is 62000000000000000000.
Step 410: the terminal equipment judges whether the third storage area has instructions, if yes, the step returns to step 402; otherwise, go to step 411:
step 411: and the terminal equipment returns the operation result in the fourth storage area to the upper computer, and the operation is finished.
In this embodiment, a specific implementation method of step 411 is the same as the method for returning the operation result in the first storage area to the upper computer by the terminal device described in step 212 of the second embodiment, and details are not repeated here.
Optionally, in this embodiment, when one of the instruction operations in the instruction sequence fails, the terminal device may also directly return an error code to the upper computer, and the operation is ended;
in the method in this embodiment, the command packet received by the terminal device contains an instruction sequence, and each instruction in the instruction sequence corresponds to a data element of a TLV structure; simultaneously operating a first thread and a second thread in the terminal equipment; the terminal device runs a first thread to analyze the command message to obtain data elements of all TLV structures corresponding to the instruction sequence, and runs a second thread to process the data elements of all TLV structures obtained by running the first thread; the first thread and the second thread work simultaneously, and the data processing efficiency is further improved.
Example four
An embodiment of the present invention provides a method for efficiently processing data of a terminal device, as shown in fig. 5, including:
step 501: the terminal equipment receives a command message sent by an upper computer;
in this embodiment, the command message includes an instruction sequence, and the instructions in the instruction sequence are sequentially spliced, and every two adjacent instructions are separated by a preset separation identifier; preferably, the preset separation flag is 0x 2C.
For example, the command message sent by the upper computer received by the terminal device is 7E1600001800a4040007a00000033301012C00840000042C 0084000008; the instruction sequences contained therein are 00A4040007A0000003330101, 0084000004, and 0084000008.
Step 502: the terminal equipment judges whether the received command message is correct, if so, step 503 is executed, otherwise, an error code is returned to the upper level, and the process is finished;
specifically, the terminal device judges whether the length shown by the data on the first preset byte in the command message is equal to the total length of the instruction sequence and each separation mark in the command message, if so, the command message is confirmed to be correct, otherwise, the command message is confirmed to be incorrect; preferably, the first preset byte is a fifth byte;
for example, in the command message, the data read out to the fifth byte is 18, the data is converted to 24 decimal, that is, the length shown by the data in the fifth byte is 24 bytes, starting from the sixth byte, the length of each instruction in the instruction sequence is 12 bytes, 5 bytes and 5 bytes, the length of each partition mark is 1 byte and 1 byte, the length of each instruction and the length of each partition mark are added to 24 bytes, and the received command message is confirmed to be correct;
step 503: the terminal equipment takes an unread instruction in the instruction sequence in the command message as current data to be processed, and reads a first instruction in the current data to be processed;
specifically, in this embodiment, the terminal device uses the unread instruction and the separation identifier in the command packet as the current data to be processed, finds the first separation identifier in the current data to be processed, and reads the data from the first byte in the current data to be processed to the previous byte of the found separation identifier to obtain the first instruction;
for example, in the present embodiment, the terminal device reads the first instruction in the command message, and takes the data 00a4040007a00000033301012C00840000042C0084000008 on the sixth byte to the last byte as the current data to be processed, and the first instruction read is 00a4040007a 0000003330101.
Step 504: the terminal equipment updates the count value of the counter according to a preset mode;
preferably, in this embodiment, the initial count value of the counter is 00, and when the terminal device reads an instruction, the terminal device increments the count value of the counter by a preset step, where the preset step is 1.
For example, when the first instruction in the instruction sequence of the command message is read, the count value of the timer is updated to 01.
Step 505: the terminal device sends the read instruction to the card and receives an operation result returned by the card, if the operation result is successful, the received operation result is stored in a fifth storage area, and step 506 is executed; if the operation result is operation failure, returning the received operation result and the current count value of the counter to the upper computer together, and ending;
preferably, in this embodiment, when the received operation result is 9000, it indicates that the operation result is success, otherwise, it indicates that the operation result is failure;
for example, in this embodiment, when the read instruction is the third instruction, the current timing value of the counter is 03, and if the received operation result is operation failure, the operation result and 03 are returned to the upper computer together, and the operation is ended.
In this embodiment, the received operation result is saved in the fifth storage area, and it is preferable that: directly saving the received operation result into a fifth storage area;
further, in this embodiment, the step of saving the received operation result in the fifth storage area may further be: organizing the received operation result into a data element of a TLV structure or an LV structure and storing the data element into a fifth storage area; in the data elements of the TLV structure, the data on the T structure is the same as the current count value of the counter;
for example, if the current count value of the counter is 03 and the received operation result is 9000, the received operation result is stored as 03029000.
Furthermore, the received operation result and the current count value of the counter are returned to the upper computer together, and the received operation result can be replaced by a data element organized into a TLV structure and returned to the upper computer; or replacing the received operation result into a data element organizing an LV structure and returning the data element and the current count value of the counter to the upper computer.
Step 506: and the terminal equipment judges whether the read instruction is the last instruction in the current data to be processed, if so, the last operation result in the fifth storage area is returned to the upper computer, and if not, the step 504 is returned.
The terminal device judges whether the read instruction is the last instruction in the current data to be processed, and specifically includes: and the terminal equipment judges whether data exist after the read instruction, if so, the read instruction is confirmed not to be the last instruction in the current data to be processed, otherwise, the read instruction is confirmed to be the last instruction in the current data to be processed.
In this embodiment, the last operation result in the fifth storage area is returned to the upper computer, that is, the operation result of the last instruction in the instruction sequence is returned to the upper computer.
Further, in this embodiment, the last operation result in the fifth storage area is returned to the upper computer, and may be replaced by: all operation results in the fifth storage area are returned to the upper computer;
specifically, all operation results in the fifth storage area are sequentially spliced, a preset separation mark is added between every two adjacent operation results to obtain a response message, and the response message is returned to the upper computer; preferably, the preset separation flag is 0x 2C;
or, when the received operation result is saved in the fifth storage area, specifically: organizing the received operation results into data elements of a TLV structure or an LV structure, and when the data elements are stored in a fifth storage area, correspondingly returning all the operation results in the fifth storage area to the upper computer, specifically: and splicing the operation results of the data element structures in the fifth storage area sequentially to obtain response messages, and returning the response messages to the upper computer.
EXAMPLE five
An embodiment of the present invention provides a method for efficiently processing data of a terminal device, as shown in fig. 6, where the method includes:
step 601: the terminal equipment receives a command message sent by an upper computer;
in this embodiment, the command message includes an instruction sequence, and each instruction in the instruction sequence corresponds to a data element of an LV (Length-Value) structure, that is, a structure of "data Length (two bytes) + data (several bytes)", where data on the V structure is an instruction;
for example, in this embodiment, the command message received by the terminal device is 0X0400002F000580EA000008000680FC19000104000780FC1800020001000700a40000022001000580FC 04110100050084000008; the instruction sequence is instructions 80EA000008, 80FC19000104, 80FC1800020001, 00a40000022001, 580FC041101 and 0084000008, and the corresponding data elements of the LV structure are respectively: 000580EA000008, 000680FC19000104, 000780FC1800020001, 000700A40000022001, 1000580FC041101, 00050084000008.
Further, in this embodiment, each instruction in the instruction sequence may also correspond to a data element of a TLV (Type-Length-Value) structure.
Step 602: the terminal equipment judges whether the received command message is correct or not, if so, the step 603 is executed, otherwise, an error code is returned to the upper computer, and the operation is finished;
specifically, the terminal device judges whether the length shown by the data on the first preset byte in the command message is equal to the total length of the data elements of each LV structure corresponding to the instruction sequence in the command message, if so, the received command message is determined to be correct, otherwise, the received command message is determined to be incorrect; preferably, the first preset byte is a fifth byte;
more specifically, the terminal device reads data on a fifth byte of the command message to obtain the total length of each data element, sequentially reads data on an L structure in each data element from the sixth byte of the command message to obtain the length of a V structure of each data element, adds 2 bytes to the length of the V structure of each data element to obtain the length of each data element, adds and sums the lengths of the data elements, judges whether the sum obtained by adding is equal to the total length of each obtained data element or not, confirms that the received command message is correct if yes, and otherwise confirms that the received command message is incorrect;
for example, in the above command message, the data read on the fifth byte is 2F, and is converted into decimal 47, that is, the length shown by the data on the fifth byte is 47 bytes; sequentially reading the data on the L structure in each data element from the sixth byte to obtain the lengths of the V structures of the data elements, namely 0005, 0006, 0007, 0005 and 0005, and obtain the lengths of the data elements of the LV structures, namely 7 bytes, 8 bytes, 9 bytes, 7 bytes and 7 bytes, wherein the sum obtained by adding the lengths of the data elements of the LV structures is 47 bytes, and the received command message is confirmed to be correct.
Step 603: the terminal device takes an unread instruction in the instruction sequence in the command message as current data to be processed, reads a first instruction in the current data to be processed, and takes the first instruction as the current instruction;
specifically, in this embodiment, the terminal device takes a data element corresponding to an unread instruction in the instruction sequence in the command message as current data to be processed, reads a first data element in the current data to be processed as a current data element, and takes an instruction in the current data element as a current instruction.
More specifically, the terminal device takes a data element corresponding to an unread instruction in an instruction sequence in the command message as current data to be processed, reads data on the first two bytes, namely an L structure, of the current data to be processed to obtain the length of a V structure of a first data element in the current data to be processed, reads corresponding data after the second byte according to the obtained length to obtain the V structure of the first data element in the current data to be processed, reads all data as the first data element in the current data to be processed, takes the data as the current data element, and takes data on the V structure of the current data element as the current instruction;
for example, in the above command message, the first data element in the current data to be processed is read as 000580EA000008, and is taken as the current data element.
Step 604: the terminal equipment executes corresponding operation according to the current instruction to obtain an operation result, and correspondingly stores the operation result into a sixth storage area;
preferably, in this embodiment, the operation result is correspondingly stored in the sixth storage area, specifically: organizing the operation result into data elements of an LV structure and saving the data elements into a sixth storage area;
for example, the terminal device performs the operation of obtaining the serial number according to the current data element 000580EA000008, and preferably, the obtaining is successful, and the obtained operation result is 000000570000025900009000, then the operation result is saved as 000C 000000570000025900009000.
Further, in this embodiment, the terminal device may further directly store the operation result in the sixth storage area, or organize the operation result into a data element with a TLV structure and store the data element in the sixth storage area;
for example, the above-described operation result 000000570000025900009000 is saved into the sixth storage area, or 010C000000570000025900009000 is saved into the sixth storage area.
Step 605: the terminal equipment judges whether the current instruction is the last instruction in the current data to be processed, if so, the operation result in the sixth storage area is returned to the upper computer, and the operation is finished; otherwise, return to step 603.
In this embodiment, the terminal device determines whether the current instruction is the last instruction in the current data to be processed, specifically: the terminal equipment judges whether data exist after the current instruction, if so, the current instruction is determined not to be the last instruction in the current data to be processed, otherwise, the current instruction is determined to be the last instruction in the current data to be processed;
in this embodiment, the operation result in the sixth storage area is returned to the upper computer, specifically: and the terminal equipment sequentially splices the operation results in the sixth storage area to obtain a response message, and returns the response message to the upper computer.
Further, when the terminal device directly saves the operation result to the sixth storage area, correspondingly, the operation result in the sixth storage area is returned to the upper computer, specifically: the terminal equipment sequentially splices the operation results in the sixth storage area, adds a preset separation mark between every two adjacent operation results to obtain a response message, and returns the response message to the upper computer;
preferably, the preset separation flag is 0x 2C;
in this embodiment, returning the operation result in the sixth storage area to the upper computer may also be: and the terminal equipment returns the last operation result in the operation results in the sixth storage area to the upper computer.
Optionally, in this embodiment, when one of the instruction operations in the instruction sequence fails, the terminal device may also directly return an error code to the upper computer, and the operation is ended;
furthermore, in this embodiment, the command message received by the terminal device includes an instruction sequence, each instruction in the instruction sequence corresponds to a data element of the LV structure, and the terminal device analyzes the command message, and processes one corresponding instruction every time a data element of the LV structure is obtained; the terminal equipment can also analyze the command message to obtain data elements of all LV structures and sequentially process instructions corresponding to the data elements of all LV structures; the terminal device may also run a first thread and a second thread simultaneously, where the terminal device runs the first thread to analyze the command packet to obtain data elements of each LV structure corresponding to the instruction sequence, and runs the second thread to process an instruction corresponding to each data element obtained by the first thread.
EXAMPLE six
The present invention provides a high-efficiency data processing terminal device, as shown in fig. 7, comprising:
a first receiving module 701, a first reading module 702, an executing module 703 and a first sending module 704;
the first receiving module 701 is configured to receive a command message sent by an upper computer;
a first reading module 702, configured to read an instruction sequence in the command message received by the first receiving module 701;
the execution module 703 is configured to sequentially execute corresponding operations according to the instruction sequence read by the first reading module 702 to obtain a series of operation results;
and the first sending module 704 is used for returning the operation result to the upper computer when the instruction sequence in the command message is completely processed.
The terminal device in this embodiment further includes: a first judgment module;
a first determining module, configured to determine whether the command message received by the first receiving module 701 is correct before the first reading module 702 reads the instruction sequence in the command message received by the first receiving module 701;
the first reading module 702 is specifically configured to: when the first determining module determines that the command message received by the first receiving module 701 is correct, reading an instruction sequence in the command message received by the first receiving module 701;
the first sending module 704 is further configured to, when the first determining module determines that the command packet received by the first receiving module 701 is incorrect, return an error code to the upper computer, and then end.
In this embodiment, the first determining module is specifically configured to:
judging whether the length of the data on the first preset byte in the command message is equal to the total length of each data element corresponding to the instruction sequence of the command message, if so, determining that the command message is correct, otherwise, determining that the command message is incorrect;
or,
and judging whether the length of the data on the first preset byte in the command message is equal to the total length of the instruction sequence and each separation mark in the command message, if so, determining that the command message is correct, and otherwise, determining that the command message is incorrect.
In this embodiment, the first reading module 702 is specifically configured to:
analyzing the command message to obtain each data element, and reading an instruction in each data element to obtain an instruction sequence;
or,
and analyzing the command message to obtain each separation identifier, and reading the command according to the obtained separation identifiers to obtain the command sequence.
The terminal device in this embodiment further includes: a second judgment module;
the first reading module 702 is specifically configured to: using an unread instruction in an instruction sequence in the command message as current data to be processed, reading a first instruction in the current data to be processed, and using the first instruction as a current instruction;
the executing module 703 is specifically configured to: executing corresponding operation according to the current instruction to obtain an operation result;
the second judgment module is specifically configured to: judging whether the current instruction is the last instruction in the current data to be processed;
the first sending module 704 is specifically configured to: when the second judging module judges that the current instruction is the last instruction in the current data to be processed, the second judging module confirms that the instruction sequence is completely processed and returns an operation result to the upper computer;
the first reading module 702 is further configured to, when the second determining module determines that the current instruction is not the last instruction in the current data to be processed, take an instruction that is not read from the instruction sequence in the command message as the current data to be processed, and read the first instruction in the current data to be processed as the current instruction.
Optionally, the terminal device in this embodiment further includes: the device comprises a first storage module, a second judgment module, a second reading module, a first removal module and a third judgment module;
correspondingly, the first reading module 702 is configured to take an instruction that is not read in the instruction sequence in the command message as current data to be analyzed, and read a first instruction in the current data to be analyzed;
the first storage module is used for storing the order read by the first reading module into a preset storage area;
a second determining module, configured to determine whether the instruction read by the first reading module 702 is a last instruction in the current data to be analyzed;
the first reading module 702 is further configured to, when the second determining module determines that the instruction read by the first reading module 702 is not the last instruction in the current data to be analyzed, take an instruction not read in the instruction sequence in the command message as the current data to be analyzed, and read a first instruction in the current data to be analyzed;
the second reading module is configured to, when the second determining module determines that the instruction read by the first reading module 702 is the last instruction in the current data to be analyzed, take an instruction in a preset storage area as the current data to be processed, and read a first instruction in the current data to be processed as the current instruction;
the execution module 703 is configured to execute a corresponding operation according to the current instruction read by the second reading module to obtain an operation result;
the first removing module is configured to remove the current instruction from the preset storage area after the executing module 703 executes the corresponding operation according to the current instruction to obtain an operation result;
the third judging module is used for judging whether the preset storage area has instructions after the first removing module removes the current instructions from the preset storage area;
the second reading module is further used for taking the instruction in the preset storage area as the current data to be processed and reading the first instruction in the current data to be processed as the current instruction when the third judging module judges that the instruction exists in the preset storage area;
the first sending module 704 is specifically configured to: and when the third judgment module judges that no instruction exists in the preset storage area, the third judgment module confirms that the instruction sequence in the instruction message is completely processed and returns the operation result to the upper computer.
Optionally, the terminal device in this embodiment further includes: the device comprises a second storage module, a fourth judgment module, a detection module, a third reading module, a second removal module and a fifth judgment module;
correspondingly, the first reading module 702 is configured to take an unread instruction in the instruction sequence as current data to be analyzed, and read a first instruction in the current data to be analyzed;
the second saving module is further configured to save the instruction sequence read by the first reading module 702 into a preset storage area;
a fourth determining module, configured to determine whether the instruction read by the first reading module 702 is a last instruction in the current data to be analyzed;
the first reading module 702 is further configured to, when the fourth determining module determines that the instruction read by the first reading module 702 is not the last instruction in the current data to be analyzed, take an instruction not read in the instruction sequence in the command message as the current data to be analyzed, and read a first instruction in the current data to be analyzed;
in this embodiment, while the first reading module 702, the second saving module and the fourth determining module are operated in the terminal device, the detecting module, the third reading module, the executing module 703, the second removing module and the fifth determining module are also operated;
the detection module is used for accessing a preset storage area and detecting whether an instruction exists in the preset storage area;
the third reading module is used for taking the instruction in the preset storage area as the current data to be processed and reading the first instruction in the current data to be processed as the current instruction when the detection module detects that the instruction exists in the preset storage area;
the executing module 703 is specifically configured to: executing corresponding operation according to the current instruction read by the third reading module to obtain an operation result;
the second removing module is configured to remove the current instruction from the preset storage area after the executing module 703 executes a corresponding operation according to the current instruction to obtain an operation result;
the fifth judging module is used for judging whether the preset storage area has instructions after the second removing module removes the current instructions from the preset storage area;
the third reading module is further used for taking the instruction in the preset storage area as the current data to be processed and reading the first instruction in the current data to be processed as the current instruction when the fifth judging module judges that the instruction still exists in the preset storage area;
the first sending module 704 is specifically configured to: and when the fifth judgment module judges that no instruction exists in the preset storage area, the fifth judgment module confirms that the instruction sequence is completely processed and returns an operation result to the upper computer.
Optionally, in this embodiment, the first sending module 704 is further configured to, when processing of one of the instructions in the instruction sequence fails, sequentially splice currently obtained operation results, and correspond to the number of unprocessed instructions in the instruction sequence, fill the same number of second preset data after the spliced operation results to obtain a response packet, and return the response packet to the upper computer.
Optionally, the first sending module 704 is further configured to return an error code to the upper computer when processing of one of the instructions in the instruction sequence fails.
The terminal device in this embodiment further includes: an update module;
an updating module, configured to update the count identifier according to a preset manner after the first reading module 702 reads the instruction sequence in the command message;
the first sending module 704 is further configured to, when processing of one of the instructions in the instruction sequence fails, return a result of the failed operation to the upper computer together with the current count value of the count identifier.
Optionally, in this embodiment, the first sending module 704 is specifically configured to:
splicing the operation results of a series of data element structures in sequence to obtain response messages, and returning the response messages to the upper computer;
or,
sequentially splicing a series of operation results, adding a separation mark between every two adjacent operation results to obtain a response message, and returning the response message to the upper computer;
or,
and returning the last operation result in the series of operation results to the upper computer.
EXAMPLE seven
A seventh embodiment of the present invention provides a high-efficiency data processing terminal device, as shown in fig. 8, including:
a first receiving module 801, a first reading module 802, a second sending module 803, a second receiving module 804 and a first sending module 805;
the first receiving module 801 is configured to receive a command packet sent by an upper computer;
the first reading module 802: for reading the instruction sequence in the command message received by the first receiving module 801;
the second sending module 803 is configured to send the instruction sequences read by the first reading module 802 to the cards in sequence;
the second receiving module 804 is used for receiving the operation result returned by the card;
and the first sending module 805 is configured to return an operation result to the upper computer when all the instruction sequences in the command message are completely processed.
The terminal device in this embodiment further includes: a first judgment module;
a first determining module, configured to determine whether the command message received by the first receiving module 801 is correct before the first reading module 802 reads the instruction sequence in the command message received by the first receiving module 801;
the first reading module 802 is specifically configured to: when the first determining module determines that the command message received by the first receiving module 801 is correct, reading an instruction sequence in the command message received by the first receiving module 801;
the first sending module 805 is further configured to, when the first determining module determines that the command packet received by the first receiving module 801 is incorrect, return an error code to the upper computer, and end.
In this embodiment, the first determining module is specifically configured to:
judging whether the length of the data on the first preset byte in the command message is equal to the total length of each data element corresponding to the instruction sequence of the command message, if so, determining that the command message is correct, otherwise, determining that the command message is incorrect;
or,
and judging whether the length of the data on the first preset byte in the command message is equal to the total length of the instruction sequence and each separation mark in the command message, if so, determining that the command message is correct, and otherwise, determining that the command message is incorrect.
In this embodiment, the first reading module 802 is specifically configured to:
analyzing the command message to obtain each data element, and reading an instruction in each data element to obtain an instruction sequence;
or,
and analyzing the command message to obtain each separation identifier, and reading the command according to the obtained separation identifiers to obtain the command sequence.
Optionally, the terminal device in this embodiment further includes: a second judgment module;
the first reading module 802 is specifically configured to: taking an unread instruction in the instruction sequence as current data to be processed, reading a first instruction in the current data to be processed, and taking the first instruction as a current instruction;
the second sending module 803 is specifically configured to: sending the current instruction to the card;
the second judgment module is specifically configured to: judging whether the current instruction is the last instruction in the current data to be processed;
the first sending module 805 is specifically configured to: when the second judging module judges that the current instruction is the last instruction in the current data to be processed, the second judging module confirms that the instruction sequence in the command message is completely processed and returns the operation result to the upper computer;
the first reading module 802 is further configured to, when the second determining module determines that the current instruction is not the last instruction in the current data to be processed, take an instruction that is not read from the instruction sequence in the command message as the current data to be processed, and read the first instruction in the current data to be processed as the current instruction.
Optionally, the terminal device in this embodiment further includes: the device comprises a first storage module, a second judgment module, a second reading module, a first removal module and a third judgment module;
correspondingly, the first reading module 802 is configured to take an instruction that is not read in the instruction sequence in the command message as current data to be analyzed, and read a first instruction in the current data to be analyzed;
a first saving module, configured to save the instruction sequence read by the first reading module 802 into a preset storage area;
a second determining module, configured to determine whether the instruction read by the first reading module 802 is a last instruction in the current data to be analyzed;
the first reading module 802 is further configured to, when the second determining module determines that the instruction read by the first reading module is not the last instruction in the current data to be analyzed, take an instruction not read in the instruction sequence in the command message as the current data to be analyzed, and read a first instruction in the current data to be analyzed;
the second reading module is configured to, when the second determining module determines that the instruction read by the first reading module 802 is the last instruction in the current data to be analyzed, take an instruction in a preset storage area as the current data to be processed, and read a first instruction in the current data to be processed as the current instruction;
the second sending module 803 is specifically configured to: sending the current instruction read by the second reading module to the card;
the first removing module is used for removing the current instruction from the preset storage area after the second receiving module 804 receives the operation result returned by the card;
the third judging module is used for judging whether the preset storage area has instructions after the first removing module removes the current instructions from the preset storage area;
the second reading module is further used for taking the instruction in the preset storage area as the current data to be processed and reading the first instruction in the current data to be processed as the current instruction when the third judging module judges that the instruction exists in the preset storage area;
the first sending module 805 is specifically configured to: and when the third judgment module judges that no instruction exists in the preset storage area, the third judgment module confirms that the instruction sequence in the instruction message is completely processed and returns the operation result to the upper computer.
Optionally, the terminal device in this embodiment further includes: the device comprises a second storage module, a fourth judgment module, a detection module, a third reading module, a second removal module and a fifth judgment module;
correspondingly, the first reading module 802 is configured to take an instruction that is not read in the instruction sequence in the command message as current data to be analyzed, and read a first instruction in the current data to be analyzed;
the second saving module is further configured to save the instruction sequence read by the first reading module 802 into a preset storage area;
a fourth determining module, configured to determine whether the instruction read by the first reading module 802 is a last instruction in the current data to be analyzed;
the first reading module 802 is further configured to, when the fourth determining module determines that the instruction read by the first reading module 802 is not the last instruction in the current data to be analyzed, take an instruction not read in the instruction sequence in the command message as the current data to be analyzed, and read a first instruction in the current data to be analyzed;
in this embodiment, while the first reading module 802, the second saving module and the fourth determining module are operated in the terminal device, a detecting module, a third reading module, a second sending module 803, a second removing module and a fifth determining module are also operated;
the detection module is used for accessing a preset storage area and detecting whether an instruction exists in the preset storage area;
the third reading module is used for taking the instruction in the preset storage area as the current data to be processed and reading the first instruction in the current data to be processed as the current instruction when the detection module detects that the instruction exists in the preset storage area;
the second sending module 803 is specifically configured to: sending the current instruction read by the third reading module to the card;
the second removing module is used for removing the current instruction from the preset storage area after the second receiving module 804 receives the operation result returned by the card;
the fifth judging module is used for judging whether the preset storage area has instructions after the second removing module removes the current instructions from the preset storage area;
the third reading module is further used for taking the instruction in the preset storage area as the current data to be processed and reading the first instruction in the current data to be processed as the current instruction when the fifth judging module judges that the instruction still exists in the preset storage area;
the first sending module 805 is specifically configured to: and when the fifth judgment module judges that no instruction exists in the preset storage area, the fifth judgment module confirms that the instruction sequence in the instruction message is completely processed and returns the operation result to the upper computer.
The terminal device in this embodiment further includes: a sixth judging module and a second executing module;
the sixth determining module is configured to determine whether data on a first byte in a data element corresponding to a current instruction to be sent is a first preset value before the second sending module 803 sends the instruction sequence to the card in sequence;
the second execution module is used for executing the card resetting operation when the sixth judgment module judges that the data on the first byte in the data element corresponding to the current instruction to be sent is the first preset value;
the second sending module 803 is specifically configured to: and when the sixth judging module judges that the data on the first byte in the data element corresponding to the current instruction to be sent is not the first preset value, sending the current instruction to be sent to the card.
The terminal device in this embodiment further includes: a seventh judging module and an eighth judging module;
the seventh judging module is used for judging whether the instruction corresponding to the operation result is the last instruction in the instruction sequence when the operation result returned by the card is operation failure;
a first sending module 805, further configured to: when the seventh judging module judges that the instruction corresponding to the operation result is the last instruction in the instruction sequence, the instruction sequence in the instruction message is confirmed to be completely processed, and the operation result is returned to the upper computer;
the eighth judging module is used for judging whether to continue to read the unread instruction in the instruction sequence when the seventh judging module judges that the instruction corresponding to the operation result is not the last instruction in the instruction sequence;
the first reading module 802 is further configured to read the instruction sequence in the command message when the eighth determining module determines that the instruction sequence is not read in the continuous reading instruction sequence;
the first sending module 805 is further configured to, when the eighth determining module determines that the unread instruction in the instruction sequence is not to be read continuously, return the received operation result to the upper computer, and then end.
In this embodiment, the eighth determining module is specifically configured to:
performing AND operation on data on a third preset byte in a data element corresponding to the instruction corresponding to the operation failure result and a second preset value to obtain an operation result, converting the operation result into a binary representation, judging whether data on the highest position in the operation result of the binary representation is first preset data, if so, confirming to continue to read the unread instruction in the instruction sequence, and otherwise, confirming to not continue to read the unread instruction in the instruction message;
or,
and judging whether the data on the fourth preset byte in the data element corresponding to the instruction corresponding to the operation failure result is the third preset data, if so, confirming to continue reading the unread instruction in the instruction sequence, and otherwise, confirming not to continue reading the unread instruction in the instruction sequence.
Optionally, in this embodiment, the first sending module 805 is further configured to, when processing of one of the instructions in the instruction sequence fails, sequentially splice the currently received operation results, and correspond to the number of unprocessed instructions in the instruction sequence, fill the same number of second preset data after the spliced operation results to obtain a response packet, and return the response packet to the upper computer.
Optionally, the first sending module 805 is further configured to return an error code to the upper computer when processing of one of the instructions in the instruction sequence fails.
Optionally, the terminal device in this embodiment further includes: an update module;
an updating module, configured to update the count identifier according to a preset manner after the first reading module 802 reads the instruction sequence in the command message;
correspondingly, the first sending module 805 is further configured to, when processing of one of the instructions in the instruction sequence fails, return a result of the failed operation to the upper computer together with the current count value of the count identifier.
Optionally, the first sending module 805 is further configured to, when the operation result received by the second receiving module 804 is smaller than a fourth preset value, return the received operation result to the upper computer.
The terminal device in this embodiment further includes: a ninth judging module and a card selecting module;
the ninth determining module is configured to determine the card type before the second sending module 803 sends the instruction read by the first reading module 802 to the card when the first reading module 802 reads the first instruction in the instruction sequence;
the card selecting module is used for executing card selecting operation according to the card type judged by the ninth judging module;
the second sending module 803 is specifically configured to: when the card selection module is successfully operated, the instruction read by the first reading module is sent to the card;
the first sending module 805 is further configured to return an error code to the upper computer when the operation of the card selection module fails.
In this embodiment, the first sending module 805 is specifically configured to:
splicing the operation results of a series of data element structures in sequence to obtain response messages, and returning the response messages to the upper computer;
or,
sequentially splicing a series of operation results, adding a separation mark between every two adjacent operation results to obtain a response message, and returning the response message to the upper computer;
or,
and returning the last operation result in the series of operation results to the upper computer.
In the invention, in the process of data interaction between the terminal equipment and the upper computer, one command message contains a plurality of instructions, so that the processing of the plurality of instructions can be completed by one-time interaction, and the data processing rate of the terminal equipment is improved.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all such changes or substitutions should be covered by the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (32)
1. A method for processing high-efficiency data of terminal equipment is characterized by comprising the following steps:
step S1: the terminal equipment receives a command message sent by an upper computer;
step S2: the terminal equipment reads the instruction sequence in the command message and sequentially executes corresponding operations according to the instruction sequence to obtain a series of operation results; or the terminal equipment reads the instruction sequence in the command message, sequentially sends the instruction sequence to a card and receives a series of operation results returned by the card;
step S3: and when the instruction sequence in the command message is completely processed, the terminal equipment returns the operation result to the upper computer.
2. The method according to claim 1, wherein before the step S2, the method further comprises: the terminal equipment judges whether the command message is correct or not, if so, the step S2 is executed; otherwise, returning an error code to the upper computer, and ending.
3. The method according to claim 2, wherein the terminal device determines whether the command packet is correct, specifically:
the terminal equipment judges whether the length of data on a first preset byte in the command message is equal to the total length of each data element corresponding to the instruction sequence in the command message, if so, the command message is confirmed to be correct, otherwise, the command message is confirmed to be incorrect;
or,
and the terminal equipment judges whether the length of the data on the first preset byte in the command message is equal to the total length of the instruction sequence and each separation mark in the command message, if so, the command message is confirmed to be correct, and if not, the command message is confirmed to be incorrect.
4. The method according to claim 1, wherein in step S2, the terminal device reads a command sequence in the command message, specifically:
the terminal equipment analyzes the command message to obtain each data element, and reads an instruction in each data element to obtain an instruction sequence;
or,
and the terminal equipment analyzes the command message to obtain each separation identifier, and reads an instruction according to each obtained separation identifier to obtain an instruction sequence.
5. The method according to claim 1, wherein the step S2 specifically includes:
step W1: the terminal device takes an unread instruction in the instruction sequence in the command message as current data to be processed, reads a first instruction in the current data to be processed, and takes the first instruction as a current instruction;
step W2: the terminal equipment executes corresponding operation according to the current instruction to obtain an operation result; or sending the current instruction to a card and receiving an operation result returned by the card;
the step S3 specifically includes: the terminal equipment judges whether the current instruction is the last instruction in the current data to be processed, if so, the terminal equipment confirms that the instruction sequence in the command message is completely processed, and returns the operation result to the upper computer; otherwise, return to step W1.
6. The method according to claim 1, wherein the step S2 specifically includes:
step Q1: the terminal device takes an unread instruction in the instruction sequence in the command message as current data to be analyzed, reads a first instruction in the current data to be analyzed, and stores the read instruction sequence in a preset storage area;
step Q2: the terminal equipment judges whether the read instruction is the last instruction in the current data to be analyzed, if so, the step Q3 is executed, otherwise, the step Q1 is returned;
step Q3: the terminal equipment takes the instruction in the preset storage area as current data to be processed, reads a first instruction in the current data to be processed as a current instruction, and executes corresponding operation according to the current instruction to obtain an operation result; or sending the current instruction to a card and receiving an operation result returned by the card;
step Q4: the terminal equipment removes the current instruction from the preset storage area;
the step S3 specifically includes: the terminal equipment judges whether instructions exist in the preset storage area or not, if yes, the step returns to the step Q3; and if not, confirming that the instruction sequence in the command message is completely processed, and returning the operation result to the upper computer.
7. The method according to claim 1, wherein the terminal device runs a first thread and a second thread simultaneously, and the step S2 specifically includes:
the terminal equipment runs the first thread and executes the following operations:
step H1: the terminal device takes an unread instruction in the instruction sequence in the command message as current data to be analyzed, reads a first instruction in the current data to be analyzed, and stores the read instruction sequence in a preset storage area;
step H2: the terminal equipment judges whether the read instruction is the last instruction in the current data to be analyzed, if so, the operation is finished, otherwise, the operation returns to the step H1;
the terminal equipment runs the second thread and executes the following operations:
step R1: the terminal device accesses the preset storage area, and when detecting that the preset storage area has an instruction, the step R2 is executed;
step R2: the terminal device takes the instruction in the preset storage area as current data to be processed, and reads a first instruction in the current data to be processed as a current instruction; executing corresponding operation according to the current instruction to obtain an operation result; or sending the current instruction to a card and receiving an operation result returned by the card;
step R3: the terminal equipment removes the current instruction from the preset storage area;
the step S3 specifically includes: the terminal equipment judges whether instructions exist in the preset storage area or not, if yes, the step R2 is returned; and if not, confirming that the instruction sequence in the command message is completely processed, and returning the operation result to the upper computer.
8. The method according to claim 1, wherein before the step S2, the step of sending the sequence of instructions to cards in sequence further comprises:
step D1: and the terminal equipment judges whether the data on the first byte in the data element corresponding to the current instruction to be sent is a first preset value, if so, the card resetting operation is executed, the operation result returned by the card is received, and if not, the current instruction to be sent is sent to the card, and the operation result returned by the card is received.
9. The method according to claim 1, wherein in step S2, when the operation result returned by the card is operation failure, the method further comprises:
step F1: the terminal device judges whether the instruction corresponding to the operation failure result is the last instruction in the instruction sequence, if so, the terminal device confirms that all processing of the instruction sequence in the command message is completed, and step S3 is executed; otherwise, executing step F2;
step F2: and the terminal equipment judges whether to continuously read the unread instruction in the instruction sequence, if so, the step S2 is continuously executed, otherwise, the received operation result is returned to the upper computer, and the operation is finished.
10. The method according to claim 9, wherein in step F2, the determining, by the terminal device, whether to continue reading the unread instruction in the instruction sequence includes:
the terminal equipment performs AND operation on data on a third preset byte in a data element corresponding to the instruction corresponding to the operation failure result and a second preset value to obtain an operation result, converts the operation result into a binary representation, judges whether data on the highest position in the operation result of the binary representation is first preset data, if so, confirms to continuously read the unread instruction in the instruction sequence, and otherwise, confirms to not continuously read the unread instruction in the instruction sequence;
or,
and the terminal equipment judges whether the data on the fourth preset byte in the data element corresponding to the instruction corresponding to the operation failure result is a third preset value, if so, the terminal equipment confirms to continue to read the unread instruction in the instruction sequence, and otherwise, the terminal equipment confirms not to continue to read the unread instruction in the instruction sequence.
11. The method according to claim 1, wherein the step S2 further comprises: when one of the instructions in the instruction sequence fails to process, executing the step M;
step M: and the terminal equipment sequentially splices the currently obtained operation results or the currently received operation results, corresponds to the number of unprocessed instructions in the instruction sequence, fills second preset data with the same number after the spliced operation results to obtain a response message, and returns the response message to the upper computer.
12. The method according to claim 1, wherein the step S2 further comprises: when one of the instructions in the instruction sequence fails to process, executing the step N;
and step N: and the terminal equipment returns an error code to the upper computer, and the operation is finished.
13. The method of claim 1,
in step S2, after the terminal device reads the instruction sequence in the command message, the method further includes:
the terminal equipment updates the counting identification according to a preset mode;
when one of the instructions in the instruction sequence fails to process, executing the step L;
step L: and the terminal equipment returns a failure operation result and the current count value of the count identification to the upper computer together, and the operation is finished.
14. The method according to claim 1, wherein in step S2, the method further comprises: and when the operation result received by the terminal equipment is smaller than a fourth preset value, returning the received operation result to the upper computer, and ending.
15. The method according to claim 1, wherein in step S2, when the terminal device reads the first instruction in the instruction sequence, before sending the read instruction to a card, the method further includes:
step P: the terminal equipment judges the card type, executes card selection operation according to the card type, and sends the read instruction to the card if the operation is successful; and if the operation fails, returning an error code to the upper computer, and ending.
16. The method according to claim 1, wherein in step S3, the terminal device returns the operation result to the upper computer, specifically:
the terminal equipment sequentially splices the operation results of the series of data element structures to obtain a response message, and returns the response message to the upper computer;
or,
the terminal equipment sequentially splices the series of operation results, adds a preset separation mark between every two adjacent operation results to obtain a response message, and returns the response message to the upper computer;
or,
and the last operation result in the series of operation results of the terminal equipment is returned to the upper computer.
17. A high efficiency data processing terminal device, comprising:
the device comprises a first receiving module, a first reading module, an executing module and a first sending module;
or,
the first receiving module, the first reading module, the first sending module, the second sending module and the second receiving module;
the first receiving module is used for receiving a command message sent by the upper computer;
the first reading module: the command message processing module is used for reading a command sequence in the command message received by the first receiving module;
the execution module is used for sequentially executing corresponding operations according to the instruction sequence read by the first reading module to obtain a series of operation results;
the second sending module is used for sequentially sending the instruction sequence read by the first reading module to a card;
the second receiving module is used for receiving the operation result returned by the card;
and the first sending module is used for returning an operation result to the upper computer when the instruction sequence in the command message is completely processed.
18. The terminal device according to claim 17, further comprising: a first judgment module;
the first judging module is configured to judge whether the command message received by the first receiving module is correct before the first reading module reads the instruction sequence in the command message received by the first receiving module;
the first reading module is specifically configured to: when the first judging module judges that the command message received by the first receiving module is correct, reading an instruction sequence in the command message received by the first receiving module;
and the first sending module is also used for returning an error code to the upper computer and ending when the first judging module judges that the command message received by the first receiving module is incorrect.
19. The terminal device of claim 18, wherein the first determining module is specifically configured to:
judging whether the length of the data on the first preset byte in the command message is equal to the total length of each data element corresponding to the instruction sequence in the command message, if so, confirming that the command message is correct, otherwise, confirming that the command message is incorrect;
or,
and judging whether the length of the data on the first preset byte in the command message is equal to the total length of the instruction sequence and each separation mark in the command message, if so, determining that the command message is correct, and otherwise, determining that the command message is incorrect.
20. The terminal device of claim 17, wherein the first reading module is specifically configured to:
analyzing the command message to obtain each data element, and reading an instruction in each data element to obtain an instruction sequence;
or,
and analyzing the command message to obtain each separation identifier, and reading an instruction according to each obtained separation identifier to obtain an instruction sequence.
21. The terminal device according to claim 17, further comprising: a second judgment module;
the first reading module is specifically configured to: taking an unread instruction in an instruction sequence in the command message as current data to be processed, reading a first instruction in the current data to be processed, and taking the first instruction as a current instruction;
the execution module is specifically configured to: executing corresponding operation according to the current instruction to obtain an operation result;
the second sending module is specifically configured to: sending the current instruction to a card;
the second judgment module is specifically configured to: judging whether the current instruction is the last instruction in the current data to be processed;
the first sending module is specifically configured to: when the second judging module judges that the current instruction is the last instruction in the current data to be processed, the second judging module confirms that all instruction sequences in the command message are processed, and returns an operation result to the upper computer;
the first reading module is further configured to, when the second determining module determines that the current instruction is not the last instruction in the current data to be processed, take an instruction that is not read from the instruction sequence in the command message as the current data to be processed, and read the first instruction in the current data to be processed as the current instruction.
22. The terminal device according to claim 17, further comprising: the device comprises a first storage module, a second judgment module, a second reading module, a first removal module and a third judgment module;
the first reading module is used for taking an unread instruction in the instruction sequence in the command message as current data to be analyzed and reading a first instruction in the current data to be analyzed;
the first storage module is used for storing the order of the instructions read by the first reading module into a preset storage area;
the second judging module is used for judging whether the instruction read by the first reading module is the last instruction in the current data to be analyzed;
the first reading module is further configured to, when the second determining module determines that the instruction read by the first reading module is not the last instruction in the current data to be analyzed, take an instruction not read in the instruction sequence in the command message as the current data to be analyzed, and read a first instruction in the current data to be analyzed;
the second reading module is configured to, when the second determining module determines that the instruction read by the first reading module is the last instruction in the current data to be analyzed, take the instruction in the preset storage area as the current data to be processed, and read the first instruction in the current data to be processed as the current instruction;
the execution module is used for executing corresponding operation according to the current instruction read by the second reading module to obtain an operation result;
the second sending module is specifically configured to: sending the current instruction read by the second reading module to a card;
the first removing module is used for removing the current instruction from the preset storage area after the executing module executes corresponding operation according to the current instruction to obtain an operation result; the second receiving module is further used for removing the current instruction from the preset storage area after receiving an operation result returned by the card;
the third judging module is used for judging whether the preset storage area has instructions after the current instructions are removed from the preset storage area by the first removing module;
the second reading module is further configured to, when the third determining module determines that there is an instruction in the preset storage area, take the instruction in the preset storage area as current data to be processed, and read a first instruction in the current data to be processed as a current instruction;
the first sending module is specifically configured to: and when the third judging module judges that no instruction exists in the preset storage area, the third judging module confirms that all instruction sequences in the instruction message are processed, and returns an operation result to the upper computer.
23. The terminal device according to claim 17, further comprising: the device comprises a second storage module, a fourth judgment module, a detection module, a third reading module, a second removal module and a fifth judgment module;
the first reading module is used for taking an unread instruction in the instruction sequence in the command message as current data to be analyzed and reading a first instruction in the current data to be analyzed;
the second storage module is further configured to store the instruction sequence read by the first reading module into a preset storage area;
the fourth judging module is configured to judge whether the instruction read by the first reading module is the last instruction in the current data to be analyzed;
the first reading module is further configured to, when the fourth determining module determines that the instruction read by the first reading module is not the last instruction in the current data to be analyzed, take an instruction not read in the instruction sequence as the current data to be analyzed, and read the first instruction in the current data to be analyzed;
the terminal device operates the first reading module, the second storing module and the fourth judging module, and also operates the detecting module, the third reading module, the executing module, the second removing module and the fifth judging module; or, the detection module, the third reading module, the second sending module, the second removing module and the fifth judging module are also operated;
the detection module is used for accessing the preset storage area and detecting whether an instruction exists in the preset storage area;
the third reading module is configured to, when the detection module detects that there is an instruction in the preset storage area, take the instruction in the preset storage area as current data to be processed, and read a first instruction in the current data to be processed as a current instruction;
the execution module is specifically configured to: executing corresponding operation according to the current instruction read by the third reading module to obtain an operation result;
the second sending module is specifically configured to: sending the current instruction read by the third reading module to a card;
the second removing module is used for removing the current instruction from the preset storage area after the executing module executes corresponding operation according to the current instruction to obtain an operation result; the second receiving module is further used for removing the current instruction from the preset storage area after receiving an operation result returned by the card;
the fifth judging module is configured to judge whether there are any instructions in the preset storage area after the second removing module removes the current instruction from the preset storage area;
the third reading module is further configured to, when the fifth judging module judges that there are instructions in the preset storage area, take the instructions in the preset storage area as current data to be processed, and read a first instruction in the current data to be processed as a current instruction;
the first sending module is specifically configured to: and when the fifth judgment module judges that no instruction exists in the preset storage area, the fifth judgment module confirms that all instruction sequences in the instruction message are processed, and returns an operation result to the upper computer.
24. The terminal device according to claim 17, further comprising: a sixth judging module and a second executing module;
the sixth judging module is configured to judge whether data on a first byte in a data element corresponding to a current instruction to be sent is a first preset value before the second sending module sends the instruction sequence to the card in sequence;
the second execution module is configured to execute a card reset operation when the sixth judgment module judges that data on a first byte in a data element corresponding to the current instruction to be sent is a first preset value;
the second sending module is specifically configured to: and when the sixth judging module judges that the data on the first byte in the data element corresponding to the current instruction to be sent is not the first preset value, sending the current instruction to be sent to the card.
25. The terminal device according to claim 17, further comprising: a seventh judging module and an eighth judging module;
the seventh judging module is configured to, when the operation result returned by the card is an operation failure, judge whether an instruction corresponding to the operation failure result is a last instruction in the instruction sequence;
the first sending module is further configured to: when the seventh judging module judges that the instruction corresponding to the operation failure result is the last instruction in the instruction sequence, the instruction sequence in the command message is confirmed to be completely processed, and the operation result is returned to the upper computer;
the eighth judging module is configured to, when the seventh judging module judges that the instruction corresponding to the operation failure result is not the last instruction in the instruction sequence, judge whether to continue reading the instruction that is not read in the instruction sequence;
the first reading module is further configured to read the instruction sequence in the command message when the eighth determining module determines to continue reading the unread instruction in the instruction sequence;
and the first sending module is further used for returning the received operation result to the upper computer and ending when the eighth judging module judges that the unread instruction in the instruction sequence is not continuously read.
26. The terminal device of claim 25, wherein the eighth determining module is specifically configured to:
performing AND operation on data on a third preset byte in a data element corresponding to the instruction corresponding to the operation failure result and a second preset value to obtain an operation result, converting the operation result into a binary representation, judging whether data on a highest position in the operation result of the binary representation is first preset data, if so, confirming to continue to read the unread instruction in the instruction sequence, and otherwise, confirming to not continue to read the unread instruction in the instruction message;
or,
and judging whether the data on the fourth preset byte in the data element corresponding to the instruction corresponding to the operation failure result is a third preset value, if so, confirming to continue reading the unread instruction in the instruction sequence, and otherwise, confirming not to continue reading the unread instruction in the instruction sequence.
27. The terminal device according to claim 17, wherein the first sending module is further configured to, when processing of one of the instructions in the instruction sequence fails, sequentially splice currently-obtained operation results or currently-received operation results, correspond to the number of unprocessed instructions in the instruction sequence, fill the same number of second preset data after the spliced operation results to obtain a response packet, and return the response packet to the upper computer.
28. The terminal device according to claim 17, wherein the first sending module is further configured to return an error code to the upper computer when one of the instructions in the instruction sequence fails to process.
29. The terminal device according to claim 17, further comprising: an update module;
the updating module is used for updating the counting identifier according to a preset mode after the first reading module reads the instruction sequence in the command message;
and the first sending module is further used for returning the failure operation result and the current count value of the count identifier to the upper computer when one instruction of the instruction sequence fails to be processed.
30. The terminal device of claim 17,
the first sending module is further configured to return the received operation result to the upper computer when the operation result received by the second receiving module is smaller than a fourth preset value.
31. The terminal device according to claim 17, further comprising: a ninth judging module and a card selecting module;
the ninth judging module is configured to judge a card type before the second sending module sends the instruction read by the first reading module to a card when the first reading module reads the first instruction in the instruction sequence;
the card selecting module is used for executing card selecting operation according to the card type judged by the ninth judging module;
the second sending module is specifically configured to: when the card selecting module is successfully operated, sending the instruction read by the first reading module to a card;
the first sending module is further used for returning an error code to the upper computer when the card selecting module fails to operate.
32. The terminal device of claim 17, wherein the first sending module is specifically configured to:
splicing the operation results of the series of data element structures in sequence to obtain a response message, and returning the response message to the upper computer;
or,
sequentially splicing the series of operation results, adding a separation mark between every two adjacent operation results to obtain a response message, and returning the response message to the upper computer;
or,
and returning the last operation result in the series of operation results to the upper computer.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710003731.5A CN106528053B (en) | 2017-01-04 | 2017-01-04 | A kind of terminal device high efficiency data processing method and its terminal device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710003731.5A CN106528053B (en) | 2017-01-04 | 2017-01-04 | A kind of terminal device high efficiency data processing method and its terminal device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106528053A true CN106528053A (en) | 2017-03-22 |
CN106528053B CN106528053B (en) | 2019-02-15 |
Family
ID=58336861
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710003731.5A Active CN106528053B (en) | 2017-01-04 | 2017-01-04 | A kind of terminal device high efficiency data processing method and its terminal device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106528053B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107577969A (en) * | 2017-09-19 | 2018-01-12 | 恒宝股份有限公司 | A kind of smart card and its personalization method |
CN107727082A (en) * | 2017-11-09 | 2018-02-23 | 国家海洋局第二海洋研究所 | A kind of modular system of monitering buoy in real time |
CN108202329A (en) * | 2017-12-31 | 2018-06-26 | 芜湖哈特机器人产业技术研究院有限公司 | A kind of method that robot demonstrator is communicated with controller data with parsing |
CN111930425A (en) * | 2020-06-23 | 2020-11-13 | 联宝(合肥)电子科技有限公司 | Data control method and device and computer readable storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050190761A1 (en) * | 1997-06-10 | 2005-09-01 | Akifumi Nakada | Message handling method, message handling apparatus, and memory media for storing a message handling apparatus controlling program |
CN101383994A (en) * | 2007-09-07 | 2009-03-11 | 凤凰微电子(中国)有限公司 | Data processing method for APDU command |
US20090187709A1 (en) * | 2008-01-23 | 2009-07-23 | Phison Electronics Corp. | Method, system and controller for transmitting and dispatching data stream |
US20090319256A1 (en) * | 2008-06-20 | 2009-12-24 | Vmware, Inc. | Decoupling dynamic program analysis from execution across heterogeneous systems |
CN102541639A (en) * | 2011-12-26 | 2012-07-04 | 北京握奇数据系统有限公司 | CPU (Central Processing Unit) card data processing method, CPU card data processing system and CPU card |
CN103345610A (en) * | 2013-06-20 | 2013-10-09 | 武汉天喻信息产业股份有限公司 | Device and method for quickly verifying data integrity of intelligent card |
CN104092675A (en) * | 2014-06-30 | 2014-10-08 | 飞天诚信科技股份有限公司 | Reverse processing method and terminal based on main communication structure and auxiliary communication structure |
-
2017
- 2017-01-04 CN CN201710003731.5A patent/CN106528053B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050190761A1 (en) * | 1997-06-10 | 2005-09-01 | Akifumi Nakada | Message handling method, message handling apparatus, and memory media for storing a message handling apparatus controlling program |
CN101383994A (en) * | 2007-09-07 | 2009-03-11 | 凤凰微电子(中国)有限公司 | Data processing method for APDU command |
US20090187709A1 (en) * | 2008-01-23 | 2009-07-23 | Phison Electronics Corp. | Method, system and controller for transmitting and dispatching data stream |
US20090319256A1 (en) * | 2008-06-20 | 2009-12-24 | Vmware, Inc. | Decoupling dynamic program analysis from execution across heterogeneous systems |
CN102541639A (en) * | 2011-12-26 | 2012-07-04 | 北京握奇数据系统有限公司 | CPU (Central Processing Unit) card data processing method, CPU card data processing system and CPU card |
CN103345610A (en) * | 2013-06-20 | 2013-10-09 | 武汉天喻信息产业股份有限公司 | Device and method for quickly verifying data integrity of intelligent card |
CN104092675A (en) * | 2014-06-30 | 2014-10-08 | 飞天诚信科技股份有限公司 | Reverse processing method and terminal based on main communication structure and auxiliary communication structure |
CN104092675B (en) * | 2014-06-30 | 2017-08-11 | 飞天诚信科技股份有限公司 | Positive method and terminal is rushed in a kind of processing based on master-slave communication mechanism |
Non-Patent Citations (1)
Title |
---|
黄健: "智能卡COS的研究与设计", 《中国优秀硕士学位论文全文数据库信息科技辑》 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107577969A (en) * | 2017-09-19 | 2018-01-12 | 恒宝股份有限公司 | A kind of smart card and its personalization method |
CN107577969B (en) * | 2017-09-19 | 2018-10-12 | 恒宝股份有限公司 | A kind of smart card and its personalization method |
CN107727082A (en) * | 2017-11-09 | 2018-02-23 | 国家海洋局第二海洋研究所 | A kind of modular system of monitering buoy in real time |
CN107727082B (en) * | 2017-11-09 | 2023-08-04 | 自然资源部第二海洋研究所 | Modularized system for monitoring buoy in real time |
CN108202329A (en) * | 2017-12-31 | 2018-06-26 | 芜湖哈特机器人产业技术研究院有限公司 | A kind of method that robot demonstrator is communicated with controller data with parsing |
CN111930425A (en) * | 2020-06-23 | 2020-11-13 | 联宝(合肥)电子科技有限公司 | Data control method and device and computer readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN106528053B (en) | 2019-02-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106528053B (en) | A kind of terminal device high efficiency data processing method and its terminal device | |
CN103995191A (en) | Method and device for identifying model of air conditioner | |
CN103051674A (en) | Method and device for remotely upgrading wireless communication module as well as handheld unit (HHU) | |
CN1835454B (en) | event notification management method and event notification management device | |
US20170171355A1 (en) | Method for transferring a new software version to at least one electricity meter via a communication network | |
CN110831050A (en) | Sensor node control method and system | |
CN111786941A (en) | Automatic identification method and communication method for communication protocol | |
CN104376296A (en) | Barcode reader setting method and barcode reader setting device | |
CN110868458A (en) | Communication method and device for stable control system | |
CN110806973A (en) | Automatic generation method and device of interface message | |
US20190208471A1 (en) | Smart card control method and device, terminal device and smart card | |
CN112312374A (en) | Device and method for upgrading firmware of single chip microcomputer based on NFC | |
CN107957883B (en) | Data processing method, 51 single chip microcomputer, equipment and readable storage medium | |
CN116561818A (en) | Industrial control system internal logic analysis method, system, equipment and medium | |
CN108958765B (en) | Method and device for upgrading optical module firmware | |
CN105791514B (en) | Application starting monitoring method and device | |
CN112988540A (en) | Primitive replacement method, system, computer readable storage medium and terminal equipment | |
CN113112786B (en) | Multi-data reading method, medium and electronic equipment for ammeter | |
CN115733873A (en) | Data reading method based on energy router device modeling configuration file | |
CN104361308A (en) | STM32-based handheld two-dimension code recognizer | |
CN111399830B (en) | Application program capacity monitoring method and device, electronic equipment and storage medium | |
CN104731992A (en) | Distribution automation modeling method and distribution automation modeling device | |
CN103237359B (en) | A kind of method and device connecting terminal | |
CN113110991A (en) | Page element positioning method and device, storage medium and electronic device | |
CN107463374B (en) | Subset model extraction method and system based on inheritance and association automatic deduction |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |