open61850 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- open61850-0.1.1/LICENSE +202 -0
- open61850-0.1.1/PKG-INFO +157 -0
- open61850-0.1.1/README.md +135 -0
- open61850-0.1.1/pyproject.toml +44 -0
- open61850-0.1.1/setup.cfg +4 -0
- open61850-0.1.1/src/open61850/__init__.py +28 -0
- open61850-0.1.1/src/open61850/ber.py +273 -0
- open61850-0.1.1/src/open61850/capture.py +257 -0
- open61850-0.1.1/src/open61850/data.py +347 -0
- open61850-0.1.1/src/open61850/display.py +57 -0
- open61850-0.1.1/src/open61850/ethernet.py +140 -0
- open61850-0.1.1/src/open61850/goose.py +190 -0
- open61850-0.1.1/src/open61850/mms/__init__.py +46 -0
- open61850-0.1.1/src/open61850/mms/__main__.py +225 -0
- open61850-0.1.1/src/open61850/mms/association.py +330 -0
- open61850-0.1.1/src/open61850/mms/client.py +315 -0
- open61850-0.1.1/src/open61850/mms/control.py +374 -0
- open61850-0.1.1/src/open61850/mms/errors.py +90 -0
- open61850-0.1.1/src/open61850/mms/pdu.py +351 -0
- open61850-0.1.1/src/open61850/mms/rcb.py +276 -0
- open61850-0.1.1/src/open61850/mms/report.py +219 -0
- open61850-0.1.1/src/open61850/mms/transport.py +185 -0
- open61850-0.1.1/src/open61850/mms/types.py +154 -0
- open61850-0.1.1/src/open61850/py.typed +0 -0
- open61850-0.1.1/src/open61850/quality.py +87 -0
- open61850-0.1.1/src/open61850/scl.py +158 -0
- open61850-0.1.1/src/open61850/sv.py +240 -0
- open61850-0.1.1/src/open61850.egg-info/PKG-INFO +157 -0
- open61850-0.1.1/src/open61850.egg-info/SOURCES.txt +39 -0
- open61850-0.1.1/src/open61850.egg-info/dependency_links.txt +1 -0
- open61850-0.1.1/src/open61850.egg-info/entry_points.txt +2 -0
- open61850-0.1.1/src/open61850.egg-info/top_level.txt +1 -0
- open61850-0.1.1/tests/test_ber.py +98 -0
- open61850-0.1.1/tests/test_capture.py +117 -0
- open61850-0.1.1/tests/test_goose_sv.py +154 -0
- open61850-0.1.1/tests/test_mms.py +563 -0
- open61850-0.1.1/tests/test_mms_association.py +106 -0
- open61850-0.1.1/tests/test_mms_capture.py +76 -0
- open61850-0.1.1/tests/test_mms_control.py +205 -0
- open61850-0.1.1/tests/test_mms_types.py +116 -0
- open61850-0.1.1/tests/test_scl.py +42 -0
open61850-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
https://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Florent Carli
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
open61850-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: open61850
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: IEC 61850 in pure Python: MMS client, GOOSE, Sampled Values, SCL, BER.
|
|
5
|
+
Author: Florent Carli
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/insatomcat/open61850
|
|
8
|
+
Project-URL: Issues, https://github.com/insatomcat/open61850/issues
|
|
9
|
+
Keywords: iec61850,mms,goose,sampled-values,substation,scl
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering
|
|
16
|
+
Classifier: Topic :: System :: Networking
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# open61850
|
|
24
|
+
|
|
25
|
+
IEC 61850 in pure Python, under the Apache 2.0 licence: an MMS client (reports, report control blocks, controls), GOOSE and Sampled Values codecs, an SCL reader and a Linux capture for the process bus. Standard library only, Python 3.10 or later.
|
|
26
|
+
|
|
27
|
+
It was written for a test and diagnostic platform of a digital substation process bus, and checked there against real IEDs (a Schneider VMC7 and an ABB SSC600). The other open-source IEC 61850 stack, libiec61850, is GPL; open61850 is an alternative for projects that cannot take a GPL dependency.
|
|
28
|
+
|
|
29
|
+
**Status**: alpha. The client side is what exists and what has been tested; there is no server yet. Until 1.0, minor versions may change the API.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install open61850
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## What is in it
|
|
38
|
+
|
|
39
|
+
| Module | Content |
|
|
40
|
+
|--------|---------|
|
|
41
|
+
| `open61850.mms` | MMS client over TCP: association (Session, Presentation, ACSE, Initiate) with the negotiated limits honoured, reads and writes, GetNameList, type and data set descriptions, several requests in flight matched by invokeID, reports delivered to callbacks, typed errors |
|
|
42
|
+
| `open61850.mms.report` | IEC 61850 report decoding driven by the report's own OptFlds and inclusion bit string (segmentation, reason codes, data references) |
|
|
43
|
+
| `open61850.mms.rcb` | Report control blocks: status, free instance, reservation (edition 1 and 2 BRCBs, URCBs), enabling with checked writes, release |
|
|
44
|
+
| `open61850.mms.control` | Controls: direct and select-before-operate, normal and enhanced security (waits for the CommandTermination, reports the LastApplError AddCause) |
|
|
45
|
+
| `open61850.goose` | GOOSE PDUs and frames (IEC 61850-8-1) |
|
|
46
|
+
| `open61850.sv` | Sampled Values PDUs and frames (IEC 61850-9-2, IEC 61869-9), INT32 + quality samples |
|
|
47
|
+
| `open61850.ethernet` | Ethernet II and 802.1Q framing with the APPID header |
|
|
48
|
+
| `open61850.data` | MMS `Data` values and their BER encoding |
|
|
49
|
+
| `open61850.quality` | Quality and TimeQuality in readable form |
|
|
50
|
+
| `open61850.scl` | SCL files: IEDs, addresses, logical devices, report control blocks and data sets |
|
|
51
|
+
| `open61850.capture` | GOOSE and SV capture on Linux from an AF_PACKET TPACKET_V3 ring, kernel timestamps, 802.1Q tags restored, no libpcap |
|
|
52
|
+
| `open61850.ber` | ASN.1 BER primitives |
|
|
53
|
+
|
|
54
|
+
Only `open61850.mms` and `open61850.capture` do I/O. The public names of each module are those of its `__all__`.
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
|
|
58
|
+
Read a value and list the logical devices:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from open61850.mms import MmsClient, ObjectName, OBJECT_CLASS_DOMAIN
|
|
62
|
+
|
|
63
|
+
with MmsClient.connect("192.0.2.10") as client:
|
|
64
|
+
print(client.association.max_outstanding_calling) # requests the IED accepts at once
|
|
65
|
+
print(client.get_name_list(OBJECT_CLASS_DOMAIN))
|
|
66
|
+
print(client.read(ObjectName("LLN0$ST$Mod$stVal", "IED01_LD0")))
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Subscribe to a buffered report control block:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import queue
|
|
73
|
+
from open61850.mms import MmsClient, ObjectName, decode_report, is_report, rcb
|
|
74
|
+
|
|
75
|
+
reports = queue.Queue()
|
|
76
|
+
with MmsClient.connect("192.0.2.10", on_information_report=reports.put) as client:
|
|
77
|
+
instances = [ObjectName(f"LLN0$BR$CB_MEAS{i:02d}", "IED01_LD0") for i in range(1, 4)]
|
|
78
|
+
free = rcb.find_free(client, instances)
|
|
79
|
+
rcb.enable(client, free.rcb) # default RcbSettings: dchg, qchg, integrity, GI
|
|
80
|
+
try:
|
|
81
|
+
while True:
|
|
82
|
+
message = reports.get()
|
|
83
|
+
if is_report(message):
|
|
84
|
+
report = decode_report(message)
|
|
85
|
+
print(report.rpt_id, report.seq_num, [(e.index, e.value) for e in report.entries])
|
|
86
|
+
finally:
|
|
87
|
+
rcb.disable(client, free.rcb) # also releases the reservation
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Operate a breaker (the control model is read from the IED):
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from open61850.mms import MmsClient, ObjectName, operate
|
|
94
|
+
|
|
95
|
+
with MmsClient.connect("192.0.2.10") as client:
|
|
96
|
+
result = operate(client, ObjectName("CBCSWI1$CO$Pos", "IED01_BayLD"), False) # False = open
|
|
97
|
+
print(result) # control model, ctlNum, CommandTermination, duration
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
A refusal raises `ControlError` with the AddCause of the IED.
|
|
101
|
+
|
|
102
|
+
Decode GOOSE and SV frames captured on the process bus (Linux, root):
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from open61850 import goose, sv
|
|
106
|
+
from open61850.capture import PacketCapture
|
|
107
|
+
|
|
108
|
+
with PacketCapture("eth1") as cap:
|
|
109
|
+
while True:
|
|
110
|
+
frame = cap.recv()
|
|
111
|
+
if frame is None:
|
|
112
|
+
continue
|
|
113
|
+
if (decoded := goose.decode_goose_frame(frame.data)) is not None:
|
|
114
|
+
eth, pdu = decoded
|
|
115
|
+
print(frame.timestamp, pdu.gocb_ref, pdu.st_num, pdu.sq_num)
|
|
116
|
+
elif (decoded := sv.decode_sv_frame(frame.data)) is not None:
|
|
117
|
+
eth, pdu = decoded
|
|
118
|
+
print(frame.timestamp, [(a.sv_id, a.smp_cnt) for a in pdu.asdus])
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Command line
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
open61850-mms 192.0.2.10 association
|
|
125
|
+
open61850-mms 192.0.2.10 domains
|
|
126
|
+
open61850-mms 192.0.2.10 rcbs --status
|
|
127
|
+
open61850-mms 192.0.2.10 read 'IED01_LD0/LLN0$DC$NamPlt'
|
|
128
|
+
open61850-mms 192.0.2.10 dataset 'IED01_LD0/LLN0$DS_MEAS'
|
|
129
|
+
open61850-mms 192.0.2.10 subscribe 'IED01_LD0/LLN0$BR$CB_MEAS'
|
|
130
|
+
open61850-mms 192.0.2.10 operate 'IED01_BayLD/CBCSWI1$CO$Pos' open
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`subscribe` takes a block or a group name without its instance number, picks a free instance, prints the decoded reports and releases the block on Ctrl-C.
|
|
134
|
+
|
|
135
|
+
## Scope and limits
|
|
136
|
+
|
|
137
|
+
- Client side only: no MMS server, no GOOSE/SV publisher service (the codecs encode, sending frames is up to the application).
|
|
138
|
+
- Not implemented: file services, log control blocks and journals, setting groups, IEC 62351 security.
|
|
139
|
+
- The association proposes fixed calling/called AP titles and selectors by default (`AssociationParameters` changes them).
|
|
140
|
+
- Tested against two IED families so far; reports of other IEDs are welcome.
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python -m pip install pytest
|
|
146
|
+
python -m pytest
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The tests need no network. The AF_PACKET capture tests run on Linux as root (`sudo python -m pytest tests/test_capture.py`); on another OS, `docker run --rm --privileged -v "$PWD":/src -w /src python:3.13-slim sh -c "pip install pytest && python -m pytest"`.
|
|
150
|
+
|
|
151
|
+
Maintainer notes (what the IED captures taught, design decisions) are in [AGENTS.md](AGENTS.md).
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
Copyright 2026 Florent Carli
|
|
156
|
+
|
|
157
|
+
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full text.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# open61850
|
|
2
|
+
|
|
3
|
+
IEC 61850 in pure Python, under the Apache 2.0 licence: an MMS client (reports, report control blocks, controls), GOOSE and Sampled Values codecs, an SCL reader and a Linux capture for the process bus. Standard library only, Python 3.10 or later.
|
|
4
|
+
|
|
5
|
+
It was written for a test and diagnostic platform of a digital substation process bus, and checked there against real IEDs (a Schneider VMC7 and an ABB SSC600). The other open-source IEC 61850 stack, libiec61850, is GPL; open61850 is an alternative for projects that cannot take a GPL dependency.
|
|
6
|
+
|
|
7
|
+
**Status**: alpha. The client side is what exists and what has been tested; there is no server yet. Until 1.0, minor versions may change the API.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install open61850
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What is in it
|
|
16
|
+
|
|
17
|
+
| Module | Content |
|
|
18
|
+
|--------|---------|
|
|
19
|
+
| `open61850.mms` | MMS client over TCP: association (Session, Presentation, ACSE, Initiate) with the negotiated limits honoured, reads and writes, GetNameList, type and data set descriptions, several requests in flight matched by invokeID, reports delivered to callbacks, typed errors |
|
|
20
|
+
| `open61850.mms.report` | IEC 61850 report decoding driven by the report's own OptFlds and inclusion bit string (segmentation, reason codes, data references) |
|
|
21
|
+
| `open61850.mms.rcb` | Report control blocks: status, free instance, reservation (edition 1 and 2 BRCBs, URCBs), enabling with checked writes, release |
|
|
22
|
+
| `open61850.mms.control` | Controls: direct and select-before-operate, normal and enhanced security (waits for the CommandTermination, reports the LastApplError AddCause) |
|
|
23
|
+
| `open61850.goose` | GOOSE PDUs and frames (IEC 61850-8-1) |
|
|
24
|
+
| `open61850.sv` | Sampled Values PDUs and frames (IEC 61850-9-2, IEC 61869-9), INT32 + quality samples |
|
|
25
|
+
| `open61850.ethernet` | Ethernet II and 802.1Q framing with the APPID header |
|
|
26
|
+
| `open61850.data` | MMS `Data` values and their BER encoding |
|
|
27
|
+
| `open61850.quality` | Quality and TimeQuality in readable form |
|
|
28
|
+
| `open61850.scl` | SCL files: IEDs, addresses, logical devices, report control blocks and data sets |
|
|
29
|
+
| `open61850.capture` | GOOSE and SV capture on Linux from an AF_PACKET TPACKET_V3 ring, kernel timestamps, 802.1Q tags restored, no libpcap |
|
|
30
|
+
| `open61850.ber` | ASN.1 BER primitives |
|
|
31
|
+
|
|
32
|
+
Only `open61850.mms` and `open61850.capture` do I/O. The public names of each module are those of its `__all__`.
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
Read a value and list the logical devices:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from open61850.mms import MmsClient, ObjectName, OBJECT_CLASS_DOMAIN
|
|
40
|
+
|
|
41
|
+
with MmsClient.connect("192.0.2.10") as client:
|
|
42
|
+
print(client.association.max_outstanding_calling) # requests the IED accepts at once
|
|
43
|
+
print(client.get_name_list(OBJECT_CLASS_DOMAIN))
|
|
44
|
+
print(client.read(ObjectName("LLN0$ST$Mod$stVal", "IED01_LD0")))
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Subscribe to a buffered report control block:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import queue
|
|
51
|
+
from open61850.mms import MmsClient, ObjectName, decode_report, is_report, rcb
|
|
52
|
+
|
|
53
|
+
reports = queue.Queue()
|
|
54
|
+
with MmsClient.connect("192.0.2.10", on_information_report=reports.put) as client:
|
|
55
|
+
instances = [ObjectName(f"LLN0$BR$CB_MEAS{i:02d}", "IED01_LD0") for i in range(1, 4)]
|
|
56
|
+
free = rcb.find_free(client, instances)
|
|
57
|
+
rcb.enable(client, free.rcb) # default RcbSettings: dchg, qchg, integrity, GI
|
|
58
|
+
try:
|
|
59
|
+
while True:
|
|
60
|
+
message = reports.get()
|
|
61
|
+
if is_report(message):
|
|
62
|
+
report = decode_report(message)
|
|
63
|
+
print(report.rpt_id, report.seq_num, [(e.index, e.value) for e in report.entries])
|
|
64
|
+
finally:
|
|
65
|
+
rcb.disable(client, free.rcb) # also releases the reservation
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Operate a breaker (the control model is read from the IED):
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from open61850.mms import MmsClient, ObjectName, operate
|
|
72
|
+
|
|
73
|
+
with MmsClient.connect("192.0.2.10") as client:
|
|
74
|
+
result = operate(client, ObjectName("CBCSWI1$CO$Pos", "IED01_BayLD"), False) # False = open
|
|
75
|
+
print(result) # control model, ctlNum, CommandTermination, duration
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
A refusal raises `ControlError` with the AddCause of the IED.
|
|
79
|
+
|
|
80
|
+
Decode GOOSE and SV frames captured on the process bus (Linux, root):
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from open61850 import goose, sv
|
|
84
|
+
from open61850.capture import PacketCapture
|
|
85
|
+
|
|
86
|
+
with PacketCapture("eth1") as cap:
|
|
87
|
+
while True:
|
|
88
|
+
frame = cap.recv()
|
|
89
|
+
if frame is None:
|
|
90
|
+
continue
|
|
91
|
+
if (decoded := goose.decode_goose_frame(frame.data)) is not None:
|
|
92
|
+
eth, pdu = decoded
|
|
93
|
+
print(frame.timestamp, pdu.gocb_ref, pdu.st_num, pdu.sq_num)
|
|
94
|
+
elif (decoded := sv.decode_sv_frame(frame.data)) is not None:
|
|
95
|
+
eth, pdu = decoded
|
|
96
|
+
print(frame.timestamp, [(a.sv_id, a.smp_cnt) for a in pdu.asdus])
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Command line
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
open61850-mms 192.0.2.10 association
|
|
103
|
+
open61850-mms 192.0.2.10 domains
|
|
104
|
+
open61850-mms 192.0.2.10 rcbs --status
|
|
105
|
+
open61850-mms 192.0.2.10 read 'IED01_LD0/LLN0$DC$NamPlt'
|
|
106
|
+
open61850-mms 192.0.2.10 dataset 'IED01_LD0/LLN0$DS_MEAS'
|
|
107
|
+
open61850-mms 192.0.2.10 subscribe 'IED01_LD0/LLN0$BR$CB_MEAS'
|
|
108
|
+
open61850-mms 192.0.2.10 operate 'IED01_BayLD/CBCSWI1$CO$Pos' open
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`subscribe` takes a block or a group name without its instance number, picks a free instance, prints the decoded reports and releases the block on Ctrl-C.
|
|
112
|
+
|
|
113
|
+
## Scope and limits
|
|
114
|
+
|
|
115
|
+
- Client side only: no MMS server, no GOOSE/SV publisher service (the codecs encode, sending frames is up to the application).
|
|
116
|
+
- Not implemented: file services, log control blocks and journals, setting groups, IEC 62351 security.
|
|
117
|
+
- The association proposes fixed calling/called AP titles and selectors by default (`AssociationParameters` changes them).
|
|
118
|
+
- Tested against two IED families so far; reports of other IEDs are welcome.
|
|
119
|
+
|
|
120
|
+
## Development
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
python -m pip install pytest
|
|
124
|
+
python -m pytest
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The tests need no network. The AF_PACKET capture tests run on Linux as root (`sudo python -m pytest tests/test_capture.py`); on another OS, `docker run --rm --privileged -v "$PWD":/src -w /src python:3.13-slim sh -c "pip install pytest && python -m pytest"`.
|
|
128
|
+
|
|
129
|
+
Maintainer notes (what the IED captures taught, design decisions) are in [AGENTS.md](AGENTS.md).
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
Copyright 2026 Florent Carli
|
|
134
|
+
|
|
135
|
+
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full text.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Copyright 2026 Florent Carli
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
[build-system]
|
|
5
|
+
requires = ["setuptools>=77"]
|
|
6
|
+
build-backend = "setuptools.build_meta"
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "open61850"
|
|
10
|
+
dynamic = ["version"]
|
|
11
|
+
description = "IEC 61850 in pure Python: MMS client, GOOSE, Sampled Values, SCL, BER."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
license = "Apache-2.0"
|
|
15
|
+
license-files = ["LICENSE"]
|
|
16
|
+
authors = [{ name = "Florent Carli" }]
|
|
17
|
+
keywords = ["iec61850", "mms", "goose", "sampled-values", "substation", "scl"]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 3 - Alpha",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
24
|
+
"Topic :: Scientific/Engineering",
|
|
25
|
+
"Topic :: System :: Networking",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Repository = "https://github.com/insatomcat/open61850"
|
|
31
|
+
Issues = "https://github.com/insatomcat/open61850/issues"
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
open61850-mms = "open61850.mms.__main__:main"
|
|
35
|
+
|
|
36
|
+
[tool.setuptools.dynamic]
|
|
37
|
+
version = { attr = "open61850.__version__" }
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.package-data]
|
|
40
|
+
open61850 = ["py.typed"]
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
testpaths = ["tests"]
|
|
44
|
+
addopts = "-ra"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright 2026 Florent Carli
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
"""IEC 61850 in pure Python (Apache-2.0), standard library only.
|
|
5
|
+
|
|
6
|
+
Codecs, with no I/O:
|
|
7
|
+
|
|
8
|
+
- :mod:`open61850.ber`: BER (X.690) primitives.
|
|
9
|
+
- :mod:`open61850.data`: the MMS ``Data`` values shared by MMS, GOOSE and reports.
|
|
10
|
+
- :mod:`open61850.quality`: Quality and TimeQuality in readable form.
|
|
11
|
+
- :mod:`open61850.display`: readable text for MMS values.
|
|
12
|
+
- :mod:`open61850.ethernet`: Ethernet II / 802.1Q framing for GOOSE and SV.
|
|
13
|
+
- :mod:`open61850.goose`: GOOSE PDUs and frames (IEC 61850-8-1).
|
|
14
|
+
- :mod:`open61850.sv`: Sampled Values PDUs and frames (IEC 61850-9-2, IEC 61869-9).
|
|
15
|
+
- :mod:`open61850.scl`: SCL files (IEDs, logical devices, data sets, report control blocks).
|
|
16
|
+
|
|
17
|
+
With I/O:
|
|
18
|
+
|
|
19
|
+
- :mod:`open61850.mms`: MMS client over TCP (association, reads, writes,
|
|
20
|
+
reports, report control blocks, controls).
|
|
21
|
+
- :mod:`open61850.capture`: GOOSE and SV capture on Linux (AF_PACKET ring).
|
|
22
|
+
|
|
23
|
+
The names listed in each module's ``__all__`` (or, for :mod:`open61850.mms`,
|
|
24
|
+
exported by the package) are the public API; anything with a leading
|
|
25
|
+
underscore is internal. Until 1.0, minor versions may change the API.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
__version__ = "0.1.1"
|