deleted broken tests and examples, updated readme

master
Ondřej Hruška 6 years ago
parent be97fbd98c
commit c6be1e064b
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 2
      LICENSE
  2. 12
      README.md
  3. 3
      examples/README.md
  4. 65
      examples/example_750841_Mmemory.php
  5. 60
      examples/example_datatype.php
  6. 24
      examples/example_fc1.php
  7. 27
      examples/example_fc15.php
  8. 25
      examples/example_fc16.php
  9. 25
      examples/example_fc2.php
  10. 25
      examples/example_fc22.php
  11. 28
      examples/example_fc23.php
  12. 24
      examples/example_fc3.php
  13. 18
      examples/example_fc4.php
  14. 23
      examples/example_fc5.php
  15. 22
      examples/example_fc6.php
  16. 256
      tests/Codesys/TEST.EXP
  17. 15
      tests/Codesys/_make_exp.cmd
  18. BIN
      tests/Codesys/test.pro
  19. 11
      tests/IecType/_test.bat
  20. 1
      tests/IecType/ref/test.iecByte.php.html
  21. 1
      tests/IecType/ref/test.iecDInt.php.html
  22. 1
      tests/IecType/ref/test.iecInt.php.html
  23. 12
      tests/IecType/ref/test.iecReal.php.html
  24. 33
      tests/IecType/test.iecByte.php
  25. 50
      tests/IecType/test.iecDInt.php
  26. 50
      tests/IecType/test.iecInt.php
  27. 50
      tests/IecType/test.iecReal.php
  28. 11
      tests/ModbusMaster/_test.bat
  29. 72
      tests/ModbusMaster/ref/test.tcp.fc16fc3.php.html
  30. 1
      tests/ModbusMaster/ref/test.tcp.fc26.php.html
  31. 1
      tests/ModbusMaster/ref/test.tcp.socket_protocol_mismatch.php.html
  32. 72
      tests/ModbusMaster/ref/test.udp.fc16fc3.php.html
  33. 1
      tests/ModbusMaster/ref/test.udp.fc26.php.html
  34. 44
      tests/ModbusMaster/test.tcp.fc16fc3.php
  35. 24
      tests/ModbusMaster/test.tcp.fc26.php
  36. 22
      tests/ModbusMaster/test.tcp.socket_protocol_mismatch.php
  37. 44
      tests/ModbusMaster/test.udp.fc16fc3.php
  38. 24
      tests/ModbusMaster/test.udp.fc26.php
  39. 11
      tests/ModbusMasterTcp/_test.bat
  40. 72
      tests/ModbusMasterTcp/ref/test.fc16fc3.php.html
  41. 1
      tests/ModbusMasterTcp/ref/test.fc26.php.html
  42. 44
      tests/ModbusMasterTcp/test.fc16fc3.php
  43. 24
      tests/ModbusMasterTcp/test.fc26.php
  44. 11
      tests/ModbusMasterUdp/_test.bat
  45. 66
      tests/ModbusMasterUdp/ref/test.fc15fc1.php.html
  46. 72
      tests/ModbusMasterUdp/ref/test.fc16fc3.php.html
  47. 72
      tests/ModbusMasterUdp/ref/test.fc16fc3bind.php.html
  48. 7
      tests/ModbusMasterUdp/ref/test.fc2.php.html
  49. 1
      tests/ModbusMasterUdp/ref/test.fc26.php.html
  50. 1
      tests/ModbusMasterUdp/ref/test.fc26bind.php.html
  51. 11
      tests/ModbusMasterUdp/ref/test.fc4.php.html
  52. 5
      tests/ModbusMasterUdp/ref/test.fc5.php.html
  53. 5
      tests/ModbusMasterUdp/ref/test.fc6fc3.php.html
  54. 22
      tests/ModbusMasterUdp/test.fc15fc1.php
  55. 44
      tests/ModbusMasterUdp/test.fc16fc3.php
  56. 45
      tests/ModbusMasterUdp/test.fc16fc3bind.php
  57. 14
      tests/ModbusMasterUdp/test.fc2.php
  58. 24
      tests/ModbusMasterUdp/test.fc26.php
  59. 25
      tests/ModbusMasterUdp/test.fc26bind.php
  60. 14
      tests/ModbusMasterUdp/test.fc4.php
  61. 23
      tests/ModbusMasterUdp/test.fc5.php
  62. 15
      tests/ModbusMasterUdp/test.fc6fc3.php
  63. 11
      tests/PhpType/_test.bat
  64. 1
      tests/PhpType/ref/test.bytes2mixed.php.html
  65. 1
      tests/PhpType/ref/test.bytes2real.php.html
  66. 1
      tests/PhpType/ref/test.bytes2signedint.php.html
  67. 1
      tests/PhpType/ref/test.bytes2string.php.html
  68. 6
      tests/PhpType/ref/test.bytes2unsignedint.php.html
  69. 1
      tests/PhpType/ref/test.strangearray.size.php.html
  70. 1
      tests/PhpType/ref/test.strangearray.textarray.php.html
  71. 37
      tests/PhpType/test.bytes2mixed.php
  72. 27
      tests/PhpType/test.bytes2real.php
  73. 35
      tests/PhpType/test.bytes2signedint.php
  74. 28
      tests/PhpType/test.bytes2string.php
  75. 36
      tests/PhpType/test.bytes2unsignedint.php
  76. 44
      tests/PhpType/test.strangearray.size.php
  77. 22
      tests/PhpType/test.strangearray.textarray.php
  78. 3
      tests/README.md
  79. 5
      tests/config.bat
  80. 3
      tests/config.php

@ -15,6 +15,8 @@ Cleanup and namespaces - Ondřej Hruška, 2016
https://github.com/MightyPork/phpmodbus https://github.com/MightyPork/phpmodbus
https://git.ondrovo.com/packages/php-modbus
+---------------------------------------------------------+ +---------------------------------------------------------+
| ORIGINAL LICENSE | | ORIGINAL LICENSE |

