Replies: 1 comment 1 reply
-
you are missing this block modbus-tcp-client/examples/example_parallel_requests_amp.php Lines 66 to 74 in 436d85d in case of write request. You still need to parse response. In parse ( $response = ResponseFactory::parseResponse($binaryData)->withStartAddress($this->request->getStartAddress());
if ($response instanceof ErrorResponse) {
return $response;
} you could do $data = b'';
while (null !== $chunk = yield $socket->read()) {
// there are rare cases when MODBUS packet is received by multiple fragmented TCP packets and it could
// take PHP multiple reads from stream to get full packet. So we concatenate data and check if all that
// we have received makes a complete modbus packet.
// NB: `Packet::isCompleteLength` is suitable only for modbus TCP packets
$data .= $chunk;
if (Packet::isCompleteLength($data)) {
return ResponseFactory::parseResponse($data)->withStartAddress($this->request->getStartAddress());
// return ResponseFactory::parseResponseOrThrow($data)->withStartAddress($this->request->getStartAddress());
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I already check the example of Parallel Request Amp and now i want a little bit different.
as you can see, i have confuse to handle response. Hope you help me to deal with this.
Beta Was this translation helpful? Give feedback.
All reactions