fixed the examples

This commit is contained in:
2016-11-20 11:29:09 +01:00
parent 61e7a690eb
commit 4256b6cef7
13 changed files with 203 additions and 209 deletions
+10 -13
View File
@@ -1,6 +1,6 @@
<?php
require_once dirname(__FILE__) . '/../Phpmodbus/ModbusMaster.php';
use PHPModbus\ModbusMaster;
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
@@ -8,21 +8,18 @@ $modbus = new ModbusMaster("192.192.15.51", "UDP");
// Data to be writen
$bitValue = true;
$bitNumber = 2;
$andMask = 0xFFFF ^ pow(2, $bitNumber) ;
$orMask = 0x0000 ^ (pow(2, $bitNumber) * $bitValue ) ;
$andMask = 0xFFFF ^ pow(2, $bitNumber);
$orMask = 0x0000 ^ (pow(2, $bitNumber) * $bitValue);
try {
// FC22
$modbus->maskWriteRegister(0, 12288, $andMask, $orMask);
}
catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
// FC22
$modbus->maskWriteRegister(0, 12288, $andMask, $orMask);
} catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print status information
echo $modbus;
?>