started ft747_set_ptt and ft747_set_vfo

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@148 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.1.0
Frank Singleton, VK3FCS 2000-09-24 03:35:39 +00:00
rodzic b7a058d814
commit a161780ccd
1 zmienionych plików z 111 dodań i 50 usunięć

Wyświetl plik

@ -7,7 +7,7 @@
* box (FIF-232C) or similar
*
*
* $Id: ft747.c,v 1.12 2000-09-23 00:35:45 javabear Exp $
* $Id: ft747.c,v 1.13 2000-09-24 03:35:39 javabear Exp $
*
*
* This program is free software; you can redistribute it and/or
@ -125,8 +125,18 @@ const struct rig_caps ft747_caps = {
NULL, /* port closed */
NULL, /* probe not supported yet */
ft747_set_freq_main_vfo_hz ,/* set freq */
NULL, /* get freq, add later */
ft747_set_freq, /* set freq */
ft747_get_freq, /* get freq */
ft747_set_mode, /* set mode */
ft747_get_mode, /* get mode */
ft747_set_vfo, /* set vfo */
ft747_get_vfo, /* get vfo */
ft747_set_ptt, /* set ptt */
ft747_get_ptt, /* get ptt */
NULL, /* add later */
NULL, /* add later */
};
/*
@ -149,14 +159,16 @@ int ft747_init(RIG *rig) {
struct ft747_priv_data *p;
if (!rig)
return -1;
return -RIG_EINVAL;
p = (struct ft747_priv_data*)malloc(sizeof(struct ft747_priv_data));
if (!p) {
/* whoops! memory shortage! */
return -2;
return -RIG_ENOMEM;
}
printf("ft747:ft747_init called \n");
/* init the priv_data from static struct
* + override with rig-specific preferences
*/
@ -165,7 +177,7 @@ int ft747_init(RIG *rig) {
rig->state.priv = (void*)p;
return 0;
return RIG_OK;
}
@ -175,13 +187,15 @@ int ft747_init(RIG *rig) {
*/
int ft747_cleanup(RIG *rig) {
if (!rig)
return -1;
return -RIG_EINVAL;
printf("ft747:ft747_cleanup called \n");
if (rig->state.priv)
free(rig->state.priv);
rig->state.priv = NULL;
return 0;
return RIG_OK;
}
@ -190,46 +204,93 @@ int ft747_cleanup(RIG *rig) {
*
*/
int ft747_set_freq_main_vfo_hz(RIG *rig, freq_t freq, rmode_t mode) {
struct ft747_priv_data *p;
int ft747_set_freq(RIG *rig, freq_t freq) {
return -RIG_ENIMPL;
}
int ft747_get_freq(RIG *rig, freq_t *freq) {
return -RIG_ENIMPL;
}
int ft747_set_mode(RIG *rig, rmode_t mode) {
return -RIG_ENIMPL;
}
int ft747_get_mode(RIG *rig, rmode_t *mode) {
return -RIG_ENIMPL;
}
int ft747_set_vfo(RIG *rig, vfo_t vfo) {
struct rig_state *rig_s;
unsigned char buf[16];
int frm_len = 5; /* fix later */
/* example opcode */
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x04 }; /* dial lock = on, FIX once freq is implemented */
/* in backend */
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)
return -1;
return -RIG_EINVAL;
p = (struct ft747_priv_data*)rig->state.priv;
rig_s = &rig->state;
/*
* should check return code and that write wrote cmd_len chars!
* TODO : check for errors -- FS
*/
write_block2(rig_s->fd, data, frm_len, rig_s->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;
switch(vfo) {
case RIG_VFO_A:
write_block(rig_s->fd, cmd_A, FT747_CMD_LENGTH, rig_s->write_delay);
return RIG_OK;
case RIG_VFO_B:
write_block(rig_s->fd, cmd_B, FT747_CMD_LENGTH, rig_s->write_delay);
return RIG_OK;
default:
return -RIG_EINVAL; /* sorry, wrong VFO */
}
return RIG_OK; /* good */
}
int ft747_get_vfo(RIG *rig, vfo_t *vfo) {
return -RIG_ENIMPL;
}
int ft747_set_ptt(RIG *rig, ptt_t ptt) {
struct rig_state *rig_s;
struct ft747_priv_data *p;
static unsigned char ptt_off[] = { 0x00, 0x00, 0x00, 0x00, 0x0f }; /* ptt off */
static unsigned char ptt_on[] = { 0x00, 0x00, 0x00, 0x01, 0x0f }; /* ptt on */
if (!rig)
return -RIG_EINVAL;
p = (struct ft747_priv_data*)rig->state.priv;
rig_s = &rig->state;
switch(ptt) {
case RIG_PTT_OFF:
write_block(rig_s->fd, ptt_off, FT747_CMD_LENGTH, rig_s->write_delay);
return RIG_OK;
case RIG_PTT_ON:
write_block(rig_s->fd, ptt_on, FT747_CMD_LENGTH, rig_s->write_delay);
return RIG_OK;
default:
return -RIG_EINVAL; /* sorry, wrong VFO */
}
return RIG_OK; /* good */
}
int ft747_get_ptt(RIG *rig, ptt_t *ptt) {
return -RIG_ENIMPL;
}
@ -242,76 +303,76 @@ int ft747_set_freq_main_vfo_hz(RIG *rig, freq_t freq, rmode_t mode) {
void ft747_cmd_set_split_yes(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x01 }; /* split = on */
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_split_no(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x01 }; /* split = off */
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_recall_memory(int fd, int mem) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x02 }; /* recall memory*/
data[3] = mem;
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_vfo_to_memory(int fd, int mem) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x03 }; /* vfo to memory*/
data[3] = mem;
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_dlock_off(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x04 }; /* dial lock = off */
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_dlock_on(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x04 }; /* dial lock = on */
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_select_vfo_a(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x05 }; /* select vfo A */
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_select_vfo_b(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x05 }; /* select vfo B */
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_memory_to_vfo(int fd, int mem) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x06 }; /* memory to vfo*/
data[3] = mem;
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_up500k(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x07 }; /* up 500 khz */
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_down500k(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x08 }; /* down 500 khz */
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_clarify_off(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x09 }; /* clarify off */
write_block2(fd,data);
write_block(fd,data);
printf("ft747_cmd_clarify_off complete \n");
}
void ft747_cmd_set_clarify_on(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x09 }; /* clarify on */
write_block2(fd,data);
write_block(fd,data);
}
@ -324,7 +385,7 @@ void ft747_cmd_set_mode(int fd, int mode) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0c }; /* mode set */
data[3] = mode;
write_block2(fd,data);
write_block(fd,data);
}
@ -332,13 +393,13 @@ void ft747_cmd_set_pacing(int fd, int delay) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0e }; /* pacing set */
data[3] = delay;
write_block2(fd,data);
write_block(fd,data);
}
void ft747_cmd_set_ptt_off(int fd) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0f }; /* ptt off */
write_block2(fd,data);
write_block(fd,data);
}
@ -346,7 +407,7 @@ void ft747_cmd_set_ptt_on(int fd) {
#ifdef TX_ENABLED
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x0f }; /* ptt on */
write_block2(fd,data);
write_block(fd,data);
printf("ft747_cmd_ptt_on complete \n");
#elsif
printf("ft747_cmd_ptt_on disabled \n");
@ -364,7 +425,7 @@ void ft747_cmd_get_update_store(int fd, unsigned char *buffer) {
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x10 }; /* request update from rig */
write_block2(fd,data);
write_block(fd,data);
n = read_sleep(fd,buffer,345); /* wait and read for 345 bytes to be read */
return;