Reader class

Read raw frame and header data from a log file. This is a lower level mechanism, most probably you will only need the Parser.load factory method and not create a Reader directly.

class orangebox.reader.Reader(path: str, log_index: int | None = None)[source]

Implements a file-like object for reading a flight log and store the raw data in a structured way. Does not do any real parsing, the iterator just yields bytes.

Parameters:
  • path – Path to a log file

  • log_index – Session index within log file. If set to None (the default) there will be no session selected and headers and frame data won’t be read until the first call to set_log_index().

set_log_index(index: int)[source]

Set the current log index and read its corresponding frame data as raw bytes, plus parse the raw headers of the selected log.

Parameters:

index – The selected log index

Raises:

RuntimeError – If index is smaller than 1 or greater than log_count

property log_index: int

Return the currently set log index. May return 0 if set_log_index() haven’t been called yet.

Type:

int

property log_count: int

The number of logs in the current file.

Type:

int

property log_pointers: List[int]

List of byte pointers to the start of each log file, including headers.

Type:

List[int]

property headers: Dict[str, str | int | float | List[int | float]]

Dict of parsed headers.

Type:

dict

property field_defs: Dict[FrameType, List[FieldDef]]

Dict of built field definitions.

Type:

dict

value() int[source]

Get current byte value.

has_subsequent(data: bytes) bool[source]

Return True if upcoming bytes equal data.

tell() int[source]

IO protocol

seek(n: int)[source]

IO protocol