From 2fbbbc584214f69ce753c32b3cd7df2907eb8634 Mon Sep 17 00:00:00 2001 From: toimtoimtoim Date: Mon, 28 Nov 2016 00:22:42 +0200 Subject: [PATCH] read more than 2048 bytes from stream --- .travis.yml | 1 - src/ModbusSocket.php | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 90e8fde..6fcd103 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,6 @@ php: branches: only: - /^dev-.*$/ - - phpunit-support before_install: - travis_retry composer self-update diff --git a/src/ModbusSocket.php b/src/ModbusSocket.php index a1fa61a..479155b 100644 --- a/src/ModbusSocket.php +++ b/src/ModbusSocket.php @@ -150,14 +150,15 @@ class ModbusSocket $read = array($this->streamSocket); $write = null; $except = null; + $data = ''; if (false !== stream_select($read, $write, $except, $readTimeout['sec'], $readTimeout['usec'])) { $this->statusMessages[] = 'Wait data ... '; if (in_array($this->streamSocket, $read, false)) { - $data = fread($this->streamSocket, 2048); // read max 2048 bytes + $data .= fread($this->streamSocket, 2048); // read max 2048 bytes if (!empty($data)) { $this->statusMessages[] = 'Data received'; - return $data; //FIXME what if we are waiting for more than that? + return $data; } $lastAccess = microtime(true); } else {