kopia lustrzana https://github.com/Hamlib/Hamlib
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
(cherry picked from commit 293a844c41
)
Hamlib-4.0
rodzic
b2227c2000
commit
e062000aa3
|
@ -753,6 +753,7 @@ int HAMLIB_API read_string(hamlib_port_t *p,
|
||||||
*/
|
*/
|
||||||
rd_count = port_read(p, &rxbuffer[total_count], 1);
|
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 we get 0 bytes or an error something is wrong */
|
||||||
if (rd_count <= 0)
|
if (rd_count <= 0)
|
||||||
{
|
{
|
||||||
|
@ -765,6 +766,8 @@ int HAMLIB_API read_string(hamlib_port_t *p,
|
||||||
return -RIG_EIO;
|
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;
|
++total_count;
|
||||||
|
|
||||||
if (stopset && memchr(stopset, rxbuffer[total_count - 1], stopset_len))
|
if (stopset && memchr(stopset, rxbuffer[total_count - 1], stopset_len))
|
||||||
|
|
|
@ -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__);
|
rig_debug(RIG_DEBUG_TRACE, "%s: debug7\n", __func__);
|
||||||
|
|
||||||
|
#if 0 // was printing Reply: twice
|
||||||
if (prompt)
|
if (prompt)
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: debug8\n", __func__);
|
rig_debug(RIG_DEBUG_TRACE, "%s: debug8\n", __func__);
|
||||||
fprintf_flush(fout, "%s: ", cmd_entry->arg2);
|
fprintf_flush(fout, "%s: ", cmd_entry->arg2);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (scanfc(fin, "%s", arg2) < 1)
|
if (scanfc(fin, "%s", arg2) < 1)
|
||||||
{
|
{
|
||||||
|
@ -4285,11 +4287,11 @@ declare_proto_rig(get_powerstat)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hasbinary(char *s)
|
static int hasbinary(char *s, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; s[i] != 0; ++i)
|
for (i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
if (!isascii(s[i])) { return 1; }
|
if (!isascii(s[i])) { return 1; }
|
||||||
}
|
}
|
||||||
|
@ -4309,7 +4311,7 @@ declare_proto_rig(send_cmd)
|
||||||
struct rig_state *rs;
|
struct rig_state *rs;
|
||||||
int backend_num, cmd_len;
|
int backend_num, cmd_len;
|
||||||
#define BUFSZ 128
|
#define BUFSZ 128
|
||||||
char bufcmd[BUFSZ];
|
char bufcmd[BUFSZ*5]; // allow for 5 chars for binary
|
||||||
unsigned char buf[BUFSZ];
|
unsigned char buf[BUFSZ];
|
||||||
char eom_buf[4] = { 0xa, 0xd, 0, 0 };
|
char eom_buf[4] = { 0xa, 0xd, 0, 0 };
|
||||||
int binary = 0;
|
int binary = 0;
|
||||||
|
@ -4414,7 +4416,7 @@ declare_proto_rig(send_cmd)
|
||||||
rig_flush(&rs->rigport);
|
rig_flush(&rs->rigport);
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: rigport=%d, bufcmd=%s, cmd_len=%d\n", __func__,
|
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);
|
retval = write_block(&rs->rigport, (char *)bufcmd, cmd_len);
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
|
@ -4426,7 +4428,7 @@ declare_proto_rig(send_cmd)
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: debug Cmd\n", __func__);
|
rig_debug(RIG_DEBUG_TRACE, "%s: debug Cmd\n", __func__);
|
||||||
fwrite(cmd->arg2, 1, strlen(cmd->arg2), fout); /* i.e. "Frequency" */
|
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
|
do
|
||||||
|
@ -4436,9 +4438,6 @@ declare_proto_rig(send_cmd)
|
||||||
if (rxbytes > 0)
|
if (rxbytes > 0)
|
||||||
{
|
{
|
||||||
++rxbytes; // need length + 1 for end of string
|
++rxbytes; // need length + 1 for end of string
|
||||||
|
|
||||||
if (cmd->cmd == 'W') { rxbytes *= 5; }
|
|
||||||
|
|
||||||
eom_buf[0] = 0;
|
eom_buf[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4463,10 +4462,10 @@ declare_proto_rig(send_cmd)
|
||||||
buf[BUFSZ - 1] = '\0';
|
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
|
// 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
|
if (binary) // convert our buf to a hex representation
|
||||||
|
|
Ładowanie…
Reference in New Issue