diff --git a/NEWS b/NEWS index 51850364d..490018f3b 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ Hamlib -- History of visible changes. Copyright (C) 2000-2003 Frank Singleton -Copyright (C) 2000-2015 Stephane Fillod, and others +Copyright (C) 2000-2016 Stephane Fillod, and others Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net @@ -9,6 +9,7 @@ Version 3.1 2016-??-?? * Fix kenwood_set_mode for ts590s and mode CW, RTTY or AM. Tks Tom, DL1JBE + * New Perseus model. Version 3.0 2015-09-20 diff --git a/icom/Makefile.am b/icom/Makefile.am index d71ece2f3..0b3f633c7 100644 --- a/icom/Makefile.am +++ b/icom/Makefile.am @@ -5,7 +5,7 @@ ICOMSRC = ic706.c icr8500.c ic735.c ic775.c ic756.c \ ic736.c ic738.c ic7410.c ic746.c ic703.c ic726.c ic271.c \ ic765.c ic781.c ic471.c icr9000.c icr9500.c \ icr10.c icr20.c icr71.c icr72.c icr75.c icrx7.c \ - id1.c id5100.c ic2730.c \ + id1.c id5100.c perseus.c ic2730.c \ ic707.c ic728.c ic751.c ic761.c \ ic78.c ic7800.c ic7000.c ic7100.c ic7200.c ic7300.c ic7600.c ic7700.c \ icom.c icom.h icom_defs.h frame.c frame.h optoscan.c optoscan.h diff --git a/icom/icom.c b/icom/icom.c index f76dea3ad..c9e780c8e 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -1,6 +1,6 @@ /* * Hamlib CI-V backend - main file - * Copyright (c) 2000-2015 by Stephane Fillod + * Copyright (c) 2000-2016 by Stephane Fillod * * * This library is free software; you can redistribute it and/or @@ -352,6 +352,7 @@ static const struct icom_addr icom_addr_list[] = { { RIG_MODEL_IC7100, 0x88 }, { RIG_MODEL_IC7200, 0x76 }, { RIG_MODEL_IC7700, 0x74 }, + { RIG_MODEL_PERSEUS, 0xE1 }, { RIG_MODEL_NONE, 0 }, }; @@ -826,8 +827,11 @@ int icom_get_mode_with_data(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { unsigned char modebuf[MAXFRAMELEN]; + const struct icom_priv_caps *priv_caps; int mode_len, retval; + priv_caps = (const struct icom_priv_caps *) rig->caps->priv; + retval = icom_transaction (rig, C_RD_MODE, -1, NULL, 0, modebuf, &mode_len); if (retval != RIG_OK) @@ -843,7 +847,15 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return -RIG_ERJCTED; } - icom2rig_mode(rig, modebuf[1], mode_len==2 ? modebuf[2] : -1, mode, width); + if (priv_caps->i2r_mode != NULL) { /* call priv code if defined */ + priv_caps->i2r_mode(rig, modebuf[1], + mode_len==2 ? modebuf[2] : -1, mode, width); + } + else { /* else call default */ + icom2rig_mode(rig, modebuf[1], + mode_len==2 ? modebuf[2] : -1, mode, width); + } + /* IC910H has different meaning of command 1A, subcommand 03. So do * not ask for DSP filter settings */ /* Likewise, don't ask if we happen to be an Omni VI Plus */ @@ -3530,7 +3542,7 @@ int icom_decode_event(RIG *rig) return -RIG_ENAVAIL; break; default: - rig_debug(RIG_DEBUG_VERBOSE,"icom_decode: tranceive cmd " + rig_debug(RIG_DEBUG_VERBOSE,"icom_decode: transceive cmd " "unsupported %#2.2x\n",buf[4]); return -RIG_ENIMPL; } @@ -3773,5 +3785,7 @@ DECLARE_INITRIG_BACKEND(icom) rig_register(&id5100_caps); rig_register(&ic2730_caps); + rig_register(&perseus_caps); + return RIG_OK; } diff --git a/icom/icom.h b/icom/icom.h index 8bed69a3b..9b811ae6b 100644 --- a/icom/icom.h +++ b/icom/icom.h @@ -1,6 +1,6 @@ /* * Hamlib CI-V backend - main header - * Copyright (c) 2000-2015 by Stephane Fillod + * Copyright (c) 2000-2016 by Stephane Fillod * * * This library is free software; you can redistribute it and/or @@ -270,4 +270,6 @@ extern const struct rig_caps id1_caps; extern const struct rig_caps id5100_caps; extern const struct rig_caps ic2730_caps; +extern const struct rig_caps perseus_caps; + #endif /* _ICOM_H */ diff --git a/icom/icom_defs.h b/icom/icom_defs.h index f21f1b9ad..c9557db54 100644 --- a/icom/icom_defs.h +++ b/icom/icom_defs.h @@ -1,6 +1,6 @@ /* * Hamlib CI-V backend - defines for the ICOM "CI-V" interface. - * Copyright (c) 2000-2010 by Stephane Fillod + * Copyright (c) 2000-2016 by Stephane Fillod * * * This library is free software; you can redistribute it and/or @@ -84,7 +84,7 @@ #define C_CTL_ANT 0x12 /* Set/get antenna, Sc */ #define C_CTL_ANN 0x13 /* Control announce (speech synth.), Sc */ #define C_CTL_LVL 0x14 /* Set AF/RF/squelch, Sc */ -#define C_RD_SQSM 0x15 /* Read squelch condiction/S-meter level, Sc */ +#define C_RD_SQSM 0x15 /* Read squelch condition/S-meter level, Sc */ #define C_CTL_FUNC 0x16 /* Function settings (AGC,NB,etc.), Sc */ #define C_SND_CW 0x17 /* Send CW message */ #define C_SET_PWR 0x18 /* Set Power ON/OFF, Sc */ @@ -92,6 +92,7 @@ #define C_CTL_MEM 0x1a /* Misc memory/bank/rig control functions, Sc */ #define C_SET_TONE 0x1b /* Set tone frequency */ #define C_CTL_PTT 0x1c /* Control Transmit On/Off, Sc */ +#define C_CTL_MTEXT 0x70 /* Microtelecom Extension */ #define C_CTL_MISC 0x7f /* Miscellaneous control, Sc */ /* diff --git a/icom/perseus.c b/icom/perseus.c new file mode 100644 index 000000000..11616cca9 --- /dev/null +++ b/icom/perseus.c @@ -0,0 +1,203 @@ +/* + * Hamlib CI-V backend - Perseus description + * Copyright (c) 2016 by Stephane Fillod + * + * + * 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 + +#include +#include "serial.h" +#include "misc.h" +#include "idx_builtin.h" + +#include "icom.h" +#include "icom_defs.h" +#include "frame.h" + + +/* TODO: $09 DRM, $0a USER */ +#define PERSEUS_MODES (RIG_MODE_AM|RIG_MODE_SAM|RIG_MODE_SSB| \ + RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY|RIG_MODE_RTTYR| \ + RIG_MODE_FM) + +#define PERSEUS_FUNCS (RIG_FUNC_NONE) + +/* TODO (not standard) : + * RIG_LEVEL_AGC|RIG_LEVEL_NB|RIG_LEVEL_ANR|RIG_LEVEL_ANR|RIG_LEVEL_AF|RIG_LEVEL_ANF + */ + +#define PERSEUS_LEVELS (RIG_LEVEL_ATT|RIG_LEVEL_SQL|RIG_LEVEL_RAWSTR) + +#define PERSEUS_PARMS (RIG_PARM_NONE) + +/* S-Meter calibration, according to the Reference Manual */ +#define PERSEUS_STR_CAL { 2, \ + { \ + { 0, -67 }, /* -140 dBm */ \ + { 255, 103 }, /* +30 dBm */ \ + } } + + +static int perseus_r2i_mode(RIG *rig, rmode_t mode, pbwidth_t width, + unsigned char *md, signed char *pd); +static void perseus_i2r_mode(RIG *rig, unsigned char md, int pd, + rmode_t *mode, pbwidth_t *width); + +static const struct icom_priv_caps perseus_priv_caps = { + 0xE1, /* default address */ + 0, /* 731 mode */ + 0, /* no XCHG */ + .r2i_mode = perseus_r2i_mode, + .i2r_mode = perseus_i2r_mode, +}; + + +/* + * PERSEUS rigs capabilities. + * + * PERSEUS Receiver CAT Interface Reference Manual (Revision EN03) : + * http://microtelecom.it/perseus/PERSEUS_CI-V_Interface-EN03.pdf + */ +const struct rig_caps perseus_caps = { +.rig_model = RIG_MODEL_PERSEUS, +.model_name = "Perseus", +.mfg_name = "Microtelecom", +.version = BACKEND_VER ".0", +.copyright = "LGPL", +.status = RIG_STATUS_ALPHA, +.rig_type = RIG_TYPE_PCRECEIVER, +.ptt_type = RIG_PTT_NONE, +.dcd_type = RIG_DCD_NONE, +.port_type = RIG_PORT_SERIAL, +.serial_rate_min = 300, +.serial_rate_max = 19200, +.serial_data_bits = 8, +.serial_stop_bits = 1, +.serial_parity = RIG_PARITY_NONE, +.serial_handshake = RIG_HANDSHAKE_NONE, +.write_delay = 0, +.post_write_delay = 0, +.timeout = 1000, +.retry = 3, + +.has_get_func = PERSEUS_FUNCS, +.has_set_func = PERSEUS_FUNCS, +.has_get_level = PERSEUS_LEVELS, +.has_set_level = RIG_LEVEL_SET(PERSEUS_LEVELS), +.has_get_parm = PERSEUS_PARMS, +.has_set_parm = PERSEUS_PARMS, +.level_gran = {}, +.parm_gran = {}, +.ctcss_list = NULL, +.dcs_list = NULL, +.preamp = { RIG_DBLST_END, }, +.attenuator = { 10, 20, 30, RIG_DBLST_END, }, +.max_rit = Hz(0), +.max_xit = Hz(0), +.max_ifshift = Hz(0), +.targetable_vfo = 0, +.vfo_ops = RIG_OP_NONE, +.transceive = RIG_TRN_OFF, +.bank_qty = 0, +.chan_desc_sz = 0, + +.chan_list = { + RIG_CHAN_END, }, + +.rx_range_list1 = { + {kHz(10),MHz(30),PERSEUS_MODES,-1,-1, RIG_VFO_A}, + RIG_FRNG_END, }, +.tx_range_list1 = { RIG_FRNG_END, }, + +.rx_range_list2 = { + {kHz(10),MHz(30),PERSEUS_MODES,-1,-1, RIG_VFO_A}, + RIG_FRNG_END, }, +.tx_range_list2 = { RIG_FRNG_END, }, /* no TX ranges, this is a receiver */ + +.tuning_steps = { + {PERSEUS_MODES,100}, /* resolution */ + RIG_TS_END, + }, + /* mode/filter list, remember: order matters! */ +.filters = { + {RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY|RIG_MODE_RTTYR, kHz(2.4)}, + {RIG_MODE_AM|RIG_MODE_SAM, kHz(8)}, + {RIG_MODE_FM, kHz(15)}, + RIG_FLT_END, + }, + +.str_cal = PERSEUS_STR_CAL, + +.cfgparams = icom_cfg_params, +.set_conf = icom_set_conf, +.get_conf = icom_get_conf, + +.priv = (void*)&perseus_priv_caps, +.rig_init = icom_init, +.rig_cleanup = icom_cleanup, +.rig_open = NULL, +.rig_close = NULL, + +.set_freq = icom_set_freq, +.get_freq = icom_get_freq, + +.set_mode = icom_set_mode, +.get_mode = icom_get_mode, + +.set_level = icom_set_level, +.get_level = icom_get_level, + +}; + +/* + * Function definitions below + */ + + +/* + * This function does the special bandwidth coding for the Perseus + * + * NB: the filter width will be ignored. + */ +static int perseus_r2i_mode(RIG *rig, rmode_t mode, pbwidth_t width, + unsigned char *md, signed char *pd) +{ + int err; + + err = rig2icom_mode(rig, mode, width, md, pd); + + if (err == 0 && mode == RIG_MODE_SAM) + *md = 0x06; + + return err; +} + +static void perseus_i2r_mode(RIG *rig, unsigned char md, int pd, + rmode_t *mode, pbwidth_t *width) +{ + icom2rig_mode(rig, md, pd, mode, width); + + if (md == 0x06) + *mode = RIG_MODE_SAM; +} + diff --git a/include/hamlib/riglist.h b/include/hamlib/riglist.h index 6edf78e59..010c32338 100644 --- a/include/hamlib/riglist.h +++ b/include/hamlib/riglist.h @@ -213,7 +213,8 @@ #define RIG_MODEL_ID5100 RIG_MAKE_MODEL(RIG_ICOM, 71) #define RIG_MODEL_IC2730 RIG_MAKE_MODEL(RIG_ICOM, 72) #define RIG_MODEL_IC7300 RIG_MAKE_MODEL(RIG_ICOM, 73) -/* next one is 74 */ +#define RIG_MODEL_PERSEUS RIG_MAKE_MODEL(RIG_ICOM, 74) +/* next one is 75 */ /* * Optoelectronics (CI-V)