diff --git a/Phpmodbus/ModbusMasterUdp.php b/Phpmodbus/ModbusMasterUdp.php index 78f3e01..2cb45f4 100644 --- a/Phpmodbus/ModbusMasterUdp.php +++ b/Phpmodbus/ModbusMasterUdp.php @@ -441,8 +441,7 @@ class ModbusMasterUdp { * @return string */ private function writeMultipleCoilsPacketBuilder($unitId, $reference, $data){ - $dataLen = 0; - $endianness = 0; + $dataLen = 0; // build bool stream to the WORD array $data_word_stream = array(); $data_word = 0; @@ -567,7 +566,6 @@ class ModbusMasterUdp { */ private function writeMultipleRegisterPacketBuilder($unitId, $reference, $data, $dataTypes){ $dataLen = 0; - $endianness = 0; // build data section $buffer1 = ""; foreach($data as $key=>$dataitem) { @@ -576,11 +574,11 @@ class ModbusMasterUdp { $dataLen += 2; } elseif($dataTypes[$key]=="DINT"){ - $buffer1 .= iecType::iecDINT($dataitem, $endianness); // register values x + $buffer1 .= iecType::iecDINT($dataitem, $this->endianness); // register values x $dataLen += 4; } elseif($dataTypes[$key]=="REAL") { - $buffer1 .= iecType::iecREAL($dataitem, $endianness); // register values x + $buffer1 .= iecType::iecREAL($dataitem, $this->endianness); // register values x $dataLen += 4; } else{ @@ -690,7 +688,6 @@ class ModbusMasterUdp { */ private function readWriteRegistersPacketBuilder($unitId, $referenceRead, $quantity, $referenceWrite, $data, $dataTypes){ $dataLen = 0; - $endianness = 0; // build data section $buffer1 = ""; foreach($data as $key => $dataitem) { @@ -699,11 +696,11 @@ class ModbusMasterUdp { $dataLen += 2; } elseif($dataTypes[$key]=="DINT"){ - $buffer1 .= iecType::iecDINT($dataitem, $endianness); // register values x + $buffer1 .= iecType::iecDINT($dataitem, $this->endianness); // register values x $dataLen += 4; } elseif($dataTypes[$key]=="REAL") { - $buffer1 .= iecType::iecREAL($dataitem, $endianness); // register values x + $buffer1 .= iecType::iecREAL($dataitem, $this->endianness); // register values x $dataLen += 4; } else{ diff --git a/index.php b/index.php new file mode 100644 index 0000000..b95a4cd --- /dev/null +++ b/index.php @@ -0,0 +1,12 @@ + + + + + PhpModbus + + + Examples
+ Tests
+ Tutorials
+ + diff --git a/readme.txt b/readme.txt deleted file mode 100644 index dc308b3..0000000 --- a/readme.txt +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004, 2009 Jan Krakora, Wago (http://www.wago.com) -All rights reserved. - -Phpmodbus library -#################### - -Phpmodbus for PHP is a small and easy-to-use Modbus UDP master library. For more -see project at http://phpmodbus.googlecode.com - -Release notes -=============== - -0.1 -> 0.2.r20 ---------------- -+ Added new class for conversion from received bytes to PHP data types (PhpType class) -+ Added new data conversion using PhpType example -+ Added new alias methods fc3, fc16 and fc23 (ModbusMasterUdp class) -* Fixed problems with the endianess when data written (IecType class) -* Improved commentaries for documentation diff --git a/tests/IecType/output/test.iecByte.php.html b/tests/IecType/output/test.iecByte.php.html new file mode 100644 index 0000000..dc6e8a7 --- /dev/null +++ b/tests/IecType/output/test.iecByte.php.html @@ -0,0 +1 @@ +125
98
0
0
0
0
0
0
0
0
0
0
255
255
255
255
158
88
97
168
\ No newline at end of file diff --git a/tests/IecType/output/test.iecDInt.php.html b/tests/IecType/output/test.iecDInt.php.html new file mode 100644 index 0000000..1abf31b --- /dev/null +++ b/tests/IecType/output/test.iecDInt.php.html @@ -0,0 +1 @@ +Endianing off
0 --> Packet: 0000_0000_
1 --> Packet: 0001_0000_
-1 --> Packet: ffff_ffff_
2147483647 --> Packet: ffff_7fff_
-2147483648 --> Packet: 0000_8000_
Endianing on
0 --> Packet: 0000_0000_
1 --> Packet: 0000_0001_
-1 --> Packet: ffff_ffff_
2147483647 --> Packet: 7fff_ffff_
-2147483648 --> Packet: 8000_0000_
\ No newline at end of file diff --git a/tests/IecType/output/test.iecInt.php.html b/tests/IecType/output/test.iecInt.php.html new file mode 100644 index 0000000..583ad9b --- /dev/null +++ b/tests/IecType/output/test.iecInt.php.html @@ -0,0 +1 @@ +Endianing off
0 --> Packet: 0000_
1 --> Packet: 0001_
-1 --> Packet: ffff_
32767 --> Packet: 7fff_
-32768 --> Packet: 8000_
Endianing on
0 --> Packet: 0000_
1 --> Packet: 0001_
-1 --> Packet: ffff_
32767 --> Packet: 7fff_
-32768 --> Packet: 8000_
\ No newline at end of file diff --git a/tests/IecType/output/test.iecReal.php.html b/tests/IecType/output/test.iecReal.php.html new file mode 100644 index 0000000..31f8272 --- /dev/null +++ b/tests/IecType/output/test.iecReal.php.html @@ -0,0 +1,12 @@ +Endianing off
+0 --> Packet: 0000_0000_
+1 --> Packet: 0000_3f80_
+-2 --> Packet: 0000_c000_
+0.33333333333333 --> Packet: aaab_3eaa_
+25 --> Packet: 0000_41c8_
+Endianing on
+0 --> Packet: 0000_0000_
+1 --> Packet: 3f80_0000_
+-2 --> Packet: c000_0000_
+0.33333333333333 --> Packet: 3eaa_aaab_
+25 --> Packet: 41c8_0000_
diff --git a/tests/ModbusMasterUdp/output/test.fc15fc1.php.html b/tests/ModbusMasterUdp/output/test.fc15fc1.php.html new file mode 100644 index 0000000..9a6ca17 --- /dev/null +++ b/tests/ModbusMasterUdp/output/test.fc15fc1.php.html @@ -0,0 +1,2 @@ + +Fatal error: Call to undefined method ModbusMasterUdp::writeMultipleCoils() in D:\Projects\20081010_phpmodbus\src\trunk\tests\ModbusMasterUdp\test.fc15fc1.php on line 11 diff --git a/tests/ModbusMasterUdp/output/test.fc16fc3.php.html b/tests/ModbusMasterUdp/output/test.fc16fc3.php.html new file mode 100644 index 0000000..00dd046 --- /dev/null +++ b/tests/ModbusMasterUdp/output/test.fc16fc3.php.html @@ -0,0 +1,72 @@ +Array +( + [0] => 0 + [1] => 0 + [2] => 0 + [3] => 1 + [4] => 0 + [5] => 1 + [6] => 0 + [7] => 255 + [8] => 0 + [9] => 255 +) +Array +( + [0] => 0 + [1] => 0 + [2] => 0 + [3] => 1 + [4] => 255 + [5] => 255 + [6] => 127 + [7] => 255 + [8] => 128 + [9] => 0 +) +Array +( + [0] => 0 + [1] => 0 + [2] => 0 + [3] => 0 + [4] => 0 + [5] => 1 + [6] => 0 + [7] => 0 + [8] => 255 + [9] => 255 + [10] => 255 + [11] => 255 + [12] => 255 + [13] => 255 + [14] => 127 + [15] => 255 + [16] => 0 + [17] => 0 + [18] => 128 + [19] => 0 +) +Array +( + [0] => 0 + [1] => 0 + [2] => 0 + [3] => 0 + [4] => 0 + [5] => 0 + [6] => 63 + [7] => 128 + [8] => 0 + [9] => 0 + [10] => 192 + [11] => 0 + [12] => 170 + [13] => 171 + [14] => 62 + [15] => 170 + [16] => 0 + [17] => 0 + [18] => 65 + [19] => 200 +) diff --git a/tests/ModbusMasterUdp/output/test.fc16fc3bind.php.html b/tests/ModbusMasterUdp/output/test.fc16fc3bind.php.html new file mode 100644 index 0000000..63d3aa0 --- /dev/null +++ b/tests/ModbusMasterUdp/output/test.fc16fc3bind.php.html @@ -0,0 +1,11 @@ + +Warning: socket_bind(): unable to bind address [0]: Požadovaná adresa není v tomto kontextu platná. + in D:\Projects\20081010_phpmodbus\src\trunk\Phpmodbus\ModbusMasterUdp.php on line 78 + +Fatal error: Uncaught exception 'Exception' with message 'socket_bind() failed.
Reason: ()Požadovaná adresa není v tomto kontextu platná. +' in D:\Projects\20081010_phpmodbus\src\trunk\Phpmodbus\ModbusMasterUdp.php:80 +Stack trace: +#0 D:\Projects\20081010_phpmodbus\src\trunk\Phpmodbus\ModbusMasterUdp.php(290): ModbusMasterUdp->connect() +#1 D:\Projects\20081010_phpmodbus\src\trunk\tests\ModbusMasterUdp\test.fc16fc3bind.php(13): ModbusMasterUdp->writeMultipleRegister(0, 12288, Array, Array) +#2 {main} + thrown in D:\Projects\20081010_phpmodbus\src\trunk\Phpmodbus\ModbusMasterUdp.php on line 80 diff --git a/tests/ModbusMasterUdp/output/test.fc26.php.html b/tests/ModbusMasterUdp/output/test.fc26.php.html new file mode 100644 index 0000000..7991aa8 --- /dev/null +++ b/tests/ModbusMasterUdp/output/test.fc26.php.html @@ -0,0 +1 @@ +writeMultipleRegister (FC26): DONE \ No newline at end of file diff --git a/tests/ModbusMasterUdp/output/test.fc26bind.php.html b/tests/ModbusMasterUdp/output/test.fc26bind.php.html new file mode 100644 index 0000000..a1a8a23 --- /dev/null +++ b/tests/ModbusMasterUdp/output/test.fc26bind.php.html @@ -0,0 +1,11 @@ + +Warning: socket_bind(): unable to bind address [0]: Požadovaná adresa není v tomto kontextu platná. + in D:\Projects\20081010_phpmodbus\src\trunk\Phpmodbus\ModbusMasterUdp.php on line 78 + +Fatal error: Uncaught exception 'Exception' with message 'socket_bind() failed.
Reason: ()Požadovaná adresa není v tomto kontextu platná. +' in D:\Projects\20081010_phpmodbus\src\trunk\Phpmodbus\ModbusMasterUdp.php:80 +Stack trace: +#0 D:\Projects\20081010_phpmodbus\src\trunk\Phpmodbus\ModbusMasterUdp.php(410): ModbusMasterUdp->connect() +#1 D:\Projects\20081010_phpmodbus\src\trunk\tests\ModbusMasterUdp\test.fc26bind.php(14): ModbusMasterUdp->readWriteRegisters(0, 12288, 6, 12288, Array, Array) +#2 {main} + thrown in D:\Projects\20081010_phpmodbus\src\trunk\Phpmodbus\ModbusMasterUdp.php on line 80 diff --git a/tests/PhpType/output/test.bytes2mixed.php.html b/tests/PhpType/output/test.bytes2mixed.php.html new file mode 100644 index 0000000..952bc9d --- /dev/null +++ b/tests/PhpType/output/test.bytes2mixed.php.html @@ -0,0 +1 @@ +32098
0
0
-1
-25000
25000
\ No newline at end of file diff --git a/tests/PhpType/output/test.bytes2real.php.html b/tests/PhpType/output/test.bytes2real.php.html new file mode 100644 index 0000000..7d44edb --- /dev/null +++ b/tests/PhpType/output/test.bytes2real.php.html @@ -0,0 +1 @@ +1000
2000
1.25
\ No newline at end of file diff --git a/tests/PhpType/output/test.bytes2signedint.php.html b/tests/PhpType/output/test.bytes2signedint.php.html new file mode 100644 index 0000000..a2b10ea --- /dev/null +++ b/tests/PhpType/output/test.bytes2signedint.php.html @@ -0,0 +1 @@ +-1
0
1
-2147483648
2147483647
diff --git a/tests/PhpType/output/test.bytes2string.php.html b/tests/PhpType/output/test.bytes2string.php.html new file mode 100644 index 0000000..31bbf09 --- /dev/null +++ b/tests/PhpType/output/test.bytes2string.php.html @@ -0,0 +1 @@ +eHll oowlr!da
Hello world!
\ No newline at end of file diff --git a/tests/PhpType/output/test.bytes2unsignedint.php.html b/tests/PhpType/output/test.bytes2unsignedint.php.html new file mode 100644 index 0000000..29be8ee --- /dev/null +++ b/tests/PhpType/output/test.bytes2unsignedint.php.html @@ -0,0 +1,6 @@ +float(4294967295) +
int(0) +
int(1) +
float(2147483648) +
int(2147483647) +
diff --git a/tests/PhpType/output/test.strangearray.size.php.html b/tests/PhpType/output/test.strangearray.size.php.html new file mode 100644 index 0000000..d0e619d --- /dev/null +++ b/tests/PhpType/output/test.strangearray.size.php.html @@ -0,0 +1 @@ +Exception 'Data are not in array 2 or 4 bytes'
25602
Exception 'Data are not in array 2 or 4 bytes'
25602
Exception 'Data are not in array 2 or 4 bytes'
\ No newline at end of file diff --git a/tests/PhpType/output/test.strangearray.textarray.php.html b/tests/PhpType/output/test.strangearray.textarray.php.html new file mode 100644 index 0000000..734d099 --- /dev/null +++ b/tests/PhpType/output/test.strangearray.textarray.php.html @@ -0,0 +1 @@ +Exception 'Data are not numeric' \ No newline at end of file