Device attributes¶
Object group 0: the attributes an outstation reports about itself and the ones a master may write. Device attributes is the guide; this is the reference.
py1815.attributes ¶
Device attributes, object group 0: encode, decode, read and write.
Every attribute is an object of its own variation that carries its data type
code, a length octet and a value (IEEE 1815-2012 5.5.4). The data type codes
are the ones of the consolidated table in TB2017-007a. This module knows those
layouts and the rules for reading and writing them, and nothing about where an
outstation gets a value from: the owner of a :class:DeviceAttributes store
decides that, and the session answers reads and writes from it.
Only attribute set 0, the one the DNP Users Group defines, exists here (IEEE 1815-2012 5.5.1). A read of any other set is refused.
Copyright 2026 DER Security Corp. Licensed under the Apache License, Version 2.0.
DataType ¶
Bases: IntEnum
The attribute data type codes of Table 11-4 as revised by TB2017-007a.
Source code in src/py1815/attributes.py
Variation ¶
Bases: IntEnum
The attribute variations of set 0 that the standard requires at Subset Level 4.
Source code in src/py1815/attributes.py
UnknownVariation ¶
BadParameter ¶
Attribute
dataclass
¶
One attribute: its data type code and the octets of its value.
Source code in src/py1815/attributes.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
value
property
¶
The value as Python holds it, or None where the data type or length does not decode.
A string, an integer, a float, the pairs of a list of variations as
(variation, writable), or the octets of an octet string. A Boolean
is an integer, as the standard defines it.
text
classmethod
¶
Return a visible-ASCII string, data type VSTR.
Raises:
| Type | Description |
|---|---|
ValueError
|
The string is longer than :data: |
Source code in src/py1815/attributes.py
unsigned
classmethod
¶
Return an unsigned integer in the fewest of 1, 2, 4 or 8 octets.
Source code in src/py1815/attributes.py
flag
classmethod
¶
Return a Boolean: an INT of one octet that is 1 for true and 0 for false.
variation_list
classmethod
¶
Return the list of variations, each with its writable bit (A.1.44).
Data type U8BS8LIST while the list fits the length octet, and U8BS8EXLIST once it does not.
Source code in src/py1815/attributes.py
encode ¶
Return the data type code, the length octet and the value.
DeviceInformation
dataclass
¶
What an outstation says about itself in its device attributes.
Each text is at most :data:MAX_TEXT visible ASCII characters. The
constructor raises ValueError, naming the field, for one that is not.
Source code in src/py1815/attributes.py
DeviceAttributes ¶
The attributes of set 0 an outstation holds, and the ones a master may write.
The store keeps the values the owner gave it and the ones a master has
written since. A written value lasts as long as this object: it is not
kept across a restart of the process, and :meth:reset returns every
attribute to the value it was given. The standard does not require a
written attribute to survive a reset of any kind (IEEE 1815-2012 5.5.8).
The session adds the three attributes that are its own: the fragment sizes and the limit on binary outputs in a request. A store holds none of them.
Source code in src/py1815/attributes.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
snapshot ¶
check ¶
Raise unless attribute may be written to variation.
Raises:
| Type | Description |
|---|---|
UnknownVariation
|
The variation is not one a master may write. |
BadParameter
|
The data type is not the attribute's, or the text is
not visible ASCII of at most :data: |
Source code in src/py1815/attributes.py
write ¶
Store every written attribute, or none of them when any is not acceptable.
Source code in src/py1815/attributes.py
describe ¶
Return the variation's name as a sentence, such as Counter count.
Source code in src/py1815/attributes.py
parse_attribute ¶
Read one attribute at offset and return it with the offset after it.
Raises:
| Type | Description |
|---|---|
ValueError
|
The octets end before the length the attribute states. |
Source code in src/py1815/attributes.py
attribute_block ¶
Return one attribute as a response block: its header, then its octets.
The list of variations goes under qualifier 0x17 with a count of 1, as IEEE 1815-2012 5.5.6.2 requires. Every other attribute goes under a range that holds the index only, as the example in 5.5.5 does.
Source code in src/py1815/attributes.py
read_blocks ¶
read_blocks(
headers: Sequence[ObjectHeader],
view: Mapping[int, Attribute],
writable: Collection[int],
) -> list[bytes]
Return the response blocks for a read of group 0, one attribute to a block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headers
|
Sequence[ObjectHeader]
|
The read's object headers, each of group 0. |
required |
view
|
Mapping[int, Attribute]
|
Every attribute of set 0 that the outstation has, by variation. It holds neither variation 254 nor variation 255. |
required |
writable
|
Collection[int]
|
The variations in |
required |
Variation 254 returns every attribute in ascending order, and never itself or the list (TB2016-003b note a to Table 12-1). A set that does not exist is a parameter error; an attribute the outstation lacks is an unknown object.
Raises:
| Type | Description |
|---|---|
UnknownVariation
|
A header names a variation that is not in |
BadParameter
|
A header names a set that does not exist, or a qualifier that selects none. |
Source code in src/py1815/attributes.py
parse_writes ¶
Return every attribute a write request carries, as (variation, attribute).
first and body are what :func:~py1815.application.parse_request
gives for a write: the first object header, and the octets after it, which
hold its object, then any further headers each followed by its object.
Raises:
| Type | Description |
|---|---|
UnknownVariation
|
A header names an object that is not an attribute. |
BadParameter
|
A header does not name set 0 under a range, or an object is cut short. |
RequestError
|
A header after the first cannot be read. |
Source code in src/py1815/attributes.py
software_version ¶
Return stated, or this library's own version when it is empty.