6 Commits
Author SHA1 Message Date
John Long bb0cdd467a 0.8 release 2013-11-29 22:27:16 -06:00
John Long 9ef8e72f3e Add syntax declaration to code block in README.md 2013-06-14 09:03:03 -04:00
John Long ad507ed46c Create README.md 2013-06-14 08:01:51 -05:00
John Long 5bb5dfe654 Added tag 0.7 for changeset 5885b1a0d0dc 2013-06-14 07:43:52 -05:00
John Long 83d9baa9f6 0.7 release 2013-06-14 07:43:45 -05:00
John Long 753bff38ec Added tag 0.6 for changeset 079f8ac1f49f 2013-06-14 07:43:03 -05:00
42 changed files with 373 additions and 481 deletions
+2
View File
@@ -3,3 +3,5 @@ a7f90c18859d31922bdd8c61299e2790f5e2eb1a 0.3
bdf8b3f414c4d08fc0edf9fd1953f55db26e4bac 0.4 bdf8b3f414c4d08fc0edf9fd1953f55db26e4bac 0.4
1e09b0da7d8c62a9a292ee51540feac9de4c1222 0.4.1 1e09b0da7d8c62a9a292ee51540feac9de4c1222 0.4.1
e1262f028e180c2719564f840ffa1a9f8672b6be 0.5 e1262f028e180c2719564f840ffa1a9f8672b6be 0.5
079f8ac1f49faf4e6bbb84d62c39eee1507805f2 0.6
5885b1a0d0dc89577eeb871ee2c3fba8e70dd4fb 0.7
+3 -3
View File
@@ -1,12 +1,12 @@
<?php <?php
/** /**
* Phpmodbus Copyright (c) 2004, 2010 Jan Krakora, WAGO Kontakttechnik GmbH & Co. KG (http://www.wago.com) * Phpmodbus Copyright (c) 2004, 2013 Jan Krakora
* *
* This source file is subject to the "PhpModbus license" that is bundled * This source file is subject to the "PhpModbus license" that is bundled
* with this package in the file license.txt. * with this package in the file license.txt.
* *
* @author Jan Krakora * @author Jan Krakora
* @copyright Copyright (c) 2004, 2010 Jan Krakora, WAGO Kontakttechnik GmbH & Co. KG (http://www.wago.com) * @copyright Copyright (c) 2004, 2013 Jan Krakora
* @license PhpModbus license * @license PhpModbus license
* @category Phpmodbus * @category Phpmodbus
* @package Phpmodbus * @package Phpmodbus
@@ -20,7 +20,7 @@
* data types to a IEC data type. * data types to a IEC data type.
* *
* @author Jan Krakora * @author Jan Krakora
* @copyright Copyright (c) 2004, 2010 Jan Krakora, WAGO Kontakttechnik GmbH & Co. KG (http://www.wago.com) * @copyright Copyright (c) 2004, 2010 Jan Krakora
* @package Phpmodbus * @package Phpmodbus
*/ */
class IecType { class IecType {
+208 -3
View File
@@ -1,12 +1,12 @@
<?php <?php
/** /**
* Phpmodbus Copyright (c) 2004, 2012 Jan Krakora * Phpmodbus Copyright (c) 2004, 2013 Jan Krakora
* *
* This source file is subject to the "PhpModbus license" that is bundled * This source file is subject to the "PhpModbus license" that is bundled
* with this package in the file license.txt. * with this package in the file license.txt.
* *
* *
* @copyright Copyright (c) 2004, 2012 Jan Krakora * @copyright Copyright (c) 2004, 2013 Jan Krakora
* @license PhpModbus license * @license PhpModbus license
* @category Phpmodbus * @category Phpmodbus
* @tutorial Phpmodbus.pkg * @tutorial Phpmodbus.pkg
@@ -27,13 +27,15 @@ require_once dirname(__FILE__) . '/PhpType.php';
* - FC 1: read coils * - FC 1: read coils
* - FC 2: read input discretes * - FC 2: read input discretes
* - FC 3: read multiple registers * - FC 3: read multiple registers
* - FC 4: read multiple input registers
* - FC 5: write single coil
* - FC 6: write single register * - FC 6: write single register
* - FC 15: write multiple coils * - FC 15: write multiple coils
* - FC 16: write multiple registers * - FC 16: write multiple registers
* - FC 23: read write registers * - FC 23: read write registers
* *
* @author Jan Krakora * @author Jan Krakora
* @copyright Copyright (c) 2004, 2012 Jan Krakora * @copyright Copyright (c) 2004, 2013 Jan Krakora
* @package Phpmodbus * @package Phpmodbus
* *
*/ */
@@ -98,6 +100,8 @@ class ModbusMaster {
$this->status .= "Bound\n"; $this->status .= "Bound\n";
} }
} }
// Socket settings
socket_set_option($this->sock, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 1, 'usec' => 0));
// Connect the socket // Connect the socket
$result = @socket_connect($this->sock, $this->host, $this->port); $result = @socket_connect($this->sock, $this->host, $this->port);
if ($result === false) { if ($result === false) {
@@ -510,6 +514,207 @@ class ModbusMaster {
return $data; return $data;
} }
/**
* readMultipleInputRegisters
*
* Modbus function FC 4(0x04) - Read Multiple Input Registers.
*
* This function reads {@link $quantity} of Words (2 bytes) from reference
* {@link $referenceRead} of a memory of a Modbus device given by
* {@link $unitId}.
*
*
* @param int $unitId usually ID of Modbus device
* @param int $reference Reference in the device memory to read data.
* @param int $quantity Amounth of the data to be read from device.
* @return false|Array Success flag or array of received data.
*/
function readMultipleInputRegisters($unitId, $reference, $quantity){
$this->status .= "readMultipleInputRegisters: START\n";
// connect
$this->connect();
// send FC 4
$packet = $this->readMultipleInputRegistersPacketBuilder($unitId, $reference, $quantity);
$this->status .= $this->printPacket($packet);
$this->send($packet);
// receive response
$rpacket = $this->rec();
$this->status .= $this->printPacket($rpacket);
// parse packet
$receivedData = $this->readMultipleInputRegistersParser($rpacket);
// disconnect
$this->disconnect();
$this->status .= "readMultipleInputRegisters: DONE\n";
// return
return $receivedData;
}
/**
* fc4
*
* Alias to {@link readMultipleInputRegisters} method.
*
* @param int $unitId
* @param int $reference
* @param int $quantity
* @return false|Array
*/
function fc4($unitId, $reference, $quantity){
return $this->readMultipleInputRegisters($unitId, $reference, $quantity);
}
/**
* readMultipleInputRegistersPacketBuilder
*
* Packet FC 4 builder - read multiple input registers
*
* @param int $unitId
* @param int $reference
* @param int $quantity
* @return string
*/
private function readMultipleInputRegistersPacketBuilder($unitId, $reference, $quantity){
$dataLen = 0;
// build data section
$buffer1 = "";
// build body
$buffer2 = "";
$buffer2 .= iecType::iecBYTE(4); // FC 4 = 4(0x04)
// build body - read section
$buffer2 .= iecType::iecINT($reference); // refnumber = 12288
$buffer2 .= iecType::iecINT($quantity); // quantity
$dataLen += 5;
// build header
$buffer3 = '';
$buffer3 .= iecType::iecINT(rand(0,65000)); // transaction ID
$buffer3 .= iecType::iecINT(0); // protocol ID
$buffer3 .= iecType::iecINT($dataLen + 1); // lenght
$buffer3 .= iecType::iecBYTE($unitId); // unit ID
// return packet string
return $buffer3. $buffer2. $buffer1;
}
/**
* readMultipleInputRegistersParser
*
* FC 4 response parser
*
* @param string $packet
* @return array
*/
private function readMultipleInputRegistersParser($packet){
$data = array();
// check Response code
$this->responseCode($packet);
// get data
for($i=0;$i<ord($packet[8]);$i++){
$data[$i] = ord($packet[9+$i]);
}
return $data;
}
/**
* writeSingleCoil
*
* Modbus function FC5(0x05) - Write Single Register.
*
* This function writes {@link $data} single coil at {@link $reference} position of
* memory of a Modbus device given by {@link $unitId}.
*
*
* @param int $unitId usually ID of Modbus device
* @param int $reference Reference in the device memory (e.g. in device WAGO 750-841, memory MW0 starts at address 12288)
* @param array $data value to be written (TRUE|FALSE).
* @return bool Success flag
*/
function writeSingleCoil($unitId, $reference, $data){
$this->status .= "writeSingleCoil: START\n";
// connect
$this->connect();
// send FC5
$packet = $this->writeSingleCoilPacketBuilder($unitId, $reference, $data);
$this->status .= $this->printPacket($packet);
$this->send($packet);
// receive response
$rpacket = $this->rec();
$this->status .= $this->printPacket($rpacket);
// parse packet
$this->writeSingleCoilParser($rpacket);
// disconnect
$this->disconnect();
$this->status .= "writeSingleCoil: DONE\n";
return true;
}
/**
* fc5
*
* Alias to {@link writeSingleCoil} method
*
* @param int $unitId
* @param int $reference
* @param array $data
* @param array $dataTypes
* @return bool
*/
function fc5($unitId, $reference, $data, $dataTypes){
return $this->writeSingleCoil($unitId, $reference, $data, $dataTypes);
}
/**
* writeSingleCoilPacketBuilder
*
* Packet builder FC5 - WRITE single register
*
* @param int $unitId
* @param int $reference
* @param array $data
* @param array $dataTypes
* @return string
*/
private function writeSingleCoilPacketBuilder($unitId, $reference, $data){
$dataLen = 0;
// build data section
$buffer1 = "";
foreach($data as $key=>$dataitem) {
if($dataitem == TRUE){
$buffer1 = iecType::iecINT(0xFF00);
} else {
$buffer1 = iecType::iecINT(0x0000);
};
};
$dataLen += 2;
// build body
$buffer2 = "";
$buffer2 .= iecType::iecBYTE(5); // FC5 = 5(0x05)
$buffer2 .= iecType::iecINT($reference); // refnumber = 12288
$dataLen += 3;
// build header
$buffer3 = '';
$buffer3 .= iecType::iecINT(rand(0,65000)); // transaction ID
$buffer3 .= iecType::iecINT(0); // protocol ID
$buffer3 .= iecType::iecINT($dataLen + 1); // lenght
$buffer3 .= iecType::iecBYTE($unitId); //unit ID
// return packet string
return $buffer3. $buffer2. $buffer1;
}
/**
* writeSingleCoilParser
*
* FC5 response parser
*
* @param string $packet
* @return bool
*/
private function writeSingleCoilParser($packet){
$this->responseCode($packet);
return true;
}
/** /**
* writeSingleRegister * writeSingleRegister
* *
+44
View File
@@ -0,0 +1,44 @@
phpmodbus
=========
This project deals with an implementation of the basic functionality of the Modbus TCP and UDP based protocol using PHP.
It's a copy of the releases from the project page over at [Google Code](https://code.google.com/p/phpmodbus/) with
composer support added.
Features
--------
* Modbus master
* FC1 - Read coils
* FC2 - Read input discretes
* FC3 - Read holding registers
* FC4 - Read holding input registers
* FC5 - Write single coil
* FC6 - Write single register
* FC15 - Write multiple coils
* FC16 - Write multiple registers
* FC23 - Read/Write multiple registers
Example
-------
```php
// Modbus master UDP
$modbus = new ModbusMaster("192.168.1.1", "UDP");
// Read multiple registers
try {
$recData = $modbus->readMultipleRegisters(0, 12288, 5);
}
catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print data in string format
echo PhpType::bytes2string($recData);
```
For more see [documentation][] or [FAQ][].
[documentation]: https://code.google.com/p/phpmodbus/downloads/list
[FAQ]: https://code.google.com/p/phpmodbus/wiki/FAQ
+19
View File
@@ -0,0 +1,19 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
// Create Modbus object
$modbus = new ModbusMasterUdp("192.192.15.51");
try {
// Read input discretes - FC 4
$recData = $modbus->readMultipleInputRegisters(0, 0, 2);
}
catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
var_dump($recData);
+24
View File
@@ -0,0 +1,24 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
// Create Modbus object
$modbus = new ModbusMasterUdp("192.192.15.51");
// Data to be writen - TRUE, FALSE
$data_true = array(TRUE);
$data_false = array(FALSE);
try {
// Write single coil - FC5
$modbus->writeSingleCoil(0, 12288, $data_true);
$modbus->writeSingleCoil(0, 12289, $data_false);
$modbus->writeSingleCoil(0, 12290, $data_true);
$modbus->writeSingleCoil(0, 12291, $data_false);
}
catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
+2 -2
View File
@@ -1,10 +1,10 @@
The Phpmodbus License, Version 1 The Phpmodbus License, Version 1
============================ ============================
Copyright (c) 2004, 2011 Jan Krakora, Wago (http://www.wago.com) Copyright (c) 2004, 2013 Jan Krakora
All rights reserved. All rights reserved.
This license is a legal agreement between you and Jan Krakora, Wago (the "Author") This license is a legal agreement between you and Jan Krakora (the "Author")
for the use of Phpmodbus (the "Software"). By obtaining, using and/or for the use of Phpmodbus (the "Software"). By obtaining, using and/or
copying the Software, you agree that you have read, understood, and will copying the Software, you agree that you have read, understood, and will
comply with the terms and conditions of this license. comply with the terms and conditions of this license.
Binary file not shown.
Binary file not shown.
-4
View File
@@ -1,4 +0,0 @@
;Version=2
;ProjectId=114942
;Checksum=0
;Filesize=0
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
125<br>98<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>255<br>255<br>255<br>255<br>158<br>88<br>97<br>168<br>
@@ -1 +0,0 @@
Endianing off <hr>0 --> Packet: 0000_0000_</br>1 --> Packet: 0001_0000_</br>-1 --> Packet: ffff_ffff_</br>2147483647 --> Packet: ffff_7fff_</br>-2147483648 --> Packet: 0000_8000_</br>Endianing on <hr>0 --> Packet: 0000_0000_</br>1 --> Packet: 0000_0001_</br>-1 --> Packet: ffff_ffff_</br>2147483647 --> Packet: 7fff_ffff_</br>-2147483648 --> Packet: 8000_0000_</br>
@@ -1 +0,0 @@
Endianing off <hr>0 --> Packet: 0000_</br>1 --> Packet: 0001_</br>-1 --> Packet: ffff_</br>32767 --> Packet: 7fff_</br>-32768 --> Packet: 8000_</br>Endianing on <hr>0 --> Packet: 0000_</br>1 --> Packet: 0001_</br>-1 --> Packet: ffff_</br>32767 --> Packet: 7fff_</br>-32768 --> Packet: 8000_</br>
@@ -1,12 +0,0 @@
Endianing off <hr>
0 --> Packet: 0000_0000_<br>
1 --> Packet: 0000_3f80_<br>
-2 --> Packet: 0000_c000_<br>
0.333333333333 --> Packet: aaab_3eaa_<br>
25 --> Packet: 0000_41c8_<br>
Endianing on <hr>
0 --> Packet: 0000_0000_<br>
1 --> Packet: 3f80_0000_<br>
-2 --> Packet: c000_0000_<br>
0.333333333333 --> Packet: 3eaa_aaab_<br>
25 --> Packet: 41c8_0000_<br>
@@ -1,72 +0,0 @@
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
)
@@ -1 +0,0 @@
writeMultipleRegister (FC26): DONE
@@ -1 +0,0 @@
Caught exception: Unknown socket protocol, should be 'TCP' or 'UDP'
@@ -1,72 +0,0 @@
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
)
@@ -1 +0,0 @@
writeMultipleRegister (FC26): DONE
@@ -1,72 +0,0 @@
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
)
@@ -1 +0,0 @@
writeMultipleRegister (FC26): DONE
@@ -1,66 +0,0 @@
array(32) {
[0]=>
bool(true)
[1]=>
bool(false)
[2]=>
bool(true)
[3]=>
bool(true)
[4]=>
bool(false)
[5]=>
bool(true)
[6]=>
bool(true)
[7]=>
bool(true)
[8]=>
bool(true)
[9]=>
bool(true)
[10]=>
bool(true)
[11]=>
bool(true)
[12]=>
bool(false)
[13]=>
bool(false)
[14]=>
bool(false)
[15]=>
bool(false)
[16]=>
bool(false)
[17]=>
bool(false)
[18]=>
bool(false)
[19]=>
bool(false)
[20]=>
bool(true)
[21]=>
bool(true)
[22]=>
bool(true)
[23]=>
bool(true)
[24]=>
bool(true)
[25]=>
bool(true)
[26]=>
bool(true)
[27]=>
bool(true)
[28]=>
bool(true)
[29]=>
bool(true)
[30]=>
bool(true)
[31]=>
bool(true)
}
@@ -1,72 +0,0 @@
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
)
@@ -1,72 +0,0 @@
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
)
@@ -1 +0,0 @@
writeMultipleRegister (FC26): DONE
@@ -1 +0,0 @@
writeMultipleRegister (FC26): DONE
@@ -1,5 +0,0 @@
Array
(
[0] => 207
[1] => 199
)
@@ -1,7 +1,11 @@
Test should pass when %IX0.0==FALSE and %IX0.1==TRUE Test should pass when %IX0.0==FALSE and %IX0.1==TRUE
array(2) { array(4) {
[0]=> [0]=>
bool(false) int(0)
[1]=> [1]=>
bool(true) int(2)
[2]=>
int(0)
[3]=>
int(0)
} }
@@ -0,0 +1,5 @@
Array
(
[0] => 0
[1] => 5
)
+14
View File
@@ -0,0 +1,14 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
require_once dirname(__FILE__) . '/../config.php';
// Create Modbus object
$modbus = new ModbusMasterUdp($test_host_ip);
// Test requirements
echo "Test should pass when %IX0.0==FALSE and %IX0.1==TRUE\n";
// Read input discretes - FC 4
$recData = $modbus->readMultipleInputRegisters(0, 0, 2);
var_dump($recData);
+23
View File
@@ -0,0 +1,23 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
require_once dirname(__FILE__) . '/../config.php';
// Create Modbus object
$modbus = new ModbusMasterUdp($test_host_ip);
// Data to be writen - TRUE, FALSE
$data_true = array(TRUE);
$data_false = array(FALSE);
// Reset target WORD
$modbus->writeSingleRegister(0, 12288, array(0), array('WORD'));
// Write single coil - FC5
$modbus->writeSingleCoil(0, 12288, $data_true);
$modbus->writeSingleCoil(0, 12289, $data_false);
$modbus->writeSingleCoil(0, 12290, $data_true);
$modbus->writeSingleCoil(0, 12291, $data_false);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 1);
print_r($recData);
@@ -1 +0,0 @@
32098<br>0<br>0<br>-1<br>-25000<br>25000<br>
@@ -1 +0,0 @@
1000<br>2000<br>1.25<br>
@@ -1 +0,0 @@
-1<br>0<br>1<br>-2147483648<br>2147483647<br>
@@ -1 +0,0 @@
eHll oowlr!da<br>Hello world!<br>
@@ -1,6 +0,0 @@
float(4294967295)
<br>int(0)
<br>int(1)
<br>float(2147483648)
<br>int(2147483647)
<br>
@@ -1 +0,0 @@
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>
@@ -1 +0,0 @@
Exception 'Data are not numeric'
+2 -2
View File
@@ -1,3 +1,3 @@
<?php <?php
$test_host_ip = "192.168.1.105"; $test_host_ip = "192.192.1.10";
$test_bind_client_ip = "192.168.1.106"; $test_bind_client_ip = "192.192.1.100";
+20
View File
@@ -24,6 +24,8 @@
<listitem><para>FC 1: read multiple coils</para></listitem> <listitem><para>FC 1: read multiple coils</para></listitem>
<listitem><para>FC 2: read input discretes</para></listitem> <listitem><para>FC 2: read input discretes</para></listitem>
<listitem><para>FC 3: read multiple registers</para></listitem> <listitem><para>FC 3: read multiple registers</para></listitem>
<listitem><para>FC 4: read multiple input registers</para></listitem>
<listitem><para>FC 5: write single coil</para></listitem>
<listitem><para>FC 6: write single register</para></listitem> <listitem><para>FC 6: write single register</para></listitem>
<listitem><para>FC 15: write multiple coils</para></listitem> <listitem><para>FC 15: write multiple coils</para></listitem>
<listitem><para>FC 16: write multiple registers</para></listitem> <listitem><para>FC 16: write multiple registers</para></listitem>
@@ -121,6 +123,24 @@ catch (Exception $e) {
{@example example_fc3.php} {@example example_fc3.php}
</para> </para>
</refsect2> </refsect2>
<refsect2 id="{@id example_fc4}">
<title>FC4 - read multiple input registers </title>
<para>
FC4 functionality example
</para>
<para>
{@example example_fc4.php}
</para>
</refsect2>
<refsect2 id="{@id example_fc5}">
<title>FC5 - write single coil</title>
<para>
FC5 functionality example
</para>
<para>
{@example example_fc5.php}
</para>
</refsect2>
<refsect2 id="{@id example_fc6}"> <refsect2 id="{@id example_fc6}">
<title>FC6 - write single register</title> <title>FC6 - write single register</title>
<para> <para>