Fixed CWPITCH function on IC-R75 to use 'set mode data' command. Added level granularity steps

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1826 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.3
Mark J. Fine 2004-08-27 01:49:38 +00:00
rodzic 4e38224cad
commit 3fd5d8f272
3 zmienionych plików z 46 dodań i 29 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib CI-V backend - main file * Hamlib CI-V backend - main file
* Copyright (c) 2000-2004 by Stephane Fillod * Copyright (c) 2000-2004 by Stephane Fillod
* *
* $Id: icom.c,v 1.87 2004-08-21 23:53:39 fillods Exp $ * $Id: icom.c,v 1.88 2004-08-27 01:49:38 fineware Exp $
* *
* This library is free software; you can redistribute it and/or modify * This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as * it under the terms of the GNU Library General Public License as
@ -452,7 +452,7 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
struct icom_priv_data *priv; struct icom_priv_data *priv;
struct rig_state *rs; struct rig_state *rs;
unsigned char ackbuf[MAXFRAMELEN]; unsigned char ackbuf[MAXFRAMELEN];
unsigned char icmode; unsigned char icmode;
signed char icmode_ext; signed char icmode_ext;
int ack_len, retval, err; int ack_len, retval, err;
@ -614,16 +614,13 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
case RIG_LEVEL_NR: case RIG_LEVEL_NR:
icom_val = val.f * 240; icom_val = val.f * 240;
break; break;
case RIG_LEVEL_CWPITCH:
icom_val = ((float)val.i - 300.0) / 600.0 * 255;
break;
case RIG_LEVEL_PBT_IN: case RIG_LEVEL_PBT_IN:
case RIG_LEVEL_PBT_OUT: case RIG_LEVEL_PBT_OUT:
icom_val = (val.f / 10.0) + 128; icom_val = (val.f / 10.0) + 128;
if (icom_val > 255) if (icom_val > 255)
icom_val = 255; icom_val = 255;
break; break;
default: default:
break; break;
} }
} }
@ -700,6 +697,14 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
case RIG_LEVEL_CWPITCH: case RIG_LEVEL_CWPITCH:
lvl_cn = C_CTL_LVL; lvl_cn = C_CTL_LVL;
lvl_sc = S_LVL_CWPITCH; lvl_sc = S_LVL_CWPITCH;
/* use 'set mode' call for CWPITCH on IC-R75*/
if (rig->caps->rig_model == RIG_MODEL_ICR75) {
lvl_cn = C_CTL_MEM;
lvl_sc = S_MEM_MODE_SLCT;
lvl_len = 3;
lvlbuf[0] = S_PRM_CWPITCH;
to_bcd_be(lvlbuf+1, (long long)icom_val, 4);
}
break; break;
case RIG_LEVEL_RFPOWER: case RIG_LEVEL_RFPOWER:
lvl_cn = C_CTL_LVL; lvl_cn = C_CTL_LVL;
@ -776,8 +781,8 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{ {
struct icom_priv_data *priv; struct icom_priv_data *priv;
struct rig_state *rs; struct rig_state *rs;
unsigned char lvlbuf[MAXFRAMELEN]; unsigned char lvlbuf[MAXFRAMELEN], lvl2buf[MAXFRAMELEN];
int lvl_len; int lvl_len, lvl2_len;
int lvl_cn, lvl_sc; /* Command Number, Subcommand */ int lvl_cn, lvl_sc; /* Command Number, Subcommand */
int icom_val; int icom_val;
int cmdhead; int cmdhead;
@ -786,7 +791,7 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
rs = &rig->state; rs = &rig->state;
priv = (struct icom_priv_data*)rs->priv; priv = (struct icom_priv_data*)rs->priv;
lvl2_len = 0;
/* Optimize: /* Optimize:
* sort the switch cases with the most frequent first * sort the switch cases with the most frequent first
*/ */
@ -843,6 +848,13 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_CWPITCH: case RIG_LEVEL_CWPITCH:
lvl_cn = C_CTL_LVL; lvl_cn = C_CTL_LVL;
lvl_sc = S_LVL_CWPITCH; lvl_sc = S_LVL_CWPITCH;
/* use 'set mode' call for CWPITCH on IC-R75*/
if (rig->caps->rig_model == RIG_MODEL_ICR75) {
lvl_cn = C_CTL_MEM;
lvl_sc = S_MEM_MODE_SLCT;
lvl2_len = 1;
lvl2buf[0] = S_PRM_CWPITCH;
}
break; break;
case RIG_LEVEL_RFPOWER: case RIG_LEVEL_RFPOWER:
lvl_cn = C_CTL_LVL; lvl_cn = C_CTL_LVL;
@ -893,7 +905,8 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return -RIG_EINVAL; return -RIG_EINVAL;
} }
retval = icom_transaction (rig, lvl_cn, lvl_sc, NULL, 0, /* use lvl2buf and lvl2_len for 'set mode' subcommand */
retval = icom_transaction (rig, lvl_cn, lvl_sc, lvl2buf, lvl2_len,
lvlbuf, &lvl_len); lvlbuf, &lvl_len);
if (retval != RIG_OK) if (retval != RIG_OK)
return retval; return retval;
@ -903,6 +916,11 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
*/ */
cmdhead = (lvl_sc == -1) ? 1:2; cmdhead = (lvl_sc == -1) ? 1:2;
lvl_len -= cmdhead; lvl_len -= cmdhead;
/* back off one char since first char in buffer is now 'set mode' subcommand */
if ((rig->caps->rig_model == RIG_MODEL_ICR75)&&(level==RIG_LEVEL_CWPITCH)){
cmdhead = 3;
lvl_len--;
}
if (lvlbuf[0] != ACK && lvlbuf[0] != lvl_cn) { if (lvlbuf[0] != ACK && lvlbuf[0] != lvl_cn) {
rig_debug(RIG_DEBUG_ERR,"icom_get_level: ack NG (%#.2x), " rig_debug(RIG_DEBUG_ERR,"icom_get_level: ack NG (%#.2x), "
@ -955,21 +973,18 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_NR: case RIG_LEVEL_NR:
val->f = (float)icom_val / 240; val->f = (float)icom_val / 240;
break; break;
case RIG_LEVEL_CWPITCH:
val->i = ((float)icom_val / 255.0 * 600.0) + 300.0;
break;
case RIG_LEVEL_PBT_IN: case RIG_LEVEL_PBT_IN:
case RIG_LEVEL_PBT_OUT: case RIG_LEVEL_PBT_OUT:
if (icom_val == 255) if (icom_val == 255)
val->f = 1280.0; val->f = 1280.0;
else else
val->f = (float)(icom_val - 128) * 10.0; val->f = (float)(icom_val - 128) * 10.0;
break; break;
default: default:
break; break;
} }
} }
rig_debug(RIG_DEBUG_TRACE,"icom_get_level: %d %d %d %f\n", lvl_len, rig_debug(RIG_DEBUG_TRACE,"icom_get_level: %d %d %d %f\n", lvl_len,
icom_val, val->i, val->f); icom_val, val->i, val->f);
@ -2282,16 +2297,16 @@ int icom_get_powerstat(RIG *rig, powerstat_t *status)
/* r75 has no way to get power status, so fake it */ /* r75 has no way to get power status, so fake it */
if (rig->caps->rig_model == RIG_MODEL_ICR75) { if (rig->caps->rig_model == RIG_MODEL_ICR75) {
retval = icom_transaction(rig, C_RD_MODE, -1, NULL, 0, retval = icom_transaction(rig, C_RD_MODE, -1, NULL, 0,
ackbuf, &ack_len); ackbuf, &ack_len);
if (retval != RIG_OK) if (retval != RIG_OK)
return retval; return retval;
*status = ((ack_len == 3)&&(ackbuf[0] == C_RD_MODE)) ? *status = ((ack_len == 3)&&(ackbuf[0] == C_RD_MODE)) ?
RIG_POWER_ON : RIG_POWER_OFF; RIG_POWER_ON : RIG_POWER_OFF;
return RIG_OK; return RIG_OK;
} }
retval = icom_transaction(rig, C_SET_PWR, -1, NULL, 0, retval = icom_transaction(rig, C_SET_PWR, -1, NULL, 0,
ackbuf, &ack_len); ackbuf, &ack_len);
if (retval != RIG_OK) if (retval != RIG_OK)
@ -2707,8 +2722,8 @@ DECLARE_PROBERIG_BACKEND(icom)
/* /*
* try all possible addresses on the CI-V bus * try all possible addresses on the CI-V bus
* FIXME: actualy, old rigs do not support C_RD_TRXID cmd! * FIXME: actualy, old rigs do not support C_RD_TRXID cmd!
* Try to be smart, and deduce model depending * Try to be smart, and deduce model depending
* on freq range, return address, and * on freq range, return address, and
* available commands. * available commands.
*/ */
for (civ_addr=0x01; civ_addr<=0x7f; civ_addr++) { for (civ_addr=0x01; civ_addr<=0x7f; civ_addr++) {

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib CI-V backend - defines for the ICOM "CI-V" interface. * Hamlib CI-V backend - defines for the ICOM "CI-V" interface.
* Copyright (c) 2000-2002 by Stephane Fillod * Copyright (c) 2000-2002 by Stephane Fillod
* *
* $Id: icom_defs.h,v 1.15 2004-08-21 23:53:39 fillods Exp $ * $Id: icom_defs.h,v 1.16 2004-08-27 01:49:38 fineware Exp $
* *
* This library is free software; you can redistribute it and/or modify * This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as * it under the terms of the GNU Library General Public License as
@ -313,6 +313,7 @@
* C_CTL_MODE Misc CI-V Mode settings * C_CTL_MODE Misc CI-V Mode settings
*/ */
#define S_PRM_BEEP 0x02 #define S_PRM_BEEP 0x02
#define S_PRM_CWPITCH 0x10
#define S_PRM_LANG 0x15 #define S_PRM_LANG 0x15
#define S_PRM_BACKLT 0x21 #define S_PRM_BACKLT 0x21
#define S_PRM_SLEEP 0x32 #define S_PRM_SLEEP 0x32

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib CI-V backend - description of IC-R75 * Hamlib CI-V backend - description of IC-R75
* Copyright (c) 2000-2004 by Stephane Fillod * Copyright (c) 2000-2004 by Stephane Fillod
* *
* $Id: icr75.c,v 1.3 2004-08-21 23:53:39 fillods Exp $ * $Id: icr75.c,v 1.4 2004-08-27 01:49:38 fineware Exp $
* *
* This library is free software; you can redistribute it and/or modify * This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as * it under the terms of the GNU Library General Public License as
@ -130,9 +130,10 @@ const struct rig_caps icr75_caps = {
.has_set_parm = RIG_PARM_SET(ICR75_PARM_ALL), .has_set_parm = RIG_PARM_SET(ICR75_PARM_ALL),
.level_gran = { .level_gran = {
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } }, [LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
[LVL_PBT_IN] = { .min = { .f = -1280 }, .max = { .f = +1280 } }, [LVL_PBT_IN] = { .min = { .f = -1280 }, .max = { .f = +1280 }, .step = { .f = 15 } },
[LVL_PBT_OUT] = { .min = { .f = -1280 }, .max = { .f = +1280 } }, [LVL_PBT_OUT] = { .min = { .f = -1280 }, .max = { .f = +1280 }, .step = { .f = 15 } },
[LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 900 } }, [LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 900 }, .step = { .i = 10 } },
[LVL_NR] = { .min = { .f = 0.0 }, .max = { .f = 1.0 }, .step = { .f = 0.066666667 } },
}, },
.parm_gran = { .parm_gran = {
[PARM_APO] = { .min = { .i = 1 }, .max = { .i = 1439} }, [PARM_APO] = { .min = { .i = 1 }, .max = { .i = 1439} },