diff options
Diffstat (limited to 'pyserial/serial/urlhandler/protocol_socket.py')
-rw-r--r-- | pyserial/serial/urlhandler/protocol_socket.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pyserial/serial/urlhandler/protocol_socket.py b/pyserial/serial/urlhandler/protocol_socket.py index 41e59b1..dc59923 100644 --- a/pyserial/serial/urlhandler/protocol_socket.py +++ b/pyserial/serial/urlhandler/protocol_socket.py @@ -20,6 +20,7 @@ from serial.serialutil import * import time import socket +import select import logging # map log level names to constants. used in fromURL() @@ -130,10 +131,10 @@ class SocketSerial(SerialBase): def inWaiting(self): """Return the number of characters currently in the input buffer.""" if not self._isOpen: raise portNotOpenError - if self.logger: - # set this one to debug as the function could be called often... - self.logger.debug('WARNING: inWaiting returns dummy value') - return 0 # hmmm, see comment in read() + # Poll the socket to see if it is ready for reading. + # If ready, at least one byte will be to read. + lr, lw, lx = select.select([self._socket], [], [], 0) + return len(lr) def read(self, size=1): """\ |