summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2014-08-04 10:29:24 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2014-08-04 10:29:24 +0000
commit58059755f7010fd12507068f815632db05ad0935 (patch)
treef7646fd9ff3f034a4c7bcecbb26dd003458f142c
parent4b6a5fc8257680f2afebf513e6ad7f54daece0b9 (diff)
downloadpyserial-58059755f7010fd12507068f815632db05ad0935.tar.gz
[Bug pyserial:157] Implement inWaiting in protocol_socket
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@506 f19166aa-fa4f-0410-85c2-fa1106f25c8a
-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):
"""\