Move semicolon removal after complete string is read.

xg3 was expecting single ; response and old way was causing timeouts
pull/1245/head
Mike Black W9MDB 2023-03-06 11:27:41 -06:00
rodzic a8aba7c13b
commit edc18103f0
1 zmienionych plików z 19 dodań i 7 usunięć

Wyświetl plik

@ -1358,6 +1358,7 @@ static int read_string_generic(hamlib_port_t *p,
direct);
}
}
while (++i < 10 && errno == EBUSY); // 50ms should be enough
/* if we get 0 bytes or an error something is wrong */
@ -1376,16 +1377,15 @@ static int read_string_generic(hamlib_port_t *p,
// check to see if our string startis with \...if so we need more chars
if (total_count == 0 && rxbuffer[total_count] == '\\') { rxmax = (rxmax - 1) * 5; }
if (total_count == 0 && rxbuffer[0] == ';')
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: skipping single ';' char\n", __func__);
}
else {
total_count += (int) rd_count;
if (rxbuffer[0] == ';' && total_count > 1)
{
}
if (total_count == rxmax) break;
if (total_count == rxmax) { break; }
if (stopset && memchr(stopset, rxbuffer[total_count - 1], stopset_len))
{
@ -1401,6 +1401,18 @@ static int read_string_generic(hamlib_port_t *p,
}
}
if (total_count > 1 && rxbuffer[0] == ';')
{
while (rxbuffer[0] == ';' && rxbuffer[0] != 0 && total_count > 1)
{
memmove(rxbuffer, &rxbuffer[1], strlen((char *)rxbuffer) - 1);
--total_count;
}
rig_debug(RIG_DEBUG_VERBOSE,
"%s: skipping single ';' chars at beginning of reply\n", __func__);
}
/*
* Doesn't hurt anyway. But be aware, some binary protocols may have
* null chars within the received buffer.