<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; } @font-face { font-family: "Cambria Math"; } @font-face { font-family: Calibri; } p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; } a:link, span.MsoHyperlink { color: rgb(5, 99, 193); text-decoration: underline; } a:visited, span.MsoHyperlinkFollowed { color: rgb(149, 79, 114); text-decoration: underline; } span.EmailStyle17 { font-family: Calibri, sans-serif; color: windowtext; } span.SpellE { } .MsoChpDefault { font-family: Calibri, sans-serif; } @page WordSection1 { margin: 72pt; } div.WordSection1 { }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<div class="WordSection1">
<p class="MsoNormal">Dear <span class="SpellE">EtherLab</span> Users,<br>
</p>
<p class="MsoNormal"><br>
</p>
<p class="MsoNormal"><br>
</p>
<p class="MsoNormal">I installed the IgH EtherCAT master, and to educate myself how to implement the communication, I set up a small network comprising of IgH master and one <span style="font-size: 14.6667px;">Technosoft Motion iPOS4808 drive.</span></p>
<p class="MsoNormal"><span style="font-size: 14.6667px;"><br>
</span></p>
<p class="MsoNormal"><span style="font-size: 14.6667px;">The ./ethercat slaves command detects it.</span></p>
<p class="MsoNormal"><span style="font-size: 14.6667px;"><br>
</span></p>
<p class="MsoNormal"><span style="font-size: 14.6667px;">The ./ethercat cstruct gives me the following configuration:</span></p>
<p class="MsoNormal"><span style="font-size: 14.6667px;"><br>
</span></p>
<div>ec_pdo_entry_info_t slave_0_pdo_entries[] = {</div>
<div>    {0x6040, 0x00, 16},</div>
<div>    {0x607a, 0x00, 32},</div>
<div>    {0x6041, 0x00, 16},</div>
<div>    {0x6064, 0x00, 32},</div>
<div>    {0x6077, 0x00, 16},</div>
<div>    {0x60f4, 0x00, 32},</div>
<div>    {0x60fd, 0x00, 32},</div>
<div>};</div>
<div><br>
</div>
<div>ec_pdo_info_t slave_0_pdos[] = {</div>
<div>    {0x1600, 2, slave_0_pdo_entries + 0},</div>
<div>    {0x1a00, 3, slave_0_pdo_entries + 2},</div>
<div>    {0x1a01, 2, slave_0_pdo_entries + 5},</div>
<div>};</div>
<div><br>
</div>
<div>ec_sync_info_t slave_0_syncs[] = {</div>
<div>    {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},</div>
<div>    {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},</div>
<div>    {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_DISABLE},</div>
<div>    {3, EC_DIR_INPUT, 2, slave_0_pdos + 1, EC_WD_DISABLE},</div>
<div>    {0xff}</div>
<div>};</div>
<div><br>
<br>
</div>
<div>Now I want to use C++ functions, to change the value outputted at 0x1a00 x02 to the object 0x2058 x00 with size 16 bit.<br>
</div>
<div><br>
</div>
<div>Hence, based on the cstruct file, as well as ~/ethercat-1.5.2/example/user/main.c , I write the following code (spread over main.h and main.cpp) to achieve this.<br>
</div>
<div><br>
</div>
<div>
<pre style="margin-top: 0px; margin-bottom: 0px;"><!--StartFragment--><span style=" color:#000080;">#include</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"auxfun.h"</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Application</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">parameters</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#000080;">#define</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">FREQUENCY</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">100</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#000080;">#define</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">PRIORITY</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Optional</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">features</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#000080;">#define</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">CONFIGURE_PDOS</span><span style=" color:#c0c0c0;">  </span><span style=" color:#000080;">1</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#000080;">#define</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">SDO_ACCESS</span><span style=" color:#c0c0c0;">      </span><span style=" color:#000080;">0</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">EtherCAT</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">ec_master_t</span><span style=" color:#c0c0c0;"> </span>*master<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">NULL</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">ec_master_state_t</span><span style=" color:#c0c0c0;"> </span>master_state<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>{};</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">ec_domain_t</span><span style=" color:#c0c0c0;"> </span>*domain1<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">NULL</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">ec_domain_state_t</span><span style=" color:#c0c0c0;"> </span>domain1_state<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>{};</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">ec_slave_config_t</span><span style=" color:#c0c0c0;"> </span>*sc_iPOS0<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">NULL</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">ec_slave_config_state_t</span><span style=" color:#c0c0c0;"> </span>sc_iPOS0_state<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>{};</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Timer</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">unsigned</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>sig_alarms<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">unsigned</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>user_alarms<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#008000;">/****************************************************************************/</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">process</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">data</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span>uint8_t<span style=" color:#c0c0c0;"> </span>*domain1_pd<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">NULL</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#000080;">#define</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">AxisBotPos</span><span style=" color:#c0c0c0;">  </span><span style=" color:#000080;">0</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">//Bottom</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">frame</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">iPOS</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Alias</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#000080;">#define</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">IPOS4808BX_CAT</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x000001a3</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x019f418d</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Vendor</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">ID,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Product</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Code</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">const</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">ec_pdo_entry_reg_t</span><span style=" color:#c0c0c0;"> </span>domain1_regs[]<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">AxisBotPos</span>,<span style=" color:#c0c0c0;">  </span><span style=" color:#000080;">IPOS4808BX_CAT</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x6060</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x00</span>,<span style=" color:#c0c0c0;"> </span>&off_iPOS0_Rx},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">AxisBotPos</span>,<span style=" color:#c0c0c0;">  </span><span style=" color:#000080;">IPOS4808BX_CAT</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x2058</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x00</span>,<span style=" color:#c0c0c0;"> </span>&off_iPOS0_Tx},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">};</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#008000;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">Analog</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">--------------------------</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#800080;">ec_pdo_entry_info_t</span><span style=" color:#c0c0c0;"> </span>iPOS0_pdo_entries[]<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0x6040</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x00</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">16</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0x6060</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x00</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">8</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0x6041</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x00</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">16</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0x2058</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x00</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">16</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0x6077</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x00</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">16</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0x60f4</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x00</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">32</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0x60fd</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0x00</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">32</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">};</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#800080;">ec_pdo_info_t</span><span style=" color:#c0c0c0;"> </span>iPOS0_pdo[]<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0x1600</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">2</span>,<span style=" color:#c0c0c0;"> </span>iPOS0_pdo_entries<span style=" color:#c0c0c0;"> </span>+<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0x1a00</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">3</span>,<span style=" color:#c0c0c0;"> </span>iPOS0_pdo_entries<span style=" color:#c0c0c0;"> </span>+<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">2</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0x1a01</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">2</span>,<span style=" color:#c0c0c0;"> </span>iPOS0_pdo_entries<span style=" color:#c0c0c0;"> </span>+<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">5</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">};</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#800080;">ec_sync_info_t</span><span style=" color:#c0c0c0;"> </span>iPOS0_syncs[]<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">EC_DIR_OUTPUT</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">NULL</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">EC_WD_DISABLE</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">1</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">EC_DIR_INPUT</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">NULL</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">EC_WD_DISABLE</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">2</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">EC_DIR_OUTPUT</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1</span>,<span style=" color:#c0c0c0;"> </span>iPOS0_pdo<span style=" color:#c0c0c0;"> </span>+<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">EC_WD_DISABLE</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">3</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">EC_DIR_INPUT</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">2</span>,<span style=" color:#c0c0c0;"> </span>iPOS0_pdo<span style=" color:#c0c0c0;"> </span>+<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">EC_WD_DISABLE</span>},</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>{<span style=" color:#000080;">0xff</span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">};</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">
<pre style="margin-top: 0px; margin-bottom: 0px;"><!--StartFragment--><span style=" color:#000080;">#include</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"main.h"</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#008000;">/****************************************************************************/</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>main(<span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>argc,<span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">char</span><span style=" color:#c0c0c0;"> </span>**argv)</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">​​<br></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#808000;">struct</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">itimerval</span><span style=" color:#c0c0c0;"> </span>tv;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>master<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>ecrt_request_master(<span style=" color:#000080;">0</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>(!master)</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#808000;">return</span><span style=" color:#c0c0c0;"> </span>-<span style=" color:#000080;">1</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">​<br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>domain1<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>ecrt_master_create_domain(master);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>(!domain1)</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#808000;">return</span><span style=" color:#c0c0c0;"> </span>-<span style=" color:#000080;">1</span>;<br></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>(!(sc_iPOS0<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>ecrt_master_slave_config(</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">                    </span>master,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">AxisBotPos</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">IPOS4808BX_CAT</span>)))<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">        </span>fprintf(stderr,<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"Failed</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">to</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">get</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">slave</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">configuration.\n"</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#808000;">return</span><span style=" color:#c0c0c0;"> </span>-<span style=" color:#000080;">1</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>}<br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>printf(<span style=" color:#008000;">"Configuring</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">PDOs...\n"</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>(ecrt_slave_config_pdos(sc_iPOS0,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">4</span>,<span style=" color:#c0c0c0;"> </span>iPOS0_syncs))<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">        </span>fprintf(stderr,<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"Failed</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">to</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">configure</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">PDOs.\n"</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#808000;">return</span><span style=" color:#c0c0c0;"> </span>-<span style=" color:#000080;">1</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>}<br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>cout<span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"Done"</span><span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span>endl;</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><pre style="margin-top: 0px; margin-bottom: 0px;"><!--StartFragment--><span style=" color:#808000;">return</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre><pre style="margin-top: 0px; margin-bottom: 0px;">}<!--EndFragment-->​<br></pre></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre></pre>
<br>
</div>
<div><br>
</div>
<div>I run the code above. It executes with no problem.</div>
<div><br>
</div>
<div>Now, I checked, using: <br>
</div>
<p class="MsoNormal"> <br>
</p>
<div>sudo ethercat upload -a 0 0x1a00 01<br>
</div>
<div><br>
</div>
<div>whether the introduced mapping modification worked. Unfortunately it seems that it is not the case and I get the same variable that was in ./ethercat cstruct at that position.<br>
</div>
<div><br>
</div>
<div>Then I tried to change the variable manually using ./ethercat download <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">-</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">a
 0 0x1a00 01 </span>0x20580010. This worked, at least in the console (confirmed by ./ethercat upload). However, cstruct still outputs previous values. I also tried the same procedure with other PDO variables to the same effect, my C++ code changes nothing in
 the mapping.<br>
</div>
<div><br>
</div>
<div>If anyone of you could look into the code and tell me whether what I am doing is correct (or wrong), I would be exteremely grateful. I mostly do not know where even to start debugging right now.<br>
</div>
<div><br>
</div>
<div>Thank you a lot in advance.<br>
</div>
<div><br>
</div>
<div>Yours faithfully,<br>
</div>
<div>Jakub Sikorski<br>
</div>
<div><br>
<br>
</div>
<p class="MsoNormal"><br>
</p>
<p class="MsoNormal"><br>
</p>
</div>
</body>
</html>