[PyQt] Using QSerialPort() instead of pyserial
phil_lor at bigpond.com
Mon Nov 20 08:02:57 GMT 2017
On 20/11/17 15:37, Florian Bruhin wrote:
> On Mon, Nov 20, 2017 at 08:20:19AM +1000, Phil wrote:
>> This seems to be the equivalent but nothing is printed.
>> while (self.serial.waitForReadyRead(5000)):
>> data = self.serial.readAll()
>> print(:data = ")
> That looks about right conceptually, apart from the print() being a syntax
> error, and only showing part of the picture (how is self.serial defined)?
> Can you please show a complete, working, minimal example script with PySerial
> which works, and one with QSerialPort which does not?
Thank you Florian for you reply.
The pyserial and QSerialPort code supplied was an example of what worked
and what didn't.
Anyway, after a good night's sleep and a bit of experimentation I now
have a working solution as follows:
data = self.serial.readLine()
I'm not sure what happens, at the moment, if there isn't and serial date
One thing I haven't sorted out is how to convert a QBytearray, "data" in
this case, to a string. The following converts the mytext QString to a
byte array but I cannot see how to convert a byte array to a string.
byte = bytes(mytext, encoding='ascii')
I want to write "data" into a text edit box like this:
More information about the PyQt