Update:
		Miscellaneous formating cleanup.


git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1235 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.1.4
Nate Bargmann, N0NB 2002-11-04 05:16:19 +00:00
rodzic 1083331fce
commit e10a0458c9
2 zmienionych plików z 272 dodań i 309 usunięć

Wyświetl plik

@ -12,7 +12,7 @@
* pages 86 to 90
*
*
* $Id: ft920.c,v 1.4 2002-11-01 04:39:47 n0nb Exp $
* $Id: ft920.c,v 1.5 2002-11-04 05:16:19 n0nb Exp $
*
*
* This program is free software; you can redistribute it and/or
@ -29,7 +29,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*/
@ -55,11 +54,14 @@
static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl);
static int ft920_send_priv_cmd(RIG *rig, unsigned char ci);
/* Native ft920 cmd set prototypes. These are READ ONLY as each */
/* rig instance will copy from these and modify if required . */
/* Complete sequences (1) can be read and used directly as a cmd sequence . */
/* Incomplete sequences (0) must be completed with extra parameters */
/* eg: mem number, or freq etc.. */
/*
* Native ft920 cmd set prototypes. These are READ ONLY as each
* rig instance will copy from these and modify if required.
* Complete sequences (1) can be read and used directly as a cmd sequence.
* Incomplete sequences (0) must be completed with extra parameters
* eg: mem number, or freq etc..
*
*/
static const yaesu_cmd_set_t ncmd[] = {
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x01 } }, /* split = off */
@ -112,12 +114,10 @@ static const yaesu_cmd_set_t ncmd[] = {
};
/*
* Receiver caps
*/
#define FT920_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB)
#define FT920_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB)
#define FT920_AM_RX_MODES (RIG_MODE_AM)
@ -130,12 +130,9 @@ static const yaesu_cmd_set_t ncmd[] = {
#define FT920_OTHER_TX_MODES (RIG_MODE_CW| RIG_MODE_USB| RIG_MODE_LSB ) /* 100 W class */
#define FT920_AM_TX_MODES (RIG_MODE_AM ) /* set 25W max */
#define FT920_FUNC_ALL (RIG_FUNC_FAGC|RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_SBKIN|RIG_FUNC_FBKIN) /* fix */
/*
* future - private data
*
@ -147,13 +144,14 @@ struct ft920_priv_data {
unsigned char current_vfo; /* active VFO from last cmd */
unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */
yaesu_cmd_set_t pcs[FT_920_NATIVE_SIZE]; /* private cmd set */
unsigned char update_data[FT920_VFO_UPDATE_DATA_LENGTH]; /* returned data--max value, some are less */
unsigned char update_data[FT920_VFO_UPDATE_DATA_LENGTH];/* returned data--max value, some are less */
};
/*
* ft920 rigs capabilities.
* Also this struct is READONLY!
*
*/
const struct rig_caps ft920_caps = {
@ -203,6 +201,7 @@ const struct rig_caps ft920_caps = {
.rx_range_list2 = {
{kHz(100), MHz(30), FT920_ALL_RX_MODES, -1, -1 }, /* General coverage + ham */
{MHz(48), MHz(56), FT920_ALL_RX_MODES, -1, -1 }, /* 6m! */
RIG_FRNG_END,
}, /* Region 2 rx ranges */
@ -252,15 +251,16 @@ const struct rig_caps ft920_caps = {
RIG_TS_END,
/* The FT-920 has a Fine tuning step which increments in 1 Hz steps
/*
* The FT-920 has a Fine tuning step which increments in 1 Hz steps
* for SSB_CW_RX_MODES, and 10 Hz steps for AM_RX_MODES and
* FM_RX_MODES. It doesn't appear that anything finer than 10 Hz
* is available through the CAT interface, however. -N0NB
*
*/
},
/* mode/filter list, .remember = order matters! */
.filters = {
{RIG_MODE_SSB, kHz(2.4)}, /* standard SSB filter bandwidth */
{RIG_MODE_CW, kHz(2.4)}, /* normal CW filter */
@ -295,7 +295,6 @@ const struct rig_caps ft920_caps = {
*
*/
int ft920_init(RIG *rig) {
struct ft920_priv_data *p;
@ -311,11 +310,9 @@ int ft920_init(RIG *rig) {
/*
* Copy native cmd set to private cmd storage area
*/
memcpy(p->pcs,ncmd,sizeof(ncmd));
/* TODO: read pacing from preferences */
p->pacing = FT920_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */
p->read_update_delay = FT920_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */
p->current_vfo = RIG_VFO_A; /* default to VFO_A ? */
@ -328,6 +325,7 @@ int ft920_init(RIG *rig) {
/*
* ft920_cleanup routine
* the serial port is closed by the frontend
*
*/
int ft920_cleanup(RIG *rig) {
@ -344,6 +342,7 @@ int ft920_cleanup(RIG *rig) {
return RIG_OK;
}
/*
* ft920_open routine
*
@ -375,7 +374,6 @@ int ft920_open(RIG *rig) {
* ft920_close routine
*
*/
int ft920_close(RIG *rig) {
rig_debug(RIG_DEBUG_VERBOSE,"ft920: ft920_close called\n");
@ -383,7 +381,6 @@ int ft920_close(RIG *rig) {
if (!rig)
return -RIG_EINVAL;
return RIG_OK;
}
@ -393,7 +390,6 @@ int ft920_close(RIG *rig) {
*
*/
int ft920_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
struct rig_state *rig_s;
struct ft920_priv_data *p;
@ -404,7 +400,6 @@ int ft920_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
if (!rig)
return -RIG_EINVAL;
p = (struct ft920_priv_data*)rig->state.priv;
rig_s = &rig->state;
@ -420,13 +415,13 @@ int ft920_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
/*
* Copy native cmd freq_set to private cmd storage area
*/
memcpy(&p->p_cmd,&ncmd[FT_920_NATIVE_FREQ_SET].nseq,YAESU_CMD_LENGTH);
to_bcd(p->p_cmd,freq/10,8); /* store bcd format in in p_cmd */
/* TODO -- fix 10Hz resolution -- FS */
rig_debug(RIG_DEBUG_TRACE,"ft920: requested freq after conversion = %lli Hz\n", from_bcd(p->p_cmd,8)* 10 );
rig_debug(RIG_DEBUG_TRACE,"ft920: requested freq after conversion = %lli Hz\n",
from_bcd(p->p_cmd,8)* 10 );
cmd = p->p_cmd; /* get native sequence */
write_block(&rig_s->rigport, cmd, YAESU_CMD_LENGTH);
@ -437,6 +432,7 @@ int ft920_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
/*
* Return Freq for a given VFO
*
*/
int ft920_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) {
@ -451,7 +447,9 @@ int ft920_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) {
priv = (struct ft920_priv_data*)rig->state.priv;
ft920_get_update_data(rig, FT_920_NATIVE_VFO_UPDATE, FT920_VFO_UPDATE_DATA_LENGTH); /* get VFO record from rig*/
/* get VFO record from rig*/
ft920_get_update_data(rig, FT_920_NATIVE_VFO_UPDATE,
FT920_VFO_UPDATE_DATA_LENGTH);
if (vfo == RIG_VFO_CURR )
vfo = priv->current_vfo; /* from previous vfo cmd */
@ -499,12 +497,11 @@ int ft920_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width ) {
ft920_set_vfo(rig, vfo); /* select VFO first , new API */
#endif
rig_debug(RIG_DEBUG_TRACE,"ft920: generic mode = %x\n", mode);
/*
* translate mode from generic to ft920 specific
*/
rig_debug(RIG_DEBUG_TRACE,"ft920: generic mode = %x\n", mode);
switch(mode) {
case RIG_MODE_AM:
cmd_index = FT_920_NATIVE_MODE_SET_AMW;
@ -529,7 +526,6 @@ int ft920_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width ) {
/*
* Now set width
*/
/* FIXME: so far setting passband is buggy, only 0 is accepted -N0NB */
switch(width) {
case RIG_PASSBAND_NORMAL: /* easy case , no change to native sequence */
@ -565,7 +561,6 @@ int ft920_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width ) {
/*
* phew! now send cmd to rig
*/
ft920_send_priv_cmd(rig,cmd_index);
rig_debug(RIG_DEBUG_TRACE,"ft920: cmd_index = %i\n", cmd_index);
@ -575,6 +570,11 @@ int ft920_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width ) {
}
/*
* get mode : eg AM, CW etc for a given VFO
*
*/
int ft920_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) {
struct ft920_priv_data *p;
unsigned char mymode; /* ft920 mode */
@ -586,10 +586,12 @@ int ft920_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) {
p = (struct ft920_priv_data*)rig->state.priv;
/* FIXME: Command passed is for VFO A & B, there should
/*
* FIXME: Command passed is for VFO A & B, there should
* be a complement for current display. e.g. mem tune -N0NB
*/
ft920_get_update_data(rig, FT_920_NATIVE_VFO_UPDATE, FT920_VFO_UPDATE_DATA_LENGTH);
ft920_get_update_data(rig, FT_920_NATIVE_VFO_UPDATE,
FT920_VFO_UPDATE_DATA_LENGTH);
mymode = p->update_data[FT920_SUMO_DISPLAYED_MODE];
mymode &= MODE_MASK; /* mask out bits 4, 5 and 6 */
@ -600,7 +602,6 @@ int ft920_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) {
* translate mode from ft920 to generic.
* TODO: Add DATA, and Narrow modes. CW on LSB? -N0NB
*/
switch(mymode) {
case MODE_FM:
(*mode) = RIG_MODE_FM;
@ -632,13 +633,12 @@ int ft920_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) {
}
/*
* set vfo and store requested vfo for later RIG_VFO_CURR
* requests.
*
*/
int ft920_set_vfo(RIG *rig, vfo_t vfo) {
struct rig_state *rig_s;
struct ft920_priv_data *p;
@ -656,8 +656,6 @@ int ft920_set_vfo(RIG *rig, vfo_t vfo) {
/*
* TODO : check for errors -- FS
*/
switch(vfo) {
case RIG_VFO_A:
cmd_index = FT_920_NATIVE_VFO_A;
@ -693,7 +691,6 @@ int ft920_set_vfo(RIG *rig, vfo_t vfo) {
/*
* phew! now send cmd to rig
*/
ft920_send_priv_cmd(rig,cmd_index);
return RIG_OK;
@ -701,6 +698,12 @@ int ft920_set_vfo(RIG *rig, vfo_t vfo) {
}
/*
* get vfo and store requested vfo for later RIG_VFO_CURR
* requests.
*
*/
int ft920_get_vfo(RIG *rig, vfo_t *vfo) {
struct ft920_priv_data *p;
unsigned char status; /* ft920 status flag */
@ -713,7 +716,8 @@ int ft920_get_vfo(RIG *rig, vfo_t *vfo) {
p = (struct ft920_priv_data*)rig->state.priv;
/* Get flags for VFO status */
ft920_get_update_data(rig, FT_920_NATIVE_UPDATE, FT920_STATUS_UPDATE_DATA_LENGTH);
ft920_get_update_data(rig, FT_920_NATIVE_UPDATE,
FT920_STATUS_UPDATE_DATA_LENGTH);
status = p->update_data[FT920_SUMO_DISPLAYED_STATUS];
status &= SF_VFOAB; /* check VFO bit*/
@ -723,7 +727,6 @@ int ft920_get_vfo(RIG *rig, vfo_t *vfo) {
/*
* translate vfo status from ft920 to generic.
*/
switch (status) {
case SF_VFOAB:
(*vfo) = RIG_VFO_B;
@ -758,6 +761,7 @@ int ft920_get_vfo(RIG *rig, vfo_t *vfo) {
* need to use this when doing ft920_get_* stuff
*
* Variables: ci = command index, rl = read length of returned data
*
*/
static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) {
@ -783,12 +787,10 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) {
rig_debug(RIG_DEBUG_TRACE,"ft920: read pacing = %i\n",p->pacing);
/* send PACING cmd to rig */
cmd = p->p_cmd;
write_block(&rig_s->rigport, cmd, YAESU_CMD_LENGTH);
/* send UPDATE comand to fetch data*/
ft920_send_priv_cmd(rig, ci);
n = read_block(&rig_s->rigport, p->update_data, rl);
@ -798,9 +800,9 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) {
}
/*
* init_ft920 is called by rig_backend_load
*
*/
int init_ft920(void *be_handle) {
@ -810,11 +812,11 @@ int init_ft920(void *be_handle) {
}
/*
* private helper function to send a private command
* sequence . Must only be complete sequences.
* TODO: place variant of this in yaesu.c
*
*/
static int ft920_send_priv_cmd(RIG *rig, unsigned char ci) {
@ -845,4 +847,3 @@ static int ft920_send_priv_cmd(RIG *rig, unsigned char ci) {
return RIG_OK;
}

Wyświetl plik

@ -9,7 +9,7 @@
* via serial interface to an FT-920 using the "CAT" interface
*
*
* $Id: ft920.h,v 1.4 2002-11-01 04:39:47 n0nb Exp $
* $Id: ft920.h,v 1.5 2002-11-04 05:16:19 n0nb Exp $
*
*
* This program is free software; you can redistribute it and/or
@ -52,24 +52,24 @@
/*
* 8N2 and 1 start bit = 11 bits at 4800 bps => effective byte rate = 1 byte in 2.2917 msec
* => 345 bytes in 790 msec
* => 28 bytes in 64 msec
*
* delay for 1 byte = 2.2917 + (pace_interval * 5)
*
* pace_interval time to read 345 bytes
* ------------ ----------------------
*
* 0 790 msec
* 1 2515 msec
* 2 4240 msec
* 255 441 sec => 7 min 21 seconds
* 0 64 msec
* 1 321 msec
* 2 642 msec
* 255 16.4 sec
*
*/
/*
* Native FT920 functions. This is what I have to work with :-)
* Native FT920 functions. More to come :-)
*
*/
@ -105,8 +105,10 @@ enum ft920_native_cmd_e {
typedef enum ft920_native_cmd_e ft920_native_cmd_t;
/* Internal MODES - when setting modes via cmd_mode_set() */
/*
* Internal MODES - when setting modes via cmd_mode_set()
*
*/
#define MODE_SET_LSB 0x00
#define MODE_SET_USB 0x01
@ -121,6 +123,7 @@ typedef enum ft920_native_cmd_e ft920_native_cmd_t;
/*
* Mode Bitmap. Bits 5 and 6 unused
* When READING modes
*
*/
#define MODE_LSB 0x00
@ -149,6 +152,7 @@ typedef enum ft920_native_cmd_e ft920_native_cmd_t;
/*
* Status Flag Masks when reading
*
*/
#define SF_DLOCK 0x01
@ -164,6 +168,7 @@ typedef enum ft920_native_cmd_e ft920_native_cmd_t;
/*
* Local VFO CMD's, according to spec
*
*/
#define FT920_VFO_A 0x00
@ -173,8 +178,6 @@ typedef enum ft920_native_cmd_e ft920_native_cmd_t;
/*
* Some useful offsets in the status update map (offset)
*
* Manual appears to be full of mistakes regarding offsets etc.. -- FS
*
*/
#define FT920_SUMO_DISPLAYED_MODE 0x07
@ -187,6 +190,7 @@ typedef enum ft920_native_cmd_e ft920_native_cmd_t;
/*
* API local implementation
*
*/
int ft920_init(RIG *rig);
@ -204,46 +208,4 @@ int ft920_set_vfo(RIG *rig, vfo_t vfo); /* select vfo */
int ft920_get_vfo(RIG *rig, vfo_t *vfo); /* get vfo */
/*
* Below is leftovers of old interface. TODO
*
*/
#if 0
/*
* Allow TX commands to be disabled
*
*/
#undef TX_ENABLED
/*
* Mode Bitmap. Bits 5 and 6 unused
* When reading modes
*/
#define MODE_FM 0x01
#define MODE_AM 0x02
#define MODE_CW 0x04
#define MODE_FMN 0x81
#define MODE_AMN 0x82
#define MODE_CWN 0x84
#define MODE_USB 0x08
#define MODE_LSB 0x10
#define MODE_NAR 0x80 /* narrow bit set only */
/*
* Map band data value to band.
*
* Band "n" is from band_data[n] to band_data[n+1]
*/
const float band_data[11] = { 0.0, 0.1, 2.5, 4.0, 7.5, 10.5, 14.5, 18.5, 21.5, 25.0, 30.0 };
#endif
#endif /* _FT920_H */