@ -2,7 +2,7 @@
Implementation of the basic functionality of the Modbus TCP and UDP based protocol using PHP. Implementation of the basic functionality of the Modbus TCP and UDP based protocol using PHP.
**NOTE: This is a fork to fix & update the library code (and code alone). Notably, the tests are probably all broken.** **NOTE: This is a fork to fix & update the library code.**
> **What's new** > **What's new**
> >
@ -31,8 +31,8 @@ Implementation of the basic functionality of the Modbus TCP and UDP based protoc
## Example ## Example
```php ```php
use PHPModbus/ModbusMaster; use MightyPork\PHPModbus\ModbusMaster;
use PHPModbus/PhpType; use MightyPork\PHPModbus\PhpType;
// Modbus master UDP // Modbus master UDP
$modbus = new ModbusMaster("192.168.1.1", "UDP"); $modbus = new ModbusMaster("192.168.1.1", "UDP");
@ -41,7 +41,7 @@ try {
$recData = $modbus->readMultipleRegisters(0, 12288, 5); $recData = $modbus->readMultipleRegisters(0, 12288, 5);
} catch (Exception $e) { } catch (Exception $e) {
// Print error information if any // Print error information if any
echo $modbus; echo $modbus . "\n";
echo $e; echo $e;
exit; exit;
} }
@ -51,12 +51,12 @@ echo PhpType::bytes2string($recData);
Use the `setTimeout($seconds)` and `setSocketTimeout($read_timeout_sec, $write_timeout_sec)` methods to adjust wait times. Use the `setTimeout($seconds)` and `setSocketTimeout($read_timeout_sec, $write_timeout_sec)` methods to adjust wait times.
Most of the code is (to some extent) commented and documented with PhpDoc. You should get useful tooltips in your IDE. Most of the code is (to some extent) commented and documented with PhpDoc.
## GoogleCode legacy docs & downloads ## GoogleCode legacy docs & downloads
This project was originally hosted on (now defunct) Google Code. It's still archived here: This project was originally hosted on Google Code. It is still archived here:
* [GoogleCode Archived Repo](http://code.google.com/p/phpmodbus) * [GoogleCode Archived Repo](http://code.google.com/p/phpmodbus)

@ -1,3 +0,0 @@
Those examples have not been updated to use namespaces.
They may not work. Just for reference.

@ -1,65 +0,0 @@
<?php
use PHPModbus\ModbusMaster;
// Create Modbus object
$ip = "192.192.15.51";
$modbus = new ModbusMaster($ip, "UDP");
try {
// FC 3
$moduleId = 0;
$reference = 12288;
$mw0address = 12288;
$quantity = 6;
$recData = $modbus->readMultipleRegisters($moduleId, $reference, $quantity);
} catch (Exception $e) {
echo $modbus;
echo $e;
exit;
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>WAGO 750-841 M-memory dump</title>
</head>
<body>
<h1>Dump of M-memory from WAGO 750-84x series coupler.</h1>
<ul>
<li>PLC: 750-84x series</li>
<li>IP: <?php echo $ip ?></li>
<li>Modbus module ID: <?php echo $moduleId ?></li>
<li>Modbus memory reference: <?php echo $reference ?></li>
<li>Modbus memory quantity: <?php echo $quantity ?></li>
</ul>
<h2>M-memory dump</h2>
<table border="1px" width="400px">
<tr>
<td>Modbus address</td>
<td>MWx</td>
<td>value</td>
</tr>
<?php
for ($i = 0; $i < count($recData); $i += 2) {
?>
<tr>
<td><?php echo $i + $reference ?></td>
<td>MW<?php echo ($i + $reference - $mw0address) / 2 ?></td>
<td><?php echo ($recData[$i] << 8) + $recData[$i + 1] ?></td>
</tr>
<?php
}
?>
</table>
<h2>Modbus class status</h2>
<pre><?= $modbus ?></pre>
</body>
</html>

@ -1,60 +0,0 @@
<?php
use PHPModbus\ModbusMaster;
use PHPModbus\PhpType;
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
try {
// FC 3
// read 10 words (20 bytes) from device ID=0, address=12288
$recData = $modbus->readMultipleRegisters(0, 12288, 10);
} catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Received data
echo "<h1>Received Data</h1>\n";
print_r($recData);
// Conversion
echo "<h2>32 bits types</h2>\n";
// Chunk the data array to set of 4 bytes
$values = array_chunk($recData, 4);
// Get float from REAL interpretation
echo "<h3>REAL to Float</h3>\n";
foreach ($values as $bytes)
echo PhpType::bytes2float($bytes) . "</br>";
// Get integer from DINT interpretation
echo "<h3>DINT to integer </h3>\n";
foreach ($values as $bytes)
echo PhpType::bytes2signedInt($bytes) . "</br>";
// Get integer of float from DINT interpretation
echo "<h3>DWORD to integer (or float) </h3>\n";
foreach ($values as $bytes)
echo PhpType::bytes2unsignedInt($bytes) . "</br>";
echo "<h2>16 bit types</h2>\n";
// Chunk the data array to set of 4 bytes
$values = array_chunk($recData, 2);
// Get signed integer from INT interpretation
echo "<h3>INT to integer </h3>\n";
foreach ($values as $bytes)
echo PhpType::bytes2signedInt($bytes) . "</br>";
// Get unsigned integer from WORD interpretation
echo "<h3>WORD to integer </h3>\n";
foreach ($values as $bytes)
echo PhpType::bytes2unsignedInt($bytes) . "</br>";
// Get string from STRING interpretation
echo "<h3>STRING to string </h3>\n";
echo PhpType::bytes2string($recData) . "</br>";

@ -1,24 +0,0 @@
<?php
use PHPModbus\ModbusMaster;
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
try {
// FC 1
$recData = $modbus->readCoils(0, 12288, 12);
} catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print status information
echo "</br>Status:</br>" . $modbus;
// Print read data
echo "</br>Data:</br>";
var_dump($recData);
echo "</br>";

@ -1,27 +0,0 @@
<?php
use PHPModbus\ModbusMaster;
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
// Data to be written - supports both 0/1 and booleans (true, false)
$data = array(
1, 0, 1, 1, 0, 1, 1, 1,
1, 1, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
);
try {
// FC15
$modbus->writeMultipleCoils(0, 12288, $data);
} catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print status information
echo $modbus;

@ -1,25 +0,0 @@
<?php
use PHPModbus\ModbusMaster;
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
// Data to be writen
$data = array(10, -1000, 2000, 3.0);
$dataTypes = array("WORD", "INT", "DINT", "REAL");
try {
// FC16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
} catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print status information
echo $modbus;
?>

@ -1,25 +0,0 @@
<?php
use PHPModbus\ModbusMaster;
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
try {
// FC 2
// read 2 input bits from address 0x0 (Wago input image)
$recData = $modbus->readInputDiscretes(0, 0, 2);
} catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print status information
echo "</br>Status:</br>" . $modbus;
// Print read data
echo "</br>Data:</br>";
var_dump($recData);
echo "</br>";

@ -1,25 +0,0 @@
<?php
use PHPModbus\ModbusMaster;
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
// Data to be writen
$bitValue = true;
$bitNumber = 2;
$andMask = 0xFFFF ^ pow(2, $bitNumber);
$orMask = 0x0000 ^ (pow(2, $bitNumber) * $bitValue);
try {
// FC22
$modbus->maskWriteRegister(0, 12288, $andMask, $orMask);
} catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print status information
echo $modbus;

@ -1,28 +0,0 @@
<?php
use PHPModbus\ModbusMaster;
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
// Data to be writen
$data = array(10, -1000, 2000, 3.0);
$dataTypes = array("WORD", "INT", "DINT", "REAL");
try {
// FC23
$recData = $modbus->readWriteRegisters(0, 12288, 6, 12288, $data, $dataTypes);
} catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print status information
echo "</br>Status:</br>" . $modbus;
// Print read data
echo "</br>Data:</br>";
print_r($recData);
echo "</br>";

@ -1,24 +0,0 @@
<?php
use PHPModbus\ModbusMaster;
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
try {
// FC 3
$recData = $modbus->readMultipleRegisters(0, 12288, 6);
} catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print status information
echo "</br>Status:</br>" . $modbus;
// Print read data
echo "</br>Data:</br>";
print_r($recData);
echo "</br>";

@ -1,18 +0,0 @@
<?php
use PHPModbus\ModbusMasterUdp;
// 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);

@ -1,23 +0,0 @@
<?php
use PHPModbus\ModbusMasterUdp;
// 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;
}

@ -1,22 +0,0 @@
<?php
use PHPModbus\ModbusMaster;
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
// Data to be writen
$data = array(-1000);
try {
// FC6
$modbus->writeSingleRegister(0, 12288, $data);
} catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print status information
echo $modbus;

@ -1,256 +0,0 @@
(* @NESTEDCOMMENTS := 'Yes' *)
(* @PATH := '' *)
(* @OBJECTFLAGS := '0, 8' *)
(* @SYMFILEFLAGS := '2048' *)
PROGRAM PLC_PRG
VAR
(* BOOL, COIL *)
COIL1 AT %MX0.0 : BOOL := 0;
COIL2 AT %MX0.1 : BOOL := 0;
COIL3 AT %MX0.2 : BOOL := 0;
COIL4 AT %MX0.3 : BOOL := 0;
COIL5 AT %MX0.4 : BOOL := 0;
COIL6 AT %MX0.5 : BOOL := 0;
COIL7 AT %MX0.6 : BOOL := 0;
COIL8 AT %MX0.7 : BOOL := 0;
(* BYTE *)
BYTE1 AT %MB0 : BYTE := 0;
BYTE2 AT %MB1 : BYTE := 0;
BYTE3 AT %MB2 : BYTE := 0;
BYTE4 AT %MB3 : BYTE := 0;
BYTE5 AT %MB4 : BYTE := 0;
(* INT *)
INT1 AT %MW0 : INT := 0;
INT2 AT %MW1 : INT := 0;
INT3 AT %MW2 : INT := 0;
INT4 AT %MW3 : INT := 0;
INT5 AT %MW4 : INT := 0;
(* WORD *)
WORD1 AT %MW0 : WORD := 0;
WORD2 AT %MW1 : WORD := 0;
WORD3 AT %MW2 : WORD := 0;
WORD4 AT %MW3 : WORD := 0;
WORD5 AT %MW4 : WORD := 0;
(* DINT *)
DINT1 AT %MD0 : DINT := 0;
DINT2 AT %MD1 : DINT := 0;
DINT3 AT %MD2 : DINT := 0;
DINT4 AT %MD3 : DINT := 0;
DINT5 AT %MD4 : DINT := 0;
(* DWORD *)
DWORD1 AT %MD0 : DWORD := 0;
DWORD2 AT %MD1 : DWORD := 0;
DWORD3 AT %MD2 : DWORD := 0;
DWORD4 AT %MD3 : DWORD := 0;
DWORD5 AT %MD4 : DWORD := 0;
(* REAL *)
REAL1 AT %MD0 : REAL := 0;
REAL2 AT %MD1 : REAL := 0;
REAL3 AT %MD2 : REAL := 0;
REAL4 AT %MD3 : REAL := 0;
REAL5 AT %MD4 : REAL := 0;
(* String *)
STRING1 AT %MW0 : STRING := 'Hello word!!!';
END_VAR
(* @END_DECLARATION := '0' *)
(* Something to do *)
;
END_PROGRAM
(* @NESTEDCOMMENTS := 'Yes' *)
(* @GLOBAL_VARIABLE_LIST := 'Global_Variables' *)
(* @PATH := '' *)
(* @OBJECTFLAGS := '0, 8' *)
(* @SYMFILEFLAGS := '2048' *)
VAR_GLOBAL
END_VAR
(* @OBJECT_END := 'Global_Variables' *)
(* @CONNECTIONS := Global_Variables
FILENAME : ''
FILETIME : 0
EXPORT : 0
NUMOFCONNECTIONS : 0
*)
(* @NESTEDCOMMENTS := 'Yes' *)
(* @GLOBAL_VARIABLE_LIST := 'Variable_Configuration' *)
(* @PATH := '' *)
(* @OBJECTFLAGS := '0, 8' *)
(* @SYMFILEFLAGS := '2048' *)
VAR_CONFIG
END_VAR
(* @OBJECT_END := 'Variable_Configuration' *)
(* @CONNECTIONS := Variable_Configuration
FILENAME : ''
FILETIME : 0
EXPORT : 0
NUMOFCONNECTIONS : 0
*)
_ALARMCONFIG
_ALARMCONFIGNEXTTEXTID : 10002
_ALARMCONFIGFORMATS : 'HH$':$'mm$':$'ss','dd$'-$'MM$'-$'yyyy'
_ALARMCLASSLIST : 1
_ALARMCLASSID : 0
_ALARMCLASSACKTYPE : 0
_ALARMCLASSNAME : 'DEFAULT'
_ALARMCLASSDESCRIPTION : ''
_ALARMCLASSBGCOLORS : 16777215,16777215,16777215
_ALARMCLASSTEXTCOLORS : 3394560,255,16711680
_ALARMCLASSBITMAPS : '','',''
_ALARMACTIONLIST : 0
(* @ALARMCLASSRESETCOLORS := '_ALARMCLASSRESETCOLORS: 33023,16777215' *)
(* @ALARMCLASSRESETBITMAP := '_ALARMCLASSRESETBITMAP: $'$'' *)
_ALARMGROUPLISTNAME : 'System'
_ALARMGROUPPATH : 'System'
_ALARMGROUPLIST : 0
_VISUALSETTINGSFLAGS : 0,0,0,0
_VISUALSETTINGSFLAGS : '','',''
_VISUALSETTINGSDYNTEXTFILECOUNT : 0
(* @ALARMCONFIGFLAGS := '_ALARMCONFIGFLAGS: 0' *)
(* @ALARMCONFIGGLOBALDB_STR := '_ALARMCONFIGGLOBALDB_STRINGS: $'$',$'$',$'$',$'$'' *)
(* @ALARMCONFIGGLOBALDB_NUM := '_ALARMCONFIGGLOBALDB_NUMBERS: 0,0' *)
_END_ALARMCONFIG
LIBRARY
Standard.lib 2.12.10 14:48:34
(* @LIBRARYSYMFILEINFO := '0' *)
NumOfPOUs: 26
ASCIIBYTE_TO_STRING: 2048
CONCAT: 0
CTD: 0
CTU: 0
CTUD: 0
DELETE: 0
F_TRIG: 0
FIND: 0
INSERT: 0
LEFT: 0
LEN: 0
MID: 0
R_TRIG: 0
REAL_STATE: 2048
REPLACE: 0
RIGHT: 0
RS: 0
RTC: 0
SEMA: 0
SR: 0
STANDARD_VERSION: 2048
STRING_COMPARE: 2048
STRING_TO_ASCIIBYTE: 2048
TOF: 0
TON: 0
TP: 0
NumOfGVLs: 1
'Global Variables 0': 0
END_LIBRARY
LIBRARY
SYSLIBCALLBACK.LIB 2.12.10 14:48:32
(* @LIBRARYSYMFILEINFO := '0' *)
NumOfPOUs: 2
SysCallbackRegister: 0
SysCallbackUnregister: 0
NumOfGVLs: 2
Globale_Variablen: 0
Version: 0
END_LIBRARY
PLC_CONFIGURATION
_GLOBAL
_VERSION: 3
_AUTOADR: 0
_CHECKADR: 0
_SAVECONFIGFILESINPROJECT: 0
_END_GLOBAL
_MODULE: '3S'
_SECTION_NAME: 'Root'
_INDEX_IN_PARENT: '-1'
_MODULE_NAME: 'Hardware configuration'
_NODE_ID: -1
_IECIN: %IB0
_IECOUT: %QB0
_IECDIAG: %MB0
_DOWNLOAD: 1
_EXCLUDEFROMAUTOADR: 0
_COMMENT: ''
_MODULE: '3S'
_SECTION_NAME: 'K_Bus'
_INDEX_IN_PARENT: '1'
_MODULE_NAME: 'K-Bus'
_NODE_ID: 0
_IECIN: %IB0
_IECOUT: %QB0
_IECDIAG: %MB0
_DOWNLOAD: 1
_EXCLUDEFROMAUTOADR: 0
_COMMENT: ''
_END_MODULE
_MODULE: '3S'
_SECTION_NAME: 'FB_VARS'
_INDEX_IN_PARENT: '2'
_MODULE_NAME: 'Fieldbus variables'
_NODE_ID: 1
_IECIN: %IB0
_IECOUT: %QB0
_IECDIAG: %MB0
_DOWNLOAD: 1
_EXCLUDEFROMAUTOADR: 0
_COMMENT: ''
_END_MODULE
_END_MODULE
PLC_END
RESOURCE
{event_task : 'start','Called when program starts','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,1,11986}
{event_task : 'stop','Called when program stops','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,2,11986}
{event_task : 'before_reset','Called before reset takes place','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,3,11986}
{event_task : 'after_reset','Called after reset took place','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,4,11986}
{event_task : 'shutdown','Called before shutdown is performed (Firmware update over ethernet)','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,5,11986}
{event_task : 'excpt_watchdog','Software watchdog of IEC-task expired','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,7,11986}
{event_task : 'excpt_fieldbus','Fieldbus error','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,9,11986}
{event_task : 'excpt_ioupdate','KBus error','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,10,11986}
{event_task : 'excpt_dividebyzero','Division by zero. Only integer operations!','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,18,11986}
{event_task : 'excpt_noncontinuable','Exception handler','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,20,11986}
{event_task : 'after_reading_inputs','Called after reading of inputs','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,28,11986}
{event_task : 'before_writing_outputs','Called before writing of outputs','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,29,11986}
{event_task : 'debug_loop','Debug loop at breakpoint','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,31,11986}
{event_task : 'online_change','Is called after CodeInit() at Online-Change','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,33,11986}
{event_task : 'before_download','Is called before the Download starts','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,34,11986}
{event_task : 'event_login','Is called before the login service is performed','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,501,11986}
{event_task : 'eth_overload','Ethernet Overload','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,750,11986}
{event_task : 'eth_network_ready','Is called directly after the Network and the PLC are initialised','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,751,11986}
{event_task : 'blink_code','New blink code / Blink code cleared ( Call STATUS_GET_LAST_ERROR for details )','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,752,11986}
{event_task : 'interrupt_0','Interrupt Real Time Clock (every second)','','FUNCTION systemevent: DWORD VAR_INPUT dwEvent: DWORD; dwFilter: DWORD; dwOwner: DWORD; END_VAR '}{event_task_info : 0,1000,11986}
END_RESOURCE
_WORKSPACE
_GLOBALVISUALSETTINGS
_VISUALSETTINGSFLAGS : 0,0,0,0
_VISUALSETTINGSFLAGS : '','',''
_VISUALSETTINGSDYNTEXTFILECOUNT : 0
_VISUALBITMAPLISTCOUNT : 0
_END_GLOBALVISUALSETTINGS
_END_WORKSPACE

@ -1,15 +0,0 @@
rem Create Codesys EXP file
rem Build cmd file
set CODESYS="c:\Program Files (x86)\WAGO Software\CoDeSys V2.3\codesys.exe"
set PROJECT=test
del %PROJECT%.EXP
echo file open %PROJECT%.pro >> codesys_cmd_file.cmd
echo project export %PROJECT%.EXP >> codesys_cmd_file.cmd
rem echo file saveas %PROJECT%.lib internallib >> codesys_cmd_file.cmd
echo file close >> codesys_cmd_file.cmd
echo file quit >> codesys_cmd_file.cmd
%CODESYS% /noinfo /cmd codesys_cmd_file.cmd
rem Clean all when finished
del codesys_cmd_file.cmd

Binary file not shown.

@ -1,11 +0,0 @@
@echo off
call ../config.bat
for %%f in (test.*.php) do %php% -q "%%f" > "output/%%f.html"
cd output
for %%f in (*.html) do %diff% "%%f" ../ref/"%%f"
cd ..
pause
@echo on

@ -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,33 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
// Received bytes interpreting Mixed values
$data = Array (
"0" => 125, // 32098 (DINT)
"1" => 98,
"2" => 0,
"3" => 0,
"4" => 0, // 0 (DINT)
"5" => 0,
"6" => 0,
"7" => 0,
"8" => 0, // 0 (DINT)
"9" => 0,
"10" => 0,
"11" => 0,
"12" => 255, // -1 (DINT)
"13" => 255,
"14" => 255,
"15" => 255,
"16" => 158, // -25000 (INT)
"17" => 88,
"18" => 97, // 25000 (INT)
"19" => 168
);
// Print mixed values
foreach($data as $d)
echo ord(IecType::iecBYTE($d)) . "<br>";
?>

@ -1,50 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
// Received bytes interpreting Mixed values
$data = Array (
"0" => 0,
"1" => 1,
"2" => -1,
"3" => pow(2,31)-1,
"4" => -pow(2,31)
);
function byte2hex($value){
$h = dechex(($value >> 4) & 0x0F);
$l = dechex($value & 0x0F);
return "$h$l";
}
function printPacket($packet){
$str = "";
$str .= "Packet: ";
for($i=0;$i<strlen($packet);$i++){
$str .= byte2hex(ord($packet[$i]));
if($i % 2)
$str .= "_";
}
$str .= "</br>";
return $str;
}
echo "Endianing off <hr>";
// Print mixed values
for($i=0;$i<count($data);$i++) {
echo $data[$i] . " --> ";
$v = IecType::iecDINT($data[$i], 0);
echo printPacket($v);
"<br>";
}
echo "Endianing on <hr>";
// Print mixed values
for($i=0;$i<count($data);$i++) {
echo $data[$i] . " --> ";
$v = IecType::iecDINT($data[$i], 1);
echo printPacket($v);
"<br>";
}
?>

@ -1,50 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
// Received bytes interpreting Mixed values
$data = Array (
"0" => 0,
"1" => 1,
"2" => -1,
"3" => pow(2,15)-1,
"4" => -pow(2,15)
);
function byte2hex($value){
$h = dechex(($value >> 4) & 0x0F);
$l = dechex($value & 0x0F);
return "$h$l";
}
function printPacket($packet){
$str = "";
$str .= "Packet: ";
for($i=0;$i<strlen($packet);$i++){
$str .= byte2hex(ord($packet[$i]));
if($i % 2)
$str .= "_";
}
$str .= "</br>";
return $str;
}
echo "Endianing off <hr>";
// Print mixed values
for($i=0;$i<count($data);$i++) {
echo $data[$i] . " --> ";
$v = IecType::iecINT($data[$i], 0);
echo printPacket($v);
"<br>";
}
echo "Endianing on <hr>";
// Print mixed values
for($i=0;$i<count($data);$i++) {
echo $data[$i] . " --> ";
$v = IecType::iecINT($data[$i], 1);
echo printPacket($v);
"<br>";
}
?>

@ -1,50 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
// http://en.wikipedia.org/wiki/Single_precision
$data = Array (
"0" => 0, // -> 0000 0000
"1" => 1, // -> 3f80 0000
"2" => -2, // -> c000 0000
"3" => 0.333333333333, //1/3 -> 3eaa aaab
"4" => 25 // -> 41c8 0000
);
function byte2hex($value){
$h = dechex(($value >> 4) & 0x0F);
$l = dechex($value & 0x0F);
return "$h$l";
}
function printPacket($packet){
$str = "";
$str .= "Packet: ";
for($i=0;$i<strlen($packet);$i++){
$str .= byte2hex(ord($packet[$i]));
if($i % 2)
$str .= "_";
}
$str .= "<br>\n";
return $str;
}
echo "Endianing off <hr>\n";
// Print mixed values
for($i=0;$i<count($data);$i++) {
echo $data[$i] . " --> ";
$v = IecType::iecREAL($data[$i], 0);
echo printPacket($v);
"<br>\n";
}
echo "Endianing on <hr>\n";
// Print mixed values
for($i=0;$i<count($data);$i++) {
echo $data[$i] . " --> ";
$v = IecType::iecREAL($data[$i], 1);
echo printPacket($v);
"<br>\n";
}
?>

@ -1,11 +0,0 @@
@echo off
call ../config.bat
for %%f in (test.*.php) do %php% -q "%%f" > "output/%%f.html"
cd output
for %%f in (*.html) do %diff% "%%f" ../ref/"%%f"
cd ..
pause
@echo on

@ -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,44 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMaster.php';
require_once dirname(__FILE__) . '/../config.php';
// Create Modbus object
$modbus = new ModbusMaster($test_host_ip, "TCP");
// Data to be writen - BYTE
$data = array(0, 1, 1, pow(2,8)-1, pow(2,8)-1);
$dataTypes = array("BYTE", "BYTE", "BYTE", "BYTE", "BYTE");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 5);
print_r($recData);
// Data to be writen - INT
$data = array(0, 1, -1, pow(2,15)-1, -pow(2,15));
$dataTypes = array("INT", "INT", "INT", "INT", "INT");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 5);
print_r($recData);
// Data to be writen - DINT
$data = array(0, 1, -1, pow(2,31)-1, -pow(2,31));
$dataTypes = array("DINT", "DINT", "DINT", "DINT", "DINT");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 10);
print_r($recData);
// Data to be writen - REAL
$data = array(0, 1, -2, 1/3, 25);
$dataTypes = array("REAL", "REAL", "REAL", "REAL", "REAL");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 10);
print_r($recData);
?>

@ -1,24 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMaster.php';
require_once dirname(__FILE__) . '/../config.php';
// Create Modbus object
$modbus = new ModbusMaster($test_host_ip, "TCP");
// Data to be writen
$data = array(1000, 2000, 1.250, 1.250);
$dataTypes = array("REAL", "REAL", "REAL", "REAL");
// FC23
$recData = $modbus->readWriteRegisters(0, 12288, 6, 12288, $data, $dataTypes);
if(!$recData) {
// Print error information if any
echo "</br>Error:</br>" . $modbus->errstr . "</br>";
//
exit();
}
// Print status information
echo "writeMultipleRegister (FC26): DONE";
?>

@ -1,22 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMaster.php';
require_once dirname(__FILE__) . '/../config.php';
// Create Modbus object
$modbus = new ModbusMaster($test_host_ip, "Mismatch");
// Data to be writen
$data = array(1000, 2000, 1.250, 1.250);
$dataTypes = array("REAL", "REAL", "REAL", "REAL");
// FC23
try {
$recData = $modbus->readWriteRegisters(0, 12288, 6, 12288, $data, $dataTypes);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
exit();
}
// Should through an Exception
// Print status information
echo "Should never reach this line!";

@ -1,44 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMaster.php';
require_once dirname(__FILE__) . '/../config.php';
// Create Modbus object
$modbus = new ModbusMaster($test_host_ip, "UDP");
// Data to be writen - BYTE
$data = array(0, 1, 1, pow(2,8)-1, pow(2,8)-1);
$dataTypes = array("BYTE", "BYTE", "BYTE", "BYTE", "BYTE");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 5);
print_r($recData);
// Data to be writen - INT
$data = array(0, 1, -1, pow(2,15)-1, -pow(2,15));
$dataTypes = array("INT", "INT", "INT", "INT", "INT");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 5);
print_r($recData);
// Data to be writen - DINT
$data = array(0, 1, -1, pow(2,31)-1, -pow(2,31));
$dataTypes = array("DINT", "DINT", "DINT", "DINT", "DINT");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 10);
print_r($recData);
// Data to be writen - REAL
$data = array(0, 1, -2, 1/3, 25);
$dataTypes = array("REAL", "REAL", "REAL", "REAL", "REAL");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 10);
print_r($recData);
?>

@ -1,24 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMaster.php';
require_once dirname(__FILE__) . '/../config.php';
// Create Modbus object
$modbus = new ModbusMaster($test_host_ip, "UDP");
// Data to be writen
$data = array(1000, 2000, 1.250, 1.250);
$dataTypes = array("REAL", "REAL", "REAL", "REAL");
// FC23
$recData = $modbus->readWriteRegisters(0, 12288, 6, 12288, $data, $dataTypes);
if(!$recData) {
// Print error information if any
echo "</br>Error:</br>" . $modbus->errstr . "</br>";
//
exit();
}
// Print status information
echo "writeMultipleRegister (FC26): DONE";
?>

@ -1,11 +0,0 @@
@echo off
call ../config.bat
for %%f in (test.*.php) do %php% -q "%%f" > "output/%%f.html"
cd output
for %%f in (*.html) do %diff% "%%f" ../ref/"%%f"
cd ..
pause
@echo on

@ -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,44 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterTcp.php';
require_once dirname(__FILE__) . '/../config.php';
// Create Modbus object
$modbus = new ModbusMasterTcp($test_host_ip);
// Data to be writen - BYTE
$data = array(0, 1, 1, pow(2,8)-1, pow(2,8)-1);
$dataTypes = array("BYTE", "BYTE", "BYTE", "BYTE", "BYTE");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 5);
print_r($recData);
// Data to be writen - INT
$data = array(0, 1, -1, pow(2,15)-1, -pow(2,15));
$dataTypes = array("INT", "INT", "INT", "INT", "INT");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 5);
print_r($recData);
// Data to be writen - DINT
$data = array(0, 1, -1, pow(2,31)-1, -pow(2,31));
$dataTypes = array("DINT", "DINT", "DINT", "DINT", "DINT");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 10);
print_r($recData);
// Data to be writen - REAL
$data = array(0, 1, -2, 1/3, 25);
$dataTypes = array("REAL", "REAL", "REAL", "REAL", "REAL");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 10);
print_r($recData);
?>

@ -1,24 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterTcp.php';
require_once dirname(__FILE__) . '/../config.php';
// Create Modbus object
$modbus = new ModbusMasterTcp($test_host_ip);
// Data to be writen
$data = array(1000, 2000, 1.250, 1.250);
$dataTypes = array("REAL", "REAL", "REAL", "REAL");
// FC23
$recData = $modbus->readWriteRegisters(0, 12288, 6, 12288, $data, $dataTypes);
if(!$recData) {
// Print error information if any
echo "</br>Error:</br>" . $modbus->errstr . "</br>";
//
exit();
}
// Print status information
echo "writeMultipleRegister (FC26): DONE";
?>

@ -1,11 +0,0 @@
@echo off
call ../config.bat
for %%f in (test.*.php) do %php% -q "%%f" > "output/%%f.html"
cd output
for %%f in (*.html) do %diff% "%%f" ../ref/"%%f"
cd ..
pause
@echo on

@ -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,7 +0,0 @@
Test should pass when %IX0.0==FALSE and %IX0.1==TRUE
array(2) {
[0]=>
bool(false)
[1]=>
bool(true)
}

@ -1 +0,0 @@
writeMultipleRegister (FC26): DONE

@ -1 +0,0 @@
writeMultipleRegister (FC26): DONE

@ -1,11 +0,0 @@
Test should pass when %IX0.0==FALSE and %IX0.1==TRUE
array(4) {
[0]=>
int(0)
[1]=>
int(2)
[2]=>
int(0)
[3]=>
int(0)
}

@ -1,5 +0,0 @@
Array
(
[0] => 0
[1] => 5
)

@ -1,5 +0,0 @@
Array
(
[0] => 207
[1] => 199
)

@ -1,22 +0,0 @@
<?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 - BOOL array
$data = array(1, 0, TRUE, TRUE, 0, 1, TRUE, TRUE,
1, 1, TRUE, TRUE, 0, 0, FALSE, FALSE,
0, 0, FALSE, FALSE, 1, 1, TRUE, TRUE,
1, 1, TRUE, TRUE, 1, 1, TRUE, TRUE);
// Write data - FC 15
$modbus->writeMultipleCoils(0, 12288, $data);
//echo $modbus->status;
//$modbus->status = "";
//echo "\n\n";
// Read data - FC 1
$recData = $modbus->readCoils(0, 12288, 32);
//echo $modbus->status;
//echo "\n\n";
var_dump($recData);

@ -1,44 +0,0 @@
<?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 - BYTE
$data = array(0, 1, 1, pow(2,8)-1, pow(2,8)-1);
$dataTypes = array("BYTE", "BYTE", "BYTE", "BYTE", "BYTE");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 5);
print_r($recData);
// Data to be writen - INT
$data = array(0, 1, -1, pow(2,15)-1, -pow(2,15));
$dataTypes = array("INT", "INT", "INT", "INT", "INT");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 5);
print_r($recData);
// Data to be writen - DINT
$data = array(0, 1, -1, pow(2,31)-1, -pow(2,31));
$dataTypes = array("DINT", "DINT", "DINT", "DINT", "DINT");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 10);
print_r($recData);
// Data to be writen - REAL
$data = array(0, 1, -2, 1/3, 25);
$dataTypes = array("REAL", "REAL", "REAL", "REAL", "REAL");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 10);
print_r($recData);
?>

@ -1,45 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
require_once dirname(__FILE__) . '/../config.php';
// Create Modbus object
$modbus = new ModbusMasterUdp($test_host_ip);
$modbus->client = $test_bind_client_ip;
// Data to be writen - BYTE
$data = array(0, 1, 1, pow(2,8)-1, pow(2,8)-1);
$dataTypes = array("BYTE", "BYTE", "BYTE", "BYTE", "BYTE");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 5);
print_r($recData);
// Data to be writen - INT
$data = array(0, 1, -1, pow(2,15)-1, -pow(2,15));
$dataTypes = array("INT", "INT", "INT", "INT", "INT");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 5);
print_r($recData);
// Data to be writen - DINT
$data = array(0, 1, -1, pow(2,31)-1, -pow(2,31));
$dataTypes = array("DINT", "DINT", "DINT", "DINT", "DINT");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 10);
print_r($recData);
// Data to be writen - REAL
$data = array(0, 1, -2, 1/3, 25);
$dataTypes = array("REAL", "REAL", "REAL", "REAL", "REAL");
// Write data - FC 16
$modbus->writeMultipleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 10);
print_r($recData);
?>

