[Hamlib-cvs-digest] CVS: hamlib/ft747 ft747.c,1.24,1.25 ft747.h,1.17,1.18
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Frank S. <jav...@us...> - 2000-12-11 04:19:12
|
Update of /cvsroot/hamlib/hamlib/ft747 In directory slayer.i.sourceforge.net:/tmp/cvs-serv3455 Modified Files: ft747.c ft747.h Log Message: trying different approach to storing cmd sequence. _set_ptt is being converted. Needs tidying up though. Some sequences are complete, and can be read from static data. Incomplete sequences will eventually be copied form static declaration, and completed in priv data. Index: ft747.c =================================================================== RCS file: /cvsroot/hamlib/hamlib/ft747/ft747.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** ft747.c 2000/12/09 21:48:52 1.24 --- ft747.c 2000/12/11 04:19:10 1.25 *************** *** 32,36 **** * TODO - FS * ! * 1. Rentrant code, handle static stuff * 2. rationalise code, more helper functions. * 3. Allow cached reads --- 32,36 ---- * TODO - FS * ! * 1. Rentrant code, remove static stuff from all functions. * 2. rationalise code, more helper functions. * 3. Allow cached reads *************** *** 60,64 **** --- 60,103 ---- static int ft747_get_update_data(RIG *rig); + /* Native ft747 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 copied to priv data and completed */ + /* there. */ + + static const struct ft747_cmd_set ncmd[] = { + { 1, { 0x00, 0x00, 0x00, 0x00, 0x01 } }, /* split = off */ + { 1, { 0x00, 0x00, 0x00, 0x01, 0x01 } }, /* split = on */ + { 0, { 0x00, 0x00, 0x00, 0x00, 0x02 } }, /* recall memory*/ + { 0, { 0x00, 0x00, 0x00, 0x00, 0x03 } }, /* vfo to memory*/ + { 1, { 0x00, 0x00, 0x00, 0x00, 0x04 } }, /* dial lock = off */ + { 1, { 0x00, 0x00, 0x00, 0x01, 0x04 } }, /* dial lock = on */ + { 1, { 0x00, 0x00, 0x00, 0x00, 0x05 } }, /* select vfo A */ + { 1, { 0x00, 0x00, 0x00, 0x01, 0x05 } }, /* select vfo B */ + { 0, { 0x00, 0x00, 0x00, 0x00, 0x06 } }, /* memory to vfo*/ + { 1, { 0x00, 0x00, 0x00, 0x00, 0x07 } }, /* up 500 khz */ + { 1, { 0x00, 0x00, 0x00, 0x00, 0x08 } }, /* down 500 khz */ + { 1, { 0x00, 0x00, 0x00, 0x00, 0x09 } }, /* clarify off */ + { 1, { 0x00, 0x00, 0x00, 0x01, 0x09 } }, /* clarify on */ + { 0, { 0x00, 0x00, 0x00, 0x00, 0x0a } }, /* set freq */ + + { 1, { 0x00, 0x00, 0x00, 0x00, 0x0c } }, /* mode set LSB */ + { 1, { 0x00, 0x00, 0x00, 0x01, 0x0c } }, /* mode set USB */ + { 1, { 0x00, 0x00, 0x00, 0x02, 0x0c } }, /* mode set CWW */ + { 1, { 0x00, 0x00, 0x00, 0x03, 0x0c } }, /* mode set CWN */ + { 1, { 0x00, 0x00, 0x00, 0x04, 0x0c } }, /* mode set AMW */ + { 1, { 0x00, 0x00, 0x00, 0x05, 0x0c } }, /* mode set AMN */ + { 1, { 0x00, 0x00, 0x00, 0x06, 0x0c } }, /* mode set FMW */ + { 1, { 0x00, 0x00, 0x00, 0x07, 0x0c } }, /* mode set FMN */ + + { 0, { 0x00, 0x00, 0x00, 0x00, 0x0e } }, /* pacing set */ + { 1, { 0x00, 0x00, 0x00, 0x00, 0x0f } }, /* ptt off */ + { 1, { 0x00, 0x00, 0x00, 0x01, 0x0f } }, /* ptt on */ + { 1, { 0x00, 0x00, 0x00, 0x00, 0x10 } }, /* request update from rig */ + }; + + + /* * Receiver caps *************** *** 552,558 **** struct rig_state *rig_s; struct ft747_priv_data *p; ! ! static unsigned char cmd_ptt_off[] = { 0x00, 0x00, 0x00, 0x00, 0x0f }; /* ptt off */ ! static unsigned char cmd_ptt_on[] = { 0x00, 0x00, 0x00, 0x01, 0x0f }; /* ptt on */ if (!rig) --- 591,595 ---- struct rig_state *rig_s; struct ft747_priv_data *p; ! unsigned char *cmd; /* points to sequence to send */ if (!rig) *************** *** 564,577 **** ft747_set_vfo(rig,vfo); /* select VFO first */ switch(ptt) { case RIG_PTT_OFF: ! write_block(rig_s->fd, cmd_ptt_off, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay); ! return RIG_OK; case RIG_PTT_ON: ! write_block(rig_s->fd, cmd_ptt_on, 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 */ } --- 601,617 ---- ft747_set_vfo(rig,vfo); /* select VFO first */ + switch(ptt) { case RIG_PTT_OFF: ! cmd = (unsigned char *)&ncmd[FT_747_NATIVE_MODE_PTT_OFF].nseq; /* get native sequence */ ! break; case RIG_PTT_ON: ! cmd = (unsigned char *)&ncmd[FT_747_NATIVE_MODE_PTT_ON].nseq; ! break; default: return -RIG_EINVAL; /* sorry, wrong VFO */ } + + write_block(rig_s->fd, cmd, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay); return RIG_OK; /* good */ } *************** *** 816,819 **** --- 856,871 ---- #endif + + /* + * Private helper cmd to copy a native cmd sequence to priv + */ + + static void build_cmd(unsigned char *dst, int command){ + int i; + for(i=0; i<FT747_CMD_LENGTH; i++) { + dst[i] = ncmd[command].nseq[i]; /* lookup native cmd and build sequence */ + } + return; + } Index: ft747.h =================================================================== RCS file: /cvsroot/hamlib/hamlib/ft747/ft747.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** ft747.h 2000/12/09 02:03:26 1.17 --- ft747.h 2000/12/11 04:19:10 1.18 *************** *** 66,69 **** --- 66,173 ---- + + /* + * Native FT747 functions. This is what I have to work with :-) + * + */ + + enum ft747_native_cmd_e { + FT_747_NATIVE_SPLIT_OFF = 0, + FT_747_NATIVE_SPLIT_ON, + FT_747_NATIVE_RECALL_MEM, + FT_747_NATIVE_VFO_TO_MEM, + FT_747_NATIVE_DLOCK_OFF, + FT_747_NATIVE_DLOCK_ON, + FT_747_NATIVE_VFO_A, + FT_747_NATIVE_VFO_B, + FT_747_NATIVE_M_TO_VFO, + FT_747_NATIVE_UP_500K, + FT_747_NATIVE_DOWN_500K, + FT_747_NATIVE_CLARIFY_OFF, + FT_747_NATIVE_CLARIFY_ON, + FT_747_NATIVE_FREQ_SET, + FT_747_NATIVE_MODE_SET_LSB, + FT_747_NATIVE_MODE_SET_USB, + FT_747_NATIVE_MODE_SET_CWW, + FT_747_NATIVE_MODE_SET_CWN, + FT_747_NATIVE_MODE_SET_AMW, + FT_747_NATIVE_MODE_SET_AMN, + FT_747_NATIVE_MODE_SET_FMW, + FT_747_NATIVE_MODE_SET_FMN, + FT_747_NATIVE_MODE_PACING, + FT_747_NATIVE_MODE_PTT_OFF, + FT_747_NATIVE_MODE_PTT_ON, + FT_747_NATIVE_MODE_UPDATE + + }; + + typedef enum ft747_native_cmd_e ft747_native_cmd_t; + + + /* + * Data structure for FT747 native cmd set + */ + + struct ft747_cmd_set { + unsigned char ncomp; /* 1 = complete, 0 = incomplete, needs extra info */ + unsigned char nseq[5]; /* native cmd sequence */ + }; + + /* typedef struct ft747_cmd_set ft747_cmd_set_t; */ + + #if 0 + #define FT_747_NATIVE_SPLIT_OFF 0 + #define FT_747_NATIVE_SPLIT_ON 1 + #define FT_747_NATIVE_RECALL_MEM 2 + #define FT_747_NATIVE_VFO_TO_MEM 3 + #define FT_747_NATIVE_DLOCK_OFF 4 + #define FT_747_NATIVE_DLOCK_ON 5 + #define FT_747_NATIVE_VFO_A 6 + #define FT_747_NATIVE_VFO_B 7 + + #define FT_747_NATIVE_M_TO_VFO 9 + #define FT_747_NATIVE_UP_500K 9 + #define FT_747_NATIVE_DOWN_500K 10 + #define FT_747_NATIVE_CLARIFY_OFF 12 + #define FT_747_NATIVE_CLARIFY_ON 12 + #define FT_747_NATIVE_FREQ_SET 13 + + #define FT_747_NATIVE_MODE_SET_LSB 14 + #define FT_747_NATIVE_MODE_SET_USB 15 + #define FT_747_NATIVE_MODE_SET_CWW 16 + #define FT_747_NATIVE_MODE_SET_CWN 17 + #define FT_747_NATIVE_MODE_SET_AMW 18 + #define FT_747_NATIVE_MODE_SET_AMN 19 + #define FT_747_NATIVE_MODE_SET_FMW 20 + #define FT_747_NATIVE_MODE_SET_FMN 20 + + #define FT_747_NATIVE_MODE_PACING 21 + #define FT_747_NATIVE_MODE_PTT_OFF 22 + #define FT_747_NATIVE_MODE_PTT_ON 23 + #define FT_747_NATIVE_MODE_UPDATE 24 + + + #endif + + + + + + + + + + + + + + + + + + + + + /* Internal MODES - when setting modes via cmd_mode_set() */ |