
Originally Posted by
kachofool
Part of the reason I feel totally lost is that I'm migrating from pthreads, where I don't need to create a separate class for threads,
Probably because pthreads has a C interface 
and where I can run things concurrently in a way that seems coherent.
I don't think this has anything to do with your current situation.
If I have different devices that need to talk to each other and to my application, I would think that threads would be involved.
Only if i/o operations are blocking. Otherwise you wouldn't need threads.
I don't understand how I can emit a signal only when there are enough bytes available to indicate a proper response from my device.
I didn't say you should. I said you should react on readyRead() in a different manner than you are doing now. Buffer the data until there is enough to perform your task. Then you can emit a signal or do whatever you like.
For instance assuming a "datagram" would be a complete line of text, you could do this in your slot connected to readyRead():
void Class::onReadyRead() {
while(device->canReadLine()) {
doSomethingWithThe(data);
}
}
void Class::onReadyRead() {
while(device->canReadLine()) {
QByteArray data = device->readLine();
doSomethingWithThe(data);
}
}
To copy to clipboard, switch view to plain text mode
So could you please point me in the right direction?
Signals and slots are your friends.
Bookmarks