Solved why serial data write on one line on console in terminal example is in package of 3 or 4 characters with qDebug?
-
hello, I want use serial data but when I write received data in file or qDebug with starting project example of Qt: terminal
m_console->putData(data); QString DataAsString =QString(data); qDebug()<<DataAsString;
I get result:
":T"
"empe"
"ratu"
"re: "
"18.8"
"0:Hu"
"midi"
"ty: "
"59.0"
"0;\r"
"\n"but on console I have
:Temperature: 18.80:Humidity:59.00;thank you for your help
-
Hi,
How are you getting these data ?
What console are you referring to ? -
@SGaist Hello, data is from arduino and console is from terminal sample of Qt
-
qDebug()
adds an carriage return when it's done while the terminal example might just concatenate all the data received. -
@SGaist may be but when I when to add date and time to the data and save it to text file with QTextStream, I have date/time between package.. like example:
:T05/05/19 23h55empe05/05/19 23h55ratu05/05/19 23h55re: 05/05/19 23h55:18.805/05/19 23h550:Hu05/05/19 23h55midi05/05/19 23h55ty:05/05/19 23h5559.005/05/19 23h550;
it's that like the data is not send in one time but by package...
-
it's that like the data is not send in one time but by package...
Thats how serial lines work. As your data is line-based, you should use
canReadLine()
andreadLine()
fromQSerialPort
Regards
-
@aha_1980 to solve to issue, I switch from 9600 bauds to 115200 and problem fixed...
-
@filipdns
It's up to you if you decide that marks your problem as Solved. However, switching to a faster speed can hardly address whatever your issue is, which is presumably a timing one. Beware that you do not find the problem arises again, as presumably it will if the data does not arrive fast enough even though you've upped the speed. As @aha_1980 said, I would have thought you need to correctly address when you read how much..... -