[Hamlib-cvs-digest] CVS: hamlib/ft747 ft747.c,1.21,1.22 ft747.h,1.15,1.16
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Frank S. <jav...@us...> - 2000-12-07 02:34:58
|
Update of /cvsroot/hamlib/hamlib/ft747 In directory slayer.i.sourceforge.net:/tmp/cvs-serv3967 Modified Files: ft747.c ft747.h Log Message: 1. Added VFO as target for some set/get cmds. 2. ./testrig still runs ok using RIG_VFO_CURR. Index: ft747.c =================================================================== RCS file: /cvsroot/hamlib/hamlib/ft747/ft747.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** ft747.c 2000/11/25 21:49:34 1.21 --- ft747.c 2000/12/07 02:34:56 1.22 *************** *** 189,193 **** p->pacing = FT747_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ p->read_update_delay = FT747_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ ! rig->state.priv = (void*)p; --- 189,193 ---- p->pacing = FT747_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ p->read_update_delay = FT747_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ ! p->current_vfo = RIG_VFO_A; /* default to VFO_A ? */ rig->state.priv = (void*)p; *************** *** 261,265 **** ! int ft747_set_freq(RIG *rig, freq_t freq) { struct rig_state *rig_s; struct ft747_priv_data *p; --- 261,265 ---- ! int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { struct rig_state *rig_s; struct ft747_priv_data *p; *************** *** 278,281 **** --- 278,283 ---- rig_debug(RIG_DEBUG_VERBOSE,"ft747: requested freq = %Li Hz \n", freq); + ft747_set_vfo(rig, vfo); /* select VFO first , new API */ + to_bcd(bcd,freq,8); *************** *** 293,300 **** ! return -RIG_ENIMPL; } ! int ft747_get_freq(RIG *rig, freq_t *freq) { struct ft747_priv_data *p; freq_t f; --- 295,307 ---- ! return RIG_OK; } ! ! /* ! * Return Freq for a given VFO ! */ ! ! int ft747_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { struct ft747_priv_data *p; freq_t f; *************** *** 306,314 **** ft747_get_update_data(rig); /* get whole shebang from rig */ - - f = from_bcd_be(&(p->update_data[FT747_SUMO_DISPLAYED_FREQ+1]),8); /* grab freq and convert */ ! rig_debug(RIG_DEBUG_VERBOSE,"ft747: displayed freq = %Li Hz \n", f); (*freq) = f; /* return diplayed frequency */ --- 313,333 ---- ft747_get_update_data(rig); /* get whole shebang from rig */ ! if (vfo == RIG_VFO_CURR ) ! vfo = p->current_vfo; /* from previous vfo cmd */ + switch(vfo) { + case RIG_VFO_A: + f = from_bcd_be(&(p->update_data[FT747_SUMO_VFO_A_FREQ]),8); /* grab freq and convert */ + break; + case RIG_VFO_B: + f = from_bcd_be(&(p->update_data[FT747_SUMO_VFO_B_FREQ]),8); /* grab freq and convert */ + break; + default: + return -RIG_EINVAL; /* sorry, wrong VFO */ + } + + rig_debug(RIG_DEBUG_VERBOSE,"ft747: freq = %Li Hz for VFO = %u \n", f, vfo); + (*freq) = f; /* return diplayed frequency */ *************** *** 318,326 **** /* ! * set mode : eg AM. AMN , CW, NCW etc.. * */ ! int ft747_set_mode(RIG *rig, rmode_t mode) { struct rig_state *rig_s; struct ft747_priv_data *p; --- 337,345 ---- /* ! * set mode : eg AM, CW etc for a given VFO * */ ! int ft747_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width ) { struct rig_state *rig_s; struct ft747_priv_data *p; *************** *** 336,339 **** --- 355,359 ---- rig_s = &rig->state; + ft747_set_vfo(rig, vfo); /* select VFO first , new API */ /* *************** *** 364,367 **** --- 384,403 ---- } + + /* + * Now set width + */ + + switch(width) { + case RIG_PASSBAND_NORMAL: /* easy case */ + break; + case RIG_PASSBAND_NARROW: /* must set narrow */ + mymode |= MODE_NAR; + break; + case RIG_PASSBAND_WIDE: + return -RIG_EINVAL; /* sorry, wrong WIDTH */ + + } + cmd[3] = mymode; write_block(rig_s->fd, cmd, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay); *************** *** 371,376 **** } ! int ft747_get_mode(RIG *rig, rmode_t *mode) { struct ft747_priv_data *p; unsigned char mymode; /* ft747 mode */ --- 407,413 ---- } + ! int ft747_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { struct ft747_priv_data *p; unsigned char mymode; /* ft747 mode */ *************** *** 425,435 **** ! int ft747_set_vfo(RIG *rig, vfo_t vfo) { struct rig_state *rig_s; struct ft747_priv_data *p; ! static unsigned char cmd_A[] = { 0x00, 0x00, 0x00, 0x00, 0x05 }; /* select vfo A */ ! static unsigned char cmd_B[] = { 0x00, 0x00, 0x00, 0x01, 0x05 }; /* select vfo B */ if (!rig) --- 462,475 ---- ! /* ! * set vfo and store requested vfo for later RIG_VFO_CURR ! * requests. ! * ! */ int ft747_set_vfo(RIG *rig, vfo_t vfo) { struct rig_state *rig_s; struct ft747_priv_data *p; ! static unsigned char cmd[] = { 0x00, 0x00, 0x00, 0x00, 0x05 }; /* select vfo A/B/Current */ if (!rig) *************** *** 446,458 **** switch(vfo) { case RIG_VFO_A: ! write_block(rig_s->fd, cmd_A, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay); return RIG_OK; case RIG_VFO_B: ! write_block(rig_s->fd, cmd_B, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay); return RIG_OK; default: return -RIG_EINVAL; /* sorry, wrong VFO */ } return RIG_OK; /* good */ } --- 486,508 ---- switch(vfo) { case RIG_VFO_A: ! cmd[3] = 0x00; ! write_block(rig_s->fd, cmd, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay); ! p->current_vfo = vfo; /* update active VFO */ return RIG_OK; case RIG_VFO_B: ! cmd[3] = 0x01; ! write_block(rig_s->fd, cmd, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay); ! p->current_vfo = vfo; /* update active VFO */ return RIG_OK; + case RIG_VFO_CURR: + cmd[3] = p->current_vfo; /* use active VFO */ + write_block(rig_s->fd, cmd, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay); + return RIG_OK; + default: return -RIG_EINVAL; /* sorry, wrong VFO */ } + return RIG_OK; /* good */ } *************** *** 491,495 **** } ! int ft747_set_ptt(RIG *rig, ptt_t ptt) { struct rig_state *rig_s; struct ft747_priv_data *p; --- 541,545 ---- } ! int ft747_set_ptt(RIG *rig,vfo_t vfo, ptt_t ptt) { struct rig_state *rig_s; struct ft747_priv_data *p; *************** *** 504,507 **** --- 554,559 ---- rig_s = &rig->state; + ft747_set_vfo(rig,vfo); /* select VFO first */ + switch(ptt) { case RIG_PTT_OFF: *************** *** 517,521 **** } ! int ft747_get_ptt(RIG *rig, ptt_t *ptt) { struct ft747_priv_data *p; unsigned char status; /* ft747 mode */ --- 569,573 ---- } ! int ft747_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { struct ft747_priv_data *p; unsigned char status; /* ft747 mode */ Index: ft747.h =================================================================== RCS file: /cvsroot/hamlib/hamlib/ft747/ft747.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** ft747.h 2000/11/25 21:49:34 1.15 --- ft747.h 2000/12/07 02:34:56 1.16 *************** *** 116,119 **** --- 116,121 ---- * Some useful offsets in the status update map (offset) * + * Manual appears to be full of mistakes regarding offsets etc.. -- FS + * */ *************** *** 121,124 **** --- 123,130 ---- #define FT747_SUMO_DISPLAYED_STATUS 0x00 #define FT747_SUMO_DISPLAYED_FREQ 0x01 + #define FT747_SUMO_VFO_A_FREQ 0x09 + #define FT747_SUMO_VFO_B_FREQ 0x11 + + *************** *** 131,134 **** --- 137,141 ---- unsigned char pacing; /* pacing value */ unsigned int read_update_delay; /* depends on pacing value */ + unsigned char current_vfo; /* active VFO from last cmd */ unsigned char p_cmd[FT747_CMD_LENGTH]; /* private copy of constructed CAT cmd */ unsigned char update_data[FT747_STATUS_UPDATE_DATA_LENGTH]; /* returned data */ *************** *** 144,158 **** int ft747_close(RIG *rig); ! int ft747_set_freq(RIG *rig, freq_t freq); ! int ft747_get_freq(RIG *rig, freq_t *freq); ! int ft747_set_mode(RIG *rig, rmode_t mode); /* select mode */ ! int ft747_get_mode(RIG *rig, rmode_t *mode); /* get mode */ int ft747_set_vfo(RIG *rig, vfo_t vfo); /* select vfo */ int ft747_get_vfo(RIG *rig, vfo_t *vfo); /* get vfo */ ! int ft747_set_ptt(RIG *rig, ptt_t ptt); ! int ft747_get_ptt(RIG *rig, ptt_t *ptt); --- 151,165 ---- int ft747_close(RIG *rig); ! int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq); ! int ft747_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); ! int ft747_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); /* select mode */ ! int ft747_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); /* get mode */ int ft747_set_vfo(RIG *rig, vfo_t vfo); /* select vfo */ int ft747_get_vfo(RIG *rig, vfo_t *vfo); /* get vfo */ ! int ft747_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); ! int ft747_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); |