<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.netio-products.com/index.php?action=history&amp;feed=atom&amp;title=Function_modbusReadDiscreteInput%28%29</id>
	<title>Function modbusReadDiscreteInput() - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.netio-products.com/index.php?action=history&amp;feed=atom&amp;title=Function_modbusReadDiscreteInput%28%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_modbusReadDiscreteInput()&amp;action=history"/>
	<updated>2026-04-21T16:19:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_modbusReadDiscreteInput()&amp;diff=394&amp;oldid=prev</id>
		<title>Phrych: Created page with &quot;{{DISPLAYTITLE:function modbusReadDiscreteInput()}} Read value from discrete input using modbus protocol. The call is asynchronous: the code execution proceeds immediately and...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_modbusReadDiscreteInput()&amp;diff=394&amp;oldid=prev"/>
		<updated>2019-06-20T12:45:18Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{DISPLAYTITLE:function modbusReadDiscreteInput()}} Read value from discrete input using modbus protocol. The call is asynchronous: the code execution proceeds immediately and...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:function modbusReadDiscreteInput()}}&lt;br /&gt;
Read value from discrete input using modbus protocol. The call is asynchronous: the code execution proceeds immediately and when the response arrives, callback function is called.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;modbusReadDiscreteInput&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
 &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; config{&amp;lt;code&amp;gt;deviceAddress&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;callback&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;,&amp;lt;code style=&amp;quot;color: #777&amp;quot;&amp;gt;port&amp;lt;/code&amp;gt;, &amp;lt;code style=&amp;quot;color: #777&amp;quot;&amp;gt;timeout&amp;lt;/code&amp;gt;}&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;deviceAddress&amp;lt;/code&amp;gt; IP address of device&lt;br /&gt;
* &amp;lt;i&amp;gt;function{response}&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;callback&amp;lt;/code&amp;gt; this function is called when response arrives&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; number of the coil&lt;br /&gt;
* optional &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;port&amp;lt;/code&amp;gt; numer of port (default 502)&lt;br /&gt;
* optional &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;timeout&amp;lt;/code&amp;gt; maximum seconds to wait for response (default 30)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Callback Parameters ===&lt;br /&gt;
 &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; response{&amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;errInfo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;}&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt; error code of the response (0 is success)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;errInfo&amp;lt;/code&amp;gt; error description (if result&amp;gt;0)&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; number of the coil&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; value of the coil&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 nil&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 -- Read value of discrete input on IP address 10.0.0.105, on port 505 with address 102&lt;br /&gt;
 function modbusReadCallback(data)&lt;br /&gt;
   if data.result == 0 then&lt;br /&gt;
     log(string.format(&amp;quot;modbus addr %d, got %s&amp;quot;, data.address, tostring(data.value)))&lt;br /&gt;
   else&lt;br /&gt;
     log(string.format(&amp;quot;modbus addr %d failed with error %d: %s&amp;quot;, data.address, data.result, data.errorInfo))&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 modbusReadCoil{deviceAddress='10.0.0.105', port=505, timeout=6, address=102, callback=modbusReadCallback}&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
Netio FirmWare 3.3.0+&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Phrych</name></author>
		
	</entry>
</feed>