@ -1,14 +0,0 @@
<?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 2
$recData = $modbus->readInputDiscretes(0, 0, 2);
var_dump($recData);

@ -1,24 +0,0 @@
<?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
$data = array(1000, 2000, 1.250, 1.250);
$dataTypes = array("REAL", "REAL", "REAL", "REAL");
// FC23
$recData = $modbus->readWriteRegisters(0, 12288, 6, 12288, $data, $dataTypes);
if(!$recData) {
// Print error information if any
echo "</br>Error:</br>" . $modbus->errstr . "</br>";
//
exit();
}
// Print status information
echo "writeMultipleRegister (FC26): DONE";
?>

@ -1,25 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
require_once dirname(__FILE__) . '/../config.php';
// Create Modbus object
$modbus = new ModbusMasterUdp($test_host_ip);
$modbus->client = $test_bind_client_ip;
// Data to be writen
$data = array(1000, 2000, 1.250, 1.250);
$dataTypes = array("REAL", "REAL", "REAL", "REAL");
// FC23
$recData = $modbus->readWriteRegisters(0, 12288, 6, 12288, $data, $dataTypes);
if(!$recData) {
// Print error information if any
echo "</br>Error:</br>" . $modbus->errstr . "</br>";
//
exit();
}
// Print status information
echo "writeMultipleRegister (FC26): DONE";
?>

