Solved Qt Serial- Open function returns false
-
Hey guys. I am new in Qt and trying to communicate with my STM board via Serial Port. But I can't open the serial port with serialPort->open(QIODevice::ReadWrite). I couldn't find where I am doing wrong. I need help.
-
What a stupid I am. The name of port I am trying to use is COM6 but i gave name randomly STMcomm in code. The name should be same. Thank you for your support sir.
-
Hi and welcome to devnet,
You might want to print the error returned by the error property.
-
Thanks for answer but how should I call that specific error function?
-
Did you try to just send its value to
qDebug() <<
? -
It says no error but then why the if statement happens to be 1?
-
problem evolved to that now. The error string is ="System couldn't find the referred file"
-
Good, one more thing: there's no reason for your
serialPort
variable to be statically declared. You should fix that. -
I know I am asking too much but I don't know what is statically declared means. I looked a bit and as I understand that means initializing without new.
I moved *QSerialPort serialPort; part to header file if you meant that. But it didn't help. I can't understand why it should be so hard to just use simple serial port.
-
What a stupid I am. The name of port I am trying to use is COM6 but i gave name randomly STMcomm in code. The name should be same. Thank you for your support sir.
-
Your use of static falls in the last paragraphe of this article.