Skip to content

Instantly share code, notes, and snippets.

@Bouni
Last active May 3, 2023 10:34
Show Gist options
  • Save Bouni/66090be5b4f883903ca41ee9b3029c6d to your computer and use it in GitHub Desktop.
Save Bouni/66090be5b4f883903ca41ee9b3029c6d to your computer and use it in GitHub Desktop.
Beckhoff EP23XX PDOs
======================================EP2308======================================
====================================Input PDOs====================================
1 Name: Input Index: 0x6000 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Input Index: 0x6010 SubIndex: 1 BitLength: 1 Datatype: BOOL
3 Name: Input Index: 0x6020 SubIndex: 1 BitLength: 1 Datatype: BOOL
4 Name: Input Index: 0x6030 SubIndex: 1 BitLength: 1 Datatype: BOOL
===================================Output PDOs====================================
1 Name: Output Index: 0x7040 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Output Index: 0x7050 SubIndex: 1 BitLength: 1 Datatype: BOOL
3 Name: Output Index: 0x7060 SubIndex: 1 BitLength: 1 Datatype: BOOL
4 Name: Output Index: 0x7070 SubIndex: 1 BitLength: 1 Datatype: BOOL
==================================================================================
======================================EP2316======================================
====================================Input PDOs====================================
1 Name: Input 1 Index: 0x6000 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Input 2 Index: 0x6000 SubIndex: 2 BitLength: 1 Datatype: BOOL
3 Name: Input 3 Index: 0x6000 SubIndex: 3 BitLength: 1 Datatype: BOOL
4 Name: Input 4 Index: 0x6000 SubIndex: 4 BitLength: 1 Datatype: BOOL
5 Name: Input 5 Index: 0x6000 SubIndex: 5 BitLength: 1 Datatype: BOOL
6 Name: Input 6 Index: 0x6000 SubIndex: 6 BitLength: 1 Datatype: BOOL
7 Name: Input 7 Index: 0x6000 SubIndex: 7 BitLength: 1 Datatype: BOOL
8 Name: Input 8 Index: 0x6000 SubIndex: 8 BitLength: 1 Datatype: BOOL
9 Name: Sync Error Index: 0x1c32 SubIndex: 32 BitLength: 1 Datatype: BOOL
10 Name: Diag Input 1 Index: 0x6001 SubIndex: 1 BitLength: 1 Datatype: BOOL
11 Name: Diag Input 2 Index: 0x6001 SubIndex: 2 BitLength: 1 Datatype: BOOL
12 Name: Diag Input 3 Index: 0x6001 SubIndex: 3 BitLength: 1 Datatype: BOOL
13 Name: Diag Input 4 Index: 0x6001 SubIndex: 4 BitLength: 1 Datatype: BOOL
14 Name: Diag Input 5 Index: 0x6001 SubIndex: 5 BitLength: 1 Datatype: BOOL
15 Name: Diag Input 6 Index: 0x6001 SubIndex: 6 BitLength: 1 Datatype: BOOL
16 Name: Diag Input 7 Index: 0x6001 SubIndex: 7 BitLength: 1 Datatype: BOOL
17 Name: Diag Input 8 Index: 0x6001 SubIndex: 8 BitLength: 1 Datatype: BOOL
18 Name: Safe state active Index: 0xf600 SubIndex: 1 BitLength: 1 Datatype: BOOL
19 Name: Error channel 1 Index: 0xf600 SubIndex: 2 BitLength: 1 Datatype: BOOL
20 Name: Error channel 2 Index: 0xf600 SubIndex: 3 BitLength: 1 Datatype: BOOL
21 Name: Sync error Index: 0x1c32 SubIndex: 32 BitLength: 1 Datatype: BOOL
22 Name: TxPDO Toggle Index: 0x1800 SubIndex: 9 BitLength: 1 Datatype: BOOL
===================================Output PDOs====================================
1 Name: Output 1 Index: 0x7000 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Output 2 Index: 0x7000 SubIndex: 2 BitLength: 1 Datatype: BOOL
3 Name: Output 3 Index: 0x7000 SubIndex: 3 BitLength: 1 Datatype: BOOL
4 Name: Output 4 Index: 0x7000 SubIndex: 4 BitLength: 1 Datatype: BOOL
5 Name: Output 5 Index: 0x7000 SubIndex: 5 BitLength: 1 Datatype: BOOL
6 Name: Output 6 Index: 0x7000 SubIndex: 6 BitLength: 1 Datatype: BOOL
7 Name: Output 7 Index: 0x7000 SubIndex: 7 BitLength: 1 Datatype: BOOL
8 Name: Output 8 Index: 0x7000 SubIndex: 8 BitLength: 1 Datatype: BOOL
9 Name: Set safe state Index: 0xf700 SubIndex: 1 BitLength: 1 Datatype: BOOL
10 Name: Reset outputs Index: 0xf700 SubIndex: 2 BitLength: 1 Datatype: BOOL
==================================================================================
======================================EP2318======================================
====================================Input PDOs====================================
1 Name: Input Index: 0x6000 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Input Index: 0x6010 SubIndex: 1 BitLength: 1 Datatype: BOOL
3 Name: Input Index: 0x6020 SubIndex: 1 BitLength: 1 Datatype: BOOL
4 Name: Input Index: 0x6030 SubIndex: 1 BitLength: 1 Datatype: BOOL
===================================Output PDOs====================================
1 Name: Output Index: 0x7040 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Output Index: 0x7050 SubIndex: 1 BitLength: 1 Datatype: BOOL
3 Name: Output Index: 0x7060 SubIndex: 1 BitLength: 1 Datatype: BOOL
4 Name: Output Index: 0x7070 SubIndex: 1 BitLength: 1 Datatype: BOOL
==================================================================================
======================================EP2328======================================
====================================Input PDOs====================================
1 Name: Input Index: 0x6000 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Input Index: 0x6010 SubIndex: 1 BitLength: 1 Datatype: BOOL
3 Name: Input Index: 0x6020 SubIndex: 1 BitLength: 1 Datatype: BOOL
4 Name: Input Index: 0x6030 SubIndex: 1 BitLength: 1 Datatype: BOOL
===================================Output PDOs====================================
1 Name: Output Index: 0x7040 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Output Index: 0x7050 SubIndex: 1 BitLength: 1 Datatype: BOOL
3 Name: Output Index: 0x7060 SubIndex: 1 BitLength: 1 Datatype: BOOL
4 Name: Output Index: 0x7070 SubIndex: 1 BitLength: 1 Datatype: BOOL
==================================================================================
======================================EP2338======================================
====================================Input PDOs====================================
1 Name: Input Index: 0x6000 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Input Index: 0x6010 SubIndex: 1 BitLength: 1 Datatype: BOOL
3 Name: Input Index: 0x6020 SubIndex: 1 BitLength: 1 Datatype: BOOL
4 Name: Input Index: 0x6030 SubIndex: 1 BitLength: 1 Datatype: BOOL
5 Name: Input Index: 0x6040 SubIndex: 1 BitLength: 1 Datatype: BOOL
6 Name: Input Index: 0x6050 SubIndex: 1 BitLength: 1 Datatype: BOOL
7 Name: Input Index: 0x6060 SubIndex: 1 BitLength: 1 Datatype: BOOL
8 Name: Input Index: 0x6070 SubIndex: 1 BitLength: 1 Datatype: BOOL
===================================Output PDOs====================================
1 Name: Output Index: 0x7000 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Output Index: 0x7010 SubIndex: 1 BitLength: 1 Datatype: BOOL
3 Name: Output Index: 0x7020 SubIndex: 1 BitLength: 1 Datatype: BOOL
4 Name: Output Index: 0x7030 SubIndex: 1 BitLength: 1 Datatype: BOOL
5 Name: Output Index: 0x7040 SubIndex: 1 BitLength: 1 Datatype: BOOL
6 Name: Output Index: 0x7050 SubIndex: 1 BitLength: 1 Datatype: BOOL
7 Name: Output Index: 0x7060 SubIndex: 1 BitLength: 1 Datatype: BOOL
8 Name: Output Index: 0x7070 SubIndex: 1 BitLength: 1 Datatype: BOOL
==================================================================================
======================================EP2339======================================
====================================Input PDOs====================================
1 Name: Input 1 Index: 0x6000 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Input 2 Index: 0x6000 SubIndex: 2 BitLength: 1 Datatype: BOOL
3 Name: Input 3 Index: 0x6000 SubIndex: 3 BitLength: 1 Datatype: BOOL
4 Name: Input 4 Index: 0x6000 SubIndex: 4 BitLength: 1 Datatype: BOOL
5 Name: Input 5 Index: 0x6000 SubIndex: 5 BitLength: 1 Datatype: BOOL
6 Name: Input 6 Index: 0x6000 SubIndex: 6 BitLength: 1 Datatype: BOOL
7 Name: Input 7 Index: 0x6000 SubIndex: 7 BitLength: 1 Datatype: BOOL
8 Name: Input 8 Index: 0x6000 SubIndex: 8 BitLength: 1 Datatype: BOOL
9 Name: Sync error Index: 0x6000 SubIndex: 14 BitLength: 1 Datatype: BOOL
10 Name: TxPDO State Index: 0x6000 SubIndex: 15 BitLength: 1 Datatype: BOOL
11 Name: TxPDO Toggle Index: 0x6000 SubIndex: 16 BitLength: 1 Datatype: BOOL
12 Name: Input 1 Index: 0x6010 SubIndex: 1 BitLength: 1 Datatype: BOOL
13 Name: Input 2 Index: 0x6010 SubIndex: 2 BitLength: 1 Datatype: BOOL
14 Name: Input 3 Index: 0x6010 SubIndex: 3 BitLength: 1 Datatype: BOOL
15 Name: Input 4 Index: 0x6010 SubIndex: 4 BitLength: 1 Datatype: BOOL
16 Name: Input 5 Index: 0x6010 SubIndex: 5 BitLength: 1 Datatype: BOOL
17 Name: Input 6 Index: 0x6010 SubIndex: 6 BitLength: 1 Datatype: BOOL
18 Name: Input 7 Index: 0x6010 SubIndex: 7 BitLength: 1 Datatype: BOOL
19 Name: Input 8 Index: 0x6010 SubIndex: 8 BitLength: 1 Datatype: BOOL
20 Name: Sync error Index: 0x6010 SubIndex: 14 BitLength: 1 Datatype: BOOL
21 Name: TxPDO State Index: 0x6010 SubIndex: 15 BitLength: 1 Datatype: BOOL
22 Name: TxPDO Toggle Index: 0x6010 SubIndex: 16 BitLength: 1 Datatype: BOOL
===================================Output PDOs====================================
1 Name: Output 1 Index: 0x7020 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Output 2 Index: 0x7020 SubIndex: 2 BitLength: 1 Datatype: BOOL
3 Name: Output 3 Index: 0x7020 SubIndex: 3 BitLength: 1 Datatype: BOOL
4 Name: Output 4 Index: 0x7020 SubIndex: 4 BitLength: 1 Datatype: BOOL
5 Name: Output 5 Index: 0x7020 SubIndex: 5 BitLength: 1 Datatype: BOOL
6 Name: Output 6 Index: 0x7020 SubIndex: 6 BitLength: 1 Datatype: BOOL
7 Name: Output 7 Index: 0x7020 SubIndex: 7 BitLength: 1 Datatype: BOOL
8 Name: Output 8 Index: 0x7020 SubIndex: 8 BitLength: 1 Datatype: BOOL
9 Name: Output 1 Index: 0x7030 SubIndex: 1 BitLength: 1 Datatype: BOOL
10 Name: Output 2 Index: 0x7030 SubIndex: 2 BitLength: 1 Datatype: BOOL
11 Name: Output 3 Index: 0x7030 SubIndex: 3 BitLength: 1 Datatype: BOOL
12 Name: Output 4 Index: 0x7030 SubIndex: 4 BitLength: 1 Datatype: BOOL
13 Name: Output 5 Index: 0x7030 SubIndex: 5 BitLength: 1 Datatype: BOOL
14 Name: Output 6 Index: 0x7030 SubIndex: 6 BitLength: 1 Datatype: BOOL
15 Name: Output 7 Index: 0x7030 SubIndex: 7 BitLength: 1 Datatype: BOOL
16 Name: Output 8 Index: 0x7030 SubIndex: 8 BitLength: 1 Datatype: BOOL
==================================================================================
======================================EP2349======================================
====================================Input PDOs====================================
1 Name: Input Index: 0x6000 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Input Index: 0x6010 SubIndex: 1 BitLength: 1 Datatype: BOOL
3 Name: Input Index: 0x6020 SubIndex: 1 BitLength: 1 Datatype: BOOL
4 Name: Input Index: 0x6030 SubIndex: 1 BitLength: 1 Datatype: BOOL
5 Name: Input Index: 0x6040 SubIndex: 1 BitLength: 1 Datatype: BOOL
6 Name: Input Index: 0x6050 SubIndex: 1 BitLength: 1 Datatype: BOOL
7 Name: Input Index: 0x6060 SubIndex: 1 BitLength: 1 Datatype: BOOL
8 Name: Input Index: 0x6070 SubIndex: 1 BitLength: 1 Datatype: BOOL
9 Name: Input Index: 0x6080 SubIndex: 1 BitLength: 1 Datatype: BOOL
10 Name: Input Index: 0x6090 SubIndex: 1 BitLength: 1 Datatype: BOOL
11 Name: Input Index: 0x60a0 SubIndex: 1 BitLength: 1 Datatype: BOOL
12 Name: Input Index: 0x60b0 SubIndex: 1 BitLength: 1 Datatype: BOOL
13 Name: Input Index: 0x60c0 SubIndex: 1 BitLength: 1 Datatype: BOOL
14 Name: Input Index: 0x60d0 SubIndex: 1 BitLength: 1 Datatype: BOOL
15 Name: Input Index: 0x60e0 SubIndex: 1 BitLength: 1 Datatype: BOOL
16 Name: Input Index: 0x60f0 SubIndex: 1 BitLength: 1 Datatype: BOOL
===================================Output PDOs====================================
1 Name: Output Index: 0x7000 SubIndex: 1 BitLength: 1 Datatype: BOOL
2 Name: Output Index: 0x7010 SubIndex: 1 BitLength: 1 Datatype: BOOL
3 Name: Output Index: 0x7020 SubIndex: 1 BitLength: 1 Datatype: BOOL
4 Name: Output Index: 0x7030 SubIndex: 1 BitLength: 1 Datatype: BOOL
5 Name: Output Index: 0x7040 SubIndex: 1 BitLength: 1 Datatype: BOOL
6 Name: Output Index: 0x7050 SubIndex: 1 BitLength: 1 Datatype: BOOL
7 Name: Output Index: 0x7060 SubIndex: 1 BitLength: 1 Datatype: BOOL
8 Name: Output Index: 0x7070 SubIndex: 1 BitLength: 1 Datatype: BOOL
9 Name: Output Index: 0x7080 SubIndex: 1 BitLength: 1 Datatype: BOOL
10 Name: Output Index: 0x7090 SubIndex: 1 BitLength: 1 Datatype: BOOL
11 Name: Output Index: 0x70a0 SubIndex: 1 BitLength: 1 Datatype: BOOL
12 Name: Output Index: 0x70b0 SubIndex: 1 BitLength: 1 Datatype: BOOL
13 Name: Output Index: 0x70c0 SubIndex: 1 BitLength: 1 Datatype: BOOL
14 Name: Output Index: 0x70d0 SubIndex: 1 BitLength: 1 Datatype: BOOL
15 Name: Output Index: 0x70e0 SubIndex: 1 BitLength: 1 Datatype: BOOL
16 Name: Output Index: 0x70f0 SubIndex: 1 BitLength: 1 Datatype: BOOL
==================================================================================
"""Parser for Beckhoff ESI files"""
import re
import sys
from bs4 import BeautifulSoup
with open(sys.argv[1], 'r', encoding='ISO-8859-15') as f:
xml = f.read()
data = BeautifulSoup(xml, "xml")
processed = []
def filter_info(entry):
try:
dtype = entry.find('DataType').text.strip()
if not dtype:
return None
except:
return None
name = entry.find('Name').text
# name = name.text if name else "?"
idx = str(entry.find('Index').text)[1:]
sub = entry.find('SubIndex')
sub = sub.text if sub else 0
length = entry.find('BitLen').text
return f"Name: {name:<20} Index: 0{idx} SubIndex: {sub:<2} BitLength: {length} Datatype: {dtype}"
def extract_name(text):
m = re.search(r"EP\d{4}", text)
return m.group(0)
for device in data.find("Devices").find_all("Device"):
if not "EP23" in device.find("Name").text:
continue
name = extract_name(device.find("Name").text)
if not name in processed:
processed.append(name)
else:
continue
print(f"{name:=^82}")
print()
print(f"{'Input PDOs':=^82}")
counter = 1
for txpdo in device.find_all("TxPdo"):
for entry in txpdo.find_all("Entry"):
result = filter_info(entry)
if result:
print(f"{counter:<3} {result}")
counter += 1
print(f"{'Output PDOs':=^82}")
counter = 1
for rxpdo in device.find_all("RxPdo"):
for entry in rxpdo.find_all("Entry"):
result = filter_info(entry)
if result:
print(f"{counter:<3} {result}")
counter += 1
print("="*82)
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment