Solved converting qbyte array to string
-
@Anna_64 Is it possible that your app is still being executed when you try to build? Stop/kill the running instance and build again. Windows does not allow write access to open/locked files.
-
@jsulm Thank You it works now
-
@Anna_64 {
QByteArray uq;
uq.resize(7);
uq[0] = 0xAA;
uq[1] = 0x55;
uq[2] = 0x04;
uq[3] = 0x00;
uq[4] = 0x00;
uq[5] = 0xC0;
uq[6] = 0xBB;
serial->write(uq);
after this write command i have to close serial port and wait for 5 sec and open serial port and send data so after
serial->write(uq);
serial->close();
QThread::sleep(5);but it gives error like device not opened -
@jsulm QByteArray uq;
uq.resize(7);
uq[0] = 0xAA;
uq[1] = 0x55;
uq[2] = 0x04;
uq[3] = 0x00;
uq[4] = 0x00;
uq[5] = 0xC0;
uq[6] = 0xBB;
serial->write(uq);
after this write command i have to close serial port and wait for 5 sec and open serial port and send data so after
serial->write(uq);
serial->close();
QThread::sleep(5);but it gives error like device not opened -
@Anna_64 You should first wait until data was written before calling close(). See https://doc.qt.io/qt-5/qserialport.html#waitForBytesWritten
-
@jsulm how to write code this
after serial->write(uq)
how to introduce a wait for 5 seconds and close serial port -
-
@jsulm QString s[64];
QString test ="";
QByteArray testfinal;
testfinal.resize(65000);
for(int j=0;j<64;j++)
{
QString offsetAddress=QString::number(j*1024).rightJustified(6, '0');
s[j] = "<UpdateFirmware><Size>2048</Size><Data>"+x[j]+"</Data><Offset>"+offsetAddress+"</Offset><Signature>"+y[j]+"</Signature></UpdateFirmware>";
//s[j] ="<UpdateFirmware><Size>2048</Size><Data>"+x[j]+"</Data><Offset>008192</Offset><Signature>"+y[j]+"</Signature></UpdateFirmware>";
if(j>=8){
testfinal+=s[j];
serial->write(testfinal);
}
i am trying to send this string message to my device and do updation but only 15% updation s happening theres no error as well but with testing i found complete updation s not happening
can u plz figure it which part of data not working i guess it s the offset adress part -
@Anna_64 Sorry, I don't understand your question. What does not work? Sending data to device?
-
@jsulm i am sending some data to a device but its not workingqbytearray to qstring s creating some issues inside the loop
in my above code
testfinal+=s[j];
this section s producing some issues