kopia lustrzana https://github.com/Hamlib/Hamlib
Merge branch 'master' of https://github.com/Hamlib/Hamlib
commit
5817096b00
|
@ -27,6 +27,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h> /* String function definitions */
|
#include <string.h> /* String function definitions */
|
||||||
#include <unistd.h> /* UNIX standard function definitions */
|
#include <unistd.h> /* UNIX standard function definitions */
|
||||||
|
#include <ctype.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "hamlib/rig.h"
|
#include "hamlib/rig.h"
|
||||||
|
@ -47,6 +48,12 @@
|
||||||
#define CHAN_MIN 0
|
#define CHAN_MIN 0
|
||||||
#define CHAN_MAX 99
|
#define CHAN_MAX 99
|
||||||
|
|
||||||
|
// "E" system state is cached for this time (ms)
|
||||||
|
#define PRM80_CACHE_TIMEOUT 200
|
||||||
|
|
||||||
|
// Length (in bytes) of the response to the "E" command
|
||||||
|
#define CMD_E_RSP_LEN 22
|
||||||
|
|
||||||
#define RX_IF_OFFSET MHz(21.4)
|
#define RX_IF_OFFSET MHz(21.4)
|
||||||
|
|
||||||
// The rig's PLL only deals with freq in Hz divided by this value
|
// The rig's PLL only deals with freq in Hz divided by this value
|
||||||
|
@ -71,7 +78,7 @@ MessageAide: DB "H",0Dh,0Ah
|
||||||
DB " [1] a [5] = Show 80c552 port state P1 to P5.",0Dh,0Ah
|
DB " [1] a [5] = Show 80c552 port state P1 to P5.",0Dh,0Ah
|
||||||
DB " [C] = Print channels list.",0Dh,0Ah
|
DB " [C] = Print channels list.",0Dh,0Ah
|
||||||
DB " [D] = Set system byte.",0Dh,0Ah
|
DB " [D] = Set system byte.",0Dh,0Ah
|
||||||
DB " [E] = Show system state (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq).",0Dh,0Ah
|
DB " [E] = Show system state (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq,RSSI).",0Dh,0Ah
|
||||||
DB " [F] = Set squelch.",0Dh,0Ah
|
DB " [F] = Set squelch.",0Dh,0Ah
|
||||||
DB " [H] = Print this help page.",0Dh,0Ah
|
DB " [H] = Print this help page.",0Dh,0Ah
|
||||||
DB " [I] = Erase and init RAM and EEPROM.",0Dh,0Ah
|
DB " [I] = Erase and init RAM and EEPROM.",0Dh,0Ah
|
||||||
|
@ -97,7 +104,7 @@ MessageAide: DB "H",0Dh,0Ah
|
||||||
[D] = Set system byte.
|
[D] = Set system byte.
|
||||||
|
|
||||||
[E] = Show system state (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX
|
[E] = Show system state (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX
|
||||||
freq).
|
freq-RSSI).
|
||||||
[F] = Set squelch.
|
[F] = Set squelch.
|
||||||
[H] = Print this help page.
|
[H] = Print this help page.
|
||||||
[K] = Set lock byte.
|
[K] = Set lock byte.
|
||||||
|
@ -138,6 +145,13 @@ MessageAide: DB "H",0Dh,0Ah
|
||||||
* *********************************************************************
|
* *********************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static void prm80_force_cache_timeout(RIG *rig)
|
||||||
|
{
|
||||||
|
struct prm80_priv_data *priv = (struct prm80_priv_data *)rig->state.priv;
|
||||||
|
|
||||||
|
rig_force_cache_timeout(&priv->status_tv);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read a prompt terminated by delimiter, then write an optional string s.
|
* Read a prompt terminated by delimiter, then write an optional string s.
|
||||||
*/
|
*/
|
||||||
|
@ -318,6 +332,8 @@ int prm80_reset(RIG *rig, reset_t reset)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prm80_force_cache_timeout(rig);
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,6 +410,8 @@ int prm80_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
priv->rx_freq = freq;
|
priv->rx_freq = freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prm80_force_cache_timeout(rig);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,6 +433,8 @@ int prm80_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
|
||||||
priv->tx_freq = tx_freq;
|
priv->tx_freq = tx_freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prm80_force_cache_timeout(rig);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,6 +545,8 @@ int prm80_set_mem(RIG *rig, vfo_t vfo, int ch)
|
||||||
|
|
||||||
sprintf(chbuf, "%02u", (unsigned)ch);
|
sprintf(chbuf, "%02u", (unsigned)ch);
|
||||||
|
|
||||||
|
prm80_force_cache_timeout(rig);
|
||||||
|
|
||||||
// Send command, no answer expected from rig except ">" prompt
|
// Send command, no answer expected from rig except ">" prompt
|
||||||
|
|
||||||
return prm80_transaction(rig, "N", chbuf, 1);
|
return prm80_transaction(rig, "N", chbuf, 1);
|
||||||
|
@ -557,21 +579,28 @@ int prm80_get_mem(RIG *rig, vfo_t vfo, int *ch)
|
||||||
/*
|
/*
|
||||||
* Convert first two hexadecimal digit to integer
|
* Convert first two hexadecimal digit to integer
|
||||||
*/
|
*/
|
||||||
static int hhtoi(const char *p)
|
static unsigned hhtoi(const char *p)
|
||||||
{
|
{
|
||||||
char buf[4];
|
char buf[4];
|
||||||
|
|
||||||
|
// it has to be hex digits
|
||||||
|
if (!isxdigit(p[0]) || !isxdigit(p[1]))
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: unexpected content '%s'\n", __func__, p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
buf[0] = p[0];
|
buf[0] = p[0];
|
||||||
buf[1] = p[1];
|
buf[1] = p[1];
|
||||||
buf[2] = '\0';
|
buf[2] = '\0';
|
||||||
|
|
||||||
return (int)strtol(buf, NULL, 16);
|
return (unsigned)strtol(buf, NULL, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get system state [E] from rig into \a statebuf
|
* Get system state [E] from rig into \a statebuf
|
||||||
*/
|
*/
|
||||||
static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf)
|
static int prm80_do_read_system_state(hamlib_port_t *rigport, char *statebuf)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -588,7 +617,7 @@ static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The response length is fixed
|
// The response length is fixed
|
||||||
ret = read_block(rigport, statebuf, 20);
|
ret = read_block(rigport, statebuf, CMD_E_RSP_LEN);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
@ -600,10 +629,10 @@ static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf)
|
||||||
statebuf[ret] = '\0';
|
statebuf[ret] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 20)
|
if (ret < CMD_E_RSP_LEN)
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: len=%d < 20, statebuf='%s'\n", __func__,
|
rig_debug(RIG_DEBUG_ERR, "%s: len=%d < %d, statebuf='%s'\n", __func__,
|
||||||
ret, statebuf);
|
ret, CMD_E_RSP_LEN, statebuf);
|
||||||
RETURNFUNC(-RIG_EPROTO);
|
RETURNFUNC(-RIG_EPROTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,8 +641,9 @@ static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf)
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
int left_to_read = (p - statebuf) + 1;
|
int left_to_read = (p - statebuf) + 1;
|
||||||
memmove(statebuf, p + 1, 20 - left_to_read);
|
memmove(statebuf, p + 1, CMD_E_RSP_LEN - left_to_read);
|
||||||
ret = read_block(rigport, statebuf + 20 - left_to_read, left_to_read);
|
ret = read_block(rigport, statebuf + CMD_E_RSP_LEN - left_to_read,
|
||||||
|
left_to_read);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
@ -621,16 +651,45 @@ static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
statebuf[20] = '\0';
|
statebuf[CMD_E_RSP_LEN] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: len=%d, statebuf='%s'\n", __func__, ret,
|
rig_debug(RIG_DEBUG_WARN, "%s: len=%d, statebuf='%s'\n", __func__, ret,
|
||||||
statebuf);
|
statebuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prm80_wait_for_prompt(rigport);
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Layer to handle the cache to Get system state [E]
|
||||||
|
*/
|
||||||
|
static int prm80_read_system_state(RIG *rig, char *statebuf)
|
||||||
|
{
|
||||||
|
struct prm80_priv_data *priv = (struct prm80_priv_data *)rig->state.priv;
|
||||||
|
int ret = RIG_OK;
|
||||||
|
|
||||||
|
if (rig_check_cache_timeout(&priv->status_tv, PRM80_CACHE_TIMEOUT))
|
||||||
|
{
|
||||||
|
ret = prm80_do_read_system_state(&rig->state.rigport, statebuf);
|
||||||
|
|
||||||
|
if (ret == RIG_OK)
|
||||||
|
{
|
||||||
|
strcpy(priv->cached_statebuf, statebuf);
|
||||||
|
|
||||||
|
/* update cache date */
|
||||||
|
gettimeofday(&priv->status_tv, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy(statebuf, priv->cached_statebuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* prm80_get_channel
|
* prm80_get_channel
|
||||||
|
@ -639,7 +698,6 @@ static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf)
|
||||||
int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
|
int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
|
||||||
{
|
{
|
||||||
struct prm80_priv_data *priv = (struct prm80_priv_data *)rig->state.priv;
|
struct prm80_priv_data *priv = (struct prm80_priv_data *)rig->state.priv;
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
char statebuf[BUFSZ];
|
char statebuf[BUFSZ];
|
||||||
int ret, chanstate, mode_byte, lock_byte;
|
int ret, chanstate, mode_byte, lock_byte;
|
||||||
|
|
||||||
|
@ -653,15 +711,15 @@ int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = prm80_read_system_state(&rs->rigport, statebuf);
|
ret = prm80_read_system_state(rig, statebuf);
|
||||||
|
|
||||||
if (ret != RIG_OK)
|
if (ret != RIG_OK)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq). */
|
/* (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq-RSSI). */
|
||||||
/* Examples: 1240080AFF0033F02D40 or 14000C00FD0079708020 */
|
/* Examples: 1240080AFF0033F02D40__ or 14000C00FD0079708020__ */
|
||||||
|
|
||||||
/* Current mode:
|
/* Current mode:
|
||||||
; b0: Squelch b1: power
|
; b0: Squelch b1: power
|
||||||
|
@ -688,11 +746,15 @@ int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
|
||||||
(chanstate & 0x04) ? RIG_RPT_SHIFT_PLUS : RIG_RPT_SHIFT_NONE;
|
(chanstate & 0x04) ? RIG_RPT_SHIFT_PLUS : RIG_RPT_SHIFT_NONE;
|
||||||
chan->flags = (chanstate & 0x08) ? RIG_CHFLAG_SKIP : 0;
|
chan->flags = (chanstate & 0x08) ? RIG_CHFLAG_SKIP : 0;
|
||||||
|
|
||||||
// cppcheck-suppress *
|
// squelch is in low nibble
|
||||||
chan->levels[LVL_SQL].f = ((float)(hhtoi(statebuf + 6) >> 4)) / 15.;
|
chan->levels[LVL_SQL].f = ((float)(hhtoi(statebuf + 6) & 0x0F)) / 15.;
|
||||||
chan->levels[LVL_AF].f = ((float)(hhtoi(statebuf + 8) >> 4)) / 15.;
|
// volume is hex "00" .. "10"
|
||||||
|
chan->levels[LVL_AF].f = ((float)hhtoi(statebuf + 8)) / 16.;
|
||||||
chan->levels[LVL_RFPOWER].f = (mode_byte & 0x02) ? 1.0 : 0.0;
|
chan->levels[LVL_RFPOWER].f = (mode_byte & 0x02) ? 1.0 : 0.0;
|
||||||
|
|
||||||
|
// new in FW V5
|
||||||
|
chan->levels[LVL_RAWSTR].i = hhtoi(statebuf + 20);
|
||||||
|
|
||||||
chan->funcs = 0;
|
chan->funcs = 0;
|
||||||
chan->funcs |= (chanstate & 0x02) ? RIG_FUNC_REV : 0;
|
chan->funcs |= (chanstate & 0x02) ? RIG_FUNC_REV : 0;
|
||||||
|
|
||||||
|
@ -725,8 +787,6 @@ int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
|
||||||
//return -RIG_ENIMPL;
|
//return -RIG_ENIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
prm80_wait_for_prompt(&rs->rigport);
|
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -895,6 +955,8 @@ int prm80_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prm80_force_cache_timeout(rig);
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,6 +982,8 @@ int prm80_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
||||||
ret = -RIG_EINVAL;
|
ret = -RIG_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prm80_force_cache_timeout(rig);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,7 +1029,8 @@ int prm80_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
switch (level)
|
switch (level)
|
||||||
{
|
{
|
||||||
case RIG_LEVEL_AF:
|
case RIG_LEVEL_AF:
|
||||||
sprintf(buf, "%02u", (unsigned)(val.f * 15));
|
// Unlike system state, volume decimal
|
||||||
|
sprintf(buf, "%02u", (unsigned)(val.f * 16));
|
||||||
|
|
||||||
return prm80_transaction(rig, "O", buf, 1);
|
return prm80_transaction(rig, "O", buf, 1);
|
||||||
|
|
||||||
|
@ -982,15 +1047,13 @@ int prm80_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
; b6: Debouncing in effect b7: LCD refresh
|
; b6: Debouncing in effect b7: LCD refresh
|
||||||
*/
|
*/
|
||||||
// Perform a "Read-Modify-Write" of the mode_byte
|
// Perform a "Read-Modify-Write" of the mode_byte
|
||||||
ret = prm80_read_system_state(&rig->state.rigport, buf);
|
ret = prm80_read_system_state(rig, buf);
|
||||||
|
|
||||||
if (ret != RIG_OK)
|
if (ret != RIG_OK)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
prm80_wait_for_prompt(&rig->state.rigport);
|
|
||||||
|
|
||||||
mode_byte = hhtoi(buf);
|
mode_byte = hhtoi(buf);
|
||||||
mode_byte &= ~0x02;
|
mode_byte &= ~0x02;
|
||||||
mode_byte |= (val.f == 0.) ? 0 : 0x02;
|
mode_byte |= (val.f == 0.) ? 0 : 0x02;
|
||||||
|
@ -1004,6 +1067,8 @@ int prm80_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prm80_force_cache_timeout(rig);
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1069,48 +1134,6 @@ static int prm80_get_rawstr_RAM(RIG *rig, value_t *val)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* get_level RIG_LEVEL_RAWSTR
|
|
||||||
*
|
|
||||||
* NB : requires a V5 firmware!
|
|
||||||
*/
|
|
||||||
static int prm80_get_rawstr(RIG *rig, value_t *val)
|
|
||||||
{
|
|
||||||
char buf[BUFSZ];
|
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
// Get rid of possible prompt sent by the rig
|
|
||||||
rig_flush(&rs->rigport);
|
|
||||||
|
|
||||||
/* [A] = RSSI */
|
|
||||||
ret = write_block(&rs->rigport, "A", 1);
|
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
RETURNFUNC(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The response length is fixed
|
|
||||||
ret = read_block(&rs->rigport, buf, 4);
|
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret >= 0)
|
|
||||||
{
|
|
||||||
buf[ret] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
val->i = hhtoi(buf);
|
|
||||||
|
|
||||||
prm80_wait_for_prompt(&rs->rigport);
|
|
||||||
|
|
||||||
return RIG_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* prm80_get_level
|
* prm80_get_level
|
||||||
* Assumes rig!=NULL
|
* Assumes rig!=NULL
|
||||||
|
@ -1120,12 +1143,6 @@ int prm80_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||||
int ret;
|
int ret;
|
||||||
channel_t chan;
|
channel_t chan;
|
||||||
|
|
||||||
// Get rawstr apart, it is not read from system state
|
|
||||||
if (level == RIG_LEVEL_RAWSTR)
|
|
||||||
{
|
|
||||||
return prm80_get_rawstr(rig, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&chan, 0, sizeof(chan));
|
memset(&chan, 0, sizeof(chan));
|
||||||
chan.vfo = RIG_VFO_CURR;
|
chan.vfo = RIG_VFO_CURR;
|
||||||
|
|
||||||
|
@ -1138,6 +1155,11 @@ int prm80_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||||
|
|
||||||
switch (level)
|
switch (level)
|
||||||
{
|
{
|
||||||
|
case RIG_LEVEL_RAWSTR:
|
||||||
|
val->i = chan.levels[LVL_RAWSTR].i;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case RIG_LEVEL_AF:
|
case RIG_LEVEL_AF:
|
||||||
val->f = chan.levels[LVL_AF].f;
|
val->f = chan.levels[LVL_AF].f;
|
||||||
|
|
||||||
|
@ -1167,8 +1189,7 @@ int prm80_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
||||||
char statebuf[BUFSZ];
|
char statebuf[BUFSZ];
|
||||||
int ret, mode_byte;
|
int ret, mode_byte;
|
||||||
|
|
||||||
// TODO use command 'A' which is faster, but not in V4
|
ret = prm80_read_system_state(rig, statebuf);
|
||||||
ret = prm80_read_system_state(&rig->state.rigport, statebuf);
|
|
||||||
|
|
||||||
if (ret != RIG_OK)
|
if (ret != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1180,8 +1201,6 @@ int prm80_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
||||||
// TX mode on?
|
// TX mode on?
|
||||||
*ptt = (mode_byte & 0x08) ? RIG_PTT_ON : RIG_PTT_OFF;
|
*ptt = (mode_byte & 0x08) ? RIG_PTT_ON : RIG_PTT_OFF;
|
||||||
|
|
||||||
prm80_wait_for_prompt(&rig->state.rigport);
|
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1190,8 +1209,7 @@ int prm80_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
|
||||||
char statebuf[BUFSZ];
|
char statebuf[BUFSZ];
|
||||||
int ret, mode_byte;
|
int ret, mode_byte;
|
||||||
|
|
||||||
// TODO use command 'A' which is faster, but not in V4
|
ret = prm80_read_system_state(rig, statebuf);
|
||||||
ret = prm80_read_system_state(&rig->state.rigport, statebuf);
|
|
||||||
|
|
||||||
if (ret != RIG_OK)
|
if (ret != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1203,8 +1221,6 @@ int prm80_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
|
||||||
// Squelch open?
|
// Squelch open?
|
||||||
*dcd = (mode_byte & 0x04) ? RIG_DCD_ON : RIG_DCD_OFF;
|
*dcd = (mode_byte & 0x04) ? RIG_DCD_ON : RIG_DCD_OFF;
|
||||||
|
|
||||||
prm80_wait_for_prompt(&rig->state.rigport);
|
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include <hamlib/rig.h>
|
#include <hamlib/rig.h>
|
||||||
|
|
||||||
#define BACKEND_VER "20210306"
|
#define BACKEND_VER "20210315"
|
||||||
|
|
||||||
#define PRM80_MEM_CAP { \
|
#define PRM80_MEM_CAP { \
|
||||||
.freq = 1, \
|
.freq = 1, \
|
||||||
|
@ -37,6 +37,8 @@ struct prm80_priv_data
|
||||||
freq_t rx_freq; /* last RX freq set */
|
freq_t rx_freq; /* last RX freq set */
|
||||||
freq_t tx_freq; /* last TX freq set */
|
freq_t tx_freq; /* last TX freq set */
|
||||||
split_t split; /* emulated split on/off */
|
split_t split; /* emulated split on/off */
|
||||||
|
struct timeval status_tv; /* date of last "E" command */
|
||||||
|
char cached_statebuf[32]; /* response of last "E" command */
|
||||||
};
|
};
|
||||||
|
|
||||||
int prm80_init(RIG *rig);
|
int prm80_init(RIG *rig);
|
||||||
|
|
|
@ -51,7 +51,6 @@ class Prm80Simul:
|
||||||
'C' : self.tch_Chanlist,
|
'C' : self.tch_Chanlist,
|
||||||
'R' : self.tch_Rfreq,
|
'R' : self.tch_Rfreq,
|
||||||
'E' : self.tch_Estate,
|
'E' : self.tch_Estate,
|
||||||
'A' : self.tch_Astatus,
|
|
||||||
'#' : self.tch_diese,
|
'#' : self.tch_diese,
|
||||||
'*' : self.tch_autre,
|
'*' : self.tch_autre,
|
||||||
}
|
}
|
||||||
|
@ -59,7 +58,7 @@ class Prm80Simul:
|
||||||
self.ChanNum = 0
|
self.ChanNum = 0
|
||||||
self.LockByte = 0
|
self.LockByte = 0
|
||||||
self.Squelch = 0
|
self.Squelch = 0
|
||||||
self.Volume = 0xff
|
self.Volume = 0x10
|
||||||
self.ModeByte = 0x16
|
self.ModeByte = 0x16
|
||||||
self.ChanState = 0x0c
|
self.ChanState = 0x0c
|
||||||
self.MaxChan = 80
|
self.MaxChan = 80
|
||||||
|
@ -172,23 +171,21 @@ class Prm80Simul:
|
||||||
self.pty_write(b'\r\n')
|
self.pty_write(b'\r\n')
|
||||||
|
|
||||||
def tch_Estate(self):
|
def tch_Estate(self):
|
||||||
""" Show system state (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq) """
|
""" Show system state (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq-RSSI) (FW V5)"""
|
||||||
#self.pty_write(b'16000C00FF0079708020')
|
#self.pty_write(b'16000C0010007970802018')
|
||||||
self.pty_write('{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}{:04X}{:04X}'.format(
|
rssi=24
|
||||||
|
self.pty_write('{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}{:04X}{:04X}{:02X}'.format(
|
||||||
self.ModeByte,
|
self.ModeByte,
|
||||||
self.ChanNum,
|
self.ChanNum,
|
||||||
self.ChanState,
|
self.ChanState,
|
||||||
self.Squelch,
|
self.Squelch, # low nibble
|
||||||
self.Volume,
|
self.Volume,
|
||||||
self.LockByte,
|
self.LockByte,
|
||||||
self.RxPLL,
|
self.RxPLL,
|
||||||
self.TxPLL
|
self.TxPLL,
|
||||||
|
rssi
|
||||||
).encode())
|
).encode())
|
||||||
|
|
||||||
def tch_Astatus(self):
|
|
||||||
""" Print value of RSSI, squelch and transmit status. V5. """
|
|
||||||
self.pty_write(b'1801')
|
|
||||||
|
|
||||||
def tch_Chanlist(self):
|
def tch_Chanlist(self):
|
||||||
""" Print channels list """
|
""" Print channels list """
|
||||||
self.pty_write(b'Channels list :\r\n00 : 8464 84\r\n01 : 81B0 00\r\n02 : 8464 0C')
|
self.pty_write(b'Channels list :\r\n00 : 8464 84\r\n01 : 81B0 00\r\n02 : 8464 0C')
|
||||||
|
|
Ładowanie…
Reference in New Issue