kopia lustrzana https://github.com/Hamlib/Hamlib
Add rig_strrmodes function and fix flrig to print mode list correctly
rodzic
011efe0452
commit
b3c6b9d707
|
@ -841,10 +841,14 @@ static int flrig_open(RIG *rig)
|
||||||
}
|
}
|
||||||
|
|
||||||
rig->state.mode_list = modes;
|
rig->state.mode_list = modes;
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: hamlib modes=%s\n", __func__,
|
|
||||||
rig_strrmode(modes));
|
retval = rig_strrmodes(modes, value, sizeof(value));
|
||||||
|
if (retval != RIG_OK) { // we might get TRUNC but we can still print the debug
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: %s\n", __func__, rigerror(retval));
|
||||||
|
}
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: hamlib modes=%s\n", __func__, value);
|
||||||
|
|
||||||
return RIG_OK;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -2410,6 +2410,7 @@ rig_probe HAMLIB_PARAMS((hamlib_port_t *p));
|
||||||
|
|
||||||
/* Misc calls */
|
/* Misc calls */
|
||||||
extern HAMLIB_EXPORT(const char *) rig_strrmode(rmode_t mode);
|
extern HAMLIB_EXPORT(const char *) rig_strrmode(rmode_t mode);
|
||||||
|
extern HAMLIB_EXPORT(int) rig_strrmodes(rmode_t modes, char *buf, int buflen);
|
||||||
extern HAMLIB_EXPORT(const char *) rig_strvfo(vfo_t vfo);
|
extern HAMLIB_EXPORT(const char *) rig_strvfo(vfo_t vfo);
|
||||||
extern HAMLIB_EXPORT(const char *) rig_strfunc(setting_t);
|
extern HAMLIB_EXPORT(const char *) rig_strfunc(setting_t);
|
||||||
extern HAMLIB_EXPORT(const char *) rig_strlevel(setting_t);
|
extern HAMLIB_EXPORT(const char *) rig_strlevel(setting_t);
|
||||||
|
|
39
src/misc.c
39
src/misc.c
|
@ -383,7 +383,7 @@ const char *HAMLIB_API rig_strrmode(rmode_t mode)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// only enable it needed for debugging -- too verbose otherwise
|
// only enable if needed for debugging -- too verbose otherwise
|
||||||
//rig_debug(RIG_DEBUG_TRACE, "%s called mode=0x%"PRXll"\n", __func__, mode);
|
//rig_debug(RIG_DEBUG_TRACE, "%s called mode=0x%"PRXll"\n", __func__, mode);
|
||||||
|
|
||||||
if (mode == RIG_MODE_NONE)
|
if (mode == RIG_MODE_NONE)
|
||||||
|
@ -402,6 +402,43 @@ const char *HAMLIB_API rig_strrmode(rmode_t mode)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Convert RIG_MODE or'd value to alpha string of all modes
|
||||||
|
* \param modes RIG_MODE or'd value
|
||||||
|
* \param buf char* of result buffer
|
||||||
|
* \param buflen length of buffer
|
||||||
|
* \return rig status -- RIG_ETRUNC if buffer not big enough
|
||||||
|
*
|
||||||
|
* \sa rmode_t
|
||||||
|
*/
|
||||||
|
const int HAMLIB_API rig_strrmodes(rmode_t modes, char *buf, int buflen)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// only enable if needed for debugging -- too verbose otherwise
|
||||||
|
//rig_debug(RIG_DEBUG_TRACE, "%s called mode=0x%"PRXll"\n", __func__, mode);
|
||||||
|
|
||||||
|
if (modes == RIG_MODE_NONE)
|
||||||
|
{
|
||||||
|
snprintf(buf,buflen,"NONE");
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0 ; mode_str[i].str[0] != '\0'; i++)
|
||||||
|
{
|
||||||
|
if (modes & mode_str[i].mode)
|
||||||
|
{
|
||||||
|
char modebuf[16];
|
||||||
|
if (strlen(buf)==0) snprintf(modebuf, sizeof(modebuf), "%s", mode_str[i].str);
|
||||||
|
else snprintf(modebuf, sizeof(modebuf)," %s", mode_str[i].str);
|
||||||
|
strncat(buf, modebuf, buflen-strlen(buf)-1);
|
||||||
|
if (strlen(buf) > buflen-10) return -RIG_ETRUNC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue