The code posted by ChrisW67 works fine for me. In my case, I changed this part:
void connected() {
sock.write(ba);
qDebug() << "Wrote:" << ba;
void connected() {
QByteArray ba("GET / HTTP/1.0\r\n\r\n");
sock.write(ba);
qDebug() << "Wrote:" << ba;
To copy to clipboard, switch view to plain text mode
by this one:
public slots:
void connected()
{
sock.write(ba);
qDebug() << "Wrote:" << ba;
}
public slots:
void connected()
{
QByteArray ba("$$$");
sock.write(ba);
qDebug() << "Wrote:" << ba;
}
To copy to clipboard, switch view to plain text mode
And everything seems to work fine, I can see I receive Read: "*Hello*" and Read: "CMD", which means that the device is answering to the command "$$$" I sent. However, what I would like to do is to send another ASCII command and then receive data. I thought about doing this:
public slots:
void connected()
{
sock.write(ba);
qDebug() << "Wrote:" << ba;
sock.write(bb);
qDebug() << "Wrote:" << bb;
}
public slots:
void connected()
{
QByteArray ba("$$$");
sock.write(ba);
qDebug() << "Wrote:" << ba;
QByteArray bb("show q\r");
sock.write(bb);
qDebug() << "Wrote:" << bb;
}
To copy to clipboard, switch view to plain text mode
But this does not work, after sending "show q" in the last variation of the connected method I should receive (appart from Read: "*Hello*" and Read: "CMD") something like "8735b7", however i receive only "Hello", and even I dont receive CMD (which is the response when "$$$" is sent), and that is why i know i am doing something wrong when trying to write two times in the connected method.
My goal is to send different commands and receive data (send command and receive response, send another command and receive response...). Im planning to do it with a widget, but first I would like to do it just by code or by using the console. Any suggestion?
Kind regards,
-E
Bookmarks