![Satechi pm130e Reference Manual Download Page 15](http://html1.mh-extra.com/html/satechi/pm130e/pm130e_reference-manual_1200398015.webp)
15
file (or section) read pointer. If you want to begin reading a file from a particular record,
which sequence number is known, you can change the pointer position by issuing the Set-
File-Position request with the desired sequence number. If you want to read a file from the
beginning, send the Reset-File-Position request that moves the pointer to the oldest file
record. If you do not change the file position, then you will continue reading the file from
the record following the one you have read the last time you accessed the file.
You need not explicitly move the file position to the following record if you want to continue
reading a file in sequence after you have uploaded the current record. Instead, issue an
acknowledgment request that automatically advances the file pointer to the next record,
and then read the record data through the file response block.
The file response block can contain more than one record. The number of records available
in the block and the file record size in words are always reported in the block heading.
There are no special rules on how to read records from the file transfer block. You can read
a single record or all records together, or begin reading from the last record and end with
the first record. However, you should remember: 1) after an acknowledgment, the file
position moves to the record following the last one you have accessed in the file transfer
block; and 2) data in the file transfer block does not change until you either issue an
acknowledgment, or explicitly change the file position by the Set-File-Position or Reset-File-
Position requests.
The file transfer is completed after you have read the last record of the file. Before storing a
file record to your database, always check bit 9 in the record status word, which contains
the end-of-file (EOF) flag. This bit set to 1 indicates that the file read pointer does not point
to any record within the file, and you should not store any record that has this bit set. The
EOF flag is set only after you have acknowledged the last record of the file, so that testing
for end-of-file requires one extra read. If you wish to stop the transfer just after storing the
last file record, acknowledge the record and check bit 0 in the record status word. Bit 0 is
set to 1 only once when you read the last record of the file.
The following gives a summary of steps you should do to read an ordinal log file:
1. If you wish to begin reading a file from a particular record or from the first record, use
either the Set-File-Position request with the desired record sequence number, or the
Reset-File-Position request. Preset a section number and channel ID to zero.
2. Write the Read-File request with a section number and channel ID set to zero.
3. Read the record data from the file response block.
4. Write an acknowledgment for the file. You need not fill all the request fields: only the
file function is required. The file pointer will be moved to the next file record.
5. Repeat steps 3-4 until all the file records are read.
Reading Multi-section Data Log Files
In a multi-section data log file, all user requests including an acknowledgment, the Read-
File, Set-File-Position and Reset-File-Position requests, relate to a particular file section
rather than to the file itself. The only request that affects the entire file is the Erase-File
that clears all the file sections together.
A file section can be requested either by a section number, or by a section channel ID. If
you use a channel ID, preset the section number field to 0xFFFF. If a section number is
specified, the channel ID field will not be checked. The device returns both fields in the
response block heading, so you can always identify what channel data is being read from
the present file section. If you want to know which channels are recorded to the file
sections, check the file channel mask in the file info block. This is a bitmap that contains
one in a bit position if a channel with an ID equal to the bit number is recorded to the file,
and contains zero if it is not.
The following gives a summary of steps for reading a multi-section data log file:
1. If you wish to begin reading a file section from a particular record or from the first
record, use either the Set-File-Position request with the desired record sequence
number, or the Reset-File-Position request. Specify either a section number, or the
channel ID for the section from where you want to read data. If you use a channel ID,
preset the section number field to 0xFFFF.
Provided
by
Northeast
Power
Systems,
Inc.
www.nepsi.com