<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Error while reading with EM6436 energy meter using modbus4j.jar]]></title><description><![CDATA[<p dir="auto">2012-07-19 02:51:44 PDT<br />
We are using  EM6436 energy meter connected to a PC via RS232 to RS485 converter .<br />
With my own code using modbus4j open source library,we are able to discover the Energy meter and obtain its ID using Modbus4j.<br />
But when I try to read data address (3901 say) of the device(EM6436) using the following code:<br />
SerialParameters params = new SerialParameters();<br />
params.setCommPortId("COM1");<br />
params.setBaudRate(9600);<br />
params.setDataBits(SerialPort.DATABITS_8);<br />
params.setParity(SerialPort.PARITY_EVEN);<br />
params.setStopBits(SerialPort.STOPBITS_1);<br />
ModbusMaster master = null;<br />
ModbusFactory factory = null;<br />
try<br />
{<br />
factory = new ModbusFactory();<br />
master=factory.createRtuMaster(params, 0);<br />
if (master == null){<br />
return;	<br />
}	<br />
master.setTimeout(5000);<br />
master.init();<br />
Object obj = null;<br />
NumericLocator locator = null;<br />
try{<br />
locator = new NumericLocator(1, RegisterRange.HOLDING_REGISTER, 3901, DataType.FOUR_BYTE_FLOAT_SWAPPED);<br />
obj = master.getValue(locator);</p>
<pre><code>	   }catch (Exception e) {
				System.out.println("Exception occured : "+e.getMessage());
			              }
			
System.out.println("Value read"+"for------"+i+"-----------&gt;"+obj);
		
			}
	      }  
	      finally {  
	        master.destroy();  
	      }  
	    }  
</code></pre>
<p dir="auto">We are getting error as Error Response Exception :Invalid data address or sometimes its giving TimeOut exception.<br />
We increase the timeout from 500 to 20000 but still it giving us the TimeOut Exception.<br />
The same code is working fine with the simulators(Modbus PAL , Modbus PLC).<br />
Even  reading the same data address with ModScan32 (with the same connection)is also working but not with the above  code. Please suggest.</p>
]]></description><link>https://forum.mango-os.com/topic/1053/error-while-reading-with-em6436-energy-meter-using-modbus4j-jar</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 07:09:09 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/1053.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Jul 2012 13:05:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Error while reading with EM6436 energy meter using modbus4j.jar on Mon, 06 Aug 2012 19:06:38 GMT]]></title><description><![CDATA[<p dir="auto">Not sure what you mean by this:</p>
<blockquote>
<p dir="auto">the enumerated output like 5.12345E28</p>
</blockquote>
<p dir="auto">How is your data stored? I.e. what does this print out?</p>
<pre><code>System.out.println("Result: "+Integer.toHexString(data*)+" === "+Integer.toString(data*)+" === "+data*);
</code></pre>
<p dir="auto">If it is not stored as a float, then you need to use another data type.</p>
]]></description><link>https://forum.mango-os.com/post/6656</link><guid isPermaLink="true">https://forum.mango-os.com/post/6656</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Mon, 06 Aug 2012 19:06:38 GMT</pubDate></item><item><title><![CDATA[Reply to Error while reading with EM6436 energy meter using modbus4j.jar on Tue, 31 Jul 2012 09:58:32 GMT]]></title><description><![CDATA[<p dir="auto">Previously we are just creating ModbusRequest and getting the ReadHoldingRegistersResponse now instead of that we are creating ModbusRequest and getting ReadResponse .<br />
We tried to convert the values into float with the NumericLocater but it giving us the enumerated output like 5.12345E28<br />
Instead of it we like to get the floating values like 12.234.</p>
]]></description><link>https://forum.mango-os.com/post/6622</link><guid isPermaLink="true">https://forum.mango-os.com/post/6622</guid><dc:creator><![CDATA[piyush]]></dc:creator><pubDate>Tue, 31 Jul 2012 09:58:32 GMT</pubDate></item><item><title><![CDATA[Reply to Error while reading with EM6436 energy meter using modbus4j.jar on Fri, 27 Jul 2012 18:19:03 GMT]]></title><description><![CDATA[<p dir="auto">Note that you are using a different register address than before. Does this explain why it was previously not working?</p>
<p dir="auto">Conversion from/to float/double is the point behind locators. The following should be equivalent to what you are trying to do:</p>
<pre><code>        NumericLocator nl = new NumericLocator(2, RegisterRange.HOLDING_REGISTER, 3926, DataType.FOUR_BYTE_FLOAT);
        float value = master.getValue(nl).floatValue();

