Fix W command speed by using bytes requested correctly

read_string now recognizes binary strings to read 5X more bytes
Fixed Reply: prompt double output and space after :
https://github.com/Hamlib/Hamlib/issues/387
pull/412/head
Michael Black W9MDB 2020-10-02 17:23:48 -05:00
rodzic 0576a01ec2
commit 293a844c41
2 zmienionych plików z 12 dodań i 10 usunięć

Wyświetl plik

@ -753,6 +753,7 @@ int HAMLIB_API read_string(hamlib_port_t *p,
*/
rd_count = port_read(p, &rxbuffer[total_count], 1);
rig_debug(RIG_DEBUG_TRACE, "%s: YYY rd_count=%d, total_count=%d\n", __func__, rd_count, total_count);
/* if we get 0 bytes or an error something is wrong */
if (rd_count <= 0)
{
@ -765,6 +766,8 @@ int HAMLIB_API read_string(hamlib_port_t *p,
return -RIG_EIO;
}
// 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;
++total_count;
if (stopset && memchr(stopset, rxbuffer[total_count - 1], stopset_len))

Wyświetl plik

@ -989,11 +989,13 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
{
rig_debug(RIG_DEBUG_TRACE, "%s: debug7\n", __func__);
#if 0 // was printing Reply: twice
if (prompt)
{
rig_debug(RIG_DEBUG_TRACE, "%s: debug8\n", __func__);
fprintf_flush(fout, "%s: ", cmd_entry->arg2);
}
#endif
if (scanfc(fin, "%s", arg2) < 1)
{
@ -4285,11 +4287,11 @@ declare_proto_rig(get_powerstat)
return status;
}
static int hasbinary(char *s)
static int hasbinary(char *s, int len)
{
int i;
for (i = 0; s[i] != 0; ++i)
for (i = 0; i < len; ++i)
{
if (!isascii(s[i])) { return 1; }
}
@ -4309,7 +4311,7 @@ declare_proto_rig(send_cmd)
struct rig_state *rs;
int backend_num, cmd_len;
#define BUFSZ 128
char bufcmd[BUFSZ];
char bufcmd[BUFSZ*5]; // allow for 5 chars for binary
unsigned char buf[BUFSZ];
char eom_buf[4] = { 0xa, 0xd, 0, 0 };
int binary = 0;
@ -4414,7 +4416,7 @@ declare_proto_rig(send_cmd)
rig_flush(&rs->rigport);
rig_debug(RIG_DEBUG_TRACE, "%s: rigport=%d, bufcmd=%s, cmd_len=%d\n", __func__,
rs->rigport.fd, hasbinary(bufcmd) ? "BINARY" : bufcmd, cmd_len);
rs->rigport.fd, hasbinary(bufcmd, cmd_len) ? "BINARY" : bufcmd, cmd_len);
retval = write_block(&rs->rigport, (char *)bufcmd, cmd_len);
if (retval != RIG_OK)
@ -4426,7 +4428,7 @@ declare_proto_rig(send_cmd)
{
rig_debug(RIG_DEBUG_TRACE, "%s: debug Cmd\n", __func__);
fwrite(cmd->arg2, 1, strlen(cmd->arg2), fout); /* i.e. "Frequency" */
fwrite(":", 1, 1, fout); /* i.e. "Frequency" */
fwrite(": ", 1, 2, fout); /* i.e. "Frequency" */
}
do
@ -4436,9 +4438,6 @@ declare_proto_rig(send_cmd)
if (rxbytes > 0)
{
++rxbytes; // need length + 1 for end of string
if (cmd->cmd == 'W') { rxbytes *= 5; }
eom_buf[0] = 0;
}
@ -4463,10 +4462,10 @@ declare_proto_rig(send_cmd)
buf[BUFSZ - 1] = '\0';
}
if (rig->caps->rig_model != RIG_MODEL_NETRIGCTL)
//if (rig->caps->rig_model != RIG_MODEL_NETRIGCTL)
{
// see if we have binary being returned
binary = hasbinary((char *)buf);
binary = hasbinary((char *)buf, retval);
}
if (binary) // convert our buf to a hex representation