I have written such code (simplified here)
Test::test()
{
timer = new QTimer(this);
timer -> setInterval(300);
timer -> setSingleShot(true);
connect(this->timer, SIGNAL(timeout()),this,SLOT(first_process()));
char first_request = 0x02;
serial -> write( &first_request);
timer -> start();
}
Test::first_process()
{
QByteArray data = serial->readAll();
//process data...
char second_request = 0x02;
serial->write( &second_request );
disconnect(this->timer, SIGNAL( timeout() ), this, SLOT( first_process() ));
connect( this->timer, SIGNAL( timeout() ), this, SLOT( second_process() ));
timer->start();
}
(serial is of course initialized, baud set and so on...)
And so one, 6 processes 'queued' to be executed in a time. However i see from the responses that the data is being send again and again i.e. in 3rd 'process' i recive half of first response in 4th another half, some other data in between.
I cant see where the mistake is made - device should respond for commands, data should be read to QByteArray
1) Why the data is being send twice (or more) even if not asked for? Is it some kind of buffering issue?
2) Is there any other mechanism to achive such behaviour? (i already tried connecting readyRead() to read function but the problem is that data is torn in pieces and i want ALL OF IT at a time)