[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] QSerialPort() basic read question
From:       Phil <phil_lor () bigpond ! com>
Date:       2017-11-19 9:25:05
Message-ID: 8c419abf-13c5-3a12-8b0a-a77ccb9eebd2 () bigpond ! com
[Download RAW message or body]

Thank you for reading this.

I'm trying to read serial data, but so far without any success. The only 
thing printed is a blank line or "data = ".

I have, however, been able to write data successfully so the port set up 
is correct.

This is how I've set up the port for both reading and writing:

    self.serial = QSerialPort()
         self.serial.setPortName('/dev/ttyACM0')
         self.serial.open(QIODevice.ReadWrite)
         self.serial.setBaudRate(9600)
         self.serial.setDataBits(8)
         self.serial.setParity(QSerialPort.NoParity)
         self.serial.setStopBits(1)
         self.serial.setFlowControl(QSerialPort.NoFlowControl)

         self.serialRead()

The following is most of what I've tried so far and includes bits that 
I've converted from C++ examples:

     def serialRead(self):
         print("DEBUG: serial received data: ", 
(bytes(self.serial.readAll()).decode('ascii')))

         data = self.serial.readAll();
         print("data = ")

         if self.serial.canReadLine():
             print("DEBUG: processing received serial data")
             self.serialProcess(self.serial.readLine())


I've also tried the following:

while (self.serial.waitForReadyRead(5000)):
     data = self.serial.readAll()
     print(:data = ")

This blocks the main window from displaying, so I might be on the wrong 
track here.

Finally, cat /dev/ttyACM0 show that the data is being received.

Any help at all will be greatly appreciated.

-- 
Regards,
Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic