From f71712b23b6daeaea97c0e1995c7fee4d1084410 Mon Sep 17 00:00:00 2001 From: Mikael Nousiainen Date: Sat, 20 Nov 2021 21:28:26 +0200 Subject: [PATCH] Add contour, audio peak filter and keyer functions/levels for many Yaesu rigs --- extra/kylix/hamlib_rigapi.pas | 2 +- include/hamlib/rig.h | 2 +- rigs/yaesu/ft1200.c | 65 +++- rigs/yaesu/ft2000.c | 47 ++- rigs/yaesu/ft2000.h | 2 +- rigs/yaesu/ft3000.c | 65 +++- rigs/yaesu/ft5000.c | 56 ++- rigs/yaesu/ft5000.h | 2 +- rigs/yaesu/ft891.c | 78 +++++ rigs/yaesu/ft891.h | 2 +- rigs/yaesu/ft991.c | 78 +++++ rigs/yaesu/ft991.h | 2 +- rigs/yaesu/ftdx10.c | 65 +++- rigs/yaesu/ftdx10.h | 2 +- rigs/yaesu/ftdx101.c | 65 +++- rigs/yaesu/ftdx101.h | 2 +- rigs/yaesu/newcat.c | 618 ++++++++++++++++++++++++++++++++++ rigs/yaesu/newcat.h | 7 + 18 files changed, 1146 insertions(+), 14 deletions(-) diff --git a/extra/kylix/hamlib_rigapi.pas b/extra/kylix/hamlib_rigapi.pas index 2007de8e8..2437c2add 100644 --- a/extra/kylix/hamlib_rigapi.pas +++ b/extra/kylix/hamlib_rigapi.pas @@ -494,7 +494,7 @@ const RIG_FUNC_ANF = (1 shl 8); {* Automatic Notch Filter (DSP); *} RIG_FUNC_NR = (1 shl 9); {* Noise Reduction (DSP); *} RIG_FUNC_AIP = (1 shl 10); {* AIP (Kenwood); *} - RIG_FUNC_APF = (1 shl 11); {* Auto Passband Filter *} + RIG_FUNC_APF = (1 shl 11); {* Audio Peak Filter *} RIG_FUNC_MON = (1 shl 12); {* Monitor transmitted signal, != rev *} RIG_FUNC_MN = (1 shl 13); {* Manual Notch (Icom); *} RIG_FUNC_RF = (1 shl 14); {* RTTY Filter (Icom); TNX AD7AI -- N0NB *} diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index f58dfa387..9c8318ad5 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -1088,7 +1088,7 @@ typedef uint64_t setting_t; #define RIG_FUNC_ANF CONSTANT_64BIT_FLAG (8) /*!< \c ANF -- Automatic Notch Filter (DSP) */ #define RIG_FUNC_NR CONSTANT_64BIT_FLAG (9) /*!< \c NR -- Noise Reduction (DSP) */ #define RIG_FUNC_AIP CONSTANT_64BIT_FLAG (10) /*!< \c AIP -- RF pre-amp (AIP on Kenwood, IPO on Yaesu, etc.) */ -#define RIG_FUNC_APF CONSTANT_64BIT_FLAG (11) /*!< \c APF -- Auto Passband/Audio Peak Filter */ +#define RIG_FUNC_APF CONSTANT_64BIT_FLAG (11) /*!< \c APF -- Audio Peak Filter */ #define RIG_FUNC_MON CONSTANT_64BIT_FLAG (12) /*!< \c MON -- Monitor transmitted signal */ #define RIG_FUNC_MN CONSTANT_64BIT_FLAG (13) /*!< \c MN -- Manual Notch */ #define RIG_FUNC_RF CONSTANT_64BIT_FLAG (14) /*!< \c RF -- RTTY Filter */ diff --git a/rigs/yaesu/ft1200.c b/rigs/yaesu/ft1200.c index 69b72d765..06e43e361 100644 --- a/rigs/yaesu/ft1200.c +++ b/rigs/yaesu/ft1200.c @@ -73,12 +73,75 @@ const struct confparams ftdx1200_ext_levels[] = } } }, + { + TOK_KEYER, + "KEYER", + "Keyer", + "Keyer on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_APF_FREQ, + "APF_FREQ", + "APF frequency", + "Audio peak filter frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -250, .max = 250, .step = 10 } }, + }, + { + TOK_APF_WIDTH, + "APF_WIDTH", + "APF width", + "Audio peak filter width", + NULL, + RIG_CONF_COMBO, + { .c = { .combostr = { "Narrow", "Medium", "Wide", NULL } } }, + }, + { + TOK_CONTOUR, + "CONTOUR", + "Contour", + "Contour on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_CONTOUR_FREQ, + "CONTOUR_FREQ", + "Contour frequency", + "Contour frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 100, .max = 4000, .step = 100 } }, + }, + { + TOK_CONTOUR_LEVEL, + "CONTOUR_LEVEL", + "Contour level", + "Contour level (dB)", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -40, .max = 20, .step = 1 } }, + }, + { + TOK_CONTOUR_WIDTH, + "CONTOUR_WIDTH", + "Contour width", + "Contour width", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 1, .max = 11, .step = 1 } }, + }, { RIG_CONF_END, NULL, } }; int ftdx1200_ext_tokens[] = { - TOK_ROOFING_FILTER, TOK_BACKEND_NONE + TOK_ROOFING_FILTER, TOK_KEYER, TOK_APF_FREQ, TOK_APF_WIDTH, + TOK_CONTOUR, TOK_CONTOUR_FREQ, TOK_CONTOUR_LEVEL, TOK_CONTOUR_WIDTH, + TOK_BACKEND_NONE }; /* diff --git a/rigs/yaesu/ft2000.c b/rigs/yaesu/ft2000.c index 07501ae3a..a438e4557 100644 --- a/rigs/yaesu/ft2000.c +++ b/rigs/yaesu/ft2000.c @@ -74,12 +74,57 @@ const struct confparams ft2000_ext_levels[] = } } }, + { + TOK_KEYER, + "KEYER", + "Keyer", + "Keyer on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_CONTOUR, + "CONTOUR", + "Contour", + "Contour on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_CONTOUR_FREQ, + "CONTOUR_FREQ", + "Contour frequency", + "Contour frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 100, .max = 4000, .step = 100 } }, + }, + { + TOK_CONTOUR_LEVEL, + "CONTOUR_LEVEL", + "Contour level", + "Contour level (dB)", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -40, .max = 20, .step = 1 } }, + }, + { + TOK_CONTOUR_WIDTH, + "CONTOUR_WIDTH", + "Contour width", + "Contour width", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 1, .max = 11, .step = 1 } }, + }, { RIG_CONF_END, NULL, } }; int ft2000_ext_tokens[] = { - TOK_ROOFING_FILTER, TOK_BACKEND_NONE + TOK_ROOFING_FILTER, TOK_KEYER, + TOK_CONTOUR, TOK_CONTOUR_FREQ, TOK_CONTOUR_LEVEL, TOK_CONTOUR_WIDTH, + TOK_BACKEND_NONE }; diff --git a/rigs/yaesu/ft2000.h b/rigs/yaesu/ft2000.h index b09da65e1..607360ae8 100644 --- a/rigs/yaesu/ft2000.h +++ b/rigs/yaesu/ft2000.h @@ -64,7 +64,7 @@ RIG_FUNC_MON|RIG_FUNC_NB|RIG_FUNC_NR|RIG_FUNC_VOX|\ RIG_FUNC_FBKIN|RIG_FUNC_COMP|RIG_FUNC_ANF|RIG_FUNC_MN|\ RIG_FUNC_RIT|RIG_FUNC_XIT|\ - RIG_FUNC_TUNER) + RIG_FUNC_TUNER|RIG_FUNC_APF) #define FT2000_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|\ diff --git a/rigs/yaesu/ft3000.c b/rigs/yaesu/ft3000.c index ab047f921..8a5e5859e 100644 --- a/rigs/yaesu/ft3000.c +++ b/rigs/yaesu/ft3000.c @@ -77,12 +77,75 @@ const struct confparams ftdx3000_ext_levels[] = } } }, + { + TOK_KEYER, + "KEYER", + "Keyer", + "Keyer on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_APF_FREQ, + "APF_FREQ", + "APF frequency", + "Audio peak filter frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -250, .max = 250, .step = 10 } }, + }, + { + TOK_APF_WIDTH, + "APF_WIDTH", + "APF width", + "Audio peak filter width", + NULL, + RIG_CONF_COMBO, + { .c = { .combostr = { "Narrow", "Medium", "Wide", NULL } } }, + }, + { + TOK_CONTOUR, + "CONTOUR", + "Contour", + "Contour on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_CONTOUR_FREQ, + "CONTOUR_FREQ", + "Contour frequency", + "Contour frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 100, .max = 4000, .step = 100 } }, + }, + { + TOK_CONTOUR_LEVEL, + "CONTOUR_LEVEL", + "Contour level", + "Contour level (dB)", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -40, .max = 20, .step = 1 } }, + }, + { + TOK_CONTOUR_WIDTH, + "CONTOUR_WIDTH", + "Contour width", + "Contour width", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 1, .max = 11, .step = 1 } }, + }, { RIG_CONF_END, NULL, } }; int ftdx3000_ext_tokens[] = { - TOK_ROOFING_FILTER, TOK_BACKEND_NONE + TOK_ROOFING_FILTER, TOK_KEYER, TOK_APF_FREQ, TOK_APF_WIDTH, + TOK_CONTOUR, TOK_CONTOUR_FREQ, TOK_CONTOUR_LEVEL, TOK_CONTOUR_WIDTH, + TOK_BACKEND_NONE }; int ft3000_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) diff --git a/rigs/yaesu/ft5000.c b/rigs/yaesu/ft5000.c index a9a27ff29..3faa0805d 100644 --- a/rigs/yaesu/ft5000.c +++ b/rigs/yaesu/ft5000.c @@ -75,12 +75,66 @@ const struct confparams ftdx5000_ext_levels[] = } } }, + { + TOK_KEYER, + "KEYER", + "Keyer", + "Keyer on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_APF_WIDTH, + "APF_WIDTH", + "APF width", + "Audio peak filter width", + NULL, + RIG_CONF_COMBO, + { .c = { .combostr = { "S. Narrow", "Narrow", "Medium", "Wide", NULL } } }, + }, + { + TOK_CONTOUR, + "CONTOUR", + "Contour", + "Contour on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_CONTOUR_FREQ, + "CONTOUR_FREQ", + "Contour frequency", + "Contour frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 100, .max = 4000, .step = 100 } }, + }, + { + TOK_CONTOUR_LEVEL, + "CONTOUR_LEVEL", + "Contour level", + "Contour level (dB)", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -40, .max = 20, .step = 1 } }, + }, + { + TOK_CONTOUR_WIDTH, + "CONTOUR_WIDTH", + "Contour width", + "Contour width", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 1, .max = 11, .step = 1 } }, + }, { RIG_CONF_END, NULL, } }; int ftdx5000_ext_tokens[] = { - TOK_ROOFING_FILTER, TOK_BACKEND_NONE + TOK_ROOFING_FILTER, TOK_KEYER, TOK_APF_WIDTH, + TOK_CONTOUR, TOK_CONTOUR_FREQ, TOK_CONTOUR_LEVEL, TOK_CONTOUR_WIDTH, + TOK_BACKEND_NONE }; const struct rig_caps ftdx5000_caps = diff --git a/rigs/yaesu/ft5000.h b/rigs/yaesu/ft5000.h index 7aba65cc7..b7524447d 100644 --- a/rigs/yaesu/ft5000.h +++ b/rigs/yaesu/ft5000.h @@ -66,7 +66,7 @@ RIG_FUNC_MON|RIG_FUNC_NB|RIG_FUNC_NR|RIG_FUNC_VOX|\ RIG_FUNC_FBKIN|RIG_FUNC_COMP|RIG_FUNC_ANF|RIG_FUNC_MN|\ RIG_FUNC_RIT|RIG_FUNC_XIT|\ - RIG_FUNC_TUNER) + RIG_FUNC_TUNER|RIG_FUNC_APF) /* TBC */ #define FTDX5000_VFO_OPS (RIG_OP_TUNE|RIG_OP_CPY|RIG_OP_XCHG|\ diff --git a/rigs/yaesu/ft891.c b/rigs/yaesu/ft891.c index 2562d1b7d..0517a2c80 100644 --- a/rigs/yaesu/ft891.c +++ b/rigs/yaesu/ft891.c @@ -50,6 +50,79 @@ static int ft891_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t static int ft891_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); static int ft891_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); +const struct confparams ft891_ext_levels[] = +{ + { + TOK_KEYER, + "KEYER", + "Keyer", + "Keyer on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_APF_FREQ, + "APF_FREQ", + "APF frequency", + "Audio peak filter frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -250, .max = 250, .step = 10 } }, + }, + { + TOK_APF_WIDTH, + "APF_WIDTH", + "APF width", + "Audio peak filter width", + NULL, + RIG_CONF_COMBO, + { .c = { .combostr = { "Narrow", "Medium", "Wide", NULL } } }, + }, + { + TOK_CONTOUR, + "CONTOUR", + "Contour", + "Contour on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_CONTOUR_FREQ, + "CONTOUR_FREQ", + "Contour frequency", + "Contour frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 10, .max = 3200, .step = 1 } }, + }, + { + TOK_CONTOUR_LEVEL, + "CONTOUR_LEVEL", + "Contour level", + "Contour level (dB)", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -40, .max = 20, .step = 1 } }, + }, + { + TOK_CONTOUR_WIDTH, + "CONTOUR_WIDTH", + "Contour width", + "Contour width", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 1, .max = 11, .step = 1 } }, + }, + { RIG_CONF_END, NULL, } +}; + +int ft891_ext_tokens[] = +{ + TOK_KEYER, TOK_APF_FREQ, TOK_APF_WIDTH, + TOK_CONTOUR, TOK_CONTOUR_FREQ, TOK_CONTOUR_LEVEL, TOK_CONTOUR_WIDTH, + TOK_BACKEND_NONE +}; + /* * FT-891 rig capabilities */ @@ -190,6 +263,9 @@ const struct rig_caps ft891_caps = RIG_FLT_END, }, + .ext_tokens = ft891_ext_tokens, + .extlevels = ft891_ext_levels, + .priv = NULL, /* private data FIXME: */ .rig_init = ft891_init, @@ -237,6 +313,8 @@ const struct rig_caps ft891_caps = .get_trn = newcat_get_trn, .set_channel = newcat_set_channel, .get_channel = newcat_get_channel, + .set_ext_level = newcat_set_ext_level, + .get_ext_level = newcat_get_ext_level, .send_morse = newcat_send_morse, }; diff --git a/rigs/yaesu/ft891.h b/rigs/yaesu/ft891.h index e0541e1d2..7f3909ea8 100644 --- a/rigs/yaesu/ft891.h +++ b/rigs/yaesu/ft891.h @@ -62,7 +62,7 @@ #define FT891_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|\ - RIG_FUNC_TUNER) + RIG_FUNC_TUNER|RIG_FUNC_APF) #define FT891_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|\ diff --git a/rigs/yaesu/ft991.c b/rigs/yaesu/ft991.c index c0fe7f35c..c5c615da7 100644 --- a/rigs/yaesu/ft991.c +++ b/rigs/yaesu/ft991.c @@ -62,6 +62,79 @@ static int ft991_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone); static int ft991_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code); static int ft991_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code); +const struct confparams ft991_ext_levels[] = +{ + { + TOK_KEYER, + "KEYER", + "Keyer", + "Keyer on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_APF_FREQ, + "APF_FREQ", + "APF frequency", + "Audio peak filter frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -250, .max = 250, .step = 10 } }, + }, + { + TOK_APF_WIDTH, + "APF_WIDTH", + "APF width", + "Audio peak filter width", + NULL, + RIG_CONF_COMBO, + { .c = { .combostr = { "Narrow", "Medium", "Wide", NULL } } }, + }, + { + TOK_CONTOUR, + "CONTOUR", + "Contour", + "Contour on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_CONTOUR_FREQ, + "CONTOUR_FREQ", + "Contour frequency", + "Contour frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 10, .max = 3200, .step = 1 } }, + }, + { + TOK_CONTOUR_LEVEL, + "CONTOUR_LEVEL", + "Contour level", + "Contour level (dB)", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -40, .max = 20, .step = 1 } }, + }, + { + TOK_CONTOUR_WIDTH, + "CONTOUR_WIDTH", + "Contour width", + "Contour width", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 1, .max = 11, .step = 1 } }, + }, + { RIG_CONF_END, NULL, } +}; + +int ft991_ext_tokens[] = +{ + TOK_KEYER, TOK_APF_FREQ, TOK_APF_WIDTH, + TOK_CONTOUR, TOK_CONTOUR_FREQ, TOK_CONTOUR_LEVEL, TOK_CONTOUR_WIDTH, + TOK_BACKEND_NONE +}; + /* * FT-991 rig capabilities */ @@ -194,6 +267,9 @@ const struct rig_caps ft991_caps = RIG_FLT_END, }, + .ext_tokens = ft991_ext_tokens, + .extlevels = ft991_ext_levels, + .priv = NULL, /* private data FIXME: */ .rig_init = ft991_init, @@ -249,6 +325,8 @@ const struct rig_caps ft991_caps = .get_trn = newcat_get_trn, .set_channel = newcat_set_channel, .get_channel = newcat_get_channel, + .set_ext_level = newcat_set_ext_level, + .get_ext_level = newcat_get_ext_level, .send_morse = newcat_send_morse, .send_voice_mem = newcat_send_voice_mem, }; diff --git a/rigs/yaesu/ft991.h b/rigs/yaesu/ft991.h index f100fe4e3..3a0438a18 100644 --- a/rigs/yaesu/ft991.h +++ b/rigs/yaesu/ft991.h @@ -65,7 +65,7 @@ RIG_FUNC_MON|RIG_FUNC_NB|RIG_FUNC_NR|RIG_FUNC_VOX|\ RIG_FUNC_FBKIN|RIG_FUNC_COMP|RIG_FUNC_ANF|RIG_FUNC_MN|\ RIG_FUNC_RIT|RIG_FUNC_XIT|\ - RIG_FUNC_TUNER) + RIG_FUNC_TUNER|RIG_FUNC_APF) #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|\ diff --git a/rigs/yaesu/ftdx10.c b/rigs/yaesu/ftdx10.c index baadf6387..bc3d6542f 100644 --- a/rigs/yaesu/ftdx10.c +++ b/rigs/yaesu/ftdx10.c @@ -63,12 +63,75 @@ const struct confparams ftdx10_ext_levels[] = RIG_CONF_COMBO, { .c = { .combostr = { "AUTO", "12 kHz", "3 kHz", "500 Hz", "300 Hz (optional)", NULL } } } }, + { + TOK_KEYER, + "KEYER", + "Keyer", + "Keyer on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_APF_FREQ, + "APF_FREQ", + "APF frequency", + "Audio peak filter frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -250, .max = 250, .step = 10 } }, + }, + { + TOK_APF_WIDTH, + "APF_WIDTH", + "APF width", + "Audio peak filter width", + NULL, + RIG_CONF_COMBO, + { .c = { .combostr = { "Narrow", "Medium", "Wide", NULL } } }, + }, + { + TOK_CONTOUR, + "CONTOUR", + "Contour", + "Contour on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_CONTOUR_FREQ, + "CONTOUR_FREQ", + "Contour frequency", + "Contour frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 10, .max = 3200, .step = 1 } }, + }, + { + TOK_CONTOUR_LEVEL, + "CONTOUR_LEVEL", + "Contour level", + "Contour level (dB)", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -40, .max = 20, .step = 1 } }, + }, + { + TOK_CONTOUR_WIDTH, + "CONTOUR_WIDTH", + "Contour width", + "Contour width", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 1, .max = 11, .step = 1 } }, + }, { RIG_CONF_END, NULL, } }; int ftdx10_ext_tokens[] = { - TOK_ROOFING_FILTER, TOK_BACKEND_NONE + TOK_ROOFING_FILTER, TOK_KEYER, TOK_APF_FREQ, TOK_APF_WIDTH, + TOK_CONTOUR, TOK_CONTOUR_FREQ, TOK_CONTOUR_LEVEL, TOK_CONTOUR_WIDTH, + TOK_BACKEND_NONE }; const struct rig_caps ftdx10_caps = diff --git a/rigs/yaesu/ftdx10.h b/rigs/yaesu/ftdx10.h index 7863efd24..3db0bd4ba 100644 --- a/rigs/yaesu/ftdx10.h +++ b/rigs/yaesu/ftdx10.h @@ -65,7 +65,7 @@ #define FTDX10_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|\ - RIG_FUNC_RIT|RIG_FUNC_XIT|RIG_FUNC_TUNER) + RIG_FUNC_RIT|RIG_FUNC_XIT|RIG_FUNC_TUNER|RIG_FUNC_APF) /* TBC */ #define FTDX10_VFO_OPS (RIG_OP_TUNE|RIG_OP_CPY|RIG_OP_XCHG|\ diff --git a/rigs/yaesu/ftdx101.c b/rigs/yaesu/ftdx101.c index f5a1af47b..db9fdd7aa 100644 --- a/rigs/yaesu/ftdx101.c +++ b/rigs/yaesu/ftdx101.c @@ -63,12 +63,75 @@ const struct confparams ftdx101d_ext_levels[] = RIG_CONF_COMBO, { .c = { .combostr = { "AUTO", "12 kHz", "3 kHz", "1.2 kHz (optional)", "600 Hz", "300 Hz (optional)", NULL } } } }, + { + TOK_KEYER, + "KEYER", + "Keyer", + "Keyer on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_APF_FREQ, + "APF_FREQ", + "APF frequency", + "Audio peak filter frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -250, .max = 250, .step = 10 } }, + }, + { + TOK_APF_WIDTH, + "APF_WIDTH", + "APF width", + "Audio peak filter width", + NULL, + RIG_CONF_COMBO, + { .c = { .combostr = { "Narrow", "Medium", "Wide", NULL } } }, + }, + { + TOK_CONTOUR, + "CONTOUR", + "Contour", + "Contour on/off", + NULL, + RIG_CONF_CHECKBUTTON, + }, + { + TOK_CONTOUR_FREQ, + "CONTOUR_FREQ", + "Contour frequency", + "Contour frequency", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 10, .max = 3200, .step = 1 } }, + }, + { + TOK_CONTOUR_LEVEL, + "CONTOUR_LEVEL", + "Contour level", + "Contour level (dB)", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = -40, .max = 20, .step = 1 } }, + }, + { + TOK_CONTOUR_WIDTH, + "CONTOUR_WIDTH", + "Contour width", + "Contour width", + NULL, + RIG_CONF_NUMERIC, + { .n = { .min = 1, .max = 11, .step = 1 } }, + }, { RIG_CONF_END, NULL, } }; int ftdx101d_ext_tokens[] = { - TOK_ROOFING_FILTER, TOK_BACKEND_NONE + TOK_ROOFING_FILTER, TOK_KEYER, TOK_APF_FREQ, TOK_APF_WIDTH, + TOK_CONTOUR, TOK_CONTOUR_FREQ, TOK_CONTOUR_LEVEL, TOK_CONTOUR_WIDTH, + TOK_BACKEND_NONE }; const struct rig_caps ftdx101d_caps = diff --git a/rigs/yaesu/ftdx101.h b/rigs/yaesu/ftdx101.h index de63cc6f1..ce4c5971d 100644 --- a/rigs/yaesu/ftdx101.h +++ b/rigs/yaesu/ftdx101.h @@ -64,7 +64,7 @@ #define FTDX101_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|\ - RIG_FUNC_RIT|RIG_FUNC_XIT|RIG_FUNC_TUNER) + RIG_FUNC_RIT|RIG_FUNC_XIT|RIG_FUNC_TUNER|RIG_FUNC_APF) /* TBC */ #define FTDX101_VFO_OPS (RIG_OP_TUNE|RIG_OP_CPY|RIG_OP_XCHG|\ diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 10d1dfa75..87090d94c 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -391,6 +391,18 @@ static int set_roofing_filter(RIG *rig, vfo_t vfo, int index); static int set_roofing_filter_for_width(RIG *rig, vfo_t vfo, int width); static int get_roofing_filter(RIG *rig, vfo_t vfo, struct newcat_roofing_filter **roofing_filter); +static int newcat_set_apf_frequency(RIG *rig, vfo_t vfo, int freq); +static int newcat_get_apf_frequency(RIG *rig, vfo_t vfo, int *freq); +static int newcat_set_apf_width(RIG *rig, vfo_t vfo, int choice); +static int newcat_get_apf_width(RIG *rig, vfo_t vfo, int *choice); +static int newcat_set_contour(RIG *rig, vfo_t vfo, int status); +static int newcat_get_contour(RIG *rig, vfo_t vfo, int *status); +static int newcat_set_contour_frequency(RIG *rig, vfo_t vfo, int freq); +static int newcat_get_contour_frequency(RIG *rig, vfo_t vfo, int *freq); +static int newcat_set_contour_level(RIG *rig, vfo_t vfo, int level); +static int newcat_get_contour_level(RIG *rig, vfo_t vfo, int *level); +static int newcat_set_contour_width(RIG *rig, vfo_t vfo, int width); +static int newcat_get_contour_width(RIG *rig, vfo_t vfo, int *width); static ncboolean newcat_valid_command(RIG *rig, char const *const command); /* @@ -5575,6 +5587,27 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) cat_term); break; + case RIG_FUNC_APF: + if (!newcat_valid_command(rig, "CO")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + + if (is_ftdx101d || is_ftdx101mp) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c2%04d%c", main_sub_vfo, status ? 1 : 0, cat_term); + } else if (is_ftdx10 || is_ft991 || is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO02%04d%c", status ? 1 : 0, cat_term); + } else if (is_ftdx5000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%02d%c", main_sub_vfo, status ? 2 : 0, cat_term); + } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%02d%c", status ? 2 : 0, cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + break; + default: RETURNFUNC(-RIG_EINVAL); } @@ -5796,6 +5829,25 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "XT%c", cat_term); break; + case RIG_FUNC_APF: + if (!newcat_valid_command(rig, "CO")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c2%c", main_sub_vfo, cat_term); + } else if (is_ftdx10 || is_ft991 || is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO02%c", cat_term); + } else if (is_ftdx5000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%c", main_sub_vfo, cat_term); + } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%c", cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + break; default: RETURNFUNC(-RIG_EINVAL); } @@ -5877,6 +5929,21 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) *status = (retfunc[0] == '1') ? 1 : 0; break; + case RIG_FUNC_APF: + if (is_ftdx101d || is_ftdx101mp) { + *status = (retfunc[last_char_index] == '1') ? 1 : 0; + } else if (is_ftdx10 || is_ft991 || is_ft891) { + *status = (retfunc[last_char_index] == '1') ? 1 : 0; + } else if (is_ftdx5000) { + *status = (retfunc[last_char_index] == '2') ? 1 : 0; + } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + *status = (retfunc[last_char_index] == '2') ? 1 : 0; + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + break; + default: RETURNFUNC(-RIG_EINVAL); } @@ -5903,6 +5970,8 @@ int newcat_get_parm(RIG *rig, setting_t parm, value_t *val) int newcat_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val) { + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + ENTERFUNC; switch (token) @@ -5910,6 +5979,35 @@ int newcat_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val) case TOK_ROOFING_FILTER: RETURNFUNC(set_roofing_filter(rig, vfo, val.i)); + case TOK_KEYER: + if (!newcat_valid_command(rig, "ML")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "KR%d%c", val.i ? 1 : 0, + cat_term); + + RETURNFUNC(newcat_set_cmd(rig)); + + case TOK_APF_FREQ: + RETURNFUNC(newcat_set_apf_frequency(rig, vfo, val.f)); + + case TOK_APF_WIDTH: + RETURNFUNC(newcat_set_apf_width(rig, vfo, val.i)); + + case TOK_CONTOUR: + RETURNFUNC(newcat_set_contour(rig, vfo, val.i)); + + case TOK_CONTOUR_FREQ: + RETURNFUNC(newcat_set_contour_frequency(rig, vfo, val.f)); + + case TOK_CONTOUR_LEVEL: + RETURNFUNC(newcat_set_contour_level(rig, vfo, val.f)); + + case TOK_CONTOUR_WIDTH: + RETURNFUNC(newcat_set_contour_width(rig, vfo, val.f)); + default: rig_debug(RIG_DEBUG_ERR, "%s: Unsupported ext level %s\n", __func__, rig_strlevel(token)); @@ -5919,7 +6017,10 @@ int newcat_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val) int newcat_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val) { + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + char *result; int retval; + int value; ENTERFUNC; @@ -5939,6 +6040,95 @@ int newcat_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val) break; } + case TOK_KEYER: + if (!newcat_valid_command(rig, "KR")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "KR%c", cat_term); + + retval = newcat_get_cmd(rig); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + /* skip command */ + result = priv->ret_data + strlen(priv->cmd_str) - 1; + /* chop term */ + priv->ret_data[strlen(priv->ret_data) - 1] = '\0'; + + val->i = result[0] == '0' ? 0 : 1; + break; + + case TOK_APF_FREQ: + retval = newcat_get_apf_frequency(rig, vfo, &value); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + val->f = value; + break; + + case TOK_APF_WIDTH: + retval = newcat_get_apf_width(rig, vfo, &value); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + val->i = value; + break; + + case TOK_CONTOUR: + retval = newcat_get_contour(rig, vfo, &value); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + val->i = value; + break; + + case TOK_CONTOUR_WIDTH: + retval = newcat_get_contour_width(rig, vfo, &value); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + val->f = value; + break; + + case TOK_CONTOUR_FREQ: + retval = newcat_get_contour_frequency(rig, vfo, &value); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + val->f = value; + break; + + case TOK_CONTOUR_LEVEL: + retval = newcat_get_contour_level(rig, vfo, &value); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + val->f = value; + break; + default: rig_debug(RIG_DEBUG_ERR, "%s: Unsupported ext level %s\n", __func__, rig_strlevel(token)); @@ -10214,3 +10404,431 @@ int newcat_send_voice_mem(RIG *rig, vfo_t vfo, int ch) RETURNFUNC(newcat_set_cmd(rig)); } +static int newcat_set_apf_frequency(RIG *rig, vfo_t vfo, int freq) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + char main_sub_vfo = (RIG_VFO_B == vfo || RIG_VFO_SUB == vfo) ? '1' : '0'; + + if (!newcat_valid_command(rig, "CO")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + // Range seems to be -250..250 Hz in 10 Hz steps + if (is_ftdx101d || is_ftdx101mp) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c3%04d%c", main_sub_vfo, (freq + 250) / 10, cat_term); + } else if (is_ftdx10 || is_ft991 || is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO03%04d%c", (freq + 250) / 10, cat_term); + } else if (is_ftdx3000 || is_ftdx1200) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO02%02d%c", (freq + 250) / 10, cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + RETURNFUNC(newcat_set_cmd(rig)); +} + +static int newcat_get_apf_frequency(RIG *rig, vfo_t vfo, int *freq) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + char main_sub_vfo = (RIG_VFO_B == vfo || RIG_VFO_SUB == vfo) ? '1' : '0'; + int err; + int ret_data_len; + char *ret_data; + + if (!newcat_valid_command(rig, "CO")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c3%c", main_sub_vfo, cat_term); + } else if (is_ftdx10 || is_ft991 || is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO03%c", cat_term); + } else if (is_ftdx3000 || is_ftdx1200) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO02%c", cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + if ((err = newcat_get_cmd(rig)) != RIG_OK) + { + RETURNFUNC(err); + } + + ret_data_len = strlen(priv->ret_data); + + /* skip command */ + ret_data = priv->ret_data + strlen(priv->cmd_str) - 1; + rig_debug(RIG_DEBUG_TRACE, "%s: ret_data='%s'\n", __func__, ret_data); + /* chop term */ + priv->ret_data[ret_data_len - 1] = '\0'; + + int raw_value = atoi(ret_data); + + // Range seems to be -250..250 Hz in 10 Hz steps + *freq = raw_value * 10 - 250; + + RETURNFUNC(RIG_OK); +} + +static int newcat_set_apf_width(RIG *rig, vfo_t vfo, int choice) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + + if (!newcat_valid_command(rig, "EX")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030201%d%c", choice, cat_term); + } else if (is_ft991) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX111%d%c", choice, cat_term); + } else if (is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1201%d%c", choice, cat_term); + } else if (is_ftdx5000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX112%d%c", choice, cat_term); + } else if (is_ftdx3000 || is_ftdx1200) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX107%d%c", choice, cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + RETURNFUNC(newcat_set_cmd(rig)); +} + +static int newcat_get_apf_width(RIG *rig, vfo_t vfo, int *choice) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + int err; + int ret_data_len; + char *ret_data; + + if (!newcat_valid_command(rig, "EX")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030201%c", cat_term); + } else if (is_ft991) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX111%c", cat_term); + } else if (is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1201%c", cat_term); + } else if (is_ftdx5000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX112%c", cat_term); + } else if (is_ftdx3000 || is_ftdx1200) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX107%c", cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + if ((err = newcat_get_cmd(rig)) != RIG_OK) + { + RETURNFUNC(err); + } + + ret_data_len = strlen(priv->ret_data); + + /* skip command */ + ret_data = priv->ret_data + strlen(priv->cmd_str) - 1; + rig_debug(RIG_DEBUG_TRACE, "%s: ret_data='%s'\n", __func__, ret_data); + /* chop term */ + priv->ret_data[ret_data_len - 1] = '\0'; + + *choice = atoi(ret_data); + + RETURNFUNC(RIG_OK); +} + +static int newcat_set_contour(RIG *rig, vfo_t vfo, int status) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + char main_sub_vfo = (RIG_VFO_B == vfo || RIG_VFO_SUB == vfo) ? '1' : '0'; + + if (!newcat_valid_command(rig, "CO")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%04d%c", main_sub_vfo, status ? 1 : 0, cat_term); + } else if (is_ftdx10 || is_ft991 || is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%04d%c", status ? 1 : 0, cat_term); + } else if (is_ftdx5000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%02d%c", main_sub_vfo, status ? 1 : 0, cat_term); + } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%02d%c", status ? 1 : 0, cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + RETURNFUNC(newcat_set_cmd(rig)); +} + +static int newcat_get_contour(RIG *rig, vfo_t vfo, int *status) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + char main_sub_vfo = (RIG_VFO_B == vfo || RIG_VFO_SUB == vfo) ? '1' : '0'; + int err; + int ret_data_len; + char *ret_data; + int last_char_index; + + if (!newcat_valid_command(rig, "CO")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%c", main_sub_vfo, cat_term); + } else if (is_ftdx10 || is_ft991 || is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%c", cat_term); + } else if (is_ftdx5000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%c", main_sub_vfo, cat_term); + } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%c", cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + if ((err = newcat_get_cmd(rig)) != RIG_OK) + { + RETURNFUNC(err); + } + + ret_data_len = strlen(priv->ret_data); + + /* skip command */ + ret_data = priv->ret_data + strlen(priv->cmd_str) - 1; + rig_debug(RIG_DEBUG_TRACE, "%s: ret_data='%s'\n", __func__, ret_data); + /* chop term */ + priv->ret_data[ret_data_len - 1] = '\0'; + + last_char_index = strlen(ret_data) - 1; + + *status = (ret_data[last_char_index] == '1') ? 1 : 0; + + RETURNFUNC(RIG_OK); +} + +static int newcat_set_contour_frequency(RIG *rig, vfo_t vfo, int freq) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + char main_sub_vfo = (RIG_VFO_B == vfo || RIG_VFO_SUB == vfo) ? '1' : '0'; + + if (!newcat_valid_command(rig, "CO")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp) { + // Range is 10..3200 Hz + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%04d%c", main_sub_vfo, freq, cat_term); + } else if (is_ftdx10 || is_ft991 || is_ft891) { + // Range is 10..3200 Hz + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO01%04d%c", freq, cat_term); + } else if (is_ftdx5000) { + // Range is 100..4000 Hz in 100 Hz steps + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%01d%c", main_sub_vfo, freq / 100, cat_term); + } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + // Range is 100..4000 Hz in 100 Hz steps + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO01%02d%c", freq / 100, cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + RETURNFUNC(newcat_set_cmd(rig)); +} + +static int newcat_get_contour_frequency(RIG *rig, vfo_t vfo, int *freq) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + char main_sub_vfo = (RIG_VFO_B == vfo || RIG_VFO_SUB == vfo) ? '1' : '0'; + int err; + int ret_data_len; + char *ret_data; + + if (!newcat_valid_command(rig, "CO")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%c", main_sub_vfo, cat_term); + } else if (is_ftdx10 || is_ft991 || is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO01%c", cat_term); + } else if (is_ftdx5000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%c", main_sub_vfo, cat_term); + } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO01%c", cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + if ((err = newcat_get_cmd(rig)) != RIG_OK) + { + RETURNFUNC(err); + } + + ret_data_len = strlen(priv->ret_data); + + /* skip command */ + ret_data = priv->ret_data + strlen(priv->cmd_str) - 1; + rig_debug(RIG_DEBUG_TRACE, "%s: ret_data='%s'\n", __func__, ret_data); + /* chop term */ + priv->ret_data[ret_data_len - 1] = '\0'; + + int raw_value = atoi(ret_data); + + if (is_ftdx101d || is_ftdx101mp || is_ftdx10 || is_ft991 || is_ft891) { + *freq = raw_value; + } else if (is_ftdx5000 || is_ftdx3000 || is_ftdx1200 || is_ft2000) { + *freq = raw_value * 100; + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + RETURNFUNC(RIG_OK); +} + +static int newcat_set_contour_level(RIG *rig, vfo_t vfo, int level) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + + if (!newcat_valid_command(rig, "EX")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030202%+03d%c", level, cat_term); + } else if (is_ft991) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX112%+03d%c", level, cat_term); + } else if (is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1202%+03d%c", level, cat_term); + } else if (is_ftdx5000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX113%+03d%c", level, cat_term); + } else if (is_ftdx3000 || is_ftdx1200) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX108%+03d%c", level, cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + RETURNFUNC(newcat_set_cmd(rig)); +} + +static int newcat_get_contour_level(RIG *rig, vfo_t vfo, int *level) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + int err; + int ret_data_len; + char *ret_data; + + if (!newcat_valid_command(rig, "EX")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030202%c", cat_term); + } else if (is_ft991) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX112%c", cat_term); + } else if (is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1202%c", cat_term); + } else if (is_ftdx5000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX113%c", cat_term); + } else if (is_ftdx3000 || is_ftdx1200) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX108%c", cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + if ((err = newcat_get_cmd(rig)) != RIG_OK) + { + RETURNFUNC(err); + } + + ret_data_len = strlen(priv->ret_data); + + /* skip command */ + ret_data = priv->ret_data + strlen(priv->cmd_str) - 1; + rig_debug(RIG_DEBUG_TRACE, "%s: ret_data='%s'\n", __func__, ret_data); + /* chop term */ + priv->ret_data[ret_data_len - 1] = '\0'; + + *level = atoi(ret_data); + + RETURNFUNC(RIG_OK); +} + +static int newcat_set_contour_width(RIG *rig, vfo_t vfo, int width) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + + if (!newcat_valid_command(rig, "EX")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030203%02d%c", width, cat_term); + } else if (is_ft991) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX113%02d%c", width, cat_term); + } else if (is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1203%02d%c", width, cat_term); + } else if (is_ftdx5000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX114%02d%c", width, cat_term); + } else if (is_ftdx3000 || is_ftdx1200) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX109%02d%c", width, cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + RETURNFUNC(newcat_set_cmd(rig)); +} + +static int newcat_get_contour_width(RIG *rig, vfo_t vfo, int *width) +{ + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + int err; + int ret_data_len; + char *ret_data; + + if (!newcat_valid_command(rig, "EX")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030203%c", cat_term); + } else if (is_ft991) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX113%c", cat_term); + } else if (is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1203%c", cat_term); + } else if (is_ftdx5000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX114%c", cat_term); + } else if (is_ftdx3000 || is_ftdx1200) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX109%c", cat_term); + } else { + RETURNFUNC(-RIG_ENIMPL); + } + + if ((err = newcat_get_cmd(rig)) != RIG_OK) + { + RETURNFUNC(err); + } + + ret_data_len = strlen(priv->ret_data); + + /* skip command */ + ret_data = priv->ret_data + strlen(priv->cmd_str) - 1; + rig_debug(RIG_DEBUG_TRACE, "%s: ret_data='%s'\n", __func__, ret_data); + /* chop term */ + priv->ret_data[ret_data_len - 1] = '\0'; + + *width = atoi(ret_data); + + RETURNFUNC(RIG_OK); +} diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index e11ef2a5f..7daac8806 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -226,5 +226,12 @@ int newcat_send_voice_mem(RIG *rig, vfo_t vfo, int ch); #define TOKEN_BACKEND(t) (t) #define TOK_ROOFING_FILTER TOKEN_BACKEND(100) +#define TOK_KEYER TOKEN_BACKEND(101) +#define TOK_APF_FREQ TOKEN_BACKEND(102) +#define TOK_APF_WIDTH TOKEN_BACKEND(103) +#define TOK_CONTOUR TOKEN_BACKEND(104) +#define TOK_CONTOUR_FREQ TOKEN_BACKEND(105) +#define TOK_CONTOUR_LEVEL TOKEN_BACKEND(106) +#define TOK_CONTOUR_WIDTH TOKEN_BACKEND(107) #endif /* _NEWCAT_H */