<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Exception with ReadNbrSlaves function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ccd3723ac4/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ccd3723ac4/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/ccd3723ac4/</id><updated>2025-10-31T02:31:20.881000Z</updated><subtitle>Recent posts to Exception with ReadNbrSlaves function</subtitle><entry><title>Exception with ReadNbrSlaves function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ccd3723ac4/?limit=250#eaad" rel="alternate"/><published>2025-10-31T02:31:20.881000Z</published><updated>2025-10-31T02:31:20.881000Z</updated><author><name>kporter</name><uri>https://forge.codesys.com/u/kporter/</uri></author><id>https://forge.codesys.com5156284362c44a01193a4e89d1c2ed648977246c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I've been playing with the code using the Windows soft master and the ReadNbrSlaves function block seems to work here: &lt;a href="https://content.helpme-codesys.com/en/libs/EtherCATStack/4.8.0.0/EtherCATStack/pou-ETCMasterStack/DynamicConfig/fld-DynamicConfig.html" rel="nofollow"&gt;https://content.helpme-codesys.com/en/libs/EtherCATStack/4.8.0.0/EtherCATStack/pou-ETCMasterStack/DynamicConfig/fld-DynamicConfig.html&lt;/a&gt; &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Exception with ReadNbrSlaves function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ccd3723ac4/?limit=25#467f" rel="alternate"/><published>2021-09-24T07:50:46.763000Z</published><updated>2021-09-24T07:50:46.763000Z</updated><author><name>paulpotat</name><uri>https://forge.codesys.com/u/paulpotat/</uri></author><id>https://forge.codesys.com0f27b3354087d6adf1707b3305792c9f54a34765</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Please any help is appreciated, even if it's not a full solution to my issue (;-;)&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Exception with ReadNbrSlaves function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ccd3723ac4/?limit=25#5ff8" rel="alternate"/><published>2021-09-16T13:04:03.419000Z</published><updated>2021-09-16T13:04:03.419000Z</updated><author><name>paulpotat</name><uri>https://forge.codesys.com/u/paulpotat/</uri></author><id>https://forge.codesys.comdf62ebbc53081431a111d6bb10afd05306d3db19</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;br/&gt;
I'm trying to scan an ethercat network to compute the number of slaves on it with CodeSys. &lt;br/&gt;
My ethercat configuration look like this :&lt;/p&gt;
&lt;p&gt;Ethercat Master&lt;br/&gt;
├─ Ethercat Slave A&lt;br/&gt;
├─ Ethercat Slave B&lt;br/&gt;
└─ Ethercat Slave C&lt;/p&gt;
&lt;p&gt;I'm using a function called "ReadNbrSlaves" from the EtherCATStackLibrary (documentation &lt;a class="" href="https://help.codesys.com/webapp/ReXz9y6WHLcBNLo196J6liDlFfc%2FReadNbrSlaves;product=EtherCATStack;version=3.5.16.0" rel="nofollow"&gt;here&lt;/a&gt;). I tried with the provided code example from the documentation which is :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;PROGRAM&lt;/span&gt; &lt;span class="n"&gt;PLC_PRG&lt;/span&gt;
&lt;span class="n"&gt;VAR&lt;/span&gt;
   &lt;span class="n"&gt;readnbr&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ReadNbrSlaves&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="n"&gt;xRead&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;TRUE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="n"&gt;wNbrSlaves&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;WORD&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;

&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="n"&gt;xRead&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   &lt;span class="n"&gt;readnbr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usiCom&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;DWORD_TO_USINT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Ethercat_Master&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;InstanceNumber&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="n"&gt;readnbr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xExecute&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;TRUE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;udiTimeOut&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="n"&gt;readnbr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xDone&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
      &lt;span class="n"&gt;xRead&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;FALSE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;wNbrSlaves&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;readnbr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wNumberSlaves&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;readnbr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xExecute&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;FALSE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="n"&gt;END_IF&lt;/span&gt;
&lt;span class="n"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I can flash this code on the PLC without errors.&lt;br/&gt;
However as soon as I try to run the program I get a message saying "No source code available for this object because it is in the compiled library 'caa behaviour model 3.5.11 (caa technical workgroup)'. Do you want to browse for the original library in order to display the source code ?"&lt;br/&gt;
&lt;img src="./attachment/Exception_Message.PNG" width="50%"/&gt;&lt;/p&gt;
&lt;p&gt;If I say "Yes" the file browser pops up but I have no idea what CodeSys is expecting me to point at... If I say "No" another error message pops-up and I get an exception that stops the program. &lt;br/&gt;
&lt;img src="./attachment/warning.PNG" width="50%"/&gt;&lt;/p&gt;
&lt;p&gt;Now the really weird part is that if I add a 50 ms timer before starting the execution of "ReadNbrSlaves" it works just fine (the result of the function is correct and there is no more exceptions).&lt;/p&gt;
&lt;p&gt;Does somebody know why this happens ? By the way I'm using CodeSys 3.5.16 and the program is running on a raspbian.&lt;br/&gt;
Thank you for your help&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>