[Hamlib-cvs-digest] CVS: hamlib/ft747 ft747.c,1.20,1.21 ft747.h,1.14,1.15
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Frank S. <jav...@us...> - 2000-11-25 21:49:40
|
Update of /cvsroot/hamlib/hamlib/ft747 In directory slayer.i.sourceforge.net:/tmp/cvs-serv17770 Modified Files: ft747.c ft747.h Log Message: added set/get freq to use generic bcd etc Index: ft747.c =================================================================== RCS file: /cvsroot/hamlib/hamlib/ft747/ft747.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** ft747.c 2000/11/25 08:20:06 1.20 --- ft747.c 2000/11/25 21:49:34 1.21 *************** *** 32,41 **** * TODO - FS * ! * 1. Rentrant code * 2. rationalise code, more helper functions. * * - * - * */ --- 32,41 ---- * TODO - FS * ! * 1. Rentrant code, handle static stuff * 2. rationalise code, more helper functions. + * 3. Allow cached reads + * 4. Fix crappy 25Hz resolution handling * * */ *************** *** 53,61 **** #include "serial.h" #include "ft747.h" /* prototypes */ - int ft747_set_freq_main_vfo_hz(RIG *rig, freq_t freq, rmode_t mode); static int ft747_get_update_data(RIG *rig); --- 53,61 ---- #include "serial.h" #include "ft747.h" + #include "misc.h" /* prototypes */ static int ft747_get_update_data(RIG *rig); *************** *** 64,78 **** * Receiver caps */ - #if 0 - #define FT747_ALL_RX_MODES (RIG_MODE_AM| RIG_MODE_CW| RIG_MODE_USB| RIG_MODE_LSB| RIG_MODE_NAM| RIG_MODE_NCW) - #define FT747_SSB_CW_RX_MODES (RIG_MODE_CW| RIG_MODE_USB| RIG_MODE_LSB| RIG_MODE_NCW) - #define FT747_AM_RX_MODES (RIG_MODE_AM| RIG_MODE_NAM) - #else #define FT747_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB) #define FT747_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB) #define FT747_AM_RX_MODES (RIG_MODE_AM) - #endif - #define FT747_FM_RX_MODES (RIG_MODE_FM) --- 64,72 ---- * Receiver caps */ + #define FT747_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB) #define FT747_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB) #define FT747_AM_RX_MODES (RIG_MODE_AM) #define FT747_FM_RX_MODES (RIG_MODE_FM) *************** *** 158,168 **** }; - /* - * Init some private data - */ - - static const struct ft747_priv_data ft747_priv = { 0 }; /* dummy atm */ - /* * Function definitions below --- 152,156 ---- *************** *** 190,194 **** } ! printf("ft747:ft747_init called \n"); /* init the priv_data from static struct --- 178,182 ---- } ! rig_debug(RIG_DEBUG_VERBOSE,"ft747:ft747_init called \n"); /* init the priv_data from static struct *************** *** 274,282 **** int ft747_set_freq(RIG *rig, freq_t freq) { return -RIG_ENIMPL; } int ft747_get_freq(RIG *rig, freq_t *freq) { ! return -RIG_ENIMPL; } --- 262,317 ---- int ft747_set_freq(RIG *rig, freq_t freq) { + struct rig_state *rig_s; + struct ft747_priv_data *p; + + static unsigned char cmd[] = { 0x00, 0x00, 0x00, 0x00, 0x0a }; /* set freq */ + static unsigned char bcd[] = { 0,0,0,0 }; /* set freq */ + + int i; + + if (!rig) + return -RIG_EINVAL; + + p = (struct ft747_priv_data*)rig->state.priv; + rig_s = &rig->state; + + rig_debug(RIG_DEBUG_VERBOSE,"ft747: requested freq = %Li Hz \n", freq); + + to_bcd(bcd,freq,8); + + dump_hex(bcd,4); /* just checking */ + + rig_debug(RIG_DEBUG_VERBOSE,"ft747: requested freq after conversion = %Li Hz \n", from_bcd(bcd,8)); + + to_bcd(bcd,freq/10,8); /* must pass as multiple of 10 Hz to ft747 yuk , see TODO -- FS*/ + + for(i=0; i<4; i++) { + cmd[i] = bcd[i]; /* add bcd coded freq to cmd */ + } + + write_block(rig_s->fd, cmd, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay); + + return -RIG_ENIMPL; } int ft747_get_freq(RIG *rig, freq_t *freq) { ! struct ft747_priv_data *p; ! freq_t f; ! ! if (!rig) ! return -RIG_EINVAL; ! ! p = (struct ft747_priv_data*)rig->state.priv; ! ! 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 */ ! ! return RIG_OK; } *************** *** 338,342 **** int ft747_get_mode(RIG *rig, rmode_t *mode) { - struct rig_state *rig_s; struct ft747_priv_data *p; unsigned char mymode; /* ft747 mode */ --- 373,376 ---- *************** *** 346,350 **** p = (struct ft747_priv_data*)rig->state.priv; - rig_s = &rig->state; ft747_get_update_data(rig); /* get whole shebang from rig */ --- 380,383 ---- *************** *** 427,431 **** int ft747_get_vfo(RIG *rig, vfo_t *vfo) { - struct rig_state *rig_s; struct ft747_priv_data *p; unsigned char status; /* ft747 status flag */ --- 460,463 ---- *************** *** 435,439 **** p = (struct ft747_priv_data*)rig->state.priv; - rig_s = &rig->state; ft747_get_update_data(rig); /* get whole shebang from rig */ --- 467,470 ---- *************** *** 487,491 **** int ft747_get_ptt(RIG *rig, ptt_t *ptt) { - struct rig_state *rig_s; struct ft747_priv_data *p; unsigned char status; /* ft747 mode */ --- 518,521 ---- *************** *** 495,499 **** p = (struct ft747_priv_data*)rig->state.priv; - rig_s = &rig->state; ft747_get_update_data(rig); /* get whole shebang from rig */ --- 525,528 ---- Index: ft747.h =================================================================== RCS file: /cvsroot/hamlib/hamlib/ft747/ft747.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** ft747.h 2000/11/25 08:19:21 1.14 --- ft747.h 2000/11/25 21:49:34 1.15 *************** *** 39,43 **** ! /* Sequential fast writes confuse FT747 without this delay */ #define FT747_POST_WRITE_DELAY 5 --- 39,43 ---- ! /* Sequential fast writes confuse my FT747 without this delay */ #define FT747_POST_WRITE_DELAY 5 *************** *** 66,70 **** ! /* MODES - when setting modes via cmd_mode_set() */ #define MODE_SET_LSB 0x00 --- 66,70 ---- ! /* Internal MODES - when setting modes via cmd_mode_set() */ #define MODE_SET_LSB 0x00 *************** *** 92,95 **** --- 92,97 ---- #define MODE_LSB 0x10 #define MODE_NAR 0x80 + + /* All relevent bits */ #define MODE_MASK 0x9f *************** *** 118,122 **** #define FT747_SUMO_DISPLAYED_MODE 0x18 #define FT747_SUMO_DISPLAYED_STATUS 0x00 ! #define FT747_SUMO_DISPLAYED_FREQ 0x00 --- 120,124 ---- #define FT747_SUMO_DISPLAYED_MODE 0x18 #define FT747_SUMO_DISPLAYED_STATUS 0x00 ! #define FT747_SUMO_DISPLAYED_FREQ 0x01 *************** *** 128,132 **** struct ft747_priv_data { unsigned char pacing; /* pacing value */ ! unsigned int read_update_delay; /* depends on pacing value */ unsigned char update_data[FT747_STATUS_UPDATE_DATA_LENGTH]; /* returned data */ }; --- 130,135 ---- struct ft747_priv_data { unsigned char pacing; /* pacing value */ ! unsigned int read_update_delay; /* depends on pacing value */ ! unsigned char p_cmd[FT747_CMD_LENGTH]; /* private copy of constructed CAT cmd */ unsigned char update_data[FT747_STATUS_UPDATE_DATA_LENGTH]; /* returned data */ }; |