Change DEBUG to a static const

This commit is contained in:
Deon George 2023-07-19 10:27:47 +10:00
parent ee03604de3
commit dcae06aad9
5 changed files with 48 additions and 48 deletions

View File

@ -14,7 +14,7 @@ use App\Models\{Address,Setup,System,SystemLog};
abstract class Protocol abstract class Protocol
{ {
// Enable extra debugging // Enable extra debugging
protected bool $DEBUG = FALSE; protected const DEBUG = FALSE;
private const LOGKEY = 'P--'; private const LOGKEY = 'P--';

View File

@ -362,7 +362,7 @@ final class Binkp extends BaseProtocol
} catch (SocketException $e) { } catch (SocketException $e) {
if ($e->getCode() === 11) { if ($e->getCode() === 11) {
// @todo We maybe should count these and abort if there are too many? // @todo We maybe should count these and abort if there are too many?
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:- Got a socket EAGAIN',self::LOGKEY)); Log::debug(sprintf('%s:- Got a socket EAGAIN',self::LOGKEY));
return TRUE; return TRUE;
@ -424,7 +424,7 @@ final class Binkp extends BaseProtocol
return TRUE; return TRUE;
} }
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - binkp_recv BUFFER [%d]',self::LOGKEY,strlen($this->rx_buf))); Log::debug(sprintf('%s: - binkp_recv BUFFER [%d]',self::LOGKEY,strlen($this->rx_buf)));
$msg = ord(substr($this->rx_buf,0,1)); $msg = ord(substr($this->rx_buf,0,1));
@ -534,7 +534,7 @@ final class Binkp extends BaseProtocol
$rc = TRUE; $rc = TRUE;
} }
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:= binkp_recv [%d]',self::LOGKEY,$rc)); Log::debug(sprintf('%s:= binkp_recv [%d]',self::LOGKEY,$rc));
return $rc; return $rc;

View File

@ -277,7 +277,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
*/ */
private function emsi_parsedat(string $str): int private function emsi_parsedat(string $str): int
{ {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:+ emsi_parsedat',self::LOGKEY)); Log::debug(sprintf('%s:+ emsi_parsedat',self::LOGKEY));
$l = 0; $l = 0;
@ -826,7 +826,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
*/ */
protected function protocol_init(): int protected function protocol_init(): int
{ {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:+ Starting EMSI Protocol INIT',self::LOGKEY)); Log::debug(sprintf('%s:+ Starting EMSI Protocol INIT',self::LOGKEY));
$got = 0; $got = 0;
@ -852,7 +852,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
$t2 = $this->client->timer_set(self::EMSI_RESEND_TO); $t2 = $this->client->timer_set(self::EMSI_RESEND_TO);
while (TRUE) { while (TRUE) {
$ch = $this->client->read_ch(max( 1,min($this->client->timer_rest($t1),$this->client->timer_rest($t2)))); $ch = $this->client->read_ch(max( 1,min($this->client->timer_rest($t1),$this->client->timer_rest($t2))));
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:- Got [%x] (%c)',self::LOGKEY,$ch,$ch)); Log::debug(sprintf('%s:- Got [%x] (%c)',self::LOGKEY,$ch,$ch));
if (($ch != self::TIMEOUT) && ($ch < 0)) if (($ch != self::TIMEOUT) && ($ch < 0))
@ -918,7 +918,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
while (! $this->client->timer_expired($t1)) { while (! $this->client->timer_expired($t1)) {
$ch = $this->client->read_ch(max( 1,min($this->client->timer_rest($t1),$this->client->timer_rest($t2)))); $ch = $this->client->read_ch(max( 1,min($this->client->timer_rest($t1),$this->client->timer_rest($t2))));
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:- Got [%x] (%c)',self::LOGKEY,$ch,$ch)); Log::debug(sprintf('%s:- Got [%x] (%c)',self::LOGKEY,$ch,$ch));
if (($ch != self::TIMEOUT) && ($ch < 0)) if (($ch != self::TIMEOUT) && ($ch < 0))

View File

@ -877,12 +877,12 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
case self::XOFF: case self::XOFF:
case self::XON|0x80: case self::XON|0x80:
case self::XOFF|0x80: case self::XOFF|0x80:
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zdonereceiver XON/XOFF, skip it',self::LOGKEY)); Log::debug(sprintf('%s: - ls_zdonereceiver XON/XOFF, skip it',self::LOGKEY));
break; break;
case self::ZPAD: case self::ZPAD:
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zdonereceiver ZPAD',self::LOGKEY)); Log::debug(sprintf('%s: - ls_zdonereceiver ZPAD',self::LOGKEY));
if (($rc=$this->ls_zrecvhdr($this->ls_rxHdr,$this->ls_HeaderTimeout)) < 0) if (($rc=$this->ls_zrecvhdr($this->ls_rxHdr,$this->ls_HeaderTimeout)) < 0)
@ -1085,7 +1085,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
*/ */
private function ls_zrecvdata16(string &$data,int &$len,int $timeout): int private function ls_zrecvdata16(string &$data,int &$len,int $timeout): int
{ {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:+ ls_zrecvdata16',self::LOGKEY),['d'=>$data]); Log::debug(sprintf('%s:+ ls_zrecvdata16',self::LOGKEY),['d'=>$data]);
$got = 0; /* Bytes total got */ $got = 0; /* Bytes total got */
@ -1094,7 +1094,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$rcvdata = 1; /* Data is being received NOW (not CRC) */ $rcvdata = 1; /* Data is being received NOW (not CRC) */
while ($rcvdata && (($c = $this->ls_readzdle($timeout)) >= 0)) { while ($rcvdata && (($c = $this->ls_readzdle($timeout)) >= 0)) {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvdata16 got [%x] (%c)',self::LOGKEY,$c,($c<31 ? 32 : $c)),['c'=>serialize($c)]); Log::debug(sprintf('%s: - ls_zrecvdata16 got [%x] (%c)',self::LOGKEY,$c,($c<31 ? 32 : $c)),['c'=>serialize($c)]);
if ($c < 256) { if ($c < 256) {
@ -1140,7 +1140,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$incrc = crc16($data.chr($frametype)); $incrc = crc16($data.chr($frametype));
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvdata16 CRC%d got %08x - calculated %08x',self::LOGKEY,16,$incrc,$crc)); Log::debug(sprintf('%s: - ls_zrecvdata16 CRC%d got %08x - calculated %08x',self::LOGKEY,16,$incrc,$crc));
if ($incrc != $crc) if ($incrc != $crc)
@ -1148,7 +1148,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$len = $got; $len = $got;
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:= ls_zrecvdata16 - frametype [%d]',self::LOGKEY,$frametype)); Log::debug(sprintf('%s:= ls_zrecvdata16 - frametype [%d]',self::LOGKEY,$frametype));
return $frametype; return $frametype;
@ -1164,7 +1164,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
*/ */
private function ls_zrecvdata32(string &$data,int &$len,int $timeout): int private function ls_zrecvdata32(string &$data,int &$len,int $timeout): int
{ {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:+ ls_zrecvdata32',self::LOGKEY),['d'=>$data]); Log::debug(sprintf('%s:+ ls_zrecvdata32',self::LOGKEY),['d'=>$data]);
$got = 0; /* Bytes total got */ $got = 0; /* Bytes total got */
@ -1173,7 +1173,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$rcvdata = 1; /* Data is being received NOW (not CRC) */ $rcvdata = 1; /* Data is being received NOW (not CRC) */
while ($rcvdata && (($c=$this->ls_readzdle($timeout)) >= 0)) { while ($rcvdata && (($c=$this->ls_readzdle($timeout)) >= 0)) {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvdata32 got [%x] (%c)',self::LOGKEY,$c,($c<31 ? 32 : $c)),['c'=>serialize($c)]); Log::debug(sprintf('%s: - ls_zrecvdata32 got [%x] (%c)',self::LOGKEY,$c,($c<31 ? 32 : $c)),['c'=>serialize($c)]);
if ($c < 256) { if ($c < 256) {
@ -1225,7 +1225,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$crc |= ($c << 0x18); $crc |= ($c << 0x18);
$incrc = crc32($data.chr($frametype)); $incrc = crc32($data.chr($frametype));
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvdata32 CRC%d got %08x - calculated %08x',self::LOGKEY,32,$incrc,$crc)); Log::debug(sprintf('%s: - ls_zrecvdata32 CRC%d got %08x - calculated %08x',self::LOGKEY,32,$incrc,$crc));
if ($incrc != $crc) if ($incrc != $crc)
@ -1233,7 +1233,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$len = $got; $len = $got;
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:= ls_zrecvdata32 - frametype [%d]',self::LOGKEY,$frametype)); Log::debug(sprintf('%s:= ls_zrecvdata32 - frametype [%d]',self::LOGKEY,$frametype));
return $frametype; return $frametype;
@ -1550,7 +1550,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
*/ */
private function ls_zrecvhdr(array &$hdr,int $timeout): int private function ls_zrecvhdr(array &$hdr,int $timeout): int
{ {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:+ Receive header with [%d] timeout',self::LOGKEY,$timeout)); Log::debug(sprintf('%s:+ Receive header with [%d] timeout',self::LOGKEY,$timeout));
$state = self::rhInit; $state = self::rhInit;
@ -1567,7 +1567,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$c = -1; $c = -1;
if ($state === self::rhInit) { if ($state === self::rhInit) {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:- ls_zrecvhdr Init State',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvhdr Init State',self::LOGKEY));
$frametype = self::ERROR; $frametype = self::ERROR;
@ -1581,7 +1581,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
} }
while ($rc=$this->client->hasData($timeout)) { while ($rc=$this->client->hasData($timeout)) {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:- ls_zrecvhdr hasData - readmode [%d], garbage chars [%d], state [%d]',self::LOGKEY,$readmode,$garbage,$state)); Log::debug(sprintf('%s:- ls_zrecvhdr hasData - readmode [%d], garbage chars [%d], state [%d]',self::LOGKEY,$readmode,$garbage,$state));
switch ($readmode) { switch ($readmode) {
@ -1602,7 +1602,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
} }
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvhdr [%x] (%c)',self::LOGKEY,$c,$c)); Log::debug(sprintf('%s: - ls_zrecvhdr [%x] (%c)',self::LOGKEY,$c,$c));
/* Here is error */ /* Here is error */
@ -1717,7 +1717,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
case self::rhBYTE: case self::rhBYTE:
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: / ls_zrecvhdr [%02x] (%d)',self::LOGKEY,$c,$got)); Log::debug(sprintf('%s: / ls_zrecvhdr [%02x] (%d)',self::LOGKEY,$c,$got));
$hdr[$got] = $c; $hdr[$got] = $c;
@ -1730,7 +1730,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
case self::rhCRC: case self::rhCRC:
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: %% ls_zrecvhdr [%02x] (%d|%d)',self::LOGKEY,$c,$crcgot+1,$got)); Log::debug(sprintf('%s: %% ls_zrecvhdr [%02x] (%d|%d)',self::LOGKEY,$c,$crcgot+1,$got));
if ($crcl === 2) { if ($crcl === 2) {
@ -1763,7 +1763,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$this->ls_Protocol |= self::LSZ_OPTCRC32; $this->ls_Protocol |= self::LSZ_OPTCRC32;
} }
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:- ls_zrecvhdr CRC%d got [%08x] - calculated [%08x]',self::LOGKEY,(($crcl==2) ? 16 : 32),$incrc,$crc)); Log::debug(sprintf('%s:- ls_zrecvhdr CRC%d got [%08x] - calculated [%08x]',self::LOGKEY,(($crcl==2) ? 16 : 32),$incrc,$crc));
if ($incrc != $crc) if ($incrc != $crc)
@ -1788,7 +1788,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
/* we need LF after <CR> */ /* we need LF after <CR> */
case self::CR: case self::CR:
case self::CR|0x80: case self::CR|0x80:
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:? ls_zrecvhdr rhCR, ignoring any remaining chars [%x]',self::LOGKEY,$c)); Log::debug(sprintf('%s:? ls_zrecvhdr rhCR, ignoring any remaining chars [%x]',self::LOGKEY,$c));
/* At this point, most implementations ignore checking for the remaining chars */ /* At this point, most implementations ignore checking for the remaining chars */
@ -1802,7 +1802,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
case self::XON: case self::XON:
case self::XON|0x80: case self::XON|0x80:
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:? ls_zrecvhdr rhCR, got XON without CR/LF [%x]',self::LOGKEY,$c)); Log::debug(sprintf('%s:? ls_zrecvhdr rhCR, got XON without CR/LF [%x]',self::LOGKEY,$c));
return $frametype; return $frametype;
@ -1833,7 +1833,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
case self::rhXON: case self::rhXON:
$state = self::rhInit; $state = self::rhInit;
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zrecvhdr rhXON',self::LOGKEY)); Log::debug(sprintf('%s: - ls_zrecvhdr rhXON',self::LOGKEY));
switch ($c) { switch ($c) {
@ -2004,11 +2004,11 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
*/ */
private function ls_zsenddata(string $data,int $frame): int private function ls_zsenddata(string $data,int $frame): int
{ {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:+ ls_zsenddata [%d] (%d)',self::LOGKEY,strlen($data),$frame)); Log::debug(sprintf('%s:+ ls_zsenddata [%d] (%d)',self::LOGKEY,strlen($data),$frame));
if ($this->ls_Protocol&self::LSZ_OPTCRC32) { if ($this->ls_Protocol&self::LSZ_OPTCRC32) {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zsenddata CRC32',self::LOGKEY)); Log::debug(sprintf('%s: - ls_zsenddata CRC32',self::LOGKEY));
for ($n=0;$n<strlen($data);$n++) for ($n=0;$n<strlen($data);$n++)
@ -2037,7 +2037,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$crc >>= 8; $crc >>= 8;
} else { } else {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zsenddata CRC16',self::LOGKEY)); Log::debug(sprintf('%s: - ls_zsenddata CRC16',self::LOGKEY));
for ($n=0;$n<strlen($data);$n++) { for ($n=0;$n<strlen($data);$n++) {
@ -2255,7 +2255,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
case self::ZACK: case self::ZACK:
$this->ls_txLastACK = $this->ls_fetchlong($this->ls_rxHdr); $this->ls_txLastACK = $this->ls_fetchlong($this->ls_rxHdr);
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s: - ls_zsendfile ZACK',self::LOGKEY),['ls_rxHdr'=>$this->ls_rxHdr,'ls_txLastACK'=>$this->ls_txLastACK,'ls_rxHdr'=>$this->ls_rxHdr]); Log::debug(sprintf('%s: - ls_zsendfile ZACK',self::LOGKEY),['ls_rxHdr'=>$this->ls_rxHdr,'ls_txLastACK'=>$this->ls_txLastACK,'ls_rxHdr'=>$this->ls_rxHdr]);
break; break;
@ -2522,7 +2522,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
/* Send HEX header. Use CRC16, send var. len. if could */ /* Send HEX header. Use CRC16, send var. len. if could */
private function ls_zsendhhdr(int $frametype,array $hdr): int private function ls_zsendhhdr(int $frametype,array $hdr): int
{ {
if ($this->DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:+ ls_zsendhhdr',self::LOGKEY)); Log::debug(sprintf('%s:+ ls_zsendhhdr',self::LOGKEY));
/* Send **<DLE> */ /* Send **<DLE> */

View File

@ -17,7 +17,7 @@ final class SocketClient {
private const LOGKEY = 'SC-'; private const LOGKEY = 'SC-';
// For deep debugging // For deep debugging
private bool $DEBUG = TRUE; private const DEBUG = FALSE;
private \Socket $connection; private \Socket $connection;
private string $address_local = ''; private string $address_local = '';
@ -162,11 +162,11 @@ final class SocketClient {
$num_bytes = strlen($data); $num_bytes = strlen($data);
while ($num_bytes) { while ($num_bytes) {
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:- To add [%d] to the TX buffer',self::LOGKEY,$num_bytes)); Log::debug(sprintf('%s:- To add [%d] to the TX buffer',self::LOGKEY,$num_bytes));
if ($num_bytes > $this->tx_free) { if ($num_bytes > $this->tx_free) {
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:- TX buffer will be too full, draining...',self::LOGKEY)); Log::debug(sprintf('%s:- TX buffer will be too full, draining...',self::LOGKEY));
do { do {
@ -185,7 +185,7 @@ final class SocketClient {
} }
} }
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:= TX buffer has [%d] space left',self::LOGKEY,$this->tx_free)); Log::debug(sprintf('%s:= TX buffer has [%d] space left',self::LOGKEY,$this->tx_free));
} }
@ -198,7 +198,7 @@ final class SocketClient {
*/ */
public function buffer_flush(int $timeout): int public function buffer_flush(int $timeout): int
{ {
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:+ Emptying TX buffer with [%d] chars, and timeout [%d]',self::LOGKEY,strlen($this->tx_buf),$timeout)); Log::debug(sprintf('%s:+ Emptying TX buffer with [%d] chars, and timeout [%d]',self::LOGKEY,strlen($this->tx_buf),$timeout));
$tm = $this->timer_set($timeout); $tm = $this->timer_set($timeout);
@ -208,12 +208,12 @@ final class SocketClient {
$tv = $this->timer_rest($tm); $tv = $this->timer_rest($tm);
if (($rc=$this->canSend($tv)) > 0) { if (($rc=$this->canSend($tv)) > 0) {
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:- Chars to send [%d]',self::LOGKEY,strlen($this->tx_buf))); Log::debug(sprintf('%s:- Chars to send [%d]',self::LOGKEY,strlen($this->tx_buf)));
$sent = $this->send(substr($this->tx_buf,0,self::TX_SIZE),0); $sent = $this->send(substr($this->tx_buf,0,self::TX_SIZE),0);
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:- Sent [%d] chars [%s]',self::LOGKEY,$sent,Str::limit($this->tx_buf,15))); Log::debug(sprintf('%s:- Sent [%d] chars [%s]',self::LOGKEY,$sent,Str::limit($this->tx_buf,15)));
$this->tx_buf = substr($this->tx_buf,$sent); $this->tx_buf = substr($this->tx_buf,$sent);
@ -291,7 +291,7 @@ final class SocketClient {
{ {
// We have data in our buffer // We have data in our buffer
if ($this->rx_left >= $len) { if ($this->rx_left >= $len) {
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:- Returning [%d] chars from the RX buffer',self::LOGKEY,$len)); Log::debug(sprintf('%s:- Returning [%d] chars from the RX buffer',self::LOGKEY,$len));
$result = substr($this->rx_buf,0,$len); $result = substr($this->rx_buf,0,$len);
@ -329,7 +329,7 @@ final class SocketClient {
if ($recv === FALSE) { if ($recv === FALSE) {
// If we have something in the buffer, we'll send it // If we have something in the buffer, we'll send it
if ($this->rx_left) { if ($this->rx_left) {
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:- Network read return an error, returning final [%d] chars from the RX buffer',self::LOGKEY,strlen($this->rx_buf))); Log::debug(sprintf('%s:- Network read return an error, returning final [%d] chars from the RX buffer',self::LOGKEY,strlen($this->rx_buf)));
$result = $this->rx_buf; $result = $this->rx_buf;
@ -355,7 +355,7 @@ final class SocketClient {
$this->rx_buf .= $buf; $this->rx_buf .= $buf;
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:- Added [%d] chars to the RX buffer',self::LOGKEY,strlen($buf)),['rx_buf'=>hex_dump($this->rx_buf)]); Log::debug(sprintf('%s:- Added [%d] chars to the RX buffer',self::LOGKEY,strlen($buf)),['rx_buf'=>hex_dump($this->rx_buf)]);
// Loop again and return the data, now that it is in the RX buffer // Loop again and return the data, now that it is in the RX buffer
@ -384,7 +384,7 @@ final class SocketClient {
public function rx_purge(): void public function rx_purge(): void
{ {
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:+ Discarding [%d] chars from the RX buffer',self::LOGKEY,strlen($this->tx_buf))); Log::debug(sprintf('%s:+ Discarding [%d] chars from the RX buffer',self::LOGKEY,strlen($this->tx_buf)));
$this->rx_buf = ''; $this->rx_buf = '';
@ -395,7 +395,7 @@ final class SocketClient {
*/ */
public function tx_purge(): void public function tx_purge(): void
{ {
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:+ Discarding [%d] chars from the TX buffer',self::LOGKEY,strlen($this->tx_buf))); Log::debug(sprintf('%s:+ Discarding [%d] chars from the TX buffer',self::LOGKEY,strlen($this->tx_buf)));
$this->tx_buf = ''; $this->tx_buf = '';
@ -414,7 +414,7 @@ final class SocketClient {
if ($timeout AND (! $rc=$this->canSend($timeout))) if ($timeout AND (! $rc=$this->canSend($timeout)))
return $rc; return $rc;
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:- Sending [%d] chars [%s]',self::LOGKEY,strlen($message),Str::limit($message,15))); Log::debug(sprintf('%s:- Sending [%d] chars [%s]',self::LOGKEY,strlen($message),Str::limit($message,15)));
switch ($this->type) { switch ($this->type) {
@ -446,7 +446,7 @@ final class SocketClient {
if ($rc === FALSE) if ($rc === FALSE)
throw new \Exception('Socket Error: '.socket_strerror(socket_last_error())); throw new \Exception('Socket Error: '.socket_strerror(socket_last_error()));
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:= Socket select returned [%d] with timeout (%d)',self::LOGKEY,$rc,$timeout),['read'=>$read,'write'=>$write,'except'=>$except]); Log::debug(sprintf('%s:= Socket select returned [%d] with timeout (%d)',self::LOGKEY,$rc,$timeout),['read'=>$read,'write'=>$write,'except'=>$except]);
return $rc; return $rc;
@ -480,7 +480,7 @@ final class SocketClient {
public function ttySelect(bool $read,bool $write, int $timeout): int public function ttySelect(bool $read,bool $write, int $timeout): int
{ {
if ($this->rx_left) { if ($this->rx_left) {
if ($this->DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:= We still have [%d] chars in the RX buffer.',self::LOGKEY,$this->rx_left)); Log::debug(sprintf('%s:= We still have [%d] chars in the RX buffer.',self::LOGKEY,$this->rx_left));
return 1; return 1;