SendQuery ($slaveId, $functionCode, $registerAddress, $regNumOrCount, $response = true) Initialize the serial port with the given paramters Class methods and propertiesÄeviceInit ($port='/dev/ttyUSB0', $baud=115200, $parity='none', $char=8, $sbits=1, $flow='none') In the above example in order to get decimal contents of registry 310C, we have to concatenate the first two bytes received and we will obtain "04be", that in decimal is 1214 (the battery voltage * 100). In order to convert this HEX data to readable format you have to convert the bytes received two by two. Modbus registry datas are 16bit (8bit for Hi byte and 8bit for Lo byte) so the array count is 6. The output is an array containing the bytes received by the slave in HEX format.
0 Comments
Leave a Reply. |