kopia lustrzana https://github.com/Hamlib/Hamlib
JST-145 is now working with WSJT-X
rodzic
dda13b91c6
commit
16cf199015
|
@ -32,6 +32,7 @@
|
||||||
#include "jrc.h"
|
#include "jrc.h"
|
||||||
|
|
||||||
|
|
||||||
|
static int jst145_init(RIG *rig);
|
||||||
static int jst145_open(RIG *rig);
|
static int jst145_open(RIG *rig);
|
||||||
static int jst145_close(RIG *rig);
|
static int jst145_close(RIG *rig);
|
||||||
static int jst145_set_vfo(RIG *rig, vfo_t vfo);
|
static int jst145_set_vfo(RIG *rig, vfo_t vfo);
|
||||||
|
@ -45,6 +46,8 @@ static int jst145_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
|
||||||
static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
|
static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
|
||||||
static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);
|
static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);
|
||||||
static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch);
|
static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch);
|
||||||
|
static int jst145_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
|
||||||
|
static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt);
|
||||||
|
|
||||||
#define JST145_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_FAX)
|
#define JST145_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_FAX)
|
||||||
|
|
||||||
|
@ -59,6 +62,14 @@ static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch);
|
||||||
.levels = RIG_LEVEL_AGC, \
|
.levels = RIG_LEVEL_AGC, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct jst145_priv_data
|
||||||
|
{
|
||||||
|
ptt_t ptt;
|
||||||
|
freq_t freqA, freqB;
|
||||||
|
mode_t mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* JST-145 rig capabilities.
|
* JST-145 rig capabilities.
|
||||||
*
|
*
|
||||||
|
@ -70,9 +81,9 @@ const struct rig_caps jst145_caps =
|
||||||
.mfg_name = "JRC",
|
.mfg_name = "JRC",
|
||||||
.version = BACKEND_VER ".1",
|
.version = BACKEND_VER ".1",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_ALPHA,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_RECEIVER,
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||||
.ptt_type = RIG_PTT_NONE,
|
.ptt_type = RIG_PTT_RIG,
|
||||||
.dcd_type = RIG_DCD_NONE,
|
.dcd_type = RIG_DCD_NONE,
|
||||||
.port_type = RIG_PORT_SERIAL,
|
.port_type = RIG_PORT_SERIAL,
|
||||||
.serial_rate_min = 4800,
|
.serial_rate_min = 4800,
|
||||||
|
@ -82,9 +93,9 @@ const struct rig_caps jst145_caps =
|
||||||
.serial_parity = RIG_PARITY_NONE,
|
.serial_parity = RIG_PARITY_NONE,
|
||||||
.serial_handshake = RIG_HANDSHAKE_NONE,
|
.serial_handshake = RIG_HANDSHAKE_NONE,
|
||||||
.write_delay = 0,
|
.write_delay = 0,
|
||||||
.post_write_delay = 20,
|
.post_write_delay = 0,
|
||||||
.timeout = 1000,
|
.timeout = 1000,
|
||||||
.retry = 0,
|
.retry = 1,
|
||||||
|
|
||||||
.has_get_func = RIG_FUNC_NONE,
|
.has_get_func = RIG_FUNC_NONE,
|
||||||
.has_set_func = RIG_FUNC_NONE,
|
.has_set_func = RIG_FUNC_NONE,
|
||||||
|
@ -154,7 +165,9 @@ const struct rig_caps jst145_caps =
|
||||||
.set_func = jst145_set_func,
|
.set_func = jst145_set_func,
|
||||||
.set_level = jst145_set_level,
|
.set_level = jst145_set_level,
|
||||||
.set_mem = jst145_set_mem,
|
.set_mem = jst145_set_mem,
|
||||||
.vfo_op = jst145_vfo_op
|
.vfo_op = jst145_vfo_op,
|
||||||
|
.set_ptt = jst145_set_ptt,
|
||||||
|
.get_ptt = jst145_get_ptt
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -168,9 +181,9 @@ const struct rig_caps jst245_caps =
|
||||||
.mfg_name = "JRC",
|
.mfg_name = "JRC",
|
||||||
.version = BACKEND_VER ".1",
|
.version = BACKEND_VER ".1",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_ALPHA,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_RECEIVER,
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||||
.ptt_type = RIG_PTT_NONE,
|
.ptt_type = RIG_PTT_RIG,
|
||||||
.dcd_type = RIG_DCD_NONE,
|
.dcd_type = RIG_DCD_NONE,
|
||||||
.port_type = RIG_PORT_SERIAL,
|
.port_type = RIG_PORT_SERIAL,
|
||||||
.serial_rate_min = 4800,
|
.serial_rate_min = 4800,
|
||||||
|
@ -241,6 +254,7 @@ const struct rig_caps jst245_caps =
|
||||||
RIG_FLT_END,
|
RIG_FLT_END,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
.rig_init = jst145_init,
|
||||||
.rig_open = jst145_open,
|
.rig_open = jst145_open,
|
||||||
.rig_close = jst145_close,
|
.rig_close = jst145_close,
|
||||||
.set_vfo = jst145_set_vfo,
|
.set_vfo = jst145_set_vfo,
|
||||||
|
@ -252,16 +266,53 @@ const struct rig_caps jst245_caps =
|
||||||
.set_func = jst145_set_func,
|
.set_func = jst145_set_func,
|
||||||
.set_level = jst145_set_level,
|
.set_level = jst145_set_level,
|
||||||
.set_mem = jst145_set_mem,
|
.set_mem = jst145_set_mem,
|
||||||
.vfo_op = jst145_vfo_op
|
.vfo_op = jst145_vfo_op,
|
||||||
|
.set_ptt = jst145_set_ptt,
|
||||||
|
.get_ptt = jst145_get_ptt
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function definitions below
|
* Function definitions below
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
static int jst145_init(RIG *rig)
|
||||||
|
{
|
||||||
|
struct jst145_priv_data *priv;
|
||||||
|
priv = (struct jst145_priv_data *)malloc(sizeof(struct jst145_priv_data));
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
{
|
||||||
|
return -RIG_ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
rig->state.priv = (void *)priv;
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static int jst145_open(RIG *rig)
|
static int jst145_open(RIG *rig)
|
||||||
{
|
{
|
||||||
return write_block(&rig->state.rigport, "H1\r", 3);
|
int retval;
|
||||||
|
freq_t freq;
|
||||||
|
rmode_t mode;
|
||||||
|
pbwidth_t width;
|
||||||
|
struct jst145_priv_data *priv = rig->state.priv;
|
||||||
|
|
||||||
|
retval = write_block(&rig->state.rigport, "H1\r", 3);
|
||||||
|
|
||||||
|
if (retval != RIG_OK)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: H1 failed: %s\n", __func__, rigerror(retval));
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
jst145_get_freq(rig, RIG_VFO_A, &freq);
|
||||||
|
priv->freqA = freq;
|
||||||
|
jst145_get_freq(rig, RIG_VFO_B, &freq);
|
||||||
|
priv->freqB = freq;
|
||||||
|
jst145_get_mode(rig, RIG_VFO_A, &mode, &width);
|
||||||
|
priv->mode = mode;
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int jst145_close(RIG *rig)
|
static int jst145_close(RIG *rig)
|
||||||
|
@ -303,12 +354,24 @@ static int jst145_get_vfo(RIG *rig, vfo_t *vfo)
|
||||||
static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
{
|
{
|
||||||
char freqbuf[24];
|
char freqbuf[24];
|
||||||
|
struct jst145_priv_data *priv = rig->state.priv;
|
||||||
|
|
||||||
snprintf(freqbuf, sizeof(freqbuf), "F%08u%c\r", (unsigned)(freq / 10),
|
snprintf(freqbuf, sizeof(freqbuf), "F%08u%c\r", (unsigned)(freq),
|
||||||
vfo == RIG_VFO_A ? 'A' : 'B');
|
vfo == RIG_VFO_A ? 'A' : 'B');
|
||||||
|
|
||||||
|
if (vfo == RIG_VFO_B)
|
||||||
|
{
|
||||||
|
priv->freqB = freq;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
priv->freqA = freq;
|
||||||
|
}
|
||||||
|
|
||||||
return write_block(&rig->state.rigport, freqbuf, strlen(freqbuf));
|
return write_block(&rig->state.rigport, freqbuf, strlen(freqbuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||||
{
|
{
|
||||||
char freqbuf[24];
|
char freqbuf[24];
|
||||||
|
@ -318,7 +381,15 @@ static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||||
int n;
|
int n;
|
||||||
char vfoc;
|
char vfoc;
|
||||||
|
|
||||||
rig_set_vfo(rig, vfo);
|
struct jst145_priv_data *priv = rig->state.priv;
|
||||||
|
|
||||||
|
if (priv->ptt) // can't get freq while transmitting
|
||||||
|
{
|
||||||
|
*freq = vfo == RIG_VFO_B ? priv->freqB : priv->freqA;
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
jst145_set_vfo(rig, vfo);
|
||||||
snprintf(cmd, sizeof(cmd), "L\r");
|
snprintf(cmd, sizeof(cmd), "L\r");
|
||||||
retval = jrc_transaction(rig, cmd, strlen(cmd), freqbuf, &freqbuf_size);
|
retval = jrc_transaction(rig, cmd, strlen(cmd), freqbuf, &freqbuf_size);
|
||||||
|
|
||||||
|
@ -329,11 +400,11 @@ static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = sscanf(freqbuf, "L%c%lf", &vfoc, freq);
|
n = sscanf(freqbuf, "L%c%*c%*c%*c%8lf", &vfoc, freq);
|
||||||
|
|
||||||
if (n != 2) { retval = -RIG_EPROTO; }
|
if (n != 2) { retval = -RIG_EPROTO; }
|
||||||
|
|
||||||
if (vfoc == 'B') { rig_set_vfo(rig, RIG_VFO_A); }
|
if (vfoc == 'B') { jst145_set_vfo(rig, RIG_VFO_A); }
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -342,6 +413,7 @@ static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
char *modestr;
|
char *modestr;
|
||||||
|
struct jst145_priv_data *priv = rig->state.priv;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
|
@ -368,6 +440,8 @@ static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->mode = mode;
|
||||||
|
|
||||||
if (RIG_PASSBAND_NOCHANGE == width) { return retval; }
|
if (RIG_PASSBAND_NOCHANGE == width) { return retval; }
|
||||||
|
|
||||||
|
|
||||||
|
@ -456,3 +530,37 @@ static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int jst145_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
||||||
|
{
|
||||||
|
char cmd[24];
|
||||||
|
struct jst145_priv_data *priv = rig->state.priv;
|
||||||
|
rig_debug(RIG_DEBUG_TRACE, "%s: entered\n", __func__);
|
||||||
|
snprintf(cmd, sizeof(cmd), "X%c\r", ptt ? '1' : '0');
|
||||||
|
priv->ptt = ptt;
|
||||||
|
return write_block(&rig->state.rigport, cmd, strlen(cmd));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
||||||
|
{
|
||||||
|
char cmd[24];
|
||||||
|
char pttstatus[24];
|
||||||
|
int pttstatus_size = sizeof(pttstatus);
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
rig_debug(RIG_DEBUG_TRACE, "%s: entered\n", __func__);
|
||||||
|
|
||||||
|
snprintf(cmd, sizeof(cmd), "X\r");
|
||||||
|
retval = jrc_transaction(rig, cmd, strlen(cmd), pttstatus, &pttstatus_size);
|
||||||
|
|
||||||
|
if (retval != RIG_OK)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: jrc_transaction error: %s\n", __func__,
|
||||||
|
rigerror(retval));
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pttstatus[1] == '1') { *ptt = RIG_PTT_ON; }
|
||||||
|
else { *ptt = RIG_PTT_OFF; }
|
||||||
|
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue