Unsolved Not able to read data from QSerialPort
-
When I write any data to the Serial Port character wise, I'm getting the expected response from my hardware. But when I send strings, I'm not able to read. I initialized my data using QByteArray but when I use QString, I'm not able to get the expected response. The code is same as Terminal Program for Qt 5.5. I'm coding in C++ on Windows platform.
-
Hi and welcome
<<But when I send strings, I'm not able to read.
How not able to read?
Do yo u get nothing or only some?If you data contains zero, it wont work with QStrings as it will be broken up.
Have you tried
QString string("I LOVE HARDWARE");
QByteArray array (string.toStdString().c_str());
serial->write(array); -
Thanks for the tip. 'c_str' did the trick. Did not know about this.