-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodbus.php
More file actions
32 lines (30 loc) · 1.1 KB
/
modbus.php
File metadata and controls
32 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
include("PhpSerialModbus.php");
if (isset($_POST["UnitID"]) && isset($_POST["Address"]) && isset($_POST["Quantity"]) && isset($_POST["FC"]))
{
$UnitID=$_POST["UnitID"];
$Address=$_POST["Address"];
$Quantity=$_POST["Quantity"];
//$FunctionCode=$_POST["FunctionCode"];
$FunCode=$_POST["FC"];
//echo "Unit ID is: $UnitID";
//echo "Address is: $Address";
//echo "Quantity is: $Quantity";
//echo "$FunCode";
$modbus = new PhpSerialModbus;
$modbus->deviceInit('/dev/ttyUSB0',1200,'none',8,1,'none');
$modbus->deviceOpen();
$modbus->debug = true;
$result=$modbus->sendQuery($UnitID,$FunCode,"$Address",$Quantity);
sleep(2);
$jsonresult=json_encode($result);
//print_r($jsonresult);
session_start();
$_SESSION["a"]=$result;
//echo $_SESSION["a"];
$modbus->deviceClose();
//header("Location: http://192.168.1.101:1880/ui/#!/0?socketid=jXgKx74Sqk5BUxoeAAAA");
echo '<a href="Modbus.html"><br /><br />Return to Modbus Page</a>';
//exit;
}
?>