From fe43cf0e268fb6deefeebf5fc70a34278e8b44cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Mon, 1 Jun 2009 16:58:08 +0000 Subject: [PATCH] * Bug fixed in icom_set_ctcss_tone and icom_set_ctcss_sql, reported by Joe KJ0EYT. * New: icom_set_dcs_code/icom_get_dcs_code * More declarations for IC-7000 git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2702 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- icom/ic7000.c | 41 ++++++++++++++---- icom/icom.c | 114 ++++++++++++++++++++++++++++++++++++-------------- icom/icom.h | 10 +++-- 3 files changed, 122 insertions(+), 43 deletions(-) diff --git a/icom/ic7000.c b/icom/ic7000.c index e70716ba4..0086434f7 100644 --- a/icom/ic7000.c +++ b/icom/ic7000.c @@ -1,7 +1,7 @@ /* * Hamlib CI-V backend - description of IC-7000 and variations * Adapted from IC-7800 code 2006 by Kent Hill - * Copyright (c) 2004 by Stephane Fillod + * Copyright (c) 2004-2009 by Stephane Fillod * * $Id: ic7000.c,v 1.2 2008-10-26 13:45:21 y32kn Exp $ * @@ -67,6 +67,27 @@ } } +/* + * + * IC7000 channel caps. + */ +#define IC7000_MEM_CAP { \ + .freq = 1, \ + .mode = 1, \ + .width = 1, \ + .split = 1, \ + .tx_freq = 1, \ + .tx_mode = 1, \ + .tx_width = 1, \ + .rptr_offs = 1, \ + .rptr_shift = 1, \ + .ctcss_tone = 1, \ + .ctcss_sql = 1, \ + .funcs = IC7000_FUNCS, \ + .levels = RIG_LEVEL_SET(IC7000_LEVELS), \ +} + + /* * IC-7000 rig capabilities. * @@ -83,9 +104,9 @@ const struct rig_caps ic7000_caps = { .rig_model = RIG_MODEL_IC7000, .model_name = "IC-7000", .mfg_name = "Icom", -.version = BACKEND_VER, +.version = BACKEND_VER ".1", .copyright = "LGPL", -.status = RIG_STATUS_UNTESTED, +.status = RIG_STATUS_BETA, .rig_type = RIG_TYPE_TRANSCEIVER, .ptt_type = RIG_PTT_RIG, .dcd_type = RIG_DCD_RIG, @@ -111,22 +132,23 @@ const struct rig_caps ic7000_caps = { }, .parm_gran = {}, .ctcss_list = common_ctcss_list, -.dcs_list = NULL, +.dcs_list = common_dcs_list, .preamp = { 10, RIG_DBLST_END, }, /* FIXME: TBC it's a guess*/ .attenuator = { 12, RIG_DBLST_END, }, .max_rit = Hz(9999), .max_xit = Hz(9999), -.max_ifshift = Hz(0), +.max_ifshift = Hz(0), /* TODO */ .targetable_vfo = 0, .vfo_ops = IC7000_VFO_OPS, .scan_ops = IC7000_SCAN_OPS, .transceive = RIG_TRN_RIG, .bank_qty = 5, -.chan_desc_sz = 0, +.chan_desc_sz = 0, /* TODO */ .chan_list = { - { 1, 99, RIG_MTYPE_MEM }, - { 100, 105, RIG_MTYPE_EDGE }, /* two by two */ + { 1, 99, RIG_MTYPE_MEM, IC7000_MEM_CAP }, + { 100, 105, RIG_MTYPE_EDGE, IC7000_MEM_CAP }, /* two by two */ + { 106, 107, RIG_MTYPE_CALL, IC7000_MEM_CAP }, RIG_CHAN_END, }, @@ -221,6 +243,7 @@ const struct rig_caps ic7000_caps = { .set_parm = NULL, .get_parm = NULL, .set_mem = icom_set_mem, +.set_mem = icom_set_bank, .vfo_op = icom_vfo_op, .scan = icom_scan, .set_ptt = icom_set_ptt, @@ -236,6 +259,8 @@ const struct rig_caps ic7000_caps = { .get_ctcss_tone = icom_get_ctcss_tone, .set_ctcss_sql = icom_set_ctcss_sql, .get_ctcss_sql = icom_get_ctcss_sql, +.set_dcs_code = icom_set_dcs_code, +.get_dcs_code = icom_get_dcs_code, .set_split_freq = icom_set_split_freq, .get_split_freq = icom_get_split_freq, .set_split_mode = icom_set_split_mode, diff --git a/icom/icom.c b/icom/icom.c index aff5b30b1..123272c63 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -1,6 +1,6 @@ /* * Hamlib CI-V backend - main file - * Copyright (c) 2000-2005 by Stephane Fillod + * Copyright (c) 2000-2008 by Stephane Fillod * * $Id: icom.c,v 1.107 2008-11-13 20:29:43 y32kn Exp $ * @@ -2131,9 +2131,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) * icom_set_ctcss_tone * Assumes rig!=NULL, rig->state.priv!=NULL * - * Warning! This is untested stuff! May work at least on 756PRO and IC746. - * Please owners report to me , thanks. --SF - Works for 746 pro and should work for 756 xx and 7800 + * Works for 746 pro and should work for 756 xx and 7800 */ int icom_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) { @@ -2144,16 +2142,6 @@ int icom_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) caps = rig->caps; - /* - * I don't have documentation for this function, - * and I can't experiment (no hardware), so let's guess. - * Most probably, it might be the index of the CTCSS subaudible - * tone, and not the tone itself, starting from zero. - * - * Something in the range of 00..51, BCD big endian 4 nibbles - * Please someone let me know if it works this way. --SF - * No. sent directly as be nibbles with frequency same format as internal kh - */ for (i = 0; caps->ctcss_list[i] != 0 && i<52; i++) { if (caps->ctcss_list[i] == tone) break; @@ -2161,7 +2149,9 @@ int icom_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) if (caps->ctcss_list[i] != tone) return -RIG_EINVAL; - tone_len = 1; + /* Sent as frequency in tenth of Hz */ + + tone_len = 3; to_bcd_be(tonebuf, tone, tone_len*2); retval = icom_transaction(rig, C_SET_TONE, S_TONE_RPTR, @@ -2191,10 +2181,6 @@ int icom_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) caps = rig->caps; - /* - * see icom_set_ctcss for discussion on the status! - */ - retval = icom_transaction(rig, C_SET_TONE, S_TONE_RPTR, NULL, 0, tonebuf, &tone_len); if (retval != RIG_OK) @@ -2224,9 +2210,6 @@ int icom_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) /* * icom_set_ctcss_sql * Assumes rig!=NULL, rig->state.priv!=NULL - * - * Warning! This is untested stuff! May work at least on 756PRO and IC746. - * Please owners report to me , thanks. --SF */ int icom_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) { @@ -2237,10 +2220,6 @@ int icom_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) caps = rig->caps; - /* - * see icom_set_ctcss for discussion on the untested status! - */ - for (i = 0; caps->ctcss_list[i] != 0 && i<52; i++) { if (caps->ctcss_list[i] == tone) break; @@ -2248,7 +2227,9 @@ int icom_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) if (caps->ctcss_list[i] != tone) return -RIG_EINVAL; - tone_len = 1; + /* Sent as frequency in tenth of Hz */ + + tone_len = 3; to_bcd_be(tonebuf, tone, tone_len*2); retval = icom_transaction(rig, C_SET_TONE, S_TONE_SQL, @@ -2278,10 +2259,6 @@ int icom_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone) caps = rig->caps; - /* - * see icom_set_ctcss for discussion on the untested status! - */ - retval = icom_transaction(rig, C_SET_TONE, S_TONE_SQL, NULL, 0, tonebuf, &tone_len); if (retval != RIG_OK) @@ -2307,6 +2284,81 @@ int icom_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone) return -RIG_EPROTO; } +/* + * icom_set_dcs_code + * Assumes rig!=NULL, rig->state.priv!=NULL + */ +int icom_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code) +{ + const struct rig_caps *caps; + unsigned char codebuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN]; + int code_len, ack_len=sizeof(ackbuf), retval; + int i; + + caps = rig->caps; + + for (i = 0; caps->dcs_list[i] != 0 && i<104; i++) { + if (caps->dcs_list[i] == code) + break; + } + if (caps->dcs_list[i] != code) + return -RIG_EINVAL; + + code_len = 3; + to_bcd_be(codebuf, code, code_len*2); + + retval = icom_transaction(rig, C_SET_TONE, S_TONE_DTCS, + codebuf, code_len, ackbuf, &ack_len); + if (retval != RIG_OK) + return retval; + + if (ack_len != 1 || ackbuf[0] != ACK) { + rig_debug(RIG_DEBUG_ERR,"icom_set_dcs_code: ack NG (%#.2x), " + "len=%d\n", ackbuf[0], ack_len); + return -RIG_ERJCTED; + } + + return RIG_OK; +} + +/* + * icom_get_dcs_code + * Assumes rig!=NULL, rig->state.priv!=NULL + */ +int icom_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code) +{ + const struct rig_caps *caps; + unsigned char codebuf[MAXFRAMELEN]; + int code_len, retval; + int i; + + caps = rig->caps; + + retval = icom_transaction(rig, C_SET_TONE, S_TONE_DTCS, NULL, 0, + codebuf, &code_len); + if (retval != RIG_OK) + return retval; + + /* cn,sc,data*3 */ + if (code_len != 5) { + rig_debug(RIG_DEBUG_ERR,"icom_get_dcs_code: ack NG (%#.2x), " + "len=%d\n", codebuf[0], code_len); + return -RIG_ERJCTED; + } + + code_len -= 2; + *code = from_bcd_be(codebuf+2, code_len*2); + + /* check this code exists. That's better than nothing. */ + for (i = 0; caps->dcs_list[i] != 0 && i<104; i++) { + if (caps->dcs_list[i] == *code) + return RIG_OK; + } + + rig_debug(RIG_DEBUG_ERR,"icom_get_dcs_code: DTCS NG " + "(%#.2x)\n", codebuf[2]); + return -RIG_EPROTO; +} /* * icom_set_powerstat diff --git a/icom/icom.h b/icom/icom.h index a72ad7fb1..f39c3045d 100644 --- a/icom/icom.h +++ b/icom/icom.h @@ -1,6 +1,6 @@ /* * Hamlib CI-V backend - main header - * Copyright (c) 2000-2004 by Stephane Fillod + * Copyright (c) 2000-2009 by Stephane Fillod * * $Id: icom.h,v 1.77 2008-11-13 20:29:43 y32kn Exp $ * @@ -31,7 +31,7 @@ #include #endif -#define BACKEND_VER "0.4" +#define BACKEND_VER "0.5" /* * defines used by comp_cal_str in rig.c @@ -108,8 +108,8 @@ struct icom_priv_caps { void (*i2r_mode)(RIG *rig, unsigned char md, int pd, rmode_t *mode, pbwidth_t *width); /*< backend specific code to convert response - tokes to bandwidth and - mdoe */ + tokens to bandwidth and + mode */ }; @@ -164,6 +164,8 @@ int icom_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone); int icom_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone); int icom_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone); int icom_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone); +int icom_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code); +int icom_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code); int icom_set_bank(RIG *rig, vfo_t vfo, int bank); int icom_set_mem(RIG *rig, vfo_t vfo, int ch); int icom_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);