API Reference

class chapter10.c10.C10(f)

A Chapter 10/11 parser.

Parameters:

f (file or str) – A file like object or file path to read from.

last_time: time.TimeF1

Most recently parsed (or generated) time packet.

classmethod from_string(s)

Create a C10 object from a string or bytes.

class chapter10.packet.Packet(file=None, parent=None, **kwargs)

Base class for the various datatypes. May be created from a file-like object or started from scratch.

Parameters:
  • file (file-like) – Source file to read from.

  • kwargs – Initial header values. Read from file if not provided.

Chapter 10 Header Attributes

  • sync_pattern

  • channel_id

  • packet_length

  • data_length

  • header_version

  • sequence_number

  • secondary_header

  • ipts_source

  • rtc_sync_error

  • data_overflow_error

  • secondary_format

  • data_checksum

  • data_type

  • rtc

  • header_checksum

Secondary Header (if present)

  • secondary_time

  • secondary_checksum

Other Members

FORMAT: BitFormat

Description of the chapter 10 header

SECONDARY_FORMAT: BitFormat

Describes the secondary header

csdw_format: BitFormat = None

Describes a datatype’s channel specific data word (CSDW)

append(*messages)

Add one or more messages to the packet.

clear()

Remove all messages.

copy()

Duplicate this packet.

get_time()

Return a timestamp for this packet. Depends on parent C10 object.

remove(i)

Remove message at index ‘i’

validate(silent=False)

Validate the packet using checksums and verifying fields. If silent = False raises InvalidPacket.

exception chapter10.packet.InvalidPacket
class chapter10.packet.Message(data=b'', parent=None, **kwargs)

The base class for packet message data. Subclasses define FORMAT, length, etc. to give the format and can be instantiated empty or from a packet using the from_packet method.

Parameters:
  • data (bytes) – The binary data to be stored. May be empty (for instance, if FORMAT fully describes the format).

  • parent (Packet) – The Packet object this message belongs to.

  • kwargs – Arbitrary key-value pairs to add as attributes to the item instance. Used for IPH values.

Class Attributes

FORMAT: BitFormat = None

Describes the intra-packet header (IPH) or message format in general.

length: int = 0

Byte size of message body. If not specified will look for a ‘length’ field in the IPH.

Instance Attributes

parent: Packet or None

The Packet object this message is attached to.

data: bytes

Raw data not identified in FORMAT

classmethod from_packet(packet)

Helper method to read a message from packet.

get_time()

Return a timestamp for this message based on parent packet.