@ -1,14 +0,0 @@
<?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);

@ -1,23 +0,0 @@
<?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,15 +0,0 @@
<?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 - INT
$data = array(-12345);
$dataTypes = array("INT");
// Write data - FC6
$modbus->writeSingleRegister(0, 12288, $data, $dataTypes);
// Read data - FC3
$recData = $modbus->readMultipleRegisters(0, 12288, 1);
print_r($recData);

@ -1,11 +0,0 @@
@echo off
call ../config.bat
for %%f in (test.*.php) do %php% -q "%%f" > "output/%%f.html"
cd output
for %%f in (*.html) do %diff% "%%f" ../ref/"%%f"
cd ..
pause
@echo on

@ -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'

@ -1,37 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
// Received bytes interpreting Mixed values
$data = Array (
"0" => 125, // 32098 (DINT)
"1" => 98,
"2" => 0,
"3" => 0,
"4" => 0, // 0 (DINT)
"5" => 0,
"6" => 0,
"7" => 0,
"8" => 0, // 0 (DINT)
"9" => 0,
"10" => 0,
"11" => 0,
"12" => 255, // -1 (DINT)
"13" => 255,
"14" => 255,
"15" => 255,
"16" => 158, // -25000 (INT)
"17" => 88,
"18" => 97, // 25000 (INT)
"19" => 168
);
// Print mixed values
echo PhpType::bytes2unsignedInt(array_slice($data, 0, 4)) . "<br>";
echo PhpType::bytes2signedInt(array_slice($data, 4, 4)) . "<br>";
echo PhpType::bytes2signedInt(array_slice($data, 8, 4)) . "<br>";
echo PhpType::bytes2signedInt(array_slice($data, 12, 4)) . "<br>";
echo PhpType::bytes2signedInt(array_slice($data, 16, 2)) . "<br>";
echo PhpType::bytes2signedInt(array_slice($data, 18, 2)) . "<br>";
?>

