Abstract:
A method for detecting that a contactless CPU card leaves a radio-frequency field relates to the field of smart cards. The method comprises: receiving and judging whether a valid instruction sent by an upper computer is received, and conducting a corresponding operation according to the received instruction; as a notification card search instruction, conducting a card search operation, and judging whether returned information is received; obtaining card number information about a contactless card according to the returned information; as an APDU instruction, sending A data to the card in accordance with a designated format, judging whether a response is received, and sending the operation result to the upper computer; as an extension instruction, executing a corresponding operation, and sending the operation result to the upper computer; when a valid instruction is not received, judging the mark of the card in the radio-frequency field, and if the card is in the radio-frequency field, conducting a card detection operation, and sending the operation result to the upper computer; and if the card is not in the radio-frequency field, conducting a card search operation. The present invention can detect the problem that a CPU card leaves a radio-frequency field in real time.

Description:
TECHNICAL FIELD 
       [0001]    The invention relates to smart card field, more particularly relates to a method for detecting whether a contactless CPU card has left a radio frequency field. 
       PRIOR ART 
       [0002]    Contactless card, which is called radio frequency card, is made up of IC chip and inductive antenna which are sealed in a standard PVC card. No part of the chip and the antenna are exposed. Contactless card is a new technology which is developed in recent years. The technology successfully combines radio frequency identification technology and IC card reader and writer together, which solves problem of powerlessness (no power inside a card) and avoids contact and is a great breakthrough in electronic component field. When a card is close to surface of a card reader and writer in a certain distance range (usually from 5-10 mm), data reading and writing operation is completed by transmission of radio wave. 
         [0003]    Radio frequency identification performs contactless and bidirectional data transmission between a card reader and a contactless CPU card by radio frequency so as to achieve purpose of target identification and data exchange. Radio frequency identification is classified into low frequency (LF), high frequency (HF) and ultra high frequency (UHF) according to applied frequency; correspondingly, representative frequencies are low frequency lower than 135 KHz, high frequency of 13.56 MHz and ultra frequency of 860-960 MHz respectively; circuit of contactless CPU card includes main parts such as central processing unit (CPU), read only memory (ROM), Random Access Memory (RAM), Electrically Erasable Programmable Read-Only Memory (EEPROM) and chip operating system (COS), etc., which is like an ultra small computer. 
         [0004]    In process of detecting contactless CPU card, inventors find that following problems exist in the prior art. After card seeking is activated, operation of detecting whether a card is in the radio frequency field cannot be performed at real time at the time interval of data interaction between the card and a master computer. General method is performing card seeking operation again which will disturb original operation status of the card. 
       SUMMARY OF THE INVENTION 
       [0005]    The object of the present invention is to provide a method for detecting whether a contactless CPU card has left a radio frequency field, which is a method for detecting whether a contactless CPU card leaves radio frequency field at real time without affecting original operation status of the contactless CPU card. 
         [0006]    Therefore, the present invention provides a method for detecting whether a contactless CPU card has left radio frequency field, comprising 
         [0007]    Step A, a card reader obtaining an instruction and determining whether the instruction is valid instruction, if yes, go to Step B; otherwise, go to Step C; 
         [0008]    Step B, the card reader determining the type of the valid instruction; 
         [0009]    If the type is instruction on informing to seek a card, to Step D; 
         [0010]    if the type is APDU instruction, sending the APDU instruction to the card and sending a response returned by the card to a master computer via USB interrupting channel; go back to Step A; 
         [0011]    if the type is extension instruction, performing operation according to the extension instruction and sending result of the operation to the master computer via USB interrupting channel; go back to Step A; 
         [0012]    Step C, the card reader determining that whether flag of the card in the radio frequency field is set, if yes, go to Step E; otherwise, go to Step D; 
         [0013]    Step D, the card reader sending card seeking instruction to the card and determining whether receives a card seeking response returned by the card, if yes, setting the flag of the card in the radio frequency field and sending the response that the card is in the radio frequency field to the master computer via USB interrupting channel; otherwise, resetting the flag of the card in the radio frequency field and sending the response that card leaves the radio frequency field to the master computer via USB interrupting channel; go back to Step A; 
         [0014]    Step E, the card reader sending detecting instruction to the card and determining whether receives detecting response returned by the card successfully, if yes, storing the detecting response and go to Step F; otherwise, go to Step G; 
         [0015]    Step F, the card reader setting the flag of the card in the radio frequency field, and sending the response that the card is in the radio frequency field to the master computer via USB interrupting channel; go back to Step A; 
         [0016]    Step G, the card reader resetting the flag of the card in the radio frequency field and sending the response that the card leaves the radio frequency field to the master computer via USB interrupting channel; go back to Step A. 
         [0017]    Preferably, sending response that the card is in the radio frequency field to the master computer via USB interrupting channel specifically comprises 
         [0018]    determining whether recorded card status is that the card is in the radio frequency field, if yes, go back to Step A; otherwise, updating the recorded card status to be that the card leaves the radio frequency field and go back to Step A; 
         [0019]    informing the master computer of the response that the card leaves the radio frequency field via USB interrupting channel specifically comprises 
         [0020]    determining whether recorded card status is that card leaves radio frequency, if yes, go back to Step A; otherwise, updating the recorded card status to be that card leaves radio frequency field, go back to Step A. 
         [0021]    Preferably, determining whether the instruction is valid instruction specifically comprises 
         [0022]    the card reader receiving instruction sent from buffer via interrupting way; if the first byte of the instruction is identical to a predetermined character, the card reader receiving the valid instruction; otherwise, the card reader does not receive valid instruction. 
         [0023]    Preferably, before Step A, the method comprises 
         [0024]    the card reader being powered up and being initialized and switching on communication interruption enabling; 
         [0025]    the method further comprises when the card reader detects communication interrupting, the card reader entering communication interrupting process, which comprises 
         [0026]    StepS 1 , the card reader switching off communication interruption enabling and clearing communication interrupting flag; 
         [0027]    StepS 2 , the card reader receiving an instruction issued by the master computer and determining whether the instruction is valid instruction, if yes, setting the flag of the instruction, switching on communication interruption enabling and exiting communication interrupting process; otherwise, switching on communication interruption enabling and exiting communicating interrupting process; 
         [0028]    Step A specifically comprises the card reader determining whether the flag of the instruction is set, if yes, resetting the flag of the instruction and go to Step B; if no, go to Step C. 
         [0029]    Preferably, determining whether the instruction is valid instruction in Step S 2  specifically comprises 
         [0030]    determining whether the first byte of the instruction is identical to a predetermined character, if yes, valid instruction being received, if no, valid instruction being not received. 
         [0031]    Preferably, the card reader sending detecting instruction to the card in Step E specifically comprises 
         [0032]    if it is the first time that the card reader sends the detecting instruction, the card reader sending a first predetermined character string to the card; 
         [0033]    if it is not the first time that the card reader sends the detecting instruction, the card reader determining the detecting instruction to be sent according to the detecting response, if the value of the last bit of the detecting response is 0, the card reader sending a first predetermined character string to the card; if the value of the last bit of the detecting response is 1, the card reader sending a second predetermined character string to the card. 
         [0034]    Preferably, determining whether successfully receives the detecting response returned by the card specifically comprises 
         [0035]    if the detecting instruction is the first predetermined character, the card reader determining whether the received response returned by the card is a first detecting response, if yes, receiving the detecting response returned by the card successfully and storing the response; if no, receiving the detecting response returned by the card unsuccessfully; 
         [0036]    if the detecting instruction is the second predetermined character, the card reader determining whether the received response returned by the card is a second detecting response, if yes, receiving the detecting response returned by the card successfully and storing the response; if no, receiving the detecting response returned by the card unsuccessfully. 
         [0037]    Preferably, Step B specifically comprises 
         [0038]    Step B 11 , the card reader determining type of the valid instruction, if the type is instruction on informing to seek a card, going to Step D; if the type is APDU instruction, going to Step B 12 ; if the type is extension instruction, going to Step B 13 ; 
         [0039]    Step B 12 , the card reader sending the APDU instruction to the card and determining whether receives a response returned by the card; if yes, setting the flag of the card in the radio frequency field and returning the received response to the master computer via USB interrupting channel; go back to Step A; otherwise, resetting the flag of the card in the radio frequency field and sending the response that the card leaves the radio frequency field to the master computer via USB interrupting channel; go back to Step A; 
         [0040]    Step B 13 , the card reader performing operation according to extension instruction and returning the result of operation to the master computer via USB interrupting channel; go back to Step A. 
         [0041]    Preferably, Step D specifically comprises 
         [0042]    Step D 11 , the card reader sending a first requesting instruction to the card and determining whether receives a first response returned by the card, if yes, go to Step D 12 ; otherwise, closing the radio frequency field; waiting for automatically opening radio frequency field in a predetermined time, resetting the flag of the card in the radio frequency field and sending response that the card leaves the radio frequency field to the master computer via USB interrupting channel; go back to Step A; 
         [0043]    Step D 12 , the card reader sending a second requesting instruction containing 0x93 and 0x20 to the card and obtaining first confirming information to the card; 
         [0044]    Step D 13 , the card reader obtaining a first data according to the first confirming information and fixed data and determining whether the first data is 0x00, if yes, cascade level of the card being 1 and storing the card number information in buffer; go to Step D 18 ; otherwise, go to Step D 14 ; 
         [0045]    Step D 14 , the card reader sending a third requesting instruction containing 0x95 and 0x20 to the card and obtaining second confirming information returned by the card; 
         [0046]    Step D 15 , the card reader obtaining a second data according to the second confirming information and the fixed data and determining whether the second data is 0x00, if yes, cascade level of the card being 2 and storing the card number information in the buffer, go to Step D 18 ; otherwise, go to Step D 16 ; 
         [0047]    Step D 16 , the card reader sending a fourth requesting instruction containing 0x97 and 0x20 to the card and obtaining a third confirming information; 
         [0048]    Step D 17 , the card reader obtaining a third data according to the third confirming information and the fixed data and determining whether the third data is 0x00, if yes, cascade level of the card being 3 and storing the card number information in the buffer and go to D 18 ; otherwise, closing radio frequency field; waiting for automatically opening the radio frequency field in a predetermined time, resetting the flag of the card in the radio frequency field and sending the response that the card leaves the radio frequency field to the master computer via USB interrupting channel; go back to Step A; 
         [0049]    Step D 18 , the card reader sending a request selecting and answering instruction to the card and determining whether receives a selecting and answering response returned by the card, if yes, going to Step D 19 ; otherwise, resetting the flag of the card in the radio frequency field and sending the response that card leaves the radio frequency field to the master computer via USB interrupting channel; go back to Step A; 
         [0050]    Step D 19 , the card reader setting the flag of the card in the radio frequency field and sending the selecting and answering response and the response that the card is in the radio frequency field to the master computer via USB interrupting channel; go back to Step A. 
         [0051]    Preferably, Step D specifically comprises 
         [0052]    Step D 21 , the card reader sending a fifth requesting instruction to the card and determining whether receives a fifth response returned by the card, if yes, go to Step D 22 ; otherwise, closing the radio frequency field, waiting for automatically opening radio frequency field in a predetermine time, resetting the flag of the card in the radio frequency field and sending the response that the card leaves the radio frequency field to the master computer via USB interrupting channel, go back to Step A; 
         [0053]    Step D 22 , the card reader sending the request selecting and answering instruction and determining whether receives the selecting and answering response returned by the card, if yes, goes to Step D 23 ; otherwise, resetting the flag of the card in the radio frequency field and sending the response that the card leaves the radio frequency field to the master compute via USB interrupting channel; go back to Step A; 
         [0054]    Step D 23 , the card reader setting the flag of the card in the radio frequency field and sending the selecting and answering response and the response that the card is in the radio frequency field to the master computer via USB interrupting channel; go back to Step A. 
         [0055]    According to another aspect of the present invention, the present invention provides a method for detecting whether a contactless CPU card has left radio frequency field, comprising 
         [0056]    Step a, a card reader switching on regular interruption enabling; 
         [0057]    Step b, the card reader receiving instruction sent by the master computer and determining whether receives valid instruction, if yes, determining the type of the valid instruction, if the type is instruction on informing to seek a card, goes to Step c; if the type is APDU instruction, go to Step d; if the type is extension instruction, go to Step e; otherwise, go to Step f; 
         [0058]    Step c, the card reader switching off regular interruption enabling, sending card seeking instruction to the card and determining whether receives a card seeking response returned by the card, if yes, setting the flag of the card in the radio frequency field and switching on regular interruption enabling, goes to Step f; otherwise, resetting the flag of the card in the radio frequency field and switching on regular interruption enabling, go to Step f; 
         [0059]    Step d, the card reader switching off regular interruption enabling, sending the APDU instruction to the card and determining whether receives a response returned by the card, if yes, setting the flag of the card in the radio frequency field, sending the received response to the master computer via USB interrupting channel and switching on regular interruption enabling, go to Step f; otherwise, resetting the flag of the card in the radio frequency field and switching on regular interruption enabling, go to Step f; 
         [0060]    Step e, the card reader switching off regular interruption enabling, performing operation according to the extension instruction, sending the operation result to the master computer via USB interrupting channel and switching on regular interruption enabling, go to Step f; 
         [0061]    Step f, the card reader determining whether the flag of the card in the radio frequency field is set, if yes, sending the response that the card is in the radio frequency field to the master computer via USB interrupting channel, go back to Step a; otherwise, sending the response that the card leaves the radio frequency field to the master computer via USB interrupting channel, go back to Step a; 
         [0062]    when the card reader receives triggering of regular interrupting, entering regular interrupting process, comprising 
         [0063]    Step g, the card reader switching off regular interruption enabling and clearing regular interrupting flag 
         [0064]    Step h, the card reader determining whether the flag of the card in the radio frequency field is set, if yes, go to Step l otherwise, sending card seeking instruction to the card and determining whether receiving a card seeking response returned by the card, if yes, go to Step l; otherwise, go to Step m; 
         [0065]    Step i, the card reader sending detecting instruction to the card and determining whether receives a detecting response returned by the card, if yes, storing the detecting response and go to Step l; otherwise, go to Step m; 
         [0066]    Step l, the card reader switching on regular interruption enabling, exiting regular interrupting process; 
         [0067]    Step m, the card reader resetting the flag of the card in the radio frequency field, switching on regular interruption enabling, exiting regular interrupting process. 
         [0068]    Preferably, Step c specifically comprises 
         [0069]    Step c 11 , the card reader switching off regular interruption enabling, sending a first requesting instruction to the card, determining whether receives a first response returned by the card, if yes, go to Step c 12 ; otherwise, closing radio frequency field, waiting for automatically opening radio frequency filed in a predetermined time, resetting the flag of the card in the radio frequency field and switching on regular interruption enabling, go to Step f; 
         [0070]    Step c 12 , the card reader sending a second requesting instruction containing 0x9 3 and 0x20 to the card and obtaining a first confirming information returned by the card; 
         [0071]    Step c 13 , the card reader obtaining a first data according to a first confirming information and fixed data and determining whether a first data is 0x00, if yes, cascade level of the card being 1, storing card number information in buffer, go to Step c 18 ; otherwise, go to Step c 14 ; 
         [0072]    Step c 14 , the card reader sending a third requesting instruction containing 0x95 and 0x20 to the card and obtaining a second confirming information returned by the card; 
         [0073]    Step c 15 , the card reader obtaining a second data according to the second confirming information and the fixed data and determining whether the second data is 0x00, if yes, cascade level of the card being 2 and storing card number information in the buffer, go to Step c 18 ; otherwise, go to Step c 16 ; 
         [0074]    Step c 16 , the card reader sending a fourth requesting instruction containing 0x97 and 0x20 to the card and obtaining a third confirming information; 
         [0075]    Step c 17 , the card reader obtaining a third data according to the third confirming information and fixed data and determining whether the third data is 0x00, if yes, cascade level of the card being 3 and storing card number information in the buffer, go to Step c 18 ; otherwise, closing the radio frequency field, waiting for automatically opening radio frequency field in a predetermined time, resetting the flag of the card in the radio frequency field and switching on regular interruption enabling, go to Step f; 
         [0076]    Step c 18 , the card reader sending request selecting and answering instruction to the card and determining whether receives a selecting and answering response returned by the card, if yes, go to Step c 19 ; otherwise, resetting the flag of the card in the radio frequency field and switching on regular interruption enabling; go to Step f; 
         [0077]    Step c 19 , the card reader setting the flag of the card in the radio frequency field and sending the selecting and answering response to the master computer via USB interrupting channel and switching on regular interruption enabling, go to Step f. 
         [0078]    Preferably, Step c specifically comprises 
         [0079]    Step c 21 , the card reader switching off regular interruption enabling, sending a fifth requesting instruction to the card and determining whether receives a fifth response returned by the card, if yes, go to Step c 22 , otherwise, closing radio frequency field and waiting for automatically opening radio frequency field, resetting the flag of the card in the radio frequency field and switching on regular interruption enabling; go to Step f; 
         [0080]    Step c 22 , the card reader sending a request selecting and answering instruction to the card and determining whether receives a selecting and answering response returned by the card, if yes, goes to Step c 23 ; otherwise, resetting the flag of the card in the radio frequency field and switching on regular interruption enabling; go to Step f; 
         [0081]    Step c 23 , the card reader setting the flag of the card in the radio frequency field, sending the selecting and answering response to the master computer and switching on regular interruption enabling, go to Step f. 
         [0082]    Preferably, if no valid instruction is received in Step b, going on waiting for receiving instruction; 
         [0083]    Steps c to f, Steps l to m are replaced with Steps c′ to e′ and Steps l′ to m′ respectively; 
         [0084]    Step c′, the card reader switching off regular interruption enabling and sending card seeking instruction to the card and determining whether a card seeking response is returned by the card, if yes, setting the flag of the card in the radio frequency field and sending the response that the card is in the radio frequency field to the master computer via USB interrupting channel; go back to Step a; otherwise, resetting the flag of the card in the radio frequency field and sending a response that the card leaves radio frequency field to the master computer via USB interrupting channel, go back to Step a; 
         [0085]    Step d′, the card reader switching off regular interruption enabling, sending the APDU instruction to the card and determining whether receives a response returned by the card, if yes, setting the flag of the card in the radio frequency field and sending the received response and the response that the card is in the radio frequency field to the master computer via USB interrupting channel, go back to Step a; otherwise, resetting the flag of the card in the radio frequency field and sending the response that the card is in the radio frequency field to the master computer via USB interrupting channel, go back to Step a; 
         [0086]    Step e′, the card reader switching off regular interruption enabling, performing operation according to the extension instruction and sending the operation result to the master computer via USB interrupting channel, go back to Step a; 
         [0087]    Step l′, the card reader setting the flag of the card in the radio frequency field, sending the response that the card is in the radio frequency field to the master computer via USB interrupting channel, switching on regular interruption enabling and exiting regular interrupting process; 
         [0088]    Step m′, the card reader resetting the flag of the card in the radio frequency field, sending the response that the card leaves the radio frequency field to the master computer via USB interrupting channel, switching on regular interruption enabling and exiting regular interrupting process. 
         [0089]    Preferably, Step c′ specifically comprises 
         [0090]    Step c′ 11 , the card reader switches off regular interruption enabling, sending a first requesting instruction to the card and determining whether receives a first response returned by the card, if yes, go to Step c′ 12 ; otherwise, closing radio frequency field, waiting for automatically opening radio frequency field in a predetermined time, resetting the flag of the card in the radio frequency field and sending the response that the card leaves the radio frequency field to the master computer via USB interrupting channel, go back to Step a; 
         [0091]    Step c′ 12 , the card reader sending a second requesting instruction containing 0x93 and 0x20 to the card and obtaining first confirming information returned from the card; 
         [0092]    Step c′ 13 , the card reader obtaining a first data according to the first confirming information and fixed data and determining whether the first data is 0x00, if yes, cascade level of the card being 1 and storing the card number information in buffer, go to Step c′ 18 ; otherwise, go to Step c′ 14 ; 
         [0093]    Step c′ 14 , the card reader sending a third requesting instruction containing 0x95 and 0x20 to the card and obtaining second confirming information returned by the card; 
         [0094]    Step c′ 15 , the card reader obtaining a second data according to the second confirming information and the fixed data and determining whether the second data is 0x00, if yes, cascade level of the card is 2 and storing the card number information in the buffer, go to Step c′ 18 ; otherwise, go to Step c′ 16 ; 
         [0095]    Step c′ 16 , the card reader sending a fourth requesting instruction containing 0x97 and 0x20 to the card and obtaining a third confirming information; 
         [0096]    Step c′ 17 , the card reader obtaining a third data according to the third confirming information and the fixed data and determining whether the third data is 0x00, if yes, cascade level of the card being 3 and storing the card number information in buffer, go to Step c′ 18 ; otherwise, closing radio frequency field, waiting for automatically opening radio frequency field in a predetermined time, restoring the flag of the card in the radio frequency field and sending the response that the card leaves the radio frequency field to the master computer via USB interrupting channel, go back to Step a; 
         [0097]    Step c′ 18 , the card reader sending a request selecting and answering instruction to the card and determining whether receives a selecting and answering response returned by the card, if yes, go to Step c′ 19 ; otherwise, resetting the flag of the card in the radio frequency field and sending the response that card leaves the radio frequency field to the master computer via USB interrupting channel, go back to Step a; 
         [0098]    Step c′ 19 , the card reader setting the flag of the card in the radio frequency field and sending the selecting and answering response and the response that the card is in the radio frequency field to the master computer via USB interrupting channel; go back to Step a. 
         [0099]    Preferably, Step c′ specifically comprises 
         [0100]    Step c′ 21 , the card reader switching off regular interruption enabling and sending a fifth requesting instruction to the card and determining whether receives a fifth response returned from the card, if yes, go to Step c′ 22 ; otherwise, closing radio frequency field, waiting for automatically opening on radio frequency field in a predetermined time, resetting the flag of the card in the radio frequency field and sending the response that the card leaves the radio frequency field to the master computer via USB interrupting channel, go back to Step a; 
         [0101]    Step c′ 22 , the card reader sending a request selecting and answering instruction to the card and determining whether receives the selecting and answering response returned by the card, if yes, go to Step c′ 23 ; otherwise, resetting the flag of the card in the radio frequency field and sending the response that the card leaves the radio frequency field to the master computer via USB interrupting channel; go back to Step a. 
         [0102]    Preferably, sending the response that the card is in the radio frequency field to the master computer via USB interrupting channel specifically comprises 
         [0103]    determining whether the recorded card status is that the card is in the radio frequency field, if yes, go back to Step a, otherwise, updating the recorded card status to be that the card is in the radio frequency field, go back to Step a; 
         [0104]    sending the response that the card leaves the radio frequency field to the master computer via USB interrupting channel specifically comprises 
         [0105]    determining whether recorded card status is that card leaves radio frequency field, if yes, go back to Step a; otherwise, updating the recorded card status to be that card leaves radio frequency field; go back to Step a. 
         [0106]    Preferably, determining whether the instruction is valid instruction specifically comprises 
         [0107]    the card reader receiving an instruction sent from the buffer via interrupting; if the first byte of the instruction is identical to a predetermined character, the valid instruction is received; otherwise, no valid instruction is received. 
         [0108]    Preferably, the card reader sending a detecting instruction to the card specifically comprises 
         [0109]    if it is the first time that the card sends the detecting instruction, the card reader sending a first predetermined character to the card; 
         [0110]    if it is not the first time that the card sends the detecting instruction, the card reader determines the detecting instruction to be sent according to the detecting response, if the value of the last bit of the detecting response is 0, the card reader sends the first predetermined character string to the card; if the value of the last bit of the detecting response is 1, the card reader sending a second predetermined character string to the card. 
         [0111]    Preferably, determining whether successfully receives the detecting response returned by the card specifically comprises 
         [0112]    if the detecting instruction is the first predetermined character string, the card reader determines whether the response returned by the card is a first detecting response, if yes, successfully receiving the detecting response returned by the card and storing the response; if no, unsuccessfully receiving the detecting response returned by the card; 
         [0113]    if the detecting instruction is the second predetermined character string, the card reader determines whether the response returned by the card is a second detecting response, if yes, successfully receiving the detecting response returned by the card and storing the response; if no, unsuccessfully receiving the detecting response returned by the card. 
         [0114]    The advantage of the present invention is that in free time, the card reader will send a detecting instruction to the card regularly so as to realize detecting whether the card is in the radio frequency field at real time. 
     
    
     
       BRIEF DESCRIPTION OF THE ACCOMPANYING DRAWINGS 
         [0115]      FIG. 1  is a flow chard of a method for detecting whether a contactless CPU card has left radio frequency field provided by Embodiment 1 of the present invention; 
           [0116]      FIG. 2A  and  FIG. 2B  are flow charts of a detailed method for detecting whether a contactless CPU card has left radio frequency field provided by Embodiment 2 of the present invention; 
           [0117]    FIG.  2 ′A and FIG.  2 ′B are flow charts of a detailed method for detecting whether a contactless CPU card has left radio frequency field provided by a variation of Embodiment 2 of the present invention; and 
           [0118]      FIG. 3A  and  FIG. 3B  are flow charts of a detailed method for detecting whether a contactless CPU card has left radio frequency field provided by Embodiment 3 of the present invention. 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0119]    In order to make the purpose, technical solution and advantages of the present invention become more clear, further detailed description of the embodiment of the present invention is presented by combining accompany drawings. 
         [0120]    In the embodiments of the present invention, for example, mentioned card reader is a contactless card reader and mentioned card is a contactless CPU card. 
       Embodiment 1 
       [0121]    Referring to  FIG. 1 , Embodiment 1 provides a method for detecting whether a card has left radio frequency field, which specifically includes following steps. 
         [0122]    Step  101 , a card reader is power up and initialized; 
         [0123]    In Embodiment 1, the initial value of flag of the card being in radio frequency (RF) field is 0. 
         [0124]    Step  102 , receive an instruction and determine whether receives a valid instruction; 
         [0125]    if yes, goes to Step  110 ; if no, goes to Step  103 . 
         [0126]    In Embodiment 1, the card reader receives an instruction sent from buffer via USB interrupting channel. If the first byte of the instruction is in a predetermined category (from 0x01 to 0x03), a valid instruction is received. For example, if the first byte of the received instruction is 0x01, a valid instruction is received. If the card reader does not receive an instruction or the first byte of a received instruction does not satisfy a predetermined value, the received instruction is not valid instruction. 
         [0127]    Step  103 , determine whether the flag of the card in the radio frequency field is 1; 
         [0128]    if yes, go to Step  104 ; if no, go to Step  111 . 
         [0129]    Step  104 , perform operation of detecting card; 
         [0130]    in Embodiment 1, if it is the first time that the card reader performs operation of detecting card, an issued detecting instruction is 0xB2; 
         [0131]    If it is not the first time that the card reader performs operation of detecting card, the card reader determines the issued detecting instruction according to the value of the last bit of the first byte of detecting instruction response returned by the card last time. For example, when the value of the last bit is 1, the card reader issues an instruction of 0xB2 to the card; while when the value of the last bit is 0, the card reader issues instruction of 0xB3 to the card. 
         [0132]    In process that the card reader sends detecting instruction at regular time, if a detecting instruction is interrupted, when the card reader sends next detecting instruction, the instruction will be changed. For example, 
         [0133]    the card reader sends detecting instruction 0xB2 to the card; after the card successfully makes corresponding response 0xA3, interruption is caused by interruption instruction; the card reader executes an interruption instruction; after completing of executing the interruption instruction, the card reader sends detecting instruction of 0xB3. 
         [0134]    Operation of detecting card specifically includes following steps. 
         [0135]    Step A, the card reader sends a detecting instruction at regular time; 
         [0136]    In Embodiment 1, the card reader sends a detecting instruction to the card at a predetermined regular time interval; preferably, the predetermined regular time interval is 5 ms. 
         [0137]    Step B, receive detecting instruction response made by the card and then go to Step  105 ; 
         [0138]    in Embodiment 1, the received response is 0xA3, or 0xA2, or other data. 
         [0139]    Step  105 , determine whether the detecting instruction response made by the card is received successfully; 
         [0140]    if yes, go to Step  107 ; otherwise, go to Step  106 . 
         [0141]    Specific determining method includes 
         [0142]    if the card reader sends detecting instruction of 0xB2 to the card, the card reader receives 0xA3 returned from the card reader, which means that the card reader receives the detecting instruction response made by the card successfully; 
         [0143]    if the card reader sends detecting instruction of 0xB3 to the card, the card reader receives 0xB2 returned from the card reader, which means that the card reader receives the detecting instruction response made by the card successfully; and 
         [0144]    if the card reader receives other response or a response which does not match its sent detecting instruction, it is regarded that the card reader receives the detecting instruction response unsuccessfully. 
         [0145]    Step  106 , inform the master computer of a response that the card leaves the radio frequency field via USB interrupting channel, clear flag of the card being in radio frequency field to be 0 and go to Step  109  or go to Step  102 ; 
         [0146]    in Embodiment 1, specifically the response that the card leaves the radio frequency field is 0x50, 0x02. 
         [0147]    Step  107 , inform the master computer of a response that the card is in the radio frequency field via USB interrupting channel, set the flag of the card in the radio frequency field as 1; then go to Step  108  or go to Step  102 ; 
         [0148]    in Embodiment 1, specifically, the response that the card is in the radio frequency field is 0x50, 0x03. 
         [0149]    Step  108 , receive an instruction and determine whether receives valid instruction; 
         [0150]    if yes, go to Step  110 ; otherwise, go to Step  104 . 
         [0151]    Determining method of Step  108  in Embodiment 1 can refer to Step  102 . No more detail is given here. 
         [0152]    Step  109 , receive an instruction and determine whether receives a valid instruction, 
         [0153]    if yes, go to Step  110 ; otherwise, go to Step  111 . 
         [0154]    Determining method of Step  110  in Embodiment 1 can refer to Step  102 . No more detail is given here. 
         [0155]    Step  110 , determine instruction type; 
         [0156]    in Embodiment 1, if the first byte of data received by the card reader is 0x01, the type is instruction on informing to seek a card and goes to Step  111 ; 
         [0157]    if the first byte of the received data is 0x02, the data is APDU instruction and goes to Step  115 ; 
         [0158]    if the first byte of the received data is 0x03, the data is extension instruction and goes to Step  118 . 
         [0159]    In Embodiment 1, extension instruction includes open/close radio frequency field instruction, lamp on/lamp off instruction, buzz instruction, etc. 
         [0160]    Step  111 , perform operation of the card seeking and determine whether the operation is successful; 
         [0161]    in Embodiment 1, for A type card, operation of the card seeking specifically includes 
         [0162]    Step A-1, sending a first requesting instruction to the card; 
         [0163]    in Embodiment 1, the first requesting instruction specifically is 0x52. 
         [0164]    Step A-2, determining whether a first response made by the card is received; 
         [0165]    in Embodiment 1, the first response is predetermined data which corresponds to the first requesting instruction; preferably, the predetermined data is data with two bytes, for example, 0x02, 0x00; 
         [0166]    if yes, goes to Step B-1; 
         [0167]    otherwise, closing radio frequency field and the card reader will wait for automatically opening radio frequency field in a predetermined time and then perform Step  106 ; preferably, the predetermined time period is 10 ms. 
         [0168]    Step B-1, sending data packet of 2 bytes, e.g. 0x93, 0x20, to the card; 
         [0169]    Step B-2, obtaining a first confirming information returned by the card; 
         [0170]    In Embodiment 1, process of obtaining a first confirming information returned by the card includes 
         [0171]    Step B-21, sending data packet of two bytes, e.g. 0x93 and 0x20, to the card; 
         [0172]    Step B-22, determining whether receives a second response data; 
         [0173]    In Embodiment 1, the second response data includes UID1 and BCC1; UID1 is a set of fixed data of segment of the card number with four bytes or a random number dynamically generated by the card; BCC1 is check byte of UID1; 
         [0174]    if yes, goes to Step B-23; 
         [0175]    if no, close radio frequency field; the card reader will wait for automatically opening radio frequency field in a predetermined time and then goes to Step  106 ; preferably, the predetermined time is 10 ms. 
         [0176]    Step B-23, sending data packet made up of 0x93, 0x70, UID1, BCC1 and CRC1 to the card; CRC1 is check detecting code; 
         [0177]    Step B-24, determining whether receives a first confirming information returned by the card; 
         [0178]    if yes, obtaining the first confirming information and goes to Step C-1; 
         [0179]    if no, closing radio frequency field; the card reader will wait for automatically opening radio frequency field in a predetermined time and goes to Step  106 ; preferably, the predetermined time is 10 ms; 
         [0180]    In Embodiment 1, the first confirming information is made up of S and CRC1; S1 represents starting communication. 
         [0181]    Step C-1, obtaining a first data which is obtained by performing AND operation on the first confirming information and fixed data; 
         [0182]    In Embodiment 1, the fixed data is 0x40. 
         [0183]    Step C-2, determining whether the first data is 0x00; 
         [0184]    if yes, cascade level of the card is 1 and storing the card information in buffer and goes to Step  112 ; 
         [0185]    if no, goes to Step D-1. 
         [0186]    Step D-1, sending data packet with 2 bytes, e.g. 0x95 and 0x20, to the card; 
         [0187]    Step D-2, obtaining a second confirming information returned by the card; 
         [0188]    In Embodiment 1, process of obtaining the second confirming information includes 
         [0189]    Step D-21, sending data packet with two bytes, e.g. 0x95 and 0x20, to the card; 
         [0190]    Step D-22, determining whether receives a third response data returned by the card; 
         [0191]    In Embodiment 1, the third response data include UID2 and BCC2; UID2 is card number segment of 4 bytes; BCC2 is check byte of UID2. 
         [0192]    if yes, goes to Step D-23; 
         [0193]    if no, closing frequency field; the card reader will wait for automatically opening radio frequency field in a predetermined time and go to Step  106 ; preferably, the predetermined time is set as 10 ms; 
         [0194]    Step D-23, sending data packet made up of 0x95, 0x70, UID2, BCC2 and CRC2 to the card; 
         [0195]    Step D-24, determining whether receives a second confirming information returned by the card; 
         [0196]    if yes, obtaining the second confirming information returned by the card and goes to Step E-1; 
         [0197]    if no, closing radio frequency field; the card reader will wait for automatically opening the radio frequency field in a predetermined time and goes to Step  106 ; preferably, the predetermined time is set as 10 ms; 
         [0198]    in Embodiment 1, the second confirming information is made up of S2 and CRC2; S2 represents starting communication. 
         [0199]    Step E-1, obtaining the second data by performing AND operation on the second confirming information and fixed data; 
         [0200]    In embodiment 1, the fixed data is 0x40. 
         [0201]    Step E-2, determining whether the second data is 0x00; 
         [0202]    if yes, the cascade level of the card is 2 and storing the card information in buffer and goes to Step  112 ; 
         [0203]    if no, goes to Step F-1. 
         [0204]    Step F-1, sending data packet with two bytes, e.g. 0x97 and 0x20, to the card; 
         [0205]    Step F-2, obtaining a third confirming information; 
         [0206]    In embodiment 1, process of obtaining the third confirming information includes 
         [0207]    Step F-21, sending data packet with two bytes e.g. 0x97 and 0x20, to the card; 
         [0208]    Step F-22, determining whether receives a fourth response data returned from the card; 
         [0209]    in Embodiment 1, the fourth response data includes UID3 and BCC3; UID3 is card number segment with four bytes; BCC3 is check byte of UID3; 
         [0210]    if yes, goes to Step F-23; 
         [0211]    if no, closing radio frequency field; the card reader will wait for automatically opening the radio frequency field in a predetermined time and goes to Step  106 ; preferably, the predetermined time is set as 10 ms; 
         [0212]    Step F-23, sending data packet made up of 0x97, 0x70, UID3, BCC3 and CRC3 to the card; 
         [0213]    Step F-24, determining whether receives the third confirming information returned from the card; 
         [0214]    In Embodiment 1, the third confirming information is made up of S3 and CRC3; S3 represents starting communication. 
         [0215]    if yes, obtaining the third confirming information and goes to Step G-1; 
         [0216]    if no, closing radio frequency field; the card reader will wait for automatically opening radio frequency field in a predetermined time and goes to Step  106 ; preferably, the predetermined time is set as 10 ms. 
         [0217]    Step G-1, obtaining a third data obtained by performing AND operation on the third confirming information and fixed data to obtain a third data; 
         [0218]    in Embodiment 1, the fixed data is 0x40. 
         [0219]    Step G-2, determining whether the third data is 0x00; 
         [0220]    if yes, cascade level is 3 and storing the card number information in buffer and goes to Step  112 ; 
         [0221]    if no, closing radio frequency field; the card reader will wait for automatically opening radio frequency field in a predetermined time and goes to Step  106 ; preferably, the predetermined time is set as 10 ms. 
         [0222]    In Embodiment 1, the cascade level corresponds to UID1; four bytes of UID1 are all card numbers; 
         [0223]    cascade level 2 corresponds to the cascade of UID1 and UID2; the first byte of the UID1 is invalid and only the last three bytes are taken; all four bytes of UID2 are taken; cascade level 2 has data of 7 bytes; 
         [0224]    cascade level 3 corresponds to cascade of UID1, UID2 and UID3; the first bytes of the UID1 and UID2 are invalid, only the last three bytes of UID1 and UID2 are taken respectively; all four bytes of UID3 are taken; cascade level 3 has data of 10 bytes. 
         [0225]    For B type card, the way of implementation is as the following. 
         [0226]    Step I, the card reader sends B type requesting instruction to the card; 
         [0227]    In Embodiment 1, specifically, B type requesting instruction is data with 5 bytes: 0x05, 0x00, 0x08, CRC (2byte). 
         [0228]    Step II, determine whether receives a response of B type request returned by the card; 
         [0229]    if yes, goes to Step  112 , if no, goes to Step  106 . 
         [0230]    In Embodiment 1, response of B type request specifically includes 0x1d, PUPI (4bytes), 0x00, 0x08, 0x01, 0x00, CRC (2bytes); PUPI represents card information. 
         [0231]    Step  112 , send request selecting and answering instruction to the card; 
         [0232]    in Embodiment 1, specifically, the request selecting and answering instruction is E0, 80, CRC. 
         [0233]    Step  113 , determine whether receives selecting and answering response; 
         [0234]    if yes, goes to Step  114 ; if no, goes to Step  106 . 
         [0235]    Step  114 , send selecting and answering response to the master computer via USB interrupting channel; and goes to Step  107 . 
         [0236]    Step  115 , send data A in specified format to the card; 
         [0237]    in Embodiment 1, specified format includes PCB, NAD/CID, data A, CRC; PCB represents Protocol Control Byte; NAD represents Node address; CID represents Card Identifier; CRC represents check detecting code. 
         [0238]    Step  116 , determine whether receives data B returned by the card; 
         [0239]    if yes, goes to Step  117 ; if no, goes to Step  106 . 
         [0240]    Step  117 , send data B to the master computer via USB interrupting channel; then goes to Step  107 . 
         [0241]    Step  118 , execute corresponding instruction and send executing result to the master computer via USB interrupting channel. 
         [0242]    In Embodiment 1, requesting lamp on instruction is taken as an example. After the card reader receives a requesting lamp on instruction sent by the master computer, the card reader performs lamp on operation and sends information of successful operation or failed operation to the master computer via USB interrupting channel. The information of successful operation is 0x00 and the information of failed operation is 0x01. 
         [0243]    In Embodiment 1 of the present invention, a response that the related card is in or is not in the radio frequency field is informed to the master computer via USB interrupting channel and the informed response that the card is in the radio frequency field is stored; before preparing for informing next time, determine whether the stored response is identical to a response to be sent, if they are identical, the informing need not be uploaded; otherwise, inform the master computer that the card is in the radio frequency field and stores response. 
       Embodiment 2 
       [0244]    Referring to  FIG. 2A  and  FIG. 2B , Embodiment 2 provides a method for detecting whether a card has left radio frequency filed, which specifically includes 
         [0245]    Step  201 , the card is powered up and initialized; 
         [0246]    Switch on regular interrupting. 
         [0247]    In Embodiment 2, the initial value of flag of the card in the radio frequency field is 0. 
         [0248]    Step  202 , receive instruction; 
         [0249]    In Embodiment 2, the instruction received by the card reader can be instruction on informing to seek a card, APDU instruction, extension instruction, which are sent by the master computer. 
         [0250]    Step  203 , determine whether receives valid instruction; 
         [0251]    if yes, go to Step  204 ; otherwise, go to Step  213 . 
         [0252]    The method of determining is the same as Step  102  in Embodiment 1. 
         [0253]    Step  204 , determine type of the instruction; 
         [0254]    in Embodiment 2, if the first byte of the instruction received by the card reader is 0x01, the type of the instruction is instruction on informing to seek a card and go to Step  205 ; 
         [0255]    If the received first byte of the instruction is 0x02, the type is APDU instruction and go to Step  217 ; 
         [0256]    If the received first byte of the instruction is 0x03, the type is extension instruction and goes to Step  223 ; 
         [0257]    In Embodiment 2, the extension instruction can be open/close frequency field; lamp on/off instruction, buzz instruction, etc. 
         [0258]    Step  205 , switch off regular interrupting; 
         [0259]    Step  206 , clear flag of the card in the radio frequency field to be 0; 
         [0260]    Step  207 , perform card seeking operation and determine whether the operation is successful; 
         [0261]    if yes, go to Step  208 ; otherwise, go to Step  216 . 
         [0262]    In Embodiment 2, specific card seeking operation is the same as Step  111  in Embodiment 1. 
         [0263]    Step  208 , sending request selecting and answering instruction to the card; 
         [0264]    in Embodiment 2, specifically, the request selecting and answering instruction is E0, 80, CRC. 
         [0265]    Step  209 , receive and determine whether receives a selecting and answering response; 
         [0266]    if yes, go to Step  210 ; otherwise, go to Step  216 . 
         [0267]    Step  210 , send the selecting and answering response to the master computer via USB interrupting channel; 
         [0268]    Step  211 , set the flag of the card in the radio frequency field as 1; 
         [0269]    Step  212 , switch on regular interrupting; 
         [0270]    Step  213 , determine whether the flag of the card in the radio frequency field is 1; 
         [0271]    if yes, go to Step  214 ; otherwise, go to Step  215 . 
         [0272]    Step  214 , sending a response that the card is in the radio frequency field to the master computer via USB interrupting channel; 
         [0273]    then go to the Step  202 . 
         [0274]    In Embodiment 2, specifically the response that the card is in the radio frequency field is 0x50, 0x03. 
         [0275]    Step  215 , send response that the card leaves the radio frequency field to the master computer via USB interrupting channel; and then go to Step  202 . 
         [0276]    In Embodiment 2, specifically, the response that the card leaves the radio frequency field is 0x50, 0x02. 
         [0277]    Step  216 , clear the flag of the card in the radio frequency field to be 0 and then go to Step  212 ; 
         [0278]    Step  217 , switch off regular interrupting; 
         [0279]    Step  218 , send data A to the card in specified format; 
         [0280]    In Embodiment 2, specified format includes PCB, NAD/CID, data A, CRC; PCB represents Protocol Control Byte; NAD represents Node address; CID represents Card Identifier; CRC represents Check detecting code. 
         [0281]    Step  219 , determine whether receive data B returned by the card; 
         [0282]    if yes, go to Step  220 ; if no, go to Step  222 . 
         [0283]    Step  220 , send data B to the master computer via USB interrupting channel; 
         [0284]    Step  221 , set flag of the card in the radio frequency field as 1, and then go to Step  212 ; 
         [0285]    Step  222 , clear flag of the card in the radio frequency field to be 0, and then go to Step  212 ; 
         [0286]    Step  223 , switch off regular interrupting; 
         [0287]    Step  224 , execute corresponding instruction, and send the executing result to the master computer via USB interrupting channel; and then go to Step  212 . 
         [0288]    Specific operation method is the same as Step  118  in Embodiment 1. 
         [0289]    Shown by  FIG. 2B , operation of regular interrupting specifically includes 
         [0290]    Step 2-1, entering regular interrupting; 
         [0291]    In Embodiment 2, performing interrupting period is predetermined time; preferably, interrupting is performed every 5 ms. 
         [0292]    Step 2-2, switching off interrupting; 
         [0293]    Step 2-3, clear interrupting; 
         [0294]    Step 2-4, determining whether the flag of the card in the radio frequency field is 1; 
         [0295]    if yes, go to Step 2-5; if no, go to Step 2-9. 
         [0296]    Step 2-5, performing operation of detecting card; 
         [0297]    in Embodiment 2, specific operation of detecting card is the same as Step 104 in Embodiment 1. 
         [0298]    Step 2-6, determine whether successfully receives response of the card detecting instruction; 
         [0299]    if yes, go to Step 2-7; otherwise, go to Step 2-8. 
         [0300]    In Embodiment 2, specific operation is the same as Step  105  in Embodiment 1. 
         [0301]    Step 2-7, switch on interrupting and exit; 
         [0302]    Step 2-8, clear the flag of the card in the radio frequency field to be 0 and then go to Step 2-7; 
         [0303]    Step 2-9, perform operation of the card seeking and determine whether the operation is successful; 
         [0304]    in Embodiment 2, specific operation is the same as Step  111  in Embodiment 1. 
         [0305]    If yes, go to Step 2-10; otherwise, go to Step 2-7. 
         [0306]    Step 2-10, send request selecting and answering instruction to the card; 
         [0307]    in Embodiment 2, specific request selecting and answering instruction is E0, 80, CRC. 
         [0308]    Step 2-11, determine whether receives a selecting and answering response from the card; 
         [0309]    If yes, go to Step 2-12; otherwise, go to Step 2-7. 
         [0310]    Step 2-12, send the selecting and answering response to the master computer via USB interrupting channel and then go to Step 2-13; 
         [0311]    Step 2-13, set the flag of the card in the radio frequency field as 1 and then go to Step 2-7. 
         [0312]    In Embodiment 2 of the present invention, a response that the related card is in or is not in the radio frequency field is informed to the master computer via USB interrupting channel and the informed response that the card is in the radio frequency field is stored; before preparing for informing next time, determine whether the stored response is identical to a response to be sent, if they are identical, the informing need not be uploaded; otherwise, inform the master computer that the card is in the radio frequency field and store the response. 
         [0313]    Embodiment 2 can be Implemented in Another Method as the Following. 
         [0314]    Referring to FIG.  2 ′A, 
         [0315]    Step  201 ′, the card reader is powered up and initialized; 
         [0316]    Switch on regular interrupting. 
         [0317]    In Embodiment 2, initial value of flag of the card in the radio frequency field is 0. 
         [0318]    Step  202 ′, receive instruction; 
         [0319]    In Embodiment 2, the instruction received by the card reader can be instruction on informing to seek a card, APDU instruction and extension instruction, which are sent by the master computer. 
         [0320]    Step  203 ′, determine whether receives a valid instruction; 
         [0321]    if yes, go to Step  204 ′; if no, go to Step  202 ′. 
         [0322]    The determining method is the same as Step  102  in Embodiment 2. 
         [0323]    Step  204 ′, determine type of instruction; 
         [0324]    in Embodiment 2, if the first byte of the instruction received by the card reader is 0x01, the type of the instruction is instruction on informing to seek a card and go to Step  205 ′; 
         [0325]    if the first byte of the received instruction is 0x02, the instruction is APDU instruction and go to Step  214 ′; 
         [0326]    if the first byte of the received instruction is 0x03, the instruction is extension instruction and go to Step  218 ′; 
         [0327]    In Embodiment 2, extension instruction can be open/close radio frequency field instruction, lamp on/lamp off instruction, buzz instruction, etc. 
         [0328]    Step  205 ′, switch off regular interrupting; 
         [0329]    Step  206 ′, clear flag of the card in the radio frequency field to be 0; 
         [0330]    Step  207 ′, perform operation of the card seeking and determine whether the operation is successful; 
         [0331]    if yes, go to Step  208 ′; if no, go to Step  212 ′. 
         [0332]    In Embodiment 2, specific operation of the card seeking is the same as Step  111  in Embodiment 1. 
         [0333]    Step  208 ′, send request selecting and answering instruction to the card; 
         [0334]    in Embodiment 2, specific request selecting and answering instruction is E0, 80, CRC. 
         [0335]    Step  209 ′, receive and determine whether receives the selecting and answering response; 
         [0336]    if yes, go to Step  210 ′; if no, go to Step  212 ′. 
         [0337]    Step  210 ′, send the selecting and answering response to the master computer via USB interrupting channel; 
         [0338]    Step  211 ′, send a response that the card is in the radio frequency field to the master computer via USB interrupting channel; set the flag of the card in the radio frequency field as 1, and go to Step  213 ′; 
         [0339]    in Embodiment 2, specifically the response that the card is in the radio frequency field is 0x50, 0x03. 
         [0340]    Step  212 ′, send a response that the card leaves radio frequency field to the master computer via USB interrupting channel; clear flag of the card in the radio frequency field to be 0; 
         [0341]    in Embodiment 2, specifically, the response that the card leaves the radio frequency field is 0x50, 0x02. 
         [0342]    Step  213 ′, switch on regular interrupting, and go to Step  202 ′; 
         [0343]    Step  214 ′, switch off regular interrupting; 
         [0344]    Step  215 ′, send data A to the card in specific format; 
         [0345]    in Embodiment 2, specified format includes PCB, NAD/CID, data A, CRC; PCB represents Protocol Control Byte; NAD represents Node address; CID represents Card Identifier; CRC represents Check detecting code. 
         [0346]    Step  216 ′, determine whether receives data B returned from the card; 
         [0347]    if yes, go to Step  217 ′; if no, go to Step  212 ′. 
         [0348]    Step  217 ′, send data B to the master computer via USB interrupting channel and go to Step  211 ′. 
         [0349]    Step  218 ′, switch off regular interrupting; 
         [0350]    Step  219 ′, execute corresponding instruction, and send executing result to the master computer via USB interrupting channel and go to Step  213 ′. 
         [0351]    Specific operation method is the same as Step  118  in Embodiment 1. 
         [0352]    Referring to FIG.  2 ′B, specifically, operation of regular interrupting includes 
         [0353]    Step 2-1′, enter regular interrupting; 
         [0354]    in Embodiment 2, period of performing regular interrupting is a predetermined time. Preferably, the regular interrupting is performed every 5 ms. 
         [0355]    Step 2-2′, switch off interrupting; 
         [0356]    Step 2-3′, clear interrupting; 
         [0357]    Step 2-4′, determine whether flag of the card in the radio frequency field is 1; 
         [0358]    if yes, go to Step 2-5′; if no, go to Step 2-10′. 
         [0359]    Step 2-5′, perform operation of detecting card; 
         [0360]    in Embodiment 2, specifically the operation of detecting card is the same as Step  104  in Embodiment 1. 
         [0361]    Step 2-6′, determine whether receives response of detecting card instruction successfully; 
         [0362]    if yes, go to Step 2-7′; if no, go to Step 2-8′. 
         [0363]    in Embodiment 2, specific determining operation is the same as Step  105  in Embodiment 1. 
         [0364]    Step 2-7′, inform the master computer of the response that the card is in the radio frequency field via USB interrupting channel; set flag of the card in the radio frequency field as 1 and go to Step 2-9′; 
         [0365]    Step 2-8′, inform the master computer of the response that the card leaves the radio frequency field via USB interrupting channel; clear flag of the card in the radio frequency field to be 0; 
         [0366]    Step 2-9′, switch on interrupting and exit; 
         [0367]    Step 2-10′, perform operation of the card seeking and determine whether the operation is successful; 
         [0368]    if yes, go to Step 2-11′; if no, go to Step 2-8′. 
         [0369]    In embodiment 2, specific operation is the same as Step  111  in Embodiment 1. 
         [0370]    Step 2-11′, send request selecting and answering instruction to the card; 
         [0371]    In Embodiment 2, specifically, request selecting and answering instruction is E0, 80, CRC. 
         [0372]    Step 2-12′, determine whether receives requesting selecting and answering response from the card; 
         [0373]    if yes, go to Step 2-13′; if no, go to Step 2-8′. 
         [0374]    Step 2-13′, send selecting and answering response to the master computer via USB interrupting channel and go to Step 2-7′. 
         [0375]    In Embodiment 2 of the present invention, a response that the related card is in or is not in the radio frequency field is informed to the master computer via USB interrupting channel and the informed response that the card is in the radio frequency field is stored; before preparing for informing next time, determine whether the stored response is identical to a response to be sent, if they are identical, the informing need not be uploaded; otherwise, inform the master computer that the card is in the radio frequency field and store the response. 
       Embodiment 3 
       [0376]    Referring to  FIG. 3A  and  FIG. 3B , Embodiment 3 provides a method for detecting a card leaving radio frequency field, which specifically includes 
         [0377]    Step  301 , a card reader is power up and initialized; 
         [0378]    Switch on communication interrupting. 
         [0379]    In Embodiment 3, initial value of instruction flag is 0; the initial value of flag of the card in the radio frequency field is 0. 
         [0380]    Step  302 , determine whether instruction flag is 1; 
         [0381]    if yes, go to Step  311 ; if no, go to Step  303 . 
         [0382]    Step  303 , determine whether the flag of the card in the radio frequency field is 1; 
         [0383]    If yes, go to Step  304 ; if no, go to Step  311 . 
         [0384]    Step  304 , perform operation of detecting card; 
         [0385]    in Embodiment 3, specifically operation of detecting card is the same as Step  104  in Embodiment 1. 
         [0386]    Step  305 , determine whether receives a response of the card detecting instruction successfully; 
         [0387]    if yes, go to Step  306 ; if no, go to Step  308 . 
         [0388]    In Embodiment 3, specifically determining operation is the same as Step  105  in Embodiment 1. 
         [0389]    Step  306 , inform the response that the card is in the radio frequency field to the master computer via USB interrupting channel; set the flag of the card in the radio frequency field as 1; go to Step  307  or Step  302 ; 
         [0390]    in Embodiment 3, specifically, the response that the card is in the radio frequency field is 0x50, 0x03. 
         [0391]    Step  307 , determine whether the instruction flag is 1; 
         [0392]    if yes, goes to Step  310 ; if no, go to Step  304 . 
         [0393]    Step  308 , inform the master computer of the response that the card leaves radio frequency field and clear flag of the card in the radio frequency field to be 0; go to Step  309  or Step  302 ; 
         [0394]    Step  309 , determine whether the instruction flag is 1; 
         [0395]    if yes, go to Step  310 ; if no, go to Step  311 . 
         [0396]    Step  310 , clear instruction flag to be 0 and determine type of instruction; in Embodiment 3, if the first byte of the data received by the card reader is 0x01, the type is instruction on informing to seek a card and go to Step  311 ; 
         [0397]    if the first byte of the data received by the card reader is 0x02, the type is APDU instruction and go to Step  315 ; 
         [0398]    if the first byte of the data received by the card reader is 0x03, the type is extension instruction and go to Step  318 ; 
         [0399]    In Embodiment 3, the extension instruction includes open/close radio frequency field instruction, lamp on/lamp off instruction, buzz instruction, etc. 
         [0400]    Step  311 , perform operation of the card seeking and determine whether the operation of determining is successful; 
         [0401]    if yes, go to Step  312 ; if no, go to Step  308 . 
         [0402]    In Embodiment 3, specific operation of the card seeking is the same as Step  111  in Embodiment 1. 
         [0403]    Step  312 , send a request selecting and answering instruction to the card; 
         [0404]    In Embodiment 3, specifically, the request selecting and answering instruction is E0, 80, CRC. 
         [0405]    Step  313 , determine whether receives a selecting and answering response from the card; 
         [0406]    if yes, go to Step  314 ; if no, go to Step  308 . 
         [0407]    Step  314 , send the selecting and answering response to the master computer via USB interrupting channel; 
         [0408]    Then, go to Step  306 . 
         [0409]    Step  315 , send data A to the card in specified format; 
         [0410]    in Embodiment 3, specified format includes PCB, NAD/CID, data A, CRC; PCB represents Protocol Control Byte; NAD represents Node address; CID represents Card Identifier; CRC represents Check detecting code. 
         [0411]    Step  316 , determine whether receives data B returned from the card; 
         [0412]    if yes, go to Step  317 ; if no, goes to Step  308 . 
         [0413]    Step  317 ; send data B to the master computer via USB interrupting channel and go to Step  306 . 
         [0414]    Step  318 , execute corresponding instruction and send corresponding result to the master computer via USB interrupting channel and go to Step  302 . 
         [0415]    Specific operation method is the same as Step  118  in Embodiment 1. 
         [0416]    In Embodiment 3, if communication interrupting happens, enter interrupting processing. Shown by  FIG. 3B , specific steps are as the following. 
         [0417]    Step 3-1, enter communication interrupting; 
         [0418]    Step 3-2, switch off interrupting; 
         [0419]    Step 3-3, clear interrupting; 
         [0420]    Step 3-4, receive instruction and determine whether receives valid instruction; 
         [0421]    if yes, go to Step 3-5; if no, go to step 3-6. 
         [0422]    In Embodiment 3, specifically determining method is the same as Step  307 . 
         [0423]    Step 3-5, set instruction flag as 1; 
         [0424]    Step 3-6, switch on interrupting and exit. 
         [0425]    In Embodiments of the present invention, a response that the revolved card is in or not in the radio frequency field is informed to the master computer via USB interrupting channel and the informed response that the card is in the radio frequency field is stored; before preparing for informing next time, determine whether the stored response is identical to a response to be sent, if they are identical, the informing need not be uploaded; otherwise, inform the master computer that the card is in the radio frequency field and stores the response.