コード例 #1
0
ファイル: sprintflst.c プロジェクト: wildj79/hamlib
int sprintf_parm(char *str, setting_t parm)
{
    int i, len = 0;

    *str = '\0';

    if (parm == RIG_PARM_NONE)
    {
        return 0;
    }

    for (i = 0; i < RIG_SETTING_MAX; i++)
    {
        const char *ms = rig_strparm(parm & rig_idx2setting(i));

        if (!ms || !ms[0])
        {
            continue;    /* unknown, FIXME! */
        }

        strcat(str, ms);
        strcat(str, " ");
        len += strlen(ms) + 1;
    }

    return len;
}
コード例 #2
0
ファイル: sprintflst.c プロジェクト: wildj79/hamlib
int sprintf_parm_gran(char *str, setting_t parm, const gran_t gran[])
{
    int i, len = 0;

    *str = '\0';

    if (parm == RIG_PARM_NONE)
    {
        return 0;
    }

    for (i = 0; i < RIG_SETTING_MAX; i++)
    {
        const char *ms;

        if (!(parm & rig_idx2setting(i)))
        {
            continue;
        }

        ms = rig_strparm(parm & rig_idx2setting(i));

        if (!ms || !ms[0])
        {
            if (parm != DUMMY_ALL && parm != RIG_PARM_SET(DUMMY_ALL))
            {
                rig_debug(RIG_DEBUG_BUG, "unknown parm idx %d\n", i);
            }

            continue;
        }

        if (RIG_PARM_IS_FLOAT(rig_idx2setting(i)))
        {
            len += sprintf(str + len,
                           "%s(%g..%g/%g) ",
                           ms,
                           gran[i].min.f,
                           gran[i].max.f,
                           gran[i].step.f);
        }
        else
        {
            len += sprintf(str + len,
                           "%s(%d..%d/%d) ",
                           ms,
                           gran[i].min.i,
                           gran[i].max.i,
                           gran[i].step.i);
        }
    }

    return len;
}
コード例 #3
0
ファイル: netrigctl.c プロジェクト: jnse/qtar8200
static int netrigctl_get_parm(RIG *rig, setting_t parm, value_t *val)
{
  int ret, len;
  char cmd[CMD_MAX];
  char buf[BUF_MAX];

  rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __FUNCTION__);

  len = sprintf(cmd, "p %s\n", rig_strparm(parm));

  ret = netrigctl_transaction(rig, cmd, len, buf);
  if (ret <= 0)
	return (ret < 0) ? ret : -RIG_EPROTO;

  if (RIG_PARM_IS_FLOAT(parm))
  	val->f = atoi(buf);
  else
  	val->i = atoi(buf);

  return RIG_OK;
}
コード例 #4
0
ファイル: netrigctl.c プロジェクト: jnse/qtar8200
static int netrigctl_set_parm(RIG *rig, setting_t parm, value_t val)
{
  int ret, len;
  char cmd[CMD_MAX];
  char buf[BUF_MAX];
  char pstr[32];

  rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__);

  if (RIG_PARM_IS_FLOAT(parm))
	sprintf(pstr, "%f", val.f);
  else
	sprintf(pstr, "%d", val.i);
  len = sprintf(cmd, "P %s %s\n", rig_strparm(parm), pstr);

  ret = netrigctl_transaction(rig, cmd, len, buf);
  if (ret > 0)
	return -RIG_EPROTO;
  else
  	return ret;
}
コード例 #5
0
ファイル: rigmatrix.c プロジェクト: airween/hamlib
int main(int argc, char *argv[])
{
    time_t gentime;
    int set_or_get;
    int i;
    char *pbuf, prntbuf[512];

    rig_load_all_backends();


    printf("<TABLE BORDER=1>");
    printf("<TR><TD>Model</TD><TD>Mfg</TD><TD>Vers.</TD><TD>Status</TD>"
           "<TD>Type</TD><TD>Freq. range</TD><TD>Parameters</TD>"
           "<TD>Capabilities</TD>"
           "<TD>Get func</TD>"
           "<TD>Set func</TD>"
           "<TD>Get level</TD>"
           "<TD>Set level</TD>"
           "<TD>Get parm</TD>"
           "<TD>Set parm</TD>"
           "</TR>\n");
    rig_list_foreach(print_caps_sum, NULL);
    printf("</TABLE>\n");

    printf("<P>");

    printf("<TABLE BORDER=1>\n");
    printf("<TR><TD>Model</TD><TD>PTT</TD><TD>DCD</TD><TD>Port</TD>"
           "<TD>Speed min</TD><TD>Speed max</TD>"
           "<TD>Parm.</TD><TD>Handshake</TD><TD>Write delay</TD>"
           "<TD>Post delay</TD><TD>Timeout</TD><TD>Retry</TD></TR>\n");
    rig_list_foreach(print_caps_parameters, NULL);
    printf("</TABLE>\n");

    printf("<P>");

    printf("<TABLE BORDER=1>\n");
    printf("<TR><TD>Model</TD><TD>Freq. range</TD></TR>\n");
    rig_list_foreach(print_caps_range, NULL);
    printf("</TABLE>\n");

    printf("<P>");

    printf("<TABLE BORDER=1>\n");
    printf("<TR><TD>Model</TD><TD>Target VFO</TD>"
           "<TD>Set freq</TD><TD>Get freq</TD>"
           "<TD>Set mode</TD><TD>Get mode</TD>"
           "<TD>Set VFO</TD><TD>Get VFO</TD>"
           "<TD>Set PTT</TD><TD>Get PTT</TD><TD>Get DCD</TD>"
           "<TD>Set rptr shift</TD><TD>Get rptr shift</TD>"
           "<TD>Set rptr offs</TD><TD>Get rptr offs</TD>"
           "<TD>Set split frq</TD><TD>Get split frq</TD>"
           "<TD>Set split</TD><TD>Get split</TD>"
           "<TD>Set ts</TD><TD>Get ts</TD>"
           "<TD>Set CTCSS</TD><TD>Get CTCSS</TD>"
           "<TD>Set DCS</TD><TD>Get DCS</TD>"
           "<TD>Set Power Stat</TD><TD>Get Power Stat</TD>"
           "<TD>Set trn</TD><TD>Get trn</TD>"
           "<TD>Decode</TD><TD>Get info</TD>"
           "</TR>\n");
    rig_list_foreach(print_caps_caps, NULL);
    printf("</TABLE>\n");

    printf("<P>");

    bitmap_func = 0;
    prntbuf[0] = '\0';
    pbuf = prntbuf;

    for (i = 0; i < RIG_SETTING_MAX; i++)
    {
        setting_t func = rig_idx2setting(i);
        const char *s = rig_strfunc(func);

        if (!s)
        {
            continue;
        }

        bitmap_func |= func;
        pbuf += sprintf(pbuf, "<TD>%s</TD>", s);
    }

    printf("Has set func");
    printf("<TABLE BORDER=1>\n");
    printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
    set_or_get = 1;
    rig_list_foreach(print_caps_func, &set_or_get);
    printf("</TABLE>\n");

    printf("<P>");

    printf("Has get func");
    printf("<TABLE BORDER=1>\n");
    printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
    set_or_get = 0;
    rig_list_foreach(print_caps_func, &set_or_get);
    printf("</TABLE>\n");

    printf("<P>");

    bitmap_level = 0;
    prntbuf[0] = '\0';
    pbuf = prntbuf;

    for (i = 0; i < RIG_SETTING_MAX; i++)
    {
        setting_t level = rig_idx2setting(i);
        const char *s = rig_strlevel(level);

        if (!s)
        {
            continue;
        }

        bitmap_level |= level;
        pbuf += sprintf(pbuf, "<TD>%s</TD>", s);
    }

    printf("Set level");
    printf("<TABLE BORDER=1>\n");
    printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
    set_or_get = 1;
    rig_list_foreach(print_caps_level, &set_or_get);
    printf("</TABLE>\n");

    printf("<P>");

    printf("Get level");
    printf("<TABLE BORDER=1>\n");
    printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
    set_or_get = 0;
    rig_list_foreach(print_caps_level, &set_or_get);
    printf("</TABLE>\n");

    printf("<P>");

    bitmap_parm = 0;
    prntbuf[0] = '\0';
    pbuf = prntbuf;

    for (i = 0; i < RIG_SETTING_MAX; i++)
    {
        setting_t parm = rig_idx2setting(i);
        const char *s = rig_strparm(parm);

        if (!s)
        {
            continue;
        }

        bitmap_parm |= parm;
        pbuf += sprintf(pbuf, "<TD>%s</TD>", s);
    }

    printf("Set parm");
    printf("<TABLE BORDER=1>\n");
    printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
    set_or_get = 1;
    rig_list_foreach(print_caps_parm, &set_or_get);
    printf("</TABLE>\n");

    printf("<P>");

    printf("Get parm");
    printf("<TABLE BORDER=1>\n");
    printf("<TR><TD>Model</TD>%s</TR>\n", prntbuf);
    set_or_get = 0;
    rig_list_foreach(print_caps_parm, &set_or_get);
    printf("</TABLE>\n");

    printf("<P>");

    time(&gentime);
    printf("Rigmatrix generated %s by %s\n", ctime(&gentime), getenv("USER"));

    printf("</body></html>\n");

    return 0;
}
コード例 #6
0
ファイル: memcsv.c プロジェクト: airween/hamlib
int csv_parm_save(RIG *rig, const char *outfilename)
{
    int i, ret;
    FILE *f;
    setting_t parm, get_parm = all ? 0x7fffffff : rig->state.has_get_parm;

    f = fopen(outfilename, "w");

    if (!f)
    {
        return -1;
    }

    for (i = 0; i < RIG_SETTING_MAX; i++)
    {
        const char *ms = rig_strparm(get_parm & rig_idx2setting(i));

        if (!ms || !ms[0])
        {
            continue;
        }

        fprintf(f, "%s%c", ms, csv_sep);
    }

    rig_ext_parm_foreach(rig, print_parm_name, f);
    fprintf(f, "\n");

    for (i = 0; i < RIG_SETTING_MAX; i++)
    {
        const char *ms;
        value_t val;

        parm = get_parm & rig_idx2setting(i);
        ms = rig_strparm(parm);

        if (!ms || !ms[0])
        {
            continue;
        }

        ret = rig_get_parm(rig, parm, &val);

        if (ret != RIG_OK)
        {
            return ret;
        }

        if (RIG_PARM_IS_FLOAT(parm))
        {
            fprintf(f, "%f%c", val.f, csv_sep);
        }
        else
        {
            fprintf(f, "%d%c", val.i, csv_sep);
        }
    }


    rig_ext_parm_foreach(rig, print_parm_val, f);
    fprintf(f, "\n");
    fclose(f);

    return 0;
}