Bit | Description |
---|---|
15 | Unused, reserved |
14 | Physical record type (only 0 is defined) |
13-12 | 00 - No checksum, 01 - 16bit checksum, 10, 11 - Undefined |
11 | Unused, reserved |
10 | If 1 File number is present in trailer |
09 | If 1 Record number is present in trailer |
08 | Unused |
07 | Unused, reserved |
06 | If 1 then a previous parity error has occurred |
05 | If 1 then a previous checksum error has occurred |
04 | Unused |
03 | Unused, reserved |
02 | Unused |
01 | If 1 there is a predecessor Physical Record |
00 | If 1 there is a succcessor Physical Record |
Specialisation of exception for Physical Records.
Physical Record unexpected EOF.
Physical Record encountered undefined checksum bit.
Encountered unknown type 1 Physical Record.
Physical Record writing.
Physical Record Trailer exception.
PR Header 4 bytes long, two big-endian 16 bit numbers The struct.Struct() format for the Physical Record Header
The struct.Struct() format for the Physical Record Header attributes
The length of the Physical Record Header
Number of bits in the 2 byte attributes
Successor bit position
Predessor bit position
Checksum error bit position
Parity error bit position
Bit position to indicate there is a record number in the trailer
Bit position to indicate there is a file number in the trailer
Bit position to indicate there is a 16bit checksum in the trailer
Bit position to indicate checksum is undefined
Bit position to indicate Physical Record Type
Unused only bits - i.e. Unused but not Unused, reserved
Unused, reserved bit mask
Unused and Unused, reserved bits, 0x899C
The struct.Struct() format for the Physical Record Trailer record number
The length of the Physical Record Trailer for the record number
The minimum record number
The maximum record number
The struct.Struct() format for the Physical Record Trailer file number
The length of the Physical Record Trailer for the file number
The minimum file number
The maximum file number
The struct.Struct() format for the Physical Record Trailer checksum
The length of the Physical Record Trailer for the checksum
Maximum possible Physical Record length represented by an unsigned 16 bit int
Base class for physical record read and write. TODO: Checksum reading, writing and testing.
Close the underlying stream, further operations will raise a ValueError.
Returns the header string to go at the top of a list of __str__().
Specialisation of PhysRecBase for reading streams.
Reads theSize logical data bytes and returns it as a bytes() object. If theSize is -1 all logical data for this logical record is returned. If theLd is not None it is extended and returned, otherwise a new bytes() object is created and returned. Returns None on end of logical record.
Skips logical data and returns a count of skipped bytes. If theSize is -1 all logical data for this logical record is skipped positioning the stream at end of this logical record (Note: not the beginning of the next logical record). Returns 0 on end of logical record.
Skips all remaining logical data, the PR trailer, and the next PR header. This positions stream at the start of the next logical record. May raise an ExceptionPhysRecEOF if there is no further Logical or Physical record. Returns the number of Logical Data bytes skipped.
Returns the absolute file position of the start current Logical record. This value can be safely used in seekLr.
Returns the absolute position of the file.
External setting of file position directly to the beginning of a PRH or TIF marker (if present). The caller is fully responsible for getting this right!
Setting the file position directly to the beginning of a PRH or TIF marker (if present) for the current Logical Rcord.
Returns True if there is logical data to be read, False otherwise. NOTE: This will return False on file initialisation and only return True once the Physical Record Header has been read.
Returns the number of bytes remaining in this particular Physical Record. NOTE: The can be 0 and hasLd() be True if at the end of a Physical Record that has a successor record.
A generator that produces a tuple of (logical data, isLrStart) where: logical data - A bytes() object for the logical data in the current PR. isLrStart - A boolean that is True of that LogicalData is the start of a logical record. NOTE: This rewinds the current state of this instance.
Represents Physical Record Tail fields.
Returns the PRH attributes, to be or’d with any other attributes.
Returns True if any PRT field is present, False otherwise.
Computes the checksum of the byte stream.
Specialisation of PhysRecBase for writing to files.
Close the Physical Record Handler and the underlying stream.
Splits a Logical Record into into Physical Records and writes them to the stream. These Physical Records have trailer records if required. Returns the tell() of the start of the LR.