</code></pre>
<p dir="auto">Your data type could also be FOUR_BYTE_FLOAT_SWAPPED. Also, locators are stateless, and so can be created once and reused as required.</p>
]]></description><link>https://forum.mango-os.com/post/6618</link><guid isPermaLink="true">https://forum.mango-os.com/post/6618</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Fri, 27 Jul 2012 18:19:03 GMT</pubDate></item><item><title><![CDATA[Reply to Error while reading with EM6436 energy meter using modbus4j.jar on Fri, 27 Jul 2012 09:03:49 GMT]]></title><description><![CDATA[<p dir="auto">Hi mlohbihler,</p>
<p dir="auto">I got the solution for my problem ,i like to ask one more thing is there any way to convert Modbus response into an float or any way to convert response into an float.<br />
Since our device support floating value ,there is no problem with the integer and real values.</p>
<p dir="auto">Thx..</p>
<p dir="auto"><em>Solution is like this:</em></p>
<pre><code> ModbusRequest mreq = new ModbusFactory().createReadRequest(2, 3, 3926, 2);
 ReadResponse mres = (ReadResponse) master.send(mreq);
 short[] data = mres.getShortData();
 int length = 65536 - 3926;
         for (int i = 0; i &lt; length; i++)
             System.out.println("Result: "+Integer.toHexString(data*)+" === "+Integer.toString(data*)+" === "+data*);         
