kopia lustrzana https://github.com/Hamlib/Hamlib
Add send_raw to rigctl
rodzic
5d7f695727
commit
af6d4d03e3
|
@ -1288,6 +1288,14 @@ CW Skimmer is started and "set_lock_mode 0" when CW Skimmer is stopped.
|
||||||
.BR get_lock_mode
|
.BR get_lock_mode
|
||||||
Returns current lock mode status 1=On, 2=Off (only useful when using rigctld)
|
Returns current lock mode status 1=On, 2=Off (only useful when using rigctld)
|
||||||
.
|
.
|
||||||
|
.TP
|
||||||
|
.BR send_raw " \(aq" \fIString\fp \(aq
|
||||||
|
.EX
|
||||||
|
Can send ASCII string or 0xnn values -- there can be no spaces in the command string.
|
||||||
|
Examples:
|
||||||
|
send_raw FA;MD;
|
||||||
|
send_raw 0x40;0x32;0x32;0x00
|
||||||
|
.
|
||||||
.SH READLINE
|
.SH READLINE
|
||||||
.
|
.
|
||||||
If
|
If
|
||||||
|
|
|
@ -7413,6 +7413,12 @@ HAMLIB_EXPORT(int) rig_send_raw(RIG *rig, const unsigned char *send,
|
||||||
unsigned char buf[200];
|
unsigned char buf[200];
|
||||||
int nbytes;
|
int nbytes;
|
||||||
ENTERFUNC;
|
ENTERFUNC;
|
||||||
|
|
||||||
|
if (rig->caps->rig_model == RIG_MODEL_DUMMY || rig->caps->rig_model == RIG_MODEL_NONE)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: not implemented for model %s\n", __func__, rig->caps->model_name);
|
||||||
|
return -RIG_ENAVAIL;
|
||||||
|
}
|
||||||
int retval = write_block_sync(&rs->rigport, send, send_len);
|
int retval = write_block_sync(&rs->rigport, send, send_len);
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
|
|
|
@ -258,6 +258,7 @@ declare_proto_rig(set_separator);
|
||||||
declare_proto_rig(get_separator);
|
declare_proto_rig(get_separator);
|
||||||
declare_proto_rig(set_lock_mode);
|
declare_proto_rig(set_lock_mode);
|
||||||
declare_proto_rig(get_lock_mode);
|
declare_proto_rig(get_lock_mode);
|
||||||
|
declare_proto_rig(send_raw);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -370,6 +371,7 @@ static struct test_table test_list[] =
|
||||||
{ 0xa1, "get_separator", ACTION(get_separator), ARG_NOVFO, "Separator" },
|
{ 0xa1, "get_separator", ACTION(get_separator), ARG_NOVFO, "Separator" },
|
||||||
{ 0xa2, "set_lock_mode", ACTION(set_lock_mode), ARG_IN | ARG_NOVFO, "Locked" },
|
{ 0xa2, "set_lock_mode", ACTION(set_lock_mode), ARG_IN | ARG_NOVFO, "Locked" },
|
||||||
{ 0xa3, "get_lock_mode", ACTION(get_lock_mode), ARG_NOVFO, "Locked" },
|
{ 0xa3, "get_lock_mode", ACTION(get_lock_mode), ARG_NOVFO, "Locked" },
|
||||||
|
{ 0xa4, "send_raw", ACTION(send_raw), ARG_NOVFO | ARG_IN | ARG_OUT, "Send raw command" },
|
||||||
{ 0x00, "", NULL },
|
{ 0x00, "", NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5343,3 +5345,43 @@ declare_proto_rig(get_lock_mode)
|
||||||
fprintf(fout, "%d\n", lock);
|
fprintf(fout, "%d\n", lock);
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int parse_hex(const char *s, unsigned char *buf, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
buf[0] = 0;
|
||||||
|
char *s2 = strdup(s);
|
||||||
|
char *p = strtok(s2,";");
|
||||||
|
while(p)
|
||||||
|
{
|
||||||
|
unsigned int val;
|
||||||
|
sscanf(p,"0x%x", &val);
|
||||||
|
buf[i++] = val;
|
||||||
|
p = strtok(NULL, ";");
|
||||||
|
}
|
||||||
|
free(s2);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
/* 0xa4 */
|
||||||
|
declare_proto_rig(send_raw)
|
||||||
|
{
|
||||||
|
int retval;
|
||||||
|
unsigned char term[] = ";";
|
||||||
|
unsigned char buf[100];
|
||||||
|
unsigned char send[100];
|
||||||
|
unsigned char *sendp = (unsigned char*)arg1;
|
||||||
|
int arg1_len = strlen(arg1);
|
||||||
|
|
||||||
|
if (strncmp(arg1, "0x", 2)==0) {
|
||||||
|
arg1_len = parse_hex(arg1,send,sizeof(send));
|
||||||
|
sendp = send;
|
||||||
|
}
|
||||||
|
rig_debug(RIG_DEBUG_TRACE, "%s:\n", __func__);
|
||||||
|
retval = rig_send_raw(rig, (unsigned char*)sendp, arg1_len, buf, sizeof(buf),term);
|
||||||
|
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
|
||||||
|
{
|
||||||
|
fprintf(fout, "%s: ", cmd->arg1);
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue