This application claims priority to Japanese Patent Application No. 2004-323135 filed on Nov. 8, 2004. The entire disclosure of Japanese Patent Application No. 2004-323135 is hereby incorporated herein by reference.
The present invention relates to a data recording device for managing files using a FAT file system and to a goods-processing apparatus comprising same.
Over the past several years, the need has arisen to save and manage production information and other information related to goods in order to deal with traceability and HACCP. In a machine for weighing and packaging goods or another goods-processing apparatus, a FAT file system (for example, see Japanese Laid-Open Patent Application Publication No. 11-149401) that is compatible with a Windows® computer is installed in order to deal with such conditions, whereby production information and the like are saved and managed.
The FAT file system comprises a data region in which file data, i.e., a main body of data is recorded in cluster units; a directory region in which file managing information about file names, creation times and dates, file properties, file sizes, starting clusters, and others is recorded; a FAT region in which file managing information about locations and order of clusters in the data region used by files and others is recorded; and a boot sector in which a boot record is recorded.
When a file is updated in the FAT file system, the old file data in the data region must be overwritten by the new file data, and the old file managing information in the FAT region and directory region must also be overwritten by the new file managing information.
For this reason, when a power source for the goods-processing apparatus is interrupted while data is being written to the data region due to a blackout or the like, the component part of the file data that was written before the power source was interrupted and the component part of file data that was present before writing began will be mixed in the data region, and, as a result, the file data will be destroyed.
When the power source is interrupted while data is being written to the directory region or FAT region, file managing information about the file names, creation times and dates, file properties, file sizes, starting clusters, locations and order of used clusters, and others will be destroyed; the file data will not match the file managing information; and the files may no longer be accessible.
In particular, in CompactFlash®, sectors that are to be written to must be erased before the data is written. Therefore, when the power source is interrupted directly after the erasing procedure, file managing information relating to that particular sector will be completely lost. In such instances, files other than those that were being accessed may also become inaccessible.
The present invention was devised in view of the foregoing circumstances, and it is an object of the present invention to provide a data recording device in which a file allocation table (referred to below simply as “FAT”) and directory data which are file managing information are protected, whereby, during a restart, the FAT and directory data can be restored to a state that was present directly before a file update or another file operation even when a power source is interrupted while such a file operation; and a goods-processing apparatus comprising same.
A data recording device according to a first aspect of the invention is a data recording device for managing files using a FAT file system, and comprising a recording medium and nonvolatile memory. The recording medium records file data, a FAT, and directory data related to the files. A backup region is provided in the nonvolatile memory. The FAT and directory data are backed up in the backup region before the FAT and directory data are updated.
The data recording device comprises nonvolatile memory. When the FAT, directory data, and other file managing information are updated, the FAT and directory data are backed up to the backup region provided to the nonvolatile memory before being updated. Accordingly, in the data recording device, the FAT and directory data are protected. Therefore, during a restart, the FAT and directory data can be restored to a state that was present directly before a file operation was performed even if the power source was interrupted during the file operation.
This includes instances in which the recording medium and nonvolatile memory are the same.
A data recording device according to a second aspect of the invention is the data recording device according to the first aspect of the invention, wherein the backup region is not managed by any file system.
In this data recording device, the backup region is not managed by any file system. Therefore, the backup data can assuredly be relied upon even when the power source is interrupted while the FAT and directory data are being backed up.
A data recording device according to a third aspect of the invention is the data recording device according to the first aspect or the second aspect of the invention, wherein the nonvolatile memory is different from the recording medium.
In this data recording device, the FAT and directory data recorded to the recording medium are backed up to the nonvolatile memory, which is different from the recording medium. Therefore, the backup data can assuredly be relied upon even if the power supply is interrupted while the FAT and directory data are being backed up.
A data recording device according to a fourth aspect of the invention is the data recording device of any of the first aspect through the third aspect of the invention, wherein, a power interruption determination flag for marking the occurrence of a power source interruption is recorded in the backup region when the FAT and directory data are backed up.
In this data recording device, the power interruption determination flag is recorded in the backup region. Accordingly, in the data recording device, whether a restoration process should be performed is automatically determined, on the basis of the recorded power interruption determination flag, during a restart.
A data recording device according to a fifth aspect of the invention is the data recording device according to any of the first aspect through the fourth aspect of the invention, wherein the recording medium is a removable medium in which a volume serial number for identifying the recording medium is recorded in the backup region when the FAT and directory data are backed up.
In this data recording device, a volume serial number for identifying the removable medium is recorded to the backup region. Accordingly, in the data recording device, when the removable medium inserted during a restart is determined, on the basis of the recorded volume serial number, not to be the removable medium inserted when the power source was interrupted, a restoration process can be avoided.
A data recording device according to a sixth aspect of the invention is the data recording device according to any of the first aspect through the fifth aspect of the invention, wherein the recording medium has a plurality of clusters including a first cluster and a second cluster that is different from the first cluster, and new file data is written to the second cluster, and a FAT chain is then reconnected to the second cluster, whereupon the first cluster is freed up in order to update the file data stored in the first cluster.
In this data recording device, new file data is written to an empty cluster and a FAT chain is then reconnected to the cluster in which the new file data has been written, whereupon the file data before the update is freed up. Accordingly, in the data recording device, the old file data can be reliably protected even when the power source is interrupted while the file data is being written.
A data recording device according to a seventh aspect of the invention is the data recording device according to any of the first aspect through the sixth aspect of the invention, wherein the nonvolatile memory is built-in.
In this data recording device, the backup region is provided to the built-in nonvolatile memory. Accordingly, in the data recording device, the FAT and directory data can readily be backed up.
A goods-processing device according to an eighth aspect of the invention comprises the data recording device of any of the first aspect through the seventh aspect of the invention.
The goods-processing device produces the same effect as the data recording device according to any of the first through seventh aspects of the invention. Accordingly, operation history, device setting data, and a variety of other data in addition to goods production information processed by the goods-processing device can be reliably saved in the goods-processing device.
In the data recording device according to the first aspect of the invention, when the FAT, directory data, and other file managing information are updated, the FAT and directory data are backed up to the backup region provided to the nonvolatile memory before being updated. Accordingly, in the data recording device, the FAT and directory data are protected. Therefore, during a restart, the FAT and directory data can be restored to a state that was present directly before a file operation was performed even if the power source was interrupted during the file operation.
In the data recording device according to the second aspect of the invention, the backup region is not managed by any file system. Therefore, the backup data can assuredly be relied upon even when the power source is interrupted while the FAT and directory data are being backed up.
In the data recording device according to the third aspect of the invention, the FAT and directory data recorded to the recording medium are backed up to the nonvolatile memory, which is different from the recording medium. Therefore, the backup data can assuredly be relied upon even if the power supply is interrupted while the FAT and directory data are being backed up.
In the data recording device according to the fourth aspect of the invention, the power interruption determination flag is recorded in the backup region. Accordingly, in the data recording device, whether a restoration process should be performed is automatically determined, on the basis of the recorded power interruption determination flag, during a restart.
In the data recording device according to the fifth aspect of the invention, a volume serial number for identifying the removable medium is recorded to the backup region. Accordingly, in the data recording device, when the removable medium inserted during a restart is determined, on the basis of the recorded volume serial number, not to be the removable medium inserted when the power source was interrupted, a restoration process can be avoided.
In the data recording device according to the sixth aspect of the invention, new file data is written to an empty cluster and a FAT chain is then reconnected to the cluster in which the new file data has been written, whereupon the file data from before the update is freed up. Accordingly, in the data recording device, the old file data can be reliably protected even when the power source is interrupted while the file data is being written.
In the data recording device according to the seventh aspect of the invention, the backup region is provided to the built-in nonvolatile memory. Accordingly, in the data recording device, the FAT and directory data can readily be backed up.
A goods-processing device according to an eighth aspect of the invention produces the same effect as the data recording device according to any of the first through seventh aspects of the invention. Accordingly, operation history, device setting data, and a variety of other data in addition to goods production information processed by the goods-processing device can be reliably saved in the goods-processing device.
A data recording device 20 and a goods-processing apparatus 10 comprising same according to an embodiment of the present invention will be described below with reference to
The goods-processing apparatus 10 is used, e.g., to weigh and package goods, print and apply goods labels, and perform other processes; and comprises the data recording device 20 that is capable of saving information related to the production of the goods, which is the object of the processing, as well as a variety of other data in order to deal with traceability and HACCP.
As shown in
As shown in
SRAM 4 whose power source is backed up is embedded in the controller 1 as nonvolatile memory that can steadily hold data and that can be accessed at high speeds. The SRAM 4 is provided with a backup region for backing up the data in the CF 2. The backup region is not managed by any file system. A CPU 5 is embedded in the controller 1. The CPU 5 is connected to the SRAM 4 and is used to perform, in accordance with a program stored in the SRAM 4, a process described below with reference to
In the process for writing a file to the CF 2, a directory entry is written (step A1), file data is written (step A2), a FAT is written (step A3), a directory entry is written (file size and starting cluster setting) (step A4), and a power interruption flag (described hereunder) is cleared (step A5) sequentially, as shown in
Details of the writing processes of steps A1, A3, and A4 are as shown in
When the capacity is sufficient for the backup process, the drive name, volume serial number, writing starting sector number, and the contents of the sector before writing are sequentially backed up to the backup region (steps B3 through B6). A power interruption determination flag is then incremented (step B7) and, finally, the FAT or directory data to be written is written to the CF 2 (step B8), and the writing process is finished. The power interruption determination flag is recorded to the backup region.
The startup process for the data recording device 20 will next be described with reference to
When the data recording device 20 is started, the file system is initialized (step C1) and the file system is mounted (step C2). The power interruption flag is then checked (step C3) in order to determine whether the power source was interrupted while a file was being written. As described above, the power interruption determination flag is incremented by one every time the writing process in step A1, A3, or A4 finishes; and is cleared when all writing processes have finished without incident. Therefore, when the power interruption determination flag is zero, it is determined that no interruption in the power source occurred while a file was being written. When it is determined that the power source was not interrupted while a file was being written, the backup region is initialized (step C6) without a file restoration process (step C5) being performed.
When it is determined that the power supply was interrupted while a file was being written, the volume serial number of the CF 2 currently inserted and the volume serial number recorded in the backup region are compared (step S4) in order to determine whether the CF 2 currently inserted in the data recording device 20 is the medium that was inserted pe when the power source was interrupted. When the numbers do not match, i.e., when the CF 2 currently inserted is different from the medium inserted when the power source was interrupted, the backup region is initialized (step C6) without a file restoration process (step C5) being performed.
On the other hand, when the power interruption determination flag is one to three (i.e., it is determined that the power supply was interrupted while a file was being written) and the CF 2 currently inserted in the data recording device 20 is determined to be the medium inserted when the power supply was interrupted, a process for restoring the FAT or directory data is performed (step C5). The restoration process of step C5 is performed by writing the pre-writing-process contents of the sector, which were backed up to the backup region in step B6, to the sector of the CF 2 that is to be restored. The sector of the CF 2 that is to be restored is determined on the basis of the drive name backed up in step B3 and the writing starting sector number backed up in step B5. The backup region is then initialized (step C6). File managing information about file names, creation dates and times, file properties, file sizes, starting clusters, locations and order of used clusters, and others can thereby reliably be restored without damage even when the power source is interrupted while the FAT or directory data of the CF 2 is being written.
The power source for the data recording device 20 may also be interrupted while file data is being written to the data region 101 in step A2. In order to address such occurrences, the writing (updating) process is performed in the data recording device 20 using a procedure shown in
Once the FAT chain has been reconnected, the clusters 202, 203 that was used to record the old file data before the update and no longer be used to record any file data are freed up, as shown in
In the above embodiment, a backup region is provided to the SRAM 4. However, the backup region may also be provided to the nonvolatile memory 6, which is separate from the SRAM 4, as shown in
In the goods-processing apparatus 10 shown in
The present invention is useful as a data recording device for managing files by a FAT file system in which a FAT, which is file managing information, and directory data are protected, whereby, during a restart, the FAT and directory data can be restored to a state that was in effect directly before a file update or another file operation was performed even when a power source is interrupted during such a file operation. The present invention is additionally useful as a goods-processing apparatus comprising the data recording device.
Number | Date | Country | Kind |
---|---|---|---|
2004-323135 | Nov 2004 | JP | national |
Filing Document | Filing Date | Country | Kind | 371c Date |
---|---|---|---|---|
PCT/JP05/20310 | 11/4/2005 | WO | 4/26/2007 |