Skip to content

Commit b170320

Browse files
committed
fix RTU over TCP example - default isComplete callback should not be used for RTU
1 parent 26f6780 commit b170320

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

examples/rtu.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
->setPort(502)
1111
->setHost('127.0.0.1')
1212
->setReadTimeoutSec(3) // increase read timeout to 3 seconds
13+
->setIsCompleteCallback(function ($binaryData, $streamIndex) {
14+
// Do not check for complete TCP packet structure. Default implementation works only for Modbus TCP.
15+
// Modbus TCP has 7 byte header and this function checks for it and whole packet to be complete. RTU does
16+
// not have that.
17+
// Read about differences here: https://www.simplymodbus.ca/TCP.htm
18+
return true;
19+
})
1320
->build();
1421

1522
$startAddress = 256;

0 commit comments

Comments
 (0)