This shows you the differences between two versions of the page.
uphp:library_functions:modbus [2021/04/09 09:07] admin |
uphp:library_functions:modbus [2021/09/13 05:57] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Modbus Library Reference====== | ||
- | |||
- | Available in < | ||
- | |||
- | The Modbus include library contains functions and defines as shown below. | ||
- | |||
- | **Usage: | ||
- | |||
- | < | ||
- | |||
- | |||
- | |||
- | |||
- | ===== 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: | ||
- | |||
- | ^FUNCTION NAME^PARAMETER(S)^RETURN^LIBRARY^DESCRIPTION^ | ||
- | |[[mb_get_error_string]]|< | ||
- | |[[mb_set_float_be_0x10]]|< | ||
- | |[[mb_set_float_le_0x10]]|< | ||
- | |[[mb_set_int16_0x03]]|< | ||
- | |[[mb_set_int16_0x10]]|< | ||
- | |[[mb_set_uint32_be_0x10]]|< | ||
- | |[[mb_set_uint32_le_0x10]]|< | ||
- | |||
- | ===== Example ===== | ||
- | |||
- | <code php> | ||
- | < | ||
- | // assume a modbus TCP connection on ID 1 on Channel 2 | ||
- | $DEBUG=1; | ||
- | |||
- | include("/ | ||
- | |||
- | $id=1; | ||
- | $bus=2; | ||
- | $reg=1; | ||
- | $cmd=100; | ||
- | $retries=1; | ||
- | |||
- | $res=mb_set_int16_0x03($id, | ||
- | print(" | ||
- | $reg++; | ||
- | $res=mb_set_int16_0x10($id, | ||
- | print(" | ||
- | $reg+=2; | ||
- | $res=mb_set_uint32_le_0x10($id, | ||
- | print(" | ||
- | $reg+=2; | ||
- | $res=mb_set_uint32_be_0x10($id, | ||
- | print(" | ||
- | $reg+=2; | ||
- | $res=mb_set_float_le_0x10($id, | ||
- | print(" | ||
- | $reg+=2; | ||
- | $res=mb_set_float_be_0x10($id, | ||
- | print(" | ||
- | ?></ | ||
- | |||
- | </ | ||