A kind of detection SIM card falls the method and system of card
Technical field
The present invention relates to SIM card technical field, in particular to a kind of detection SIM card falls the method and system of card.
Background technique
Mobile terminal needs to be put into the SIM of operator's offer using operator in the terminal when the network provided
(Subscriber Identity Module, client identification module) card, because SIM card is all simply by certain mechanical structure
Block in the terminal, and contact corresponding with mobile terminal is connected, electrical connection stability is relatively low, especially moves
Dynamic terminal has portability, in movement, or even situations such as falling, colliding occurs, it is easy to make SIM card and movement
The disconnecting of terminal, the phenomenon that occurring card.
The waveform of each pin of SIM card when generally requiring to grab card by oscillograph for the detection that SIM card falls card, comes
Judgement is specifically which pin connection disconnection leads to SIM card and mobile terminal disconnecting.And falls card and be frequently experienced in very in short-term
In, and be not easy to reappear, and user can not all day by mobile terminal connection oscillograph carry out using, therefore, existing skill
Instantaneous waveform when falling card for crawl SIM card in art judge the pin of actual physics connection disconnection still without effective method,
Mobile terminal oscillograph can only be connected by tester to carry out constantly grabbing waveform using to reappear to fall card, it is very time-consuming
Effort.
Thus the prior art could be improved and improve.
Summary of the invention
Place in view of above-mentioned deficiencies of the prior art, the purpose of the present invention is to provide the sides that a kind of detection SIM card falls card
Method and system, can the moment of the level change of each pin of SIM card when SIM card falls card according to historical record when restoring to fall card
Waveform judges the pin that actual physics connection disconnects, effectively increases the pin detection efficiency that SIM card falls card.
In order to achieve the above object, this invention takes following technical schemes:
A method of detection SIM card falls card comprising following steps:
It A, is edge triggered interruption mode by each pin configuration of SIM card;
B, the level state of each pin of the SIM card is detected;
C, when detecting that the level state changes, obtain and record the level state information of current pin;
D, when SIM card Communications failure, stop the level state for detecting each pin, according to the level state of historical record
Information judges that the pin of SIM card disconnects information.
The detection SIM card is fallen in the method for card, and the step C is specifically included:
C1, when detecting that the level state changes, obtain and record the level of the title of current pin, pin
And current time.
The detection SIM card is fallen in the method for card, and the step C1 is specifically included:
When detecting that the level state of reset pin of SIM card changes, by the title of reset pin and it is recorded as
" RST ", the level and current time for obtaining and recording current reset pin;
When detecting that the level state of power pins of SIM card changes, by the title of power pins and it is recorded as
" VCC ", the level and current time for obtaining and recording current power pin;
When detecting that the level state of data pin of SIM card changes, by the title of data pin and it is recorded as
" DATA ", the level and current time for obtaining and recording current data pin;
When detecting that the level state of clock pins of SIM card changes, by the title of clock pins and it is recorded as
" CLK ", the level and current time for obtaining and recording present clock pin.
The detection SIM card is fallen in the method for card, and the step D is specifically included:
D1, when SIM card Communications failure, stop the level state for detecting each pin;
D2, in the level state information of historical record, connection disconnection condition is met according to time-sequencing judgement at first
Pin.
The detection SIM card is fallen in the method for card, and the connection disconnection condition specifically includes:
SIM card is judged when the level of entitled " RST " of pin and pin is low level in the level state information
Reset pin meet connection disconnection condition;
SIM card is judged when the level of entitled " VCC " of pin and pin is low level in the level state information
Power pins meet connection disconnection condition;
When continuously N number of clock cycle is the level of entitled " DATA " of pin and pin in the level state information
Level or continuous N number of clock cycle judge that the data pin of SIM card meets connection disconnection condition when being high level, the N is 10;
As entitled " CLK " of pin in the level state information and the level of pin continuous 2 clock cycle are electricity
Flat or continuous 2 clock cycle judge that the clock pins of SIM card meet connection disconnection condition when being high level.
The system that a kind of detection SIM card falls card comprising:
Configuration module, for being edge triggered interruption mode by each pin configuration of SIM card;
Detection module, the level state of the pin for detecting the SIM card;
Logging modle is obtained, for when detecting that the level state changes, obtaining and recording current pin
Level state information;
Judging treatmenting module, for when detecting SIM card Communications failure, stopping detecting the level state of the pin,
Judge that the pin of SIM card disconnects information according to the level state information of historical record.
The detection SIM card is fallen in the system of card, and the acquisition logging modle, which is specifically used for working as, detects the level
When state changes, the title of current pin, the level of pin and current time are obtained and recorded.
The detection SIM card is fallen in the system of card, and the acquisition logging modle includes:
First obtains record sub module, for inciting somebody to action when detecting that the level state of reset pin of SIM card changes
The title of reset pin and the level and current time for being recorded as " RST ", obtaining and record current reset pin;
Second obtains record sub module, for inciting somebody to action when detecting that the level state of power pins of SIM card changes
The title of power pins and the level and current time for being recorded as " VCC ", obtaining and record current power pin;
Third obtains record sub module, for inciting somebody to action when detecting that the level state of data pin of SIM card changes
The title of data pin and the level and current time for being recorded as " DATA ", obtaining and record current data pin;
4th obtains record sub module, for inciting somebody to action when detecting that the level state of clock pins of SIM card changes
The title of clock pins and the level and current time for being recorded as " CLK ", obtaining and record present clock pin.
The detection SIM card is fallen in the system of card, and the judging treatmenting module includes:
Submodule is handled, for when SIM card Communications failure, stopping detecting the level state of the pin;
Judging submodule, for being met at first according to time-sequencing judgement and being connected in the level state information of historical record
Connect the pin of disconnection condition.
The detection SIM card is fallen in the system of card, and the judging submodule includes:
First judging unit, in the level state information entitled " RST " of pin and the level of pin is
Judge that the reset pin of SIM card meets connection disconnection condition when low level;
Second judgment unit, in the level state information entitled " VCC " of pin and the level of pin is
Judge that the power pins of SIM card meet connection disconnection condition when low level;
Third judging unit, for when entitled " DATA " of pin and the level of pin in the level state information
It is disconnected to judge that the data pin of SIM card meets connection when continuous N number of clock cycle is level or continuously N number of clock cycle is high level
Condition is opened, the N is 10;
4th judging unit, for when the level of entitled " CLK " of pin and pin company in the level state information
Continuous 2 clock cycle, which are level or continuous 2 clock cycle, judge that the clock pins of SIM card meet connection disconnection when being high level
Condition.
Compared to the prior art, detection SIM card provided by the invention falls system described in the method and system of card by setting
It sets configuration module, detection module, obtain logging modle and judging treatmenting module, be edge touching by each pin configuration of SIM card
Send out interrupt mode;The level state of each pin of the SIM card is detected later;When detecting that the level state changes
When, obtain and record the level state information of current pin;When SIM card Communications failure, stop the level for detecting each pin
State judges that the pin of SIM card disconnects information according to the level state information of historical record, to fall card Shi Nenggen in SIM card
Restore to fall instantaneous waveform when card according to the level change of each pin of the SIM card of historical record, judges that actual physics connection disconnects
Pin, effectively increase pin detection efficiency and accuracy that SIM card falls card.
Detailed description of the invention
Fig. 1 is the flow chart for the method that detection SIM card provided by the invention falls card.
Fig. 2 is the structural block diagram for the system that detection SIM card provided by the invention falls card.
Fig. 3 is the knot that detection SIM card provided by the invention falls to obtain logging modle and each pin of SIM card in the system of card
Structure block diagram.
Specific embodiment
In view of in the prior art for can not effectively grab instantaneous waveform when SIM card falls card, judge that actual physics connect
The shortcomings that pin low efficiency of disconnection, the purpose of the present invention is to provide a kind of detection SIM cards to fall the method and system of card, can be
Instantaneous waveform when card is fallen in level change recovery when SIM card falls card according to each pin of SIM card of historical record, judges reality
The pin that physical connection disconnects, effectively increases the pin detection efficiency that SIM card falls card.
To make the purpose of the present invention, technical solution and effect clearer, clear and definite, right as follows in conjunction with drawings and embodiments
The present invention is further described.It should be appreciated that described herein, specific examples are only used to explain the present invention, is not used to
Limit the present invention.
Referring to Fig. 1, the method that detection SIM card provided by the invention falls card includes the following steps:
S100, by each pin configuration of SIM card be edge triggered interruption mode;
S200, the detection SIM card each pin level state;
S300, when detecting that the level state changes, obtain and record the level state information of current pin;
S400, when SIM card Communications failure, stop the level state for detecting the pin, according to the level of historical record
Status information judges that the pin of SIM card disconnects information.
Currently, common SIM card, which includes at least, reset pin RST, power pins VCC, data pin DATA and clock
Each pin configuration of SIM card is by pin CLK, the present invention by the way that each pin of SIM card is connected with system in advance
Edge triggered interruption mode, while detecting the level state of each pin of the SIM card, when detecting the level state hair
When changing, the level state information for the pin that current level state is changed is obtained and records, in SIM card Communications failure
When stop detecting the level state of each pin, instantaneous waveform when card is fallen according to the level state Information recovering of historical record,
To judge that the actual physics of SIM card connect the pinout information disconnected, Waveshape reproduction when SIM card falls card is realized, is facilitated
The pinout information that the practical connection of judgement disconnects, substantially increases the efficiency that SIM card falls card detection.
Wherein, the step S300 is specifically included: when detecting that the level state changes, being obtained and is recorded and work as
The title of preceding pin, the level of pin and current time.
It ought detect in reset pin RST, power pins VCC, data pin DATA and the clock pins CLK of SIM card
When the level state of any one pin changes, the name for the pin that current level state is changed is obtained and recorded
Claim, the level of pin and current time, the Waveshape reproduction to fall card moment provide reliable information.
Specifically, when detecting that the level state of reset pin of SIM card changes, simultaneously by the title of reset pin
It is recorded as " RST ", is obtained and is recorded the level and current time of current reset pin;When the power pins for detecting SIM card
When level state changes, by the title of power pins and the level that is recorded as " VCC ", obtains and record current power pin
And current time;When detecting that the level state of data pin of SIM card changes, by the title and record of data pin
For " DATA ", the level and current time that obtain and record current data pin;When the level for the clock pins for detecting SIM card
When state changes, by the title of clock pins and it is recorded as " CLK ", the level that obtains and record present clock pin and works as
The preceding time.
For example, the level of power pins is that high level will then generate edge when the level of power pins becomes low level
(failing edge) interrupts, and the title of power pins is recorded as " VCC " by system at this time, and the level for obtaining power pins (is currently
Low level) and current time (for example, 1876.455186909 seconds, this time is the time after distance booting), it preserves,
It is as follows:
Pin name " VCC ", low level, 1876.455186909;
Equally, when the level state of other pins of SIM card changes, system will also be remembered according to above-mentioned record rule
Record its lower level state information.
Further, the step S400 is specifically included:
When SIM card Communications failure, stop the level state for detecting the pin;
In the level state information of historical record, drawing for connection disconnection condition is met according to time-sequencing judgement at first
Foot.
When it is implemented, the connection disconnection condition specifically includes:
SIM card is judged when the level of entitled " RST " of pin and pin is low level in the level state information
Reset pin meet connection disconnection condition;
SIM card is judged when the level of entitled " VCC " of pin and pin is low level in the level state information
Power pins meet connection disconnection condition;
When continuously N number of clock cycle is the level of entitled " DATA " of pin and pin in the level state information
Level or continuous N number of clock cycle judge that the data pin of SIM card meets connection disconnection condition when being high level, the N is 10,
The clock cycle is the period that clock pins export clock;
As entitled " CLK " of pin in the level state information and the level of pin continuous 2 clock cycle are electricity
Flat or continuous 2 clock cycle judge that the clock pins of SIM card meet connection disconnection condition, the clock cycle when being high level
The period of clock is exported for clock pins.
Due in actual use, when the pin physical connection of a SIM card disconnects, will lead in the communication of other pins
Disconnected, the pin that finally also other physical connections can be made not disconnect meets connection disconnection condition, therefore, when SIM card Communications failure, i.e.,
When SIM card connect disconnection with system, stop the level state for detecting each pin, in the level state information of historical record,
Time is sorted according to sequencing, judges which pin meets connection disconnection condition at first according to time-sequencing, i.e., by it
It is judged as the pin that actual physics connection disconnects, judges what practical connection disconnected by historical record level information to realize
Pin improves the accuracy that SIM card falls card detection.
For example, the level state information of historical record is as follows when SIM card Communications failure:
Assuming that several of front record does not all meet connection disconnection condition;
Pin name " RST ", low level, 1876.455186909;
Pin name " VCC ", low level, 1876.455196156;
Pin name " DATA ", low level, 1876.455212170;
From the level state information of above-mentioned historical record it is found that pin, power pins, data pin are all satisfied connection disconnection
Condition, but reset pin meets connection disconnection condition at first, therefore by above-mentioned in the level state information of historical record, according to when
Between sequence judgement at first meet connection disconnection condition pin method, judge actual physics connection disconnect pin be reset draw
Foot, instantaneous waveform when SIM card to be fallen to card restore, and the pin that the practical connection of accurate judgement disconnects effectively increases SIM card and falls card
Pin detection efficiency.
Referring to Fig. 2, the present invention correspondingly provides a kind of system for detecting SIM card and falling card comprising: configuration module 10,
Detection module 20 obtains logging modle 30 and judging treatmenting module 40.Wherein, the configuration module 10 is used for each of SIM card
A pin configuration is edge triggered interruption mode;The detection module 20 is used to detect the level of each pin of the SIM card
State;The acquisition logging modle 30 is used for when detecting that the level state changes, and is obtained and is recorded current pin
Level state information;The judging treatmenting module 40 is used for when detecting SIM card Communications failure, stops detecting the pin
Level state, according to the level state information of historical record judge SIM card pin disconnect information.
Detection SIM card provided by the invention falls the system of card and is by each pin configuration of SIM card by configuration module 10
Edge triggered interruption mode;The level state of each pin of the SIM card is detected by detection module 20;When detection module 20 is examined
When measuring the level state and changing, passes through to obtain logging modle 30 and obtain and record current level state and changed
Pin level state information;When SIM card Communications failure, stop detecting the electricity of each pin by judging treatmenting module 40
Level state, and instantaneous waveform when falling according to the level state Information recovering of historical record card, to judge the practical object of SIM card
The pinout information that reason connection disconnects, realizes Waveshape reproduction when SIM card falls card, helps to judge the pin that practical connection disconnects
Information substantially increases the efficiency that SIM card falls card detection.
Wherein, the acquisition logging modle 30 is specifically used for when detecting that the level state changes, and obtains simultaneously
Record the title of current pin, the level of pin and current time.When detection module 20 detect SIM card reset pin RST,
When the level state of any one pin changes in power pins VCC, data pin DATA and clock pins CLK, obtain
Logging modle 30 obtains and records the title for the pin that current level state is changed, the level of pin and current time,
Reliable information is provided for the SIM Waveshape reproduction for falling card moment.
Specifically, also referring to Fig. 3, the acquisition logging modle 30 includes: the first acquisition record sub module 401,
Two obtain record sub module 402, third obtains record sub module 403 and the 4th obtains record sub module 404, and described first obtains
Record sub module 401 is connect with the reset pin RST of SIM card;Described second obtains the power supply of record sub module 402 and SIM card
Pin VCC connection;The third obtains record sub module 403 and connect with the data pin DATA of SIM card;Described 4th obtains note
Record submodule 404 is connect with the clock pins CLK of SIM card.
The first acquisition record sub module 401, which is used to work as, detects that the level state of the reset pin of SIM card becomes
When change, by the title of reset pin and the level and current time that are recorded as " RST ", obtain and record current reset pin;Institute
It states the second acquisition record sub module 402 to be used for when detecting that the level state of power pins of SIM card changes, by power supply
The title of pin and the level and current time for being recorded as " VCC ", obtaining and record current power pin;The third obtains note
It records submodule 403 to be used for when detecting that the level state of data pin of SIM card changes, simultaneously by the title of data pin
It is recorded as " DATA ", is obtained and is recorded the level and current time of current data pin;Described 4th obtains record sub module 404
For by the title of clock pins and being recorded as when detecting that the level state of clock pins of SIM card changes
" CLK ", the level and current time for obtaining and recording present clock pin.
For example, the level of power pins is that high level will then generate edge when the level of power pins becomes low level
(failing edge) interrupts, and the title of power pins is recorded as " VCC " by the second acquisition record sub module 402 at this time, and is obtained
The level (being currently low level) and current time of power pins (for example, 1876.455186909 seconds, opened for distance by this time
Time after machine), it preserves, as follows:
Pin name " VCC ", low level, 1876.455186909;
Equally, when the level state of other pins of SIM card changes, first obtains record sub module 401, third
Obtaining record sub module 403 and the 4th acquisition record sub module 404 also will record its level state according to above-mentioned record rule
Information.
Further, the judging treatmenting module 40 includes processing submodule (not shown) and judging submodule (figure
In be not shown), the processing submodule is used for when SIM card Communications failure, stops the level state for detecting the pin;It is described
Judging submodule is used in the level state information of historical record, meets connection disconnection condition at first according to time-sequencing judgement
Pin.
Due in actual use, when the pin physical connection of a SIM card disconnects, will lead in the communication of other pins
Disconnected, the pin that finally also other physical connections can be made not disconnect meets connection disconnection condition, therefore, when SIM card Communications failure,
The judging submodule control stops detecting the level state of each pin, and in the level state information of historical record, will
Time sorts according to sequencing, judges which pin meets connection disconnection condition at first according to time-sequencing, that is, is sentenced
Break the pin disconnected for actual physics connection, so as to which SIM card to be fallen to instantaneous waveform when card by historical record level information
Reproduction, and the pin disconnected by the practical connection of waveform judgement, improve the accuracy that SIM card falls card detection.Specific implementation
Example is described in detail in the specific embodiment for the method that above-mentioned detection SIM card falls card, and details are not described herein again.
Further, the judging submodule includes the first judging unit (not shown), second judgment unit (figure
In be not shown), third judging unit (not shown) and the 4th judging unit (not shown), first judging unit
For judging answering for SIM card when the level of entitled " RST " of pin and pin is low level in the level state information
Position pin meets connection disconnection condition;The second judgment unit is used for the entitled of in level state information pin
The level of " VCC " and pin judges that the power pins of SIM card meet connection disconnection condition when being low level;The third judgement
Unit is used for when continuously N number of clock cycle is the level of entitled " DATA " of pin and pin in the level state information
Level or continuous N number of clock cycle judge that the data pin of SIM card meets connection disconnection condition when being high level, the N is 10,
The clock cycle is the period that clock pins export clock;4th judging unit is used for when in the level state information
Entitled " CLK " of pin and the level of pin continuous 2 clock cycle are level or continuous 2 clock cycle are high level
When judge SIM card clock pins meet connection disconnection condition, the clock cycle be clock pins export clock period.From
And when the level state of each pin of SIM card changes, can each pin of accurate judgement whether meet connection disconnect item
Part provides accurate level state information for the Waveshape reproduction that SIM card falls card moment.
In conclusion detection SIM card provided by the invention, which falls system described in the method and system of card, passes through setting configuration
Module, obtains logging modle and judging treatmenting module at detection module, is edge triggered interruption by each pin configuration of SIM card
Mode;The level state of each pin of the SIM card is detected later;When detecting that the level state changes, obtain
Take and record the level state information of current pin;When SIM card Communications failure, stop the level state for detecting each pin,
Judge that the pin of SIM card disconnects information according to the level state information of historical record, thus can be according to history when SIM card falls card
The level change of each pin of the SIM card of record restores to fall instantaneous waveform when card, judges the pin that actual physics connection disconnects,
Effectively increase pin detection efficiency and accuracy that SIM card falls card.
It, can according to the technique and scheme of the present invention and its hair it is understood that for those of ordinary skills
Bright design is subject to equivalent substitution or change, and all these changes or replacement all should belong to the guarantor of appended claims of the invention
Protect range.