Problems with serial port interface

lionelgreenstreet at gmail.com lionelgreenstreet at gmail.com
Thu Jun 13 04:01:17 EDT 2013


I've some other informations:
i've created a class like this

class CReader(QThread):
    def start(self, ser, priority = QThread.InheritPriority):
        self.ser = ser
        QThread.start(self, priority)
        self._isRunning = True
        self.numData=0;
     
    def run(self):
        print("Enter Creader")
        while True:
            if self._isRunning:
                try:
                    data = self.ser.read(self.numData)
                    n = self.ser.inWaiting()
                    if n:
                        data = self.ser.read(n) 
                        print(data)
                except:
                    errMsg = "Reader thread is terminated unexpectedly."
                    self.emit(SIGNAL("error(QString)"), errMsg)
            else:
                return
           
    def stop(self):
        self._isRunning = False
        self.wait()

I've tested my class and it works well and i have no error messages.
So, i think that my problem is this line (taken from previous code)

self.emit(SIGNAL("newData(QString)"), data.decode('cp1252', 'ignore'))

i need this line to display all data received to my QT interface, so can't be removed.
I've tried to use a timer to display data every 500ms: my program crasches after 5minutes.
Can you help me?
Thanks
  



More information about the Python-list mailing list