summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt1
-rw-r--r--serial/urlhandler/protocol_socket.py9
2 files changed, 6 insertions, 4 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 96de156..663dbeb 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -489,6 +489,7 @@ Version 2.8 2014-xx-xx
Bugfixes:
+- [Bug pyserial:157] Implement inWaiting in protocol_socket
- [Bug pyserial:166] RFC2217 connections always fail
Bugfixes (posix):
diff --git a/serial/urlhandler/protocol_socket.py b/serial/urlhandler/protocol_socket.py
index 41e59b1..dc59923 100644
--- a/serial/urlhandler/protocol_socket.py
+++ b/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):
"""\