read more than 2048 bytes from stream

pull/2/head
toimtoimtoim 8 years ago
parent 8c482eee3d
commit 2fbbbc5842
  1. 1
      .travis.yml
  2. 5
      src/ModbusSocket.php

@ -13,7 +13,6 @@ php:
branches: branches:
only: only:
- /^dev-.*$/ - /^dev-.*$/
- phpunit-support
before_install: before_install:
- travis_retry composer self-update - travis_retry composer self-update

@ -150,14 +150,15 @@ class ModbusSocket
$read = array($this->streamSocket); $read = array($this->streamSocket);
$write = null; $write = null;
$except = null; $except = null;
$data = '';
if (false !== stream_select($read, $write, $except, $readTimeout['sec'], $readTimeout['usec'])) { if (false !== stream_select($read, $write, $except, $readTimeout['sec'], $readTimeout['usec'])) {
$this->statusMessages[] = 'Wait data ... '; $this->statusMessages[] = 'Wait data ... ';
if (in_array($this->streamSocket, $read, false)) { 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)) { if (!empty($data)) {
$this->statusMessages[] = 'Data received'; $this->statusMessages[] = 'Data received';
return $data; //FIXME what if we are waiting for more than that? return $data;
} }
$lastAccess = microtime(true); $lastAccess = microtime(true);
} else { } else {

Loading…
Cancel
Save