Revert read_string() to partial results are a success status

The read_string() function was changed to return a -RIG_ETIMEOUT error
when timing out after having read  some characters. This caused a back
end to fail because it was  using a read_string() with an invalid stop
character  and relying  on the  timed out  read_string() to  fetch the
data. This  patch reverts to  the prior  behavior of returning  a null
terminated buffer and  read bytes count if at least  one byte has been
read.
Hamlib-3.0
Bill Somerville 2014-12-10 01:25:33 +00:00
rodzic 6b2069af28
commit 82b8649030
1 zmienionych plików z 11 dodań i 8 usunięć

Wyświetl plik

@ -505,16 +505,19 @@ int HAMLIB_API read_string(hamlib_port_t *p, char *rxbuffer, size_t rxmax, const
retval = port_select(p, p->fd+1, &rfds, NULL, &efds, &tv);
if (retval == 0) {
/* Record timeout time and caculate elapsed time */
gettimeofday(&end_time, NULL);
timersub(&end_time, &start_time, &elapsed_time);
if (0 == total_count) {
/* Record timeout time and caculate elapsed time */
gettimeofday(&end_time, NULL);
timersub(&end_time, &start_time, &elapsed_time);
dump_hex((unsigned char *) rxbuffer, total_count);
rig_debug(RIG_DEBUG_WARN, "%s(): Timed out %d.%d seconds after %d chars\n",
__func__, elapsed_time.tv_sec, elapsed_time.tv_usec, total_count);
dump_hex((unsigned char *) rxbuffer, total_count);
rig_debug(RIG_DEBUG_WARN, "%s(): Timed out %d.%d seconds after %d chars\n",
__func__, elapsed_time.tv_sec, elapsed_time.tv_usec, total_count);
return -RIG_ETIMEOUT;
}
return -RIG_ETIMEOUT;
}
break; /* return what we have read */
}
if (retval < 0) {
dump_hex((unsigned char *) rxbuffer, total_count);