<?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_modbusReadCoil%28%29</id>
	<title>Function modbusReadCoil() - 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_modbusReadCoil%28%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_modbusReadCoil()&amp;action=history"/>
	<updated>2026-04-21T16:21:35Z</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_modbusReadCoil()&amp;diff=395&amp;oldid=prev</id>
		<title>Phrych at 12:45, 20 June 2019</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_modbusReadCoil()&amp;diff=395&amp;oldid=prev"/>
		<updated>2019-06-20T12:45:43Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 12:45, 20 June 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l25&quot; &gt;Line 25:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 25:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Usage ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Usage ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  -- Read value of all outputs from NETIO with IP 10.0.0.105 on port 505&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  -- Read value of all outputs from NETIO with IP 10.0.0.105 on port 505&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;local &lt;/del&gt;function modbusReadCallback(data)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  function modbusReadCallback(data)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    if data.result == 0 then&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    if data.result == 0 then&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      log(string.format(&amp;quot;modbus addr %d, got %s&amp;quot;, data.address, tostring(data.value)))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      log(string.format(&amp;quot;modbus addr %d, got %s&amp;quot;, data.address, tostring(data.value)))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Phrych</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_modbusReadCoil()&amp;diff=393&amp;oldid=prev</id>
		<title>Phrych: Created page with &quot;{{DISPLAYTITLE:function modbusReadCoil()}} Read value from single coil using modbus protocol. The call is asynchronous: the code execution proceeds immediately and when the re...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_modbusReadCoil()&amp;diff=393&amp;oldid=prev"/>
		<updated>2019-06-20T12:36:40Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{DISPLAYTITLE:function modbusReadCoil()}} Read value from single coil using modbus protocol. The call is asynchronous: the code execution proceeds immediately and when the re...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:function modbusReadCoil()}}&lt;br /&gt;
Read value from single coil 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;modbusReadCoil&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 all outputs from NETIO with IP 10.0.0.105 on port 505&lt;br /&gt;
 local 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 coil 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;
 for i = 101,104 do&lt;br /&gt;
   modbusReadCoil{deviceAddress='10.0.0.105', port=505, timeout=6, address=i, callback=modbusReadCallback}&lt;br /&gt;
 end&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>