BinaryTraceFileReader

class osi_utilities.tracefile.binary_reader.BinaryTraceFileReader(message_type=MessageType.UNKNOWN)[source]

Bases: TraceFileReader

Reader for single-channel binary OSI trace files (.osi).

Each message is stored as: [4-byte LE length][serialized protobuf bytes]

The message type can be specified explicitly or inferred from the filename.

Parameters:

message_type (MessageType)

open(path)[source]

Open a binary .osi trace file.

Parameters:

path (Path) – Path to the .osi file.

Returns:

True on success, False on failure.

Return type:

bool

open_with_type(path, message_type)[source]

Open a binary .osi trace file with an explicit message type.

Parameters:
  • path (Path) – Path to the .osi file.

  • message_type (MessageType) – The message type to use.

Returns:

True on success, False on failure.

Return type:

bool

read_message()[source]

Read the next message from the binary trace file.

Returns:

ReadResult on success, None if no more messages.

Raises:

RuntimeError – If the message is truncated or deserialization fails.

Return type:

ReadResult | None

has_next()[source]

Check if there are more messages to read.

Return type:

bool

close()[source]

Close the trace file.

Return type:

None

property message_type: MessageType

The message type being read.