0.3 Release
This commit is contained in:
@@ -0,0 +1 @@
|
||||
eHll oowlr!da<br>Hello world!<br>
|
||||
@@ -0,0 +1 @@
|
||||
Exception 'Data are not in array 2 or 4 bytes'<br>25602<br>Exception 'Data are not in array 2 or 4 bytes'<br>25602<br>Exception 'Data are not in array 2 or 4 bytes'<br>
|
||||
@@ -0,0 +1 @@
|
||||
Exception 'Data are not numeric'
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
|
||||
|
||||
// Received bytes interpreting 3 REAL values (6 words)
|
||||
$data = array( // String "Hello word!"
|
||||
0x48, //H
|
||||
0x65, //e
|
||||
0x6c, //l
|
||||
0x6c, //l
|
||||
0x6f, //o
|
||||
0x20, //
|
||||
0x77, //w
|
||||
0x6f, //o
|
||||
0x72, //r
|
||||
0x6c, //l
|
||||
0x64, //d
|
||||
0x21, //!
|
||||
0x00, //\0
|
||||
0x61, //a
|
||||
0x61 //a
|
||||
);
|
||||
|
||||
// Print string interpretation of the values
|
||||
echo PhpType::bytes2string($data) . "<br>";
|
||||
echo PhpType::bytes2string($data, true) . "<br>";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
|
||||
|
||||
// Received bytes interpreting Mixed values
|
||||
$data = Array (
|
||||
"0" => 100, // 32098 (DINT)
|
||||
"1" => 2,
|
||||
"2" => 0,
|
||||
"3" => 0,
|
||||
"4" => 100, // 32098 (DINT)
|
||||
"5" => 2
|
||||
);
|
||||
|
||||
// Print mixed values
|
||||
try {
|
||||
echo PhpType::bytes2unsignedInt(array_slice($data, 0, 1)) . "<br>";
|
||||
} catch(Exception $e) {
|
||||
echo "Exception 'Data are not in array 2 or 4 bytes'". "<br>";
|
||||
}
|
||||
try {
|
||||
echo PhpType::bytes2unsignedInt(array_slice($data, 0, 2)). "<br>";
|
||||
} catch(Exception $e) {
|
||||
echo "Exception 'Data are not in array 2 or 4 bytes'". "<br>";
|
||||
}
|
||||
try {
|
||||
echo PhpType::bytes2unsignedInt(array_slice($data, 0, 3)). "<br>";
|
||||
} catch(Exception $e) {
|
||||
echo "Exception 'Data are not in array 2 or 4 bytes'". "<br>";
|
||||
}
|
||||
try {
|
||||
echo PhpType::bytes2unsignedInt(array_slice($data, 0, 4)). "<br>";
|
||||
} catch(Exception $e) {
|
||||
echo "Exception 'Data are not in array 2 or 4 bytes'". "<br>";
|
||||
}
|
||||
try {
|
||||
echo PhpType::bytes2unsignedInt(array_slice($data, 0, 5)). "<br>";
|
||||
} catch(Exception $e) {
|
||||
echo "Exception 'Data are not in array 2 or 4 bytes'". "<br>";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
|
||||
|
||||
// Received bytes interpreting Mixed values
|
||||
$data = Array (
|
||||
"0" => 100, // 32098 (DINT)
|
||||
"1" => "e",
|
||||
"2" => 0,
|
||||
"3" => 0
|
||||
);
|
||||
|
||||
// Print mixed values
|
||||
try {
|
||||
echo PhpType::bytes2unsignedInt(array_slice($data, 0, 4));
|
||||
} catch(Exception $e) {
|
||||
echo "Exception 'Data are not numeric'";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user