Problems with serial port interface
Peter Otten
__peter__ at web.de
Fri Jun 7 07:23:00 EDT 2013
lionelgreenstreet at gmail.com wrote:
> Sorry for my quote,
> but do you have any suggestion?
>> After 30seconds (more or less) the program crashes: seems a buffer
>> problem, but i'm not really sure.
>>
>> What's wrong?
I don't use qt or pyserial myself, but your problem description is too vague
anyway. Some random remarks:
Does your script segfault or do you get a traceback? If the latter, post it.
As you are using two external libraries, can you limit the problem to a
single one? For example: temporarily replace pyserial with a file. Do the
problems persist?
What happens if you remove the bare
try: ...
except: pass
? It may hide useful information.
Finally, can you make a self-contained example that we can run? Make it as
simple as possible. I'd start with something like
class CReader(QThread):
def __init__(self, ser):
self.ser = ser
def run(self):
while True:
data = self.ser.read(1)
if data:
n = self.ser.inWaiting()
if n:
data += self.ser.read(n)
text = data.decode('cp1252', 'ignore')
print(text)
# adding the following would be the next step
#self.emit(SIGNAL("newData(QString)"), text)
and once you have something that does run you can gradually increase
complexity until it breaks.
More information about the Python-list
mailing list