</code></pre>
]]></description><link>https://forum.mango-os.com/post/6617</link><guid isPermaLink="true">https://forum.mango-os.com/post/6617</guid><dc:creator><![CDATA[piyush]]></dc:creator><pubDate>Fri, 27 Jul 2012 09:03:49 GMT</pubDate></item><item><title><![CDATA[Reply to Error while reading with EM6436 energy meter using modbus4j.jar on Fri, 27 Jul 2012 00:33:38 GMT]]></title><description><![CDATA[<p dir="auto">Do you have Mango? You could try the discovery tools in there to see what's going on in your device.</p>
<p dir="auto">Otherwise, it's hard to troubleshoot something that works in some cases but not in others without being able to test it personally. To deal with your issues with code versions, i suggest you download the latest jars (modbus4J and seroUtils) from the SF CVS.</p>
]]></description><link>https://forum.mango-os.com/post/6614</link><guid isPermaLink="true">https://forum.mango-os.com/post/6614</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Fri, 27 Jul 2012 00:33:38 GMT</pubDate></item><item><title><![CDATA[Reply to Error while reading with EM6436 energy meter using modbus4j.jar on Thu, 26 Jul 2012 09:15:11 GMT]]></title><description><![CDATA[<p dir="auto">Hi mlohbihler,</p>
<p dir="auto">Thx for the information.</p>
<p dir="auto">The code we posted is used by use and we also tried the RTU sample code.<br />
The sample code given by mango to read RTU device register there they used one line code to read the value on device i.e<br />
master.getValue(7, RegisterRange.HOLDING_REGISTER, 1000, DataType.FOUR_BYTE_FLOAT_SWAPPED)</p>
<p dir="auto">We tried to use this particular line in our code but we are not getting this method in modbus4j.jar</p>
<p dir="auto">In your previous post you mentioned about the register indexing i.e 0 used by modbus4j and 1 by ModScan ,we also tried to read register from 3900,1000,2000 etc...but still we are geting error like</p>
<ol>
<li>Illegal register address (When register address is 3901)</li>
<li>TimeOut exception (When register address is 3900)</li>
</ol>
<p dir="auto">Similarly we tried to read the register value using ModbusLocater ,this method is also not get imported.<br />
Sample code for ModbusLocater which we tried is like this:</p>
<p dir="auto">// Define the point locator.<br />
ModbusLocator loc = new ModbusLocator(1, RegisterRange.HOLDING_REGISTER, 0, DataType.TWO_BYTE_INT_UNSIGNED);</p>
<p dir="auto">// Set the point value<br />
master.setValue(loc, 1800);</p>
<p dir="auto">// Get the point value<br />
System.out.println(master.getValue(loc));</p>
<p dir="auto">Can you suggest anything on it.</p>
]]></description><link>https://forum.mango-os.com/post/6611</link><guid isPermaLink="true">https://forum.mango-os.com/post/6611</guid><dc:creator><![CDATA[piyush]]></dc:creator><pubDate>Thu, 26 Jul 2012 09:15:11 GMT</pubDate></item><item><title><![CDATA[Reply to Error while reading with EM6436 energy meter using modbus4j.jar on Wed, 25 Jul 2012 18:05:15 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">We tried the sample code provided by mango community(RTU example),but we are not getting particular method like ...</p>
</blockquote>
<p dir="auto">That code looks old. Changes to Modbus4J have occurred since then. From your other code samples, it looks like you've figured out the new ways doing things, so i'm not sure what your question in.</p>
]]></description><link>https://forum.mango-os.com/post/6608</link><guid isPermaLink="true">https://forum.mango-os.com/post/6608</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Wed, 25 Jul 2012 18:05:15 GMT</pubDate></item><item><title><![CDATA[Reply to Error while reading with EM6436 energy meter using modbus4j.jar on Wed, 25 Jul 2012 17:57:29 GMT]]></title><description><![CDATA[<p dir="auto">Note that Modbus4J uses 0-indexing for registers. I don't recall precisely, but perhaps ModScan uses 1-indexing? So, have you tried reading from register 3900 instead?</p>
]]></description><link>https://forum.mango-os.com/post/6607</link><guid isPermaLink="true">https://forum.mango-os.com/post/6607</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Wed, 25 Jul 2012 17:57:29 GMT</pubDate></item><item><title><![CDATA[Reply to Error while reading with EM6436 energy meter using modbus4j.jar on Wed, 25 Jul 2012 16:31:06 GMT]]></title><description><![CDATA[<p dir="auto">We are using Mango 1.13 version to perform the reading of Modbus RTU energy meter device EM6436 register value and we are able to read the register values of energy meter device.<br />
We tried the sample code provided by mango community(RTU example),but we are not getting particular method like</p>
<ol>
<li>master.getValue(7, RegisterRange.HOLDING_REGISTER, 1000, DataType.FOUR_BYTE_FLOAT_SWAPPED)</li>
<li>ModbusLocator loc = new ModbusLocator(1, RegisterRange.HOLDING_REGISTER, 0, DataType.TWO_BYTE_INT_UNSIGNED);</li>
</ol>
<p dir="auto">Can you suggest some solution for reading register value from Modbus RTU device, since we are using modbus4j.jar for the same and is there any latest seroUtil and modbus jar available which support above mentioned function.</p>
]]></description><link>https://forum.mango-os.com/post/6606</link><guid isPermaLink="true">https://forum.mango-os.com/post/6606</guid><dc:creator><![CDATA[piyush]]></dc:creator><pubDate>Wed, 25 Jul 2012 16:31:06 GMT</pubDate></item></channel></rss>