예제 #1
0
파일: ft857.c 프로젝트: jessicalh/hamlib
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;
}
예제 #2
0
파일: ft857.c 프로젝트: mdblack98/hamlib
int ft857_get_vfo(RIG *rig, vfo_t *vfo)
{
  unsigned char c;
  int n;
  *vfo = RIG_VFO_B;
  if ((n = ft857_read_eeprom(rig, 0x0068, &c)) < 0) { /* get vfo status */
    return -RIG_EPROTO;
  }
  if ((c&0x1)==0) *vfo = RIG_VFO_A;
  return RIG_OK;
}
예제 #3
0
파일: ft857.c 프로젝트: jessicalh/hamlib
static int ft857_get_status(RIG *rig, int status)
{
  struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv;
  struct timeval *tv;
  unsigned char *data;
  int len;
  int n;

  switch (status) {
  case FT857_NATIVE_CAT_GET_FREQ_MODE_STATUS:
    data = p->fm_status;
    len  = YAESU_CMD_LENGTH;
    tv   = &p->fm_status_tv;
    break;
  case FT857_NATIVE_CAT_GET_RX_STATUS:
    data = &p->rx_status;
    len  = 1;
    tv   = &p->rx_status_tv;
    break;
  case FT857_NATIVE_CAT_GET_TX_STATUS:
    data = &p->tx_status;
    len  = 1;
    tv   = &p->tx_status_tv;
    break;
  default:
    rig_debug(RIG_DEBUG_ERR, "ft857_get_status: Internal error!\n");
    return -RIG_EINTERNAL;
  }

  serial_flush(&rig->state.rigport);

  write_block(&rig->state.rigport, (char *) p->pcs[status].nseq, YAESU_CMD_LENGTH);

  if ((n = read_block(&rig->state.rigport, (char *) data, len)) < 0)
    return n;

  if (n != len)
    return -RIG_EIO;

  if (status == FT857_NATIVE_CAT_GET_FREQ_MODE_STATUS) {
    if ((n = ft857_read_eeprom(rig, 0x0078, &p->fm_status[5])) < 0)
      return n;

    p->fm_status[5] >>= 5;
  }

  gettimeofday(tv, NULL);

  return RIG_OK;
}