Add new semi-colon separated hex values for send_raw icom

https://github.com/Hamlib/Hamlib/issues/1632
pull/1635/head
Michael Black W9MDB 2024-12-01 11:23:13 -06:00
rodzic ab2b5fb9e9
commit 4a34d4c27f
3 zmienionych plików z 33 dodań i 7 usunięć

1
NEWS
Wyświetl plik

@ -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

Wyświetl plik

@ -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

Wyświetl plik

@ -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;