Wednesday, 15 July 2015

c++ - What is the correct syntax to extract serial data from QSerialPort to a double in Qt Creator? -



c++ - What is the correct syntax to extract serial data from QSerialPort to a double in Qt Creator? -

i trying stream info in real time arduino. below how set serial port :

qserialport serial; qbytearray value0; mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); serial.setportname("com3"); serial.setbaudrate(qserialport::baud9600); serial.setdatabits(qserialport::data8); serial.setparity(qserialport::noparity); serial.setstopbits(qserialport::onestop); serial.setflowcontrol(qserialport::noflowcontrol); serial.open(qiodevice::readwrite); } ....

this how have tried alter serial info double :

serial.readdata();

you should convert raw byte array double according device logic. in case have sent info on other side streaming it, can read :

qbytearray info = serial->readall(); qdatastream stream(data); double value; stream>>value

c++ qt real-time qt-creator

No comments:

Post a Comment