Exemplo n.º 1
0
static int thd72_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
  int retval, lvl;
  char c, lvlc, cmd[10];

  rig_debug(RIG_DEBUG_TRACE, "%s: called VFO=%s, level=%s, val=%g\n", __func__,
            rig_strvfo(vfo), rig_strlevel(level), val.f);

  retval = thd72_vfoc(rig, vfo, &c);

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

  switch (level)
  {
  case RIG_LEVEL_RFPOWER:
    if (val.f <= 0.01) { lvlc = '2'; }
    else if (val.f <= 0.10) { lvlc = '1'; }
    else { lvlc = '0'; }

    sprintf(cmd, "PC %c,%c", c, lvlc);
    return kenwood_simple_transaction(rig, cmd, 6);

  case RIG_LEVEL_VOXGAIN:
    return thd72_set_menu_item(rig, 8, (int)(val.f * 10.0 - 0.5));

  case RIG_LEVEL_VOXDELAY:
    if (val.i > 20000) { lvl = 6; }
    else if (val.i > 10000) { lvl = val.i / 10000 + 3; }
    else { lvl = val.i / 2500; }

    return thd72_set_menu_item(rig, 9, lvl);

  case RIG_LEVEL_SQL:
    lvlc = '0' + (int)(val.f * 5);
    sprintf(cmd, "PC %c,%c", c, lvlc);
    return kenwood_simple_transaction(rig, cmd, 6);

  case RIG_LEVEL_BALANCE:
    /* FIXME - is balance 0.0 .. 1.0 or -1.0 .. 1.0? */
    lvl = (int)(val.f * 4.0);
    return thd72_set_menu_item(rig, 13, lvl);

  default:
    rig_debug(RIG_DEBUG_ERR, "%s: Unsupported Level %d\n", __func__, level);
    return -RIG_EINVAL;
  }

  return retval;
}
Exemplo n.º 2
0
static int thd72_set_vfo(RIG *rig, vfo_t vfo)
{
  const char *cmd;

  rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);

  switch (vfo)
  {
  case RIG_VFO_A:
  case RIG_VFO_VFO:
  case RIG_VFO_MAIN:
    cmd = "BC 0";
    rig->state.current_vfo = RIG_VFO_A;
    break;

  case RIG_VFO_B:
  case RIG_VFO_SUB:
    rig->state.current_vfo = RIG_VFO_B;
    cmd = "BC 1";
    break;

  default:
    rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO: %s\n", __func__,
              rig_strvfo(vfo));
    return -RIG_ENTARGET;
  }

  return kenwood_simple_transaction(rig, cmd, 4);
}
Exemplo n.º 3
0
static int thd72_set_freq_item(RIG *rig, vfo_t vfo, int item, int val)
{
    int retval;
    char buf[64];

    retval = thd72_get_freq_info(rig, vfo, buf);
    if (retval != RIG_OK)
	return retval;
    buf[item] = val + '0';
    return kenwood_simple_transaction(rig, buf, 52);
}
Exemplo n.º 4
0
static int thd72_set_mem(RIG *rig, vfo_t vfo, int ch)
{
    int retval;
    char c, cmd[10];

    rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);

    retval = thd72_vfoc(rig, vfo, &c);
    if (retval != RIG_OK)
	return retval;
    sprintf(cmd, "MR %c,%03d", c, ch);
    return kenwood_simple_transaction(rig, cmd, 10);
}
Exemplo n.º 5
0
static int thd72_set_menu_item(RIG* rig, int item, int val)
{
    int retval;
    char c, buf[48];

    retval = thd72_get_menu_info(rig, buf);
    if (retval != RIG_OK)
	return retval;
    if (val < 10) c = val + '0';
    else 	  c = val - 10 + 'A';
    buf[3 + 2*item] = c;
    return kenwood_simple_transaction(rig, buf, 40);
}
Exemplo n.º 6
0
static int thd72_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs)
{
    int retval;
    char boff[9], buf[64];

    rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);

    retval = thd72_get_freq_info(rig, vfo, buf);
    if (retval != RIG_OK)
	return retval;
    sprintf(boff, "%08ld", offs);
    memcpy(buf+42, boff, 8);
    retval = kenwood_simple_transaction(rig, buf, 52);
    return retval;
}
Exemplo n.º 7
0
static int thd72_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
    int retval;
    char buf[64], fbuf[11];

    rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);

    retval = thd72_get_freq_info(rig, vfo, buf);
    if (retval != RIG_OK)
	return retval;
    sprintf(fbuf, "%010"PRIll, (int64_t)freq);
    memcpy(buf+5, fbuf, 10);
    retval = kenwood_simple_transaction(rig, buf, 52);
    return retval;
}
Exemplo n.º 8
0
static int thd72_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
{
  int retval, tinx;
  char buf[64], tmp[4];

  rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);

  tinx = 0;   /* default */

  if (tone != 0)
  {
    for (tinx = 0; tinx < 42; tinx++)
    {
      if (tone == kenwood42_ctcss_list[tinx])
      {
        break;
      }
    }

    if (tinx >= 42)
    {
      return -RIG_EINVAL;
    }
  }

  retval = thd72_get_freq_info(rig, vfo, buf);

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

  buf[24] = (tone == 0) ? '0' : '1';
  sprintf(tmp, "%02d", tinx);
  memcpy(buf + 33, tmp, 2);
  return kenwood_simple_transaction(rig, buf, 52);
}
Exemplo n.º 9
0
static int thd72_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
{
  int retval, cinx;
  char buf[64], tmp[4];

  rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);

  cinx = 0;   /* default */

  if (code != 0)
  {
    for (cinx = 0; cinx < 104; cinx++)
    {
      if (code == thd72dcs_list[cinx])
      {
        break;
      }
    }

    if (cinx >= 104)
    {
      return -RIG_EINVAL;
    }
  }

  retval = thd72_get_freq_info(rig, vfo, buf);

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

  buf[26] = (code == 0) ? '0' : '1';
  sprintf(tmp, "%03d", cinx);
  memcpy(buf + 36, tmp, 3);
  return kenwood_simple_transaction(rig, buf, 52);
}
Exemplo n.º 10
0
static int ts450_open(RIG *rig)
{
	int err;
	int maxtries;

	err = kenwood_open(rig);
	if (err != RIG_OK)
		return err;

	maxtries = rig->state.rigport.retry;
	/* no retry for this command that may be missing */
	rig->state.rigport.retry = 0;

	err = kenwood_simple_transaction(rig, "TO", 3);
	if (err != RIG_OK) {
		rig_debug(RIG_DEBUG_VERBOSE, "%s: tone unit not detected\n", __func__);
		rig->state.has_set_func &= ~RIG_FUNC_TONE;
		rig->state.has_get_func &= ~RIG_FUNC_TONE;
	}

	rig->state.rigport.retry = maxtries;

	return RIG_OK;
}
Exemplo n.º 11
0
/*
 * th_set_vfo
 * Apply to non-split models: TH-F7, TH-D7
 *
 * Assumes rig!=NULL
 */
int
th_set_vfo(RIG *rig, vfo_t vfo)
{
	const char *cmd;
	int retval;

	rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);


	/* from thf7.c
	 * The band must be active before selecting VFO or MEM.
	 * The dilemma is whether MEM should be applied to Band A or Band B.
	 * Remember, not all bands have the same capability
	 * TODO: if (RIG_VFO_MEM) query current band with BC, then do appropriate VMC
	 */

	/* set band */
	if (vfo != RIG_VFO_MEM) {

		switch (vfo) {
			case RIG_VFO_A:
			case RIG_VFO_VFO:
			case RIG_VFO_MAIN:
			    cmd = "BC 0";
			    break;

		    case RIG_VFO_B:
			case RIG_VFO_SUB:
			    cmd = "BC 1";
			    break;

		default:
			return kenwood_wrong_vfo(__func__, vfo);
		}

		retval = kenwood_simple_transaction(rig, cmd, 5);
		if (retval != RIG_OK)
				return retval;
	}

    /* No "VMC" cmd on THD72A */
    if (rig->caps->rig_model == RIG_MODEL_THD72A)
        return RIG_OK;

	/* set vfo */
	switch (vfo) {
		case RIG_VFO_A:
		case RIG_VFO_VFO:
		case RIG_VFO_MAIN:
		    cmd = "VMC 0,0";
		    break;

		case RIG_VFO_B:
		case RIG_VFO_SUB:
		    cmd = "VMC 1,0";
		    break;

		case RIG_VFO_MEM:
		if (rig->caps->rig_model == RIG_MODEL_THF7E ||
				rig->caps->rig_model == RIG_MODEL_THF6A)
			cmd = "VMC 0,1";
		else
			cmd = "VMC 0,2";
		break;

		default:
		return kenwood_wrong_vfo(__func__, vfo);
	}

	return kenwood_cmd(rig, cmd);
}