0.6 release

pull/1/head 0.6
John Long 11 years ago
parent 7f4c4f2af1
commit 5f069276eb
  1. 12
      Phpmodbus/IecType.php
  2. 1810
      Phpmodbus/ModbusMaster.php
  3. 6
      Phpmodbus/PhpType.php
  4. 26
      examples/example_fc2.php
  5. 26
      examples/example_fc6.php
  6. BIN
      tests/Codesys/DEFAULT.DFR
  7. 256
      tests/Codesys/TEST.EXP
  8. 15
      tests/Codesys/_make_exp.cmd
  9. BIN
      tests/Codesys/test.SDB
  10. 4
      tests/Codesys/test.SYM
  11. BIN
      tests/Codesys/test.pro
  12. BIN
      tests/Codesys/test00002ed2r.ci
  13. BIN
      tests/Codesys/test00002ed2r.ri
  14. 1
      tests/IecType/output/test.iecByte.php.html
  15. 1
      tests/IecType/output/test.iecDInt.php.html
  16. 1
      tests/IecType/output/test.iecInt.php.html
  17. 12
      tests/IecType/output/test.iecReal.php.html
  18. 24
      tests/IecType/ref/test.iecReal.php.html
  19. 2
      tests/IecType/test.iecReal.php
  20. 72
      tests/ModbusMaster/output/test.tcp.fc16fc3.php.html
  21. 1
      tests/ModbusMaster/output/test.tcp.fc26.php.html
  22. 1
      tests/ModbusMaster/output/test.tcp.socket_protocol_mismatch.php.html
  23. 72
      tests/ModbusMaster/output/test.udp.fc16fc3.php.html
  24. 1
      tests/ModbusMaster/output/test.udp.fc26.php.html
  25. 8
      tests/ModbusMaster/ref/test.tcp.socket_protocol_mismatch.php.html
  26. 10
      tests/ModbusMaster/test.tcp.socket_protocol_mismatch.php
  27. 72
      tests/ModbusMasterTcp/output/test.fc16fc3.php.html
  28. 1
      tests/ModbusMasterTcp/output/test.fc26.php.html
  29. 66
      tests/ModbusMasterUdp/output/test.fc15fc1.php.html
  30. 72
      tests/ModbusMasterUdp/output/test.fc16fc3.php.html
  31. 72
      tests/ModbusMasterUdp/output/test.fc16fc3bind.php.html
  32. 7
      tests/ModbusMasterUdp/output/test.fc2.php.html
  33. 1
      tests/ModbusMasterUdp/output/test.fc26.php.html
  34. 1
      tests/ModbusMasterUdp/output/test.fc26bind.php.html
  35. 5
      tests/ModbusMasterUdp/output/test.fc6fc3.php.html
  36. 66
      tests/ModbusMasterUdp/ref/test.fc15fc1.php.html
  37. 2
      tests/ModbusMasterUdp/ref/test.fc16fc3.php.html
  38. 7
      tests/ModbusMasterUdp/ref/test.fc2.php.html
  39. 5
      tests/ModbusMasterUdp/ref/test.fc6fc3.php.html
  40. 10
      tests/ModbusMasterUdp/test.fc15fc1.php
  41. 14
      tests/ModbusMasterUdp/test.fc2.php
  42. 15
      tests/ModbusMasterUdp/test.fc6fc3.php
  43. 1
      tests/PhpType/output/test.bytes2mixed.php.html
  44. 1
      tests/PhpType/output/test.bytes2real.php.html
  45. 1
      tests/PhpType/output/test.bytes2signedint.php.html
  46. 1
      tests/PhpType/output/test.bytes2string.php.html
  47. 6
      tests/PhpType/output/test.bytes2unsignedint.php.html
  48. 1
      tests/PhpType/output/test.strangearray.size.php.html
  49. 1
      tests/PhpType/output/test.strangearray.textarray.php.html
  50. 2
      tests/config.bat
  51. 5
      tests/config.php
  52. 23
      tutorials/Phpmodbus/Phpmodbus.pkg

