User Tools

Site Tools


uphp:library_functions:modbus

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
uphp:library_functions:modbus [2021/04/09 08:55]
admin created
uphp:library_functions:modbus [2021/09/13 05:57] (current)
Line 5: Line 5:
 The Modbus include library contains functions and defines as shown below. The Modbus include library contains functions and defines as shown below.
  
-Usage: +**Usage:** 
  
-<html><pre>include("/lib/uphp/modbus.inc");</pre></html>+<html><pre>include("/lib/uphp/modbus.inc");</pre></html> 
  
 +**Source:**
 +
 +[[modbus.inc|View Source]]
 +
 +
 +===== Defines =====
 +
 +^DEFINE^VALUE^
 +|MB_ILLEGAL_FUNCTION|-1|
 +|MB_ILLEGAL_ADDRESS|-2|
 +|MB_ILLEGAL_VALUE|-3|
 +|MB_SLAVE_FAILURE|-4|
 +
 +===== Functions =====
 Click on the function name for further details: Click on the function name for further details:
  
Line 19: Line 33:
 |[[mb_set_uint32_be_0x10]]|<html><span style="color:green">int<span style="color:blue"> id, <span style="color:green">int<span style="color:blue"> bus, <span style="color:green">int<span style="color:blue"> reg, <span style="color:green">int<span style="color:black"> val, <span style="color:green">int<span style="color:blue"> retries</html>|<html><span style="color:green">int<span style="color:blue"></html>|[[modbus]]|Set a modbus UINT32 in big endian using function 10h| |[[mb_set_uint32_be_0x10]]|<html><span style="color:green">int<span style="color:blue"> id, <span style="color:green">int<span style="color:blue"> bus, <span style="color:green">int<span style="color:blue"> reg, <span style="color:green">int<span style="color:black"> val, <span style="color:green">int<span style="color:blue"> retries</html>|<html><span style="color:green">int<span style="color:blue"></html>|[[modbus]]|Set a modbus UINT32 in big endian using function 10h|
 |[[mb_set_uint32_le_0x10]]|<html><span style="color:green">int<span style="color:blue"> id, <span style="color:green">int<span style="color:blue"> bus, <span style="color:green">int<span style="color:blue"> reg, <span style="color:green">int<span style="color:black"> val, <span style="color:green">int<span style="color:blue"> retries</html>|<html><span style="color:green">int<span style="color:blue"></html>|[[modbus]]|Set a modbus UINT32 in little endian using function 10h| |[[mb_set_uint32_le_0x10]]|<html><span style="color:green">int<span style="color:blue"> id, <span style="color:green">int<span style="color:blue"> bus, <span style="color:green">int<span style="color:blue"> reg, <span style="color:green">int<span style="color:black"> val, <span style="color:green">int<span style="color:blue"> retries</html>|<html><span style="color:green">int<span style="color:blue"></html>|[[modbus]]|Set a modbus UINT32 in little endian using function 10h|
 +
 +===== Example =====
 +
 +<code php>
 +<pre><?
 +// assume a modbus TCP connection on ID 1 on Channel 2
 +$DEBUG=1;
 +
 +include("/lib/uphp/modbus.inc");
 +
 +$id=1;
 +$bus=2;
 +$reg=1;
 +$cmd=100;
 +$retries=1;
 +
 +$res=mb_set_int16_0x03($id, $bus, $reg, $cmd, $retries);
 +print("\r\nSet INT 16 func 03 result is : ".$res." ".mb_get_error_string($res));
 +$reg++;
 +$res=mb_set_int16_0x10($id, $bus, $reg, $cmd, $retries);
 +print("\r\nSet INT 16 func 10 result is : ".$res." ".mb_get_error_string($res));
 +$reg+=2;
 +$res=mb_set_uint32_le_0x10($id, $bus, $reg, $cmd, $retries);
 +print("\r\mb_set_uint32_le_0x10 result is : ".$res." ".mb_get_error_string($res));
 +$reg+=2;
 +$res=mb_set_uint32_be_0x10($id, $bus, $reg, $cmd, $retries);
 +print("\r\mb_set_uint32_be_0x10 result is : ".$res." ".mb_get_error_string($res));
 +$reg+=2;
 +$res=mb_set_float_le_0x10($id, $bus, $reg, $cmd, $retries);
 +print("\r\mb_set_float_le_0x10 result is : ".$res." ".mb_get_error_string($res));
 +$reg+=2;
 +$res=mb_set_float_be_0x10($id, $bus, $reg, $cmd, $retries);
 +print("\r\mb_set_float_be_0x10 result is : ".$res." ".mb_get_error_string($res));
 +?></pre>
 +
 +</code>
  
uphp/library_functions/modbus.1617958516.txt.gz · Last modified: 2021/09/13 05:56 (external edit)