Added checking of return string from rig on set (non-retrieval) commands.

Added code for COMP function.
Added alinco_set_parm & tweaked dx77 capabilities.


git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1704 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.1
Ben Coleman, NJ8J 2004-03-15 04:02:08 +00:00
rodzic 95eb2712dd
commit c2aea00644
3 zmienionych plików z 51 dodań i 11 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Alinco backend - main file
* Copyright (c) 2001-2003 by Stephane Fillod
*
* $Id: alinco.c,v 1.21 2004-02-15 00:30:29 fillods Exp $
* $Id: alinco.c,v 1.22 2004-03-15 04:02:08 nj8j Exp $
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
@ -119,9 +119,16 @@ int alinco_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *
/* if (retval <= 3)
return retval; */
/* no data expected, TODO: flush input? */
if (!data || !data_len)
return 0;
/* no data expected, check for OK returned */
if (!data || !data_len) {
retval = read_string(&rs->rigport, echobuf, BUFSZ, LF, strlen(LF));
retval -= 2;
echobuf[retval] = 0;
if (strcmp(echobuf, "OK") == 0)
return RIG_OK;
else
return RIG_ERJCTED;
}
*data_len = read_string(&rs->rigport, data, BUFSZ, LF, strlen(LF));
@ -488,6 +495,9 @@ int alinco_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
cmd_len = sprintf(cmdbuf, AL CMD_NB "%d" EOM, status?1:0);
return alinco_transaction (rig, cmdbuf, cmd_len, NULL, NULL);
case RIG_FUNC_COMP:
cmd_len = sprintf(cmdbuf, AL CMD_SDATA "C%d" EOM, status?1:0);
return alinco_transaction (rig, cmdbuf, cmd_len, NULL, NULL);
case RIG_FUNC_MON:
cmd_len = sprintf(cmdbuf, AL CMD_MON "%d" EOM, status?1:0);
@ -690,6 +700,35 @@ int alinco_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return RIG_OK;
}
/*
* alinco_set_parm
*/
int alinco_set_parm(RIG *rig, setting_t parm, value_t val) {
int cmd_len;
char cmdbuf[BUFSZ];
/* Optimize:
* sort the switch cases with the most frequent first
*/
switch (parm) {
case RIG_PARM_BEEP:
rig_debug(RIG_DEBUG_ERR,"val is %d\n", val.i);
cmd_len = sprintf(cmdbuf, AL CMD_SDATA "A%d" EOM, val.i?1:0);
return alinco_transaction(rig, cmdbuf, cmd_len, NULL, NULL);
case RIG_PARM_BACKLIGHT:
rig_debug(RIG_DEBUG_ERR,"val is %0f\n", val.f);
cmd_len = sprintf(cmdbuf, AL CMD_SDATA "O%d" EOM, (int)(val.f * 5));
return alinco_transaction(rig, cmdbuf, cmd_len, NULL, NULL);
default:
rig_debug(RIG_DEBUG_ERR,"Unsupported set_parm %d\n", parm);
return -RIG_EINVAL;
}
return RIG_OK;
}
/*
* alinco_set_ctcss_tone
* Assumes rig!=NULL, rig->caps->ctcss_list != NULL

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Alinco backend - main header
* Copyright (c) 2001-2003 by Stephane Fillod
*
* $Id: alinco.h,v 1.13 2003-11-16 17:14:42 fillods Exp $
* $Id: alinco.h,v 1.14 2004-03-15 04:02:08 nj8j Exp $
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
@ -40,8 +40,8 @@ int alinco_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
int alinco_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status);
int alinco_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
int alinco_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
int alinco_set_parm(RIG *rig, vfo_t vfo, setting_t parm, value_t val);
int alinco_get_parm(RIG *rig, vfo_t vfo, setting_t parm, value_t *val);
int alinco_set_parm(RIG *rig, setting_t parm, value_t val);
int alinco_get_parm(RIG *rig, setting_t parm, value_t *val);
int alinco_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone);
int alinco_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit);
int alinco_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt);

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Alinco backend - DX77 description
* Copyright (c) 2001-2003 by Stephane Fillod
*
* $Id: dx77.c,v 1.10 2004-02-15 00:30:29 fillods Exp $
* $Id: dx77.c,v 1.11 2004-03-15 04:02:08 nj8j Exp $
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
@ -35,7 +35,7 @@
#define DX77_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM)
#define DX77_AM_TX_MODES RIG_MODE_AM
#define DX77_FUNC (RIG_FUNC_FAGC|RIG_FUNC_NB|RIG_FUNC_TONE|RIG_FUNC_COMP)
#define DX77_FUNC (RIG_FUNC_FAGC|RIG_FUNC_NB|RIG_FUNC_TONE)
#define DX77_LEVEL_ALL (RIG_LEVEL_SQLSTAT|RIG_LEVEL_RAWSTR|RIG_LEVEL_RFPOWER|RIG_LEVEL_KEYSPD|RIG_LEVEL_BKINDL|RIG_LEVEL_CWPITCH)
@ -98,10 +98,10 @@ const struct rig_caps dx77_caps = {
.retry = 3,
.has_get_func = DX77_FUNC,
.has_set_func = DX77_FUNC|RIG_FUNC_MON,
.has_set_func = DX77_FUNC|RIG_FUNC_MON|RIG_FUNC_COMP,
.has_get_level = DX77_LEVEL_ALL,
.has_set_level = RIG_LEVEL_SET(DX77_LEVEL_ALL),
.has_get_parm = DX77_PARM_ALL,
.has_get_parm = RIG_PARM_NONE,
.has_set_parm = RIG_PARM_SET(DX77_PARM_ALL),
.level_gran = {
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
@ -181,6 +181,7 @@ const struct rig_caps dx77_caps = {
.get_dcd = alinco_get_dcd,
.set_func = alinco_set_func,
.get_func = alinco_get_func,
.set_parm = alinco_set_parm,
.set_level = alinco_set_level,
.get_level = alinco_get_level,
.set_mem = alinco_set_mem,