* fixed a bug in rig_init

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@458 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.1.1
Stéphane Fillod, F8CFE 2001-04-24 19:55:29 +00:00
rodzic 2fa640d629
commit 29166df172
1 zmienionych plików z 73 dodań i 18 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
Copyright (C) 2000 Stephane Fillod and Frank Singleton Copyright (C) 2000 Stephane Fillod and Frank Singleton
This file is part of the hamlib package. This file is part of the hamlib package.
$Id: rig.c,v 1.24 2001-03-04 23:06:30 f4cfe Exp $ $Id: rig.c,v 1.25 2001-04-24 19:55:29 f4cfe Exp $
Hamlib is free software; you can redistribute it and/or modify it Hamlib is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by under the terms of the GNU General Public License as published by
@ -280,10 +280,12 @@ RIG *rig_init(rig_model_t rig_model)
break; break;
} }
memcpy(rs->preamp, caps->preamp, MAXDBLSTSIZ); memcpy(rs->preamp, caps->preamp, sizeof(int)*MAXDBLSTSIZ);
memcpy(rs->attenuator, caps->attenuator, MAXDBLSTSIZ); memcpy(rs->attenuator, caps->attenuator, sizeof(int)*MAXDBLSTSIZ);
memcpy(rs->tuning_steps, caps->tuning_steps, TSLSTSIZ); memcpy(rs->tuning_steps, caps->tuning_steps,
memcpy(rs->filters, caps->filters, FLTLSTSIZ); sizeof(struct tuning_step_list)*TSLSTSIZ);
memcpy(rs->filters, caps->filters,
sizeof(struct filter_list)*FLTLSTSIZ);
rs->has_get_func = caps->has_get_func; rs->has_get_func = caps->has_get_func;
rs->has_set_func = caps->has_set_func; rs->has_set_func = caps->has_set_func;
@ -691,13 +693,21 @@ int rig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
return retcode; return retcode;
} }
#if 0 /**
/* * rig_passband_normal - get the normal passband of a mode
* purpose (example): * @rig: The rig handle
* rig_set_mode(my_rig, RIG_MODE_LSB, rig_passband_narrow(my_rig, RIG_MODE_LSB)) * @mode: The mode to get the passband
* *
* FIXME: returning 0 when an error occurs, or mode not found is no good! * The rig_passband_normal() function returns the normal (default)
* passband for the given the @mode.
*
* RETURN VALUE: The rig_passband_normal() function returns
* the passband in Hz if the operation has been sucessful,
* or a 0 if an error occured (passband not found, whatever).
*
* SEE ALSO: rig_passband_narrow(), rig_passband_wide()
*/ */
pbwidth_t rig_passband_normal(RIG *rig, rmode_t mode) pbwidth_t rig_passband_normal(RIG *rig, rmode_t mode)
{ {
const struct rig_state *rs; const struct rig_state *rs;
@ -708,12 +718,33 @@ pbwidth_t rig_passband_normal(RIG *rig, rmode_t mode)
rs = &rig->state; rs = &rig->state;
for (i=0; i<FLTLSTSIZ && rs->filters[i].modes; i++) for (i=0; i<FLTLSTSIZ && rs->filters[i].modes; i++) {
if (rs->filters[i].modes & mode) if (rs->filters[i].modes & mode) {
return rs->filters[i].width; return rs->filters[i].width;
}
}
return 0; return 0;
} }
/**
* rig_passband_narrow - get the narrow passband of a mode
* @rig: The rig handle
* @mode: The mode to get the passband
*
* The rig_passband_narrow() function returns the narrow (closest)
* passband for the given the @mode.
*
* EXAMPLE: rig_set_mode(my_rig, RIG_MODE_LSB,
* rig_passband_narrow(my_rig, RIG_MODE_LSB) );
*
* RETURN VALUE: The rig_passband_narrow() function returns
* the passband in Hz if the operation has been sucessful,
* or a 0 if an error occured (passband not found, whatever).
*
* SEE ALSO: rig_passband_normal(), rig_passband_wide()
*/
pbwidth_t rig_passband_narrow(RIG *rig, rmode_t mode) pbwidth_t rig_passband_narrow(RIG *rig, rmode_t mode)
{ {
const struct rig_state *rs; const struct rig_state *rs;
@ -725,19 +756,40 @@ pbwidth_t rig_passband_narrow(RIG *rig, rmode_t mode)
rs = &rig->state; rs = &rig->state;
for (i=0; i<FLTLSTSIZ-1 && rs->filters[i].modes; i++) for (i=0; i<FLTLSTSIZ-1 && rs->filters[i].modes; i++) {
if (rs->filters[i].modes & mode) { if (rs->filters[i].modes & mode) {
normal = rs->filters[i].width; normal = rs->filters[i].width;
for (i++; i<FLTLSTSIZ && rs->filters[i].modes; i++) { for (i++; i<FLTLSTSIZ && rs->filters[i].modes; i++) {
if ((rs->filters[i].modes & mode) && if ((rs->filters[i].modes & mode) &&
(rs->filters[i].width < normal)) (rs->filters[i].width < normal)) {
return rs->filters[i].width; return rs->filters[i].width;
}
} }
return 0; return 0;
} }
}
return 0; return 0;
} }
/**
* rig_passband_wide - get the wide passband of a mode
* @rig: The rig handle
* @mode: The mode to get the passband
*
* The rig_passband_wide() function returns the wide (default)
* passband for the given the @mode.
*
* EXAMPLE: rig_set_mode(my_rig, RIG_MODE_AM,
* rig_passband_wide(my_rig, RIG_MODE_AM) );
*
* RETURN VALUE: The rig_passband_wide() function returns
* the passband in Hz if the operation has been sucessful,
* or a 0 if an error occured (passband not found, whatever).
*
* SEE ALSO: rig_passband_narrow(), rig_passband_normal()
*/
pbwidth_t rig_passband_wide(RIG *rig, rmode_t mode) pbwidth_t rig_passband_wide(RIG *rig, rmode_t mode)
{ {
const struct rig_state *rs; const struct rig_state *rs;
@ -749,19 +801,21 @@ pbwidth_t rig_passband_wide(RIG *rig, rmode_t mode)
rs = &rig->state; rs = &rig->state;
for (i=0; i<FLTLSTSIZ-1 && rs->filters[i].modes; i++) for (i=0; i<FLTLSTSIZ-1 && rs->filters[i].modes; i++) {
if (rs->filters[i].modes & mode) { if (rs->filters[i].modes & mode) {
normal = rs->filters[i].width; normal = rs->filters[i].width;
for (i++; i<FLTLSTSIZ && rs->filters[i].modes; i++) { for (i++; i<FLTLSTSIZ && rs->filters[i].modes; i++) {
if ((rs->filters[i].modes & mode) && if ((rs->filters[i].modes & mode) &&
(rs->filters[i].width > normal)) (rs->filters[i].width > normal)) {
return rs->filters[i].width; return rs->filters[i].width;
}
} }
return 0; return 0;
} }
}
return 0; return 0;
} }
#endif
/** /**
* rig_set_vfo - set the current VFO * rig_set_vfo - set the current VFO
@ -2702,7 +2756,8 @@ int rig_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
* rig_get_func - get the status of functions of the radio * rig_get_func - get the status of functions of the radio
* @rig: The rig handle * @rig: The rig handle
* @vfo: The target VFO * @vfo: The target VFO
* @func: The location where to store the function status * @func: The functions to get the status
* @status: The location where to store the function status
* *
* The rig_get_func() function retrieves the status of functions * The rig_get_func() function retrieves the status of functions
* of the radio. Only the function bits set to 1 will be queried. * of the radio. Only the function bits set to 1 will be queried.