Location: HomeNews Technical News

Introduction to CPU Card Knowledge Tutorial - Chapter 6: Operation of Files in CPU Cards

2023-08-24 15:17:09

What methods do we have to manipulate files?

For example, we need to operate on the personal basic information file pm.txt. In DOS, we can use EDIT pm.txt for editing,

Under Windows, we can double-click pm.txt and open the file using a text editor.

But how do we operate on a file (such as EF1) in a CPU card?

For example, if we want to hit someone, we must first find the person who will be unlucky to be hit.

Similarly, when we need to manipulate a file, first we must find the file we want to manipulate.

How can we find the files in the CPU card?

We can find someone by looking up his (her) ID number. Does each file of the card in the CPU also have

Where's their ID number number?

Yes: That's file identification. The files in the CPU card are marked with a file identification table.

Looking for someone, you can also search for files in the CPU card by their name? Unfortunately,

The files related to MF and DF directories have their file names, while other files do not have file names.

<File identifier and file name>

The file identifier is the identification code of a file, represented by 2 bytes. Why is there only 2 bytes? Because two bytes are enough, two bytes

FFFF=65535.

When selecting a file, simply find the identifier of the file to locate it. The file identifiers in the same directory are unique.

The file identifier for MF is 3F00, the file name is customizable, and it should comply with bank regulations. The name should be 1PAY SYS DDF01,

Of course, the social security card does not specify this name.

All files can be selected using the SELECT command through file identifiers, and directory files DF can be selected through directory names.

Short file identifier:

Due to the requirement of saving space and facilitating operations on CPU card files.

So it seems like the short file identifier has appeared.

The so-called short file identifier literally means it is shorter than the file identifier. It seems like it's actually the same.

Let's take a look, short file identifiers are only represented by one byte, and are represented by the lower five bits of one byte.

The short identifier of files in the same directory must be unique.

The short file identifier can be implemented through the parameter P1 of the Read Binary and Update Binary commands to identify the file

Option: If the high three bits of P1 are 100, then the low five bits are the short file identifier. For example, if P1 is 81H, i.e. 10000001,

If the top three digits are 100, the selected file identifier is 00001, and the hexadecimal file identifier is represented as 00 01.

The selection of short file identifiers can also be achieved through the Read Record and Update Record command parameters P2,

The method is that if the upper five bits of P2 are not all 0 and the lower five bits are 100, then the upper five bits are the short file identifier. For commands

The last five digits of the Append Record are 000 to indicate the short file identifier.

The selection of short file identifiers can only be determined by five digits, so the maximum file identifier that can be selected is 31,

If a file requires a short file identifier for selection, the file identifier needs to be set between 1 and 31 when creating the file.

<Access to files>

In the previous section, there were so many files specified, so how should we access those files?

MF:

Automatically selected after the CPU card is reset, MF can be selected in any level of subdirectory using the file identifier 3F00 or its file name

DF

Select DF by file name or file identifier, and any DF can be selected under MF.

If the current file is an EF under a DF, you can also select any DF by selecting its file identifier or file name.

Binary files:

When the read condition is met, Read Binary can be used to read, and Update Binary can be used to change the binary text when the write condition is met

The content of the item.

Fixed length record file:

When the read condition is met, Read Record can be used to read. When the write condition is met, if the record is not full, Append Record can be used to increase it

New record, if the record is full, use Update Record to change the content of the specified record.

Circular fixed length record file:

When the read condition is met, Read Record can be used to read, and when the append condition is met, Append Record can be used to append to the end of the file

A record that automatically overwrites the earliest written record when it is full. The record number for the last written record is always 1

The record number is 2, and so on.

Variable length record file

When the reading conditions are met, the Read Record can be used to read out the record. If the record is not full when the writing conditions are met, the Append Record can be used to increase it

New record, if the record is full, use Update Record to change the content of the specified record. The format of the variable length record file is TLV format,

Tag is a 1-byte record identifier, L is a 1-byte record data length, and V is an L-byte data value. Performing Update Record changes

When there are existing records, the length of the newly written entire record must be equal to the length of the original entire record, otherwise an error will be returned.

About FONGWAH
FONGWAH Technology is a high-tech enterprise that specializes in research, development, production, and operation of intelligent IC cards, embedded IC card modules, desktop IC card readers, and related IC card reading and writing devices
Last News

Related products

Page

Hot News