lms: Return error on device read timeout

If LImeSDR device is unplugged or its fw crashes during operation,
reading from the device will fail and will first receive short reads and
finally 0 byte reads. Let's quickly notify these events to upper layers
instead of trying to process the buffer and checking timestamps for
something we know it's already not useful.

Related: OS#3340
Change-Id: Ib1af8cdd6cdadf581b039882add4049eea45a0f7
This commit is contained in:
Pau Espin 2018-09-03 16:46:34 +02:00
parent 8e498bfd35
commit 49ad759072
1 changed files with 5 additions and 3 deletions

View File

@ -511,11 +511,13 @@ int LMSDevice::readSamples(std::vector < short *>&bufs, int len, bool * overrun,
for (i = 0; i<chans; i++) {
thread_enable_cancel(false);
rc = LMS_RecvStream(&m_lms_stream_rx[i], bufs[i], len, &rx_metadata, 100);
if (rc != len) {
LOGC(DDEV, ALERT) << "LMS: Device receive timed out (" << rc << " vs exp " << len << ").";
thread_enable_cancel(true);
return -1;
}
if (timestamp != (TIMESTAMP)rx_metadata.timestamp)
LOGC(DDEV, ALERT) << "chan "<< i << " recv buffer of len " << rc << " expect " << std::hex << timestamp << " got " << std::hex << (TIMESTAMP)rx_metadata.timestamp << " (" << std::hex << rx_metadata.timestamp <<") diff=" << rx_metadata.timestamp - timestamp;
if (rc != len) {
LOGC(DDEV, ALERT) << "LMS: Device receive timed out";
}
if (LMS_GetStreamStatus(&m_lms_stream_rx[i], &status) == 0) {
if (status.underrun > m_last_rx_underruns[i])