Solved Issue with QSerialPort (ubuntu)
-
Hello, I am writing a simple serial program that works fine on Windows, but not on Linux (Ubuntu) here is the code
Port1 = new QSerialPort (); Foreach (const QSerialPortInfo & info, QSerialPortInfo :: availablePorts ()) { Port_name = info.portName ();} Port1-> setPortName (port_name); Port1-> setBaudRate (38400); Port1-> setDataBits (QSerialPort :: Data8); Port1-> setStopBits (QSerialPort :: OneStop); Port1-> setParity (QSerialPort :: NoParity); Port1-> setFlowControl (QSerialPort :: NoFlowControl); If (port1-> open (QIODevice :: ReadWrite)) { Ui-> textEdit-> append ("Connected to" + port_name); } Else { Ui-> textEdit-> append ("Waiting ... \ n");}
textEdit show me connected to /dev/ttyUSB0 for example, but after 1 second this program it freezes, what should I do? regards
-
Hi
You first check with other serial program that
/dev/ttyUSB0 does work.
Could be access issues. -
yes, I try with cutecom and works
-
Then it sounds like you have a normal bug in your program. :)
To test it, try the sample
http://doc.qt.io/qt-5/qtserialport-terminal-example.htmlIf that do not freeze,
its not something with Qt
but something you do in your own code and you
just need to find out what. -
@RSC9421 What do you do after connecting (after if (port1-> open (QIODevice :: ReadWrite)))?
It looks like your app is able to connect. -
-
@RSC9421 Can you show the whole source code of your program?
-
Sorry for the delay, I did not have the internet ^^ Fortunately, I could fix it
I was compiling a similar project
The error was in the signal function "readyRead"
Thank you