removed old API functions, general cleanup

tested rig_close and rig_cleanup


git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@302 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.1.1
Frank Singleton, VK3FCS 2000-12-22 01:27:01 +00:00
rodzic 92c0043aad
commit 493b28369a
1 zmienionych plików z 12 dodań i 633 usunięć

Wyświetl plik

@ -6,7 +6,7 @@
* via serial interface to an FT-847 using the "CAT" interface.
*
*
* $Id: ft847.c,v 1.27 2000-12-20 06:33:59 javabear Exp $
* $Id: ft847.c,v 1.28 2000-12-22 01:27:01 javabear Exp $
*
*
*
@ -30,6 +30,8 @@
/*
* TODO - Remove static stuff, see ft747 for new style.
* - create yaesu.h for common command structure etc..
* - add mode set before freq set to avoid prior mode offset (eg: CW)
*
*/
/*
@ -37,9 +39,9 @@
* related to the Yaesu's FT847 design, not my program :-)
*
* 1. Rig opcodes allow only 10Hz resolution.
* 2. Cannot select VFO
*
*
* 2. Cannot select VFO B
* 3. Using CAT and Tuner controls simultaneously can
* cause problems.
*
*/
@ -443,6 +445,7 @@ int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
}
int ft847_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) {
return -RIG_ENIMPL;
}
@ -618,640 +621,16 @@ int ft847_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) {
}
#if 0
int ft847_set_freq_main_vfo_hz(RIG *rig, freq_t freq, rmode_t mode) {
struct ft847_priv_data *p;
struct rig_state *rig_s;
unsigned char buf[16];
int frm_len = 5; /* fix later */
/* examlpe opcode */
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x04 }; /* dial lock = on */
if (!rig)
return -1;
p = (struct ft847_priv_data*)rig->state.priv;
rig_s = &rig->state;
/*
* should check return code and that write wrote cmd_len chars!
*/
write_block(rig_s->fd, data, frm_len, rig_s->write_delay, rig_s->post_write_delay);
/*
* wait for ACK ... etc..
*/
read_block(rig_s->fd, buf, frm_len, rig_s->timeout);
/*
* TODO: check address, Command number and ack!
*/
/* then set the mode ... etc. */
return 0;
}
#define TRUE 1;
#define FALSE 0;
static unsigned char datain[5]; /* data read from rig */
static long int calc_freq_from_packed4(unsigned char *in);
static void calc_packed4_from_freq(long int freq, unsigned char *out);
static struct rig_caps rigft847 = {
"ft847", 4800, 57600, 8, 2, RIG_PARITY_NONE, ""
};
/*
* Allowable DCS Codes
*
*/
static int dcs_allowed[] = {
23,25,26,31,32,36,43,47,51,53,54,65,71,
72,73,74,114,115,116,122,125,131,132,134,143,145,
152,155,156,162,165,172,174,205,212,223,225,226,243,
244,245,246,251,252,255,266,263,265,266,271,274,306,
311,315,325,331,332,343,347,351,356,364,365,371,411,
412,413,423,431,432,445,446,452,454,455,462,464,465,
466,503,506,516,523,526,532,546,565,606,612,624,627,
631,632,654,662,664,703,712,723,731,732,734,743,754
};
/*
* Function definitions below
*/
/*
* Open serial connection to rig.
* returns fd.
*/
/* int rig_open(char *serial_port) { */
/* return open_port(serial_port); */
/* } */
/*
* Open serial connection to rig using rig_caps
* returns fd.
*/
int rig_open(struct rig_caps *rc) {
return open_port2(rc);
}
/*
* Closes serial connection to rig.
*
*/
int rig_close(int fd) {
return close_port(fd);
}
/*
* Gets rig capabilities.
*
*/
struct rig_caps *rig_get_caps() {
struct rig_caps *rc;
rc = &rigft847;
printf("rig = %s \n", rc->rig_name);
printf("rig serial_rate_min = = %u \n", rc->serial_rate_min);
printf("rig serial_rate_max = = %u \n", rc->serial_rate_max);
return &rigft847;
}
/*
* Implement OPCODES
*/
void cmd_set_cat_on(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x00 }; /* cat = on */
write_block(fd,data);
}
void cmd_set_cat_off(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x80 }; /* cat = off */
write_block(fd,data);
}
void cmd_set_ptt_on(int fd) {
#ifdef TX_ENABLED
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0f }; /* ptt = on */
write_block(fd,data);
printf("cmd_ptt_on complete \n");
#elsif
printf("cmd_ptt_on disabled \n");
#endif
}
void cmd_set_ptt_off(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x88 }; /* ptt = off */
write_block(fd,data);
}
void cmd_set_sat_on(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x4e }; /* sat = on */
write_block(fd,data);
}
void cmd_set_sat_off(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x8e }; /* sat = off */
write_block(fd,data);
}
void cmd_set_freq_main_vfo(int fd, unsigned char d1, unsigned char d2,
unsigned char d3, unsigned char d4) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x01 }; /* set freq, main vfo*/
data[0] = d1;
data[1] = d2;
data[2] = d3;
data[3] = d4;
write_block(fd,data);
}
void cmd_set_freq_sat_rx_vfo(int fd, unsigned char d1, unsigned char d2,
unsigned char d3, unsigned char d4) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x11 }; /* set freq, sat rx vfo*/
data[0] = d1;
data[1] = d2;
data[2] = d3;
data[3] = d4;
write_block(fd,data);
}
void cmd_set_freq_sat_tx_vfo(int fd, unsigned char d1, unsigned char d2,
unsigned char d3, unsigned char d4) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x21 }; /* set freq, sat tx vfo*/
data[0] = d1;
data[1] = d2;
data[2] = d3;
data[3] = d4;
write_block(fd,data);
}
void cmd_set_opmode_main_vfo(int fd, unsigned char d1) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x07 }; /* set opmode, main vfo*/
data[0] = d1;
write_block(fd,data);
}
void cmd_set_opmode_sat_rx_vfo(int fd, unsigned char d1) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x17 }; /* set opmode, sat rx vfo */
data[0] = d1;
write_block(fd,data);
}
void cmd_set_opmode_sat_tx_vfo(int fd, unsigned char d1) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x27 }; /* set opmode, sat tx vfo */
data[0] = d1;
write_block(fd,data);
}
void cmd_set_ctcss_dcs_main_vfo(int fd, unsigned char d1) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0a }; /* set ctcss/dcs, main vfo*/
data[0] = d1;
write_block(fd,data);
}
void cmd_set_ctcss_dcs_sat_rx_vfo(int fd, unsigned char d1) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x1a }; /* set ctcss/dcs, sat rx vfo*/
data[0] = d1;
write_block(fd,data);
}
void cmd_set_ctcss_dcs_sat_tx_vfo(int fd, unsigned char d1) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x2a }; /* set ctcss/dcs, sat tx vfo*/
data[0] = d1;
write_block(fd,data);
}
void cmd_set_ctcss_freq_main_vfo(int fd, unsigned char d1) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0b }; /* set ctcss freq, main vfo*/
data[0] = d1;
write_block(fd,data);
}
void cmd_set_ctcss_freq_sat_rx_vfo(int fd, unsigned char d1) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x1b }; /* set ctcss freq, sat rx vfo*/
data[0] = d1;
write_block(fd,data);
}
void cmd_set_ctcss_freq_sat_tx_vfo(int fd, unsigned char d1) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x2b }; /* set ctcss freq, sat rx vfo*/
data[0] = d1;
write_block(fd,data);
}
void cmd_set_dcs_code_main_vfo(int fd, unsigned char d1, unsigned char d2) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0c }; /* set dcs code, main vfo*/
data[0] = d1;
data[1] = d2;
write_block(fd,data);
}
void cmd_set_dcs_code_sat_rx_vfo(int fd, unsigned char d1, unsigned char d2) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x1c }; /* set dcs code, sat rx vfo*/
data[0] = d1;
data[1] = d2;
write_block(fd,data);
}
void cmd_set_dcs_code_sat_tx_vfo(int fd, unsigned char d1, unsigned char d2) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x2c }; /* set dcs code, sat tx vfo*/
data[0] = d1;
data[1] = d2;
write_block(fd,data);
}
void cmd_set_repeater_shift_minus(int fd) {
static unsigned char data[] = { 0x09, 0x00, 0x00, 0x00, 0x09 }; /* set repeater shift minus */
write_block(fd,data);
}
void cmd_set_repeater_shift_plus(int fd) {
static unsigned char data[] = { 0x49, 0x00, 0x00, 0x00, 0x09 }; /* set repeater shift */
write_block(fd,data);
}
void cmd_set_repeater_shift_simplex(int fd) {
static unsigned char data[] = { 0x89, 0x00, 0x00, 0x00, 0x09 }; /* set repeater simplex */
write_block(fd,data);
}
void cmd_set_repeater_offset(int fd, unsigned char d1, unsigned char d2,
unsigned char d3, unsigned char d4) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0xf9 }; /* set repeater offset */
data[0] = d1;
data[1] = d2;
data[2] = d3;
data[3] = d4;
write_block(fd,data);
}
/*
* Get data rx from the RIG...only 1 byte
*
*/
unsigned char cmd_get_rx_status(int fd) {
int n; /* counters */
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0xe7 }; /* get receiver status */
write_block(fd,data);
n = read_sleep(fd,datain,1); /* wait and read for 1 byte to be read */
printf("datain[0] = %x \n",datain[0]);
return datain[0];
}
/*
* Get data tx from the RIG...only 1 byte
*
*/
unsigned char cmd_get_tx_status(int fd) {
int n; /* counters */
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0xf7 }; /* get tx status */
write_block(fd,data);
n = read_sleep(fd,datain,1); /* wait and read for 1 byte to be read */
printf("datain[0] = %x \n",datain[0]);
return datain[0];
}
/*
* Get freq and mode data from the RIG main VFO...only 5 bytes
*
*/
long int cmd_get_freq_mode_status_main_vfo(int fd, unsigned char *mode) {
long int f;
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x03 }; /* get freq and mode status */
/* main vfo*/
write_block(fd,data);
read_sleep(fd,datain,5); /* wait and read for 5 byte to be read */
f = calc_freq_from_packed4(datain); /* 1st 4 bytes */
*mode = datain[4]; /* last byte */
return f; /* return freq in Hz */
}
/*
* Get freq and mode data from the RIG sat RX vfo ...only 5 bytes
*
*/
long int cmd_get_freq_mode_status_sat_rx_vfo(int fd, unsigned char *mode ) {
long int f;
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x13 }; /* get freq and mode status */
/* sat rx vfo*/
write_block(fd,data);
read_sleep(fd,datain,5); /* wait and read for 5 byte to be read */
f = calc_freq_from_packed4(datain); /* 1st 4 bytes */
*mode = datain[4]; /* last byte */
return f; /* return freq in Hz */
}
/*
* Get freq and mode data from the RIG sat TX VFO...only 5 bytes
*
*/
long int cmd_get_freq_mode_status_sat_tx_vfo(int fd, unsigned char *mode) {
long int f;
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x23 }; /* get freq and mode status */
/* sat tx vfo*/
write_block(fd,data);
read_sleep(fd,datain,5); /* wait and read for 5 byte to be read */
f = calc_freq_from_packed4(datain); /* 1st 4 bytes */
*mode = datain[4]; /* last byte */
return f; /* return freq in Hz */
}
/*
* Set main vfo frequency in Hz and mode.
*
*/
void cmd_set_freq_main_vfo_hz(int fd,long int freq, unsigned char mode) {
unsigned char d1,d2,d3,d4;
unsigned char farray[4]; /* holds packed freq */
calc_packed4_from_freq(freq,farray); /* and store in farray */
d1 = farray[0];
d2 = farray[1];
d3 = farray[2];
d4 = farray[3];
cmd_set_opmode_main_vfo(fd,mode); /* set mode first, otherwise previous CW mode */
/* causes offset for next freq set command */
cmd_set_freq_main_vfo(fd,d1,d2,d3,d4); /* set freq */
}
/*
* Set sat rx vfo frequency in Hz and mode.
*
*/
void cmd_set_freq_sat_rx_vfo_hz(int fd,long int freq, unsigned char mode) {
unsigned char d1,d2,d3,d4;
unsigned char farray[4]; /* holds packed freq */
calc_packed4_from_freq(freq,farray); /* and store in farray */
d1 = farray[0];
d2 = farray[1];
d3 = farray[2];
d4 = farray[3];
cmd_set_opmode_sat_rx_vfo(fd,mode); /* set mode first, otherwise previous CW mode */
/* causes offset for next freq set command */
cmd_set_freq_sat_rx_vfo(fd,d1,d2,d3,d4); /* set freq */
}
/*
* Set sat tx vfo frequency in Hz and mode.
*
*/
void cmd_set_freq_sat_tx_vfo_hz(int fd,long int freq, unsigned char mode) {
unsigned char d1,d2,d3,d4;
unsigned char farray[4]; /* holds packed freq */
calc_packed4_from_freq(freq,farray); /* and store in farray */
d1 = farray[0];
d2 = farray[1];
d3 = farray[2];
d4 = farray[3];
cmd_set_opmode_sat_tx_vfo(fd,mode); /* set mode first, otherwise previous CW mode */
/* causes offset for next freq set command */
cmd_set_freq_sat_tx_vfo(fd,d1,d2,d3,d4); /* set freq */
}
/*
* Set Repeater offset in Hz.
*
*/
void cmd_set_repeater_offset_hz(int fd,long int freq) {
unsigned char d1,d2,d3,d4;
unsigned char farray[4]; /* holds packed freq */
/* can only specify multiples of 10Hz on FT847, but */
/* calc_packed4_from_freq() does that for us , so dont */
/* do it here.. */
calc_packed4_from_freq(freq,farray); /* and store in farray */
d1 = farray[0];
d2 = farray[1];
d3 = farray[2];
d4 = farray[3];
cmd_set_repeater_offset(fd,d1,d2,d3,d4); /* set freq */
}
/*
* Private helper functions....
*
*/
/*
* Calculate freq from packed decimal (4 bytes, 8 digits)
* and return frequency in Hz. No string routines.
*
*/
static long int calc_freq_from_packed4(unsigned char *in) {
long int f; /* frequnecy in Hz */
unsigned char d1,d2,d3,d4;
printf("frequency/mode = %.2x%.2x%.2x%.2x %.2x \n", in[0], in[1], in[2], in[3], in[4]);
d1 = calc_char_from_packed(in[0]);
d2 = calc_char_from_packed(in[1]);
d3 = calc_char_from_packed(in[2]);
d4 = calc_char_from_packed(in[3]);
f = d1*1000000;
f += d2*10000;
f += d3*100;
f += d4;
f = f *10; /* yaesu uses freq as multiple of 10 Hz, so must */
/* scale to return Hz*/
printf("ft847:frequency = %ld Hz\n", f);
return f; /* Hz */
}
/*
* Calculate packed decimal from freq hz (4 bytes, 8 digits)
* and return packed decimal frequency in out[] array.
*
* Note this routine also scales freq as multiple of
* 10Hz as required for most freq parameters.
*
*/
static void calc_packed4_from_freq(long int freq, unsigned char *out) {
unsigned char d1,d2,d3,d4;
long int f1,f2,f3,f4;
freq = freq / 10; /* yaesu ft847 only accepts 10Hz resolution */
f1 = freq / 1000000; /* get 100 Mhz/10 Mhz part */
f2 = (freq - (f1 * 1000000)) / 10000; /* get 1Mhz/100Khz part */
f3 = (freq - (f1 * 1000000) - (f2 * 10000)) / 100; /* get 10khz/1khz part */
f4 = (freq - (f1 * 1000000) - (f2 * 10000) - (f3 * 100)); /* get 10khz/1khz part */
d1 = calc_packed_from_char(f1);
d2 = calc_packed_from_char(f2);
d3 = calc_packed_from_char(f3);
d4 = calc_packed_from_char(f4);
out[0] = d1; /* get 100 Mhz-10 Mhz part */
out[1] = d2; /* get 1Mhz-100Khz part */
out[2] = d3; /* get 10khz-1khz part */
out[3] = d4; /* get 10khz-1khz part */
}
/*
* To see if a value is present in an array of ints.
*
*/
static int is_in_list(int *list, int list_length, int value) {
int i;
for(i=0; i<list_length; i++){
if (*(list+i) == value)
return TRUE; /* found */
}
return FALSE; /* not found */
}
#endif /* 0 */
/*
* init_ft847 is called by rig_backend_load
*/
int init_ft847(void *be_handle)
{
rig_debug(RIG_DEBUG_VERBOSE, "ft847: _init called\n");
rig_register(&ft847_caps);
int init_ft847(void *be_handle) {
rig_debug(RIG_DEBUG_VERBOSE, "ft847: _init called\n");
return RIG_OK;
rig_register(&ft847_caps);
return RIG_OK;
}