@ -34,7 +34,7 @@ class IecType {
* @return value IEC BYTE data type
*
*/
function iecBYTE($value) {
public static function iecBYTE($value) {
return chr($value & 0xFF);
}
@ -47,7 +47,7 @@ class IecType {
* @return value IEC-1131 INT data type
*
*/
function iecINT($value) {
public static function iecINT($value) {
return self::iecBYTE(($value >> 8) & 0x00FF) .
self::iecBYTE(($value & 0x00FF));
}
@ -62,7 +62,7 @@ class IecType {
* @return value IEC-1131 INT data type
*
*/
function iecDINT($value, $endianness = 0) {
public static function iecDINT($value, $endianness = 0) {
// result with right endianness
return self::endianness($value, $endianness);
}
@ -76,7 +76,7 @@ class IecType {
* @param value endianness defines endian codding (little endian == 0, big endian == 1)
* @return value IEC-1131 REAL data type
*/
function iecREAL($value, $endianness = 0) {
public static function iecREAL($value, $endianness = 0) {
// iecREAL representation
$real = self::float2iecReal($value);
// result with right endianness
@ -95,7 +95,7 @@ class IecType {
* @param float value to be converted
* @return value IEC REAL data type
*/
private function float2iecReal($value) {
private static function float2iecReal($value) {
// get float binary string
$float = pack("f", $value);
// set 32-bit unsigned integer of the float
@ -113,7 +113,7 @@ class IecType {
* @param bool $endianness
* @return int
*/
private function endianness($value, $endianness = 0) {
private static function endianness($value, $endianness = 0) {
if ($endianness == 0)
return
self::iecBYTE(($value >> 8) & 0x000000FF) .

File diff suppressed because it is too large Load Diff

@ -1,12 +1,12 @@
<?php
/**
* Phpmodbus Copyright (c) 2004, 2010 Jan Krakora, WAGO Kontakttechnik GmbH & Co. KG (http://www.wago.com)
* Phpmodbus Copyright (c) 2004, 2012 Jan Krakora
*
* This source file is subject to the "PhpModbus license" that is bundled
* with this package in the file license.txt.
*
* @author Jan Krakora
* @copyright Copyright (c) 2004, 2010 Jan Krakora, WAGO Kontakttechnik GmbH & Co. KG (http://www.wago.com)
* @copyright Copyright (c) 2004, 2012 Jan Krakora
* @license PhpModbus license
* @category Phpmodbus
* @package Phpmodbus
@ -21,7 +21,7 @@
* (array of bytes) to the PHP data type, i.e. signed int, unsigned int and float.
*
* @author Jan Krakora
* @copyright Copyright (c) 2004, 2010 Jan Krakora, WAGO Kontakttechnik GmbH & Co. KG (http://www.wago.com)
* @copyright Copyright (c) 2004, 2012 Jan Krakora
* @package Phpmodbus
*
*/

@ -0,0 +1,26 @@
<?php
require_once dirname(__FILE__) . '/../Phpmodbus/ModbusMaster.php';
// 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>";

@ -0,0 +1,26 @@
<?php
require_once dirname(__FILE__) . '/../Phpmodbus/ModbusMaster.php';
// Create Modbus object
$modbus = new ModbusMaster("192.192.15.51", "UDP");
// Data to be writen
$data = array(-1000);
$dataTypes = array("INT");
try {
// FC6
$modbus->writeSingleRegister(0, 12288, $data, $dataTypes);
}
catch (Exception $e) {
// Print error information if any
echo $modbus;
echo $e;
exit;
}
// Print status information
echo $modbus;
?>

Binary file not shown.

@ -0,0 +1,256 @@
(* @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

@ -0,0 +1,15 @@
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.

@ -0,0 +1,4 @@
;Version=2
;ProjectId=114942
;Checksum=0
;Filesize=0

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1 @@
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>

@ -0,0 +1 @@
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>

@ -0,0 +1 @@
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>

@ -0,0 +1,12 @@
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,12 +1,12 @@
Endianing off <hr>
0 --> Packet: 0000_0000_<br>
1 --> Packet: 0000_3f80_<br>
-2 --> Packet: 0000_c000_<br>
0.333333333333 --> Packet: aaaa_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_aaaa_<br>
25 --> Packet: 41c8_0000_<br>
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>

@ -7,7 +7,7 @@ $data = Array (
"0" => 0, // -> 0000 0000
"1" => 1, // -> 3f80 0000
"2" => -2, // -> c000 0000
"3" => 1/3, // -> 3eaa aaab
"3" => 0.333333333333, //1/3 -> 3eaa aaab
"4" => 25 // -> 41c8 0000
);

@ -0,0 +1,72 @@
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 1
[4] => 0
[5] => 1
[6] => 0
[7] => 255
[8] => 0
[9] => 255
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 1
[4] => 255
[5] => 255
[6] => 127
[7] => 255
[8] => 128
[9] => 0
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 1
[6] => 0
[7] => 0
[8] => 255
[9] => 255
[10] => 255
[11] => 255
[12] => 255
[13] => 255
[14] => 127
[15] => 255
[16] => 0
[17] => 0
[18] => 128
[19] => 0
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 0
[6] => 63
[7] => 128
[8] => 0
[9] => 0
[10] => 192
[11] => 0
[12] => 170
[13] => 171
[14] => 62
[15] => 170
[16] => 0
[17] => 0
[18] => 65
[19] => 200
)

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

@ -0,0 +1 @@
Caught exception: Unknown socket protocol, should be 'TCP' or 'UDP'

@ -0,0 +1,72 @@
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 1
[4] => 0
[5] => 1
[6] => 0
[7] => 255
[8] => 0
[9] => 255
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 1
[4] => 255
[5] => 255
[6] => 127
[7] => 255
[8] => 128
[9] => 0
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 1
[6] => 0
[7] => 0
[8] => 255
[9] => 255
[10] => 255
[11] => 255
[12] => 255
[13] => 255
[14] => 127
[15] => 255
[16] => 0
[17] => 0
[18] => 128
[19] => 0
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 0
[6] => 63
[7] => 128
[8] => 0
[9] => 0
[10] => 192
[11] => 0
[12] => 170
[13] => 171
[14] => 62
[15] => 170
[16] => 0
[17] => 0
[18] => 65
[19] => 200
)

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

@ -1,7 +1 @@
Fatal error: Uncaught exception 'Exception' with message 'Unknown socket protocol, should be 'TCP' or 'UDP'' in D:\Projects\20081010_phpmodbus\src\trunk\Phpmodbus\ModbusMaster.php:87
Stack trace:
#0 D:\Projects\20081010_phpmodbus\src\trunk\Phpmodbus\ModbusMaster.php(654): ModbusMaster->connect()
#1 D:\Projects\20081010_phpmodbus\src\trunk\tests\ModbusMaster\test.tcp.socket_protocol_mismatch.php(13): ModbusMaster->readWriteRegisters(0, 12288, 6, 12288, Array, Array)
#2 {main}
thrown in D:\Projects\20081010_phpmodbus\src\trunk\Phpmodbus\ModbusMaster.php on line 87
Caught exception: Unknown socket protocol, should be 'TCP' or 'UDP'

@ -10,9 +10,13 @@ $data = array(1000, 2000, 1.250, 1.250);
$dataTypes = array("REAL", "REAL", "REAL", "REAL");
// FC23
$recData = $modbus->readWriteRegisters(0, 12288, 6, 12288, $data, $dataTypes);
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 "Something wrong!";
echo "Should never reach this line!";

@ -0,0 +1,72 @@
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 1
[4] => 0
[5] => 1
[6] => 0
[7] => 255
[8] => 0
[9] => 255
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 1
[4] => 255
[5] => 255
[6] => 127
[7] => 255
[8] => 128
[9] => 0
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 1
[6] => 0
[7] => 0
[8] => 255
[9] => 255
[10] => 255
[11] => 255
[12] => 255
[13] => 255
[14] => 127
[15] => 255
[16] => 0
[17] => 0
[18] => 128
[19] => 0
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 0
[6] => 63
[7] => 128
[8] => 0
[9] => 0
[10] => 192
[11] => 0
[12] => 170
[13] => 171
[14] => 62
[15] => 170
[16] => 0
[17] => 0
[18] => 65
[19] => 200
)

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

@ -0,0 +1,66 @@
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)
}

@ -0,0 +1,72 @@
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 1
[4] => 0
[5] => 1
[6] => 0
[7] => 255
[8] => 0
[9] => 255
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 1
[4] => 255
[5] => 255
[6] => 127
[7] => 255
[8] => 128
[9] => 0
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 1
[6] => 0
[7] => 0
[8] => 255
[9] => 255
[10] => 255
[11] => 255
[12] => 255
[13] => 255
[14] => 127
[15] => 255
[16] => 0
[17] => 0
[18] => 128
[19] => 0
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 0
[6] => 63
[7] => 128
[8] => 0
[9] => 0
[10] => 192
[11] => 0
[12] => 170
[13] => 171
[14] => 62
[15] => 170
[16] => 0
[17] => 0
[18] => 65
[19] => 200
)

@ -0,0 +1,72 @@
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 1
[4] => 0
[5] => 1
[6] => 0
[7] => 255
[8] => 0
[9] => 255
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 1
[4] => 255
[5] => 255
[6] => 127
[7] => 255
[8] => 128
[9] => 0
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 1
[6] => 0
[7] => 0
[8] => 255
[9] => 255
[10] => 255
[11] => 255
[12] => 255
[13] => 255
[14] => 127
[15] => 255
[16] => 0
[17] => 0
[18] => 128
[19] => 0
)
Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
[5] => 0
[6] => 63
[7] => 128
[8] => 0
[9] => 0
[10] => 192
[11] => 0
[12] => 170
[13] => 171
[14] => 62
[15] => 170
[16] => 0
[17] => 0
[18] => 65
[19] => 200
)

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

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

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

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

@ -0,0 +1,66 @@
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)
}

@ -62,7 +62,7 @@ Array
[10] => 192
[11] => 0
[12] => 170
[13] => 170
[13] => 171
[14] => 62
[15] => 170
[16] => 0

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

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

@ -12,11 +12,11 @@ $data = array(1, 0, TRUE, TRUE, 0, 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";
//echo $modbus->status;
//$modbus->status = "";
//echo "\n\n";
// Read data - FC 1
$recData = $modbus->readCoils(0, 12288, 32);
echo $modbus->status;
echo "\n\n";
//echo $modbus->status;
//echo "\n\n";
var_dump($recData);

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

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

@ -0,0 +1 @@
32098<br>0<br>0<br>-1<br>-25000<br>25000<br>

@ -0,0 +1 @@
-1<br>0<br>1<br>-2147483648<br>2147483647<br>

@ -0,0 +1 @@
eHll oowlr!da<br>Hello world!<br>

@ -0,0 +1,6 @@
float(4294967295)
<br>int(0)
<br>int(1)
<br>float(2147483648)
<br>int(2147483647)
<br>

@ -0,0 +1 @@
Exception 'Data are not in array 2 or 4 bytes'<br>25602<br>Exception 'Data are not in array 2 or 4 bytes'<br>25602<br>Exception 'Data are not in array 2 or 4 bytes'<br>

@ -1,4 +1,4 @@
set php=c:\Program_Files\xampplite\php\php.exe
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

@ -1,4 +1,3 @@
<?php
$test_host_ip = "192.192.15.51";
$test_bind_client_ip = "192.192.15.113";
?>
$test_host_ip = "192.168.1.105";
$test_bind_client_ip = "192.168.1.106";

@ -22,7 +22,9 @@
The library implements:
<itemizedlist>
<listitem><para>FC 1: read multiple coils</para></listitem>
<listitem><para>FC 2: read input discretes</para></listitem>
<listitem><para>FC 3: read multiple registers</para></listitem>
<listitem><para>FC 6: write single register</para></listitem>
<listitem><para>FC 15: write multiple coils</para></listitem>
<listitem><para>FC 16: write multiple registers</para></listitem>
<listitem><para>FC 23: read write registers</para></listitem>
@ -32,9 +34,6 @@
For more about Modbus protocol see [{@link http://www.modbus.org}] or
[{@link http://en.wikipedia.org/wiki/Modbus Wiki}]
</para>
<note>
Developed with support of <graphic fileref="wago_logo.png"/> {@link http://www.wago.com}.
</note>
</refsect1>
<refsect1 id="{@id install}">
<title>Install</title>
@ -104,6 +103,15 @@ catch (Exception $e) {
{@example example_fc1.php}
</para>
</refsect2>
<refsect2 id="{@id example_fc2}">
<title>FC2 - read input discretes</title>
<para>
FC2 functionality example
</para>
<para>
{@example example_fc2.php}
</para>
</refsect2>
<refsect2 id="{@id example_fc3}">
<title>FC3 - read mutliple registers</title>
<para>
@ -113,6 +121,15 @@ catch (Exception $e) {
{@example example_fc3.php}
</para>
</refsect2>
<refsect2 id="{@id example_fc6}">
<title>FC6 - write single register</title>
<para>
FC6 functionality example
</para>
<para>
{@example example_fc6.php}
</para>
</refsect2>
<refsect2 id="{@id example_fc15}">
<title>FC15 - write mutliple coils</title>
<para>

Loading…
Cancel
Save