Embodiment
The information storage means of the electronic tag that the embodiment of the invention provides by in each sector of storage space the state of activation byte being set, realize recycling of all sectors, improve the serviceable life of electronic tag.
At first, each sector to the electronic tag storage space is provided with.For example storage space can be that CPU inside can also can be outside other storage spaces such as EEPROM for the Flash storage space of canned data.As shown in Figure 1, be the storage organization synoptic diagram of electronic tag internal storage space, this storage space can comprise S
0, S
1, S
2..., S
N-1Be total to N the sector that the address is continuous.
The state of activation byte is set in each sector, and preferable, the first byte of each sector is set to the state of activation byte of this sector (for example shown in Figure 1).Activate to write in the identification byte and activate sign, can also write and be used to complete sign.For example: activate sign and can be set to 0xfe, the expression sector is in the state of being activated, and is used to complete sign and can be set to 0xfc, represents that this sector is used to complete.
When certainly the information in the sector is wiped free of, then be a sign of unused state in this byte, this is identified at the sector and is wiped free of the back and recovers automatically to obtain.For example: do not use sign to be traditionally arranged to be 0xff, the expression sector is in the state that is not used.
Preferable, the data for the ease of recovering to write under abnormal conditions can also be provided with the byte that returns to form in each sector, and for example: second byte of each sector is set to the byte that returns to form (as shown in Figure 1) of this sector.When the sector was used to complete, what then write in this byte that returns to form was irrecoverable sign, then reverts to automatically in this byte that returns to form to recover sign when the sector is wiped free of, and keep the state that can recover to identify in the process of using always after activation.For example: irrecoverable sign can be set to 0xfe, represents that the information of this sector is in unrecoverable state; Can recover to be designated 0xff, represent that the information of this sector is in and can returns to form.
As shown in Figure 1, except that the state of activation byte that is provided with and the byte that returns to form, other storage areas of each sector are available memory area.
Embodiment one
The information storage means of the electronic tag that the embodiment of the invention one provides, after the state of activation byte is set, the flow process that electronic tag is realized information stores as shown in Figure 2, execution in step is as follows:
Step S11: electronic tag receives the request of using.
Electronic tag is in dormant state when not using, and waits for the outside use request that receives.
For example: the use request can be from the compound read write line of expressway entrance and exit and road side base station on the way etc.
Step S12: electronic tag is searched the sector that is in state of activation in each sector of its storage space after receiving and using request.
After receiving the use request, electronic tag begins to search which sector is in state of activation in its storage space, generally search in the state of activation byte of setting and comprise the sector of activating sign, realize searching the sector that is in state of activation in each sector of storage space by traversal.
For example: when the activation that is provided with was designated 0xfe, then finding in the state of activation byte was that sector of 0xfe, is the sector that is in state of activation.
For example: the traversal specific implementation flow process of searching as shown in Figure 3, execution in step is as follows:
Step S120: beginning.
Step S121: read sector S
iThe state of activation byte.
From i=0, promptly first sector begins to read when generally searching.
Step S122: judge that this sector is in state of activation?
Activate sign if comprise in the state of activation byte of this sector, then this sector is in state of activation, otherwise is not.
If, execution in step S123, otherwise execution in step S124.
Step S123: determine this sector S
iFor being in the sector of state of activation.
Step S124: make i=i++, and judge that whether i is more than or equal to sector total quantity N.If, execution in step S125 then; If not, then return continuation execution in step S121.
Step S125: the sector of determining not to be in state of activation.
Step S13:, determine the current sector of using according to the Query Result that whether inquires the sector that is in state of activation.Specifically comprise:
(1) comprises the sector of activating sign if found among the above-mentioned steps S12, and when this sector is not last sector of storage space, activation in this sector sign is rewritten as is used to complete sign, and with the next sector of this sector as the current sector of using.
(2) comprise the sector of activating sign if found among the above-mentioned steps S12, and during last sector that this sector is a storage space, activation in this sector sign is rewritten as is used to complete sign, and with first sector of storage space as the current sector of using.
(3) if do not find among the above-mentioned steps S12 when comprising the sector of activating sign, with first sector of storage space as the current sector of using.
Continue to use the example of top, if find sector S
iThe state of activation byte in when comprising state of activation sign 0xfe, illustrate that then this sector is the sector of using last time, the sign of the activation in this sector 0xfe is rewritten as is used to complete sign 0xfc.And definite sector S
(i+1) %NAs the current sector of using.Wherein, (i+1) %N represents the remainder of (i+1)/N, thereby can be implemented in the sector S that comprises state of activation sign 0xfe that finds
iBe sector S
N-1The time, the current sector of determining of using is sector S0.
If find when comprising the sector of activating sign 0xfe in the state of activation byte, the current sector of determining of using is sector S
0Be the situation of storage space when being in unused state at this moment, all sectors all are original, therefore do not need to rewrite the state of activation byte.
Step S14: activate the current sector of using.
Determine current use the sector after, wipe current the use and being used to complete sign and canned data in the sector, in the current state of activation byte of using the sector, write and activate sign, to activate the current sector of using.
Continue to use the example of top, with the current sector S that uses that determines
(i+1) %NOr S
0Wipe, and in its state of activation byte, write activation sign 0xfe.Be the current sector S that uses
(i+1) %NOr S
0Be activated.
Step S15: continue to receive information from the outside.
After receiving the use request and carrying out above-mentioned steps, electronic tag then can keep dormant state and wait for the information that reception is outside, and the information from the outside that may receive comprises request of writing and the instruction that is used to complete.
Write when request, execution in step S16 when receiving; When receiving the instruction that is used to complete, execution in step S17; Otherwise continuation dormancy.
Step S16: a little write the information to be stored that receives with the current sector of using as initial writing, and return step S15 and continue to wait for reception information.
After electronic tag receives information to be stored, though information to be stored generally speaking can not surpass the size of a sector.But consider that the size that information to be stored may occur surpasses this special circumstances of size of the available memory area of a sector.Preferable, need carry out the judgement whether needs are striden sector storage according to the actual conditions of information to be stored.Can be divided into following dual mode at the different situations of court verdict writes:
(i), if the size of the required storage area of information to be stored is not more than the size of the available memory area of a sector, then directly information to be stored is written to determine current and uses in the sector.
Continue to use above-mentioned example, the information to be stored that receives is written to the current current sector S that uses in sector that uses that is activated
(i+1) %NOr S
0
(ii), the size of the storage area required as if information to be stored is greater than the size of the available memory area of a sector, then, information to be stored is written at least from the available memory area of the continuous sector of current two of using the sector to begin according to the size of the required storage area of information to be stored.
Continue to use above-mentioned example, the information to be stored that receives is written to from the current sector S that uses that is activated
(i+1) %NOr S
0In at least two continuous sectors of beginning.
(ii) under the kind situation, in order to use the storage space of sector more fully, it is also conceivable that in the several sectors that to use continuously that first byte of other sector except that first sector and second byte also are used for storage, then need to do an escape this moment and handle.Promptly when using first byte, if the information data that need write is not just for using identification informations such as identifying or activate sign identical with above-mentioned setting.When second bytes store information, if the information data that need write then can adopt two characters of setting to replace just for using irrecoverable sign maybe can recover to identify identical with above-mentioned the setting.For example: when writing information data 0xfe, use two characters of 0xff and 0x01 to replace; When writing information data 0xff, use two characters of 0xff and 0x00 to replace.Other situation is then carried out normal write operation.
Step S17: finish this Stored Procedure.
When electronic tag receives the instruction that is used to complete, then finish this use, electronic tag enters dormant state.
Preferable, judge whether need to recover information in the sector for the ease of the back in abnormal conditions, when receiving the instruction that is used to complete, in the current byte that returns to form of using the sector, write irrecoverable sign, represent that this sector has been used to complete to need not recovering information again.That is to say when not writing this irrecoverable sign, is to wipe the sign the recovered sign that obtains behind the sector in the byte that returns to form, and expression needs recovering information.
Continue to use above-mentioned example, when being used to complete, in the current byte that returns to form of using the sector, write irrecoverable sign 0xfe, for before writing this sign, in the byte that returns to form for recovering sign 0xff.
Embodiment two
The information storage means of the electronic tag that the embodiment of the invention two provides, after the state of activation byte is set, the flow process that electronic tag is realized information stores as shown in Figure 4, execution in step is as follows:
Step S21: electronic tag receives the request of using.
With step S11, repeat no more herein.
Step S22: electronic tag is searched the sector that is in state of activation in each sector of its storage space after receiving and using request.
With step S12, repeat no more herein.
Step S23:, determine the current sector of using according to the Query Result that whether inquires the sector that is in state of activation.Specifically comprise:
(1) if found among the above-mentioned steps S22 and comprise the sector of activating sign, and this sector wipes activation sign and canned data in this sector when not being last sector of storage space, and with the next sector of this sector as the current sector of using.
(2), and during last sector that is storage space, this sector, wipe activation sign and canned data in this sector if found among the above-mentioned steps S22 and comprise the sector of activating sign, and with first sector of storage space as the current sector of using.
(3) if do not find among the above-mentioned steps S22 when comprising the sector of activating sign, with first sector of storage space as the current sector of using.
Continue to use the example of top, if find sector S
iThe state of activation byte in when comprising state of activation sign 0xfe, illustrate that then this sector is the sector of using last time, wipes this sector S
iIn activation sign and canned data, and definite sector S
(i+1) %NAs the current sector of using.Wherein, (i+1) %N represents the remainder of (i+1)/N, thereby can be implemented in the sector S that comprises state of activation sign 0xfe that finds
iBe sector S
N-1The time, the current sector of determining of using is sector S
0
If find when comprising the sector of activating sign 0xfe in the state of activation byte, the current sector of determining of using is sector S
0At this moment, be the situation of storage space when being in unused state, all sectors all are original, therefore do not need to wipe.
Step S24: activate the current sector of using.
Determine current use the sector after, in the current state of activation byte of using the sector, write and activate sign, to activate the current sector of using.
Continue to use the example of top, the current sector S that uses that is determining
(i+1) %NOr S
0The state of activation byte in write and activate sign 0xfe.Be the current sector S that uses
(i+1) %NOr S
0Be activated.
Step S25: continue to receive information from the outside.
After receiving the use request and carrying out above-mentioned steps, electronic tag then can keep dormant state and wait for the information that reception is outside, and the information from the outside that may receive may comprise request of writing and the instruction that is used to complete.
Write when request, execution in step S26 when receiving; When receiving the instruction that is used to complete, execution in step S27; Otherwise continuation dormancy.
Step S26: a little write the information to be stored that receives with the current sector of using as initial writing, and return step S25 and continue to wait for reception information.
The detailed process of information stores repeats no more with step S16 herein.
Step S27: finish this Stored Procedure.Electronic tag enters dormant state.
With step S17, repeat no more herein.
The electronic labeling information storage realization flow of the foregoing description one was wiped the sector that will use at every turn before writing, realize that the sector repeating query of storage space is used, and guaranteed that each sector of using only is wiped free of once.The electronic labeling information storage realization flow of the foregoing description two, before writing, wipe once just used sector at every turn, clash again writing fashionable then need not, can realize that equally the sector repeating query of storage space is used, and guarantee that each sector of using only is wiped free of once.
After above-mentioned setting returns to form byte, when abnormal restarting takes place, for example: when accident power-off, equipment failure etc. causes the situation of abnormal restarting to occur, can recover to be in state of activation and the sector of using in information.Its flow process as shown in Figure 5, execution in step is as follows:
Step S31: electronic tag powers on and restarts.
For example: electronic tag hinders or abnormal conditions such as outage and restarting for some reason.
Step S32: find the sector that is in state of activation in each sector of its storage space.
The process of searching can repeat no more with step S12 herein.
Step S33: check the byte that returns to form in the sector that is in state of activation that finds.
Check the byte that returns to form in the sector that is in state of activation,, determine whether and to recover this information that is in the sector of state of activation so that according to whether comprising irrecoverable sign in the byte that returns to form that is provided with.
Wherein, above-mentioned irrecoverable be identified to receive write after the instruction that is used to complete in the current byte that returns to form of using the sector.If fruit is in the sector of state of activation not this irrecoverable sign, this sector just in use needed recovery when then specification exception started.
For example: the sector that is in state of activation that finds, promptly comprising the sector of activating sign in the state of activation byte is S
i, then check sector S
iThe byte that returns to form.
Step S34: comprise irrecoverable sign in the byte that returns to form? if not, execution in step S36; If, execution in step S35.
Continue to use the example of top, if sector S
iThe byte that returns to form comprise irrecoverable sign 0xfe, if execution in step S35 then is sector S
iThe byte that returns to form do not comprise irrecoverable sign 0xfe, can recover to identify 0xff but comprise, then execution in step S36.
Step S35: electronic tag enters dormant state.
Need not sector S
iInternal storage information recover.
Step S36: canned data in the sector that is in state of activation of recovering to find.
To sector S
iInternal storage information recover according to message structure.
Step S37: electronic tag enters normal Stored Procedure.
After canned data was recovered to finish, this electronic tag that is in state of activation entered normal Stored Procedure, until finishing this use.
Be available as long as guarantee not use sign and can recover sign in fact by erase operation, and irrecoverable sign and activation sign are to get final product by the mode that writes is available, and being used to complete sign is can be by available the getting final product of mode of rewriting.Concrete sign setting can be selected flexibly.
The information storage means of the above-mentioned electronic tag that provides according to the embodiment of the invention one, can make up a kind of information-storing device of electronic tag, its structure comprises as shown in Figure 6: receiver module 10, enquiry module 20, determination module 30, writing module 40 and execution module 50.
Receiver module 10 is used to receive the instruction of using request, writing request and be used to complete.
Enquiry module 20 is used for searching the sector that is in state of activation in each sector of its storage space after receiver module 10 receives the use request.
Above-mentioned enquiry module 20 specifically is used for: after receiver module 10 receives the use request, comprise the sector of activating sign in the state of activation byte that is provided with in the storage space by searching, realize looking into the sector that is in state of activation in each sector of storage space.
Determination module 30 is used for whether inquiring according to enquiry module 20 Query Result of the sector that is in state of activation, determines the current sector of using, and the sector that change is in state of activation is the current sector of determining of using.
Preferable, above-mentioned determination module 30 further can comprise: first determining unit 301 and first activates unit 302.
First determining unit 301, be used for finding when comprising last sector that the sector of activating sign and this sector be not storage space in the state of activation byte that storage space is provided with when enquiry module 20, activation in this sector sign is rewritten as is used to complete sign, and with the next sector of this sector as the current sector of using; When enquiry module 20 finds when comprising the sector of activating sign and being last sector of storage space, the sign of the activation in this sector is rewritten as is used to complete sign, and with first sector of storage space as the current sector of using; When enquiry module 20 does not find when comprising the sector of activating sign, with first sector of storage space as the current sector of using.
First activates unit 302, is used to wipe that first determining unit 301 determines that current the use being used to complete sign and canned data the sector in, writes to activate to identify in the current state of activation byte of using the sector.
Writing module 40 is used for writing when request when receiver module 10 receives, and the current sector of determining with determination module 30 of using a little writes the information to be stored that receives as initial writing.
Preferable, above-mentioned writing module 40 further can comprise: judging unit 401 and writing unit 402.
Judging unit 401 is used for writing when request when receiver module 10 receives, and whether the size of judging the storage area that information to be stored is required is greater than the size of the available memory area of a sector.
Writing unit 402, the size that is used for the storage area required as if information to be stored is not more than the size of the available memory area of a sector, then directly information to be stored is written to determine current and uses in the sector; If the size of the storage area that information to be stored is required is greater than the size of the available memory area of a sector, then, information to be stored is written at least from the available memory area of the continuous sector of current two of using the sector to begin according to the size of the required storage area of information to be stored.
Execution module 50 is used for finishing this Stored Procedure after receiver module 10 receives the instruction that is used to complete.
Preferable, the information-storing device of above-mentioned electronic tag also comprises: recover module 60.
Above-mentioned execution module 50 also is used for after receiver module 10 receives the instruction that is used to complete, and writes irrecoverable sign in the current byte that returns to form of using the sector.
Recover module 60, after being used for the electronic tag abnormal restarting, find the sector that is in state of activation in each sector of its storage space, be in the byte that returns to form that is provided with in the sector of state of activation whether comprise irrecoverable sign according to this, determine whether and to recover this information that is in the sector of state of activation.
The information storage means of the above-mentioned electronic tag that provides according to the embodiment of the invention two, can make up a kind of information-storing device of electronic tag, its structure comprises as shown in Figure 7: receiver module 11, enquiry module 21, determination module 31, writing module 41 and execution module 51.
Wherein, receiver module 11, enquiry module 21, writing module 41 and execution module 51 respectively with receiver module 10, enquiry module 20, writing module 40 and the execution module 50 of the information-storing device of above-mentioned electronic tag shown in Figure 6.Judging unit 411 that comprises in the writing module 41 and writing unit 412 are identical with writing unit 402 with the judging unit 401 that comprises in the writing module 40.
The difference of this device and device shown in Figure 6 is: its determination module 31, be used for whether inquiring the Query Result of the sector that is in state of activation according to enquiry module 20, determine the current sector of using, and the sector that change is in state of activation is the current sector of determining of using.
Preferable, above-mentioned determination module 31 further can comprise: first determining unit 311 and first activates unit 312.
Second determining unit 311, be used for finding when comprising last sector that the sector of activating sign and this sector be not storage space in the state of activation byte that storage space is provided with when enquiry module 21, wipe activation sign and canned data in this sector, and with the next sector of this sector as the current sector of using; When enquiry module 21 finds when comprising the sector of activating sign and being last sector of storage space, wipe activation sign and canned data in this sector, and with first sector of storage space as the current sector of using; When enquiry module 21 does not find when comprising the sector of activating sign, with first sector of storage space as the current sector of using.
Second activates unit 312, is used for writing the activation sign in the current state of activation byte of sector of using that second determining unit 311 is determined.
The information storage means of the above-mentioned electronic tag that the embodiment of the invention provides and device, by when using certain sector, it is set to state of activation, search the sector that is in state of activation by comprising to activate to identify in the identification state of activation byte when using next time, and determine that its next sector is current spendable sector, thereby realize using by turns successively of sector, improved the resources of chip utilization factor of electronic tag, prolonged the serviceable life of electronic tag internal storage space.
The electronic tag of using in the path identifying system of intelligent transportation field, storage spaces such as interior Flash of the sheet of its CPU or the outer EEPROM of sheet generally are used for store electrons the label routing information and the expressway entrance and exit information of process on the way.Need the canned data amount to have only tens bytes usually, generally be not more than the memory capacity of a minimum sector.And the storage space of electronic tag can provide the space of a plurality of sectors to be used for data storage, makes machine-processed by turns the application in the electronic labeling information storage in sector possess precondition.
As can be seen, after new each time sector used request to take place, the sector of use all can be rotated automatically, and available sector is recycled from the flow process of above-mentioned whole information stores.No matter be that the foregoing description one was wiped the sector that will use before writing at every turn, the foregoing description two before writing, wipe once just used sector at every turn, write the fashionable mode that clashes again of then need not in next time, the every use in each sector once all is an erase operation for once.For the transition process of embodiment one from the state of activation to the completion status is the sign of the activation in state of activation byte 0xfe directly to be rewritten into be used to complete sign 0xfc; The process that becomes unrecoverable state from returning to form to is recovering the byte that returns to form to be identified 0xff directly be rewritten into irrecoverable sign 0xfe.
The characteristic of Flash storage space has determined write operation can only realize being write 1 of some or several binary digits as 0, and erase operation is that 0 of all binary digits are reverted to 1.And above-mentioned state of activation byte and the sign in the byte of returning to form are provided with and just are based on that this rule is provided with, never use sign 0xff to be rewritten into to activate sign 0xfe, directly be rewritten into and be used to complete sign 0xfc and directly be rewritten into irrecoverable sign 0xfe, write as 0 operation from 1 from recovering to identify 0xff from activating sign 0xfe; And from reverting to and do not use sign 0xff, revert to and do not use sign 0xff and revert to and can recover to identify 0xff from can not recovering to identify 0xfe from being used to complete sign 0xfc from activating sign 0xfe, all be to recover 1 operation by erasable from 0.Therefore, the setting of the state of activation byte and the byte that returns to form does not need additionally storage space to be wiped, at utmost reduce the frequency of wiping of storage space, guarantee that each sector of using only is wiped free of once, improves the access times of storage space to greatest extent.Avoided the erasable repeatedly problem of same position quilt, thereby improved serviceable life at storage space.
Said method meets writing the activation sign and being used to complete sign, use sign of erasable characteristic by using in the state of activation byte, controls the use by turns of sector; And sign recovered and irrecoverable sign by meeting erasable characteristic equally, come realization information to recover control.By having taken into full account the erasable characteristic of storage space, guarantee that each byte of current use sector only can be by once erasable in the process of finishing primary information storage use.Simultaneously, by the setting byte that returns to form, when abnormal conditions take place, can also guarantee system meet accident the outage or restart after, canned data in the sector of using that is in state of activation before can correctly recovering to cut off the power supply after restarting that powers on has improved the stability and the reliability of system to a great extent.
The above; only be the preferable embodiment of the present invention; but protection scope of the present invention is not limited thereto; anyly be familiar with those skilled in the art in the technical scope that the present invention discloses; the variation that can expect easily, replace or be applied to other similar devices, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claims.