From 5abc606e13903e821c0ac88a2768f6549c5b8704 Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Sun, 1 Dec 2024 11:23:13 -0600 Subject: [PATCH] Add new semi-colon separated hex values for send_raw icom --- NEWS | 1 + doc/man1/rigctl.1 | 19 ++++++++++++++++--- tests/rigctl_parse.c | 20 ++++++++++++++++---- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 2cef16957..d9b04777f 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ Version 5.x -- future * Change FT1000MP Mark V model names to align with FT1000MP Version 4.6 + * send_raw can now take hex digits as colon-seperated -- e.g. send_raw icom xfe:xfe:x94:xe0:03:xfd * Add IC7760 * IC7300 Mode filter can now be set by # (i.e. 1,2,3) * Fixed AF6SA WRC rotor controller diff --git a/doc/man1/rigctl.1 b/doc/man1/rigctl.1 index cb8ba8a89..9a1b6d44e 100644 --- a/doc/man1/rigctl.1 +++ b/doc/man1/rigctl.1 @@ -1398,13 +1398,26 @@ Returns current lock mode status 1=On, 2=Off (only useful when using rigctld) .TP .BR send_raw " \(aq" \fITerminator\fP "\(aq \(aq" \fIString\fP \(aq .EX -Can send ASCII string or 0xnn values -- there can be no spaces in the command string. +Can send ASCII string or 0xnn values or xnn values -- there can be no spaces in the command string. Possible terminator values are CR, LF, ;, ICOM, 0-100 (bytes to read), or -1 meaning unknown (will timeout on read) -Examples: - send_raw ; FA;MD; +Examples (note that a ; must be escaped in Unix/Linux): +For Windows & Unix/Linux we have a new colon-separated format for hex digits + send_raw icom 0xFE:0xFE:0x94:0x03:0xFD Note: colon-separated does not have to be escaped on Unix/Linux + send_raw -1 0xFE:0xFE:0x94:0x03:0xFD + send_raw 14 0xFE:0xFE:0x94:0x03:0xFD + Note that ASCII commands still require escaping the semicolon on Unix/Linux + send_raw \; FA\;MD\; + +For Windows: send_raw icom 0xFE;0xFE;0x94;0x03;0xFD send_raw -1 0xFE;0xFE;0x94;0x03;0xFD send_raw 14 0xFE;0xFE;0x94;0x03;0xFD + + For Unix/Linux + send_raw icom 0xFE\;0xFE\;0x94\;0x03\;0xFD + send_raw \; FA\;MD\; + send_raw -1 0xFE\;0xFE\;0x94\;0x03\;0xFD + send_raw 14 0xFE\;0xFE\;0x94\;0x03\;0xFD . .TP .BR client_version " \(aq" \fIString\fP "\(aq diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 4b305a281..5c52ad408 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -5793,14 +5793,26 @@ static int parse_hex(const char *s, unsigned char *buf, int len) int i = 0; buf[0] = 0; char *s2 = strdup(s); - char *p = strtok(s2, ";"); + char *p = strtok(s2, ";:"); while (p) { unsigned int val; - sscanf(p, "0x%x", &val); + int n; + + if ((n = sscanf(p, "0x%2x", &val)) != 1) + { + n = sscanf(p, "x%2x", &val); + } + + if (n == 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: unable to parse 0x??; or x??; from '%s'\n", + __func__, s); + } + buf[i++] = val; - p = strtok(NULL, ";"); + p = strtok(NULL, ";:"); } free(s2); @@ -5863,7 +5875,7 @@ declare_proto_rig(send_raw) return -RIG_EINVAL; } - if (strncmp(arg2, "0x", 2) == 0) + if (strncmp(arg2, "0x", 2) == 0 || arg2[0] == 'x') { arg2_len = parse_hex(arg2, send, sizeof(send)); sendp = send;