diff --git a/include/hamlib/riglist.h b/include/hamlib/riglist.h index 02c0aa08a..8e90c1c5f 100644 --- a/include/hamlib/riglist.h +++ b/include/hamlib/riglist.h @@ -96,6 +96,7 @@ #define RIG_MODEL_FTDX5000 RIG_MAKE_MODEL(RIG_YAESU, 32) #define RIG_MODEL_VX1700 RIG_MAKE_MODEL(RIG_YAESU, 33) #define RIG_MODEL_FT1200 RIG_MAKE_MODEL(RIG_YAESU, 34) +#define RIG_MODEL_FT991 RIG_MAKE_MODEL(RIG_YAESU, 35) /* * Kenwood diff --git a/yaesu/Makefile.am b/yaesu/Makefile.am index 9765d640b..851720b9f 100644 --- a/yaesu/Makefile.am +++ b/yaesu/Makefile.am @@ -8,8 +8,8 @@ YAESUSRC = ft100.c ft100.h ft747.c ft747.h ft817.c ft817.h ft847.c ft847.h \ ft767gx.h ft840.c ft840.h ft980.c vx1700.c vx1700.h ## Yaesu radios that use the new Kenwood style CAT commands -NEWCATSRC = newcat.c newcat.h ft450.c ft450.h ft950.c ft950.h ft2000.c \ - ft2000.h ft9000.c ft9000.h ft5000.c ft5000.h ft1200.c ft1200.h +NEWCATSRC = newcat.c newcat.h ft450.c ft450.h ft950.c ft950.h ft991.c ft991.h \ + ft2000.c ft2000.h ft9000.c ft9000.h ft5000.c ft5000.h ft1200.c ft1200.h noinst_LTLIBRARIES = libhamlib-yaesu.la libhamlib_yaesu_la_SOURCES = $(YAESUSRC) $(NEWCATSRC) yaesu.c yaesu.h diff --git a/yaesu/ft100.c b/yaesu/ft100.c index 5e79a9562..804c81ebe 100644 --- a/yaesu/ft100.c +++ b/yaesu/ft100.c @@ -325,11 +325,9 @@ int ft100_init(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __func__); - priv = (struct ft100_priv_data*)malloc(sizeof(struct ft100_priv_data)); + priv = (struct ft100_priv_data *) calloc(1, sizeof(struct ft100_priv_data)); if (!priv) return -RIG_ENOMEM; - memset(priv, 0, sizeof(struct ft100_priv_data)); - rig->state.priv = (void*)priv; return RIG_OK; diff --git a/yaesu/ft1000mp.c b/yaesu/ft1000mp.c index e8b575850..5ad324904 100644 --- a/yaesu/ft1000mp.c +++ b/yaesu/ft1000mp.c @@ -589,7 +589,7 @@ int ft1000mp_init(RIG *rig) { rig_debug(RIG_DEBUG_TRACE,"ft1000mp: ft1000mp_init called \n"); - p = (struct ft1000mp_priv_data*)malloc(sizeof(struct ft1000mp_priv_data)); + p = (struct ft1000mp_priv_data *) calloc(1, sizeof(struct ft1000mp_priv_data)); if (!p) /* whoops! memory shortage! */ return -RIG_ENOMEM; diff --git a/yaesu/ft736.c b/yaesu/ft736.c index 21a0bb8da..088d75ffe 100644 --- a/yaesu/ft736.c +++ b/yaesu/ft736.c @@ -220,7 +220,7 @@ int ft736_open(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s called\n",__FUNCTION__); - priv = (struct ft736_priv_data*)malloc(sizeof(struct ft736_priv_data)); + priv = (struct ft736_priv_data *) calloc(1, sizeof(struct ft736_priv_data)); if (!priv) return -RIG_ENOMEM; diff --git a/yaesu/ft747.c b/yaesu/ft747.c index c9c5c146a..ba0994782 100644 --- a/yaesu/ft747.c +++ b/yaesu/ft747.c @@ -299,14 +299,12 @@ const struct rig_caps ft747_caps = { int ft747_init(RIG *rig) { struct ft747_priv_data *p; - p = (struct ft747_priv_data*)malloc(sizeof(struct ft747_priv_data)); + p = (struct ft747_priv_data* ) calloc(1, sizeof(struct ft747_priv_data)); if (!p) /* whoops! memory shortage! */ return -RIG_ENOMEM; rig_debug(RIG_DEBUG_VERBOSE,"ft747:ft747_init called \n"); - memset(p, 0, sizeof(struct ft747_priv_data)); - rig->state.priv = (void*)p; return RIG_OK; diff --git a/yaesu/ft757gx.c b/yaesu/ft757gx.c index e2c414f79..e2c9dbb5c 100644 --- a/yaesu/ft757gx.c +++ b/yaesu/ft757gx.c @@ -316,7 +316,7 @@ int ft757_init(RIG *rig) if (!rig) return -RIG_EINVAL; - p = (struct ft757_priv_data *)malloc(sizeof(struct ft757_priv_data)); + p = (struct ft757_priv_data * ) calloc(1, sizeof(struct ft757_priv_data)); if (!p) /* whoops! memory shortage! */ return -RIG_ENOMEM; diff --git a/yaesu/ft767gx.c b/yaesu/ft767gx.c index 185432bde..e23c176cd 100644 --- a/yaesu/ft767gx.c +++ b/yaesu/ft767gx.c @@ -377,7 +377,7 @@ int ft767_init(RIG *rig) { if (!rig) return -RIG_EINVAL; - p = (struct ft767_priv_data*)malloc(sizeof(struct ft767_priv_data)); + p = (struct ft767_priv_data *) calloc(1, sizeof(struct ft767_priv_data)); if (!p) /* whoops! memory shortage! */ return -RIG_ENOMEM; diff --git a/yaesu/ft840.c b/yaesu/ft840.c index e800bdd13..4334fbf22 100644 --- a/yaesu/ft840.c +++ b/yaesu/ft840.c @@ -346,7 +346,7 @@ static int ft840_init(RIG *rig) { if (!rig) return -RIG_EINVAL; - priv = (struct ft840_priv_data *)malloc(sizeof(struct ft840_priv_data)); + priv = (struct ft840_priv_data *) calloc(1, sizeof(struct ft840_priv_data)); if (!priv) /* whoops! memory shortage! */ return -RIG_ENOMEM; diff --git a/yaesu/ft847.c b/yaesu/ft847.c index f3f52a40b..9063fd5fe 100644 --- a/yaesu/ft847.c +++ b/yaesu/ft847.c @@ -367,7 +367,7 @@ int ft847_init(RIG *rig) { if (!rig) return -RIG_EINVAL; - p = (struct ft847_priv_data*)malloc(sizeof(struct ft847_priv_data)); + p = (struct ft847_priv_data *) calloc(1, sizeof(struct ft847_priv_data)); if (!p) { /* whoops! memory shortage! */ return -RIG_ENOMEM; diff --git a/yaesu/ft890.c b/yaesu/ft890.c index d531ad5d9..439463117 100644 --- a/yaesu/ft890.c +++ b/yaesu/ft890.c @@ -284,7 +284,7 @@ static int ft890_init(RIG *rig) { if (!rig) return -RIG_EINVAL; - priv = (struct ft890_priv_data *)malloc(sizeof(struct ft890_priv_data)); + priv = (struct ft890_priv_data *) calloc(1, sizeof(struct ft890_priv_data)); if (!priv) /* whoops! memory shortage! */ return -RIG_ENOMEM; diff --git a/yaesu/ft900.c b/yaesu/ft900.c index f212359c3..2ce3132ad 100644 --- a/yaesu/ft900.c +++ b/yaesu/ft900.c @@ -284,7 +284,7 @@ static int ft900_init(RIG *rig) { if (!rig) return -RIG_EINVAL; - priv = (struct ft900_priv_data *)malloc(sizeof(struct ft900_priv_data)); + priv = (struct ft900_priv_data *) calloc(1, sizeof(struct ft900_priv_data)); if (!priv) /* whoops! memory shortage! */ return -RIG_ENOMEM; diff --git a/yaesu/ft920.c b/yaesu/ft920.c index 9020b5949..41d81510d 100644 --- a/yaesu/ft920.c +++ b/yaesu/ft920.c @@ -363,7 +363,7 @@ static int ft920_init(RIG *rig) { if (!rig) return -RIG_EINVAL; - priv = (struct ft920_priv_data *)malloc(sizeof(struct ft920_priv_data)); + priv = (struct ft920_priv_data *) calloc(1, sizeof(struct ft920_priv_data)); if (!priv) return -RIG_ENOMEM; /* whoops! memory shortage! */ diff --git a/yaesu/ft980.c b/yaesu/ft980.c index f99550951..7e28dabf3 100644 --- a/yaesu/ft980.c +++ b/yaesu/ft980.c @@ -614,7 +614,7 @@ int ft980_open(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s called\n",__FUNCTION__); - rig->state.priv = malloc(sizeof (struct ft980_priv_data)); + rig->state.priv = calloc(1, sizeof (struct ft980_priv_data)); if (!rig->state.priv) return -RIG_ENOMEM; diff --git a/yaesu/ft990.c b/yaesu/ft990.c index 41d54765a..bd5d7a542 100644 --- a/yaesu/ft990.c +++ b/yaesu/ft990.c @@ -287,7 +287,7 @@ int ft990_init(RIG *rig) { if (!rig) return -RIG_EINVAL; - priv = (struct ft990_priv_data *)malloc(sizeof(struct ft990_priv_data)); + priv = (struct ft990_priv_data *) calloc(1, sizeof(struct ft990_priv_data)); if (!priv) return -RIG_ENOMEM; diff --git a/yaesu/ft991.c b/yaesu/ft991.c new file mode 100644 index 000000000..23ad143bb --- /dev/null +++ b/yaesu/ft991.c @@ -0,0 +1,243 @@ +/* + * hamlib - (C) Frank Singleton 2000 (javabear at users.sourceforge.net) + * + * ft991.c - (C) Nate Bargmann 2007 (n0nb at arrl.net) + * (C) Stephane Fillod 2008 + * (C) Terry Embry 2008-2009 + * (C) Michael Black W9MDB 2015 -- taken from ft950.c + * + * The FT991 is very much like the FT950 except freq max increases for 440MHz + * So most of this code is a duplicate of the FT950 + * + * This shared library provides an API for communicating + * via serial interface to an FT-991 using the "CAT" interface + * + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 "ft991.h" +#include "idx_builtin.h" + +/* + * ft991 rigs capabilities. + * Also this struct is READONLY! + * + */ + +const struct rig_caps ft991_caps = { + .rig_model = RIG_MODEL_FT991, + .model_name = "FT-991", + .mfg_name = "Yaesu", + .version = NEWCAT_VER ".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_HARDWARE, + .write_delay = FT991_WRITE_DELAY, + .post_write_delay = FT991_POST_WRITE_DELAY, + .timeout = 2000, + .retry = 3, + .has_get_func = FT991_FUNCS, + .has_set_func = FT991_FUNCS, + .has_get_level = FT991_LEVELS, + .has_set_level = RIG_LEVEL_SET(FT991_LEVELS), + .has_get_parm = RIG_PARM_NONE, + .has_set_parm = RIG_PARM_NONE, + .level_gran = { + [LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } }, + [LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 1050 }, .step = { .i = 50 } }, + }, + .ctcss_list = common_ctcss_list, + .dcs_list = NULL, + .preamp = { 10, 20, RIG_DBLST_END, }, /* TBC */ + .attenuator = { 6, 12, 18, RIG_DBLST_END, }, + .max_rit = Hz(9999), + .max_xit = Hz(9999), + .max_ifshift = Hz(1000), + .vfo_ops = FT991_VFO_OPS, + .targetable_vfo = RIG_TARGETABLE_FREQ, + .transceive = RIG_TRN_OFF, /* May enable later as the 950 has an Auto Info command */ + .bank_qty = 0, + .chan_desc_sz = 0, + .str_cal = FT991_STR_CAL, + .chan_list = { + { 1, 99, RIG_MTYPE_MEM, NEWCAT_MEM_CAP }, + { 100, 117, RIG_MTYPE_EDGE, NEWCAT_MEM_CAP }, /* two by two */ + RIG_CHAN_END, + }, + + .rx_range_list1 = { + {kHz(30), MHz(470), FT991_ALL_RX_MODES, -1, -1, FT991_VFO_ALL, FT991_ANTS}, /* General coverage + ham */ + RIG_FRNG_END, + }, /* FIXME: Are these the correct Region 1 values? */ + + .tx_range_list1 = { + FRQ_RNG_HF(1, FT991_OTHER_TX_MODES, W(5), W(100), FT991_VFO_ALL, FT991_ANTS), + FRQ_RNG_HF(1, FT991_AM_TX_MODES, W(2), W(25), FT991_VFO_ALL, FT991_ANTS), /* AM class */ + FRQ_RNG_6m(1, FT991_OTHER_TX_MODES, W(5), W(100), FT991_VFO_ALL, FT991_ANTS), + FRQ_RNG_6m(1, FT991_AM_TX_MODES, W(2), W(25), FT991_VFO_ALL, FT991_ANTS), /* AM class */ + + RIG_FRNG_END, + }, + + .rx_range_list2 = { + {kHz(30), MHz(470), FT991_ALL_RX_MODES, -1, -1, FT991_VFO_ALL, FT991_ANTS}, + RIG_FRNG_END, + }, + + .tx_range_list2 = { + FRQ_RNG_HF(2, FT991_OTHER_TX_MODES, W(5), W(100), FT991_VFO_ALL, FT991_ANTS), + FRQ_RNG_HF(2, FT991_AM_TX_MODES, W(2), W(25), FT991_VFO_ALL, FT991_ANTS), /* AM class */ + FRQ_RNG_6m(2, FT991_OTHER_TX_MODES, W(5), W(100), FT991_VFO_ALL, FT991_ANTS), + FRQ_RNG_6m(2, FT991_AM_TX_MODES, W(2), W(25), FT991_VFO_ALL, FT991_ANTS), /* AM class */ + + RIG_FRNG_END, + }, + + .tuning_steps = { + {FT991_SSB_CW_RX_MODES, Hz(10)}, /* Normal */ + {FT991_SSB_CW_RX_MODES, Hz(100)}, /* Fast */ + + {FT991_AM_RX_MODES, Hz(100)}, /* Normal */ + {FT991_AM_RX_MODES, kHz(1)}, /* Fast */ + + {FT991_FM_RX_MODES, Hz(100)}, /* Normal */ + {FT991_FM_RX_MODES, kHz(1)}, /* Fast */ + + RIG_TS_END, + + }, + + /* mode/filter list, .remember = order matters! */ + .filters = { + {FT991_CW_RTTY_PKT_RX_MODES, Hz(1700)}, /* Normal CW, RTTY, PKT */ + {FT991_CW_RTTY_PKT_RX_MODES, Hz(500)}, /* Narrow CW, RTTY, PKT */ + {FT991_CW_RTTY_PKT_RX_MODES, Hz(2400)}, /* Wide CW, RTTY, PKT */ + {FT991_CW_RTTY_PKT_RX_MODES, Hz(2000)}, /* CW, RTTY, PKT */ + {FT991_CW_RTTY_PKT_RX_MODES, Hz(1400)}, /* CW, RTTY, PKT */ + {FT991_CW_RTTY_PKT_RX_MODES, Hz(1200)}, /* CW, RTTY, PKT */ + {FT991_CW_RTTY_PKT_RX_MODES, Hz(800)}, /* CW, RTTY, PKT */ + {FT991_CW_RTTY_PKT_RX_MODES, Hz(400)}, /* CW, RTTY, PKT */ + {FT991_CW_RTTY_PKT_RX_MODES, Hz(300)}, /* CW, RTTY, PKT */ + {FT991_CW_RTTY_PKT_RX_MODES, Hz(200)}, /* CW, RTTY, PKT */ + {FT991_CW_RTTY_PKT_RX_MODES, Hz(100)}, /* CW, RTTY, PKT */ + {RIG_MODE_SSB, Hz(2400)}, /* Normal SSB */ + {RIG_MODE_SSB, Hz(1800)}, /* Narrow SSB */ + {RIG_MODE_SSB, Hz(3000)}, /* Wide SSB */ + {RIG_MODE_SSB, Hz(2900)}, /* SSB */ + {RIG_MODE_SSB, Hz(2800)}, /* SSB */ + {RIG_MODE_SSB, Hz(2700)}, /* SSB */ + {RIG_MODE_SSB, Hz(2600)}, /* SSB */ + {RIG_MODE_SSB, Hz(2500)}, /* SSB */ + {RIG_MODE_SSB, Hz(2250)}, /* SSB */ + {RIG_MODE_SSB, Hz(2100)}, /* SSB */ + {RIG_MODE_SSB, Hz(1950)}, /* SSB */ + {RIG_MODE_SSB, Hz(1650)}, /* SSB */ + {RIG_MODE_SSB, Hz(1500)}, /* SSB */ + {RIG_MODE_SSB, Hz(1350)}, /* SSB */ + {RIG_MODE_SSB, Hz(1100)}, /* SSB */ + {RIG_MODE_SSB, Hz(850)}, /* SSB */ + {RIG_MODE_SSB, Hz(600)}, /* SSB */ + {RIG_MODE_SSB, Hz(400)}, /* SSB */ + {RIG_MODE_SSB, Hz(200)}, /* SSB */ + {RIG_MODE_AM, Hz(9000)}, /* Normal AM */ + {RIG_MODE_AM, Hz(6000)}, /* Narrow AM */ + {FT991_FM_RX_MODES, Hz(16000)}, /* Normal FM */ + {FT991_FM_RX_MODES, Hz(9000)}, /* Narrow FM */ + + RIG_FLT_END, + }, + + .priv = NULL, /* private data FIXME: */ + + .rig_init = ft991_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_xit = newcat_set_xit, + .get_xit = newcat_get_xit, + .set_ant = newcat_set_ant, + .get_ant = newcat_get_ant, + .get_func = newcat_get_func, + .set_func = newcat_set_func, + .get_level = newcat_get_level, + .set_level = newcat_set_level, + .get_mem = newcat_get_mem, + .set_mem = newcat_set_mem, + .vfo_op = newcat_vfo_op, + .get_info = newcat_get_info, + .power2mW = newcat_power2mW, + .mW2power = newcat_mW2power, + .set_rptr_shift = newcat_set_rptr_shift, + .get_rptr_shift = newcat_get_rptr_shift, + .set_ctcss_tone = newcat_set_ctcss_tone, + .get_ctcss_tone = newcat_get_ctcss_tone, + .set_ctcss_sql = newcat_set_ctcss_sql, + .get_ctcss_sql = newcat_get_ctcss_sql, + .set_powerstat = newcat_set_powerstat, + .get_powerstat = newcat_get_powerstat, + .set_ts = newcat_set_ts, + .get_ts = newcat_get_ts, + .set_trn = newcat_set_trn, + .get_trn = newcat_get_trn, + .set_channel = newcat_set_channel, + .get_channel = newcat_get_channel, + +}; + +int ft991_init(RIG *rig) { + struct newcat_priv_data *priv; + rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __func__); + int ret = newcat_init(rig); + if (ret != RIG_OK) return ret; + priv = (struct newcat_priv_data *)rig->state.priv; + priv->width_frequency = 9; + priv->offset_rit = 13; + return RIG_OK; +} diff --git a/yaesu/ft991.h b/yaesu/ft991.h new file mode 100644 index 000000000..d5b86dcb0 --- /dev/null +++ b/yaesu/ft991.h @@ -0,0 +1,126 @@ +/* + * hamlib - (C) Frank Singleton 2000 (javabear at users.sourceforge.net) + * + * ft991.h - (C) Nate Bargmann 2007 (n0nb at arrl.net) + * (C) Stephane Fillod 2008 + * + * This shared library provides an API for communicating + * via serial interface to an FT-950 using the "CAT" interface + * + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +#ifndef _FT991_H +#define _FT991_H 1 + +#define TRUE 1 +#define FALSE 0 +#define ON TRUE +#define OFF FALSE + +#define FT991_VFO_ALL (RIG_VFO_A|RIG_VFO_B) + +/* Receiver caps */ + +#define FT991_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|\ + RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTFM) +#define FT991_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|\ + RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB) +#define FT991_AM_RX_MODES (RIG_MODE_AM) +#define FT991_FM_RX_MODES (RIG_MODE_FM|RIG_MODE_PKTFM) +#define FT991_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR) +#define FT991_CW_RTTY_PKT_RX_MODES (RIG_MODE_RTTY|RIG_MODE_RTTYR|\ + RIG_MODE_PKTUSB|RIG_MODE_PKTLSB|RIG_MODE_CW|RIG_MODE_CWR) + +/* TRX caps */ + +#define FT991_OTHER_TX_MODES (RIG_MODE_CW| RIG_MODE_USB| RIG_MODE_LSB ) /* 100 W class */ +#define FT991_AM_TX_MODES (RIG_MODE_AM) /* set 25W max */ + +#define FT991_LEVELS (RIG_LEVEL_ATT|RIG_LEVEL_PREAMP|\ + RIG_LEVEL_ALC|RIG_LEVEL_RAWSTR|RIG_LEVEL_SWR|\ + RIG_LEVEL_RFPOWER|RIG_LEVEL_RF|RIG_LEVEL_SQL|\ + RIG_LEVEL_MICGAIN|RIG_LEVEL_IF|RIG_LEVEL_CWPITCH|\ + RIG_LEVEL_KEYSPD|RIG_LEVEL_AF|RIG_LEVEL_AGC|\ + RIG_LEVEL_METER|RIG_LEVEL_BKINDL|RIG_LEVEL_SQL|\ + RIG_LEVEL_VOXGAIN|RIG_LEVEL_VOXDELAY|RIG_LEVEL_COMP|\ + RIG_LEVEL_ANTIVOX|RIG_LEVEL_NR|RIG_LEVEL_NOTCHF) + +#define FT991_FUNCS (RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_LOCK|\ + RIG_FUNC_MON|RIG_FUNC_NB|RIG_FUNC_NR|RIG_FUNC_VOX|\ + RIG_FUNC_FBKIN|RIG_FUNC_COMP|RIG_FUNC_ANF|RIG_FUNC_MN) + +#define FT991_VFO_OPS (RIG_OP_TUNE|RIG_OP_CPY|RIG_OP_XCHG|\ + RIG_OP_UP|RIG_OP_DOWN|RIG_OP_BAND_UP|RIG_OP_BAND_DOWN|\ + RIG_OP_TO_VFO|RIG_OP_FROM_VFO|RIG_OP_TOGGLE) + +/* TBC */ +#define FT991_STR_CAL { 16, \ + { \ + { 0, -54 }, /* S0 */ \ + { 12, -48 }, /* S1 */ \ + { 27, -42 }, /* S2 */ \ + { 40, -36 }, /* S3 */ \ + { 55, -30 }, /* S4 */ \ + { 65, -24 }, /* S5 */ \ + { 80, -18 }, /* S6 */ \ + { 95, -12 }, /* S7 */ \ + { 112, -6 }, /* S8 */ \ + { 130, 0 }, /* S9 */ \ + { 150, 10 }, /* +10 */ \ + { 172, 20 }, /* +20 */ \ + { 190, 30 }, /* +30 */ \ + { 220, 40 }, /* +40 */ \ + { 240, 50 }, /* +50 */ \ + { 255, 60 }, /* +60 */ \ + } } + + +/* + * Other features (used by rig_caps) + * + */ + +#define FT991_ANTS (RIG_ANT_1|RIG_ANT_2) + +#define FT991_MEM_CHNL_LENGTH 1 /* 0x10 P1 = 01 return size */ +#define FT991_OP_DATA_LENGTH 19 /* 0x10 P1 = 03 return size */ +#define FT991_VFO_DATA_LENGTH 18 /* 0x10 P1 = 03 return size -- A & B returned */ +#define FT991_MEM_CHNL_DATA_LENGTH 19 /* 0x10 P1 = 04, P4 = 0x01-0x20 return size */ +#define FT991_STATUS_FLAGS_LENGTH 5 /* 0xf7, 0xfa return size */ +#define FT991_ALL_DATA_LENGTH 649 /* 0x10 P1 = 00 return size */ + +/* Timing values in mS */ + +// #define FT991_PACING_INTERVAL 5 +// #define FT991_PACING_DEFAULT_VALUE 0 + +/* Delay between bytes sent to FT-991 + * Should not exceed value set in CAT TOT menu (rig default is 10 mSec) + */ +#define FT991_WRITE_DELAY 0 + + +/* Delay sequential fast writes */ + +#define FT991_POST_WRITE_DELAY 5 + +/* Prototypes */ +int ft991_init(RIG *rig); + +#endif /* _FT991_H */ diff --git a/yaesu/newcat.c b/yaesu/newcat.c index 7edcb748e..915763a27 100644 --- a/yaesu/newcat.c +++ b/yaesu/newcat.c @@ -209,22 +209,6 @@ static const yaesu_newcat_commands_t valid_commands[] = { }; int valid_commands_count = sizeof(valid_commands) / sizeof(yaesu_newcat_commands_t); -/* - * future - private data - * - * FIXME: Does this need to be exposed to the application/frontend through - * rig_caps.priv? I'm guessing not since it's private to the backend. -N0NB - */ - -struct newcat_priv_data { - unsigned int read_update_delay; /* depends on pacing value */ -// vfo_t current_vfo; /* active VFO from last cmd */ - char cmd_str[NEWCAT_DATA_LEN]; /* command string buffer */ - char ret_data[NEWCAT_DATA_LEN]; /* returned data--max value, most are less */ - int current_mem; /* private memory channel number */ - int rig_id; /* rig id from CAT Command ID; */ -}; - /* NewCAT Internal Functions */ static ncboolean newcat_is_rig(RIG * rig, rig_model_t model); static int newcat_get_tx_vfo(RIG * rig, vfo_t * tx_vfo); @@ -266,7 +250,7 @@ int newcat_init(RIG *rig) { if (!rig) return -RIG_EINVAL; - priv = (struct newcat_priv_data *)malloc(sizeof(struct newcat_priv_data)); + priv = (struct newcat_priv_data *) calloc(1, sizeof(struct newcat_priv_data)); if (!priv) /* whoops! memory shortage! */ return -RIG_ENOMEM; @@ -441,7 +425,10 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { // CAT command string for setting frequency requires that 8 digits be sent // including leading fill zeros - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "F%c%08d%c", c, (int)freq, cat_term); + int width_frequency = priv->width_frequency; + if (width_frequency == 0) width_frequency = 8; // default to 8 + + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "F%c%0*d%c", c, width_frequency, (int)freq, cat_term); rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, priv->cmd_str); if (RIG_OK != (err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str)))) { @@ -741,6 +728,16 @@ int newcat_set_vfo(RIG *rig, vfo_t vfo) { rig_debug(RIG_DEBUG_TRACE, "%s: called, passed vfo = 0x%02x\n", __func__, vfo); + if (newcat_is_rig(rig, RIG_MODEL_FT991)) + { + if (vfo==RIG_VFO_A) { /* FT991 does not have VS -- pretend we do for VFO_A */ + return RIG_OK; + } + else { + return -RIG_EINVAL; + } + } + if (!newcat_valid_command(rig, command)) return -RIG_ENAVAIL; @@ -1204,7 +1201,10 @@ int newcat_get_rit(RIG * rig, vfo_t vfo, shortfreq_t * rit) rig_debug(RIG_DEBUG_TRACE, "%s: RIT value = %c\n", __func__, err, priv->ret_data[18]); - retval = priv->ret_data + 13; + int offset_rit = priv->offset_rit; + if (offset_rit == 0) offset_rit = 13; // default to 13 + + retval = priv->ret_data + offset_rit; rit_on = retval[5]; retval[5] = '\0'; @@ -3690,6 +3690,73 @@ int newcat_set_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return -RIG_EINVAL; } /* end switch(mode) */ } /* end if FT950 */ + else if (newcat_is_rig(rig, RIG_MODEL_FT991)) { + switch (mode) { + case RIG_MODE_PKTUSB: + case RIG_MODE_PKTLSB: + case RIG_MODE_RTTY: + case RIG_MODE_RTTYR: + case RIG_MODE_CW: + case RIG_MODE_CWR: + switch (width) { // the defaults can be different for CW and RTTY (e.g. FT991) but I don't think it matters here + case 1700: snprintf(width_str, sizeof(width_str), "14"); narrow = '0'; break; /* normal */ + case 500: snprintf(width_str, sizeof(width_str), "10"); narrow = '0'; break; /* narrow */ + case 3000: snprintf(width_str, sizeof(width_str), "17"); narrow = '0'; break; /* wide */ + case 2400: snprintf(width_str, sizeof(width_str), "16"); narrow = '0'; break; + case 2000: snprintf(width_str, sizeof(width_str), "15"); narrow = '0'; break; + case 1400: snprintf(width_str, sizeof(width_str), "13"); narrow = '0'; break; + case 1200: snprintf(width_str, sizeof(width_str), "12"); narrow = '0'; break; + case 800: snprintf(width_str, sizeof(width_str), "11"); narrow = '0'; break; + case 450: snprintf(width_str, sizeof(width_str), "09"); narrow = '1'; break; + case 400: snprintf(width_str, sizeof(width_str), "08"); narrow = '1'; break; + case 350: snprintf(width_str, sizeof(width_str), "07"); narrow = '1'; break; + case 300: snprintf(width_str, sizeof(width_str), "06"); narrow = '1'; break; + case 250: snprintf(width_str, sizeof(width_str), "05"); narrow = '1'; break; + case 200: snprintf(width_str, sizeof(width_str), "04"); narrow = '1'; break; + case 150: snprintf(width_str, sizeof(width_str), "03"); narrow = '1'; break; + case 100: snprintf(width_str, sizeof(width_str), "02"); narrow = '1'; break; + case 50: snprintf(width_str, sizeof(width_str), "01"); narrow = '1'; break; + default: return -RIG_EINVAL; + } + break; + case RIG_MODE_LSB: + case RIG_MODE_USB: + switch (width) { + case 2400: snprintf(width_str, sizeof(width_str), "14"); narrow = '0'; break; /* normal */ + case 1500: snprintf(width_str, sizeof(width_str), "07"); narrow = '0'; break; /* narrow */ + case 3200: snprintf(width_str, sizeof(width_str), "21"); narrow = '0'; break; /* wide */ + case 3000: snprintf(width_str, sizeof(width_str), "20"); narrow = '0'; break; + case 2900: snprintf(width_str, sizeof(width_str), "19"); narrow = '0'; break; + case 2800: snprintf(width_str, sizeof(width_str), "18"); narrow = '0'; break; + case 2700: snprintf(width_str, sizeof(width_str), "17"); narrow = '0'; break; + case 2600: snprintf(width_str, sizeof(width_str), "16"); narrow = '0'; break; + case 2500: snprintf(width_str, sizeof(width_str), "15"); narrow = '0'; break; + case 2250: snprintf(width_str, sizeof(width_str), "12"); narrow = '0'; break; + case 2100: snprintf(width_str, sizeof(width_str), "11"); narrow = '0'; break; + case 1950: snprintf(width_str, sizeof(width_str), "10"); narrow = '0'; break; + case 1800: snprintf(width_str, sizeof(width_str), "09"); narrow = '0'; break; + case 1650: snprintf(width_str, sizeof(width_str), "08"); narrow = '1'; break; + case 1350: snprintf(width_str, sizeof(width_str), "06"); narrow = '1'; break; + case 1100: snprintf(width_str, sizeof(width_str), "05"); narrow = '1'; break; + case 850: snprintf(width_str, sizeof(width_str), "04"); narrow = '1'; break; + case 600: snprintf(width_str, sizeof(width_str), "03"); narrow = '1'; break; + case 400: snprintf(width_str, sizeof(width_str), "02"); narrow = '1'; break; + case 200: snprintf(width_str, sizeof(width_str), "01"); narrow = '1'; break; + default: return -RIG_EINVAL; + } + break; + case RIG_MODE_AM: + //case RIG_MODE_FM: // Can you set passband on FM or FMN for FT991? Returns error for now. + case RIG_MODE_PKTFM: + if (width < rig_passband_normal(rig, mode)) + err = newcat_set_narrow(rig, vfo, TRUE); + else + err = newcat_set_narrow(rig, vfo, FALSE); + return err; + default: + return -RIG_EINVAL; + } /* end switch(mode) */ + } /* end if FT991 */ else if (newcat_is_rig(rig, RIG_MODEL_FT1200)) { switch (mode) { case RIG_MODE_PKTUSB: diff --git a/yaesu/newcat.h b/yaesu/newcat.h index 6208c6a58..521e429a9 100644 --- a/yaesu/newcat.h +++ b/yaesu/newcat.h @@ -68,6 +68,25 @@ typedef char ncboolean; .ctcss_sql = 1,\ } +/* + * future - private data + * + * FIXME: Does this need to be exposed to the application/frontend through + * rig_caps.priv? I'm guessing not since it's private to the backend. -N0NB + */ + +struct newcat_priv_data { + unsigned int read_update_delay; /* depends on pacing value */ +// vfo_t current_vfo; /* active VFO from last cmd */ + char cmd_str[NEWCAT_DATA_LEN]; /* command string buffer */ + char ret_data[NEWCAT_DATA_LEN]; /* returned data--max value, most are less */ + int current_mem; /* private memory channel number */ + int rig_id; /* rig id from CAT Command ID; */ + int width_frequency; /* width of FA/FB freq response */ + int offset_rit; /* offset of rit in response */ +}; + + /* * Functions considered to be Stable: * diff --git a/yaesu/vr5000.c b/yaesu/vr5000.c index c15fae3ce..ea7fe53b0 100644 --- a/yaesu/vr5000.c +++ b/yaesu/vr5000.c @@ -242,7 +242,7 @@ int vr5000_init(RIG *rig) { struct vr5000_priv_data *priv; - priv = (struct vr5000_priv_data*)malloc(sizeof(struct vr5000_priv_data)); + priv = (struct vr5000_priv_data *) calloc(1, sizeof(struct vr5000_priv_data)); if (!priv) return -RIG_ENOMEM; rig->state.priv = (void*)priv; diff --git a/yaesu/vx1700.c b/yaesu/vx1700.c index 48527be93..33a6e1ea4 100644 --- a/yaesu/vx1700.c +++ b/yaesu/vx1700.c @@ -487,10 +487,10 @@ static int vx1700_init(RIG *rig){ struct vx1700_priv_data *priv; rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__); - priv = malloc(sizeof(struct vx1700_priv_data)); + + priv = calloc(1, sizeof(struct vx1700_priv_data)); if (priv == NULL) return -RIG_ENOMEM; - memset(priv, 0, sizeof(struct vx1700_priv_data)); priv->ch = 1; rig->state.priv = (rig_ptr_t)priv; return RIG_OK; diff --git a/yaesu/yaesu.c b/yaesu/yaesu.c index 2b09aea9c..6b5dcfb1d 100644 --- a/yaesu/yaesu.c +++ b/yaesu/yaesu.c @@ -104,6 +104,7 @@ DECLARE_INITRIG_BACKEND(yaesu) rig_register(&vr5000_caps); rig_register(&vx1700_caps); rig_register(&ft1200_caps); + rig_register(&ft991_caps); return RIG_OK; } diff --git a/yaesu/yaesu.h b/yaesu/yaesu.h index 4b8f1c993..cc84e5dc1 100644 --- a/yaesu/yaesu.h +++ b/yaesu/yaesu.h @@ -62,6 +62,7 @@ extern const struct rig_caps ft920_caps; extern const struct rig_caps ft950_caps; extern const struct rig_caps ft980_caps; extern const struct rig_caps ft990_caps; +extern const struct rig_caps ft991_caps; extern const struct rig_caps ft1000mp_caps; extern const struct rig_caps ft1000mpmkv_caps; extern const struct rig_caps ft1000mpmkvfld_caps;