Open ELGUEROUEL opened 4 years ago
I'm sorry, but i have no cpu to test it. Can anyone else please test and debug this issue?
thanks for your replay . I tested it . I have a cpu 1500
If you want lo read a float value (in PLC named REAL), use s7_phphelper::getS7_Real. I test it on S7-300 CPU and work well. Remember to read 4bytes for every REAL value.
require_once("../src/phosphor7.php");
require_once("../src/s7_phphelper.php");
$c = new TSnap7MicroClient();
$c->ConnectTo("192.168.1.216", 0, 2);
$floatBuff = "";
$c->DBRead(101, 38, 8, $floatBuff); // from DB101.DBB38 for 8 bytes
$c->Disconnect();
$fVal = s7_phphelper::getS7_Real($floatBuff, 0);
echo "1st float: " . $fVal . "\n"; // 12.34 in my PLC
$fVal = s7_phphelper::getS7_Real($floatBuff, 4);
echo "2nd float: " . $fVal . "\n"; // 5.6 in my PLC
For S7-1500 the data block must have the flag optimized block off.
require_once("../src/phosphor7.php");
$c = new TSnap7MicroClient();
$c->ConnectTo("10.11.6.2", 0, 0);
$buffer = ""; $c->DBRead(7, 48, 2, $buffer); // I want read value of energy var_dump(bin2hex($buffer)); $c->Disconnect(); I have in output 477d but it is false ( because is not real)