* removed [sg]et_passband in favor of an enhanced [sg]et_mode which

includes the passband, since most rigs tie these parameters together
  quite often. For exemple, WFM is (RIG_MODE_FM,RIG_PASSBAND_WIDE) in Hamlib.
  Another set of functions will be needed to fine tune aditional
  frequency response/filters.


git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@280 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.1.0
Stéphane Fillod, F8CFE 2000-12-04 23:39:18 +00:00
rodzic 55a47c9c17
commit d0e751257d
9 zmienionych plików z 118 dodań i 154 usunięć

Wyświetl plik

@ -6,7 +6,7 @@
* via serial interface to an AOR scanner. * via serial interface to an AOR scanner.
* *
* *
* $Id: aor.c,v 1.1 2000-11-01 23:23:56 f4cfe Exp $ * $Id: aor.c,v 1.2 2000-12-04 23:39:17 f4cfe Exp $
* *
* *
* *
@ -159,17 +159,39 @@ int aor_get_freq(RIG *rig, freq_t *freq)
* aor_set_mode * aor_set_mode
* Assumes rig!=NULL * Assumes rig!=NULL
*/ */
int aor_set_mode(RIG *rig, rmode_t mode) int aor_set_mode(RIG *rig, rmode_t mode, pbwidth_t width)
{ {
unsigned char mdbuf[16],ackbuf[16]; unsigned char mdbuf[16],ackbuf[16];
int mdbuf_len,ack_len,aormode; int mdbuf_len,ack_len,aormode;
switch (mode) { switch (mode) {
case RIG_MODE_AM: aormode = MD_AM; break; case RIG_MODE_AM:
switch(width) {
case RIG_PASSBAND_NORMAL: aormode = MD_AM; break;
case RIG_PASSBAND_WIDE: aormode = MD_WAM; break;
case RIG_PASSBAND_NARROW: aormode = MD_NAM; break;
default:
rig_debug(RIG_DEBUG_ERR,
"aor_set_mode: unsupported passband %d %d\n",
mode, width);
return -RIG_EINVAL;
}
break;
case RIG_MODE_CW: aormode = MD_CW; break; case RIG_MODE_CW: aormode = MD_CW; break;
case RIG_MODE_USB: aormode = MD_USB; break; case RIG_MODE_USB: aormode = MD_USB; break;
case RIG_MODE_LSB: aormode = MD_LSB; break; case RIG_MODE_LSB: aormode = MD_LSB; break;
case RIG_MODE_FM: aormode = MD_NFM; break; case RIG_MODE_FM:
switch(width) {
case RIG_PASSBAND_NORMAL: aormode = MD_NFM; break;
case RIG_PASSBAND_WIDE: aormode = MD_WFM; break;
case RIG_PASSBAND_NARROW: aormode = MD_SFM; break;
default:
rig_debug(RIG_DEBUG_ERR,
"aor_set_mode: unsupported passband %d %d\n",
mode, width);
return -RIG_EINVAL;
}
break;
case RIG_MODE_RTTY: case RIG_MODE_RTTY:
default: default:
rig_debug(RIG_DEBUG_ERR,"aor_set_mode: unsupported mode %d\n", rig_debug(RIG_DEBUG_ERR,"aor_set_mode: unsupported mode %d\n",
@ -193,7 +215,7 @@ int aor_set_mode(RIG *rig, rmode_t mode)
* aor_get_mode * aor_get_mode
* Assumes rig!=NULL, mode!=NULL * Assumes rig!=NULL, mode!=NULL
*/ */
int aor_get_mode(RIG *rig, rmode_t *mode) int aor_get_mode(RIG *rig, rmode_t *mode, pbwidth_t *width)
{ {
unsigned char ackbuf[16]; unsigned char ackbuf[16];
int ack_len; int ack_len;
@ -207,12 +229,28 @@ int aor_get_mode(RIG *rig, rmode_t *mode)
return -RIG_ERJCTED; return -RIG_ERJCTED;
} }
*width = RIG_PASSBAND_NORMAL;
switch (ackbuf[0]) { switch (ackbuf[0]) {
case MD_AM: *mode = RIG_MODE_AM; break; case MD_AM: *mode = RIG_MODE_AM; break;
case MD_NAM:
*mode = RIG_MODE_AM;
*width = RIG_PASSBAND_NARROW;
break;
case MD_WAM:
*mode = RIG_MODE_AM;
*width = RIG_PASSBAND_WIDE;
break;
case MD_CW: *mode = RIG_MODE_CW; break; case MD_CW: *mode = RIG_MODE_CW; break;
case MD_USB: *mode = RIG_MODE_USB; break; case MD_USB: *mode = RIG_MODE_USB; break;
case MD_LSB: *mode = RIG_MODE_LSB; break; case MD_LSB: *mode = RIG_MODE_LSB; break;
case MD_NFM: *mode = RIG_MODE_FM; break; case MD_NFM: *mode = RIG_MODE_FM; break;
case MD_SFM:
*mode = RIG_MODE_FM;
*width = RIG_PASSBAND_NARROW;
break;
case MD_WFM: *mode = RIG_MODE_FM;
*width = RIG_PASSBAND_WIDE;
break;
default: default:
rig_debug(RIG_DEBUG_ERR,"aor_get_mode: unsupported mode %d\n", rig_debug(RIG_DEBUG_ERR,"aor_get_mode: unsupported mode %d\n",
ackbuf[0]); ackbuf[0]);

Wyświetl plik

@ -6,7 +6,7 @@
* via serial interface to an AOR scanner. * via serial interface to an AOR scanner.
* *
* *
* $Id: aor.h,v 1.1 2000-11-01 23:23:56 f4cfe Exp $ * $Id: aor.h,v 1.2 2000-12-04 23:39:17 f4cfe Exp $
* *
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -33,8 +33,8 @@ int aor_close(RIG *rig);
int aor_set_freq(RIG *rig, freq_t freq); int aor_set_freq(RIG *rig, freq_t freq);
int aor_get_freq(RIG *rig, freq_t *freq); int aor_get_freq(RIG *rig, freq_t *freq);
int aor_set_mode(RIG *rig, rmode_t mode); int aor_set_mode(RIG *rig, rmode_t mode, pbwidth_t width);
int aor_get_mode(RIG *rig, rmode_t *mode); int aor_get_mode(RIG *rig, rmode_t *mode, pbwidth_t *width);
int aor_set_ts(RIG *rig, unsigned long ts); int aor_set_ts(RIG *rig, unsigned long ts);
int aor_set_poweroff(RIG *rig); int aor_set_poweroff(RIG *rig);

Wyświetl plik

@ -6,7 +6,7 @@
* CI-V interface, used in serial communication to ICOM radios. * CI-V interface, used in serial communication to ICOM radios.
* *
* *
* $Id: frame.c,v 1.5 2000-11-01 23:21:47 f4cfe Exp $ * $Id: frame.c,v 1.6 2000-12-04 23:39:17 f4cfe Exp $
* *
* *
* *
@ -194,7 +194,10 @@ int read_icom_frame(FILE *stream, unsigned char rxbuffer[], int timeout)
} }
unsigned short hamlib2icom_mode(rmode_t mode) /*
* TODO: be more exhaustive
*/
unsigned short hamlib2icom_mode(rmode_t mode, pbwidth_t width)
{ {
int icmode, icmode_ext; int icmode, icmode_ext;
@ -206,24 +209,10 @@ unsigned short hamlib2icom_mode(rmode_t mode)
case RIG_MODE_USB: icmode = S_USB; break; case RIG_MODE_USB: icmode = S_USB; break;
case RIG_MODE_LSB: icmode = S_LSB; break; case RIG_MODE_LSB: icmode = S_LSB; break;
case RIG_MODE_RTTY: icmode = S_RTTY; break; case RIG_MODE_RTTY: icmode = S_RTTY; break;
case RIG_MODE_FM: icmode = S_FM; break; case RIG_MODE_FM:
#if 0 icmode = width==RIG_PASSBAND_WIDE?S_WFM:S_FM;
case RIG_MODE_WFM: icmode = S_WFM; break; icmode_ext = width==RIG_PASSBAND_NARROW?0x01:0x00;
break;
case RIG_MODE_NFM: icmode = S_FM; icmode_ext = 0x01; break;
case RIG_MODE_NAM: icmode = S_AM; break;
case RIG_MODE_WAM: icmode = S_AM; break;
case RIG_MODE_NCW: icmode = S_CW; break;
case RIG_MODE_WCW: icmode = S_CW; break;
case RIG_MODE_CWR: icmode = S_CW; break;
case RIG_MODE_NUSB: icmode = S_USB; break;
case RIG_MODE_WUSB: icmode = S_USB; break;
case RIG_MODE_NLSB: icmode = S_LSB; break;
case RIG_MODE_WLSB: icmode = S_LSB; break;
case RIG_MODE_NRTTY: icmode = S_RTTY; break;
case RIG_MODE_WRTTY: icmode = S_RTTY; break;
#endif
default: default:
rig_debug(RIG_DEBUG_ERR,"icom: Unsupported Hamlib mode %d\n",mode); rig_debug(RIG_DEBUG_ERR,"icom: Unsupported Hamlib mode %d\n",mode);
icmode = 0xff; icmode = 0xff;
@ -231,25 +220,27 @@ unsigned short hamlib2icom_mode(rmode_t mode)
return (icmode_ext<<8 | icmode); return (icmode_ext<<8 | icmode);
} }
rmode_t icom2hamlib_mode(unsigned short icmode) void icom2hamlib_mode(unsigned short icmode, rmode_t *mode, pbwidth_t *width)
{ {
rmode_t mode; *width = RIG_PASSBAND_NORMAL;
switch (icmode & 0xff) { switch (icmode & 0xff) {
case S_AM: mode = RIG_MODE_AM; break; case S_AM: *mode = RIG_MODE_AM; break;
case S_CW: mode = RIG_MODE_CW; break; case S_CW: *mode = RIG_MODE_CW; break;
case S_FM: mode = RIG_MODE_FM; break; case S_FM: *mode = RIG_MODE_FM; break;
case S_WFM: mode = RIG_MODE_FM; break; /* and set width to wide.. */ case S_WFM:
case S_USB: mode = RIG_MODE_USB; break; *mode = RIG_MODE_FM;
case S_LSB: mode = RIG_MODE_LSB; break; *width = RIG_PASSBAND_WIDE;
case S_RTTY: mode = RIG_MODE_RTTY; break; break;
case S_USB: *mode = RIG_MODE_USB; break;
case S_LSB: *mode = RIG_MODE_LSB; break;
case S_RTTY: *mode = RIG_MODE_RTTY; break;
case 0xff: mode = 0; break; /* blank mem channel */ case 0xff: mode = 0; break; /* blank mem channel */
default: default:
rig_debug(RIG_DEBUG_ERR,"icom: Unsupported Icom mode %#.2x\n", rig_debug(RIG_DEBUG_ERR,"icom: Unsupported Icom mode %#.2x\n",
icmode); icmode);
mode = 0; *mode = 0;
} }
return mode;
} }

Wyświetl plik

@ -6,7 +6,7 @@
* via serial interface to an ICOM using the "CI-V" interface. * via serial interface to an ICOM using the "CI-V" interface.
* *
* *
* $Id: frame.h,v 1.3 2000-11-01 23:21:47 f4cfe Exp $ * $Id: frame.h,v 1.4 2000-12-04 23:39:17 f4cfe Exp $
* *
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -38,8 +38,8 @@ int make_cmd_frame(char frame[], char re_id, char cmd, int subcmd, const char *d
int icom_transaction (RIG *rig, int cmd, int subcmd, const char *payload, int payload_len, char *data, int *data_len); int icom_transaction (RIG *rig, int cmd, int subcmd, const char *payload, int payload_len, char *data, int *data_len);
int read_icom_frame(FILE *stream, unsigned char rxbuffer[], int timeout); int read_icom_frame(FILE *stream, unsigned char rxbuffer[], int timeout);
unsigned short hamlib2icom_mode(rmode_t mode); unsigned short hamlib2icom_mode(rmode_t mode, pbwidth_t width);
rmode_t icom2hamlib_mode(unsigned short icmode); void icom2hamlib_mode(unsigned short icmode, rmode_t *mode, pbwidth_t *width);
#endif /* _FRAME_H */ #endif /* _FRAME_H */

Wyświetl plik

@ -6,7 +6,7 @@
* via serial interface to an ICOM using the "CI-V" interface. * via serial interface to an ICOM using the "CI-V" interface.
* *
* *
* $Id: icom.c,v 1.9 2000-10-29 16:25:56 f4cfe Exp $ * $Id: icom.c,v 1.10 2000-12-04 23:39:17 f4cfe Exp $
* *
* *
* *
@ -354,7 +354,7 @@ int icom_get_freq(RIG *rig, freq_t *freq)
* icom_set_mode * icom_set_mode
* Assumes rig!=NULL, rig->state.priv!=NULL * Assumes rig!=NULL, rig->state.priv!=NULL
*/ */
int icom_set_mode(RIG *rig, rmode_t mode) int icom_set_mode(RIG *rig, rmode_t mode, pbwidth_t width)
{ {
struct icom_priv_data *priv; struct icom_priv_data *priv;
struct rig_state *rig_s; struct rig_state *rig_s;
@ -364,7 +364,7 @@ int icom_set_mode(RIG *rig, rmode_t mode)
rig_s = &rig->state; rig_s = &rig->state;
priv = (struct icom_priv_data*)rig_s->priv; priv = (struct icom_priv_data*)rig_s->priv;
icmode = hamlib2icom_mode(mode); icmode = hamlib2icom_mode(mode,width);
icom_transaction (rig, C_SET_MODE, icmode, NULL, 0, ackbuf, &ack_len); icom_transaction (rig, C_SET_MODE, icmode, NULL, 0, ackbuf, &ack_len);
@ -379,9 +379,9 @@ int icom_set_mode(RIG *rig, rmode_t mode)
/* /*
* icom_get_mode * icom_get_mode
* Assumes rig!=NULL, rig->state.priv!=NULL, mode!=NULL * Assumes rig!=NULL, rig->state.priv!=NULL, mode!=NULL, width!=NULL
*/ */
int icom_get_mode(RIG *rig, rmode_t *mode) int icom_get_mode(RIG *rig, rmode_t *mode, pbwidth_t *width)
{ {
struct icom_priv_data *priv; struct icom_priv_data *priv;
struct rig_state *rig_s; struct rig_state *rig_s;
@ -403,7 +403,7 @@ int icom_get_mode(RIG *rig, rmode_t *mode)
return -RIG_ERJCTED; return -RIG_ERJCTED;
} }
*mode = icom2hamlib_mode(modebuf[1]| modebuf[2]<<8); icom2hamlib_mode(modebuf[1]| modebuf[2]<<8, mode, width);
return RIG_OK; return RIG_OK;
} }
@ -1030,7 +1030,7 @@ int icom_set_channel(RIG *rig, const channel_t *chan)
chan_len = 3+freq_len+1; chan_len = 3+freq_len+1;
icmode = hamlib2icom_mode(chan->mode); icmode = hamlib2icom_mode(chan->mode, RIG_PASSBAND_NORMAL); /* FIXME */
chanbuf[chan_len++] = icmode&0xff; chanbuf[chan_len++] = icmode&0xff;
chanbuf[chan_len++] = icmode>>8; chanbuf[chan_len++] = icmode>>8;
to_bcd_be(chanbuf+chan_len++,chan->att,2); to_bcd_be(chanbuf+chan_len++,chan->att,2);
@ -1061,6 +1061,7 @@ int icom_get_channel(RIG *rig, channel_t *chan)
struct rig_state *rig_s; struct rig_state *rig_s;
unsigned char chanbuf[24]; unsigned char chanbuf[24];
int chan_len,freq_len; int chan_len,freq_len;
pbwidth_t width; /* FIXME */
rig_s = &rig->state; rig_s = &rig->state;
priv = (struct icom_priv_data*)rig_s->priv; priv = (struct icom_priv_data*)rig_s->priv;
@ -1089,7 +1090,8 @@ int icom_get_channel(RIG *rig, channel_t *chan)
chan_len = 4+freq_len+1; chan_len = 4+freq_len+1;
chan->mode = icom2hamlib_mode(chanbuf[chan_len] | chanbuf[chan_len+1]); icom2hamlib_mode(chanbuf[chan_len] | chanbuf[chan_len+1],
&chan->mode, &width);
chan_len += 2; chan_len += 2;
chan->att = from_bcd_be(chanbuf+chan_len++,2); chan->att = from_bcd_be(chanbuf+chan_len++,2);
chan->preamp = from_bcd_be(chanbuf+chan_len++,2); chan->preamp = from_bcd_be(chanbuf+chan_len++,2);
@ -1279,6 +1281,7 @@ int icom_decode_event(RIG *rig)
int frm_len; int frm_len;
freq_t freq; freq_t freq;
rmode_t mode; rmode_t mode;
pbwidth_t width;
rig_debug(RIG_DEBUG_VERBOSE, "icom: icom_decode called\n"); rig_debug(RIG_DEBUG_VERBOSE, "icom: icom_decode called\n");
@ -1305,8 +1308,8 @@ int icom_decode_event(RIG *rig)
break; break;
case C_SND_MODE: case C_SND_MODE:
if (rig->callbacks.mode_event) { if (rig->callbacks.mode_event) {
mode = icom2hamlib_mode(buf[5]| buf[6]<<8); icom2hamlib_mode(buf[5]| buf[6]<<8, &mode, &width);
return rig->callbacks.mode_event(rig,mode); return rig->callbacks.mode_event(rig,mode,width);
} else } else
return -RIG_ENAVAIL; return -RIG_ENAVAIL;
break; break;

Wyświetl plik

@ -6,7 +6,7 @@
* via serial interface to an ICOM using the "CI-V" interface. * via serial interface to an ICOM using the "CI-V" interface.
* *
* *
* $Id: icom.h,v 1.8 2000-10-29 16:26:23 f4cfe Exp $ * $Id: icom.h,v 1.9 2000-12-04 23:39:17 f4cfe Exp $
* *
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -44,8 +44,8 @@ int icom_init(RIG *rig);
int icom_cleanup(RIG *rig); int icom_cleanup(RIG *rig);
int icom_set_freq(RIG *rig, freq_t freq); int icom_set_freq(RIG *rig, freq_t freq);
int icom_get_freq(RIG *rig, freq_t *freq); int icom_get_freq(RIG *rig, freq_t *freq);
int icom_set_mode(RIG *rig, rmode_t mode); int icom_set_mode(RIG *rig, rmode_t mode, pbwidth_t width);
int icom_get_mode(RIG *rig, rmode_t *mode); int icom_get_mode(RIG *rig, rmode_t *mode, pbwidth_t *width);
int icom_set_vfo(RIG *rig, vfo_t vfo); int icom_set_vfo(RIG *rig, vfo_t vfo);
int icom_set_rptr_shift(RIG *rig, rptr_shift_t rptr_shift); int icom_set_rptr_shift(RIG *rig, rptr_shift_t rptr_shift);
int icom_get_rptr_shift(RIG *rig, rptr_shift_t *rptr_shift); int icom_get_rptr_shift(RIG *rig, rptr_shift_t *rptr_shift);

Wyświetl plik

@ -5,7 +5,7 @@
* will be used for obtaining rig capabilities. * will be used for obtaining rig capabilities.
* *
* *
* $Id: rig.h,v 1.9 2000-11-28 22:31:40 f4cfe Exp $ * * $Id: rig.h,v 1.10 2000-12-04 23:39:17 f4cfe Exp $ *
* *
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -238,7 +238,7 @@ typedef union value_u value_t;
#define RIG_LEVEL_SQLSTAT (1<<30) /* SQL status, arg int (open=1/closed=0) */ #define RIG_LEVEL_SQLSTAT (1<<30) /* SQL status, arg int (open=1/closed=0) */
#define RIG_LEVEL_STRENGTH (1<<31) /* Signal strength, arg int (db) */ #define RIG_LEVEL_STRENGTH (1<<31) /* Signal strength, arg int (db) */
typedef unsigned long setting_t; /* at least 32 bits */ typedef unsigned long setting_t; /* 32 bits might not be enough.. */
/* /*
* tranceive mode, ie. the rig notify the host of any event, * tranceive mode, ie. the rig notify the host of any event,
@ -284,7 +284,11 @@ typedef long long freq_t;
typedef unsigned int rmode_t; /* radio mode */ typedef unsigned int rmode_t; /* radio mode */
/* Do not use an enum since this will be used w/ rig_mode_t bit fields */ /*
* Do not use an enum since this will be used w/ rig_mode_t bit fields.
* Also, how should CW reverse sideband and RTTY reverse
* sideband be handled?
* */
#define RIG_MODE_NONE 0 #define RIG_MODE_NONE 0
#define RIG_MODE_AM (1<<0) #define RIG_MODE_AM (1<<0)
#define RIG_MODE_CW (1<<1) #define RIG_MODE_CW (1<<1)
@ -293,25 +297,6 @@ typedef unsigned int rmode_t; /* radio mode */
#define RIG_MODE_RTTY (1<<4) #define RIG_MODE_RTTY (1<<4)
#define RIG_MODE_FM (1<<5) #define RIG_MODE_FM (1<<5)
/* The following are deprecated */
/* use the get/set_filter to manipulate these bits */
#if 0
#define RIG_MODE_WFM (1<<6)
#define RIG_MODE_CWR (1<<7) /* CW reverse sideband*/
#define RIG_MODE_RTTYR (1<<8) /* RTTY reverse sideband */
#define RIG_MODE_NFM (1<<19) /* should we distinguish modes w/ filers? */
#define RIG_MODE_NAM (1<<20) /* Narrow AM */
#define RIG_MODE_WAM (1<<9) /* Wide AM */
#define RIG_MODE_NCW (1<<10)
#define RIG_MODE_WCW (1<<11)
#define RIG_MODE_NUSB (1<<13)
#define RIG_MODE_WUSB (1<<14)
#define RIG_MODE_NLSB (1<<15)
#define RIG_MODE_WLSB (1<<16)
#define RIG_MODE_NRTTY (1<<17)
#define RIG_MODE_WRTTY (1<<18)
#endif
#define RIGNAMSIZ 30 #define RIGNAMSIZ 30
@ -431,8 +416,8 @@ struct rig_caps {
int (*set_freq)(RIG *rig, freq_t freq); /* select freq */ int (*set_freq)(RIG *rig, freq_t freq); /* select freq */
int (*get_freq)(RIG *rig, freq_t *freq); /* get freq */ int (*get_freq)(RIG *rig, freq_t *freq); /* get freq */
int (*set_mode)(RIG *rig, rmode_t mode); /* select mode */ int (*set_mode)(RIG *rig, rmode_t mode, pbwidth_t width); /* select mode */
int (*get_mode)(RIG *rig, rmode_t *mode); /* get mode */ int (*get_mode)(RIG *rig, rmode_t *mode, pbwidth_t *width); /* get mode */
int (*set_vfo)(RIG *rig, vfo_t vfo); /* select vfo (A,B, etc.) */ int (*set_vfo)(RIG *rig, vfo_t vfo); /* select vfo (A,B, etc.) */
int (*get_vfo)(RIG *rig, vfo_t *vfo); /* get vfo */ int (*get_vfo)(RIG *rig, vfo_t *vfo); /* get vfo */
@ -440,9 +425,6 @@ struct rig_caps {
int (*set_ptt)(RIG *rig, ptt_t ptt); /* ptt on/off */ int (*set_ptt)(RIG *rig, ptt_t ptt); /* ptt on/off */
int (*get_ptt)(RIG *rig, ptt_t *ptt); /* get ptt status */ int (*get_ptt)(RIG *rig, ptt_t *ptt); /* get ptt status */
int (*set_passband)(RIG *rig, pbwidth_t width); /* select width */
int (*get_passband)(RIG *rig, pbwidth_t *width); /* get width */
int (*set_rptr_shift)(RIG *rig, rptr_shift_t rptr_shift); /* set repeater shift */ int (*set_rptr_shift)(RIG *rig, rptr_shift_t rptr_shift); /* set repeater shift */
int (*get_rptr_shift)(RIG *rig, rptr_shift_t *rptr_shift); /* get repeater shift */ int (*get_rptr_shift)(RIG *rig, rptr_shift_t *rptr_shift); /* get repeater shift */
@ -564,7 +546,7 @@ struct rig_state {
*/ */
struct rig_callbacks { struct rig_callbacks {
int (*freq_event)(RIG *rig, freq_t freq); int (*freq_event)(RIG *rig, freq_t freq);
int (*mode_event)(RIG *rig, rmode_t mode); int (*mode_event)(RIG *rig, rmode_t mode, pbwidth_t width);
int (*vfo_event)(RIG *rig, vfo_t vfo); int (*vfo_event)(RIG *rig, vfo_t vfo);
int (*ptt_event)(RIG *rig, ptt_t mode); int (*ptt_event)(RIG *rig, ptt_t mode);
/* etc.. */ /* etc.. */
@ -595,11 +577,8 @@ extern int rig_open(RIG *rig);
extern int rig_set_freq(RIG *rig, freq_t freq); /* select freq */ extern int rig_set_freq(RIG *rig, freq_t freq); /* select freq */
extern int rig_get_freq(RIG *rig, freq_t *freq); /* get freq */ extern int rig_get_freq(RIG *rig, freq_t *freq); /* get freq */
extern int rig_set_mode(RIG *rig, rmode_t mode); /* select mode */ extern int rig_set_mode(RIG *rig, rmode_t mode, pbwidth_t width); /* select mode */
extern int rig_get_mode(RIG *rig, rmode_t *mode); /* get mode */ extern int rig_get_mode(RIG *rig, rmode_t *mode, pbwidth_t *width); /* get mode */
extern int rig_set_passband(RIG *rig, pbwidth_t width); /* select width */
extern int rig_get_passband(RIG *rig, pbwidth_t *width); /* get width */
extern int rig_set_vfo(RIG *rig, vfo_t vfo); /* select vfo */ extern int rig_set_vfo(RIG *rig, vfo_t vfo); /* select vfo */
extern int rig_get_vfo(RIG *rig, vfo_t *vfo); /* get vfo */ extern int rig_get_vfo(RIG *rig, vfo_t *vfo); /* get vfo */

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.9 2000-11-28 22:33:37 f4cfe Exp $ $Id: rig.c,v 1.10 2000-12-04 23:39:18 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
@ -398,8 +398,11 @@ int rig_get_freq(RIG *rig, freq_t *freq)
* rig_set_mode - set the mode of the current VFO * rig_set_mode - set the mode of the current VFO
* @rig: The rig handle * @rig: The rig handle
* @mode: The mode to set to * @mode: The mode to set to
* @width: The passband width to set to
* *
* The rig_set_mode() function sets the mode of the current VFO. * The rig_set_mode() function sets the mode of the current VFO.
* As a begining, the backend is free to ignore the @width argument,
* however, it would be nice to at least honor the WFM case.
* *
* RETURN VALUE: The rig_set_mode() function returns %RIG_OK * RETURN VALUE: The rig_set_mode() function returns %RIG_OK
* if the operation has been sucessful, or a negative value * if the operation has been sucessful, or a negative value
@ -408,7 +411,7 @@ int rig_get_freq(RIG *rig, freq_t *freq)
* SEE ALSO: rig_get_mode() * SEE ALSO: rig_get_mode()
*/ */
int rig_set_mode(RIG *rig, rmode_t mode) int rig_set_mode(RIG *rig, rmode_t mode, pbwidth_t width)
{ {
if (!rig || !rig->caps) if (!rig || !rig->caps)
return -RIG_EINVAL; return -RIG_EINVAL;
@ -416,15 +419,18 @@ int rig_set_mode(RIG *rig, rmode_t mode)
if (rig->caps->set_mode == NULL) if (rig->caps->set_mode == NULL)
return -RIG_ENAVAIL; return -RIG_ENAVAIL;
else else
return rig->caps->set_mode(rig, mode); return rig->caps->set_mode(rig, mode, width);
} }
/** /**
* rig_get_mode - get the mode of the current VFO * rig_get_mode - get the mode of the current VFO
* @rig: The rig handle * @rig: The rig handle
* @mode: The location where to store the current mode * @mode: The location where to store the current mode
* @width: The location where to store the current passband width
* *
* The rig_set_mode() function retrieves the mode of the current VFO. * The rig_set_mode() function retrieves the mode of the current VFO.
* If the backend is unable to determine the width, it must
* return %RIG_PASSBAND_NORMAL as a default.
* *
* RETURN VALUE: The rig_get_mode() function returns %RIG_OK * RETURN VALUE: The rig_get_mode() function returns %RIG_OK
* if the operation has been sucessful, or a negative value * if the operation has been sucessful, or a negative value
@ -433,47 +439,15 @@ int rig_set_mode(RIG *rig, rmode_t mode)
* SEE ALSO: rig_set_mode() * SEE ALSO: rig_set_mode()
*/ */
int rig_get_mode(RIG *rig, rmode_t *mode) int rig_get_mode(RIG *rig, rmode_t *mode, pbwidth_t *width)
{ {
if (!rig || !rig->caps || !mode) if (!rig || !rig->caps || !mode || !width)
return -RIG_EINVAL; return -RIG_EINVAL;
if (rig->caps->get_mode == NULL) if (rig->caps->get_mode == NULL)
return -RIG_ENAVAIL; return -RIG_ENAVAIL;
else else
return rig->caps->get_mode(rig, mode); return rig->caps->get_mode(rig, mode, width);
}
/*
* rig_set_passband
*
*/
int rig_set_passband(RIG *rig, pbwidth_t width)
{
if (!rig || !rig->caps)
return -RIG_EINVAL;
if (rig->caps->set_passband == NULL)
return -RIG_ENAVAIL;
else
return rig->caps->set_passband(rig, width);
}
/*
* rig_get_passband
*
*/
int rig_get_passband(RIG *rig, pbwidth_t *width)
{
if (!rig || !rig->caps || !width)
return -RIG_EINVAL;
if (rig->caps->get_passband == NULL)
return -RIG_ENAVAIL;
else
return rig->caps->get_passband(rig, width);
} }
/** /**

Wyświetl plik

@ -7,7 +7,7 @@
* TODO: be more generic and add command line option to run * TODO: be more generic and add command line option to run
* in non-interactive mode * in non-interactive mode
* *
* $Id: rigctl.c,v 1.2 2000-11-28 22:34:37 f4cfe Exp $ * $Id: rigctl.c,v 1.3 2000-12-04 23:39:18 f4cfe Exp $
* *
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -46,8 +46,6 @@ static int set_freq(RIG *rig);
static int get_freq(RIG *rig); static int get_freq(RIG *rig);
static int set_mode(RIG *rig); static int set_mode(RIG *rig);
static int get_mode(RIG *rig); static int get_mode(RIG *rig);
static int set_passband(RIG *rig);
static int get_passband(RIG *rig);
static int set_vfo(RIG *rig); static int set_vfo(RIG *rig);
static int get_vfo(RIG *rig); static int get_vfo(RIG *rig);
static int set_ptt(RIG *rig); static int set_ptt(RIG *rig);
@ -85,8 +83,6 @@ struct test_table test_list[] = {
{ 'f', "rig_get_freq", get_freq }, { 'f', "rig_get_freq", get_freq },
{ 'M', "rig_set_mode", set_mode }, { 'M', "rig_set_mode", set_mode },
{ 'm', "rig_get_mode", get_mode }, { 'm', "rig_get_mode", get_mode },
{ 'P', "rig_set_passband", set_passband },
{ 'p', "rig_get_passband", get_passband },
{ 'V', "rig_set_vfo", set_vfo }, { 'V', "rig_set_vfo", set_vfo },
{ 'v', "rig_get_vfo", get_vfo }, { 'v', "rig_get_vfo", get_vfo },
{ 'T', "rig_set_ptt", set_ptt }, { 'T', "rig_set_ptt", set_ptt },
@ -225,10 +221,13 @@ static int get_freq(RIG *rig)
static int set_mode(RIG *rig) static int set_mode(RIG *rig)
{ {
rmode_t mode; rmode_t mode;
pbwidth_t width;
printf("Mode: "); printf("Mode: ");
scanf("%d", &mode); scanf("%d", &mode);
return rig_set_mode(rig, mode); printf("Passband: ");
scanf("%d", (int*)&width);
return rig_set_mode(rig, mode, width);
} }
@ -236,30 +235,10 @@ static int get_mode(RIG *rig)
{ {
int status; int status;
rmode_t mode; rmode_t mode;
status = rig_get_mode(rig, &mode);
printf("Mode: %d\n", mode);
return status;
}
static int set_passband(RIG *rig)
{
pbwidth_t width; pbwidth_t width;
printf("Passband: "); status = rig_get_mode(rig, &mode, &width);
scanf("%d", (int*)&width); printf("Mode: %d\nPassband: %d\n", mode, width);
return rig_set_passband(rig, width);
}
static int get_passband(RIG *rig)
{
int status;
pbwidth_t width;
status = rig_get_passband(rig, &width);
printf("Passband: %d\n", width);
return status; return status;
} }