profinet-py 0.4.0__py3-none-any.whl

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.
profinet/__init__.py ADDED
@@ -0,0 +1,489 @@
1
+ """
2
+ PROFINET IO-Controller Library
3
+
4
+ A Python library for PROFINET IO communication, supporting:
5
+ - DCP (Discovery and Configuration Protocol) for device discovery
6
+ - DCE/RPC for acyclic parameter read/write operations
7
+ - IM0/IM1 device identification data access
8
+
9
+ This library acts as an IO-Controller, allowing connection to and
10
+ communication with PROFINET IO-Devices.
11
+
12
+ Credits:
13
+ Original implementation by Alfred Krohmer (2015)
14
+ https://github.com/alfredkrohmer/profinet
15
+
16
+ Modernized for Python 3.8+ by f0rw4rd (2024)
17
+ https://github.com/f0rw4rd/profinet-py
18
+ """
19
+
20
+ from . import blocks, indices
21
+ from .alarm_listener import (
22
+ AlarmEndpoint,
23
+ AlarmListener,
24
+ )
25
+ from .alarms import (
26
+ # Alarm item types
27
+ AlarmItem,
28
+ # Alarm notification
29
+ AlarmNotification,
30
+ DiagnosisItem,
31
+ MaintenanceItem,
32
+ PE_AlarmItem,
33
+ PRAL_AlarmItem,
34
+ RS_AlarmItem,
35
+ UploadRetrievalItem,
36
+ iParameterItem,
37
+ parse_alarm_item,
38
+ # Parsing functions
39
+ parse_alarm_notification,
40
+ )
41
+ from .blocks import (
42
+ # Data classes for block parsing
43
+ BlockHeader,
44
+ ExpectedSubmodule,
45
+ ExpectedSubmoduleAPI,
46
+ # ExpectedSubmodule
47
+ ExpectedSubmoduleBlockReq,
48
+ ExpectedSubmoduleDataDescription,
49
+ IODWriteMultipleBuilder,
50
+ # ModuleDiff
51
+ ModuleDiffBlock,
52
+ ModuleDiffModule,
53
+ ModuleDiffSubmodule,
54
+ PDRealData,
55
+ PeerInfo,
56
+ RealIdentificationData,
57
+ SlotInfo,
58
+ # WriteMultiple
59
+ WriteMultipleResult,
60
+ # Parsing functions
61
+ parse_block_header,
62
+ parse_module_diff_block,
63
+ parse_multiple_block_header,
64
+ parse_pd_interface_data_real,
65
+ parse_pd_port_data_real,
66
+ parse_pd_real_data,
67
+ parse_port_statistics,
68
+ parse_real_identification_data,
69
+ parse_write_multiple_response,
70
+ )
71
+ from .cyclic import (
72
+ CyclicController,
73
+ CyclicStats,
74
+ )
75
+ from .dcp import (
76
+ DCP_GET_SET_FRAME_ID,
77
+ DCP_HELLO_FRAME_ID,
78
+ # Frame IDs
79
+ DCP_IDENTIFY_FRAME_ID,
80
+ # Options
81
+ DCP_MAX_NAME_LENGTH,
82
+ DCP_OPTION_ALL,
83
+ DCP_OPTION_CONTROL,
84
+ DCP_OPTION_DEVICE,
85
+ DCP_OPTION_DEVICE_INITIATIVE,
86
+ DCP_OPTION_DHCP,
87
+ DCP_OPTION_IP,
88
+ DCP_OPTION_LLDP,
89
+ DCP_OPTION_MANUF_MAX,
90
+ # Manufacturer options
91
+ DCP_OPTION_MANUF_MIN,
92
+ DCP_OPTION_NME,
93
+ # Service IDs
94
+ DCP_SERVICE_ID_GET,
95
+ DCP_SERVICE_ID_HELLO,
96
+ DCP_SERVICE_ID_IDENTIFY,
97
+ DCP_SERVICE_ID_SET,
98
+ # Service Types
99
+ DCP_SERVICE_TYPE_REQUEST,
100
+ DCP_SERVICE_TYPE_RESPONSE_SUCCESS,
101
+ DCP_SERVICE_TYPE_RESPONSE_UNSUPPORTED,
102
+ # Device Initiative suboption
103
+ DCP_SUBOPTION_DEVICE_INITIATIVE,
104
+ DCP_SUBOPTION_DHCP_CLASS_ID,
105
+ DCP_SUBOPTION_DHCP_CLIENT_ID,
106
+ DCP_SUBOPTION_DHCP_CONTROL,
107
+ DCP_SUBOPTION_DHCP_FQDN,
108
+ # DHCP suboptions
109
+ DCP_SUBOPTION_DHCP_HOSTNAME,
110
+ DCP_SUBOPTION_DHCP_PARAM_REQ,
111
+ DCP_SUBOPTION_DHCP_SERVER_ID,
112
+ DCP_SUBOPTION_DHCP_UUID,
113
+ DCP_SUBOPTION_DHCP_VENDOR_SPEC,
114
+ DCP_SUBOPTION_LLDP_CHASSIS_ID,
115
+ DCP_SUBOPTION_LLDP_MGMT_ADDR,
116
+ DCP_SUBOPTION_LLDP_PORT_DESC,
117
+ # LLDP suboptions
118
+ DCP_SUBOPTION_LLDP_PORT_ID,
119
+ DCP_SUBOPTION_LLDP_SYSTEM_CAP,
120
+ DCP_SUBOPTION_LLDP_SYSTEM_DESC,
121
+ DCP_SUBOPTION_LLDP_SYSTEM_NAME,
122
+ DCP_SUBOPTION_LLDP_TTL,
123
+ RESET_MODE_ALL_DATA,
124
+ RESET_MODE_APPLICATION,
125
+ # Legacy reset modes
126
+ RESET_MODE_COMMUNICATION,
127
+ RESET_MODE_DEVICE,
128
+ RESET_MODE_ENGINEERING,
129
+ RESET_MODE_FACTORY,
130
+ BlockQualifier,
131
+ # Classes
132
+ DCPDeviceDescription,
133
+ DCPDHCPBlock,
134
+ DCPLLDPBlock,
135
+ DCPResponseCode,
136
+ DeviceInitiative,
137
+ IPBlockInfo,
138
+ ResetQualifier,
139
+ get_param,
140
+ read_response,
141
+ receive_hello,
142
+ reset_to_factory,
143
+ # Functions
144
+ send_discover,
145
+ send_hello,
146
+ send_request,
147
+ set_ip,
148
+ set_param,
149
+ signal_device,
150
+ )
151
+ from .device import (
152
+ DeviceInfo,
153
+ ProfinetDevice,
154
+ WriteItem,
155
+ scan,
156
+ scan_dict,
157
+ )
158
+ from .diagnosis import (
159
+ # Constants
160
+ CHANNEL_ERROR_TYPES,
161
+ EXT_CHANNEL_ERROR_TYPES_MAP,
162
+ ChannelAccumulative,
163
+ ChannelDiagnosis,
164
+ ChannelDirection,
165
+ ChannelProperties,
166
+ ChannelSpecifier,
167
+ ChannelType,
168
+ # Diagnosis data classes
169
+ DiagnosisData,
170
+ ExtChannelDiagnosis,
171
+ QualifiedChannelDiagnosis,
172
+ # Enums
173
+ UserStructureIdentifier,
174
+ decode_channel_error_type,
175
+ decode_ext_channel_error_type,
176
+ # Parsing functions
177
+ parse_diagnosis_block,
178
+ parse_diagnosis_simple,
179
+ )
180
+ from .exceptions import (
181
+ DCPDeviceNotFoundError,
182
+ DCPError,
183
+ DCPTimeoutError,
184
+ InvalidIPError,
185
+ InvalidMACError,
186
+ PermissionDeniedError,
187
+ PNIOError,
188
+ ProfinetError,
189
+ RPCConnectionError,
190
+ RPCError,
191
+ RPCFaultError,
192
+ RPCTimeoutError,
193
+ SocketError,
194
+ ValidationError,
195
+ )
196
+ from .protocol import (
197
+ EthernetHeader,
198
+ EthernetVLANHeader,
199
+ IPConfiguration,
200
+ PNARBlockRequest,
201
+ PNBlockHeader,
202
+ PNDCPBlock,
203
+ PNDCPBlockRequest,
204
+ PNDCPHeader,
205
+ PNInM0,
206
+ PNInM1,
207
+ PNInM2,
208
+ PNInM3,
209
+ PNInM4,
210
+ PNInM5,
211
+ PNIODHeader,
212
+ PNIODReleaseBlock,
213
+ PNNRDData,
214
+ PNRPCHeader,
215
+ )
216
+ from .rpc import (
217
+ MAU_TYPES,
218
+ PNIO_DEVICE_INTERFACE_VERSION,
219
+ # Python timing constants
220
+ PYTHON_MIN_CYCLE_TIME_MS,
221
+ PYTHON_SAFE_CYCLE_TIME_MS,
222
+ RPC_BIND_PORT,
223
+ # RPC Constants
224
+ RPC_PORT,
225
+ UUID_EPM_V4,
226
+ UUID_NULL,
227
+ UUID_PNIO_CONTROLLER,
228
+ UUID_PNIO_DEVICE,
229
+ ARInfo,
230
+ ConnectResult,
231
+ DiagnosisEntry,
232
+ EPMEndpoint,
233
+ InterfaceInfo,
234
+ IOCRSetup,
235
+ # IOCR setup classes
236
+ IOSlot,
237
+ LinkData,
238
+ LogEntry,
239
+ PortInfo,
240
+ # Data classes
241
+ PortStatistics,
242
+ RPCCon,
243
+ epm_lookup,
244
+ get_station_info,
245
+ )
246
+ from .rt import (
247
+ IOCR_TYPE_INPUT,
248
+ IOCR_TYPE_OUTPUT,
249
+ IOXS_BAD,
250
+ IOXS_GOOD,
251
+ RT_CLASS_1,
252
+ CyclicDataBuilder,
253
+ IOCRConfig,
254
+ IODataObject,
255
+ RTFrame,
256
+ )
257
+ from .util import (
258
+ ethernet_socket,
259
+ get_mac,
260
+ ip2s,
261
+ mac2s,
262
+ s2ip,
263
+ s2mac,
264
+ to_hex,
265
+ udp_socket,
266
+ )
267
+ from .vendors import (
268
+ get_vendor_name,
269
+ lookup_vendor,
270
+ profinet_vendor_map,
271
+ )
272
+
273
+ __version__ = "0.3.0"
274
+ __all__ = [
275
+ # Protocol structures
276
+ "EthernetHeader",
277
+ "EthernetVLANHeader",
278
+ "PNDCPHeader",
279
+ "PNDCPBlock",
280
+ "PNDCPBlockRequest",
281
+ "IPConfiguration",
282
+ "PNRPCHeader",
283
+ "PNNRDData",
284
+ "PNIODHeader",
285
+ "PNBlockHeader",
286
+ "PNARBlockRequest",
287
+ "PNIODReleaseBlock",
288
+ "PNInM0",
289
+ "PNInM1",
290
+ "PNInM2",
291
+ "PNInM3",
292
+ "PNInM4",
293
+ "PNInM5",
294
+ # DCP classes
295
+ "DCPDeviceDescription",
296
+ "DCPResponseCode",
297
+ "DCPDHCPBlock",
298
+ "DCPLLDPBlock",
299
+ "IPBlockInfo",
300
+ "BlockQualifier",
301
+ "ResetQualifier",
302
+ "DeviceInitiative",
303
+ # DCP functions
304
+ "send_discover",
305
+ "send_request",
306
+ "read_response",
307
+ "send_hello",
308
+ "receive_hello",
309
+ "get_param",
310
+ "set_param",
311
+ "set_ip",
312
+ "signal_device",
313
+ "reset_to_factory",
314
+ # DCP Frame IDs
315
+ "DCP_IDENTIFY_FRAME_ID",
316
+ "DCP_GET_SET_FRAME_ID",
317
+ "DCP_HELLO_FRAME_ID",
318
+ # DCP Service IDs
319
+ "DCP_SERVICE_ID_GET",
320
+ "DCP_SERVICE_ID_SET",
321
+ "DCP_SERVICE_ID_IDENTIFY",
322
+ "DCP_SERVICE_ID_HELLO",
323
+ # DCP Service Types
324
+ "DCP_SERVICE_TYPE_REQUEST",
325
+ "DCP_SERVICE_TYPE_RESPONSE_SUCCESS",
326
+ "DCP_SERVICE_TYPE_RESPONSE_UNSUPPORTED",
327
+ # DCP Options
328
+ "DCP_MAX_NAME_LENGTH",
329
+ "DCP_OPTION_IP",
330
+ "DCP_OPTION_DEVICE",
331
+ "DCP_OPTION_DHCP",
332
+ "DCP_OPTION_LLDP",
333
+ "DCP_OPTION_CONTROL",
334
+ "DCP_OPTION_DEVICE_INITIATIVE",
335
+ "DCP_OPTION_NME",
336
+ "DCP_OPTION_ALL",
337
+ "DCP_OPTION_MANUF_MIN",
338
+ "DCP_OPTION_MANUF_MAX",
339
+ # DCP DHCP suboptions
340
+ "DCP_SUBOPTION_DHCP_HOSTNAME",
341
+ "DCP_SUBOPTION_DHCP_VENDOR_SPEC",
342
+ "DCP_SUBOPTION_DHCP_SERVER_ID",
343
+ "DCP_SUBOPTION_DHCP_PARAM_REQ",
344
+ "DCP_SUBOPTION_DHCP_CLASS_ID",
345
+ "DCP_SUBOPTION_DHCP_CLIENT_ID",
346
+ "DCP_SUBOPTION_DHCP_FQDN",
347
+ "DCP_SUBOPTION_DHCP_UUID",
348
+ "DCP_SUBOPTION_DHCP_CONTROL",
349
+ # DCP LLDP suboptions
350
+ "DCP_SUBOPTION_LLDP_PORT_ID",
351
+ "DCP_SUBOPTION_LLDP_CHASSIS_ID",
352
+ "DCP_SUBOPTION_LLDP_TTL",
353
+ "DCP_SUBOPTION_LLDP_PORT_DESC",
354
+ "DCP_SUBOPTION_LLDP_SYSTEM_NAME",
355
+ "DCP_SUBOPTION_LLDP_SYSTEM_DESC",
356
+ "DCP_SUBOPTION_LLDP_SYSTEM_CAP",
357
+ "DCP_SUBOPTION_LLDP_MGMT_ADDR",
358
+ # DCP DeviceInitiative suboption
359
+ "DCP_SUBOPTION_DEVICE_INITIATIVE",
360
+ # Reset modes (legacy)
361
+ "RESET_MODE_COMMUNICATION",
362
+ "RESET_MODE_APPLICATION",
363
+ "RESET_MODE_ENGINEERING",
364
+ "RESET_MODE_ALL_DATA",
365
+ "RESET_MODE_DEVICE",
366
+ "RESET_MODE_FACTORY",
367
+ # RPC
368
+ "RPCCon",
369
+ "get_station_info",
370
+ "epm_lookup",
371
+ "EPMEndpoint",
372
+ # IOCR setup classes
373
+ "IOSlot",
374
+ "IOCRSetup",
375
+ "ConnectResult",
376
+ # Python timing constants
377
+ "PYTHON_MIN_CYCLE_TIME_MS",
378
+ "PYTHON_SAFE_CYCLE_TIME_MS",
379
+ # RPC constants
380
+ "RPC_PORT",
381
+ "RPC_BIND_PORT",
382
+ "UUID_NULL",
383
+ "UUID_EPM_V4",
384
+ "UUID_PNIO_DEVICE",
385
+ "UUID_PNIO_CONTROLLER",
386
+ "PNIO_DEVICE_INTERFACE_VERSION",
387
+ # Utilities
388
+ "ethernet_socket",
389
+ "udp_socket",
390
+ "get_mac",
391
+ "s2mac",
392
+ "mac2s",
393
+ "s2ip",
394
+ "ip2s",
395
+ "to_hex",
396
+ # Vendor lookup
397
+ "profinet_vendor_map",
398
+ "get_vendor_name",
399
+ "lookup_vendor",
400
+ # Diagnosis
401
+ "DiagnosisData",
402
+ "ChannelDiagnosis",
403
+ "ExtChannelDiagnosis",
404
+ "QualifiedChannelDiagnosis",
405
+ "ChannelProperties",
406
+ "UserStructureIdentifier",
407
+ "ChannelType",
408
+ "ChannelDirection",
409
+ "ChannelAccumulative",
410
+ "ChannelSpecifier",
411
+ "parse_diagnosis_block",
412
+ "parse_diagnosis_simple",
413
+ "decode_channel_error_type",
414
+ "decode_ext_channel_error_type",
415
+ "CHANNEL_ERROR_TYPES",
416
+ "EXT_CHANNEL_ERROR_TYPES_MAP",
417
+ # Blocks module
418
+ "BlockHeader",
419
+ "SlotInfo",
420
+ "PeerInfo",
421
+ "PDRealData",
422
+ "RealIdentificationData",
423
+ "ModuleDiffBlock",
424
+ "ModuleDiffModule",
425
+ "ModuleDiffSubmodule",
426
+ "WriteMultipleResult",
427
+ "IODWriteMultipleBuilder",
428
+ "ExpectedSubmoduleBlockReq",
429
+ "ExpectedSubmoduleAPI",
430
+ "ExpectedSubmodule",
431
+ "ExpectedSubmoduleDataDescription",
432
+ "parse_block_header",
433
+ "parse_multiple_block_header",
434
+ "parse_pd_interface_data_real",
435
+ "parse_pd_port_data_real",
436
+ "parse_pd_real_data",
437
+ "parse_real_identification_data",
438
+ "parse_port_statistics",
439
+ "parse_module_diff_block",
440
+ "parse_write_multiple_response",
441
+ # Alarms module
442
+ "AlarmItem",
443
+ "DiagnosisItem",
444
+ "MaintenanceItem",
445
+ "UploadRetrievalItem",
446
+ "iParameterItem",
447
+ "PE_AlarmItem",
448
+ "RS_AlarmItem",
449
+ "PRAL_AlarmItem",
450
+ "AlarmNotification",
451
+ "parse_alarm_notification",
452
+ "parse_alarm_item",
453
+ # Alarm listener
454
+ "AlarmListener",
455
+ "AlarmEndpoint",
456
+ # Real-time (cyclic IO)
457
+ "RTFrame",
458
+ "IOCRConfig",
459
+ "IODataObject",
460
+ "CyclicDataBuilder",
461
+ "CyclicController",
462
+ "CyclicStats",
463
+ "IOCR_TYPE_INPUT",
464
+ "IOCR_TYPE_OUTPUT",
465
+ "RT_CLASS_1",
466
+ "IOXS_GOOD",
467
+ "IOXS_BAD",
468
+ # Device module (high-level API)
469
+ "ProfinetDevice",
470
+ "DeviceInfo",
471
+ "WriteItem",
472
+ "scan",
473
+ "scan_dict",
474
+ # Exceptions
475
+ "ProfinetError",
476
+ "DCPError",
477
+ "DCPTimeoutError",
478
+ "DCPDeviceNotFoundError",
479
+ "RPCError",
480
+ "RPCTimeoutError",
481
+ "RPCFaultError",
482
+ "RPCConnectionError",
483
+ "PNIOError",
484
+ "ValidationError",
485
+ "InvalidMACError",
486
+ "InvalidIPError",
487
+ "SocketError",
488
+ "PermissionDeniedError",
489
+ ]