2004-08-10 21:10:36 +00:00
|
|
|
/*
|
2005-02-26 22:30:55 +00:00
|
|
|
* frg100.c - (C) Stephane Fillod 2002-2005
|
2004-08-10 21:10:36 +00:00
|
|
|
*
|
|
|
|
* This shared library provides an API for communicating
|
|
|
|
* via serial interface to an FRG-100 using the "CAT" interface
|
|
|
|
*
|
|
|
|
*
|
2011-08-23 02:26:44 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2004-08-10 21:10:36 +00:00
|
|
|
*
|
2011-08-23 02:26:44 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2004-08-10 21:10:36 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-08-23 02:26:44 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2004-08-10 21:10:36 +00:00
|
|
|
*
|
2011-08-23 02:26:44 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2004-08-10 21:10:36 +00:00
|
|
|
* License along with this library; if not, write to the Free Software
|
2011-08-23 02:26:44 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-08-10 21:10:36 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
#include <unistd.h> /* UNIX standard function definitions */
|
|
|
|
|
|
|
|
#include "hamlib/rig.h"
|
|
|
|
#include "serial.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "yaesu.h"
|
2016-02-02 14:34:11 +00:00
|
|
|
#include "frg100.h"
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define FRG100_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_AM|RIG_MODE_FM)
|
|
|
|
|
|
|
|
#define FRG100_VFOS (RIG_VFO_A)
|
|
|
|
#define FRG100_ANTS 0
|
|
|
|
|
|
|
|
|
2004-11-15 15:21:11 +00:00
|
|
|
/* TODO: get real measure numbers */
|
2004-08-10 21:10:36 +00:00
|
|
|
#define FRG100_STR_CAL { 2, { \
|
2019-11-30 16:19:08 +00:00
|
|
|
{ 0, -60 }, /* S0 -6dB */ \
|
|
|
|
{ 60, 60 } /* +60 */ \
|
|
|
|
} }
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
#define FRG100_MEM_CAP { \
|
|
|
|
.freq = 1, \
|
|
|
|
.mode = 1, \
|
|
|
|
.width = 1 \
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
|
|
|
static const yaesu_cmd_set_t ncmd[] =
|
|
|
|
{
|
|
|
|
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x02 } }, /* Recall Memory */
|
|
|
|
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x03 } }, /* VFO to MEM */
|
|
|
|
{ 0, { 0x00, 0x00, 0x01, 0x00, 0x03 } }, /* Hide Memory Channel */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x05 } }, /* Select VFO (A) */
|
|
|
|
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x0a } }, /* Set Op Freq */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x0c } }, /* OP Mode Set LSB */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x01, 0x0c } }, /* OP Mode Set USB */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x02, 0x0c } }, /* OP Mode Set CW-W */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x03, 0x0c } }, /* OP Mode Set CW-N */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x04, 0x0c } }, /* OP Mode Set AM */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x08, 0x0c } }, /* OP Mode Set RTTY LSB-W */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x09, 0x0c } }, /* OP Mode Set RTTY USB-W */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x0d, 0x0c } }, /* OP Mode Set H3E */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x0e, 0x0c } }, /* OP Mode Set RTTY LSB-N */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x0f, 0x0c } }, /* OP Mode Set RTTY USB-N */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x0f } }, /* PTT (OFF) */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x01, 0x0f } }, /* PTT (ON) */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x01, 0x10 } }, /* Update Memory Ch Number */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x02, 0x10 } }, /* Update Op Data */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x03, 0x10 } }, /* Update VFO Data */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x18 } }, /* Set TX power low */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x28 } }, /* Set TX power mid */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x48 } }, /* Set TX power hi */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x85 } }, /* Copy RX to TX */
|
|
|
|
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x8a } }, /* Set TX Freq only */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x8e } }, /* Step Operating Frequency Up */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x01, 0x8e } }, /* Step Operating Frequency Down */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0xf7 } }, /* Read Meter */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0xfa } }, /* Read Status Flags */
|
2016-02-02 14:34:11 +00:00
|
|
|
};
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
/* Private helper function prototypes */
|
|
|
|
|
|
|
|
static int frg100_open(RIG *rig);
|
|
|
|
|
2016-02-02 14:34:11 +00:00
|
|
|
static int frg100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
|
2004-08-10 21:10:36 +00:00
|
|
|
static int frg100_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
|
|
|
static int frg100_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
|
|
|
|
static int frg100_set_vfo(RIG *rig, vfo_t vfo);
|
|
|
|
static int frg100_set_powerstat(RIG *rig, powerstat_t status);
|
|
|
|
static int frg100_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
|
|
|
|
|
2006-10-07 15:51:38 +00:00
|
|
|
#if 0
|
2004-08-10 21:10:36 +00:00
|
|
|
static int rig2mode(RIG *rig, int md, rmode_t *mode, pbwidth_t *width);
|
2006-10-07 15:51:38 +00:00
|
|
|
#endif
|
2004-08-10 21:10:36 +00:00
|
|
|
static int mode2rig(RIG *rig, rmode_t mode, pbwidth_t width);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* frg100 rigs capabilities.
|
|
|
|
* Also this struct is READONLY!
|
|
|
|
*
|
|
|
|
* TODO:
|
2019-11-30 16:19:08 +00:00
|
|
|
* - Memory recall
|
|
|
|
* - VFO->M & M->VFO
|
|
|
|
* - Lock, Up/Down
|
|
|
|
* - Status update
|
|
|
|
* - Clock set, Timer
|
|
|
|
* - Scan skip
|
|
|
|
* - Step Frequency Size
|
|
|
|
* - Dim
|
2004-08-10 21:10:36 +00:00
|
|
|
*/
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
const struct rig_caps frg100_caps =
|
|
|
|
{
|
2020-03-05 14:44:18 +00:00
|
|
|
RIG_MODEL(RIG_MODEL_FRG100),
|
2019-11-30 16:19:08 +00:00
|
|
|
.model_name = "FRG-100",
|
|
|
|
.mfg_name = "Yaesu",
|
|
|
|
.version = "0.5",
|
|
|
|
.copyright = "LGPL",
|
|
|
|
.status = RIG_STATUS_BETA,
|
|
|
|
.rig_type = RIG_TYPE_RECEIVER,
|
|
|
|
.ptt_type = RIG_PTT_NONE,
|
|
|
|
.dcd_type = RIG_DCD_NONE,
|
|
|
|
.port_type = RIG_PORT_SERIAL,
|
|
|
|
.serial_rate_min = 4800,
|
|
|
|
.serial_rate_max = 4800,
|
|
|
|
.serial_data_bits = 8,
|
|
|
|
.serial_stop_bits = 2,
|
|
|
|
.serial_parity = RIG_PARITY_NONE,
|
|
|
|
.serial_handshake = RIG_HANDSHAKE_NONE,
|
|
|
|
.write_delay = 20,
|
|
|
|
.post_write_delay = 300,
|
|
|
|
.timeout = 2000,
|
|
|
|
.retry = 0,
|
|
|
|
.has_get_func = RIG_FUNC_LOCK,
|
|
|
|
.has_set_func = RIG_FUNC_LOCK,
|
|
|
|
.has_get_level = RIG_LEVEL_RAWSTR,
|
|
|
|
.has_set_level = RIG_LEVEL_NONE,
|
|
|
|
.has_get_parm = RIG_PARM_NONE,
|
|
|
|
.has_set_parm = RIG_PARM_BACKLIGHT,
|
|
|
|
.vfo_ops = RIG_OP_FROM_VFO | RIG_OP_TO_VFO | RIG_OP_UP | RIG_OP_DOWN,
|
|
|
|
.preamp = { RIG_DBLST_END, },
|
|
|
|
.attenuator = { RIG_DBLST_END, },
|
|
|
|
.max_rit = Hz(0),
|
|
|
|
.max_xit = Hz(0),
|
|
|
|
.max_ifshift = Hz(0),
|
|
|
|
.targetable_vfo = RIG_TARGETABLE_NONE,
|
|
|
|
.transceive = RIG_TRN_OFF,
|
|
|
|
.bank_qty = 0,
|
|
|
|
.chan_desc_sz = 0,
|
|
|
|
.chan_list = {
|
|
|
|
{ 1, 0x32, RIG_MTYPE_MEM, FRG100_MEM_CAP },
|
|
|
|
{ 0x33, 0x34, RIG_MTYPE_EDGE },
|
|
|
|
},
|
|
|
|
.rx_range_list1 = {
|
|
|
|
{kHz(50), MHz(30), FRG100_MODES, -1, -1, FRG100_VFOS, FRG100_ANTS },
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* Region 1 rx ranges */
|
|
|
|
|
|
|
|
.tx_range_list1 = {
|
|
|
|
{kHz(50), MHz(30), FRG100_MODES, -1, -1, FRG100_VFOS, FRG100_ANTS },
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* region 1 TX ranges */
|
|
|
|
|
|
|
|
.rx_range_list2 = {
|
|
|
|
{kHz(50), MHz(30), FRG100_MODES, -1, -1, FRG100_VFOS, FRG100_ANTS },
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* Region 2 rx ranges */
|
|
|
|
|
|
|
|
.tx_range_list2 = {
|
|
|
|
{kHz(50), MHz(30), FRG100_MODES, -1, -1, FRG100_VFOS, FRG100_ANTS },
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* region 2 TX ranges */
|
|
|
|
|
|
|
|
.tuning_steps = {
|
|
|
|
{RIG_MODE_SSB | RIG_MODE_CW, Hz(10)},
|
|
|
|
{RIG_MODE_FM | RIG_MODE_AM, Hz(100)},
|
|
|
|
RIG_TS_END,
|
|
|
|
},
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
/* mode/filter list, remember: order matters! */
|
2019-11-30 16:19:08 +00:00
|
|
|
.filters = {
|
|
|
|
{RIG_MODE_SSB | RIG_MODE_CW, kHz(2.4)},
|
|
|
|
{RIG_MODE_CW, Hz(500)},
|
|
|
|
{RIG_MODE_AM, kHz(6)},
|
|
|
|
{RIG_MODE_AM, kHz(4)},
|
|
|
|
{RIG_MODE_FM, kHz(15)},
|
|
|
|
RIG_FLT_END,
|
|
|
|
},
|
|
|
|
|
|
|
|
.str_cal = FRG100_STR_CAL,
|
|
|
|
|
|
|
|
.rig_open = frg100_open,
|
|
|
|
|
|
|
|
.get_freq = frg100_get_freq,
|
|
|
|
.set_freq = frg100_set_freq,
|
|
|
|
.set_mode = frg100_set_mode,
|
|
|
|
.set_vfo = frg100_set_vfo,
|
|
|
|
.get_level = frg100_get_level,
|
|
|
|
|
|
|
|
.set_powerstat = frg100_set_powerstat,
|
2004-08-10 21:10:36 +00:00
|
|
|
};
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
static inline int frg100_channel_is_ok(unsigned char channel)
|
|
|
|
{
|
2016-02-02 14:34:11 +00:00
|
|
|
return ((channel >= FRG100_MIN_CHANNEL) &&
|
|
|
|
(channel <= FRG100_MAX_CHANNEL)) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
static int frg100_do_transaction(RIG *rig,
|
|
|
|
const unsigned char cmd[YAESU_CMD_LENGTH],
|
|
|
|
unsigned char *retbuf, size_t retbuf_len)
|
|
|
|
{
|
2016-02-02 14:34:11 +00:00
|
|
|
struct rig_state *rs;
|
|
|
|
unsigned char default_retbuf[1];
|
|
|
|
int retval;
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (retbuf == NULL)
|
|
|
|
{
|
2016-02-02 14:34:11 +00:00
|
|
|
retbuf = default_retbuf;
|
|
|
|
retbuf_len = sizeof(default_retbuf);
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
2016-02-02 14:34:11 +00:00
|
|
|
rs = &rig->state;
|
|
|
|
memset(retbuf, 0, retbuf_len);
|
|
|
|
|
|
|
|
serial_flush(&rs->rigport);
|
2019-11-30 16:19:08 +00:00
|
|
|
retval = write_block(&rs->rigport, (const char *)cmd, YAESU_CMD_LENGTH);
|
|
|
|
|
|
|
|
if (retval != RIG_OK) { return retval; }
|
|
|
|
|
|
|
|
retval = read_block(&rs->rigport, (char *)retbuf, retbuf_len);
|
|
|
|
|
|
|
|
if (retval != retbuf_len)
|
|
|
|
{
|
|
|
|
if ((retval == 1) && (retbuf[0] == FRG100_CMD_RETCODE_ERROR)) { return -RIG_ERJCTED; }
|
2016-02-02 14:34:11 +00:00
|
|
|
|
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
if (retval == 1)
|
|
|
|
{
|
|
|
|
if ((cmd[4] == FRG100_CMD_UPDATE) && (cmd[3] == 0x01))
|
|
|
|
{
|
2016-02-02 14:34:11 +00:00
|
|
|
/* read memory channel number */
|
2019-11-30 16:19:08 +00:00
|
|
|
if (frg100_channel_is_ok(retbuf[0] + 1))
|
|
|
|
{
|
2016-02-02 14:34:11 +00:00
|
|
|
/* WARNING: Documentation bug, actually
|
|
|
|
we got 0--199 for channels 1--200 */
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
if (retbuf[0] == FRG100_CMD_RETCODE_ERROR) { return -RIG_ERJCTED; }
|
|
|
|
|
2016-02-02 14:34:11 +00:00
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
if (retbuf[0] == FRG100_CMD_RETCODE_OK) { return RIG_OK; }
|
|
|
|
|
|
|
|
if (retbuf[0] == FRG100_CMD_RETCODE_ERROR) { return -RIG_ERJCTED; }
|
|
|
|
|
2016-02-02 14:34:11 +00:00
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
2016-02-02 14:34:11 +00:00
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
static inline freq_t frg100_read_freq_from_buf(const unsigned char p[])
|
|
|
|
{
|
2016-02-02 14:34:11 +00:00
|
|
|
/* WARNING: documentation bug, actually frequency stored in bytes 0..2 only,
|
|
|
|
byte 3 is not used and contain zero */
|
|
|
|
return ((((((unsigned)p[2]) << 8) + p[1]) << 8) + p[0]) * 10.0;
|
|
|
|
}
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
static inline int frg100_read_op_data_raw(RIG *rig, unsigned char reply[])
|
|
|
|
{
|
|
|
|
if (rig == NULL) { return -RIG_EINVAL; }
|
|
|
|
|
2016-02-02 14:34:11 +00:00
|
|
|
return frg100_do_transaction(rig, ncmd[FRG100_NATIVE_UPDATE_OP_DATA].nseq,
|
|
|
|
reply, FRG100_OP_DATA_LENGTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int frg100_read_op_data(RIG *rig, unsigned char *hwmode,
|
2019-11-30 16:19:08 +00:00
|
|
|
freq_t *rx_freq, freq_t *tx_freq)
|
|
|
|
{
|
2016-02-02 14:34:11 +00:00
|
|
|
int ret;
|
|
|
|
unsigned char reply[FRG100_OP_DATA_LENGTH];
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if ((ret = frg100_read_op_data_raw(rig, reply)) != RIG_OK) { return ret; }
|
|
|
|
|
|
|
|
if (hwmode != NULL) { *hwmode = reply[7]; }
|
|
|
|
|
|
|
|
if (rx_freq != NULL) { *rx_freq = frg100_read_freq_from_buf(reply + 2); }
|
|
|
|
|
|
|
|
if (tx_freq != NULL) { *tx_freq = frg100_read_freq_from_buf(reply + 11); }
|
|
|
|
|
2016-02-02 14:34:11 +00:00
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* frg100_open routine
|
2011-08-23 02:26:44 +00:00
|
|
|
*
|
2004-08-10 21:10:36 +00:00
|
|
|
*/
|
|
|
|
int frg100_open(RIG *rig)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x0e};
|
2011-08-23 02:26:44 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* send 0 delay pacing */
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
int frg100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|
|
|
{
|
2016-02-02 14:34:11 +00:00
|
|
|
(void) vfo;
|
|
|
|
return frg100_read_op_data(rig, NULL, freq, NULL);
|
|
|
|
}
|
|
|
|
|
2004-08-10 21:10:36 +00:00
|
|
|
int frg100_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x0a};
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* store bcd format in cmd (LSB) */
|
|
|
|
to_bcd(cmd, freq / 10, 8);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* Frequency set */
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int frg100_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x0c};
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* fill in p1 */
|
|
|
|
cmd[3] = mode2rig(rig, mode, width);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Actually, this is tape relay, 0xfe=on
|
|
|
|
*/
|
|
|
|
int frg100_set_powerstat(RIG *rig, powerstat_t status)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x20};
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
cmd[3] = status == RIG_POWER_OFF ? 0x00 : 0x01;
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* Frequency set */
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int frg100_set_vfo(RIG *rig, vfo_t vfo)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
|
|
|
|
|
|
|
switch (vfo)
|
|
|
|
{
|
|
|
|
case RIG_VFO_CURR:
|
|
|
|
return RIG_OK;
|
|
|
|
|
|
|
|
case RIG_VFO_VFO:
|
|
|
|
case RIG_VFO_A:
|
|
|
|
cmd[4] = 0x05;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_VFO_MEM:
|
|
|
|
/* TODO: cmd[3] = priv->current_mem_chan; */
|
|
|
|
cmd[4] = 0x02;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL; /* sorry, wrong VFO */
|
|
|
|
}
|
|
|
|
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int frg100_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0xf7};
|
|
|
|
int retval;
|
2011-08-23 02:26:44 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (level != RIG_LEVEL_RAWSTR)
|
|
|
|
{
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
serial_flush(&rig->state.rigport);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* send READ STATUS(Meter only) cmd to rig */
|
|
|
|
retval = write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
|
|
|
|
|
|
|
if (retval < 0)
|
|
|
|
{
|
|
|
|
return retval;
|
|
|
|
}
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* read back the 1 byte */
|
|
|
|
retval = read_block(&rig->state.rigport, (char *) cmd, 5);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (retval < 1)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: read meter failed %d\n",
|
|
|
|
__func__, retval);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return retval < 0 ? retval : -RIG_EIO;
|
|
|
|
}
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
val->i = cmd[0];
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
#define MODE_LSB 0x00
|
|
|
|
#define MODE_USB 0x01
|
|
|
|
#define MODE_CWW 0x02
|
|
|
|
#define MODE_CWN 0x03
|
|
|
|
#define MODE_AMW 0x04
|
|
|
|
#define MODE_AMN 0x05
|
|
|
|
#define MODE_FMW 0x06
|
|
|
|
#define MODE_FMN 0x07
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
int mode2rig(RIG *rig, rmode_t mode, pbwidth_t width)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
int md;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* translate mode from generic to frg100 specific
|
|
|
|
*/
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case RIG_MODE_USB: md = MODE_USB; break;
|
|
|
|
|
|
|
|
case RIG_MODE_LSB: md = MODE_LSB; break;
|
|
|
|
|
|
|
|
case RIG_MODE_AM:
|
|
|
|
if (width != RIG_PASSBAND_NOCHANGE
|
|
|
|
&& (width != RIG_PASSBAND_NORMAL ||
|
|
|
|
width < rig_passband_normal(rig, mode)))
|
|
|
|
{
|
|
|
|
md = MODE_AMN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
md = MODE_AMW;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_MODE_FM:
|
|
|
|
if (width != RIG_PASSBAND_NOCHANGE
|
|
|
|
&& (width != RIG_PASSBAND_NORMAL ||
|
|
|
|
width < rig_passband_normal(rig, mode)))
|
|
|
|
{
|
|
|
|
md = MODE_FMN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
md = MODE_FMW;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_MODE_CW:
|
|
|
|
if (width != RIG_PASSBAND_NOCHANGE
|
|
|
|
&& (width != RIG_PASSBAND_NORMAL ||
|
|
|
|
width < rig_passband_normal(rig, mode)))
|
|
|
|
{
|
|
|
|
md = MODE_CWN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
md = MODE_CWW;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL; /* sorry, wrong MODE */
|
|
|
|
}
|
|
|
|
|
|
|
|
return md;
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
2006-10-07 15:51:38 +00:00
|
|
|
/* function not used */
|
|
|
|
#if 0
|
2004-08-10 21:10:36 +00:00
|
|
|
int rig2mode(RIG *rig, int md, rmode_t *mode, pbwidth_t *width)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
/*
|
|
|
|
* translate mode from frg100 specific to generic
|
|
|
|
*/
|
|
|
|
switch (md)
|
|
|
|
{
|
|
|
|
case MODE_USB: *mode = RIG_MODE_USB; break;
|
|
|
|
|
|
|
|
case MODE_LSB: *mode = RIG_MODE_LSB; break;
|
|
|
|
|
|
|
|
case MODE_AMW:
|
|
|
|
case MODE_AMN: *mode = RIG_MODE_AM; break;
|
|
|
|
|
|
|
|
case MODE_FMW:
|
|
|
|
case MODE_FMN: *mode = RIG_MODE_FM; break;
|
|
|
|
|
|
|
|
case MODE_CWW:
|
|
|
|
case MODE_CWN: *mode = RIG_MODE_CW; break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL; /* sorry, wrong MODE */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (md == MODE_CWN || md == MODE_AMN || md == MODE_FMN)
|
|
|
|
{
|
|
|
|
*width = rig_passband_narrow(rig, *mode);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*width = rig_passband_normal(rig, *mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
2006-10-07 15:51:38 +00:00
|
|
|
#endif
|