fixed the examples
This commit is contained in:
+15
-14
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user