@ -1,27 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
// Received bytes interpreting 3 REAL values (6 words)
$data = array( // 1000
0 => 0,
1 => 0,
2 => 68,
3 => 122,
4 => 0,
5 => 0,
6 => 68,
7 => 250,
8 => 0,
9 => 0,
10 => 63,
11 => 160,
);
$dword = array_chunk($data, 4);
// Print float interpretation of the real value
echo PhpType::bytes2float($dword[0]) . "<br>";
echo PhpType::bytes2float($dword[1]) . "<br>";
echo PhpType::bytes2float($dword[2]) . "<br>";
?>

@ -1,35 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
// Received bytes interpreting DINT values
$data = array(
0xFF, // -1
0xFF,
0xFF,
0xFF,
0, // 0
0,
0,
0,
0, // 1
0x01,
0,
0,
0, // minus max
0,
0x80,
0x0,
0xFF, // plus max
0xFF,
0x7F,
0xFF,
);
$dword = array_chunk($data, 4);
// Print float interpretation of the real value
foreach($dword as $value) {
echo PhpType::bytes2signedInt($value) . "<br>";
}
?>

@ -1,28 +0,0 @@
<?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>";
?>

@ -1,36 +0,0 @@
<?php
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php';
// Received bytes interpreting DINT values
$data = array(
0xFF, // -1
0xFF,
0xFF,
0xFF,
0, // 0
0,
0,
0,
0, // 1
0x01,
0,
0,
0, // minus max
0,
0x80,
0x0,
0xFF, // plus max
0xFF,
0x7F,
0xFF,
);
$dword = array_chunk($data, 4);
// Print float interpretation of the real value
foreach($dword as $value) {
var_dump(PhpType::bytes2unsignedInt($value));
echo "<br>";
}
?>

@ -1,44 +0,0 @@
<?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>";
}
?>

@ -1,22 +0,0 @@
<?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'";
}
?>

@ -1,3 +0,0 @@
Probably broken and dubious.
Left from the original repo.

@ -1,5 +0,0 @@
set php=c:\Program_Files\xampp\php\php.exe
rem set php=C:\PHP\versions\php-5.2.6-Win32\php.exe -d auto_prepend_file=C:\PHP\locale.php
set diff="diff.exe"
rem set testUri=http://localHost/nette/_trunk/tests
rem set wget=wget.exe

@ -1,3 +0,0 @@
<?php
$test_host_ip = "192.192.1.10";
$test_bind_client_ip = "192.192.1.100";
Loading…
Cancel
Save