Added 'W' command for reading a fixed number of bytes

So we can now do this...write once to see how many bytes you get back
Rig command: w \0xfe\0xfe\0x58\0xe0\0x03\0xfd
Cmd:\0xFE\0xFE\0x58\0xE0\0x03\0xFD\0xFE\0xFE\0xE0\0x58\0x03\0x00\0x00\0x09\0x14\0x00\0xFD 17

Then use 'W' to write the command with the # of bytes to expect -- no timeout this way
Rig command: W \0xfe\0xfe\0x58\0xe0\0x03\0xfd 17
Cmd:\0xFE\0xFE\0x58\0xE0\0x03\0xFD\0xFE\0xFE\0xE0\0x58\0x03\0x00\0x00\0x09\0x14\0x00\0xFD 17
pull/155/head
Michael Black 2019-12-09 23:37:14 -06:00
rodzic 2fce78ac87
commit 9eae761579
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6599353EC683404D
1 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -311,6 +311,7 @@ static struct test_table test_list[] =
{ 0x8a, "recv_dtmf", ACTION(recv_dtmf), ARG_OUT, "Digits" },
{ '*', "reset", ACTION(reset), ARG_IN, "Reset" },
{ 'w', "send_cmd", ACTION(send_cmd), ARG_IN1 | ARG_IN_LINE | ARG_OUT2 | ARG_NOVFO, "Cmd", "Reply" },
{ 'W', "send_cmd_rx", ACTION(send_cmd), ARG_IN | ARG_OUT2 | ARG_NOVFO,"Cmd","NBytes"},
{ 'b', "send_morse", ACTION(send_morse), ARG_IN | ARG_IN_LINE, "Morse" },
{ 0x8b, "get_dcd", ACTION(get_dcd), ARG_OUT, "DCD" },
{ '2', "power2mW", ACTION(power2mW), ARG_IN1 | ARG_IN2 | ARG_IN3 | ARG_OUT1 | ARG_NOVFO, "Power [0.0..1.0]", "Frequency", "Mode", "Power mW" },
@ -4011,7 +4012,7 @@ declare_proto_rig(get_powerstat)
* Special debugging purpose send command display reply until there's a
* timeout.
*
* 'w'
* 'w' and 'W'
*/
declare_proto_rig(send_cmd)
{
@ -4023,6 +4024,7 @@ declare_proto_rig(send_cmd)
char buf[BUFSZ];
char eom_buf[4] = { 0xa, 0xd, 0, 0 };
int binary = 0;
int rxbytes = BUFSZ;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -4094,8 +4096,10 @@ declare_proto_rig(send_cmd)
do
{
if (arg2) sscanf(arg2, "%d", &rxbytes);
if (rxbytes > 0) ++rxbytes; // need length + 1 for end of string
/* Assumes CR or LF is end of line char for all ASCII protocols. */
retval = read_string(&rs->rigport, buf, BUFSZ, eom_buf, strlen(eom_buf));
retval = read_string(&rs->rigport, buf, rxbytes, eom_buf, strlen(eom_buf));
if (retval < 0)
{