eric6/MicroPython/MicroPythonSerialPort.py

branch
micropython
changeset 7082
ec199ef0cfc6
parent 7077
3b7475b7a1ef
child 7083
217862c28319
--- a/eric6/MicroPython/MicroPythonSerialPort.py	Tue Jul 23 19:43:14 2019 +0200
+++ b/eric6/MicroPython/MicroPythonSerialPort.py	Wed Jul 24 20:12:19 2019 +0200
@@ -32,6 +32,7 @@
         
         self.__connected = False
         self.__timeout = timeout      # 10s default timeout
+        self.__timedOut = False
     
     def setTimeout(self, timeout):
         """
@@ -83,6 +84,15 @@
         """
         return self.__connected
     
+    def hasTimedOut(self):
+        """
+        Public method to check, if the last 'readUntil' has timed out.
+        
+        @return flag indicating a timeout
+        @@rtype bool
+        """
+        return self.__timedOut
+    
     def readUntil(self, expected=b"\n", size=None):
         r"""
         Public method to read data until an expected sequence is found
@@ -96,6 +106,7 @@
         @rtype bytes
         """
         data = bytearray()
+        self.__timedOut = False
         
         t = QTime()
         t.start()
@@ -111,6 +122,7 @@
 #            else:
 #                break
             if t.elapsed() > self.__timeout:
+                self.__timedOut = True
                 break
         
         return bytes(data)

eric ide

mercurial