Object Utilities¶
- icspacket.proto.dnp3.objects.util.new_octet_string(data: bytes, /, group: int | None = None, prefix: int | None = None) DNP3Objects[source]¶
Create a new DNP3 octet string object.
This function constructs a
DNP3Objectscontainer holding a single octet string object of the given length. By default, group 110 is used (standard octet strings), unless a specific group is provided.The function automatically selects the variation number based on the length of the input string.
- Parameters:
data (bytes) – Octet string payload.
group (int | None, optional) – Optional group identifier. Defaults to 110 if not provided.
prefix (int | None, optional) – Optional prefix used when adding the object instance.
- Returns:
A DNP3Objects container with the constructed octet string.
- Return type:
- Raises:
ValueError – If the octet string exceeds 255 bytes.
- icspacket.proto.dnp3.objects.util.get_octet_string(objects: DNP3Objects, /, group_id: int | None = None) bytes[source]¶
Extract the first octet string instance from a DNP3Objects container.
This function searches the given
DNP3Objectscontainer for an octet string in the specified group (default: 110). If found, it returns the first octet string instance.This function always succeeds.
- Parameters:
objects (DNP3Objects) – Container holding DNP3 objects.
group_id (int | None, optional) – Optional group identifier. Defaults to 110 if not provided.
- Returns:
The extracted octet string, or an empty bytes object if not found.
- Return type:
bytes
- icspacket.proto.dnp3.objects.util.as_variation0(*groups: int) DNP3Objects[source]¶
Construct variation 0 objects for the given groups.
Variation 0 is a “request all variations” mechanism defined by the DNP3 specification. This utility builds a
DNP3Objectscontainer where each requested group contains a variation 0 object.- Parameters:
groups (int) – One or more group identifiers.
- Returns:
A DNP3Objects container with variation 0 objects for the given groups.
- Return type:
- icspacket.proto.dnp3.objects.util.new_class_data_request(*classes: int) DNP3Objects[source]¶
Construct a DNP3 class data request.
This function creates a
DNP3Objectscontainer representing a request for event data belonging to the specified DNP3 classes (0-3). Each class corresponds to a variation within Group 60:Class 0 Group 60 Variation 1
Class 1 Group 60 Variation 2
Class 2 Group 60 Variation 3
Class 3 Group 60 Variation 4
- Parameters:
classes (int) – One or more class numbers (0-3).
- Returns:
A DNP3Objects container representing the class data request.
- Return type: