Beispiel #1
0
int ft857_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
{
  struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv;
  int n;

  if (vfo != RIG_VFO_CURR)
    return -RIG_ENTARGET;

  if (check_cache_timeout(&p->tx_status_tv))
    if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_TX_STATUS)) < 0)
      return n;

  if (p->tx_status & 0x80)
    {
      // TX status not valid when in RX
      unsigned char c;
      if ((n = ft857_read_eeprom(rig, 0x008d, &c)) < 0) /* get split status */
        return n;
      *split = (c & 0x80) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
    }
  else
    {
      *split = (p->tx_status & 0x20) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
    }

  return RIG_OK;
}
Beispiel #2
0
static int ft857_get_smeter_level(RIG *rig, value_t *val)
{
  struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv;
  int n;

  if (check_cache_timeout(&p->rx_status_tv))
    if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_RX_STATUS)) < 0)
      return n;

  val->i = n = (p->rx_status & 0x0F)  * 6 - 20;  // Convert S level to dB

  return RIG_OK;
}
Beispiel #3
0
static int ft857_get_smeter_level(RIG *rig, value_t *val)
{
  struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv;
  int n;

  if (check_cache_timeout(&p->rx_status_tv))
    if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_RX_STATUS)) < 0)
      return n;

  n = (p->rx_status & 0x0F);  // S level returned
  if (n >= 9) val->i = (n-9)*10;
  else val->i = n*6-54;

  return RIG_OK;
}
Beispiel #4
0
int ft857_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
  struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv;
  int n;

  if (vfo != RIG_VFO_CURR)
    return -RIG_ENTARGET;

  if (check_cache_timeout(&p->tx_status_tv))
    if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_TX_STATUS)) < 0)
      return n;

  *ptt = ((p->tx_status & 0x80) == 0);

  return RIG_OK;
}
Beispiel #5
0
int ft857_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
  struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv;
  int n;

  if (vfo != RIG_VFO_CURR)
    return -RIG_ENTARGET;

  if (check_cache_timeout(&p->fm_status_tv))
    if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0)
      return n;

  get_mode (rig, p, mode, width);

  return RIG_OK;
}
Beispiel #6
0
int ft857_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
  struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv;
  int n;

  if (vfo != RIG_VFO_CURR)
    return -RIG_ENTARGET;

  if (check_cache_timeout(&p->fm_status_tv))
    if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0)
      return n;

  *freq = from_bcd_be(p->fm_status, 8) * 10;

  return -RIG_OK;
}
Beispiel #7
0
int ft857_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
{
  struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv;
  int n;

  if (vfo != RIG_VFO_CURR)
    return -RIG_ENTARGET;

  if (check_cache_timeout(&p->rx_status_tv))
    if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_RX_STATUS)) < 0)
      return n;

  /* TODO: consider bit 6 too ??? (CTCSS/DCS code match) */
  if (p->rx_status & 0x80)
    *dcd = RIG_DCD_OFF;
  else
    *dcd = RIG_DCD_ON;

  return RIG_OK;
}
Beispiel #8
0
static int ft857_get_pometer_level(RIG *rig, value_t *val)
{
  struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv;
  int n;

  if (check_cache_timeout(&p->tx_status_tv))
    if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_TX_STATUS)) < 0)
      return n;

  /* Valid only if PTT is on */
  if ((p->tx_status & 0x80) == 0) {
    // convert watts to dBm
    val->i = 10 * log10(p->tx_status & 0x0F) + 30;
    // now convert to db over S9
    val->i += 73;
  }
  else
    val->i = -911; // invalid value return

  return RIG_OK;
}