kopia lustrzana https://github.com/Hamlib/Hamlib
Moved from ft747 and ft847 dirs
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@310 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.1.1
rodzic
17b888a4d5
commit
52cd5cf034
|
@ -0,0 +1,916 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* ft747.c - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to an FT-747GX using the "CAT" interface
|
||||
* box (FIF-232C) or similar
|
||||
*
|
||||
*
|
||||
* $Id: ft747.c,v 1.1 2001-01-04 05:39:03 javabear Exp $
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* TODO - FS
|
||||
*
|
||||
* 1. Rentrant code, remove static stuff from all functions.
|
||||
* 2. rationalise code, more helper functions.
|
||||
* 3. Allow cached reads
|
||||
* 4. Fix crappy 25Hz resolution handling
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h> /* Standard input/output definitions */
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <termios.h> /* POSIX terminal control definitions */
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include <hamlib/riglist.h>
|
||||
#include "serial.h"
|
||||
#include "ft747.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
/* prototypes */
|
||||
|
||||
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 completed with extra parameters */
|
||||
/* eg: mem number, or freq etc.. */
|
||||
|
||||
static const ft747_cmd_set_t 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
|
||||
*/
|
||||
|
||||
|
||||
#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)
|
||||
|
||||
|
||||
/*
|
||||
* TX caps
|
||||
*/
|
||||
|
||||
#define FT747_OTHER_TX_MODES (RIG_MODE_CW| RIG_MODE_USB| RIG_MODE_LSB ) /* 100 W class */
|
||||
#define FT747_AM_TX_MODES (RIG_MODE_AM ) /* set 25W max */
|
||||
|
||||
#define FT747_FUNC_ALL (RIG_FUNC_FAGC|RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_SBKIN|RIG_FUNC_FBKIN) /* fix */
|
||||
|
||||
/*
|
||||
* ft747 rigs capabilities.
|
||||
* Also this struct is READONLY!
|
||||
*/
|
||||
|
||||
const struct rig_caps ft747_caps = {
|
||||
RIG_MODEL_FT747, "FT-747GX", "Yaesu", "0.1", RIG_STATUS_ALPHA,
|
||||
RIG_TYPE_MOBILE, RIG_PTT_RIG, 4800, 4800, 8, 2, RIG_PARITY_NONE,
|
||||
RIG_HANDSHAKE_NONE, FT747_WRITE_DELAY, FT747_POST_WRITE_DELAY, 2000, 0,FT747_FUNC_ALL,0,0,20,RIG_TRN_OFF,
|
||||
{ {100000,29999900,FT747_ALL_RX_MODES,-1,-1}, {0,0,0,0,0}, }, /* rx range */
|
||||
|
||||
{ {1500000,1999900,FT747_OTHER_TX_MODES,5000,100000}, /* 100W class */
|
||||
{1500000,1999900,FT747_AM_TX_MODES,2000,25000}, /* 25W class */
|
||||
|
||||
{3500000,3999900,FT747_OTHER_TX_MODES,5000,100000},
|
||||
{3500000,3999900,FT747_AM_TX_MODES,2000,25000},
|
||||
|
||||
{7000000,7499900,FT747_OTHER_TX_MODES,5000,100000},
|
||||
{7000000,7499900,FT747_AM_TX_MODES,2000,25000},
|
||||
|
||||
{10000000,10499900,FT747_OTHER_TX_MODES,5000,100000},
|
||||
{10000000,10499900,FT747_AM_TX_MODES,2000,25000},
|
||||
|
||||
{14000000,14499900,FT747_OTHER_TX_MODES,5000,100000},
|
||||
{14000000,14499900,FT747_AM_TX_MODES,2000,25000},
|
||||
|
||||
{18000000,18499900,FT747_OTHER_TX_MODES,5000,100000},
|
||||
{18000000,18499900,FT747_AM_TX_MODES,2000,25000},
|
||||
|
||||
{21000000,21499900,FT747_OTHER_TX_MODES,5000,100000},
|
||||
{21000000,21499900,FT747_AM_TX_MODES,2000,25000},
|
||||
|
||||
{24500000,24999900,FT747_OTHER_TX_MODES,5000,100000},
|
||||
{24500000,24999900,FT747_AM_TX_MODES,2000,25000},
|
||||
|
||||
{28000000,29999900,FT747_OTHER_TX_MODES,5000,100000},
|
||||
{28000000,29999900,FT747_AM_TX_MODES,2000,25000},
|
||||
|
||||
{0,0,0,0,0} },
|
||||
|
||||
{ {FT747_SSB_CW_RX_MODES,25}, /* fast off */
|
||||
{FT747_SSB_CW_RX_MODES,2500}, /* fast on */
|
||||
|
||||
{FT747_AM_RX_MODES,KHz(1)}, /* fast off */
|
||||
{FT747_AM_RX_MODES,KHz(10)}, /* fast on */
|
||||
|
||||
{FT747_FM_RX_MODES,KHz(5)}, /* fast off */
|
||||
{FT747_FM_RX_MODES,12500}, /* fast on */
|
||||
|
||||
{0,0}
|
||||
},
|
||||
ft747_init,
|
||||
ft747_cleanup,
|
||||
ft747_open, /* port opened */
|
||||
ft747_close, /* port closed */
|
||||
NULL, /* probe not supported yet */
|
||||
|
||||
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 */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Function definitions below
|
||||
*/
|
||||
|
||||
/*
|
||||
* setup *priv
|
||||
* serial port is already open (rig->state->fd)
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
int ft747_init(RIG *rig) {
|
||||
struct ft747_priv_data *p;
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft747_priv_data*)malloc(sizeof(struct ft747_priv_data));
|
||||
if (!p) {
|
||||
/* whoops! memory shortage! */
|
||||
return -RIG_ENOMEM;
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747:ft747_init called \n");
|
||||
|
||||
/*
|
||||
* Copy native cmd set to private cmd storage area
|
||||
*/
|
||||
|
||||
memcpy(p->pcs,ncmd,sizeof(ncmd));
|
||||
|
||||
/* TODO: read pacing from preferences */
|
||||
|
||||
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;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ft747_cleanup routine
|
||||
* the serial port is closed by the frontend
|
||||
*/
|
||||
int ft747_cleanup(RIG *rig) {
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "ft747: _cleanup called\n");
|
||||
|
||||
if (rig->state.priv)
|
||||
free(rig->state.priv);
|
||||
rig->state.priv = NULL;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* ft747_open routine
|
||||
*
|
||||
*/
|
||||
|
||||
int ft747_open(RIG *rig) {
|
||||
struct rig_state *rig_s;
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
rig_s = &rig->state;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747:rig_open: write_delay = %i msec \n", rig_s->write_delay);
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747:rig_open: post_write_delay = %i msec \n", rig_s->post_write_delay);
|
||||
|
||||
|
||||
/* TODO */
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ft747_close routine
|
||||
*
|
||||
*/
|
||||
|
||||
int ft747_close(RIG *rig) {
|
||||
struct rig_state *rig_s;
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
rig_s = &rig->state;
|
||||
|
||||
/* TODO */
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Example of wrapping backend function inside frontend API
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
|
||||
struct rig_state *rig_s;
|
||||
struct ft747_priv_data *p;
|
||||
unsigned char *cmd; /* points to sequence to send */
|
||||
|
||||
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);
|
||||
|
||||
ft747_set_vfo(rig, vfo); /* select VFO first , new API */
|
||||
|
||||
|
||||
/*
|
||||
* Copy native cmd freq_set to private cmd storage area
|
||||
*/
|
||||
|
||||
memcpy(&p->p_cmd,&ncmd[FT_747_NATIVE_FREQ_SET].nseq,FT747_CMD_LENGTH);
|
||||
|
||||
to_bcd(p->p_cmd,freq/10,8); /* store bcd format in in p_cmd */
|
||||
/* TODO -- fix 10Hz resolution -- FS */
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: requested freq after conversion = %Li Hz \n", from_bcd(p->p_cmd,8)* 10 );
|
||||
|
||||
cmd = p->p_cmd; /* get native sequence */
|
||||
write_block(rig_s->fd, cmd, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay);
|
||||
|
||||
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;
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft747_priv_data*)rig->state.priv;
|
||||
|
||||
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 */
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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;
|
||||
unsigned char *cmd; /* points to sequence to send */
|
||||
unsigned char cmd_index; /* index of sequence to send */
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft747_priv_data*)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
ft747_set_vfo(rig, vfo); /* select VFO first , new API */
|
||||
|
||||
/*
|
||||
* translate mode from generic to ft747 specific
|
||||
*/
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: generic mode = %x \n", mode);
|
||||
|
||||
switch(mode) {
|
||||
case RIG_MODE_AM:
|
||||
cmd_index = FT_747_NATIVE_MODE_SET_AMW;
|
||||
break;
|
||||
case RIG_MODE_CW:
|
||||
cmd_index = FT_747_NATIVE_MODE_SET_CWW;
|
||||
break;
|
||||
case RIG_MODE_USB:
|
||||
cmd_index = FT_747_NATIVE_MODE_SET_USB;
|
||||
break;
|
||||
case RIG_MODE_LSB:
|
||||
cmd_index = FT_747_NATIVE_MODE_SET_LSB;
|
||||
break;
|
||||
case RIG_MODE_FM:
|
||||
cmd_index = FT_747_NATIVE_MODE_SET_FMW;
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong MODE */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Now set width
|
||||
*/
|
||||
|
||||
switch(width) {
|
||||
case RIG_PASSBAND_NORMAL: /* easy case , no change to native sequence */
|
||||
break;
|
||||
|
||||
case RIG_PASSBAND_WIDE:
|
||||
return -RIG_EINVAL; /* sorry, WIDE WIDTH is not supported */
|
||||
|
||||
case RIG_PASSBAND_NARROW: /* must set narrow */
|
||||
switch(mode) {
|
||||
case RIG_MODE_AM:
|
||||
cmd_index = FT_747_NATIVE_MODE_SET_AMN;
|
||||
break;
|
||||
case RIG_MODE_FM:
|
||||
cmd_index = FT_747_NATIVE_MODE_SET_FMN;
|
||||
break;
|
||||
case RIG_MODE_CW:
|
||||
cmd_index = FT_747_NATIVE_MODE_SET_CWN;
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong MODE/WIDTH combo */
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong WIDTH requested */
|
||||
}
|
||||
|
||||
/*
|
||||
* phew! now send cmd to rig
|
||||
*/
|
||||
|
||||
cmd = (unsigned char *) p->pcs[cmd_index].nseq; /* get native sequence */
|
||||
write_block(rig_s->fd, cmd, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay);
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: cmd_index = %i \n", cmd_index);
|
||||
|
||||
return RIG_OK; /* good */
|
||||
|
||||
}
|
||||
|
||||
|
||||
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 */
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft747_priv_data*)rig->state.priv;
|
||||
|
||||
ft747_get_update_data(rig); /* get whole shebang from rig */
|
||||
|
||||
mymode = p->update_data[FT747_SUMO_DISPLAYED_MODE];
|
||||
mymode &= MODE_MASK; /* mask out bits 5 and 6 */
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: mymode = %x \n", mymode);
|
||||
|
||||
/*
|
||||
* translate mode from ft747 to generic.
|
||||
*/
|
||||
|
||||
switch(mymode) {
|
||||
case MODE_FM:
|
||||
(*mode) = RIG_MODE_FM;
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: mode = FM \n");
|
||||
break;
|
||||
case MODE_AM:
|
||||
(*mode) = RIG_MODE_AM;
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: mode = AM \n");
|
||||
break;
|
||||
case MODE_CW:
|
||||
(*mode) = RIG_MODE_CW;
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: mode = CW \n");
|
||||
break;
|
||||
case MODE_USB:
|
||||
(*mode) = RIG_MODE_USB;
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: mode = USB \n");
|
||||
break;
|
||||
case MODE_LSB:
|
||||
(*mode) = RIG_MODE_LSB;
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: mode = LSB \n");
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong mode */
|
||||
break;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
||||
unsigned char *cmd; /* points to sequence to send */
|
||||
unsigned char cmd_index; /* index of sequence to send */
|
||||
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft747_priv_data*)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
|
||||
/*
|
||||
* TODO : check for errors -- FS
|
||||
*/
|
||||
|
||||
|
||||
switch(vfo) {
|
||||
case RIG_VFO_A:
|
||||
cmd_index = FT_747_NATIVE_VFO_A;
|
||||
p->current_vfo = vfo; /* update active VFO */
|
||||
break;
|
||||
case RIG_VFO_B:
|
||||
cmd_index = FT_747_NATIVE_VFO_B;
|
||||
p->current_vfo = vfo; /* update active VFO */
|
||||
break;
|
||||
case RIG_VFO_CURR:
|
||||
switch(p->current_vfo) { /* what is my active VFO ? */
|
||||
case RIG_VFO_A:
|
||||
cmd_index = FT_747_NATIVE_VFO_A;
|
||||
break;
|
||||
case RIG_VFO_B:
|
||||
cmd_index = FT_747_NATIVE_VFO_B;
|
||||
break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: Unknown default VFO \n");
|
||||
return -RIG_EINVAL; /* sorry, wrong current VFO */
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong VFO */
|
||||
}
|
||||
|
||||
/*
|
||||
* phew! now send cmd to rig
|
||||
*/
|
||||
|
||||
cmd = (unsigned char *) p->pcs[cmd_index].nseq; /* get native sequence */
|
||||
write_block(rig_s->fd, cmd, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay);
|
||||
|
||||
return RIG_OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int ft747_get_vfo(RIG *rig, vfo_t *vfo) {
|
||||
struct ft747_priv_data *p;
|
||||
unsigned char status; /* ft747 status flag */
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft747_priv_data*)rig->state.priv;
|
||||
|
||||
ft747_get_update_data(rig); /* get whole shebang from rig */
|
||||
|
||||
status = p->update_data[FT747_SUMO_DISPLAYED_STATUS];
|
||||
status &= SF_VFOAB; /* check VFO bit*/
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: vfo status = %x \n", status);
|
||||
|
||||
/*
|
||||
* translate vfo status from ft747 to generic.
|
||||
*/
|
||||
|
||||
if (status) {
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: VFO = B \n");
|
||||
(*vfo) = RIG_VFO_B;
|
||||
return RIG_OK;
|
||||
} else {
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: VFO = A \n");
|
||||
(*vfo) = RIG_VFO_A;
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int ft747_set_ptt(RIG *rig,vfo_t vfo, ptt_t ptt) {
|
||||
struct rig_state *rig_s;
|
||||
struct ft747_priv_data *p;
|
||||
unsigned char *cmd; /* points to sequence to send */
|
||||
unsigned char cmd_index; /* index of sequence to send */
|
||||
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft747_priv_data*)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
ft747_set_vfo(rig,vfo); /* select VFO first */
|
||||
|
||||
|
||||
switch(ptt) {
|
||||
case RIG_PTT_OFF:
|
||||
cmd_index = FT_747_NATIVE_PTT_OFF;
|
||||
break;
|
||||
case RIG_PTT_ON:
|
||||
cmd_index = FT_747_NATIVE_PTT_ON;
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong VFO */
|
||||
}
|
||||
|
||||
/*
|
||||
* phew! now send cmd to rig
|
||||
*/
|
||||
|
||||
cmd = (unsigned char *) p->pcs[cmd_index].nseq; /* get native sequence */
|
||||
write_block(rig_s->fd, cmd, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay);
|
||||
|
||||
return RIG_OK; /* good */
|
||||
}
|
||||
|
||||
int ft747_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) {
|
||||
struct ft747_priv_data *p;
|
||||
unsigned char status; /* ft747 mode */
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft747_priv_data*)rig->state.priv;
|
||||
|
||||
ft747_get_update_data(rig); /* get whole shebang from rig */
|
||||
|
||||
status = p->update_data[FT747_SUMO_DISPLAYED_STATUS];
|
||||
status = status & SF_RXTX; /* check RXTX bit*/
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: ptt status = %x \n", status);
|
||||
|
||||
/*
|
||||
* translate mode from ft747 to generic.
|
||||
*/
|
||||
|
||||
if (status) {
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: PTT = ON \n");
|
||||
(*ptt) = RIG_PTT_ON;
|
||||
return RIG_OK;
|
||||
} else {
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: PTT = OFF \n");
|
||||
(*ptt) = RIG_PTT_OFF;
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/*
|
||||
* private helper function. Retrieves update data from rig.
|
||||
* Uses ft747_get_update_data() to get status flag
|
||||
*/
|
||||
|
||||
static int ft747_get_status_flags(RIG *rig, int sf_order) {
|
||||
struct rig_state *rig_s;
|
||||
struct ft747_priv_data *p;
|
||||
unsigned char status; /* ft747 status flags */
|
||||
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft747_priv_data*)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
ft747_get_update_data(rig); /* get whole shebang from rig */
|
||||
|
||||
status = p->update_data[FT747_STATUS_UPDATE_STATUS_OFFSET];
|
||||
|
||||
return status & SF_RXTX;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* private helper function. Retrieves update data from rig.
|
||||
* using pacing value and buffer indicated in *priv struct.
|
||||
*
|
||||
* need to use this when doing ft747_get_* stuff
|
||||
*/
|
||||
|
||||
static int ft747_get_update_data(RIG *rig) {
|
||||
struct rig_state *rig_s;
|
||||
struct ft747_priv_data *p;
|
||||
int n; /* counter */
|
||||
|
||||
static unsigned char cmd_pace[] = { 0x00, 0x00, 0x00, 0x00, 0x0e }; /* pacing set */
|
||||
static unsigned char cmd_update[] = { 0x00, 0x00, 0x00, 0x00, 0x10 }; /* request update from rig */
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft747_priv_data*)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
cmd_pace[3] = p->pacing; /* get pacing value */
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: read pacing = %i \n",p->pacing);
|
||||
|
||||
write_block(rig_s->fd, cmd_pace, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay);
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft747: read timeout = %i \n",FT747_DEFAULT_READ_TIMEOUT);
|
||||
|
||||
write_block(rig_s->fd, cmd_update, FT747_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay); /* request data */
|
||||
n = read_sleep(rig_s->fd,p->update_data, FT747_STATUS_UPDATE_DATA_LENGTH, FT747_DEFAULT_READ_TIMEOUT);
|
||||
/* n = read_block(rig_s->fd,p->update_data, FT747_STATUS_UPDATE_DATA_LENGTH, FT747_DEFAULT_READ_TIMEOUT); */
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Implement these old OPCODES -- FS
|
||||
*/
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
void ft747_cmd_set_split_yes(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x01 }; /* split = on */
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void ft747_cmd_set_split_no(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x01 }; /* split = off */
|
||||
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_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_block(fd,data);
|
||||
}
|
||||
|
||||
void ft747_cmd_set_dlock_off(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x04 }; /* dial lock = off */
|
||||
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_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_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_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_block(fd,data);
|
||||
}
|
||||
|
||||
void ft747_cmd_set_up500k(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x07 }; /* up 500 khz */
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void ft747_cmd_set_down500k(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x08 }; /* down 500 khz */
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void ft747_cmd_set_clarify_off(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x09 }; /* clarify off */
|
||||
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_block(fd,data);
|
||||
}
|
||||
|
||||
|
||||
void ft747_cmd_set_freq(int fd, unsigned int freq) {
|
||||
printf("ft747_cmd_freq_set not implemented yet \n");
|
||||
}
|
||||
|
||||
|
||||
void ft747_cmd_set_mode(int fd, int mode) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0c }; /* mode set */
|
||||
|
||||
data[3] = mode;
|
||||
write_block(fd,data);
|
||||
|
||||
}
|
||||
|
||||
void ft747_cmd_set_pacing(int fd, int delay) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0e }; /* pacing set */
|
||||
|
||||
data[3] = delay;
|
||||
write_block(fd,data);
|
||||
|
||||
}
|
||||
|
||||
void ft747_cmd_set_ptt_off(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0f }; /* ptt off */
|
||||
write_block(fd,data);
|
||||
|
||||
}
|
||||
|
||||
void ft747_cmd_set_ptt_on(int fd) {
|
||||
|
||||
#ifdef TX_ENABLED
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x0f }; /* ptt on */
|
||||
write_block(fd,data);
|
||||
printf("ft747_cmd_ptt_on complete \n");
|
||||
#elsif
|
||||
printf("ft747_cmd_ptt_on disabled \n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Read data from rig and store in buffer provided
|
||||
* by the user.
|
||||
*/
|
||||
|
||||
void ft747_cmd_get_update_store(int fd, unsigned char *buffer) {
|
||||
int n; /* counter */
|
||||
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x10 }; /* request update from rig */
|
||||
|
||||
write_block(fd,data);
|
||||
n = read_sleep(fd,buffer,FT747_STATUS_UPDATE_SIZE); /* wait and read for bytes to be read */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* init_ft747 is called by rig_backend_load
|
||||
*/
|
||||
int init_ft747(void *be_handle) {
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "ft747: _init called\n");
|
||||
rig_register(&ft747_caps);
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,311 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@@ix.netcom.com)
|
||||
*
|
||||
* ft747.h - (C) Frank Singleton 2000 (vk3fcs@@ix.netcom.com)
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to an FT-747GX using the "CAT" interface
|
||||
* box (FIF-232C) or similar (max232 + some capacitors :-)
|
||||
*
|
||||
*
|
||||
* $Id: ft747.h,v 1.1 2001-01-04 05:39:03 javabear Exp $
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _FT747_H
|
||||
#define _FT747_H 1
|
||||
|
||||
#define FT747_CMD_LENGTH 5
|
||||
#define FT747_STATUS_UPDATE_DATA_LENGTH 345
|
||||
|
||||
#define FT747_PACING_INTERVAL 5
|
||||
#define FT747_PACING_DEFAULT_VALUE 0
|
||||
#define FT747_WRITE_DELAY 50
|
||||
|
||||
|
||||
/* Sequential fast writes confuse my FT747 without this delay */
|
||||
|
||||
#define FT747_POST_WRITE_DELAY 5
|
||||
|
||||
|
||||
/* Rough safe value for default timeout */
|
||||
|
||||
#define FT747_DEFAULT_READ_TIMEOUT 345 * ( 3 + (FT747_PACING_INTERVAL * FT747_PACING_DEFAULT_VALUE))
|
||||
|
||||
|
||||
/*
|
||||
* 8N2 and 1 start bit = 11 bits at 4800 bps => effective byte rate = 1 byte in 2.2917 msec
|
||||
* => 345 bytes in 790 msec
|
||||
*
|
||||
* delay for 1 byte = 2.2917 + (pace_interval * 5)
|
||||
*
|
||||
* pace_interval time to read 345 bytes
|
||||
* ------------ ----------------------
|
||||
*
|
||||
* 0 790 msec
|
||||
* 1 2515 msec
|
||||
* 2 4240 msec
|
||||
* 255 441 sec => 7 min 21 seconds
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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_PACING,
|
||||
FT_747_NATIVE_PTT_OFF,
|
||||
FT_747_NATIVE_PTT_ON,
|
||||
FT_747_NATIVE_UPDATE,
|
||||
FT_747_NATIVE_SIZE /* end marker, value indicates number of */
|
||||
/* native cmd entries */
|
||||
|
||||
};
|
||||
|
||||
typedef enum ft747_native_cmd_e ft747_native_cmd_t;
|
||||
|
||||
|
||||
/*
|
||||
* Basic 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;
|
||||
|
||||
|
||||
|
||||
/* Internal MODES - when setting modes via cmd_mode_set() */
|
||||
|
||||
#define MODE_SET_LSB 0x00
|
||||
#define MODE_SET_USB 0x01
|
||||
#define MODE_SET_CWW 0x02
|
||||
#define MODE_SET_CWN 0x03
|
||||
#define MODE_SET_AMW 0x04
|
||||
#define MODE_SET_AMN 0x05
|
||||
#define MODE_SET_FMW 0x06
|
||||
#define MODE_SET_FMN 0x07
|
||||
|
||||
|
||||
/*
|
||||
* Mode Bitmap. Bits 5 and 6 unused
|
||||
* When READING modes
|
||||
*/
|
||||
|
||||
#define MODE_FM 0x01
|
||||
#define MODE_AM 0x02
|
||||
#define MODE_CW 0x04
|
||||
#define MODE_FMN 0x81
|
||||
#define MODE_AMN 0x82
|
||||
#define MODE_CWN 0x84
|
||||
#define MODE_USB 0x08
|
||||
#define MODE_LSB 0x10
|
||||
#define MODE_NAR 0x80
|
||||
|
||||
/* All relevent bits */
|
||||
#define MODE_MASK 0x9f
|
||||
|
||||
|
||||
/*
|
||||
* Status Flag Masks when reading
|
||||
*/
|
||||
|
||||
#define SF_DLOCK 0x01
|
||||
#define SF_SPLIT 0x02
|
||||
#define SF_CLAR 0x04
|
||||
#define SF_VFOAB 0x08
|
||||
#define SF_VFOMR 0x10
|
||||
#define SF_RXTX 0x20
|
||||
#define SF_RESV 0x40
|
||||
#define SF_PRI 0x80
|
||||
|
||||
|
||||
/*
|
||||
* Local VFO CMD's, according to spec
|
||||
*/
|
||||
|
||||
#define FT747_VFO_A 0x00
|
||||
#define FT747_VFO_B 0x01
|
||||
|
||||
|
||||
/*
|
||||
* Some useful offsets in the status update map (offset)
|
||||
*
|
||||
* Manual appears to be full of mistakes regarding offsets etc.. -- FS
|
||||
*
|
||||
*/
|
||||
|
||||
#define FT747_SUMO_DISPLAYED_MODE 0x18
|
||||
#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
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* future - private data
|
||||
*
|
||||
*/
|
||||
|
||||
struct ft747_priv_data {
|
||||
unsigned char pacing; /* pacing value */
|
||||
unsigned int read_update_delay; /* depends on pacing value */
|
||||
unsigned char current_vfo; /* active VFO from last cmd , can be either RIG_VFO_A or RIG_VFO_B only */
|
||||
unsigned char p_cmd[FT747_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */
|
||||
ft747_cmd_set_t pcs[FT_747_NATIVE_SIZE]; /* private cmd set */
|
||||
unsigned char update_data[FT747_STATUS_UPDATE_DATA_LENGTH]; /* returned data */
|
||||
};
|
||||
|
||||
/*
|
||||
* API local implementation
|
||||
*/
|
||||
|
||||
int ft747_init(RIG *rig);
|
||||
int ft747_cleanup(RIG *rig);
|
||||
int ft747_open(RIG *rig);
|
||||
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);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Below is leftovers of old interface. TODO
|
||||
*
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Allow TX commands to be disabled
|
||||
*
|
||||
*/
|
||||
|
||||
#undef TX_ENABLED
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Mode Bitmap. Bits 5 and 6 unused
|
||||
* When reading modes
|
||||
*/
|
||||
|
||||
#define MODE_FM 0x01
|
||||
#define MODE_AM 0x02
|
||||
#define MODE_CW 0x04
|
||||
#define MODE_FMN 0x81
|
||||
#define MODE_AMN 0x82
|
||||
#define MODE_CWN 0x84
|
||||
#define MODE_USB 0x08
|
||||
#define MODE_LSB 0x10
|
||||
#define MODE_NAR 0x80 /* narrow bit set only */
|
||||
|
||||
/*
|
||||
* Map band data value to band.
|
||||
*
|
||||
* Band "n" is from band_data[n] to band_data[n+1]
|
||||
*/
|
||||
|
||||
const float band_data[11] = { 0.0, 0.1, 2.5, 4.0, 7.5, 10.5, 14.5, 18.5, 21.5, 25.0, 30.0 };
|
||||
|
||||
|
||||
/*
|
||||
* Visible functions in shared lib.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* set commands
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
void cmd_set_split_yes(int fd);
|
||||
void cmd_set_split_no(int fd);
|
||||
void cmd_set_recall_memory(int fd, int mem);
|
||||
void cmd_set_vfo_to_memory(int fd, int mem);
|
||||
void cmd_set_dlock_off(int fd);
|
||||
void cmd_set_dlock_on(int fd);
|
||||
void cmd_set_select_vfo_a(int fd);
|
||||
void cmd_set_select_vfo_b(int fd);
|
||||
void cmd_set_memory_to_vfo(int fd, int mem);
|
||||
void cmd_set_up500k(int fd);
|
||||
void cmd_set_down500k(int fd);
|
||||
void cmd_set_clarify_off(int fd);
|
||||
void cmd_set_clarify_on(int fd);
|
||||
|
||||
/*
|
||||
*void cmd_set_freq(int fd, unsigned int freq);
|
||||
*/
|
||||
|
||||
void cmd_set_mode(int fd, int mode);
|
||||
void cmd_set_pacing(int fd, int delay);
|
||||
void cmd_set_ptt_off(int fd);
|
||||
void cmd_set_ptt_on(int fd); /* careful.. */
|
||||
|
||||
/*
|
||||
* get commands
|
||||
*/
|
||||
|
||||
void cmd_get_update_store(int fd, unsigned char *buffer); /* data external */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _FT747_H */
|
|
@ -0,0 +1,636 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* ft847.c - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to an FT-847 using the "CAT" interface.
|
||||
*
|
||||
*
|
||||
* $Id: ft847.c,v 1.1 2001-01-04 05:39:03 javabear Exp $
|
||||
*
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* 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)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Notes on limitations in RIG control capabilities. These are
|
||||
* related to the Yaesu's FT847 design, not my program :-)
|
||||
*
|
||||
* 1. Rig opcodes allow only 10Hz resolution.
|
||||
* 2. Cannot select VFO B
|
||||
* 3. Using CAT and Tuner controls simultaneously can
|
||||
* cause problems.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h> /* Standard input/output definitions */
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <termios.h> /* POSIX terminal control definitions */
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include <hamlib/riglist.h>
|
||||
#include "serial.h"
|
||||
#include "ft847.h"
|
||||
#include "misc.h"
|
||||
|
||||
/* prototypes */
|
||||
|
||||
static int ft847_send_priv_cmd(RIG *rig, unsigned char ci);
|
||||
|
||||
|
||||
/* Native ft847 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 completed with extra parameters */
|
||||
/* eg: mem number, or freq etc.. */
|
||||
|
||||
static const ft847_cmd_set_t ncmd[] = {
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* CAT = On */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x80 } }, /* CAT = Off */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x08 } }, /* ptt on */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x01, 0x88 } }, /* ptt off */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x4e } }, /* sat mode on */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x8e } }, /* sat mode off */
|
||||
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x01 } }, /* set freq main */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x11 } }, /* set freq sat rx */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x21 } }, /* set freq sat tx */
|
||||
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main LSB */
|
||||
{ 1, { 0x01, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main USB */
|
||||
{ 1, { 0x02, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main CW */
|
||||
{ 1, { 0x03, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main CWR */
|
||||
{ 1, { 0x04, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main AM */
|
||||
{ 1, { 0x08, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main FM */
|
||||
{ 1, { 0x82, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main CWN */
|
||||
{ 1, { 0x83, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main CWRN */
|
||||
{ 1, { 0x84, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main AMN */
|
||||
{ 1, { 0x88, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main FMN */
|
||||
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x17 } }, /* mode set sat rx LSB */
|
||||
{ 1, { 0x01, 0x00, 0x00, 0x00, 0x17 } }, /* mode set sat rx USB */
|
||||
{ 1, { 0x02, 0x00, 0x00, 0x00, 0x17 } }, /* mode set sat rx CW */
|
||||
{ 1, { 0x03, 0x00, 0x00, 0x00, 0x17 } }, /* mode set sat rx CWR */
|
||||
{ 1, { 0x04, 0x00, 0x00, 0x00, 0x17 } }, /* mode set sat rx AM */
|
||||
{ 1, { 0x08, 0x00, 0x00, 0x00, 0x17 } }, /* mode set sat rx FM */
|
||||
{ 1, { 0x82, 0x00, 0x00, 0x00, 0x17 } }, /* mode set sat rx CWN */
|
||||
{ 1, { 0x83, 0x00, 0x00, 0x00, 0x17 } }, /* mode set sat rx CWRN */
|
||||
{ 1, { 0x84, 0x00, 0x00, 0x00, 0x17 } }, /* mode set sat rx AMN */
|
||||
{ 1, { 0x88, 0x00, 0x00, 0x00, 0x17 } }, /* mode set sat rx FMN */
|
||||
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x27 } }, /* mode set sat tx LSB */
|
||||
{ 1, { 0x01, 0x00, 0x00, 0x00, 0x27 } }, /* mode set sat tx USB */
|
||||
{ 1, { 0x02, 0x00, 0x00, 0x00, 0x27 } }, /* mode set sat tx CW */
|
||||
{ 1, { 0x03, 0x00, 0x00, 0x00, 0x27 } }, /* mode set sat tx CWR */
|
||||
{ 1, { 0x04, 0x00, 0x00, 0x00, 0x27 } }, /* mode set sat tx AM */
|
||||
{ 1, { 0x08, 0x00, 0x00, 0x00, 0x27 } }, /* mode set sat tx FM */
|
||||
{ 1, { 0x82, 0x00, 0x00, 0x00, 0x27 } }, /* mode set sat tx CWN */
|
||||
{ 1, { 0x83, 0x00, 0x00, 0x00, 0x27 } }, /* mode set sat tx CWRN */
|
||||
{ 1, { 0x84, 0x00, 0x00, 0x00, 0x27 } }, /* mode set sat tx AMN */
|
||||
{ 1, { 0x88, 0x00, 0x00, 0x00, 0x27 } }, /* mode set sat tx FMN */
|
||||
|
||||
{ 1, { 0x0a, 0x00, 0x00, 0x00, 0x0a } }, /* set DCS on, main */
|
||||
{ 1, { 0x2a, 0x00, 0x00, 0x00, 0x0a } }, /* set CTCSS/DCS enc/dec on, main */
|
||||
{ 1, { 0x4a, 0x00, 0x00, 0x00, 0x0a } }, /* set CTCSS/DCS enc on, main */
|
||||
{ 1, { 0x8a, 0x00, 0x00, 0x00, 0x0a } }, /* set CTCSS/DCS off, main */
|
||||
|
||||
{ 1, { 0x0a, 0x00, 0x00, 0x00, 0x1a } }, /* set DCS on, sat rx */
|
||||
{ 1, { 0x2a, 0x00, 0x00, 0x00, 0x1a } }, /* set CTCSS/DCS enc/dec on, sat rx */
|
||||
{ 1, { 0x4a, 0x00, 0x00, 0x00, 0x1a } }, /* set CTCSS/DCS enc on, sat rx */
|
||||
{ 1, { 0x8a, 0x00, 0x00, 0x00, 0x1a } }, /* set CTCSS/DCS off, sat rx */
|
||||
|
||||
{ 1, { 0x0a, 0x00, 0x00, 0x00, 0x2a } }, /* set DCS on, sat tx */
|
||||
{ 1, { 0x2a, 0x00, 0x00, 0x00, 0x2a } }, /* set CTCSS/DCS enc/dec on, sat tx */
|
||||
{ 1, { 0x4a, 0x00, 0x00, 0x00, 0x2a } }, /* set CTCSS/DCS enc on, sat tx */
|
||||
{ 1, { 0x8a, 0x00, 0x00, 0x00, 0x2a } }, /* set CTCSS/DCS off, sat tx */
|
||||
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x0b } }, /* set CTCSS freq, main */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x1b } }, /* set CTCSS freq, sat rx */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x2b } }, /* set CTCSS freq, sat tx */
|
||||
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x0c } }, /* set DCS code, main */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x1c } }, /* set DCS code, sat rx */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x2c } }, /* set DCS code, sat tx */
|
||||
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x09 } }, /* set RPT shift MINUS */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x49 } }, /* set RPT shift PLUS */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x89 } }, /* set RPT shift SIMPLEX */
|
||||
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0xf9 } }, /* set RPT offset freq */
|
||||
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0xe7 } }, /* get RX status */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0xf7 } }, /* get TX status */
|
||||
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x03 } }, /* get FREQ and MODE status, main */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x13 } }, /* get FREQ and MODE status, sat rx */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x23 } }, /* get FREQ and MODE status, sat tx */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Receiver caps
|
||||
*/
|
||||
|
||||
|
||||
#define FT847_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM)
|
||||
#define FT847_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB)
|
||||
#define FT847_AM_FM_RX_MODES (RIG_MODE_AM|RIG_MODE_FM)
|
||||
|
||||
/* tx doesn't have WFM.
|
||||
* 100W in 160-6m (25 watts AM carrier)
|
||||
* 50W in 2m/70cm (12.5 watts AM carrier)
|
||||
*/
|
||||
|
||||
#define FT847_OTHER_TX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM)
|
||||
#define FT847_AM_TX_MODES (RIG_MODE_AM)
|
||||
|
||||
#define FT847_FUNC_ALL (RIG_FUNC_FAGC|RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_SBKIN|RIG_FUNC_FBKIN) /* fix */
|
||||
|
||||
/*
|
||||
* ft847 rigs capabilities.
|
||||
* Notice that some rigs share the same functions.
|
||||
* Also this struct is READONLY!
|
||||
*/
|
||||
|
||||
|
||||
const struct rig_caps ft847_caps = {
|
||||
RIG_MODEL_FT847, "FT-847", "Yaesu", "0.1", RIG_STATUS_ALPHA,
|
||||
RIG_TYPE_TRANSCEIVER,RIG_PTT_RIG, 4800, 57600, 8, 2, RIG_PARITY_NONE,
|
||||
RIG_HANDSHAKE_NONE,FT847_WRITE_DELAY ,FT847_POST_WRITE_DELAY, 100, 0, FT847_FUNC_ALL, 0, 0, 78, RIG_TRN_OFF,
|
||||
{ {100000,76000000,FT847_ALL_RX_MODES,-1,-1}, /* rx range begin */
|
||||
{108000000,174000000,FT847_ALL_RX_MODES,-1,-1},
|
||||
{420000000,512000000,FT847_ALL_RX_MODES,-1,-1},
|
||||
|
||||
{0,0,0,0,0}, }, /* rx range end */
|
||||
|
||||
{ {1800000,1999999,FT847_OTHER_TX_MODES,5000,100000}, /* 5-100W class */
|
||||
{1800000,1999999,FT847_AM_TX_MODES,1000,25000}, /* 1-5W class */
|
||||
|
||||
{3500000,3999999,FT847_OTHER_TX_MODES,5000,100000},
|
||||
{3500000,3999999,FT847_AM_TX_MODES,1000,25000},
|
||||
|
||||
{7000000,7300000,FT847_OTHER_TX_MODES,5000,100000},
|
||||
{7000000,7300000,FT847_AM_TX_MODES,1000,25000},
|
||||
|
||||
{10000000,10150000,FT847_OTHER_TX_MODES,5000,100000},
|
||||
{10000000,10150000,FT847_AM_TX_MODES,1000,25000},
|
||||
|
||||
{14000000,14350000,FT847_OTHER_TX_MODES,5000,100000},
|
||||
{14000000,14350000,FT847_AM_TX_MODES,1000,25000},
|
||||
|
||||
{18068000,18168000,FT847_OTHER_TX_MODES,5000,100000},
|
||||
{18068000,18168000,FT847_AM_TX_MODES,1000,25000},
|
||||
|
||||
{21000000,21450000,FT847_OTHER_TX_MODES,5000,100000},
|
||||
{21000000,21450000,FT847_AM_TX_MODES,1000,25000},
|
||||
|
||||
{24890000,24990000,FT847_OTHER_TX_MODES,5000,100000},
|
||||
{24890000,24990000,FT847_AM_TX_MODES,1000,25000},
|
||||
|
||||
{28000000,29700000,FT847_OTHER_TX_MODES,5000,100000},
|
||||
{28000000,29700000,FT847_AM_TX_MODES,1000,25000},
|
||||
|
||||
{50000000,54000000,FT847_OTHER_TX_MODES,5000,100000},
|
||||
{50000000,54000000,FT847_AM_TX_MODES,1000,25000},
|
||||
|
||||
{144000000,148000000,FT847_OTHER_TX_MODES,1000,50000},
|
||||
{144000000,148000000,FT847_AM_TX_MODES,1000,12500},
|
||||
|
||||
{430000000,44000000,FT847_OTHER_TX_MODES,1000,50000}, /* check range */
|
||||
{430000000,440000000,FT847_AM_TX_MODES,1000,12500},
|
||||
|
||||
{0,0,0,0,0} },
|
||||
|
||||
{ {FT847_SSB_CW_RX_MODES,1}, /* normal */
|
||||
{FT847_SSB_CW_RX_MODES,10}, /* fast */
|
||||
{FT847_SSB_CW_RX_MODES,100}, /* faster */
|
||||
|
||||
|
||||
{FT847_AM_FM_RX_MODES,10}, /* normal */
|
||||
{FT847_AM_FM_RX_MODES,100}, /* fast */
|
||||
|
||||
{0,0},
|
||||
},
|
||||
ft847_init,
|
||||
ft847_cleanup,
|
||||
ft847_open,
|
||||
ft847_close,
|
||||
NULL /* probe not supported yet */,
|
||||
|
||||
ft847_set_freq, /* set freq */
|
||||
ft847_get_freq, /* get freq */
|
||||
ft847_set_mode, /* set mode */
|
||||
ft847_get_mode, /* get mode */
|
||||
ft847_set_vfo, /* set vfo */
|
||||
ft847_get_vfo, /* get vfo */
|
||||
ft847_set_ptt, /* set ptt */
|
||||
ft847_get_ptt, /* get ptt */
|
||||
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Function definitions below
|
||||
*/
|
||||
|
||||
/*
|
||||
* setup *priv
|
||||
* serial port is already open (rig->state->fd)
|
||||
*/
|
||||
|
||||
int ft847_init(RIG *rig) {
|
||||
struct ft847_priv_data *p;
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft847_priv_data*)malloc(sizeof(struct ft847_priv_data));
|
||||
if (!p) {
|
||||
/* whoops! memory shortage! */
|
||||
return -RIG_ENOMEM;
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847:ft847_init called \n");
|
||||
|
||||
/*
|
||||
* Copy complete native cmd set to private cmd storage area
|
||||
*/
|
||||
|
||||
memcpy(p->pcs,ncmd,sizeof(ncmd));
|
||||
|
||||
p->current_vfo = RIG_VFO_MAIN; /* default to VFO_MAIN */
|
||||
rig->state.priv = (void*)p;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ft847_cleanup routine
|
||||
* the serial port is closed by the frontend
|
||||
*/
|
||||
|
||||
int ft847_cleanup(RIG *rig) {
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
if (rig->state.priv)
|
||||
free(rig->state.priv);
|
||||
rig->state.priv = NULL;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847:ft847_cleanup called \n");
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ft847_open routine
|
||||
*
|
||||
*/
|
||||
|
||||
int ft847_open(RIG *rig) {
|
||||
|
||||
/* Good time to set CAT ON */
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847:ft847_open called \n");
|
||||
|
||||
ft847_send_priv_cmd(rig,FT_847_NATIVE_CAT_ON);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* ft847_close routine
|
||||
*
|
||||
*/
|
||||
|
||||
int ft847_close(RIG *rig) {
|
||||
|
||||
/* Good time to set CAT OFF */
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847:ft847_close called \n");
|
||||
|
||||
ft847_send_priv_cmd(rig,FT_847_NATIVE_CAT_OFF);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* private helper function to send a private command
|
||||
* sequence . Must only be complete sequences.
|
||||
*
|
||||
*/
|
||||
|
||||
static int ft847_send_priv_cmd(RIG *rig, unsigned char ci) {
|
||||
|
||||
struct rig_state *rig_s;
|
||||
struct ft847_priv_data *p;
|
||||
unsigned char *cmd; /* points to sequence to send */
|
||||
unsigned char cmd_index; /* index of sequence to send */
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
|
||||
p = (struct ft847_priv_data*)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
cmd_index = ci; /* get command */
|
||||
|
||||
if (! p->pcs[cmd_index].ncomp) {
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847: Attempt to send incomplete sequence \n");
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
cmd = (unsigned char *) p->pcs[cmd_index].nseq; /* get native sequence */
|
||||
write_block(rig_s->fd, cmd, FT847_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay);
|
||||
|
||||
return RIG_OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Set frequency to freq Hz. Note 10 Hz resolution -- YUK -- FS
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
|
||||
struct rig_state *rig_s;
|
||||
struct ft847_priv_data *p;
|
||||
unsigned char *cmd; /* points to sequence to send */
|
||||
unsigned char cmd_index; /* index of sequence to send */
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft847_priv_data*)rig->state.priv;
|
||||
|
||||
rig_s = &rig->state;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847: requested freq = %Li Hz \n", freq);
|
||||
|
||||
|
||||
/*
|
||||
* Copy native cmd freq_set to private cmd storage area
|
||||
*/
|
||||
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847: vfo =%i \n", vfo);
|
||||
|
||||
switch(vfo) {
|
||||
case RIG_VFO_MAIN:
|
||||
cmd_index = FT_847_NATIVE_CAT_SET_FREQ_MAIN;
|
||||
break;
|
||||
case RIG_VFO_CURR:
|
||||
switch(p->current_vfo) { /* what is my active VFO ? */
|
||||
case RIG_VFO_MAIN:
|
||||
cmd_index = FT_847_NATIVE_CAT_SET_FREQ_MAIN;
|
||||
break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847: Unknown default VFO \n");
|
||||
return -RIG_EINVAL; /* sorry, wrong current VFO */
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847: Unknown VFO \n");
|
||||
return -RIG_EINVAL; /* sorry, wrong VFO */
|
||||
}
|
||||
|
||||
memcpy(&p->p_cmd,&ncmd[cmd_index].nseq,FT847_CMD_LENGTH);
|
||||
|
||||
to_bcd_be(p->p_cmd,freq/10,8); /* store bcd format in in p_cmd */
|
||||
/* TODO -- fix 10Hz resolution -- FS */
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847: requested freq after conversion = %Li Hz \n", from_bcd_be(p->p_cmd,8)* 10 );
|
||||
|
||||
cmd = p->p_cmd; /* get native sequence */
|
||||
write_block(rig_s->fd, cmd, FT847_CMD_LENGTH, rig_s->write_delay, rig_s->post_write_delay);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int ft847_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) {
|
||||
|
||||
return -RIG_ENIMPL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int ft847_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) {
|
||||
unsigned char cmd_index; /* index of sequence to send */
|
||||
|
||||
/*
|
||||
* translate mode from generic to ft847 specific
|
||||
*/
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847: generic mode = %x \n", mode);
|
||||
|
||||
switch(mode) {
|
||||
case RIG_MODE_AM:
|
||||
cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_AM;
|
||||
break;
|
||||
case RIG_MODE_CW:
|
||||
cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_CW;
|
||||
break;
|
||||
case RIG_MODE_USB:
|
||||
cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_USB;
|
||||
break;
|
||||
case RIG_MODE_LSB:
|
||||
cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_LSB;
|
||||
break;
|
||||
case RIG_MODE_FM:
|
||||
cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_FM;
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong MODE */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Now set width
|
||||
*/
|
||||
|
||||
switch(width) {
|
||||
case RIG_PASSBAND_NORMAL: /* easy case , no change to native sequence */
|
||||
ft847_send_priv_cmd(rig,cmd_index); /* TODO -- check return codes */
|
||||
return RIG_OK; /* I am out of here .. */
|
||||
|
||||
case RIG_PASSBAND_WIDE:
|
||||
return -RIG_EINVAL; /* sorry, WIDE WIDTH is not supported */
|
||||
|
||||
case RIG_PASSBAND_NARROW: /* must set narrow */
|
||||
switch(mode) {
|
||||
case RIG_MODE_AM:
|
||||
cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_AMN;
|
||||
break;
|
||||
case RIG_MODE_FM:
|
||||
cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_FMN;
|
||||
break;
|
||||
case RIG_MODE_CW:
|
||||
cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_CWN;
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong MODE/WIDTH combo */
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong WIDTH requested */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Now send the command
|
||||
*/
|
||||
|
||||
ft847_send_priv_cmd(rig,cmd_index);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int ft847_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) {
|
||||
return -RIG_ENIMPL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TODO -- FT847 has NO set_vfo cmd. VFO is specified
|
||||
* in other cmd's like set freq, set mode etc..
|
||||
*
|
||||
* For the time being, simply cache the requested
|
||||
* VFO in private active VFO
|
||||
* Must fix this later. MAybe store active VFO in
|
||||
* frontend instead ?
|
||||
*
|
||||
* Perhaps I can try a dummy cmd that includes the VFO..
|
||||
* eg: set_dcs etc..
|
||||
* Try later -- FS
|
||||
*
|
||||
*
|
||||
* Also, RIG can handle only VFO_MAIN . Add SAT VFO's later.
|
||||
*
|
||||
*/
|
||||
|
||||
int ft847_set_vfo(RIG *rig, vfo_t vfo) {
|
||||
struct rig_state *rig_s;
|
||||
struct ft847_priv_data *p;
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
p = (struct ft847_priv_data*)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
|
||||
|
||||
/*
|
||||
* TODO : check for errors -- FS
|
||||
*/
|
||||
|
||||
switch(vfo) {
|
||||
case RIG_VFO_MAIN:
|
||||
p->current_vfo = vfo; /* update active VFO */
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong VFO */
|
||||
}
|
||||
|
||||
|
||||
|
||||
return RIG_OK;
|
||||
|
||||
}
|
||||
|
||||
int ft847_get_vfo(RIG *rig, vfo_t *vfo) {
|
||||
|
||||
return -RIG_ENIMPL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* _set_ptt
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
int ft847_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) {
|
||||
unsigned char cmd_index; /* index of sequence to send */
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE,"ft847:ft847_set_ptt called \n");
|
||||
|
||||
switch(ptt) {
|
||||
case RIG_PTT_ON:
|
||||
cmd_index = FT_847_NATIVE_CAT_PTT_ON;
|
||||
break;
|
||||
case RIG_PTT_OFF:
|
||||
cmd_index = FT_847_NATIVE_CAT_PTT_OFF;
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL; /* sorry, wrong ptt range */
|
||||
}
|
||||
|
||||
/*
|
||||
* phew! now send cmd to rig
|
||||
*/
|
||||
|
||||
ft847_send_priv_cmd(rig,cmd_index);
|
||||
|
||||
return RIG_OK; /* good */
|
||||
|
||||
}
|
||||
|
||||
int ft847_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) {
|
||||
return -RIG_ENIMPL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,358 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* ft847.h - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to an FT-847 using the "CAT" interface.
|
||||
*
|
||||
*
|
||||
* $Id: ft847.h,v 1.1 2001-01-04 05:39:03 javabear Exp $
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _FT847_H
|
||||
#define _FT847_H 1
|
||||
|
||||
|
||||
#define FT847_CMD_LENGTH 5
|
||||
#define FT847_WRITE_DELAY 50
|
||||
|
||||
/* Sequential fast writes may confuse FT847 without this delay */
|
||||
|
||||
#define FT847_POST_WRITE_DELAY 50
|
||||
|
||||
|
||||
/* Rough safe value for default timeout */
|
||||
|
||||
#define FT847_DEFAULT_READ_TIMEOUT 2000
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Native FT847 functions. This is what I have to work with :-)
|
||||
*
|
||||
*/
|
||||
|
||||
enum ft847_native_cmd_e {
|
||||
|
||||
/* Set commands to the rig */
|
||||
|
||||
FT_847_NATIVE_CAT_ON = 0,
|
||||
FT_847_NATIVE_CAT_OFF,
|
||||
|
||||
FT_847_NATIVE_CAT_PTT_ON,
|
||||
FT_847_NATIVE_CAT_PTT_OFF,
|
||||
|
||||
FT_847_NATIVE_CAT_SAT_MODE_ON,
|
||||
FT_847_NATIVE_CAT_SAT_MODE_OFF,
|
||||
|
||||
FT_847_NATIVE_CAT_SET_FREQ_MAIN,
|
||||
FT_847_NATIVE_CAT_SET_FREQ_SAT_RX_VFO,
|
||||
FT_847_NATIVE_CAT_SET_FREQ_SAT_TX_VFO,
|
||||
|
||||
FT_847_NATIVE_CAT_SET_MODE_MAIN_LSB, /* MAIN VFO */
|
||||
FT_847_NATIVE_CAT_SET_MODE_MAIN_USB,
|
||||
FT_847_NATIVE_CAT_SET_MODE_MAIN_CW,
|
||||
FT_847_NATIVE_CAT_SET_MODE_MAIN_CWR,
|
||||
FT_847_NATIVE_CAT_SET_MODE_MAIN_AM,
|
||||
FT_847_NATIVE_CAT_SET_MODE_MAIN_FM,
|
||||
FT_847_NATIVE_CAT_SET_MODE_MAIN_CWN,
|
||||
FT_847_NATIVE_CAT_SET_MODE_MAIN_CWRN,
|
||||
FT_847_NATIVE_CAT_SET_MODE_MAIN_AMN,
|
||||
FT_847_NATIVE_CAT_SET_MODE_MAIN_FMN,
|
||||
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_RX_LSB, /* SAT RX VFO */
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_RX_USB,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CW,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CWR,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_RX_AM,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_RX_FM,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CWN,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CWRN,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_RX_AMN,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_RX_FMN,
|
||||
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_TX_LSB, /* SAT TX VFO */
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_TX_USB,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CW,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CWR,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_TX_AM,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_TX_FM,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CWN,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CWRN,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_TX_AMN,
|
||||
FT_847_NATIVE_CAT_SET_MODE_SAT_TX_FMN,
|
||||
|
||||
FT_847_NATIVE_CAT_SET_DCS_ON_MAIN, /* MAIN CTCSS/DCS */
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON_MAIN,
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_ENC_ON_MAIN,
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_DCS_OFF_MAIN,
|
||||
|
||||
FT_847_NATIVE_CAT_SET_DCS_ON_SAT_RX, /* SAT RX CTCSS/DCS */
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON_SAT_RX,
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_ENC_ON_SAT_RX,
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_DCS_OFF_SAT_RX,
|
||||
|
||||
FT_847_NATIVE_CAT_SET_DCS_ON_SAT_TX, /* SAT TX CTCSS/DCS */
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON_SAT_TX,
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_ENC_ON_SAT_TX,
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_DCS_OFF_SAT_TX,
|
||||
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_FREQ_MAIN, /* CTCSS Freq */
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_FREQ_SAT_RX,
|
||||
FT_847_NATIVE_CAT_SET_CTCSS_FREQ_SAT_TX,
|
||||
|
||||
FT_847_NATIVE_CAT_SET_DCS_CODE_MAIN, /* DCS code */
|
||||
FT_847_NATIVE_CAT_SET_DCS_CODE_SAT_RX,
|
||||
FT_847_NATIVE_CAT_SET_DCS_CODE_SAT_TX,
|
||||
|
||||
FT_847_NATIVE_CAT_SET_RPT_SHIFT_MINUS, /* RPT SHIFT */
|
||||
FT_847_NATIVE_CAT_SET_RPT_SHIFT_PLUS,
|
||||
FT_847_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX,
|
||||
|
||||
FT_847_NATIVE_CAT_SET_RPT_OFFSET, /* RPT Offset frequency */
|
||||
|
||||
/* Get info from the rig */
|
||||
|
||||
FT_847_NATIVE_CAT_GET_RX_STATUS,
|
||||
FT_847_NATIVE_CAT_GET_TX_STATUS,
|
||||
|
||||
FT_847_NATIVE_CAT_GET_FREQ_MODE_STATUS_MAIN,
|
||||
FT_847_NATIVE_CAT_GET_FREQ_MODE_STATUS_SAT_RX,
|
||||
FT_847_NATIVE_CAT_GET_FREQ_MODE_STATUS_SAT_TX,
|
||||
|
||||
FT_847_NATIVE_SIZE /* end marker, value indicates number of */
|
||||
/* native cmd entries */
|
||||
|
||||
};
|
||||
|
||||
typedef enum ft847_native_cmd_e ft847_native_cmd_t;
|
||||
|
||||
|
||||
/*
|
||||
* TODO -- Move this to common yaesu.h file -- FS
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Basic Data structure for FT847 native cmd set
|
||||
*/
|
||||
|
||||
|
||||
|
||||
struct ft847_cmd_set {
|
||||
unsigned char ncomp; /* 1 = complete, 0 = incomplete, needs extra info */
|
||||
unsigned char nseq[5]; /* native cmd sequence */
|
||||
};
|
||||
|
||||
typedef struct ft847_cmd_set ft847_cmd_set_t;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ft847 instance - private data
|
||||
*
|
||||
*/
|
||||
|
||||
struct ft847_priv_data {
|
||||
unsigned char current_vfo; /* active VFO from last cmd , can be either RIG_VFO_A, SAT_RX, SAT_TX */
|
||||
unsigned char p_cmd[FT847_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */
|
||||
ft847_cmd_set_t pcs[FT_847_NATIVE_SIZE]; /* private cmd set */
|
||||
unsigned char rx_status; /* tx returned data */
|
||||
unsigned char tx_status; /* rx returned data */
|
||||
unsigned char fm_status_main; /* freq and mode ,returned data */
|
||||
unsigned char fm_status_satrx; /* freq and mode ,returned data */
|
||||
unsigned char fm_status_sattx; /* freq and mode ,returned data */
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* API local implementation
|
||||
*/
|
||||
|
||||
int ft847_init(RIG *rig);
|
||||
int ft847_open(RIG *rig);
|
||||
|
||||
int ft847_cleanup(RIG *rig);
|
||||
int ft847_close(RIG *rig);
|
||||
|
||||
int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||
int ft847_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
|
||||
|
||||
int ft847_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); /* select mode */
|
||||
int ft847_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); /* get mode */
|
||||
|
||||
int ft847_set_vfo(RIG *rig, vfo_t vfo); /* select vfo */
|
||||
int ft847_get_vfo(RIG *rig, vfo_t *vfo); /* get vfo */
|
||||
|
||||
int ft847_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
|
||||
int ft847_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt);
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/*
|
||||
* Allow TX commands to be disabled
|
||||
*
|
||||
*/
|
||||
|
||||
#undef TX_ENABLED
|
||||
|
||||
/*
|
||||
* RX Status Flags
|
||||
*/
|
||||
|
||||
const unsigned char RXSF_DISC_CENTER = (1<<5);
|
||||
const unsigned char RXSF_CTCSS_DCS_CODE = (1<<6);
|
||||
const unsigned char RXSF_SQUELCH_STATUS = (1<<7);
|
||||
const unsigned char RXSF_SMETER_MASK = 0x1f; /* bottom 5 bits */
|
||||
|
||||
/*
|
||||
* TX Status Flags
|
||||
*/
|
||||
|
||||
const unsigned char TXSF_PTT_STATUS = (1<<7);
|
||||
const unsigned char TXSF_POALC_METER_MASK = 0x1f; /* bottom 5 bits */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* MODES for READING and SETTING
|
||||
*/
|
||||
|
||||
#define MODE_LSB 0x00
|
||||
#define MODE_USB 0x01
|
||||
#define MODE_CW 0x02
|
||||
#define MODE_CWR 0x03
|
||||
#define MODE_AM 0x04
|
||||
#define MODE_FM 0x08
|
||||
#define MODE_CWN 0x82
|
||||
#define MODE_CWNR 0x83
|
||||
#define MODE_AMN 0x84
|
||||
#define MODE_FMN 0x88
|
||||
|
||||
/*
|
||||
* Modes for setting CTCSS/DCS Mode
|
||||
*
|
||||
*/
|
||||
|
||||
const unsigned char DCS_ON = 0x0a;
|
||||
const unsigned char CTCSS_ENC_DEC_ON = 0x2a;
|
||||
const unsigned char CTCSS_ENC_ON = 0x4a;
|
||||
const unsigned char CTCSS_ENC_DEC_OFF = 0x2a;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Raw CAT command set
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
void cmd_set_cat_on(int fd);
|
||||
void cmd_set_cat_off(int fd);
|
||||
|
||||
void cmd_set_ptt_on(int fd);
|
||||
void cmd_set_ptt_off(int fd);
|
||||
|
||||
void cmd_set_sat_on(int fd);
|
||||
void cmd_set_sat_off(int fd);
|
||||
|
||||
void cmd_set_freq_main_vfo(int fd, unsigned char d1, unsigned char d2,
|
||||
unsigned char d3, unsigned char d4);
|
||||
|
||||
void cmd_set_freq_sat_rx_vfo(int fd, unsigned char d1, unsigned char d2,
|
||||
unsigned char d3, unsigned char d4);
|
||||
|
||||
void cmd_set_freq_sat_tx_vfo(int fd, unsigned char d1, unsigned char d2,
|
||||
unsigned char d3, unsigned char d4);
|
||||
|
||||
void cmd_set_opmode_main_vfo(int fd, unsigned char d1);
|
||||
void cmd_set_opmode_sat_rx_vfo(int fd, unsigned char d1);
|
||||
void cmd_set_opmode_sat_tx_vfo(int fd, unsigned char d1);
|
||||
|
||||
void cmd_set_ctcss_dcs_main_vfo(int fd, unsigned char d1);
|
||||
void cmd_set_ctcss_dcs_sat_rx_vfo(int fd, unsigned char d1);
|
||||
void cmd_set_ctcss_dcs_sat_tx_vfo(int fd, unsigned char d1);
|
||||
|
||||
void cmd_set_ctcss_freq_main_vfo(int fd, unsigned char d1);
|
||||
void cmd_set_ctcss_freq_sat_rx_vfo(int fd, unsigned char d1);
|
||||
void cmd_set_ctcss_freq_sat_tx_vfo(int fd, unsigned char d1);
|
||||
|
||||
void cmd_set_dcs_code_main_vfo(int fd, unsigned char d1, unsigned char d2);
|
||||
void cmd_set_dcs_code_sat_rx_vfo(int fd, unsigned char d1, unsigned char d2);
|
||||
void cmd_set_dcs_code_sat_tx_vfo(int fd, unsigned char d1, unsigned char d2);
|
||||
|
||||
void cmd_set_repeater_shift_minus(int fd);
|
||||
void cmd_set_repeater_shift_plus(int fd);
|
||||
void cmd_set_repeater_shift_simplex(int fd);
|
||||
|
||||
void cmd_set_repeater_offset(int fd, unsigned char d1, unsigned char d2,
|
||||
unsigned char d3, unsigned char d4);
|
||||
|
||||
unsigned char cmd_get_rx_status(int fd);
|
||||
unsigned char cmd_get_tx_status(int fd);
|
||||
|
||||
/*
|
||||
* Get frequency and mode info
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
long int cmd_get_freq_mode_status_main_vfo(int fd, unsigned char *mode);
|
||||
long int cmd_get_freq_mode_status_sat_rx_vfo(int fd, unsigned char *mode);
|
||||
long int cmd_get_freq_mode_status_sat_tx_vfo(int fd, unsigned char *mode);
|
||||
|
||||
|
||||
/*
|
||||
* Set frequency in Hz and mode
|
||||
*
|
||||
*/
|
||||
|
||||
void cmd_set_freq_main_vfo_hz(int fd,long int freq, unsigned char mode);
|
||||
void cmd_set_freq_sat_rx_vfo_hz(int fd,long int freq, unsigned char mode);
|
||||
void cmd_set_freq_sat_tx_vfo_hz(int fd,long int freq, unsigned char mode);
|
||||
|
||||
|
||||
/*
|
||||
* Set Repeater offset in Hz.
|
||||
*
|
||||
*/
|
||||
|
||||
void cmd_set_repeater_offset_hz(int fd,long int freq);
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
|
||||
#endif /* _FT847_H */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Ładowanie…
Reference in New Issue