Hi all,
I have written some code to parse the generated XML file from "ethercat xml"
and use that to configure the ethercat stack. The problem I am having is the
output from ecrt_slave_config_ret_pdo_entry produces overlapped offsets. I
also tried using ecrt_slave_config_reg_pdo_entry_pos with the same results.
This is a very simple test rig that has one each of DO, DI, AO, and AI slices -
all beckhoff. I have attached a file which includes the generated XML file,
the code in question, and the log output. Does anyone know what I am doing
wrong?
Best regards,
Steven Hartmann
<?xml version="1.0" ?>
<EtherCATInfoList>
<EtherCATInfo>
<!-- Slave 0 -->
<Vendor>
<Id>2</Id>
</Vendor>
<Descriptions>
<Devices>
<Device>
<Type ProductCode="#x044d2c52" RevisionNo="#x00120000">EK1101</Type>
<Name><![CDATA[EK1101 EtherCAT-Koppler (2A E-Bus, ID-Switch)]]></Name>
<Sm Enable="0" StartAddress="#x1000" ControlByte="#x0"
DefaultSize="0" />
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a00</Index>
<Name>ID</Name>
<Entry>
<Index>#x6000</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>ID</Name>
<DataType>UINT</DataType>
</Entry>
</TxPdo>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>
<EtherCATInfo>
<!-- Slave 1 -->
<Vendor>
<Id>2</Id>
</Vendor>
<Descriptions>
<Devices>
<Device>
<Type ProductCode="#x071b3052" RevisionNo="#x00110000">EL1819</Type>
<Name><![CDATA[EL1819 16K. Dig. Eingang 24V, 10µs]]></Name>
<Sm Enable="1" StartAddress="#x1000" ControlByte="#x0"
DefaultSize="2" />
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a00</Index>
<Name>Channel 1</Name>
<Entry>
<Index>#x6000</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a01</Index>
<Name>Channel 2</Name>
<Entry>
<Index>#x6010</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a02</Index>
<Name>Channel 3</Name>
<Entry>
<Index>#x6020</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a03</Index>
<Name>Channel 4</Name>
<Entry>
<Index>#x6030</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a04</Index>
<Name>Channel 5</Name>
<Entry>
<Index>#x6040</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a05</Index>
<Name>Channel 6</Name>
<Entry>
<Index>#x6050</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a06</Index>
<Name>Channel 7</Name>
<Entry>
<Index>#x6060</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a07</Index>
<Name>Channel 8</Name>
<Entry>
<Index>#x6070</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a08</Index>
<Name>Channel 9</Name>
<Entry>
<Index>#x6080</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a09</Index>
<Name>Channel 10</Name>
<Entry>
<Index>#x6090</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a0a</Index>
<Name>Channel 11</Name>
<Entry>
<Index>#x60a0</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a0b</Index>
<Name>Channel 12</Name>
<Entry>
<Index>#x60b0</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a0c</Index>
<Name>Channel 13</Name>
<Entry>
<Index>#x60c0</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a0d</Index>
<Name>Channel 14</Name>
<Entry>
<Index>#x60d0</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a0e</Index>
<Name>Channel 15</Name>
<Entry>
<Index>#x60e0</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1a0f</Index>
<Name>Channel 16</Name>
<Entry>
<Index>#x60f0</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Input</Name>
<DataType>BOOL</DataType>
</Entry>
</TxPdo>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>
<EtherCATInfo>
<!-- Slave 2 -->
<Vendor>
<Id>2</Id>
</Vendor>
<Descriptions>
<Devices>
<Device>
<Type ProductCode="#x07e83052" RevisionNo="#x00110000">EL2024</Type>
<Name><![CDATA[EL2024 4Ch. Dig. Output 24V, 2A]]></Name>
<Sm Enable="9" StartAddress="#xf00" ControlByte="#x44"
DefaultSize="0" />
<RxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1600</Index>
<Name>Channel 1</Name>
<Entry>
<Index>#x7000</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Output</Name>
<DataType>BOOL</DataType>
</Entry>
</RxPdo>
<RxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1601</Index>
<Name>Channel 2</Name>
<Entry>
<Index>#x7010</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Output</Name>
<DataType>BOOL</DataType>
</Entry>
</RxPdo>
<RxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1602</Index>
<Name>Channel 3</Name>
<Entry>
<Index>#x7020</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Output</Name>
<DataType>BOOL</DataType>
</Entry>
</RxPdo>
<RxPdo Sm="0" Fixed="1" Mandatory="1">
<Index>#x1603</Index>
<Name>Channel 4</Name>
<Entry>
<Index>#x7030</Index>
<SubIndex>1</SubIndex>
<BitLen>1</BitLen>
<Name>Output</Name>
<DataType>BOOL</DataType>
</Entry>
</RxPdo>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>
<EtherCATInfo>
<!-- Slave 3 -->
<Vendor>
<Id>2</Id>
</Vendor>
<Descriptions>
<Devices>
<Device>
<Type ProductCode="#x10243052" RevisionNo="#x03fa0000">EL4132</Type>
<Name><![CDATA[EL4132 2Ch. Ana. Ausgang +/-10V, 16bit]]></Name>
<Sm Enable="1" StartAddress="#x1800" ControlByte="#x26"
DefaultSize="246" />
<Sm Enable="1" StartAddress="#x18f6" ControlByte="#x22"
DefaultSize="246" />
<Sm Enable="1" StartAddress="#x1000" ControlByte="#x24"
DefaultSize="4" />
<Sm Enable="0" StartAddress="#x1100" ControlByte="#x20"
DefaultSize="0" />
<RxPdo Sm="2" Fixed="1" Mandatory="1">
<Index>#x1600</Index>
<Name>RxPDO 01 mapping</Name>
<Entry>
<Index>#x3001</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>Output</Name>
<DataType DScale="+/-10">INT</DataType>
</Entry>
</RxPdo>
<RxPdo Sm="2" Fixed="1" Mandatory="1">
<Index>#x1601</Index>
<Name>RxPDO 02 mapping</Name>
<Entry>
<Index>#x3002</Index>
<SubIndex>1</SubIndex>
<BitLen>16</BitLen>
<Name>Output</Name>
<DataType DScale="+/-10">INT</DataType>
</Entry>
</RxPdo>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>
<EtherCATInfo>
<!-- Slave 4 -->
<Vendor>
<Id>2</Id>
</Vendor>
<Descriptions>
<Devices>
<Device>
<Type ProductCode="#x0c1e3052" RevisionNo="#x00110000">EL3102</Type>
<Name><![CDATA[EL3102 2K. Ana. Eingang +/-10V, Diff.]]></Name>
<Sm Enable="1" StartAddress="#x1000" ControlByte="#x26"
DefaultSize="128" />
<Sm Enable="1" StartAddress="#x1080" ControlByte="#x22"
DefaultSize="128" />
<Sm Enable="0" StartAddress="#x1100" ControlByte="#x4"
DefaultSize="0" />
<Sm Enable="1" StartAddress="#x1180" ControlByte="#x20"
DefaultSize="6" />
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a00</Index>
<Name>TxPDO-Map Channel 1</Name>
<Entry>
<Index>#x3101</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>Status</Name>
<DataType>USINT</DataType>
</Entry>
<Entry>
<Index>#x3101</Index>
<SubIndex>2</SubIndex>
<BitLen>16</BitLen>
<Name>Value</Name>
<DataType DScale="+/-10">INT</DataType>
</Entry>
</TxPdo>
<TxPdo Sm="3" Fixed="1" Mandatory="1">
<Index>#x1a01</Index>
<Name>TxPDO-Map Channel 2</Name>
<Entry>
<Index>#x3102</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>Status</Name>
<DataType>USINT</DataType>
</Entry>
<Entry>
<Index>#x3102</Index>
<SubIndex>2</SubIndex>
<BitLen>16</BitLen>
<Name>Value</Name>
<DataType DScale="+/-10">INT</DataType>
</Entry>
</TxPdo>
</Device>
</Devices>
</Descriptions>
</EtherCATInfo>
</EtherCATInfoList>
--------------------------------------------------------------------------------------------------
Vendor: 2
Type: EK1101
Product Code and revision: 72166482 #x00120000
2014/04/09 22:22:02.899 DEBUG Getting save info for pos 0
2014/04/09 22:22:02.899 DEBUG Found group 1
2014/04/09 22:22:02.899 DEBUG Sync Manager 0 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.899 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a00
2014/04/09 22:22:02.899 DEBUG PDO Entry: PDO Index 0x1a00 Entry Index: 0x6000
Entry subindex: 0x1 entry bit length: 10
2014/04/09 22:22:02.899 DEBUG DomainOffset = 0 sm idx 0 pdo pos 0 entry pos 0
bit pos 0
Vendor: 2
Type: EL1819
Product Code and revision: 119222354 #x00110000
2014/04/09 22:22:02.900 DEBUG Getting save info for pos 1
2014/04/09 22:22:02.900 DEBUG Found group 3
2014/04/09 22:22:02.900 DEBUG Sync Manager 0 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.900 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a00
2014/04/09 22:22:02.900 DEBUG PDO Entry: PDO Index 0x1a00 Entry Index: 0x6000
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.900 DEBUG DomainOffset = 2 sm idx 0 pdo pos 0 entry pos 0
bit pos 0
2014/04/09 22:22:02.900 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a01
2014/04/09 22:22:02.900 DEBUG PDO Entry: PDO Index 0x1a01 Entry Index: 0x6010
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.900 DEBUG DomainOffset = 2 sm idx 0 pdo pos 1 entry pos 0
bit pos 1
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a02
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a02 Entry Index: 0x6020
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 2 entry pos 0
bit pos 2
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a03
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a03 Entry Index: 0x6030
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 3 entry pos 0
bit pos 3
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a04
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a04 Entry Index: 0x6040
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 4 entry pos 0
bit pos 4
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a05
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a05 Entry Index: 0x6050
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 5 entry pos 0
bit pos 5
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a06
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a06 Entry Index: 0x6060
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 6 entry pos 0
bit pos 6
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a07
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a07 Entry Index: 0x6070
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 7 entry pos 0
bit pos 7
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a08
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a08 Entry Index: 0x6080
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 3 sm idx 0 pdo pos 8 entry pos 0
bit pos 0
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a09
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a09 Entry Index: 0x6090
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 3 sm idx 0 pdo pos 9 entry pos 0
bit pos 1
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0a
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a0a Entry Index: 0x60a0
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 3 sm idx 0 pdo pos a entry pos 0
bit pos 2
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0b
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a0b Entry Index: 0x60b0
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 3 sm idx 0 pdo pos b entry pos 0
bit pos 3
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0c
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a0c Entry Index: 0x60c0
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 3 sm idx 0 pdo pos c entry pos 0
bit pos 4
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0d
2014/04/09 22:22:02.902 DEBUG PDO Entry: PDO Index 0x1a0d Entry Index: 0x60d0
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.902 DEBUG DomainOffset = 3 sm idx 0 pdo pos d entry pos 0
bit pos 5
2014/04/09 22:22:02.902 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0e
2014/04/09 22:22:02.902 DEBUG PDO Entry: PDO Index 0x1a0e Entry Index: 0x60e0
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.902 DEBUG DomainOffset = 3 sm idx 0 pdo pos e entry pos 0
bit pos 6
2014/04/09 22:22:02.902 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0f
2014/04/09 22:22:02.902 DEBUG PDO Entry: PDO Index 0x1a0f Entry Index: 0x60f0
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.902 DEBUG DomainOffset = 3 sm idx 0 pdo pos f entry pos 0
bit pos 7
Vendor: 2
Type: EL2024
Product Code and revision: 132657234 #x00110000
2014/04/09 22:22:02.902 DEBUG Getting save info for pos 2
2014/04/09 22:22:02.902 DEBUG Found group 2
2014/04/09 22:22:02.902 DEBUG Sync Manager 0 Direction: 1 Watchdog: 1
2014/04/09 22:22:02.902 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1600
2014/04/09 22:22:02.902 DEBUG PDO Entry: PDO Index 0x1600 Entry Index: 0x7000
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.902 DEBUG DomainOffset = 3 sm idx 0 pdo pos 0 entry pos 0
bit pos 0
2014/04/09 22:22:02.902 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1601
2014/04/09 22:22:02.902 DEBUG PDO Entry: PDO Index 0x1601 Entry Index: 0x7010
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.902 DEBUG DomainOffset = 3 sm idx 0 pdo pos 1 entry pos 0
bit pos 1
2014/04/09 22:22:02.902 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1602
2014/04/09 22:22:02.903 DEBUG PDO Entry: PDO Index 0x1602 Entry Index: 0x7020
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.903 DEBUG DomainOffset = 3 sm idx 0 pdo pos 2 entry pos 0
bit pos 2
2014/04/09 22:22:02.903 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1603
2014/04/09 22:22:02.903 DEBUG PDO Entry: PDO Index 0x1603 Entry Index: 0x7030
Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.903 DEBUG DomainOffset = 3 sm idx 0 pdo pos 3 entry pos 0
bit pos 3
Vendor: 2
Type: EL4132
Product Code and revision: 270807122 #x03fa0000
2014/04/09 22:22:02.903 DEBUG Getting save info for pos 3
2014/04/09 22:22:02.903 DEBUG Found group 4
2014/04/09 22:22:02.903 DEBUG Sync Manager 0 Direction: 1 Watchdog: 2
2014/04/09 22:22:02.903 DEBUG Sync Manager 1 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.903 DEBUG Sync Manager 2 Direction: 1 Watchdog: 2
2014/04/09 22:22:02.903 DEBUG Sync Manager 3 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.903 DEBUG PDO: SM Index 0x2 pdoIndex: 0x1600
2014/04/09 22:22:02.903 DEBUG PDO Entry: PDO Index 0x1600 Entry Index: 0x3001
Entry subindex: 0x1 entry bit length: 10
2014/04/09 22:22:02.903 DEBUG DomainOffset = 4 sm idx 2 pdo pos 0 entry pos 0
bit pos 0
2014/04/09 22:22:02.903 DEBUG PDO: SM Index 0x2 pdoIndex: 0x1601
2014/04/09 22:22:02.903 DEBUG PDO Entry: PDO Index 0x1601 Entry Index: 0x3002
Entry subindex: 0x1 entry bit length: 10
2014/04/09 22:22:02.903 DEBUG DomainOffset = 6 sm idx 2 pdo pos 1 entry pos 0
bit pos 0
Vendor: 2
Type: EL3102
Product Code and revision: 203305042 #x00110000
2014/04/09 22:22:02.904 DEBUG Getting save info for pos 4
2014/04/09 22:22:02.904 DEBUG Found group 5
2014/04/09 22:22:02.904 DEBUG Sync Manager 0 Direction: 1 Watchdog: 2
2014/04/09 22:22:02.904 DEBUG Sync Manager 1 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.904 DEBUG Sync Manager 2 Direction: 1 Watchdog: 2
2014/04/09 22:22:02.904 DEBUG Sync Manager 3 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.904 DEBUG PDO: SM Index 0x3 pdoIndex: 0x1a00
2014/04/09 22:22:02.904 DEBUG PDO Entry: PDO Index 0x1a00 Entry Index: 0x3101
Entry subindex: 0x1 entry bit length: 8
2014/04/09 22:22:02.904 DEBUG DomainOffset = 6 sm idx 3 pdo pos 0 entry pos 0
bit pos 0
2014/04/09 22:22:02.904 DEBUG PDO Entry: PDO Index 0x1a00 Entry Index: 0x3101
Entry subindex: 0x2 entry bit length: 10
2014/04/09 22:22:02.904 DEBUG DomainOffset = 7 sm idx 3 pdo pos 0 entry pos 1
bit pos 0
2014/04/09 22:22:02.904 DEBUG PDO: SM Index 0x3 pdoIndex: 0x1a01
2014/04/09 22:22:02.904 DEBUG PDO Entry: PDO Index 0x1a01 Entry Index: 0x3102
Entry subindex: 0x1 entry bit length: 8
2014/04/09 22:22:02.904 DEBUG DomainOffset = 9 sm idx 3 pdo pos 1 entry pos 0
bit pos 0
2014/04/09 22:22:02.904 DEBUG PDO Entry: PDO Index 0x1a01 Entry Index: 0x3102
Entry subindex: 0x2 entry bit length: 10
2014/04/09 22:22:02.904 DEBUG DomainOffset = a sm idx 3 pdo pos 1 entry pos 1
bit pos 0
2014/04/09 22:22:02.905 DEBUG Number of IO points: 1b
DomainDC = 0xcdf68000
-----------------------------------------------------------------------------------------------------------
bool EtherLabEtherCATMaster::parseXmlFile(const char* filename)
{
bool ret(true);
std::ifstream is;
is.open(filename);
if (!is.is_open()) {
return false;;
}
boost::property_tree::ptree pt;
boost::property_tree::read_xml(is, pt);
uint8_t syncManagerIndex(0);
LongTranslator lTrans;
ULongTranslator ulTrans;
U16Translator u16Trans;
U8Translator u8Trans;
uint16_t posCount = 0;
uint32_t vendorID;
uint32_t productCode;
ec_slave_config_t* slaveConfig;
ec_slave_info_t slaveInfo;
TIOPointType ioPointType;
unsigned pdoPos, entryPos;
BOOST_FOREACH(boost::property_tree::ptree::value_type const& v,
pt.get_child("EtherCATInfoList")) {
if (v.first == "EtherCATInfo") {
BOOST_FOREACH(boost::property_tree::ptree::value_type const& v1, v.second
) {
//std::cout << v1.first << std::endl;
if (v1.first == "Vendor") {
vendorID = v1.second.get<uint32_t>("Id");
std::cout << "Vendor: " << vendorID << std::endl;
}
if (v1.first == "Descriptions") {
boost::property_tree::ptree devTree = v1.second;
boost::property_tree::ptree devParts = devTree.get_child("Devices");
syncManagerIndex = 0;
BOOST_FOREACH(boost::property_tree::ptree::value_type const&
deviceList, devParts.get_child("Device")) {
//std::cout << deviceList.first << std::endl;
if (deviceList.first == "Type") {
cout << "Type: " << deviceList.second.get_value<std::string>()
<< std::endl;
productCode =
deviceList.second.get<uint32_t>("<xmlattr>.ProductCode", ulTrans);
cout << "Product Code and revision: " << productCode
<< " " <<
deviceList.second.get<std::string>("<xmlattr>.RevisionNo") << std::endl;
slaveConfig = ecrt_master_slave_config(Master, 0, posCount,
vendorID, productCode);
if (!slaveConfig) {
ret = false;
} else {
LOG4CPLUS_DEBUG(Logger, "Getting save info for pos " <<
posCount);
ecrt_master_get_slave(Master, posCount, &slaveInfo);
ioPointType = TranslateIOType(slaveInfo.group);
LOG4CPLUS_DEBUG(Logger, "Found group " << ioPointType);
}
}
if (deviceList.first == "Sm") {
long startAddr;
startAddr = deviceList.second.get<long>("<xmlattr>.StartAddress",
lTrans);
uint32_t controlRegister =
deviceList.second.get<uint32_t>("<xmlattr>.ControlByte",ulTrans);
ec_direction_t smDirection = (controlRegister & 0x4) ?
EC_DIR_OUTPUT : EC_DIR_INPUT;
ec_watchdog_mode_t smWatchdogMode = (controlRegister & 0x40)?
EC_WD_ENABLE : EC_WD_DISABLE;
if (0 != ecrt_slave_config_sync_manager(slaveConfig,
syncManagerIndex, smDirection, smWatchdogMode)) {
ret = false;
LOG4CPLUS_ERROR(Logger, "Error during
ecrt_slave_config_sync_manager()");
}
ecrt_slave_config_pdo_assign_clear(slaveConfig, syncManagerIndex);
LOG4CPLUS_DEBUG(Logger, "Sync Manager " << (int)syncManagerIndex
<< " Direction: " << smDirection
<< " Watchdog: " << smWatchdogMode);
++syncManagerIndex;
pdoPos = 0;
}
if (deviceList.first == "RxPdo" || deviceList.first == "TxPdo") {
uint8_t smIndex = deviceList.second.get<uint8_t>("<xmlattr>.Sm",
u8Trans);
uint16_t pdoIndex = deviceList.second.get<uint16_t>("Index",
u16Trans);
if (0 != ecrt_slave_config_pdo_assign_add(slaveConfig, smIndex,
pdoIndex)) {
ret = false;
LOG4CPLUS_ERROR(Logger, "Error during
ecrt_slave_config_pdo_assign_add()");
}
ecrt_slave_config_pdo_mapping_clear(slaveConfig, pdoIndex);
LOG4CPLUS_DEBUG(Logger, "PDO: SM Index 0x" << std::hex <<
(int)smIndex
<< " pdoIndex: 0x" << std::hex << pdoIndex);
entryPos = 0;
BOOST_FOREACH(boost::property_tree::ptree::value_type const&
pdoEntryList, deviceList.second) {
//cout << "Index " << pdoEntryList.second.get<string>("Index")
<< std::endl;
if(pdoEntryList.first == "Entry") {
uint16_t entryIndex;
uint8_t entrySubindex;
uint8_t entryBitLength;
entryIndex = pdoEntryList.second.get<uint16_t>("Index",
u16Trans);
entrySubindex = pdoEntryList.second.get<uint8_t>("SubIndex",
u8Trans);
entryBitLength = pdoEntryList.second.get<uint8_t>("BitLen",
u8Trans);
std::string ioName =
pdoEntryList.second.get<std::string>("Name");
std::string ioDataTypeStr =
pdoEntryList.second.get<std::string>("DataType");
TECDataType ioDataType = TranslateDataType(ioDataTypeStr);
std::string ioRangeStr =
pdoEntryList.second.get("DataType.<xmlattr>.DScale","");
double rangeHi, rangeLo;
TranslateRange(ioRangeStr, rangeLo, rangeHi);
LOG4CPLUS_DEBUG(Logger, "PDO Entry: PDO Index 0x" << std::hex
<< pdoIndex
<< " Entry Index: 0x" << std::hex << entryIndex
<< " Entry subindex: 0x" << std::hex <<
(int)entrySubindex
<< " entry bit length: " << (int)entryBitLength);
if (0 != ecrt_slave_config_pdo_mapping_add(slaveConfig,
pdoIndex, entryIndex, entrySubindex, entryBitLength)) {
ret = false;
LOG4CPLUS_ERROR(Logger, "Error during
ecrt_slave_config_pdo_mapping_add()");
}
// Now search for a domain in which this PDO entry belongs
std::vector<ELDomainRecord*>::iterator dptr;
for (dptr = Domains.begin();dptr != Domains.end(); ++dptr) {
if (posCount >= (*dptr)->BeginSlave && posCount <=
(*dptr)->EndSlave) {
IOPointRecord iop;
iop.BitSize = entryBitLength;
iop.IOType = ioPointType;
iop.Name = ioName;
iop.DataType = ioDataType;
iop.RangeHi = rangeHi;
iop.RangeLo = rangeLo;
//iop.DomainOffset =
ecrt_slave_config_reg_pdo_entry(slaveConfig, entryIndex, entrySubindex,
(*dptr)->Domain, &(iop.BitPosition));
iop.DomainOffset =
ecrt_slave_config_reg_pdo_entry_pos(slaveConfig, smIndex, pdoPos, entryPos,
(*dptr)->Domain, &(iop.BitPosition));
LOG4CPLUS_DEBUG(Logger, "DomainOffset = " <<
iop.DomainOffset
<< " sm idx " << (int)smIndex
<< " pdo pos " << pdoPos
<< " entry pos " << entryPos
<< " bit pos " << iop.BitPosition);
if (iop.DomainOffset < 0) {
LOG4CPLUS_ERROR(Logger, "Error obtaining domain PD
offset for io point at slave position " << posCount);
} else {
(*dptr)->IOPoints.push_back(iop);
}
}
}
++entryPos;
}
}
++pdoPos;
}
}
++posCount;
}
}
}
}
return ret;
}
_______________________________________________
etherlab-users mailing list
[email protected]
http://lists.etherlab.org/mailman/listinfo/etherlab-users