kopia lustrzana https://github.com/Hamlib/Hamlib
New radio model, FT-450, including support for the new ASCII CAT command
syntax now employed by Yaesu. git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2247 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.7
rodzic
db317f0fcf
commit
62bd7d5d88
|
@ -2,7 +2,7 @@
|
|||
* Hamlib Interface - list of known rigs
|
||||
* Copyright (c) 2000-2005 by Stephane Fillod and Frank Singleton
|
||||
*
|
||||
* $Id: riglist.h,v 1.62 2007-11-07 18:38:32 fillods Exp $
|
||||
* $Id: riglist.h,v 1.63 2007-11-22 04:48:43 n0nb Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -86,7 +86,7 @@
|
|||
#define RIG_MODEL_FT1000MP RIG_MAKE_MODEL(RIG_YAESU, 24)
|
||||
#define RIG_MODEL_FT1000MPMKVFLD RIG_MAKE_MODEL(RIG_YAESU, 25)
|
||||
#define RIG_MODEL_VR5000 RIG_MAKE_MODEL(RIG_YAESU, 26)
|
||||
|
||||
#define RIG_MODEL_FT450 RIG_MAKE_MODEL(RIG_YAESU, 27)
|
||||
/*
|
||||
* Kenwood
|
||||
*/
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
## Yeasu radios that use the legacy CAT commands
|
||||
YAESUSRC = ft100.c ft747.c ft817.c ft847.c ft890.c ft900.c ft920.c \
|
||||
ft1000mp.c ft857.c ft897.c ft990.c frg8800.c \
|
||||
ft757gx.c ft736.c frg100.c frg9600.c ft1000d.c \
|
||||
vr5000.c ft767gx.c
|
||||
|
||||
## Yaesu radios that use the new Kenwood style CAT commands
|
||||
NEWCATSRC = newcat.c ft450.c
|
||||
|
||||
lib_LTLIBRARIES = hamlib-yaesu.la
|
||||
hamlib_yaesu_la_SOURCES = $(YAESUSRC) yaesu.c
|
||||
hamlib_yaesu_la_SOURCES = $(YAESUSRC) $(NEWCATSRC) yaesu.c
|
||||
hamlib_yaesu_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
hamlib_yaesu_la_LIBADD = $(top_builddir)/lib/libmisc.la \
|
||||
$(top_builddir)/src/libhamlib.la
|
||||
|
||||
noinst_HEADERS = ft100.h ft747.h ft817.h ft847.h ft890.h ft900.h ft920.h \
|
||||
ft1000mp.h ft857.h ft897.h ft990.h yaesu.h yaesu_tones.h \
|
||||
ft757gx.h ft767gx.h
|
||||
ft757gx.h ft767gx.h ft450.h newcat.h
|
||||
|
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (javabear at users.sourceforge.net)
|
||||
*
|
||||
* ft450.c - (C) Nate Bargmann 2007 (n0nb at arrl.net)
|
||||
*
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to an FT-450 using the "CAT" interface
|
||||
*
|
||||
*
|
||||
* $Id: ft450.c,v 1.1 2007-11-22 04:48:43 n0nb Exp $
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include "bandplan.h"
|
||||
#include "serial.h"
|
||||
#include "misc.h"
|
||||
#include "yaesu.h"
|
||||
#include "newcat.h"
|
||||
#include "ft450.h"
|
||||
|
||||
/*
|
||||
* ft450 rigs capabilities.
|
||||
* Also this struct is READONLY!
|
||||
*
|
||||
*/
|
||||
|
||||
const struct rig_caps ft450_caps = {
|
||||
.rig_model = RIG_MODEL_FT450,
|
||||
.model_name = "FT-450",
|
||||
.mfg_name = "Yaesu",
|
||||
.version = "0.0.1",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_ALPHA,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
.ptt_type = RIG_PTT_RIG,
|
||||
.dcd_type = RIG_DCD_NONE,
|
||||
.port_type = RIG_PORT_SERIAL,
|
||||
.serial_rate_min = 4800, /* Default rate per manual */
|
||||
.serial_rate_max = 38400,
|
||||
.serial_data_bits = 8,
|
||||
.serial_stop_bits = 1, /* Assumed since manual makes no mention */
|
||||
.serial_parity = RIG_PARITY_NONE,
|
||||
.serial_handshake = RIG_HANDSHAKE_NONE,
|
||||
.write_delay = FT450_WRITE_DELAY,
|
||||
.post_write_delay = FT450_POST_WRITE_DELAY,
|
||||
.timeout = 2000,
|
||||
.retry = 0,
|
||||
.has_get_func = RIG_FUNC_NONE,
|
||||
.has_set_func = RIG_FUNC_NONE,
|
||||
.has_get_level = RIG_LEVEL_NONE,
|
||||
.has_set_level = RIG_LEVEL_NONE,
|
||||
.has_get_parm = RIG_PARM_NONE,
|
||||
.has_set_parm = RIG_PARM_NONE,
|
||||
.ctcss_list = NULL,
|
||||
.dcs_list = NULL,
|
||||
.preamp = { RIG_DBLST_END, },
|
||||
.attenuator = { RIG_DBLST_END, },
|
||||
.max_rit = Hz(9999),
|
||||
.max_xit = Hz(0),
|
||||
.max_ifshift = Hz(1000),
|
||||
.vfo_ops = RIG_OP_TUNE,
|
||||
.targetable_vfo = RIG_TARGETABLE_ALL,
|
||||
.transceive = RIG_TRN_OFF, /* May enable later as the 450 has an Auto Info command */
|
||||
.bank_qty = 0,
|
||||
.chan_desc_sz = 0,
|
||||
.chan_list = { RIG_CHAN_END, },
|
||||
|
||||
.rx_range_list1 = {
|
||||
{kHz(30), MHz(56), FT450_ALL_RX_MODES, -1, -1, FT450_VFO_ALL, FT450_ANTS}, /* General coverage + ham */
|
||||
RIG_FRNG_END,
|
||||
}, /* FIXME: Are these the correct Region 1 values? */
|
||||
|
||||
.tx_range_list1 = {
|
||||
FRQ_RNG_HF(1, FT450_OTHER_TX_MODES, W(5), W(100), FT450_VFO_ALL, FT450_ANTS),
|
||||
FRQ_RNG_HF(1, FT450_AM_TX_MODES, W(2), W(25), FT450_VFO_ALL, FT450_ANTS), /* AM class */
|
||||
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
|
||||
.rx_range_list2 = {
|
||||
{kHz(30), MHz(56), FT450_ALL_RX_MODES, -1, -1, FT450_VFO_ALL, FT450_ANTS},
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
|
||||
.tx_range_list2 = {
|
||||
FRQ_RNG_HF(2, FT450_OTHER_TX_MODES, W(5), W(100), FT450_VFO_ALL, FT450_ANTS),
|
||||
FRQ_RNG_HF(2, FT450_AM_TX_MODES, W(2), W(25), FT450_VFO_ALL, FT450_ANTS), /* AM class */
|
||||
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
|
||||
.tuning_steps = {
|
||||
{FT450_SSB_CW_RX_MODES, Hz(10)}, /* Normal */
|
||||
{FT450_SSB_CW_RX_MODES, Hz(100)}, /* Fast */
|
||||
|
||||
{FT450_AM_RX_MODES, Hz(100)}, /* Normal */
|
||||
{FT450_AM_RX_MODES, kHz(1)}, /* Fast */
|
||||
|
||||
{FT450_FM_RX_MODES, Hz(100)}, /* Normal */
|
||||
{FT450_FM_RX_MODES, kHz(1)}, /* Fast */
|
||||
|
||||
RIG_TS_END,
|
||||
|
||||
},
|
||||
|
||||
/* mode/filter list, .remember = order matters! */
|
||||
.filters = {
|
||||
{RIG_MODE_SSB, kHz(2.4)}, /* standard SSB filter bandwidth */
|
||||
{RIG_MODE_CW, kHz(2.4)}, /* normal CW filter */
|
||||
{RIG_MODE_CW, kHz(0.5)}, /* CW filter with narrow selection (must be installed!) */
|
||||
{RIG_MODE_AM, kHz(6)}, /* normal AM filter */
|
||||
{RIG_MODE_AM, kHz(2.4)}, /* AM filter with narrow selection (SSB filter switched in) */
|
||||
{RIG_MODE_FM, kHz(12)}, /* FM */
|
||||
|
||||
RIG_FLT_END,
|
||||
},
|
||||
|
||||
.priv = NULL, /* private data FIXME: */
|
||||
|
||||
.rig_init = newcat_init,
|
||||
.rig_cleanup = newcat_cleanup,
|
||||
.rig_open = newcat_open, /* port opened */
|
||||
.rig_close = newcat_close, /* port closed */
|
||||
|
||||
.set_freq = newcat_set_freq,
|
||||
.get_freq = newcat_get_freq,
|
||||
// .set_mode = newcat_set_mode,
|
||||
// .get_mode = newcat_get_mode,
|
||||
.set_vfo = newcat_set_vfo,
|
||||
.get_vfo = newcat_get_vfo,
|
||||
// .set_ptt = newcat_set_ptt,
|
||||
// .get_ptt = newcat_get_ptt,
|
||||
// .set_split_vfo = newcat_set_split_vfo,
|
||||
// .get_split_vfo = newcat_get_split_vfo,
|
||||
// .set_rit = newcat_set_rit,
|
||||
// .get_rit = newcat_get_rit,
|
||||
// .set_func = newcat_set_func,
|
||||
// .get_level = newcat_get_level,
|
||||
// .vfo_op = newcat_vfo_op,
|
||||
};
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (javabear at users.sourceforge.net)
|
||||
*
|
||||
* ft450.h - (C) Nate Bargmann 2007 (n0nb at arrl.net)
|
||||
*
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to an FT-450 using the "CAT" interface
|
||||
*
|
||||
*
|
||||
* $Id: ft450.h,v 1.1 2007-11-22 04:48:43 n0nb Exp $
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _FT450_H
|
||||
#define _FT450_H 1
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define ON TRUE
|
||||
#define OFF FALSE
|
||||
|
||||
#define FT450_VFO_ALL (RIG_VFO_A|RIG_VFO_B)
|
||||
|
||||
/* Receiver caps */
|
||||
|
||||
#define FT450_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB)
|
||||
#define FT450_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB)
|
||||
#define FT450_AM_RX_MODES (RIG_MODE_AM)
|
||||
#define FT450_FM_RX_MODES (RIG_MODE_FM)
|
||||
|
||||
|
||||
/* TX caps */
|
||||
|
||||
#define FT450_OTHER_TX_MODES (RIG_MODE_CW| RIG_MODE_USB| RIG_MODE_LSB ) /* 100 W class */
|
||||
#define FT450_AM_TX_MODES (RIG_MODE_AM ) /* set 25W max */
|
||||
#define FT450_FUNC_ALL (RIG_FUNC_FAGC|RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_SBKIN|RIG_FUNC_FBKIN) /* fix */
|
||||
|
||||
|
||||
/*
|
||||
* Other features (used by rig_caps)
|
||||
*
|
||||
*/
|
||||
|
||||
#define FT450_ANTS 0
|
||||
|
||||
#define FT450_MEM_CHNL_LENGTH 1 /* 0x10 P1 = 01 return size */
|
||||
#define FT450_OP_DATA_LENGTH 19 /* 0x10 P1 = 03 return size */
|
||||
#define FT450_VFO_DATA_LENGTH 18 /* 0x10 P1 = 03 return size -- A & B returned */
|
||||
#define FT450_MEM_CHNL_DATA_LENGTH 19 /* 0x10 P1 = 04, P4 = 0x01-0x20 return size */
|
||||
#define FT450_STATUS_FLAGS_LENGTH 5 /* 0xf7, 0xfa return size */
|
||||
#define FT450_ALL_DATA_LENGTH 649 /* 0x10 P1 = 00 return size */
|
||||
|
||||
/* Timing values in mS */
|
||||
|
||||
#define FT450_PACING_INTERVAL 5
|
||||
#define FT450_PACING_DEFAULT_VALUE 0
|
||||
#define FT450_WRITE_DELAY 50
|
||||
|
||||
|
||||
/* Delay sequential fast writes */
|
||||
|
||||
#define FT450_POST_WRITE_DELAY 5
|
||||
|
||||
|
||||
/*
|
||||
* API local implementation
|
||||
*
|
||||
*/
|
||||
|
||||
//static int ft450_init(RIG *rig);
|
||||
//static int ft450_cleanup(RIG *rig);
|
||||
//static int ft450_open(RIG *rig);
|
||||
//static int ft450_close(RIG *rig);
|
||||
|
||||
//static int ft450_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||
|
||||
//static int ft450_set_vfo(RIG *rig, vfo_t vfo);
|
||||
|
||||
#endif /* _FT450_H */
|
|
@ -0,0 +1,518 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (javabear at users.sourceforge.net)
|
||||
* and the Hamlib Group (hamlib-developer at lists.sourceforge.net)
|
||||
*
|
||||
* newcat.c - (C) Nate Bargmann 2007 (n0nb at arrl.net)
|
||||
*
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to any newer Yaesu radio using the
|
||||
* "new" text CAT interface.
|
||||
*
|
||||
*
|
||||
* $Id: newcat.c,v 1.1 2007-11-22 04:48:43 n0nb Exp $
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include "iofunc.h"
|
||||
#include "newcat.h"
|
||||
|
||||
/* global variables */
|
||||
static char cat_term = ';'; /* Yaesu command terminator */
|
||||
|
||||
/*
|
||||
* future - private data
|
||||
*
|
||||
* FIXME: Does this need to be exposed to the application/frontend through
|
||||
* newcat_caps.priv? -N0NB
|
||||
*/
|
||||
|
||||
struct newcat_priv_data {
|
||||
// unsigned char pacing; /* pacing value */
|
||||
// unsigned int read_update_delay; /* depends on pacing value */
|
||||
vfo_t current_vfo; /* active VFO from last cmd */
|
||||
// unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */
|
||||
// yaesu_cmd_set_t pcs[FT450_NATIVE_SIZE]; /* private cmd set */
|
||||
// unsigned char update_data[FT450_ALL_DATA_LENGTH]; /* returned data--max value, some are less */
|
||||
// unsigned char current_mem; /* private memory channel number */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* ************************************
|
||||
*
|
||||
* Hamlib API functions
|
||||
*
|
||||
* ************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* rig_init
|
||||
*
|
||||
*/
|
||||
|
||||
int newcat_init(RIG *rig) {
|
||||
struct newcat_priv_data *priv;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
priv = (struct newcat_priv_data *)malloc(sizeof(struct newcat_priv_data));
|
||||
if (!priv) /* whoops! memory shortage! */
|
||||
return -RIG_ENOMEM;
|
||||
|
||||
/* TODO: read pacing from preferences */
|
||||
// priv->pacing = NEWCAT_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */
|
||||
// priv->read_update_delay = FT450_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */
|
||||
priv->current_vfo = RIG_VFO_MAIN; /* default to whatever */
|
||||
rig->state.priv = (void *)priv;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rig_cleanup
|
||||
*
|
||||
* the serial port is closed by the frontend
|
||||
*
|
||||
*/
|
||||
|
||||
int newcat_cleanup(RIG *rig) {
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
if (rig->state.priv)
|
||||
free(rig->state.priv);
|
||||
rig->state.priv = NULL;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rig_open
|
||||
*
|
||||
* New CAT does not support pacing
|
||||
*
|
||||
*/
|
||||
|
||||
int newcat_open(RIG *rig) {
|
||||
struct rig_state *rig_s;
|
||||
struct newcat_priv_data *priv;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
priv = (struct newcat_priv_data *)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: write_delay = %i msec\n",
|
||||
__func__, rig_s->rigport.write_delay);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: post_write_delay = %i msec\n",
|
||||
__func__, rig_s->rigport.post_write_delay);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rig_close
|
||||
*
|
||||
*/
|
||||
|
||||
int newcat_close(RIG *rig) {
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rig_set_freq
|
||||
*
|
||||
* Set frequency for a given VFO
|
||||
*
|
||||
* If vfo is set to RIG_VFO_CUR then vfo from priv_data is used.
|
||||
* If vfo differs from stored value then VFO will be set to the
|
||||
* passed vfo.
|
||||
*
|
||||
*/
|
||||
|
||||
int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
|
||||
const struct rig_caps *caps;
|
||||
struct newcat_priv_data *priv;
|
||||
struct rig_state *rig_s;
|
||||
char cmd_str[16]; /* Up to 999.999999999 GHz ;-) */
|
||||
char c;
|
||||
int err, len;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
priv = (struct newcat_priv_data *)rig->state.priv;
|
||||
caps = rig->caps;
|
||||
rig_s = &rig->state;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: passed vfo = 0x%02x\n", __func__, vfo);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: passed freq = %"PRIfreq" Hz\n", __func__, freq);
|
||||
|
||||
/* additional debugging */
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: R2 minimum freq = %"PRIfreq" Hz\n", __func__, caps->rx_range_list2[0].start);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: R2 maximum freq = %"PRIfreq" Hz\n", __func__, caps->rx_range_list2[0].end);
|
||||
|
||||
if (freq < caps->rx_range_list1[0].start || freq > caps->rx_range_list1[0].end ||
|
||||
freq < caps->rx_range_list2[0].start || freq > caps->rx_range_list2[0].end)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
if (vfo == RIG_VFO_CURR) {
|
||||
vfo = priv->current_vfo; /* from previous vfo cmd */
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
} else if (vfo != priv->current_vfo) {
|
||||
/* force a VFO change if requested vfo value differs from stored value */
|
||||
err = newcat_set_vfo(rig, vfo);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
}
|
||||
|
||||
switch (vfo) {
|
||||
case RIG_VFO_A:
|
||||
c = 'A';
|
||||
break;
|
||||
case RIG_VFO_B:
|
||||
c = 'B';
|
||||
break;
|
||||
default:
|
||||
return -RIG_ENIMPL; /* Only VFO_A or VFO_B are valid */
|
||||
}
|
||||
|
||||
/* CAT command/terminator plus variable length frequency
|
||||
* string length plus '\0' string terminator
|
||||
*/
|
||||
len = snprintf(NULL, 0, "F%c%d%c", c, (int)freq, cat_term) + 1;
|
||||
if (len < 0)
|
||||
return -RIG_EINTERNAL; /* bad news */
|
||||
|
||||
/* Build the command string */
|
||||
snprintf(cmd_str, len, "F%c%d%c", c, (int)freq, cat_term);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, cmd_str);
|
||||
|
||||
err = write_block(&rig_s->rigport, cmd_str, strlen(cmd_str));
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rig_get_freq
|
||||
*
|
||||
* Return Freq for a given VFO
|
||||
*
|
||||
*/
|
||||
|
||||
int newcat_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) {
|
||||
struct newcat_priv_data *priv;
|
||||
struct rig_state *rig_s;
|
||||
char cmd_str[4]; /* command + terminator */
|
||||
char ret_data[15]; /* freq string returned from rig up to 999.999999999 GHz*/
|
||||
// unsigned char *p;
|
||||
// unsigned char offset;
|
||||
// freq_t f;
|
||||
// int err, cmd_index, count;
|
||||
char c;
|
||||
int err;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: passed vfo = 0x%02x\n", __func__, vfo);
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
priv = (struct newcat_priv_data *)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
if (vfo == RIG_VFO_CURR) {
|
||||
err = newcat_get_vfo(rig, &priv->current_vfo);
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
vfo = priv->current_vfo; /* from previous get_vfo cmd */
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
}
|
||||
|
||||
switch(vfo) {
|
||||
case RIG_VFO_A:
|
||||
case RIG_VFO_VFO:
|
||||
// cmd_index = FT890_NATIVE_VFO_DATA;
|
||||
// offset = FT890_SUMO_VFO_A_FREQ;
|
||||
// count = FT890_VFO_DATA_LENGTH;
|
||||
c = 'A';
|
||||
break;
|
||||
case RIG_VFO_B:
|
||||
// cmd_index = FT890_NATIVE_VFO_DATA;
|
||||
// offset = FT890_SUMO_VFO_B_FREQ;
|
||||
// count = FT890_VFO_DATA_LENGTH;
|
||||
c = 'B';
|
||||
break;
|
||||
// case RIG_VFO_MEM:
|
||||
// case RIG_VFO_MAIN:
|
||||
// cmd_index = FT890_NATIVE_OP_DATA;
|
||||
// offset = FT890_SUMO_DISPLAYED_FREQ;
|
||||
// count = FT890_OP_DATA_LENGTH;
|
||||
// break;
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, unsupported VFO */
|
||||
}
|
||||
|
||||
/* Build the command string */
|
||||
snprintf(cmd_str, sizeof(cmd_str), "F%c%c", c, cat_term);
|
||||
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", cmd_str);
|
||||
|
||||
/* get freq */
|
||||
err = write_block(&rig_s->rigport, cmd_str, strlen(cmd_str));
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
err = read_string(&rig_s->rigport, ret_data, sizeof(ret_data), &cat_term, sizeof(cat_term));
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s\n",
|
||||
__func__, err, ret_data);
|
||||
|
||||
/* Check that command termination is correct */
|
||||
if (strchr(cat_term, ret_data[strlen(ret_data) - 1]) == NULL) {
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n",
|
||||
__func__, ret_data);
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
/* convert the read frequency string into freq_t and store in *freq */
|
||||
sscanf(ret_data+2, "%"SCNfreq, freq);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: freq = %"PRIfreq" Hz for vfo 0x%02x\n", __func__, freq, vfo);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rig_set_vfo
|
||||
*
|
||||
* set vfo and store requested vfo for later RIG_VFO_CURR
|
||||
* requests.
|
||||
*
|
||||
*/
|
||||
|
||||
int newcat_set_vfo(RIG *rig, vfo_t vfo) {
|
||||
struct newcat_priv_data *priv;
|
||||
struct rig_state *rig_s;
|
||||
char cmd_str[5]; /* command + VFO + terminator + \0 */
|
||||
char c;
|
||||
int err;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: passed vfo = 0x%02x\n", __func__, vfo);
|
||||
|
||||
priv = (struct newcat_priv_data *)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
if (vfo == RIG_VFO_CURR) {
|
||||
vfo = priv->current_vfo; /* from previous vfo cmd */
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
|
||||
}
|
||||
|
||||
/* FIXME: Include support for RIG_VFO_MAIN, RIG_VFO_MEM */
|
||||
switch(vfo) {
|
||||
case RIG_VFO_A:
|
||||
priv->current_vfo = vfo; /* update active VFO */
|
||||
c = '0';
|
||||
break;
|
||||
case RIG_VFO_B:
|
||||
priv->current_vfo = vfo;
|
||||
c = '1';
|
||||
break;
|
||||
// case RIG_VFO_MEM:
|
||||
/* reset to memory channel stored by previous get_vfo
|
||||
* The recall mem channel command uses 0x01 though 0x20
|
||||
*/
|
||||
// err = newcat_send_dynamic_cmd(rig, FT450_NATIVE_RECALL_MEM,
|
||||
// (priv->current_mem + 1), 0, 0, 0);
|
||||
// if (err != RIG_OK)
|
||||
// return err;
|
||||
|
||||
// priv->current_vfo = vfo;
|
||||
|
||||
// rig_debug(RIG_DEBUG_TRACE, "%s: set mem channel = 0x%02x\n",
|
||||
// __func__, priv->current_mem);
|
||||
// return RIG_OK;
|
||||
default:
|
||||
return -RIG_ENIMPL; /* sorry, VFO not implemented */
|
||||
}
|
||||
|
||||
/* Build the command string */
|
||||
snprintf(cmd_str, sizeof(cmd_str), "VS%c%c", c, cat_term);
|
||||
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", cmd_str);
|
||||
|
||||
err = write_block(&rig_s->rigport, cmd_str, strlen(cmd_str));
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rig_get_vfo
|
||||
*
|
||||
* get current RX vfo/mem and store requested vfo for
|
||||
* later RIG_VFO_CURR requests plus pass the tested vfo/mem
|
||||
* back to the frontend.
|
||||
*
|
||||
* TODO: determine memory status if possible
|
||||
*/
|
||||
|
||||
int newcat_get_vfo(RIG *rig, vfo_t *vfo) {
|
||||
struct newcat_priv_data *priv;
|
||||
struct rig_state *rig_s;
|
||||
char cmd_str[] = "VS;"; /* command + terminator string */
|
||||
char ret_data[5]; /* string returned from rig */
|
||||
char c;
|
||||
int err;
|
||||
|
||||
// unsigned char status_0; /* newcat status flag 0 */
|
||||
// unsigned char stat_vfo, stat_mem; /* status tests */
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
priv = (struct newcat_priv_data *)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, cmd_str);
|
||||
|
||||
/* Get VFO */
|
||||
err = write_block(&rig_s->rigport, cmd_str, strlen(cmd_str));
|
||||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
err = read_string(&rig_s->rigport, ret_data, sizeof(ret_data), &cat_term, sizeof(cat_term));
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
/* Check that command termination is correct */
|
||||
if (strchr(cat_term, ret_data[strlen(ret_data) - 1]) == NULL) {
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n",
|
||||
__func__, ret_data);
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s, VFO value = %c\n",
|
||||
__func__, err, ret_data, ret_data[2]);
|
||||
|
||||
/*
|
||||
* The current VFO value is a digit ('0' or '1' ('A' or 'B' respectively))
|
||||
* embedded at ret_data[2] in the read string.
|
||||
*/
|
||||
c = ret_data[2];
|
||||
|
||||
// status_0 = priv->update_data[FT450_SUMO_DISPLAYED_STATUS_0];
|
||||
// stat_vfo = status_0 & SF_VFO_MASK; /* get VFO active bits */
|
||||
// stat_mem = status_0 & SF_MEM_MASK; /* get MEM active bits */
|
||||
|
||||
// rig_debug(RIG_DEBUG_TRACE,
|
||||
// "%s: vfo status_0 = 0x%02x\n", __func__, status_0);
|
||||
// rig_debug(RIG_DEBUG_TRACE,
|
||||
// "%s: stat_vfo = 0x%02x\n", __func__, stat_vfo);
|
||||
// rig_debug(RIG_DEBUG_TRACE,
|
||||
// "%s: stat_mem = 0x%02x\n", __func__, stat_mem);
|
||||
|
||||
switch (c) {
|
||||
case '0':
|
||||
*vfo = RIG_VFO_A;
|
||||
priv->current_vfo = RIG_VFO_A;
|
||||
break;
|
||||
case '1':
|
||||
*vfo = RIG_VFO_B;
|
||||
priv->current_vfo = RIG_VFO_B;
|
||||
break;
|
||||
default:
|
||||
// switch (stat_mem) {
|
||||
// case SF_MT:
|
||||
// case SF_MR:
|
||||
// *vfo = RIG_VFO_MEM;
|
||||
// priv->current_vfo = RIG_VFO_MEM;
|
||||
|
||||
/*
|
||||
* Per Hamlib policy capture and store memory channel number
|
||||
* for future set_vfo command.
|
||||
*/
|
||||
// err = newcat_get_update_data(rig, FT450_NATIVE_MEM_CHNL,
|
||||
// FT450_MEM_CHNL_LENGTH);
|
||||
// if (err != RIG_OK)
|
||||
// return err;
|
||||
|
||||
// priv->current_mem = priv->update_data[FT450_SUMO_MEM_CHANNEL];
|
||||
|
||||
// rig_debug(RIG_DEBUG_TRACE, "%s: stored mem channel = 0x%02x\n",
|
||||
// __func__, priv->current_mem);
|
||||
// break;
|
||||
// default: /* Oops! */
|
||||
// return -RIG_EINVAL; /* sorry, wrong current VFO */
|
||||
// }
|
||||
return -RIG_EINVAL; /* sorry, wrong current VFO */
|
||||
}
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: set vfo = 0x%02x\n", __func__, *vfo);
|
||||
|
||||
return RIG_OK;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (javabear at users.sourceforge.net)
|
||||
* and the Hamlib Group (hamlib-developer at lists.sourceforge.net)
|
||||
*
|
||||
* newcat.h - (C) Nate Bargmann 2007 (n0nb at arrl.net)
|
||||
*
|
||||
* This shared library provides the backend API for communicating
|
||||
* via serial interface to any Yaesu radio using the new "CAT"
|
||||
* interface commands that are similar to the Kenwood command set.
|
||||
*
|
||||
*
|
||||
* $Id: newcat.h,v 1.1 2007-11-22 04:48:43 n0nb Exp $
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _NEWCAT_H
|
||||
#define _NEWCAT_H 1
|
||||
|
||||
/*
|
||||
* Functions considered to be Stable:
|
||||
*
|
||||
* Functions considered to be Beta:
|
||||
*
|
||||
* Functions considered to be Alpha:
|
||||
* newcat_set_freq
|
||||
* newcat_set_vfo
|
||||
*
|
||||
* Functions not yet implemented
|
||||
* most everything at this time.
|
||||
*
|
||||
* At this time, CAT documentation for the FT-450 can be obtained from
|
||||
* the Yaesu website at: http://www.yaesu.com/downloadFile.cfm?FileID=2600&FileCatID=158&FileName=FT%2D450%5FCAT%5FOperation%5FReference%5FBook.pdf&FileContentType=application%2Fpdf
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* newcat function definitions.
|
||||
*
|
||||
*/
|
||||
|
||||
int newcat_init(RIG *rig);
|
||||
int newcat_cleanup(RIG *rig);
|
||||
int newcat_open(RIG *rig);
|
||||
int newcat_close(RIG *rig);
|
||||
|
||||
int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||
int newcat_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
|
||||
|
||||
int newcat_set_vfo(RIG *rig, vfo_t vfo);
|
||||
int newcat_get_vfo(RIG *rig, vfo_t *vfo);
|
||||
|
||||
#endif /* _NEWCAT_H */
|
Ładowanie…
Reference in New Issue