From 5300b2a86791454f769c2ce02c119a93ddec2d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Fri, 11 Mar 2016 22:27:10 +0100 Subject: [PATCH] added a namespace --- .gitignore | 4 + .hgignore | 2 - .hgtags | 7 - license.txt => LICENSE | 151 +++++--- README.md | 82 ++-- composer.json | 32 +- examples/README.md | 3 + {Phpmodbus => src}/IecType.php | 267 ++++++------- {Phpmodbus => src}/ModbusMaster.php | 6 +- {Phpmodbus => src}/ModbusMasterTcp.php | 99 ++--- {Phpmodbus => src}/ModbusMasterUdp.php | 101 ++--- {Phpmodbus => src}/PhpType.php | 499 +++++++++++++------------ tests/README.md | 3 + tutorials/Phpmodbus/Phpmodbus.pkg | 210 ----------- tutorials/Phpmodbus/wago_logo.png | Bin 1208 -> 0 bytes 15 files changed, 649 insertions(+), 817 deletions(-) create mode 100644 .gitignore delete mode 100644 .hgignore delete mode 100644 .hgtags rename license.txt => LICENSE (78%) create mode 100644 examples/README.md rename {Phpmodbus => src}/IecType.php (96%) rename {Phpmodbus => src}/ModbusMaster.php (99%) rename {Phpmodbus => src}/ModbusMasterTcp.php (91%) rename {Phpmodbus => src}/ModbusMasterUdp.php (91%) rename {Phpmodbus => src}/PhpType.php (96%) create mode 100644 tests/README.md delete mode 100644 tutorials/Phpmodbus/Phpmodbus.pkg delete mode 100644 tutorials/Phpmodbus/wago_logo.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cf03ab8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/vendor +composer.lock + +*~ diff --git a/.hgignore b/.hgignore deleted file mode 100644 index a7e5f6c..0000000 --- a/.hgignore +++ /dev/null @@ -1,2 +0,0 @@ -vendor -.svn diff --git a/.hgtags b/.hgtags deleted file mode 100644 index ab38c82..0000000 --- a/.hgtags +++ /dev/null @@ -1,7 +0,0 @@ -a88b5a87fb4cd49f16ce72062cce19d55f1fbf98 0.2 -a7f90c18859d31922bdd8c61299e2790f5e2eb1a 0.3 -bdf8b3f414c4d08fc0edf9fd1953f55db26e4bac 0.4 -1e09b0da7d8c62a9a292ee51540feac9de4c1222 0.4.1 -e1262f028e180c2719564f840ffa1a9f8672b6be 0.5 -079f8ac1f49faf4e6bbb84d62c39eee1507805f2 0.6 -5885b1a0d0dc89577eeb871ee2c3fba8e70dd4fb 0.7 diff --git a/license.txt b/LICENSE similarity index 78% rename from license.txt rename to LICENSE index 4a2550a..fafe0eb 100644 --- a/license.txt +++ b/LICENSE @@ -1,62 +1,89 @@ -The Phpmodbus License, Version 1 -============================ - -Copyright (c) 2004, 2013 Jan Krakora -All rights reserved. - -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 -copying the Software, you agree that you have read, understood, and will -comply with the terms and conditions of this license. - - -PERMITTED USE -------------- - -You are permitted to use, copy, modify, and distribute the Software and its -documentation, with or without modification, for any purpose, provided that -the following conditions are met: - -1. A copy of this license agreement must be included with the distribution. - -2. Redistributions of source code must retain the above copyright notice in - all source code files. - -3. Redistributions in binary form must reproduce the above copyright notice - in the documentation and/or other materials provided with the distribution. - -4. Products derived from the Software must include an acknowledgment that - they are derived from "Phpmodbus" in their documentation and/or other - materials provided with the distribution. - -5. The name "Phpmodbus" must not be used to endorse or promote products - derived from the Software without prior written permission from Author. - -6. Products derived from the Software may not be called "Phpmodbus", - nor may "Phpmodbus" appear in their name, without prior written - permission from Author. - - -INDEMNITY ---------- - -You agree to indemnify and hold harmless the Author and any contributors -for any direct, indirect, incidental, or consequential third-party claims, -actions or suits, as well as any related expenses, liabilities, damages, -settlements or fees arising from your use or misuse of the Software, -or a violation of any terms of this license. - - -DISCLAIMER OF WARRANTY ----------------------- - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++---------------------------------------------------------+ +| ACKNOWLEDGEMENTS | ++---------------------------------------------------------+ + +This project is based on work by Jan Krákora, (c) 2004-2013. +The original license is reproduced below. + + https://code.google.com/archive/p/phpmodbus/ + +Further improvements - John S. Long and other contributors + + https://github.com/adduc/phpmodbus + +Cleanup and namespaces - Ondřej Hruška, 2016 + + https://github.com/MightyPork/phpmodbus + + ++---------------------------------------------------------+ +| ORIGINAL LICENSE | ++---------------------------------------------------------+ + + +The Phpmodbus License, Version 1 +============================ + +Copyright (c) 2004, 2013 Jan Krakora +All rights reserved. + +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 +copying the Software, you agree that you have read, understood, and will +comply with the terms and conditions of this license. + + +PERMITTED USE +------------- + +You are permitted to use, copy, modify, and distribute the Software and its +documentation, with or without modification, for any purpose, provided that +the following conditions are met: + +1. A copy of this license agreement must be included with the distribution. + +2. Redistributions of source code must retain the above copyright notice in + all source code files. + +3. Redistributions in binary form must reproduce the above copyright notice + in the documentation and/or other materials provided with the distribution. + +4. Products derived from the Software must include an acknowledgment that + they are derived from "Phpmodbus" in their documentation and/or other + materials provided with the distribution. + +5. The name "Phpmodbus" must not be used to endorse or promote products + derived from the Software without prior written permission from Author. + +6. Products derived from the Software may not be called "Phpmodbus", + nor may "Phpmodbus" appear in their name, without prior written + permission from Author. + + +INDEMNITY +--------- + +You agree to indemnify and hold harmless the Author and any contributors +for any direct, indirect, incidental, or consequential third-party claims, +actions or suits, as well as any related expenses, liabilities, damages, +settlements or fees arising from your use or misuse of the Software, +or a violation of any terms of this license. + + +DISCLAIMER OF WARRANTY +---------------------- + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +End of file. diff --git a/README.md b/README.md index 422a9bc..95f7dcb 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,47 @@ -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 - * FC22 - Mask Write register - * FC23 - Read/Write multiple registers - -Example -------- +# phpmodbus + +Implementation of the basic functionality of the Modbus TCP and UDP based protocol using PHP. + +This is a fork of the original project at https://code.google.com/p/phpmodbus/ + +> **What's new** +> +> This fork adds a namespace and fixes issues encountered when porting to PHP 7 + +Implemented 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); +require_once dirname(__FILE__) . '/Phpmodbus/ModbusMaster.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][]. +For more see [http://code.google.com/p/phpmodbus/downloads/list documentation] or [http://code.google.com/p/phpmodbus/wiki/FAQ FAQ]. -[documentation]: https://code.google.com/p/phpmodbus/downloads/list -[FAQ]: https://code.google.com/p/phpmodbus/wiki/FAQ +Note: + * The PHP extension php_sockets.dll should be enabled (server php.ini file) diff --git a/composer.json b/composer.json index 668b139..7cacb15 100644 --- a/composer.json +++ b/composer.json @@ -1,17 +1,21 @@ { - "name": "adduc/phpmodbus", - "description": "Composer version of PhpModBus", - "license": "LGPL", - "authors": [ - { - "name": "Honza Krakora", - "email": "krakora.jan@googlemail.com" - } - ], - "autoload": { - "classmap": [ "Phpmodbus" ] - }, - "require": { - "ext-sockets": "*" + "name": "MightyPork/phpmodbus", + "keywords": ["phpmodbus","modbus"], + "description": "PhpModbus with namespaces and updated to PHP 7", + "license": "LGPL", + "require": { + "php": "^5.3.2 || ^7.0", + "ext-sockets": "*" + }, + "authors": [ + { + "name": "Honza Krakora", + "email": "krakora.jan@googlemail.com" } + ], + "autoload": { + "psr-4": { + "PHPModbus\\": "src/" + } + } } diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..f3e0c3b --- /dev/null +++ b/examples/README.md @@ -0,0 +1,3 @@ +Those examples have not been updated to use namespaces. + +They may not work. Just for reference. diff --git a/Phpmodbus/IecType.php b/src/IecType.php similarity index 96% rename from Phpmodbus/IecType.php rename to src/IecType.php index 74c1314..de42261 100644 --- a/Phpmodbus/IecType.php +++ b/src/IecType.php @@ -1,133 +1,136 @@ -> 8) & 0x00FF) . - self::iecBYTE(($value & 0x00FF)); - } - - /** - * iecDINT - * - * Converts a value to IEC-1131 DINT data type - * - * @param value value to be converted - * @param value endianness defines endian codding (little endian == 0, big endian == 1) - * @return value IEC-1131 INT data type - * - */ - public static function iecDINT($value, $endianness = 0) { - // result with right endianness - return self::endianness($value, $endianness); - } - - /** - * iecREAL - * - * Converts a value to IEC-1131 REAL data type. The function uses function @use float2iecReal. - * - * @param value value to be converted - * @param value endianness defines endian codding (little endian == 0, big endian == 1) - * @return value IEC-1131 REAL data type - */ - public static function iecREAL($value, $endianness = 0) { - // iecREAL representation - $real = self::float2iecReal($value); - // result with right endianness - return self::endianness($real, $endianness); - } - - /** - * float2iecReal - * - * This function converts float value to IEC-1131 REAL single precision form. - * - * For more see [{@link http://en.wikipedia.org/wiki/Single_precision Single precision on Wiki}] or - * [{@link http://de.php.net/manual/en/function.base-convert.php PHP base_convert function commentary}, Todd Stokes @ Georgia Tech 21-Nov-2007] or - * [{@link http://www.php.net/manual/en/function.pack.php PHP pack/unpack functionality}] - * - * @param float value to be converted - * @return value IEC REAL data type - */ - private static function float2iecReal($value) { - // get float binary string - $float = pack("f", $value); - // set 32-bit unsigned integer of the float - $w = unpack("L", $float); - return $w[1]; - } - - /** - * endianness - * - * Make endianess as required. - * For more see http://en.wikipedia.org/wiki/Endianness - * - * @param int $value - * @param bool $endianness - * @return int - */ - private static function endianness($value, $endianness = 0) { - if ($endianness == 0) - return - self::iecBYTE(($value >> 8) & 0x000000FF) . - self::iecBYTE(($value & 0x000000FF)) . - self::iecBYTE(($value >> 24) & 0x000000FF) . - self::iecBYTE(($value >> 16) & 0x000000FF); - else - return - self::iecBYTE(($value >> 24) & 0x000000FF) . - self::iecBYTE(($value >> 16) & 0x000000FF) . - self::iecBYTE(($value >> 8) & 0x000000FF) . - self::iecBYTE(($value & 0x000000FF)); - } - -} - +> 8) & 0x00FF) . + self::iecBYTE(($value & 0x00FF)); + } + + /** + * iecDINT + * + * Converts a value to IEC-1131 DINT data type + * + * @param value value to be converted + * @param value endianness defines endian codding (little endian == 0, big endian == 1) + * @return value IEC-1131 INT data type + * + */ + public static function iecDINT($value, $endianness = 0) { + // result with right endianness + return self::endianness($value, $endianness); + } + + /** + * iecREAL + * + * Converts a value to IEC-1131 REAL data type. The function uses function @use float2iecReal. + * + * @param value value to be converted + * @param value endianness defines endian codding (little endian == 0, big endian == 1) + * @return value IEC-1131 REAL data type + */ + public static function iecREAL($value, $endianness = 0) { + // iecREAL representation + $real = self::float2iecReal($value); + // result with right endianness + return self::endianness($real, $endianness); + } + + /** + * float2iecReal + * + * This function converts float value to IEC-1131 REAL single precision form. + * + * For more see [{@link http://en.wikipedia.org/wiki/Single_precision Single precision on Wiki}] or + * [{@link http://de.php.net/manual/en/function.base-convert.php PHP base_convert function commentary}, Todd Stokes @ Georgia Tech 21-Nov-2007] or + * [{@link http://www.php.net/manual/en/function.pack.php PHP pack/unpack functionality}] + * + * @param float value to be converted + * @return value IEC REAL data type + */ + private static function float2iecReal($value) { + // get float binary string + $float = pack("f", $value); + // set 32-bit unsigned integer of the float + $w = unpack("L", $float); + return $w[1]; + } + + /** + * endianness + * + * Make endianess as required. + * For more see http://en.wikipedia.org/wiki/Endianness + * + * @param int $value + * @param bool $endianness + * @return int + */ + private static function endianness($value, $endianness = 0) { + if ($endianness == 0) + return + self::iecBYTE(($value >> 8) & 0x000000FF) . + self::iecBYTE(($value & 0x000000FF)) . + self::iecBYTE(($value >> 24) & 0x000000FF) . + self::iecBYTE(($value >> 16) & 0x000000FF); + else + return + self::iecBYTE(($value >> 24) & 0x000000FF) . + self::iecBYTE(($value >> 16) & 0x000000FF) . + self::iecBYTE(($value >> 8) & 0x000000FF) . + self::iecBYTE(($value & 0x000000FF)); + } + +} + ?> \ No newline at end of file diff --git a/Phpmodbus/ModbusMaster.php b/src/ModbusMaster.php similarity index 99% rename from Phpmodbus/ModbusMaster.php rename to src/ModbusMaster.php index a03229f..c98b69e 100644 --- a/Phpmodbus/ModbusMaster.php +++ b/src/ModbusMaster.php @@ -1,4 +1,7 @@ host = $host; - $this->socket_protocol = "TCP"; - } -} +host = $host; + $this->socket_protocol = "TCP"; + } +} diff --git a/Phpmodbus/ModbusMasterUdp.php b/src/ModbusMasterUdp.php similarity index 91% rename from Phpmodbus/ModbusMasterUdp.php rename to src/ModbusMasterUdp.php index 0fa4fa7..d242e7b 100644 --- a/Phpmodbus/ModbusMasterUdp.php +++ b/src/ModbusMasterUdp.php @@ -1,50 +1,51 @@ -host = $host; - $this->socket_protocol = "UDP"; - } -} +host = $host; + $this->socket_protocol = "UDP"; + } +} diff --git a/Phpmodbus/PhpType.php b/src/PhpType.php similarity index 96% rename from Phpmodbus/PhpType.php rename to src/PhpType.php index 5552e61..f13b4f4 100644 --- a/Phpmodbus/PhpType.php +++ b/src/PhpType.php @@ -1,249 +1,252 @@ - 0)) { - $int = 0xFFFF8000 | $int; - } - // Convert the value - return (int) self::dword2signedInt($int); - } - - /** - * bytes2unsignedInt - * - * The function converts array of 2 or 4 bytes to unsigned integer. - * The return value depends on order of the input bytes (endianning). - * - * @param array $values - * @param bool $endianness - * @return int|float - */ - public static function bytes2unsignedInt($values, $endianness = 0) { - $data = array(); - $int = 0; - // Set the array to correct form - $data = self::checkData($values); - // Combine bytes - $int = self::combineBytes($data, $endianness); - // Convert the value - return self::dword2unsignedInt($int); - } - - /** - * bytes2string - * - * The function converts an values array to the string. The function detects - * the end of the string by 0x00 character as defined by string standards. - * - * @param array $values - * @param bool $endianness - * @return string - */ - public static function bytes2string($values, $endianness = 0) { - // Prepare string variable - $str = ""; - // Parse the received data word array - for($i=0;$i4 || - count($data)==3) { - throw new Exception('The input data should be an array of 2 or 4 bytes.'); - } - // Fill the rest of array by zeroes - if (count($data) == 2) { - $data[2] = 0; - $data[3] = 0; - } - // Check the values to be number - if (!is_numeric($data[0]) || - !is_numeric($data[1]) || - !is_numeric($data[2]) || - !is_numeric($data[3])) { - throw new Exception('Data are not numeric or the array keys are not indexed by 0,1,2 and 3'); - } - - return $data; - } - - /** - * combineBytes - * - * Combine bytes together - * - * @param int $data - * @param bool $endianness - * @return int - */ - private static function combineBytes($data, $endianness) { - $value = 0; - // Combine bytes - if ($endianness == 0) - $value = (($data[3] & 0xFF)<<16) | - (($data[2] & 0xFF)<<24) | - (($data[1] & 0xFF)) | - (($data[0] & 0xFF)<<8); - else - $value = (($data[3] & 0xFF)<<24) | - (($data[2] & 0xFF)<<16) | - (($data[1] & 0xFF)<<8) | - (($data[0] & 0xFF)); - - return $value; - } -} + 0)) { + $int = 0xFFFF8000 | $int; + } + // Convert the value + return (int) self::dword2signedInt($int); + } + + /** + * bytes2unsignedInt + * + * The function converts array of 2 or 4 bytes to unsigned integer. + * The return value depends on order of the input bytes (endianning). + * + * @param array $values + * @param bool $endianness + * @return int|float + */ + public static function bytes2unsignedInt($values, $endianness = 0) { + $data = array(); + $int = 0; + // Set the array to correct form + $data = self::checkData($values); + // Combine bytes + $int = self::combineBytes($data, $endianness); + // Convert the value + return self::dword2unsignedInt($int); + } + + /** + * bytes2string + * + * The function converts an values array to the string. The function detects + * the end of the string by 0x00 character as defined by string standards. + * + * @param array $values + * @param bool $endianness + * @return string + */ + public static function bytes2string($values, $endianness = 0) { + // Prepare string variable + $str = ""; + // Parse the received data word array + for($i=0;$i4 || + count($data)==3) { + throw new Exception('The input data should be an array of 2 or 4 bytes.'); + } + // Fill the rest of array by zeroes + if (count($data) == 2) { + $data[2] = 0; + $data[3] = 0; + } + // Check the values to be number + if (!is_numeric($data[0]) || + !is_numeric($data[1]) || + !is_numeric($data[2]) || + !is_numeric($data[3])) { + throw new Exception('Data are not numeric or the array keys are not indexed by 0,1,2 and 3'); + } + + return $data; + } + + /** + * combineBytes + * + * Combine bytes together + * + * @param int $data + * @param bool $endianness + * @return int + */ + private static function combineBytes($data, $endianness) { + $value = 0; + // Combine bytes + if ($endianness == 0) + $value = (($data[3] & 0xFF)<<16) | + (($data[2] & 0xFF)<<24) | + (($data[1] & 0xFF)) | + (($data[0] & 0xFF)<<8); + else + $value = (($data[3] & 0xFF)<<24) | + (($data[2] & 0xFF)<<16) | + (($data[1] & 0xFF)<<8) | + (($data[0] & 0xFF)); + + return $value; + } +} ?> \ No newline at end of file diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..1dbebf5 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,3 @@ +Probably broken and dubious. + +Left from the original repo. diff --git a/tutorials/Phpmodbus/Phpmodbus.pkg b/tutorials/Phpmodbus/Phpmodbus.pkg deleted file mode 100644 index d3e57ea..0000000 --- a/tutorials/Phpmodbus/Phpmodbus.pkg +++ /dev/null @@ -1,210 +0,0 @@ - - - Phpmodbus user's guide - Phpmodbus How-to - - - - Jan Krakora - - {@link mailto:krakora.jan@googlemail.com email} - - - - {@toc} - - Introduction - - Phpmodbus is a PHP library for the Modbus protocol. The library implements - Modbus TCP/UDP master class with subset of the most used Modbus commands. - - - The library implements: - - FC 1: read multiple coils - FC 2: read input discretes - FC 3: read multiple registers - FC 4: read multiple input registers - FC 5: write single coil - FC 6: write single register - FC 15: write multiple coils - FC 16: write multiple registers - FC 23: read write registers - - - - For more about Modbus protocol see [{@link http://www.modbus.org}] or - [{@link http://en.wikipedia.org/wiki/Modbus Wiki}] - - - - Install - - At the first, it is supposed an PHP solution has been already installed on - your server (LAMP, WAMP, MSS+CGI etc.). - - - Copy the Phpmodbus library to your PHP project folder. - - - Create a PHP script and assign the library using require_once() command - - - - - - To create UDP Modbus master object communicating to an modbus slave - e.g. at IP address 192.168.1.1 write - - - - - - To create TCP Modbus master use - - - - - - To read 5 words (10 bytes) from the device ID=0 and its memory address 12288 - use try-catch method call - - readMultipleRegisters(0, 12288, 5); -} -catch (Exception $e) { - // Exception processing, e.g. print error information - echo $modbus; - echo $e; - exit; -}]]> - - - - To process the function byte stream, use conversion to PHP types in - - - - - - For other examples see sections bellow. - - - - Examples - - This section presents library features and examples - - - FC1 - read mutliple coils - - FC1 functionality example - - - {@example example_fc1.php} - - - - FC2 - read input discretes - - FC2 functionality example - - - {@example example_fc2.php} - - - - FC3 - read mutliple registers - - FC3 functionality example - - - {@example example_fc3.php} - - - - FC4 - read multiple input registers - - FC4 functionality example - - - {@example example_fc4.php} - - - - FC5 - write single coil - - FC5 functionality example - - - {@example example_fc5.php} - - - - FC6 - write single register - - FC6 functionality example - - - {@example example_fc6.php} - - - - FC15 - write mutliple coils - - FC15 functionality example - - - {@example example_fc15.php} - - - - FC16 - write mutliple registers - - FC16 functionality example - - - {@example example_fc16.php} - - - - FC23 - read write registers - - FC23 functionality example - - - {@example example_fc23.php} - - - - Dump of M-memory from WAGO 750-84x series coupler. - - Dump of M-memory from WAGO 750-84x series coupler. - - - {@example example_750841_Mmemory.php} - - - - Data conversion to PHP types. - - Conversion of the data bytes, received from Modbus, to a PHP type. - - - {@example example_datatype.php} - - - - - Back compatibility - - This version is back compatible to the last versions. Just use - - - - - - \ No newline at end of file diff --git a/tutorials/Phpmodbus/wago_logo.png b/tutorials/Phpmodbus/wago_logo.png deleted file mode 100644 index 681b0643e29f7cb89aa3642eb9d155b1e57960bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1208 zcmV;p1V{UcP)BHA0n%)wp(M7Gl*9?x!N%iw zY-1<3XW?V$XyQzqMg+l;Ki)m>+g?W|(m%6#@VZ!M8sA7y#Uh{1i_| zM1|A5BahJY0xy}dj0(UjInlz5H)gLWHb}9HtMwKUPcu1Yqp5HflkIQ#_ZyQ7BXWjL&R@U(s89rJscY@< zTwwXXw+I4AZbSbN%gzVOv!9Ni%Tjzf`EG_wiQ~Pc&2-Z5rU%7Pr!pR}w_Kfie`Q?+ zK~FVa!jNV4t=i&&`EDtEw)S)hRRsX=jJ%p+lWY3}5EfVLT#3=EEr-gVKi7X;nre2u zq*xRH5I~&fhS6Z}H{QzRXGY<21yP>vy{7s3`VB}{L7k%-2iWPW) zyX=0OKvgMD`NaXi&DqY8Ko0<;6VmMDMRxbIbyOXf8Jt{5@6m0;Mv_nf>-7^MB5G!b4(cR9p9z9YzoY0KAOrPViev zi6U5zW(Xi+)~bRPvp4`?C?Q=F1v>lQ(x=0V0g17Yg$L{{XZw#yIW2Xk8}c6)$9=x8 z(cmp{j3IcF?U0KekiIl>sBx{+vO|TcyNUKhCZ=ev#?qKg@&YS>AYY<5kVpiOPS1s# zvz=mCZ{73C&WrLAa%C2?tds1fR1|>HZHg|E|6j@s)%(g0dl?reu+^5G2RA*p z+4_ilJs5`S_0+uIPY?u2YSn60C=}A^bSi=Dza0C3YoT7t40YSvV4IQ|0f WI<-VGRvh{O0000