kopia lustrzana https://github.com/Hamlib/Hamlib
fix read_string return code bug, query only one channel memory content in aor_get_channel, and parse only declared fields in mem_caps
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2002 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.5
rodzic
653b51c8cb
commit
fe3eb0b51f
47
aor/aor.c
47
aor/aor.c
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib AOR backend - main file
|
* Hamlib AOR backend - main file
|
||||||
* Copyright (c) 2000-2005 by Stephane Fillod
|
* Copyright (c) 2000-2005 by Stephane Fillod
|
||||||
*
|
*
|
||||||
* $Id: aor.c,v 1.33 2005-04-09 16:33:42 fillods Exp $
|
* $Id: aor.c,v 1.34 2005-04-10 20:59:30 fillods 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
|
||||||
|
@ -88,7 +88,11 @@ int aor_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *dat
|
||||||
if (!data || !data_len)
|
if (!data || !data_len)
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
|
|
||||||
*data_len = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM));
|
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM));
|
||||||
|
if (retval < 0)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
*data_len = retval;
|
||||||
|
|
||||||
if (*data_len < BUFSZ)
|
if (*data_len < BUFSZ)
|
||||||
data[*data_len] = '\0';
|
data[*data_len] = '\0';
|
||||||
|
@ -683,7 +687,7 @@ int aor_get_channel(RIG *rig, channel_t *chan)
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
cmd_len = sprintf(aorcmd, "MA" EOM);
|
cmd_len = sprintf(aorcmd, "RX" EOM);
|
||||||
retval = aor_transaction (rig, aorcmd, cmd_len, chanbuf, &chan_len);
|
retval = aor_transaction (rig, aorcmd, cmd_len, chanbuf, &chan_len);
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -696,35 +700,43 @@ int aor_get_channel(RIG *rig, channel_t *chan)
|
||||||
basep = chanbuf;
|
basep = chanbuf;
|
||||||
|
|
||||||
/* pass */
|
/* pass */
|
||||||
|
if (mem_caps->flags) {
|
||||||
tagp = strstr(basep, "MP");
|
tagp = strstr(basep, "MP");
|
||||||
if (!tagp && mem_caps->flags) {
|
if (!tagp) {
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: no MP in returned string: '%s'\n",
|
rig_debug(RIG_DEBUG_WARN, "%s: no MP in returned string: '%s'\n",
|
||||||
__FUNCTION__, chanbuf);
|
__FUNCTION__, chanbuf);
|
||||||
return -RIG_EPROTO;
|
return -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
chan->flags = tagp[2] == '0' ? 0 : RIG_CHFLAG_SKIP;
|
chan->flags = tagp[2] == '0' ? 0 : RIG_CHFLAG_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
/* frequency */
|
/* frequency */
|
||||||
|
if (mem_caps->freq) {
|
||||||
tagp = strstr(basep, "RF");
|
tagp = strstr(basep, "RF");
|
||||||
if (!tagp && mem_caps->freq) {
|
if (!tagp) {
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: no RF in returned string: '%s'\n",
|
rig_debug(RIG_DEBUG_WARN, "%s: no RF in returned string: '%s'\n",
|
||||||
__FUNCTION__, chanbuf);
|
__FUNCTION__, chanbuf);
|
||||||
return -RIG_EPROTO;
|
return -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
sscanf(tagp+2,"%"SCNfreq, &chan->freq);
|
sscanf(tagp+2,"%"SCNfreq, &chan->freq);
|
||||||
|
}
|
||||||
|
|
||||||
/* channel desc */
|
/* channel desc */
|
||||||
|
if (mem_caps->tuning_step) {
|
||||||
tagp = strstr(basep, "ST");
|
tagp = strstr(basep, "ST");
|
||||||
if (!tagp && mem_caps->tuning_step) {
|
if (!tagp) {
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: no ST in returned string: '%s'\n",
|
rig_debug(RIG_DEBUG_WARN, "%s: no ST in returned string: '%s'\n",
|
||||||
__FUNCTION__, chanbuf);
|
__FUNCTION__, chanbuf);
|
||||||
return -RIG_EPROTO;
|
return -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
sscanf(tagp+2,"%d", (int*)&chan->tuning_step);
|
sscanf(tagp+2,"%d", (int*)&chan->tuning_step);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* mode and width */
|
/* mode and width */
|
||||||
|
if (mem_caps->mode && mem_caps->width) {
|
||||||
tagp = strstr(basep, "MD");
|
tagp = strstr(basep, "MD");
|
||||||
if (!tagp && mem_caps->mode && mem_caps->width) {
|
if (!tagp && mem_caps->mode && mem_caps->width) {
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: no MD in returned string: '%s'\n",
|
rig_debug(RIG_DEBUG_WARN, "%s: no MD in returned string: '%s'\n",
|
||||||
|
@ -735,21 +747,39 @@ int aor_get_channel(RIG *rig, channel_t *chan)
|
||||||
retval = parse_aor_mode(rig, tagp[2], &chan->mode, &chan->width);
|
retval = parse_aor_mode(rig, tagp[2], &chan->mode, &chan->width);
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
return retval;
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* auto-mode */
|
||||||
|
if (mem_caps->funcs&RIG_FUNC_ABM) {
|
||||||
|
tagp = strstr(basep, "AU");
|
||||||
|
if (!tagp) {
|
||||||
|
rig_debug(RIG_DEBUG_WARN, "%s: no AU in returned string: '%s'\n",
|
||||||
|
__FUNCTION__, chanbuf);
|
||||||
|
return -RIG_EPROTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
chan->funcs = tagp[2] == '0' ? 0 : RIG_FUNC_ABM;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* attenuator */
|
/* attenuator */
|
||||||
|
if (mem_caps->levels&LVL_ATT) {
|
||||||
tagp = strstr(basep, "AT");
|
tagp = strstr(basep, "AT");
|
||||||
if (!tagp && (mem_caps->levels&LVL_ATT)) {
|
if (!tagp) {
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: no AT in returned string: '%s'\n",
|
rig_debug(RIG_DEBUG_WARN, "%s: no AT in returned string: '%s'\n",
|
||||||
__FUNCTION__, chanbuf);
|
__FUNCTION__, chanbuf);
|
||||||
return -RIG_EPROTO;
|
return -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
chan->levels[LVL_ATT].i = tagp[2] == '0' ? 0 :
|
chan->levels[LVL_ATT].i = tagp[2] == '0' ? 0 :
|
||||||
rig->caps->attenuator[tagp[2] - '0' - 1];
|
rig->caps->attenuator[tagp[2] - '0' - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* channel desc */
|
/* channel desc */
|
||||||
|
if (mem_caps->channel_desc) {
|
||||||
tagp = strstr(basep, "TM");
|
tagp = strstr(basep, "TM");
|
||||||
if (!tagp && mem_caps->channel_desc) {
|
if (!tagp) {
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: no TM in returned string: '%s'\n",
|
rig_debug(RIG_DEBUG_WARN, "%s: no TM in returned string: '%s'\n",
|
||||||
__FUNCTION__, chanbuf);
|
__FUNCTION__, chanbuf);
|
||||||
return -RIG_EPROTO;
|
return -RIG_EPROTO;
|
||||||
|
@ -757,6 +787,7 @@ int aor_get_channel(RIG *rig, channel_t *chan)
|
||||||
|
|
||||||
strncpy(chan->channel_desc, tagp+2, 12);
|
strncpy(chan->channel_desc, tagp+2, 12);
|
||||||
chan->channel_desc[12] = '\0';
|
chan->channel_desc[12] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
|
|
Ładowanie…
Reference in New Issue