Added support for rig_set_ptt and rig_get_ptt. FT-920 supports CAT

control of PTT even though manual lacks mention of the command.
Moved setting of pacing value to ft920_open from ft920_get_update_data
to avoid sending two commands for each status update request and set
the default pacing value in ft920.h to 0 mS between characters sent
from the FT-920.


git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2253 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.7
Nate Bargmann, N0NB 2007-11-25 04:57:42 +00:00
rodzic bc1e6f3959
commit e23a3cef49
2 zmienionych plików z 1255 dodań i 1068 usunięć

Wyświetl plik

@ -12,7 +12,7 @@
* pages 86 to 90
*
*
* $Id: ft920.c,v 1.20 2006-10-07 15:51:38 csete Exp $
* $Id: ft920.c,v 1.21 2007-11-25 04:57:42 n0nb Exp $
*
*
* This library is free software; you can redistribute it and/or
@ -103,6 +103,8 @@ static const yaesu_cmd_set_t ncmd[] = {
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x0a } }, /* set vfo A freq */
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x0c } }, /* mode set */
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x0e } }, /* update interval/pacing */
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x0f } }, /* PTT off */
{ 1, { 0x00, 0x00, 0x00, 0x01, 0x0f } }, /* PTT on */
{ 1, { 0x00, 0x00, 0x00, 0x01, 0x10 } }, /* Status Update Data--Memory Channel Number (1 byte) */
{ 1, { 0x00, 0x00, 0x00, 0x02, 0x10 } }, /* Status Update Data--Current operating data for VFO/Memory (28 bytes) */
{ 1, { 0x00, 0x00, 0x00, 0x03, 0x10 } }, /* Status Update DATA--VFO A and B Data (28 bytes) */
@ -113,10 +115,10 @@ static const yaesu_cmd_set_t ncmd[] = {
{ 1, { 0x00, 0x00, 0x00, 0x80, 0x8c } }, /* VFO B wide filter */
{ 1, { 0x00, 0x00, 0x00, 0x82, 0x8c } }, /* VFO B narrow filter */
{ 1, { 0x00, 0x00, 0x00, 0x01, 0xFA } }, /* Read status flags */
/* { 0, { 0x00, 0x00, 0x00, 0x00, 0x70 } }, */ /* keyer commands */
/* { 1, { 0x00, 0x00, 0x00, 0x00, 0x81 } }, */ /* tuner off */
/* { 1, { 0x00, 0x00, 0x00, 0x01, 0x81 } }, */ /* tuner on */
/* { 1, { 0x00, 0x00, 0x00, 0x00, 0x82 } }, */ /* tuner start*/
/* { 0, { 0x00, 0x00, 0x00, 0x00, 0x70 } }, */ /* keyer commands */
/* { 1, { 0x00, 0x00, 0x00, 0x00, 0x81 } }, */ /* tuner off */
/* { 1, { 0x00, 0x00, 0x00, 0x01, 0x81 } }, */ /* tuner on */
/* { 1, { 0x00, 0x00, 0x00, 0x00, 0x82 } }, */ /* tuner start*/
};
@ -125,7 +127,7 @@ static const yaesu_cmd_set_t ncmd[] = {
* future - private data
*
* FIXME: Does this need to be exposed to the application/frontend through
* ft920_caps.priv? -N0NB
* ft920_caps.priv? I'm guessing not as it's private to the backend. -N0NB
*/
struct ft920_priv_data {
@ -151,7 +153,7 @@ const struct rig_caps ft920_caps = {
.copyright = "LGPL",
.status = RIG_STATUS_ALPHA,
.rig_type = RIG_TYPE_TRANSCEIVER,
.ptt_type = RIG_PTT_NONE,
.ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_NONE,
.port_type = RIG_PORT_SERIAL,
.serial_rate_min = 4800,
@ -177,6 +179,9 @@ const struct rig_caps ft920_caps = {
.max_rit = Hz(9999),
.max_xit = Hz(9999),
.max_ifshift = Hz(0),
.announces = RIG_ANN_NONE,
.vfo_ops = RIG_OP_NONE,
.scan_ops = RIG_SCAN_NONE,
.targetable_vfo = RIG_TARGETABLE_ALL,
.transceive = RIG_TRN_OFF, /* Yaesus have to be polled, sigh */
.bank_qty = 0,
@ -249,30 +254,91 @@ const struct rig_caps ft920_caps = {
RIG_FLT_END,
},
.priv = NULL, /* private data FIXME: */
.str_cal = EMPTY_STR_CAL,
.cfgparams = NULL,
.priv = NULL, /* private data FIXME: ?? */
.rig_init = ft920_init,
.rig_cleanup = ft920_cleanup,
.rig_open = ft920_open, /* port opened */
.rig_close = ft920_close, /* port closed */
.set_freq = ft920_set_freq, /* set freq */
.get_freq = ft920_get_freq, /* get freq */
.set_mode = ft920_set_mode, /* set mode */
.get_mode = ft920_get_mode, /* get mode */
.set_vfo = ft920_set_vfo, /* set vfo */
.get_vfo = ft920_get_vfo, /* get vfo */
.set_split_vfo = ft920_set_split_vfo,
.get_split_vfo = ft920_get_split_vfo,
.set_freq = ft920_set_freq,
.get_freq = ft920_get_freq,
.set_mode = ft920_set_mode,
.get_mode = ft920_get_mode,
.set_vfo = ft920_set_vfo,
.get_vfo = ft920_get_vfo,
.set_ptt = ft920_set_ptt,
.get_ptt = ft920_get_ptt,
.get_dcd = NULL,
.set_rptr_shift = NULL,
.get_rptr_shift = NULL,
.set_rptr_offs = NULL,
.get_rptr_offs= NULL,
.set_split_freq = ft920_set_split_freq,
.get_split_freq = ft920_get_split_freq,
.set_split_mode = ft920_set_split_mode,
.get_split_mode = ft920_get_split_mode,
.set_split_vfo = ft920_set_split_vfo,
.get_split_vfo = ft920_get_split_vfo,
.set_rit = ft920_set_rit,
.get_rit = ft920_get_rit,
.set_xit = ft920_set_xit,
.get_xit = ft920_get_xit,
.set_ts = NULL,
.get_ts = NULL,
.set_dcs_code = NULL,
.get_dcs_code = NULL,
.set_tone = NULL,
.get_tone = NULL,
.set_ctcss_tone = NULL,
.get_ctcss_tone = NULL,
.set_dcs_sql = NULL,
.get_dcs_sql = NULL,
.set_tone_sql = NULL,
.get_tone_sql = NULL,
.set_ctcss_sql = NULL,
.get_ctcss_sql = NULL,
.power2mW = NULL,
.mW2power = NULL,
.set_powerstat = NULL,
.get_powerstat = NULL,
.reset = NULL,
.set_ant = NULL,
.get_ant = NULL,
.set_level = NULL,
.get_level = NULL,
.set_func = NULL,
.get_func = NULL,
.set_parm = NULL,
.get_parm = NULL,
.set_ext_level = NULL,
.get_ext_level = NULL,
.set_ext_parm = NULL,
.get_ext_parm = NULL,
.set_conf = NULL,
.get_conf = NULL,
.send_dtmf = NULL,
.recv_dtmf = NULL,
.send_morse = NULL,
.set_bank = NULL,
.set_mem = NULL,
.get_mem = NULL,
.vfo_op = NULL,
.scan = NULL,
.set_trn = NULL,
.get_trn = NULL,
.decode_event = NULL,
.set_channel = NULL,
.get_channel = NULL,
.get_info = NULL,
.set_chan_all_cb = NULL,
.get_chan_all_cb = NULL,
.set_mem_all_cb = NULL,
.get_mem_all_cb = NULL,
.clone_combo_set = NULL,
.clone_combo_get = NULL,
};
@ -298,8 +364,8 @@ static int ft920_init(RIG *rig) {
return -RIG_EINVAL;
priv = (struct ft920_priv_data *)malloc(sizeof(struct ft920_priv_data));
if (!priv) /* whoops! memory shortage! */
return -RIG_ENOMEM;
if (!priv)
return -RIG_ENOMEM; /* whoops! memory shortage! */
/*
* Copy native cmd set to private cmd storage area
@ -343,12 +409,15 @@ static int ft920_cleanup(RIG *rig) {
static int ft920_open(RIG *rig) {
struct rig_state *rig_s;
struct ft920_priv_data *priv;
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
return -RIG_EINVAL;
priv = (struct ft920_priv_data *)rig->state.priv;
rig_s = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: write_delay = %i msec\n",
@ -356,6 +425,18 @@ static int ft920_open(RIG *rig) {
rig_debug(RIG_DEBUG_TRACE, "%s: post_write_delay = %i msec\n",
__func__, rig_s->rigport.post_write_delay);
/* Copy native cmd PACING to private cmd storage area */
memcpy(&priv->p_cmd, &ncmd[FT920_NATIVE_PACING].nseq, YAESU_CMD_LENGTH);
/* get pacing value, and store in private cmd */
priv->p_cmd[P1] = priv->pacing;
rig_debug(RIG_DEBUG_TRACE, "%s: read pacing = %i\n", __func__, priv->pacing);
err = write_block(&rig_s->rigport, (char *) priv->p_cmd, YAESU_CMD_LENGTH);
if (err != RIG_OK)
return err;
/* TODO: more initialization as necessary */
return RIG_OK;
@ -907,7 +988,6 @@ static int ft920_get_vfo(RIG *rig, vfo_t *vfo) {
rig_debug(RIG_DEBUG_TRACE, "%s: set vfo = 0x%02x\n", __func__, *vfo);
return RIG_OK;
}
@ -1281,6 +1361,114 @@ static int ft920_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit) {
}
/*
* rig_set_ptt
*
* set the '920 into TX mode
*
* vfo is respected by calling ft920_set_vfo if
* passed vfo != priv->current_vfo
*
* This command is not documented in my '920 manual, but it works! -N0NB
*
*/
static int ft920_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) {
struct ft920_priv_data *priv;
unsigned char cmd_index;
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
return -RIG_EINVAL;
priv = (struct ft920_priv_data *)rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: passed vfo = 0x%02x\n", __func__, vfo);
rig_debug(RIG_DEBUG_TRACE, "%s: passed ptt = 0x%02x\n", __func__, ptt);
if (vfo == RIG_VFO_CURR) {
vfo = priv->current_vfo; /* from previous vfo cmd */
rig_debug(RIG_DEBUG_TRACE,
"%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
} else if (vfo != priv->current_vfo) {
ft920_set_vfo(rig, vfo);
}
switch (ptt) {
case RIG_PTT_OFF:
cmd_index = FT920_NATIVE_PTT_OFF;
break;
case RIG_PTT_ON:
cmd_index = FT920_NATIVE_PTT_ON;
break;
default:
return -RIG_EINVAL; /* wrong PTT state! */
}
err = ft920_send_static_cmd(rig, cmd_index);
if (err != RIG_OK)
return err;
return RIG_OK;
}
/*
* rig_get_ptt
*
* get current PTT status
*
*/
static int ft920_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) {
struct ft920_priv_data *priv;
unsigned char stat_0; /* ft920 status flag 0 */
unsigned char stat_ptt; /* status tests */
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
return -RIG_EINVAL;
priv = (struct ft920_priv_data *)rig->state.priv;
/* Get flags for VFO status */
err = ft920_get_update_data(rig, FT920_NATIVE_STATUS_FLAGS,
FT920_STATUS_FLAGS_LENGTH);
if (err != RIG_OK)
return err;
/*
* The FT-920 status gives two flags for PTT, one if the PTT
* line is grounded externally and the other if the PTT line
* is grounded as the result of a CAT command. However, the
* 7th bit of status byte 0 is set or cleared in each case
* and gives an accurate state of the PTT line.
*/
stat_0 = priv->update_data[FT920_SUMO_DISPLAYED_STATUS_0];
stat_ptt = stat_0 & SF_PTT_MASK; /* get external PTT active bit */
rig_debug(RIG_DEBUG_TRACE, "%s: ptt stat_0 = 0x%02x, stat_ptt = 0x%02x\n",
__func__, stat_0, stat_ptt);
switch (stat_ptt) {
case SF_PTT_OFF:
*ptt = RIG_PTT_OFF;
break;
case SF_PTT_ON:
*ptt = RIG_PTT_ON;
break;
default: /* Oops! */
return -RIG_EINVAL; /* Invalid PTT bit?! */
}
return RIG_OK;
}
/*
* ************************************
*
@ -1320,23 +1508,11 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) {
priv = (struct ft920_priv_data *)rig->state.priv;
rig_s = &rig->state;
/* Copy native cmd PACING to private cmd storage area */
memcpy(&priv->p_cmd, &ncmd[FT920_NATIVE_PACING].nseq, YAESU_CMD_LENGTH);
/* get pacing value, and store in private cmd */
priv->p_cmd[P1] = priv->pacing;
rig_debug(RIG_DEBUG_TRACE, "%s: read pacing = %i\n", __func__, priv->pacing);
err = write_block(&rig_s->rigport, (char *) priv->p_cmd, YAESU_CMD_LENGTH);
if (err != RIG_OK)
return err;
err = ft920_send_static_cmd(rig, ci);
if (err != RIG_OK)
return err;
n = read_block(&rig_s->rigport, (char *) priv->update_data, rl);
n = read_block(&rig_s->rigport, (char *)priv->update_data, rl);
if (n < 0)
return n; /* die returning read_block error */
@ -1426,7 +1602,8 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci,
* as static (1), then bail out.
*/
if (priv->pcs[ci].ncomp) {
rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__);
rig_debug(RIG_DEBUG_TRACE, "%s: Attempted to modify a complete command sequence: %i\n",
__func__, ci);
return -RIG_EINVAL;
}

Wyświetl plik

@ -2,14 +2,14 @@
* hamlib - (C) Frank Singleton 2000 (javabear at users.sourceforge.net)
*
* ft920.h - (C) Frank Singleton 2000 (javabear at users.sourceforge.net)
* (C) Nate Bargmann 2002-2005 (n0nb at arrl.net)
* (C) Nate Bargmann 2002-2007 (n0nb at arrl.net)
* (C) Stephane Fillod 2002 (fillods at users.sourceforge.net)
*
* This shared library provides an API for communicating
* via serial interface to an FT-920 using the "CAT" interface
*
*
* $Id: ft920.h,v 1.13 2005-01-18 23:06:51 n0nb Exp $
* $Id: ft920.h,v 1.14 2007-11-25 04:57:42 n0nb Exp $
*
*
* This library is free software; you can redistribute it and/or
@ -67,7 +67,7 @@
/* Timing values in mS */
#define FT920_PACING_INTERVAL 5
#define FT920_PACING_DEFAULT_VALUE 1
#define FT920_PACING_DEFAULT_VALUE 0 /* time between characters from 920 */
#define FT920_WRITE_DELAY 50
@ -86,8 +86,8 @@
/*
* 8N2 and 1 start bit = 11 bits at 4800 bps => effective byte rate = 1 byte in 2.2917 msec
* => 28 bytes in 64 msec
* 8N2 and 1 start bit = 11 bits at 4800 bps => effective byte rate = 1 byte
* in 2.2917 msec => 28 bytes in 64 msec
*
* delay for 28 bytes = (2.2917 + pace_interval) * 28
*
@ -120,6 +120,8 @@ enum ft920_native_cmd_e {
FT920_NATIVE_VFO_A_FREQ_SET,
FT920_NATIVE_MODE_SET,
FT920_NATIVE_PACING,
FT920_NATIVE_PTT_OFF,
FT920_NATIVE_PTT_ON,
FT920_NATIVE_MEM_CHNL,
FT920_NATIVE_OP_DATA,
FT920_NATIVE_VFO_DATA,
@ -215,6 +217,9 @@ typedef enum ft920_native_cmd_e ft920_native_cmd_t;
#define SF_SPLITA (1<<0) /* Split operation with VFO-B on TX */
#define SF_SPLITB (1<<1) /* Split operation with VFO-B on RX */
#define SF_VFOB (SF_SPLITA|SF_SPLITB) /* bits 0 & 1, VFO B TX/RX == 3 */
#define SF_PTT_OFF (0<<7) /* Receive mode (PTT line open) */
#define SF_PTT_ON (1<<7) /* Transmission in progress (PTT line grounded) */
#define SF_PTT_MASK (SF_PTT_ON)
#define FT920_SUMO_DISPLAYED_STATUS_1 0x01 /* Status flag byte 1 */
#define SF_QMB (1<<3) /* Quick Memory Bank (QMB) selected */
@ -224,6 +229,7 @@ typedef enum ft920_native_cmd_e ft920_native_cmd_t;
#define SF_GC (1<<7) /* General Coverage Reception selected */
#define SF_VFO_MASK (SF_QMB|SF_MT|SF_VFO|SF_MR)
/*
* Offsets for VFO record retrieved via 0x10 P1 = 02, 03
*
@ -336,4 +342,8 @@ static int ft920_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit);
static int ft920_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit);
static int ft920_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit);
/* not documented in my FT-920 manual, but it works! - N0NB */
static int ft920_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
static int ft920_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt);
#endif /* _FT920_H */