kopia lustrzana https://github.com/Hamlib/Hamlib
Add get_vfo_list command so rigctl can see available vfos
Should allow Log4OM to query VFOB/Sub freq now Another fix to argumenet prompting with rigctl/rigctld https://github.com/Hamlib/Hamlib/issues/530pull/544/head
rodzic
02fffca989
commit
635ee95f3f
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <time.h>
|
||||
|
||||
|
@ -2322,6 +2323,9 @@ extern HAMLIB_EXPORT(int)
|
|||
rig_get_vfo_info HAMLIB_PARAMS((RIG *rig,
|
||||
vfo_t vfo, freq_t *freq, rmode_t *mode, pbwidth_t *width));
|
||||
|
||||
extern HAMLIB_EXPORT(const char *)
|
||||
rig_get_vfo_list HAMLIB_PARAMS((RIG *rig));
|
||||
|
||||
extern HAMLIB_EXPORT(int)
|
||||
netrigctl_get_vfo_mode HAMLIB_PARAMS((RIG *rig));
|
||||
|
||||
|
@ -2829,7 +2833,6 @@ extern HAMLIB_EXPORT(int)
|
|||
rig_set_uplink HAMLIB_PARAMS((RIG *rig,
|
||||
int val));
|
||||
|
||||
|
||||
extern HAMLIB_EXPORT(const char *)
|
||||
rig_get_info HAMLIB_PARAMS((RIG *rig));
|
||||
|
||||
|
@ -2878,11 +2881,12 @@ rig_need_debug HAMLIB_PARAMS((enum rig_debug_level_e debug_level));
|
|||
// this need to be fairly big to avoid compiler warnings
|
||||
#define DEBUGMSGSAVE_SIZE 24000
|
||||
extern HAMLIB_EXPORT_VAR(char) debugmsgsave[DEBUGMSGSAVE_SIZE]; // last debug msg
|
||||
extern HAMLIB_EXPORT_VAR(char) debugmsgsave2[DEBUGMSGSAVE_SIZE]; // last-1 debug msg
|
||||
#ifndef __cplusplus
|
||||
#ifdef __GNUC__
|
||||
// doing the debug macro with a dummy sprintf allows gcc to check the format string
|
||||
//#define rig_debug(debug_level,fmt,...) { char xxxbuf[16384]="";snprintf(xxxbuf,sizeof(xxxbuf),fmt,__VA_ARGS__);rig_debug(debug_level,fmt,##__VA_ARGS__); }
|
||||
#define rig_debug(debug_level,fmt,...) { snprintf(debugmsgsave,sizeof(debugmsgsave),fmt,__VA_ARGS__);rig_debug(debug_level,fmt,##__VA_ARGS__); }
|
||||
#define rig_debug(debug_level,fmt,...) { strcpy(debugmsgsave2, debugmsgsave);snprintf(debugmsgsave,sizeof(debugmsgsave),fmt,__VA_ARGS__);rig_debug(debug_level,fmt,##__VA_ARGS__); }
|
||||
#endif
|
||||
#endif
|
||||
extern HAMLIB_EXPORT(void)
|
||||
|
|
28
src/rig.c
28
src/rig.c
|
@ -291,6 +291,7 @@ int foreach_opened_rig(int (*cfunc)(RIG *, rig_ptr_t), rig_ptr_t data)
|
|||
* \todo support gettext/localization
|
||||
*/
|
||||
char debugmsgsave[DEBUGMSGSAVE_SIZE] = "No message";
|
||||
char debugmsgsave2[DEBUGMSGSAVE_SIZE] = "No message";
|
||||
|
||||
const char *HAMLIB_API rigerror(int errnum)
|
||||
{
|
||||
|
@ -302,11 +303,11 @@ const char *HAMLIB_API rigerror(int errnum)
|
|||
return "ERR_OUT_OF_RANGE";
|
||||
}
|
||||
|
||||
static char msg[25000];
|
||||
static char msg[DEBUGMSGSAVE_SIZE*2];
|
||||
// we have to remove LF from debugmsgsave since calling function controls LF
|
||||
char *p = &debugmsgsave[strlen(debugmsgsave)-1];
|
||||
if (*p=='\n') *p=0;
|
||||
snprintf(msg, sizeof(msg), "%.80s\n%.15000s", rigerror_table[errnum], debugmsgsave);
|
||||
snprintf(msg, sizeof(msg), "%.80s\n%.15000s\n%.15000s", rigerror_table[errnum], debugmsgsave2, debugmsgsave);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@ -1604,7 +1605,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: set_vfo err %.10000s\n", __func__, rigerror(retcode));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: set_vfo(%s) err %.10000s\n", __func__, rig_strvfo(vfo), rigerror(retcode));
|
||||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
|
@ -5638,6 +5639,27 @@ int HAMLIB_API rig_get_vfo_info(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode
|
|||
RETURNFUNC(retcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get list of available vfos
|
||||
* \param rig The rig handle
|
||||
*
|
||||
* Retrieves all usable vfo entries for the rig
|
||||
*
|
||||
* \return a pointer to a string, e.g. "VFOA VFOB Mem"
|
||||
* if the operation has been successful, otherwise NULL if an error occurred
|
||||
*/
|
||||
const char *HAMLIB_API rig_get_vfo_list(RIG *rig)
|
||||
{
|
||||
ENTERFUNC;
|
||||
|
||||
if (CHECK_RIG_ARG(rig))
|
||||
{
|
||||
RETURNFUNC(NULL);
|
||||
}
|
||||
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the Hamlib license
|
||||
*
|
||||
|
|
|
@ -167,6 +167,7 @@ declare_proto_rig(get_mode);
|
|||
declare_proto_rig(set_vfo);
|
||||
declare_proto_rig(get_vfo);
|
||||
declare_proto_rig(get_vfo_info);
|
||||
declare_proto_rig(get_vfo_list);
|
||||
declare_proto_rig(set_ptt);
|
||||
declare_proto_rig(get_ptt);
|
||||
declare_proto_rig(get_ptt);
|
||||
|
@ -332,6 +333,7 @@ static struct test_table test_list[] =
|
|||
{ 0xf0, "chk_vfo", ACTION(chk_vfo), ARG_NOVFO, "ChkVFO" }, /* rigctld only--check for VFO mode */
|
||||
{ 0xf2, "set_vfo_opt", ACTION(set_vfo_opt), ARG_NOVFO | ARG_IN, "Status" }, /* turn vfo option on/off */
|
||||
{ 0xf3, "get_vfo_info", ACTION(get_vfo_info), ARG_NOVFO | ARG_IN1 | ARG_OUT3, "VFO", "Freq", "Mode", "Width" }, /* turn vfo option on/off */
|
||||
{ 0xf4, "get_vfo_list", ACTION(get_vfo_list), ARG_OUT | ARG_NOVFO, "VFOs" },
|
||||
{ 0xf1, "halt", ACTION(halt), ARG_NOVFO }, /* rigctld only--halt the daemon */
|
||||
{ 0x8c, "pause", ACTION(pause), ARG_IN, "Seconds" },
|
||||
{ 0x00, "", NULL },
|
||||
|
@ -721,7 +723,6 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
if (cmd == '\\')
|
||||
{
|
||||
unsigned char cmd_name[MAXNAMSIZ], *pcmd = cmd_name;
|
||||
int c_len = MAXNAMSIZ;
|
||||
|
||||
if (scanfc(fin, "%c", pcmd) < 1)
|
||||
{
|
||||
|
@ -729,19 +730,8 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
return -1;
|
||||
}
|
||||
|
||||
#if 1
|
||||
fscanf(fin, "%s", ++pcmd);
|
||||
while(*++pcmd);
|
||||
#else
|
||||
while (c_len-- && (isalnum(*pcmd) || *pcmd == '_'))
|
||||
{
|
||||
if (scanfc(fin, "%c", ++pcmd) < 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#5?\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
*pcmd = '\0';
|
||||
cmd = parse_arg((char *)cmd_name);
|
||||
|
@ -2161,6 +2151,10 @@ declare_proto_rig(set_vfo)
|
|||
|
||||
#endif
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: set_vfo(%s) failed, requested %s\n", __func__, rig_strvfo(vfo), arg1);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -2221,6 +2215,23 @@ declare_proto_rig(get_vfo_info)
|
|||
RETURNFUNC(retval);
|
||||
}
|
||||
|
||||
/* '\get_vfo_list' */
|
||||
declare_proto_rig(get_vfo_list)
|
||||
{
|
||||
static char prntbuf[256];
|
||||
|
||||
rig_sprintf_vfo(prntbuf, rig->state.vfo_list);
|
||||
|
||||
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
|
||||
{
|
||||
fprintf(fout, "%s: ", cmd->arg1);
|
||||
}
|
||||
|
||||
fprintf(fout, "%s%c", prntbuf[0] ? prntbuf : "None", ext_resp);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/* 'T' */
|
||||
declare_proto_rig(set_ptt)
|
||||
|
|
Ładowanie…
Reference in New Issue