<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-NZ" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">There are a few different kinds of API to do SDO transfers, depending on how and when you want to do them.  (But in short: no, that code is probably not correct.)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal">ecrt_master_sdo_download/upload are blocking APIs; they are intended to be called before activating the master.  It is still possible to call them
<i>on a separate thread</i> while the master is active (though be aware that this will cause lock contention so is not recommended if you have a fast cycle time).  You
<b>must not</b> call it from your realtime thread.  These are intended for network discovery or other one-off or infrequent actions.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">ecrt_slave_config_create_sdo_request and the companion ecrt_sdo_request_* methods are intended for the case where you want to do transfers (either one-off or periodically) from the realtime thread
 while the master is active.  You create the request first (before activating the master) and then use the other methods to kick off a specific action and then poll it for completion from inside your realtime loop.  These are non-blocking.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">ecrt_slave_config_sdo* is for slave configuration settings that need to be written to the slave each time it reboots.  You call these once before activating the master and then the master itself
 takes care of sending these on first configuration and also if the slave needs to be reconfigured for any reason (eg. network disruption, rebooting).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">It's all explained in the documentation, the examples, and the header files themselves.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> jerry itnet<br>
<b>Sent:</b> Tuesday, 19 June 2018 04:15<br>
<b>Subject:</b> [etherlab-users] How to "upload/download" SDOs in application(*.c file)?<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">I am confused on how to "upload/download" SDOs in an application.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">For example, am I correct by writing codes like:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">------------- application.c ---------------------------------------------------------------------------------------------------<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">....<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  uint16_t sdo_index = 0xf880;        uint8_t sdo_subindex = 1;        uint32_t value = 0;<br>
  ecrt_slave_config_sdo32( sc, sdo_index, sdo_subindex, value);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">  if (ecrt_master_activate(master))         return -1;<br>
    <br>
  size_t *result_size;    uint8_t *target;    const uint8_t *data;    uint32_t *abort_code;<br>
  ecrt_master_sdo_upload(master, 5, 0xf880, 1, target, 4, result_size, abort_code );<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  cycle_task();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">----------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thank in advance for any hint!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Jerry<o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>