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
+15 -14
View File
@@ -1,25 +1,26 @@
<?php
require_once dirname(__FILE__) . '/../Phpmodbus/ModbusMaster.php';
use PHPModbus\ModbusMaster;
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
// Data to be writen
$data = array(TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
// Data to be written - supports both 0/1 and booleans (true, false)
$data = array(
1, 0, 1, 1, 0, 1, 1, 1,
1, 1, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
);
try {
// FC15
$modbus->writeMultipleCoils(0, 12288, $data);
}
catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
// FC15
$modbus->writeMultipleCoils(0, 12288, $data);
} catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print status information