Maybe this is your problem. From the canReadLine() docs:
Note that unbuffered devices, which have no way of determining what can be read, always return false.
I communicate with an unbuffered device and if I were using your onReceive() function it would look something like this:
void Motor::onReceive()
{
while(port->bytesAvailable()< RX_BUF_SIZE) {} //wait for data
char tmp[RX_BUF_SIZE];
qint64 len = port->read(tmp, RX_BUF_SIZE); //use read instead of readline
data.fromRawData(tmp,len);
quint8 fault = 0;
// do something with the data before
// clearing the buffer
data.clear();
rxcnt++;
}
}
void Motor::onReceive()
{
QMutexLocker locker(&m);
while(port->bytesAvailable()< RX_BUF_SIZE) {} //wait for data
char tmp[RX_BUF_SIZE];
qint64 len = port->read(tmp, RX_BUF_SIZE); //use read instead of readline
data.fromRawData(tmp,len);
quint8 fault = 0;
// do something with the data before
// clearing the buffer
data.clear();
rxcnt++;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks