kopia lustrzana https://github.com/Hamlib/Hamlib
Porównaj commity
20 Commity
190747430f
...
761f1d3b00
Autor | SHA1 | Data |
---|---|---|
Mike Black W9MDB | 761f1d3b00 | |
Mike Black W9MDB | 48d3f3f750 | |
Mike Black W9MDB | aec9348138 | |
Mike Black W9MDB | df64af4583 | |
Mike Black W9MDB | 0e5d2cfc48 | |
Mike Black W9MDB | 4d568c782e | |
Mike Black W9MDB | d6689145a0 | |
Michael Black | 34ccdcc5a5 | |
George Baltz N3GB | f15679f575 | |
George Baltz N3GB | 7f67363687 | |
George Baltz N3GB | 64f69421de | |
George Baltz N3GB | aa9c3b39ba | |
George Baltz N3GB | fddddf1f6f | |
George Baltz N3GB | 2c85a96309 | |
George Baltz N3GB | b0d1eb297f | |
George Baltz N3GB | cd1f4d3929 | |
George Baltz N3GB | e178a984ca | |
Mike Black W9MDB | 0b67958751 | |
Mike Black W9MDB | 4b03abbdac | |
Mike Black W9MDB | 11b5da8782 |
1
NEWS
1
NEWS
|
@ -13,6 +13,7 @@ Version 5.x -- future
|
|||
* Change FT1000MP Mark V model names to align with FT1000MP
|
||||
|
||||
Version 4.6
|
||||
* Added RIG_FUNC_SYNC for FTDX101D/MP
|
||||
* Added Barrett 4100
|
||||
* Added DL2MAN (tr)uSDX -- needs refinement
|
||||
* Added Thetis entry -- derived from FlexRadio/Apache PowerSDR
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#ifndef _AMPLIFIER_H
|
||||
#define _AMPLIFIER_H 1
|
||||
|
@ -445,6 +446,8 @@ rig_ext_lookup HAMLIB_PARAMS((RIG *rig,
|
|||
extern HAMLIB_EXPORT(setting_t) amp_parse_level(const char *s);
|
||||
extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
|
||||
|
||||
extern HAMLIB_EXPORT(void *) amp_data_pointer(AMP *amp, rig_ptrx_t idx);
|
||||
|
||||
//! @endcond
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#ifndef _RIG_H
|
||||
#define _RIG_H 1
|
||||
|
@ -1273,7 +1273,7 @@ typedef uint64_t setting_t;
|
|||
#define RIG_FUNC_SEND_MORSE CONSTANT_64BIT_FLAG (45) /*!< \c SEND_MORSE -- Send specified characters using CW */
|
||||
#define RIG_FUNC_SEND_VOICE_MEM CONSTANT_64BIT_FLAG (46) /*!< \c SEND_VOICE_MEM -- Transmit in SSB message stored in memory */
|
||||
#define RIG_FUNC_OVF_STATUS CONSTANT_64BIT_FLAG (47) /*!< \c OVF -- Read overflow status 0=Off, 1=On */
|
||||
#define RIG_FUNC_BIT48 CONSTANT_64BIT_FLAG (48) /*!< \c available for future RIG_FUNC items */
|
||||
#define RIG_FUNC_SYNC CONSTANT_64BIT_FLAG (48) /*!< \c Synchronize VFOS -- FTDX101D/MP for now SY command */
|
||||
#define RIG_FUNC_BIT49 CONSTANT_64BIT_FLAG (49) /*!< \c available for future RIG_FUNC items */
|
||||
#define RIG_FUNC_BIT50 CONSTANT_64BIT_FLAG (50) /*!< \c available for future RIG_FUNC items */
|
||||
#define RIG_FUNC_BIT51 CONSTANT_64BIT_FLAG (51) /*!< \c available for future RIG_FUNC items */
|
||||
|
@ -2463,10 +2463,14 @@ typedef hamlib_port_t_deprecated port_t_deprecated;
|
|||
typedef hamlib_port_t port_t;
|
||||
#endif
|
||||
|
||||
/* Macros to access port structures/pointers
|
||||
/* Macros to access data structures/pointers
|
||||
* Make it easier to change location in preparation
|
||||
* for moving them out of rig->state.
|
||||
* See https://github.com/Hamlib/Hamlib/issues/1445
|
||||
* https://github.com/Hamlib/Hamlib/issues/1452
|
||||
* https://github.com/Hamlib/Hamlib/issues/1420
|
||||
* https://github.com/Hamlib/Hamlib/issues/536
|
||||
* https://github.com/Hamlib/Hamlib/issues/487
|
||||
*/
|
||||
// Note: Experimental, and subject to change!!
|
||||
#if defined(IN_HAMLIB)
|
||||
|
@ -2474,18 +2478,38 @@ typedef hamlib_port_t port_t;
|
|||
#define RIGPORT(r) (&r->state.rigport)
|
||||
#define PTTPORT(r) (&r->state.pttport)
|
||||
#define DCDPORT(r) (&r->state.dcdport)
|
||||
#else
|
||||
/* Define external unique names */
|
||||
/* These will be changed to a function call before release */
|
||||
#define HAMLIB_RIGPORT(r) (&r->state.rigport)
|
||||
#define HAMLIB_PTTPORT(r) (&r->state.pttport)
|
||||
#define HAMLIB_DCDPORT(r) (&r->state.dcdport)
|
||||
#endif
|
||||
#define CACHE(r) (&r->state.cache)
|
||||
#define AMPPORT(a) (&a->state.ampport)
|
||||
#define ROTPORT(r) (&r->state.rotport)
|
||||
#define ROTPORT2(r) (&r->state.rotport2)
|
||||
/* Then when the rigport address is stored as a pointer somewhere else(say,
|
||||
* in the rig structure itself), the definition could be changed to
|
||||
* #define RIGPORT(r) r->somewhereelse
|
||||
* and every reference is updated.
|
||||
*/
|
||||
#else
|
||||
/* Define external unique names */
|
||||
#define HAMLIB_RIGPORT(r) ((hamlib_port_t *)rig_data_pointer(r, RIG_PTRX_RIGPORT))
|
||||
#define HAMLIB_PTTPORT(r) ((hamlib_port_t *)rig_data_pointer(r, RIG_PTRX_PTTPORT))
|
||||
#define HAMLIB_DCDPORT(r) ((hamlib_port_t *)rig_data_pointer(r, RIG_PTRX_DCDPORT))
|
||||
#define HAMLIB_CACHE(r) ((struct rig_cache *)rig_data_pointer(r, RIG_PTRX_CACHE))
|
||||
#define HAMLIB_AMPPORT(a) ((hamlib_port_t *)amp_data_pointer(a, RIG_PTRX_AMPPORT))
|
||||
#define HAMLIB_ROTPORT(r) ((hamlib_port_t *)rot_data_pointer(r, RIG_PTRX_ROTPORT))
|
||||
#define HAMLIB_ROTPORT2(r) ((hamlib_port_t *)rot_data_pointer(r, RIG_PTRX_ROTPORT2))
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
RIG_PTRX_NONE=0,
|
||||
RIG_PTRX_RIGPORT,
|
||||
RIG_PTRX_PTTPORT,
|
||||
RIG_PTRX_DCDPORT,
|
||||
RIG_PTRX_CACHE,
|
||||
RIG_PTRX_AMPPORT,
|
||||
RIG_PTRX_ROTPORT,
|
||||
RIG_PTRX_ROTPORT2,
|
||||
// New entries go directly above this line====================
|
||||
RIG_PTRX_MAXIMUM
|
||||
} rig_ptrx_t;
|
||||
|
||||
#define HAMLIB_ELAPSED_GET 0
|
||||
#define HAMLIB_ELAPSED_SET 1
|
||||
|
@ -3822,7 +3846,9 @@ extern HAMLIB_EXPORT(char*) rig_date_strget(char *buf, int buflen, int localtime
|
|||
enum GPIO { GPIO1, GPIO2, GPIO3, GPIO4 };
|
||||
extern HAMLIB_EXPORT(int) rig_cm108_get_bit(hamlib_port_t *p, enum GPIO gpio, int *bit);
|
||||
extern HAMLIB_EXPORT(int) rig_cm108_set_bit(hamlib_port_t *p, enum GPIO gpio, int bit);
|
||||
extern HAMLIB_EXPORT(int) rig_band_changed(RIG *rig, hamlib_bandselect_t band);
|
||||
|
||||
extern HAMLIB_EXPORT(void *) rig_data_pointer(RIG *rig, rig_ptrx_t idx);
|
||||
|
||||
//! @endcond
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#ifndef _ROTATOR_H
|
||||
#define _ROTATOR_H 1
|
||||
|
@ -797,6 +798,8 @@ extern HAMLIB_EXPORT(const char *) rot_strlevel(setting_t);
|
|||
extern HAMLIB_EXPORT(const char *) rot_strparm(setting_t);
|
||||
extern HAMLIB_EXPORT(const char *) rot_strstatus(rot_status_t);
|
||||
|
||||
extern HAMLIB_EXPORT(void *) rot_data_pointer(ROT *rot, rig_ptrx_t idx);
|
||||
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
|
|
|
@ -257,6 +257,14 @@ int ic7700_get_clock(RIG *rig, int *year, int *month, int *day, int *hour,
|
|||
return retval;
|
||||
}
|
||||
|
||||
static int ic7700_rig_open(RIG *rig)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: enter\n", __func__);
|
||||
struct icom_priv_data *priv = (struct icom_priv_data *) rig->state.priv;
|
||||
priv->x26cmdfails = priv->x25cmdfails = 1;
|
||||
return icom_rig_open(rig);
|
||||
}
|
||||
|
||||
struct rig_caps ic7700_caps =
|
||||
{
|
||||
RIG_MODEL(RIG_MODEL_IC7700),
|
||||
|
@ -394,7 +402,7 @@ struct rig_caps ic7700_caps =
|
|||
.priv = (void *)& ic7700_priv_caps,
|
||||
.rig_init = icom_init,
|
||||
.rig_cleanup = icom_cleanup,
|
||||
.rig_open = icom_rig_open,
|
||||
.rig_open = ic7700_rig_open,
|
||||
.rig_close = icom_rig_close,
|
||||
|
||||
.set_freq = icom_set_freq,
|
||||
|
|
|
@ -1576,9 +1576,9 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
|
|||
tsplit = RIG_SPLIT_OFF; // default in case rig does not set split status
|
||||
retval = rig_get_split_vfo(rig, vfo, &tsplit, &tx_vfo);
|
||||
|
||||
priv->split = rig->state.cache.split = split;
|
||||
rig->state.cache.split_vfo = txvfo;
|
||||
elapsed_ms(&rig->state.cache.time_split, HAMLIB_ELAPSED_SET);
|
||||
priv->split = CACHE(rig)->split = split;
|
||||
CACHE(rig)->split_vfo = txvfo;
|
||||
elapsed_ms(&CACHE(rig)->time_split, HAMLIB_ELAPSED_SET);
|
||||
|
||||
// and it should be OK to do a SPLIT_OFF at any time so we won's skip that
|
||||
if (retval == RIG_OK && split == RIG_SPLIT_ON && tsplit == RIG_SPLIT_ON)
|
||||
|
@ -1598,7 +1598,7 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
|
|||
|| rig->caps->rig_model == RIG_MODEL_KX2
|
||||
|| rig->caps->rig_model == RIG_MODEL_KX3)
|
||||
{
|
||||
rig_set_freq(rig, RIG_VFO_B, rig->state.cache.freqMainA);
|
||||
rig_set_freq(rig, RIG_VFO_B, CACHE(rig)->freqMainA);
|
||||
}
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -1607,8 +1607,8 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
|
|||
}
|
||||
|
||||
/* Remember whether split is on, for kenwood_set_vfo */
|
||||
priv->split = rig->state.cache.split = split;
|
||||
elapsed_ms(&rig->state.cache.time_split, HAMLIB_ELAPSED_SET);
|
||||
priv->split = CACHE(rig)->split = split;
|
||||
elapsed_ms(&CACHE(rig)->time_split, HAMLIB_ELAPSED_SET);
|
||||
|
||||
RETURNFUNC2(RIG_OK);
|
||||
}
|
||||
|
@ -2964,7 +2964,7 @@ static int kenwood_get_power_minmax(RIG *rig, int *power_now, int *power_min,
|
|||
}
|
||||
|
||||
// Don't do this if PTT is on...don't want to max out power!!
|
||||
if (rs->cache.ptt == RIG_PTT_ON)
|
||||
if (CACHE(rig)->ptt == RIG_PTT_ON)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: ptt on so not checking min/max power levels\n",
|
||||
__func__);
|
||||
|
|
|
@ -252,7 +252,7 @@ const struct confparams tmd710_ext_levels[] =
|
|||
|
||||
struct rig_caps tmd710_caps =
|
||||
{
|
||||
.rig_model = RIG_MODEL_TMD710,
|
||||
RIG_MODEL(RIG_MODEL_TMD710),
|
||||
.model_name = "TM-D710(G)",
|
||||
.mfg_name = "Kenwood",
|
||||
.version = BACKEND_VER ".6",
|
||||
|
|
|
@ -65,7 +65,8 @@
|
|||
#define FTDX101_FUNCS (RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_LOCK|\
|
||||
RIG_FUNC_MON|RIG_FUNC_NB|RIG_FUNC_NR|RIG_FUNC_VOX|\
|
||||
RIG_FUNC_FBKIN|RIG_FUNC_COMP|RIG_FUNC_ANF|RIG_FUNC_MN|\
|
||||
RIG_FUNC_RIT|RIG_FUNC_XIT|RIG_FUNC_TUNER|RIG_FUNC_APF)
|
||||
RIG_FUNC_RIT|RIG_FUNC_XIT|RIG_FUNC_TUNER|RIG_FUNC_APF|\
|
||||
RIG_FUNC_SYNC)
|
||||
|
||||
/* TBC */
|
||||
#define FTDX101_VFO_OPS (RIG_OP_TUNE|RIG_OP_CPY|RIG_OP_XCHG|\
|
||||
|
|
|
@ -6401,6 +6401,16 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
|
||||
break;
|
||||
|
||||
case RIG_FUNC_SYNC:
|
||||
if (!newcat_valid_command(rig, "SY"))
|
||||
{
|
||||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "SY%d%c", status ? 1 : 0,
|
||||
cat_term);
|
||||
break;
|
||||
|
||||
default:
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
@ -6694,6 +6704,15 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
|||
|
||||
break;
|
||||
|
||||
case RIG_FUNC_SYNC:
|
||||
if (!newcat_valid_command(rig, "SY"))
|
||||
{
|
||||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "SY%c", cat_term);
|
||||
break;
|
||||
|
||||
default:
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
@ -6808,6 +6827,10 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
|||
|
||||
break;
|
||||
|
||||
case RIG_FUNC_SYNC:
|
||||
*status = (retfunc[0] == '1') ? 1 : 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
typedef char ncboolean;
|
||||
|
||||
/* shared function version */
|
||||
#define NEWCAT_VER "20240113"
|
||||
#define NEWCAT_VER "20240118"
|
||||
|
||||
/* Hopefully large enough for future use, 128 chars plus '\0' */
|
||||
#define NEWCAT_DATA_LEN 129
|
||||
|
|
112
src/amplifier.c
112
src/amplifier.c
|
@ -20,6 +20,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
/**
|
||||
* \addtogroup amplifier
|
||||
|
@ -185,6 +186,7 @@ AMP *HAMLIB_API amp_init(amp_model_t amp_model)
|
|||
AMP *amp;
|
||||
const struct amp_caps *caps;
|
||||
struct amp_state *rs;
|
||||
hamlib_port_t *ap;
|
||||
|
||||
amp_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
|
@ -224,37 +226,41 @@ AMP *HAMLIB_API amp_init(amp_model_t amp_model)
|
|||
*/
|
||||
rs = &->state;
|
||||
|
||||
rs->comm_state = 0;
|
||||
rs->ampport.type.rig = caps->port_type; /* default from caps */
|
||||
//TODO allocate and link new ampport
|
||||
// For now, use the embedded one
|
||||
ap = AMPPORT(amp);
|
||||
|
||||
rs->ampport.write_delay = caps->write_delay;
|
||||
rs->ampport.post_write_delay = caps->post_write_delay;
|
||||
rs->ampport.timeout = caps->timeout;
|
||||
rs->ampport.retry = caps->retry;
|
||||
rs->comm_state = 0;
|
||||
ap->type.rig = caps->port_type; /* default from caps */
|
||||
|
||||
ap->write_delay = caps->write_delay;
|
||||
ap->post_write_delay = caps->post_write_delay;
|
||||
ap->timeout = caps->timeout;
|
||||
ap->retry = caps->retry;
|
||||
rs->has_get_level = caps->has_get_level;
|
||||
|
||||
switch (caps->port_type)
|
||||
{
|
||||
case RIG_PORT_SERIAL:
|
||||
// Don't think we need a default port here
|
||||
//strncpy(rs->ampport.pathname, DEFAULT_SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
|
||||
rs->ampport.parm.serial.rate = caps->serial_rate_max; /* fastest ! */
|
||||
rs->ampport.parm.serial.data_bits = caps->serial_data_bits;
|
||||
rs->ampport.parm.serial.stop_bits = caps->serial_stop_bits;
|
||||
rs->ampport.parm.serial.parity = caps->serial_parity;
|
||||
rs->ampport.parm.serial.handshake = caps->serial_handshake;
|
||||
//strncpy(ap->pathname, DEFAULT_SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
|
||||
ap->parm.serial.rate = caps->serial_rate_max; /* fastest ! */
|
||||
ap->parm.serial.data_bits = caps->serial_data_bits;
|
||||
ap->parm.serial.stop_bits = caps->serial_stop_bits;
|
||||
ap->parm.serial.parity = caps->serial_parity;
|
||||
ap->parm.serial.handshake = caps->serial_handshake;
|
||||
break;
|
||||
|
||||
case RIG_PORT_NETWORK:
|
||||
case RIG_PORT_UDP_NETWORK:
|
||||
strncpy(rs->ampport.pathname, "127.0.0.1:4531", HAMLIB_FILPATHLEN - 1);
|
||||
strncpy(ap->pathname, "127.0.0.1:4531", HAMLIB_FILPATHLEN - 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
strncpy(rs->ampport.pathname, "", HAMLIB_FILPATHLEN - 1);
|
||||
strncpy(ap->pathname, "", HAMLIB_FILPATHLEN - 1);
|
||||
}
|
||||
|
||||
rs->ampport.fd = -1;
|
||||
ap->fd = -1;
|
||||
|
||||
/*
|
||||
* let the backend a chance to setup his private data
|
||||
|
@ -279,7 +285,7 @@ AMP *HAMLIB_API amp_init(amp_model_t amp_model)
|
|||
// Now we have to copy our new rig state hamlib_port structure to the deprecated one
|
||||
// Clients built on older 4.X versions will use the old structure
|
||||
// Clients built on newer 4.5 versions will use the new structure
|
||||
memcpy(&->state.ampport_deprecated, &->state.ampport,
|
||||
memcpy(&->state.ampport_deprecated, ap,
|
||||
sizeof(amp->state.ampport_deprecated));
|
||||
|
||||
return amp;
|
||||
|
@ -306,6 +312,7 @@ int HAMLIB_API amp_open(AMP *amp)
|
|||
{
|
||||
const struct amp_caps *caps;
|
||||
struct amp_state *rs;
|
||||
hamlib_port_t *ap = AMPPORT(amp);
|
||||
int status;
|
||||
int net1, net2, net3, net4, port;
|
||||
|
||||
|
@ -324,21 +331,21 @@ int HAMLIB_API amp_open(AMP *amp)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
rs->ampport.fd = -1;
|
||||
ap->fd = -1;
|
||||
|
||||
// determine if we have a network address
|
||||
if (sscanf(rs->ampport.pathname, "%d.%d.%d.%d:%d", &net1, &net2, &net3, &net4,
|
||||
if (sscanf(ap->pathname, "%d.%d.%d.%d:%d", &net1, &net2, &net3, &net4,
|
||||
&port) == 5)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: using network address %s\n", __func__,
|
||||
rs->ampport.pathname);
|
||||
rs->ampport.type.rig = RIG_PORT_NETWORK;
|
||||
ap->pathname);
|
||||
ap->type.rig = RIG_PORT_NETWORK;
|
||||
}
|
||||
|
||||
switch (rs->ampport.type.rig)
|
||||
switch (ap->type.rig)
|
||||
{
|
||||
case RIG_PORT_SERIAL:
|
||||
status = serial_open(&rs->ampport);
|
||||
status = serial_open(ap);
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
|
@ -348,7 +355,7 @@ int HAMLIB_API amp_open(AMP *amp)
|
|||
break;
|
||||
|
||||
case RIG_PORT_PARALLEL:
|
||||
status = par_open(&rs->ampport);
|
||||
status = par_open(ap);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
|
@ -358,18 +365,18 @@ int HAMLIB_API amp_open(AMP *amp)
|
|||
break;
|
||||
|
||||
case RIG_PORT_DEVICE:
|
||||
status = open(rs->ampport.pathname, O_RDWR, 0);
|
||||
status = open(ap->pathname, O_RDWR, 0);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
return -RIG_EIO;
|
||||
}
|
||||
|
||||
rs->ampport.fd = status;
|
||||
ap->fd = status;
|
||||
break;
|
||||
|
||||
case RIG_PORT_USB:
|
||||
status = usb_port_open(&rs->ampport);
|
||||
status = usb_port_open(ap);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
|
@ -385,7 +392,7 @@ int HAMLIB_API amp_open(AMP *amp)
|
|||
case RIG_PORT_NETWORK:
|
||||
case RIG_PORT_UDP_NETWORK:
|
||||
/* FIXME: default port */
|
||||
status = network_open(&rs->ampport, 4531);
|
||||
status = network_open(ap, 4531);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
|
@ -412,31 +419,31 @@ int HAMLIB_API amp_open(AMP *amp)
|
|||
|
||||
if (status != RIG_OK)
|
||||
{
|
||||
memcpy(&->state.ampport_deprecated, &->state.ampport,
|
||||
memcpy(&->state.ampport_deprecated, ap,
|
||||
sizeof(amp->state.ampport_deprecated));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
if (rs->ampport.parm.serial.dtr_state == RIG_SIGNAL_ON)
|
||||
if (ap->parm.serial.dtr_state == RIG_SIGNAL_ON)
|
||||
{
|
||||
ser_set_dtr(&rs->ampport, 1);
|
||||
ser_set_dtr(ap, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ser_set_dtr(&rs->ampport, 0);
|
||||
ser_set_dtr(ap, 0);
|
||||
}
|
||||
|
||||
if (rs->ampport.parm.serial.rts_state == RIG_SIGNAL_ON)
|
||||
if (ap->parm.serial.rts_state == RIG_SIGNAL_ON)
|
||||
{
|
||||
ser_set_rts(&rs->ampport, 1);
|
||||
ser_set_rts(ap, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ser_set_rts(&rs->ampport, 0);
|
||||
ser_set_rts(ap, 0);
|
||||
}
|
||||
|
||||
memcpy(&->state.ampport_deprecated, &->state.ampport,
|
||||
memcpy(&->state.ampport_deprecated, ap,
|
||||
sizeof(amp->state.ampport_deprecated));
|
||||
|
||||
return RIG_OK;
|
||||
|
@ -464,6 +471,7 @@ int HAMLIB_API amp_close(AMP *amp)
|
|||
{
|
||||
const struct amp_caps *caps;
|
||||
struct amp_state *rs;
|
||||
hamlib_port_t *ap = AMPPORT(amp);
|
||||
|
||||
amp_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
|
@ -499,32 +507,32 @@ int HAMLIB_API amp_close(AMP *amp)
|
|||
}
|
||||
|
||||
|
||||
if (rs->ampport.fd != -1)
|
||||
if (ap->fd != -1)
|
||||
{
|
||||
switch (rs->ampport.type.rig)
|
||||
switch (ap->type.rig)
|
||||
{
|
||||
case RIG_PORT_SERIAL:
|
||||
ser_close(&rs->ampport);
|
||||
ser_close(ap);
|
||||
break;
|
||||
|
||||
case RIG_PORT_PARALLEL:
|
||||
par_close(&rs->ampport);
|
||||
par_close(ap);
|
||||
break;
|
||||
|
||||
case RIG_PORT_USB:
|
||||
usb_port_close(&rs->ampport);
|
||||
usb_port_close(ap);
|
||||
break;
|
||||
|
||||
case RIG_PORT_NETWORK:
|
||||
case RIG_PORT_UDP_NETWORK:
|
||||
network_close(&rs->ampport);
|
||||
network_close(ap);
|
||||
break;
|
||||
|
||||
default:
|
||||
close(rs->ampport.fd);
|
||||
close(ap->fd);
|
||||
}
|
||||
|
||||
rs->ampport.fd = -1;
|
||||
ap->fd = -1;
|
||||
}
|
||||
|
||||
remove_opened_amp(amp);
|
||||
|
@ -949,5 +957,21 @@ int HAMLIB_API amp_get_powerstat(AMP *amp, powerstat_t *status)
|
|||
return amp->caps->get_powerstat(amp, status);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the address of amplifier data structure(s)
|
||||
*
|
||||
* \sa rig_data_pointer
|
||||
*
|
||||
*/
|
||||
void * HAMLIB_API amp_data_pointer(AMP *amp, rig_ptrx_t idx)
|
||||
{
|
||||
switch(idx)
|
||||
{
|
||||
case RIG_PTRX_AMPPORT:
|
||||
return AMPPORT(amp);
|
||||
default:
|
||||
amp_debug(RIG_DEBUG_ERR, "%s: Invalid data index=%d\n", __func__, idx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/*! @} */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Can customize during build
|
||||
// Eventually should improved this for external actions when
|
||||
// rigctld gets integrated as a service within Hamlib
|
||||
static int rig_band_changed(RIG *rig, hamlib_bandselect_t band)
|
||||
int HAMLIB_API rig_band_changed(RIG *rig, hamlib_bandselect_t band)
|
||||
{
|
||||
// See band_changed.c
|
||||
// Examples:
|
||||
|
|
173
src/conf.c
173
src/conf.c
|
@ -239,6 +239,9 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
{
|
||||
struct rig_caps *caps;
|
||||
struct rig_state *rs;
|
||||
hamlib_port_t *rp = RIGPORT(rig);
|
||||
hamlib_port_t *pttp = PTTPORT(rig);
|
||||
hamlib_port_t *dcdp = DCDPORT(rig);
|
||||
long val_i;
|
||||
|
||||
caps = rig->caps;
|
||||
|
@ -247,7 +250,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
switch (token)
|
||||
{
|
||||
case TOK_PATHNAME:
|
||||
strncpy(rs->rigport.pathname, val, HAMLIB_FILPATHLEN - 1);
|
||||
strncpy(rp->pathname, val, HAMLIB_FILPATHLEN - 1);
|
||||
strncpy(rs->rigport_deprecated.pathname, val, HAMLIB_FILPATHLEN - 1);
|
||||
break;
|
||||
|
||||
|
@ -257,7 +260,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
return -RIG_EINVAL;//value format error
|
||||
}
|
||||
|
||||
rs->rigport.write_delay = val_i;
|
||||
rp->write_delay = val_i;
|
||||
rs->rigport_deprecated.write_delay = val_i;
|
||||
break;
|
||||
|
||||
|
@ -267,7 +270,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
return -RIG_EINVAL;//value format error
|
||||
}
|
||||
|
||||
rs->rigport.post_write_delay = val_i;
|
||||
rp->post_write_delay = val_i;
|
||||
rs->rigport_deprecated.post_write_delay = val_i;
|
||||
break;
|
||||
|
||||
|
@ -286,7 +289,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
return -RIG_EINVAL;//value format error
|
||||
}
|
||||
|
||||
rs->rigport.timeout = val_i;
|
||||
rp->timeout = val_i;
|
||||
rs->rigport_deprecated.timeout = val_i;
|
||||
break;
|
||||
|
||||
|
@ -296,12 +299,12 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
return -RIG_EINVAL;//value format error
|
||||
}
|
||||
|
||||
rs->rigport.retry = val_i;
|
||||
rp->retry = val_i;
|
||||
rs->rigport_deprecated.retry = val_i;
|
||||
break;
|
||||
|
||||
case TOK_SERIAL_SPEED:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
@ -311,12 +314,12 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
return -RIG_EINVAL;//value format error
|
||||
}
|
||||
|
||||
rs->rigport.parm.serial.rate = val_i;
|
||||
rp->parm.serial.rate = val_i;
|
||||
rs->rigport_deprecated.parm.serial.rate = val_i;
|
||||
break;
|
||||
|
||||
case TOK_DATA_BITS:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
@ -326,12 +329,12 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
return -RIG_EINVAL;//value format error
|
||||
}
|
||||
|
||||
rs->rigport.parm.serial.data_bits = val_i;
|
||||
rp->parm.serial.data_bits = val_i;
|
||||
rs->rigport_deprecated.parm.serial.data_bits = val_i;
|
||||
break;
|
||||
|
||||
case TOK_STOP_BITS:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
@ -341,39 +344,39 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
return -RIG_EINVAL;//value format error
|
||||
}
|
||||
|
||||
rs->rigport.parm.serial.stop_bits = val_i;
|
||||
rp->parm.serial.stop_bits = val_i;
|
||||
rs->rigport_deprecated.parm.serial.stop_bits = val_i;
|
||||
break;
|
||||
|
||||
case TOK_PARITY:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
if (!strcmp(val, "None"))
|
||||
{
|
||||
rs->rigport.parm.serial.parity = RIG_PARITY_NONE;
|
||||
rp->parm.serial.parity = RIG_PARITY_NONE;
|
||||
rs->rigport_deprecated.parm.serial.parity = RIG_PARITY_SPACE;
|
||||
}
|
||||
else if (!strcmp(val, "Odd"))
|
||||
{
|
||||
rs->rigport.parm.serial.parity = RIG_PARITY_ODD;
|
||||
rp->parm.serial.parity = RIG_PARITY_ODD;
|
||||
rs->rigport_deprecated.parm.serial.parity = RIG_PARITY_SPACE;
|
||||
}
|
||||
else if (!strcmp(val, "Even"))
|
||||
{
|
||||
rs->rigport.parm.serial.parity = RIG_PARITY_EVEN;
|
||||
rp->parm.serial.parity = RIG_PARITY_EVEN;
|
||||
rs->rigport_deprecated.parm.serial.parity = RIG_PARITY_SPACE;
|
||||
}
|
||||
else if (!strcmp(val, "Mark"))
|
||||
{
|
||||
rs->rigport.parm.serial.parity = RIG_PARITY_MARK;
|
||||
rp->parm.serial.parity = RIG_PARITY_MARK;
|
||||
rs->rigport_deprecated.parm.serial.parity = RIG_PARITY_SPACE;
|
||||
}
|
||||
else if (!strcmp(val, "Space"))
|
||||
{
|
||||
rs->rigport.parm.serial.parity = RIG_PARITY_SPACE;
|
||||
rp->parm.serial.parity = RIG_PARITY_SPACE;
|
||||
rs->rigport_deprecated.parm.serial.parity = RIG_PARITY_SPACE;
|
||||
}
|
||||
else
|
||||
|
@ -384,7 +387,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
break;
|
||||
|
||||
case TOK_HANDSHAKE:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: setting handshake is invalid for non-serial port rig type\n",
|
||||
|
@ -394,17 +397,17 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
|
||||
if (!strcmp(val, "None"))
|
||||
{
|
||||
rs->rigport.parm.serial.handshake = RIG_HANDSHAKE_NONE;
|
||||
rp->parm.serial.handshake = RIG_HANDSHAKE_NONE;
|
||||
rs->rigport_deprecated.parm.serial.handshake = RIG_HANDSHAKE_HARDWARE;
|
||||
}
|
||||
else if (!strcmp(val, "XONXOFF"))
|
||||
{
|
||||
rs->rigport.parm.serial.handshake = RIG_HANDSHAKE_XONXOFF;
|
||||
rp->parm.serial.handshake = RIG_HANDSHAKE_XONXOFF;
|
||||
rs->rigport_deprecated.parm.serial.handshake = RIG_HANDSHAKE_HARDWARE;
|
||||
}
|
||||
else if (!strcmp(val, "Hardware"))
|
||||
{
|
||||
rs->rigport.parm.serial.handshake = RIG_HANDSHAKE_HARDWARE;
|
||||
rp->parm.serial.handshake = RIG_HANDSHAKE_HARDWARE;
|
||||
rs->rigport_deprecated.parm.serial.handshake = RIG_HANDSHAKE_HARDWARE;
|
||||
}
|
||||
else
|
||||
|
@ -415,24 +418,24 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
break;
|
||||
|
||||
case TOK_RTS_STATE:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
if (!strcmp(val, "Unset"))
|
||||
{
|
||||
rs->rigport.parm.serial.rts_state = RIG_SIGNAL_UNSET;
|
||||
rp->parm.serial.rts_state = RIG_SIGNAL_UNSET;
|
||||
rs->rigport_deprecated.parm.serial.rts_state = RIG_SIGNAL_UNSET;
|
||||
}
|
||||
else if (!strcmp(val, "ON"))
|
||||
{
|
||||
rs->rigport.parm.serial.rts_state = RIG_SIGNAL_ON;
|
||||
rp->parm.serial.rts_state = RIG_SIGNAL_ON;
|
||||
rs->rigport_deprecated.parm.serial.rts_state = RIG_SIGNAL_ON;
|
||||
}
|
||||
else if (!strcmp(val, "OFF"))
|
||||
{
|
||||
rs->rigport.parm.serial.rts_state = RIG_SIGNAL_OFF;
|
||||
rp->parm.serial.rts_state = RIG_SIGNAL_OFF;
|
||||
rs->rigport_deprecated.parm.serial.rts_state = RIG_SIGNAL_OFF;
|
||||
}
|
||||
else
|
||||
|
@ -443,24 +446,24 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
break;
|
||||
|
||||
case TOK_DTR_STATE:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
if (!strcmp(val, "Unset"))
|
||||
{
|
||||
rs->rigport.parm.serial.dtr_state = RIG_SIGNAL_UNSET;
|
||||
rp->parm.serial.dtr_state = RIG_SIGNAL_UNSET;
|
||||
rs->rigport_deprecated.parm.serial.dtr_state = RIG_SIGNAL_UNSET;
|
||||
}
|
||||
else if (!strcmp(val, "ON"))
|
||||
{
|
||||
rs->rigport.parm.serial.dtr_state = RIG_SIGNAL_ON;
|
||||
rp->parm.serial.dtr_state = RIG_SIGNAL_ON;
|
||||
rs->rigport_deprecated.parm.serial.dtr_state = RIG_SIGNAL_ON;
|
||||
}
|
||||
else if (!strcmp(val, "OFF"))
|
||||
{
|
||||
rs->rigport.parm.serial.dtr_state = RIG_SIGNAL_OFF;
|
||||
rp->parm.serial.dtr_state = RIG_SIGNAL_OFF;
|
||||
rs->rigport_deprecated.parm.serial.dtr_state = RIG_SIGNAL_OFF;
|
||||
}
|
||||
else
|
||||
|
@ -522,46 +525,46 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
case TOK_PTT_TYPE:
|
||||
if (!strcmp(val, "RIG"))
|
||||
{
|
||||
rs->pttport.type.ptt = RIG_PTT_RIG;
|
||||
pttp->type.ptt = RIG_PTT_RIG;
|
||||
caps->ptt_type = RIG_PTT_RIG;
|
||||
}
|
||||
else if (!strcmp(val, "RIGMICDATA"))
|
||||
{
|
||||
rs->pttport.type.ptt = RIG_PTT_RIG_MICDATA;
|
||||
pttp->type.ptt = RIG_PTT_RIG_MICDATA;
|
||||
caps->ptt_type = RIG_PTT_RIG_MICDATA;
|
||||
}
|
||||
else if (!strcmp(val, "DTR"))
|
||||
{
|
||||
rs->pttport.type.ptt = RIG_PTT_SERIAL_DTR;
|
||||
pttp->type.ptt = RIG_PTT_SERIAL_DTR;
|
||||
caps->ptt_type = RIG_PTT_SERIAL_DTR;
|
||||
}
|
||||
else if (!strcmp(val, "RTS"))
|
||||
{
|
||||
rs->pttport.type.ptt = RIG_PTT_SERIAL_RTS;
|
||||
pttp->type.ptt = RIG_PTT_SERIAL_RTS;
|
||||
caps->ptt_type = RIG_PTT_SERIAL_RTS;
|
||||
}
|
||||
else if (!strcmp(val, "Parallel"))
|
||||
{
|
||||
rs->pttport.type.ptt = RIG_PTT_PARALLEL;
|
||||
pttp->type.ptt = RIG_PTT_PARALLEL;
|
||||
caps->ptt_type = RIG_PTT_PARALLEL;
|
||||
}
|
||||
else if (!strcmp(val, "CM108"))
|
||||
{
|
||||
rs->pttport.type.ptt = RIG_PTT_CM108;
|
||||
pttp->type.ptt = RIG_PTT_CM108;
|
||||
caps->ptt_type = RIG_PTT_CM108;
|
||||
}
|
||||
else if (!strcmp(val, "GPIO"))
|
||||
{
|
||||
rs->pttport.type.ptt = RIG_PTT_GPIO;
|
||||
pttp->type.ptt = RIG_PTT_GPIO;
|
||||
}
|
||||
else if (!strcmp(val, "GPION"))
|
||||
{
|
||||
rs->pttport.type.ptt = RIG_PTT_GPION;
|
||||
pttp->type.ptt = RIG_PTT_GPION;
|
||||
caps->ptt_type = RIG_PTT_GPION;
|
||||
}
|
||||
else if (!strcmp(val, "None"))
|
||||
{
|
||||
rs->pttport.type.ptt = RIG_PTT_NONE;
|
||||
pttp->type.ptt = RIG_PTT_NONE;
|
||||
caps->ptt_type = RIG_PTT_NONE;
|
||||
}
|
||||
else
|
||||
|
@ -570,13 +573,13 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
}
|
||||
|
||||
// JTDX and WSJTX currently use state.pttport to check for PTT_NONE
|
||||
rig->state.pttport.type.ptt = rs->pttport.type.ptt;
|
||||
rs->pttport_deprecated.type.ptt = rs->pttport.type.ptt;
|
||||
// rig->state.pttport.type.ptt = pttp->type.ptt;
|
||||
rs->pttport_deprecated.type.ptt = pttp->type.ptt;
|
||||
|
||||
break;
|
||||
|
||||
case TOK_PTT_PATHNAME:
|
||||
strncpy(rs->pttport.pathname, val, HAMLIB_FILPATHLEN - 1);
|
||||
strncpy(pttp->pathname, val, HAMLIB_FILPATHLEN - 1);
|
||||
strncpy(rs->pttport_deprecated.pathname, val, HAMLIB_FILPATHLEN - 1);
|
||||
break;
|
||||
|
||||
|
@ -586,55 +589,55 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
return -RIG_EINVAL;//value format error
|
||||
}
|
||||
|
||||
rs->pttport.parm.cm108.ptt_bitnum = val_i;
|
||||
rs->rigport.parm.cm108.ptt_bitnum = val_i;
|
||||
pttp->parm.cm108.ptt_bitnum = val_i;
|
||||
rp->parm.cm108.ptt_bitnum = val_i;
|
||||
rs->pttport_deprecated.parm.cm108.ptt_bitnum = val_i;
|
||||
break;
|
||||
|
||||
case TOK_DCD_TYPE:
|
||||
if (!strcmp(val, "RIG"))
|
||||
{
|
||||
rs->dcdport.type.dcd = RIG_DCD_RIG;
|
||||
dcdp->type.dcd = RIG_DCD_RIG;
|
||||
rs->dcdport_deprecated.type.dcd = RIG_DCD_RIG;
|
||||
}
|
||||
else if (!strcmp(val, "DSR"))
|
||||
{
|
||||
rs->dcdport.type.dcd = RIG_DCD_SERIAL_DSR;
|
||||
dcdp->type.dcd = RIG_DCD_SERIAL_DSR;
|
||||
rs->dcdport_deprecated.type.dcd = RIG_DCD_SERIAL_DSR;
|
||||
}
|
||||
else if (!strcmp(val, "CTS"))
|
||||
{
|
||||
rs->dcdport.type.dcd = RIG_DCD_SERIAL_CTS;
|
||||
dcdp->type.dcd = RIG_DCD_SERIAL_CTS;
|
||||
rs->dcdport_deprecated.type.dcd = RIG_DCD_SERIAL_CTS;
|
||||
}
|
||||
else if (!strcmp(val, "CD"))
|
||||
{
|
||||
rs->dcdport.type.dcd = RIG_DCD_SERIAL_CAR;
|
||||
dcdp->type.dcd = RIG_DCD_SERIAL_CAR;
|
||||
rs->dcdport_deprecated.type.dcd = RIG_DCD_SERIAL_CAR;
|
||||
}
|
||||
else if (!strcmp(val, "Parallel"))
|
||||
{
|
||||
rs->dcdport.type.dcd = RIG_DCD_PARALLEL;
|
||||
dcdp->type.dcd = RIG_DCD_PARALLEL;
|
||||
rs->dcdport_deprecated.type.dcd = RIG_DCD_PARALLEL;
|
||||
}
|
||||
else if (!strcmp(val, "CM108"))
|
||||
{
|
||||
rs->dcdport.type.dcd = RIG_DCD_CM108;
|
||||
dcdp->type.dcd = RIG_DCD_CM108;
|
||||
rs->dcdport_deprecated.type.dcd = RIG_DCD_CM108;
|
||||
}
|
||||
else if (!strcmp(val, "GPIO"))
|
||||
{
|
||||
rs->dcdport.type.dcd = RIG_DCD_GPIO;
|
||||
dcdp->type.dcd = RIG_DCD_GPIO;
|
||||
rs->dcdport_deprecated.type.dcd = RIG_DCD_GPIO;
|
||||
}
|
||||
else if (!strcmp(val, "GPION"))
|
||||
{
|
||||
rs->dcdport.type.dcd = RIG_DCD_GPION;
|
||||
dcdp->type.dcd = RIG_DCD_GPION;
|
||||
rs->dcdport_deprecated.type.dcd = RIG_DCD_GPION;
|
||||
}
|
||||
else if (!strcmp(val, "None"))
|
||||
{
|
||||
rs->dcdport.type.dcd = RIG_DCD_NONE;
|
||||
dcdp->type.dcd = RIG_DCD_NONE;
|
||||
rs->dcdport_deprecated.type.dcd = RIG_DCD_NONE;
|
||||
}
|
||||
else
|
||||
|
@ -645,7 +648,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
break;
|
||||
|
||||
case TOK_DCD_PATHNAME:
|
||||
strncpy(rs->dcdport.pathname, val, HAMLIB_FILPATHLEN - 1);
|
||||
strncpy(dcdp->pathname, val, HAMLIB_FILPATHLEN - 1);
|
||||
strncpy(rs->dcdport_deprecated.pathname, val, HAMLIB_FILPATHLEN - 1);
|
||||
break;
|
||||
|
||||
|
@ -728,7 +731,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
return -RIG_EINVAL; //value format error
|
||||
}
|
||||
|
||||
rs->rigport.flushx = val_i ? 1 : 0;
|
||||
rp->flushx = val_i ? 1 : 0;
|
||||
break;
|
||||
|
||||
case TOK_TWIDDLE_TIMEOUT:
|
||||
|
@ -768,7 +771,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
rs->rigport.timeout_retry = val_i;
|
||||
rp->timeout_retry = val_i;
|
||||
break;
|
||||
|
||||
case TOK_OFFSET_VFOA:
|
||||
|
@ -833,21 +836,24 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
{
|
||||
struct rig_state *rs;
|
||||
const char *s = "";
|
||||
hamlib_port_t *rp = RIGPORT(rig);
|
||||
hamlib_port_t *pttp = PTTPORT(rig);
|
||||
hamlib_port_t *dcdp = DCDPORT(rig);
|
||||
|
||||
rs = &rig->state;
|
||||
|
||||
switch (token)
|
||||
{
|
||||
case TOK_PATHNAME:
|
||||
SNPRINTF(val, val_len, "%s", rs->rigport.pathname);
|
||||
SNPRINTF(val, val_len, "%s", rp->pathname);
|
||||
break;
|
||||
|
||||
case TOK_WRITE_DELAY:
|
||||
SNPRINTF(val, val_len, "%d", rs->rigport.write_delay);
|
||||
SNPRINTF(val, val_len, "%d", rp->write_delay);
|
||||
break;
|
||||
|
||||
case TOK_POST_WRITE_DELAY:
|
||||
SNPRINTF(val, val_len, "%d", rs->rigport.post_write_delay);
|
||||
SNPRINTF(val, val_len, "%d", rp->post_write_delay);
|
||||
break;
|
||||
|
||||
case TOK_POST_PTT_DELAY:
|
||||
|
@ -855,11 +861,11 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
break;
|
||||
|
||||
case TOK_TIMEOUT:
|
||||
SNPRINTF(val, val_len, "%d", rs->rigport.timeout);
|
||||
SNPRINTF(val, val_len, "%d", rp->timeout);
|
||||
break;
|
||||
|
||||
case TOK_RETRY:
|
||||
SNPRINTF(val, val_len, "%d", rs->rigport.retry);
|
||||
SNPRINTF(val, val_len, "%d", rp->retry);
|
||||
break;
|
||||
|
||||
#if 0 // needs to be replace?
|
||||
|
@ -871,39 +877,39 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
#endif
|
||||
|
||||
case TOK_SERIAL_SPEED:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
SNPRINTF(val, val_len, "%d", rs->rigport.parm.serial.rate);
|
||||
SNPRINTF(val, val_len, "%d", rp->parm.serial.rate);
|
||||
break;
|
||||
|
||||
case TOK_DATA_BITS:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
SNPRINTF(val, val_len, "%d", rs->rigport.parm.serial.data_bits);
|
||||
SNPRINTF(val, val_len, "%d", rp->parm.serial.data_bits);
|
||||
break;
|
||||
|
||||
case TOK_STOP_BITS:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
SNPRINTF(val, val_len, "%d", rs->rigport.parm.serial.stop_bits);
|
||||
SNPRINTF(val, val_len, "%d", rp->parm.serial.stop_bits);
|
||||
break;
|
||||
|
||||
case TOK_PARITY:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
switch (rs->rigport.parm.serial.parity)
|
||||
switch (rp->parm.serial.parity)
|
||||
{
|
||||
case RIG_PARITY_NONE:
|
||||
s = "None";
|
||||
|
@ -933,7 +939,7 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
break;
|
||||
|
||||
case TOK_HANDSHAKE:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: getting handshake is invalid for non-serial port rig type\n",
|
||||
|
@ -941,7 +947,7 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
switch (rs->rigport.parm.serial.handshake)
|
||||
switch (rp->parm.serial.handshake)
|
||||
{
|
||||
case RIG_HANDSHAKE_NONE:
|
||||
s = "None";
|
||||
|
@ -963,12 +969,12 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
break;
|
||||
|
||||
case TOK_RTS_STATE:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
switch (rs->rigport.parm.serial.rts_state)
|
||||
switch (rp->parm.serial.rts_state)
|
||||
{
|
||||
case RIG_SIGNAL_UNSET:
|
||||
s = "Unset";
|
||||
|
@ -990,12 +996,12 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
break;
|
||||
|
||||
case TOK_DTR_STATE:
|
||||
if (rs->rigport.type.rig != RIG_PORT_SERIAL)
|
||||
if (rp->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
switch (rs->rigport.parm.serial.dtr_state)
|
||||
switch (rp->parm.serial.dtr_state)
|
||||
{
|
||||
case RIG_SIGNAL_UNSET:
|
||||
s = "Unset";
|
||||
|
@ -1029,7 +1035,7 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
break;
|
||||
|
||||
case TOK_PTT_TYPE:
|
||||
switch (rs->pttport.type.ptt)
|
||||
switch (pttp->type.ptt)
|
||||
{
|
||||
case RIG_PTT_RIG:
|
||||
s = "RIG";
|
||||
|
@ -1075,15 +1081,15 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
break;
|
||||
|
||||
case TOK_PTT_PATHNAME:
|
||||
strcpy(val, rs->pttport.pathname);
|
||||
strcpy(val, pttp->pathname);
|
||||
break;
|
||||
|
||||
case TOK_PTT_BITNUM:
|
||||
SNPRINTF(val, val_len, "%d", rs->pttport.parm.cm108.ptt_bitnum);
|
||||
SNPRINTF(val, val_len, "%d", pttp->parm.cm108.ptt_bitnum);
|
||||
break;
|
||||
|
||||
case TOK_DCD_TYPE:
|
||||
switch (rs->dcdport.type.dcd)
|
||||
switch (dcdp->type.dcd)
|
||||
{
|
||||
case RIG_DCD_RIG:
|
||||
s = "RIG";
|
||||
|
@ -1129,7 +1135,7 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
break;
|
||||
|
||||
case TOK_DCD_PATHNAME:
|
||||
strcpy(val, rs->dcdport.pathname);
|
||||
strcpy(val, dcdp->pathname);
|
||||
break;
|
||||
|
||||
case TOK_LO_FREQ:
|
||||
|
@ -1157,7 +1163,7 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
break;
|
||||
|
||||
case TOK_FLUSHX:
|
||||
SNPRINTF(val, val_len, "%d", rs->rigport.flushx);
|
||||
SNPRINTF(val, val_len, "%d", rp->flushx);
|
||||
break;
|
||||
|
||||
case TOK_DISABLE_YAESU_BANDSELECT:
|
||||
|
@ -1177,7 +1183,7 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
break;
|
||||
|
||||
case TOK_TIMEOUT_RETRY:
|
||||
SNPRINTF(val, val_len, "%d", rs->rigport.timeout_retry);
|
||||
SNPRINTF(val, val_len, "%d", rp->timeout_retry);
|
||||
break;
|
||||
|
||||
case TOK_MULTICAST_DATA_ADDR:
|
||||
|
@ -1200,7 +1206,7 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->rigport_deprecated, rp, sizeof(hamlib_port_t_deprecated));
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
@ -1371,7 +1377,6 @@ token_t HAMLIB_API rig_token_lookup(RIG *rig, const char *name)
|
|||
*/
|
||||
int HAMLIB_API rig_set_conf(RIG *rig, token_t token, const char *val)
|
||||
{
|
||||
struct rig_state *rs = &rig->state;
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig || !rig->caps)
|
||||
|
@ -1380,7 +1385,7 @@ int HAMLIB_API rig_set_conf(RIG *rig, token_t token, const char *val)
|
|||
}
|
||||
|
||||
// Some parameters can be ignored
|
||||
if (token == TOK_HANDSHAKE && (rs->rigport.type.rig != RIG_PORT_SERIAL))
|
||||
if (token == TOK_HANDSHAKE && (RIGPORT(rig)->type.rig != RIG_PORT_SERIAL))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN,
|
||||
"%s: handshake is not valid for non-serial port rig\n", __func__);
|
||||
|
|
|
@ -740,6 +740,7 @@ static const struct
|
|||
{ RIG_FUNC_SEND_MORSE, "SEND_MORSE" },
|
||||
{ RIG_FUNC_SEND_VOICE_MEM, "SEND_VOICE_MEM" },
|
||||
{ RIG_FUNC_OVF_STATUS, "OVF_STATUS" },
|
||||
{ RIG_FUNC_SYNC, "SYNC" },
|
||||
{ RIG_FUNC_NONE, "" },
|
||||
};
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ static int multicast_send_json(RIG *rig)
|
|||
// sprintf(msg,"%s:f=%.1f", date_strget(msg, (int)sizeof(msg), 0), f);
|
||||
msg[0] = 0;
|
||||
snprintf(buf, sizeof(buf), "%s:%s", rig->caps->model_name,
|
||||
rig->state.rigport.pathname);
|
||||
RIGPORT(rig)->pathname);
|
||||
strcat(msg, "{\n");
|
||||
json_add_string(msg, "ID", buf, 1);
|
||||
json_add_time(msg, 1);
|
||||
|
@ -339,7 +339,7 @@ void *multicast_thread_rx(void *vrig)
|
|||
while (rig->state.multicast->runflag)
|
||||
{
|
||||
#if 0
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, sizeof(buf), "\n",
|
||||
ret = read_string(RIGPORT(rig), (unsigned char *) buf, sizeof(buf), "\n",
|
||||
1,
|
||||
0, 1);
|
||||
#endif
|
||||
|
@ -652,8 +652,8 @@ int main(int argc, const char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
strncpy(rig->state.rigport.pathname, "/dev/ttyUSB0", HAMLIB_FILPATHLEN - 1);
|
||||
rig->state.rigport.parm.serial.rate = 38400;
|
||||
strncpy(RIGPORT(rig)->pathname, "/dev/ttyUSB0", HAMLIB_FILPATHLEN - 1);
|
||||
RIGPORT(rig)->parm.serial.rate = 38400;
|
||||
rig_open(rig);
|
||||
multicast_init(rig, "224.0.0.1", 4532);
|
||||
pthread_join(rig->state.multicast->threadid, NULL);
|
||||
|
|
137
src/rotator.c
137
src/rotator.c
|
@ -19,6 +19,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
/**
|
||||
* \addtogroup rotator
|
||||
|
@ -219,6 +220,7 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model)
|
|||
ROT *rot;
|
||||
const struct rot_caps *caps;
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp, *rotp2;
|
||||
|
||||
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
|
@ -258,41 +260,46 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model)
|
|||
*/
|
||||
rs = &rot->state;
|
||||
|
||||
//TODO Allocate new rotport[2]
|
||||
// For now, use the embedded ones
|
||||
rotp = ROTPORT(rot);
|
||||
rotp2 = ROTPORT2(rot);
|
||||
|
||||
rs->comm_state = 0;
|
||||
rs->rotport.type.rig = caps->port_type; /* default from caps */
|
||||
rotp->type.rig = caps->port_type; /* default from caps */
|
||||
|
||||
rs->rotport.write_delay = caps->write_delay;
|
||||
rs->rotport.post_write_delay = caps->post_write_delay;
|
||||
rs->rotport.timeout = caps->timeout;
|
||||
rs->rotport.retry = caps->retry;
|
||||
rotp->write_delay = caps->write_delay;
|
||||
rotp->post_write_delay = caps->post_write_delay;
|
||||
rotp->timeout = caps->timeout;
|
||||
rotp->retry = caps->retry;
|
||||
|
||||
switch (caps->port_type)
|
||||
{
|
||||
case RIG_PORT_SERIAL:
|
||||
strncpy(rs->rotport.pathname, DEFAULT_SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
|
||||
rs->rotport.parm.serial.rate = rs->rotport2.parm.serial.rate =
|
||||
strncpy(rotp->pathname, DEFAULT_SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
|
||||
rotp->parm.serial.rate = rotp2->parm.serial.rate =
|
||||
caps->serial_rate_max; /* fastest ! */
|
||||
rs->rotport.parm.serial.data_bits = rs->rotport2.parm.serial.data_bits =
|
||||
rotp->parm.serial.data_bits = rotp2->parm.serial.data_bits =
|
||||
caps->serial_data_bits;
|
||||
rs->rotport.parm.serial.stop_bits = rs->rotport2.parm.serial.stop_bits =
|
||||
rotp->parm.serial.stop_bits = rotp2->parm.serial.stop_bits =
|
||||
caps->serial_stop_bits;
|
||||
rs->rotport.parm.serial.parity = rs->rotport2.parm.serial.parity =
|
||||
rotp->parm.serial.parity = rotp2->parm.serial.parity =
|
||||
caps->serial_parity;
|
||||
rs->rotport.parm.serial.handshake = rs->rotport2.parm.serial.handshake =
|
||||
rotp->parm.serial.handshake = rotp2->parm.serial.handshake =
|
||||
caps->serial_handshake;
|
||||
break;
|
||||
|
||||
case RIG_PORT_PARALLEL:
|
||||
strncpy(rs->rotport.pathname, DEFAULT_PARALLEL_PORT, HAMLIB_FILPATHLEN - 1);
|
||||
strncpy(rotp->pathname, DEFAULT_PARALLEL_PORT, HAMLIB_FILPATHLEN - 1);
|
||||
break;
|
||||
|
||||
case RIG_PORT_NETWORK:
|
||||
case RIG_PORT_UDP_NETWORK:
|
||||
strncpy(rs->rotport.pathname, "127.0.0.1:4533", HAMLIB_FILPATHLEN - 1);
|
||||
strncpy(rotp->pathname, "127.0.0.1:4533", HAMLIB_FILPATHLEN - 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
strncpy(rs->rotport.pathname, "", HAMLIB_FILPATHLEN - 1);
|
||||
strncpy(rotp->pathname, "", HAMLIB_FILPATHLEN - 1);
|
||||
}
|
||||
|
||||
rs->min_el = caps->min_el;
|
||||
|
@ -301,7 +308,7 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model)
|
|||
rs->max_az = caps->max_az;
|
||||
rs->current_speed = 50; // Set default speed to 50%
|
||||
|
||||
rs->rotport.fd = -1;
|
||||
rotp->fd = -1;
|
||||
|
||||
rs->has_get_func = caps->has_get_func;
|
||||
rs->has_set_func = caps->has_set_func;
|
||||
|
@ -338,7 +345,7 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model)
|
|||
// Now we have to copy our new rig state hamlib_port structure to the deprecated one
|
||||
// Clients built on older 4.X versions will use the old structure
|
||||
// Clients built on newer 4.5 versions will use the new structure
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport,
|
||||
memcpy(&rot->state.rotport_deprecated, rotp,
|
||||
sizeof(rot->state.rotport_deprecated));
|
||||
|
||||
return rot;
|
||||
|
@ -366,6 +373,8 @@ int HAMLIB_API rot_open(ROT *rot)
|
|||
{
|
||||
const struct rot_caps *caps;
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
hamlib_port_t *rotp2 = ROTPORT2(rot);
|
||||
int status;
|
||||
int net1, net2, net3, net4, port;
|
||||
|
||||
|
@ -384,30 +393,30 @@ int HAMLIB_API rot_open(ROT *rot)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
rs->rotport.fd = -1;
|
||||
rs->rotport2.fd = -1;
|
||||
rotp->fd = -1;
|
||||
rotp2->fd = -1;
|
||||
|
||||
// determine if we have a network address
|
||||
if (sscanf(rs->rotport.pathname, "%d.%d.%d.%d:%d", &net1, &net2, &net3, &net4,
|
||||
if (sscanf(rotp->pathname, "%d.%d.%d.%d:%d", &net1, &net2, &net3, &net4,
|
||||
&port) == 5)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: using network address %s\n", __func__,
|
||||
rs->rotport.pathname);
|
||||
rs->rotport.type.rig = RIG_PORT_NETWORK;
|
||||
rotp->pathname);
|
||||
rotp->type.rig = RIG_PORT_NETWORK;
|
||||
}
|
||||
|
||||
if (sscanf(rs->rotport2.pathname, "%d.%d.%d.%d:%d", &net1, &net2, &net3, &net4,
|
||||
if (sscanf(rotp2->pathname, "%d.%d.%d.%d:%d", &net1, &net2, &net3, &net4,
|
||||
&port) == 5)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: using network address %s\n", __func__,
|
||||
rs->rotport2.pathname);
|
||||
rs->rotport2.type.rig = RIG_PORT_NETWORK;
|
||||
rotp2->pathname);
|
||||
rotp2->type.rig = RIG_PORT_NETWORK;
|
||||
}
|
||||
|
||||
switch (rs->rotport.type.rig)
|
||||
switch (rotp->type.rig)
|
||||
{
|
||||
case RIG_PORT_SERIAL:
|
||||
status = serial_open(&rs->rotport);
|
||||
status = serial_open(rotp);
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
|
@ -416,9 +425,9 @@ int HAMLIB_API rot_open(ROT *rot)
|
|||
|
||||
// RT21 has 2nd serial port elevation
|
||||
// so if a 2nd pathname is provided we'll open it
|
||||
if (rot->caps->rot_model == ROT_MODEL_RT21 && rs->rotport2.pathname[0] != 0)
|
||||
if (rot->caps->rot_model == ROT_MODEL_RT21 && rotp2->pathname[0] != 0)
|
||||
{
|
||||
status = serial_open(&rs->rotport2);
|
||||
status = serial_open(rotp2);
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
|
@ -429,7 +438,7 @@ int HAMLIB_API rot_open(ROT *rot)
|
|||
break;
|
||||
|
||||
case RIG_PORT_PARALLEL:
|
||||
status = par_open(&rs->rotport);
|
||||
status = par_open(rotp);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
|
@ -439,27 +448,27 @@ int HAMLIB_API rot_open(ROT *rot)
|
|||
break;
|
||||
|
||||
case RIG_PORT_DEVICE:
|
||||
status = open(rs->rotport.pathname, O_RDWR, 0);
|
||||
status = open(rotp->pathname, O_RDWR, 0);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
return -RIG_EIO;
|
||||
}
|
||||
|
||||
rs->rotport.fd = status;
|
||||
rotp->fd = status;
|
||||
|
||||
// RT21 has 2nd serial port elevation
|
||||
// so if a 2nd pathname is provided we'll open it
|
||||
if (rot->caps->rot_model == ROT_MODEL_RT21 && rs->rotport2.pathname[0] != 0)
|
||||
if (rot->caps->rot_model == ROT_MODEL_RT21 && rotp2->pathname[0] != 0)
|
||||
{
|
||||
status = open(rs->rotport2.pathname, O_RDWR, 0);
|
||||
status = open(rotp2->pathname, O_RDWR, 0);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
return -RIG_EIO;
|
||||
}
|
||||
|
||||
rs->rotport2.fd = status;
|
||||
rotp2->fd = status;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -467,7 +476,7 @@ int HAMLIB_API rot_open(ROT *rot)
|
|||
#if defined(HAVE_LIB_USB_H) || defined(HAMB_LIBUSB_1_0_LIBUSB_H)
|
||||
|
||||
case RIG_PORT_USB:
|
||||
status = usb_port_open(&rs->rotport);
|
||||
status = usb_port_open(rotp);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
|
@ -484,7 +493,7 @@ int HAMLIB_API rot_open(ROT *rot)
|
|||
case RIG_PORT_NETWORK:
|
||||
case RIG_PORT_UDP_NETWORK:
|
||||
/* FIXME: default port */
|
||||
status = network_open(&rs->rotport, 4533);
|
||||
status = network_open(rotp, 4533);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
|
@ -511,31 +520,31 @@ int HAMLIB_API rot_open(ROT *rot)
|
|||
|
||||
if (status != RIG_OK)
|
||||
{
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport,
|
||||
memcpy(&rot->state.rotport_deprecated, rotp,
|
||||
sizeof(rot->state.rotport_deprecated));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
if (rs->rotport.parm.serial.dtr_state == RIG_SIGNAL_ON)
|
||||
if (rotp->parm.serial.dtr_state == RIG_SIGNAL_ON)
|
||||
{
|
||||
ser_set_dtr(&rs->rotport, 1);
|
||||
ser_set_dtr(rotp, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ser_set_dtr(&rs->rotport, 0);
|
||||
ser_set_dtr(rotp, 0);
|
||||
}
|
||||
|
||||
if (rs->rotport.parm.serial.rts_state == RIG_SIGNAL_ON)
|
||||
if (rotp->parm.serial.rts_state == RIG_SIGNAL_ON)
|
||||
{
|
||||
ser_set_rts(&rs->rotport, 1);
|
||||
ser_set_rts(rotp, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ser_set_rts(&rs->rotport, 0);
|
||||
ser_set_rts(rotp, 0);
|
||||
}
|
||||
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport,
|
||||
memcpy(&rot->state.rotport_deprecated, rotp,
|
||||
sizeof(rot->state.rotport_deprecated));
|
||||
|
||||
return RIG_OK;
|
||||
|
@ -561,6 +570,7 @@ int HAMLIB_API rot_close(ROT *rot)
|
|||
{
|
||||
const struct rot_caps *caps;
|
||||
struct rot_state *rs;
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
|
||||
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
|
@ -587,42 +597,42 @@ int HAMLIB_API rot_close(ROT *rot)
|
|||
}
|
||||
|
||||
|
||||
if (rs->rotport.fd != -1)
|
||||
if (rotp->fd != -1)
|
||||
{
|
||||
switch (rs->rotport.type.rig)
|
||||
switch (rotp->type.rig)
|
||||
{
|
||||
case RIG_PORT_SERIAL:
|
||||
ser_close(&rs->rotport);
|
||||
ser_close(rotp);
|
||||
break;
|
||||
|
||||
case RIG_PORT_PARALLEL:
|
||||
par_close(&rs->rotport);
|
||||
par_close(rotp);
|
||||
break;
|
||||
|
||||
#if defined(HAVE_LIB_USB_H) || defined(HAMB_LIBUSB_1_0_LIBUSB_H)
|
||||
|
||||
case RIG_PORT_USB:
|
||||
usb_port_close(&rs->rotport);
|
||||
usb_port_close(rotp);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case RIG_PORT_NETWORK:
|
||||
case RIG_PORT_UDP_NETWORK:
|
||||
network_close(&rs->rotport);
|
||||
network_close(rotp);
|
||||
break;
|
||||
|
||||
default:
|
||||
close(rs->rotport.fd);
|
||||
close(rotp->fd);
|
||||
}
|
||||
|
||||
rs->rotport.fd = -1;
|
||||
rotp->fd = -1;
|
||||
}
|
||||
|
||||
remove_opened_rot(rot);
|
||||
|
||||
rs->comm_state = 0;
|
||||
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport,
|
||||
memcpy(&rot->state.rotport_deprecated, rotp,
|
||||
sizeof(rot->state.rotport_deprecated));
|
||||
|
||||
return RIG_OK;
|
||||
|
@ -670,6 +680,8 @@ int HAMLIB_API rot_cleanup(ROT *rot)
|
|||
rot->caps->rot_cleanup(rot);
|
||||
}
|
||||
|
||||
//TODO Release any allocated port structures
|
||||
|
||||
free(rot);
|
||||
|
||||
return RIG_OK;
|
||||
|
@ -1031,4 +1043,23 @@ int HAMLIB_API rot_get_status(ROT *rot, rot_status_t *status)
|
|||
return rot->caps->get_status(rot, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get the address of rotator data structure(s)
|
||||
*
|
||||
* \sa rig_data_pointer
|
||||
*
|
||||
*/
|
||||
void * HAMLIB_API rot_data_pointer(ROT *rot, rig_ptrx_t idx)
|
||||
{
|
||||
switch(idx)
|
||||
{
|
||||
case RIG_PTRX_ROTPORT:
|
||||
return ROTPORT(rot);
|
||||
case RIG_PTRX_ROTPORT2:
|
||||
return ROTPORT2(rot);
|
||||
default:
|
||||
rot_debug(RIG_DEBUG_ERR, "%s: Invalid data index=%d\n", __func__, idx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/*! @} */
|
||||
|
|
10
src/serial.c
10
src/serial.c
|
@ -1051,7 +1051,7 @@ int HAMLIB_API ser_set_rts(hamlib_port_t *p, int state)
|
|||
|
||||
/**
|
||||
* \brief Get RTS bit
|
||||
* \param p supposed to be &rig->state.rigport
|
||||
* \param p supposed to be RIGPORT(rig)
|
||||
* \param state non-NULL
|
||||
*/
|
||||
int HAMLIB_API ser_get_rts(hamlib_port_t *p, int *state)
|
||||
|
@ -1134,7 +1134,7 @@ int HAMLIB_API ser_set_dtr(hamlib_port_t *p, int state)
|
|||
|
||||
/**
|
||||
* \brief Get DTR bit
|
||||
* \param p supposed to be &rig->state.rigport
|
||||
* \param p supposed to be RIGPORT(rig)
|
||||
* \param state non-NULL
|
||||
*/
|
||||
int HAMLIB_API ser_get_dtr(hamlib_port_t *p, int *state)
|
||||
|
@ -1186,7 +1186,7 @@ int HAMLIB_API ser_set_brk(const hamlib_port_t *p, int state)
|
|||
|
||||
/**
|
||||
* \brief Get Carrier (CI?) bit
|
||||
* \param p supposed to be &rig->state.rigport
|
||||
* \param p supposed to be RIGPORT(rig)
|
||||
* \param state non-NULL
|
||||
*/
|
||||
int HAMLIB_API ser_get_car(hamlib_port_t *p, int *state)
|
||||
|
@ -1209,7 +1209,7 @@ int HAMLIB_API ser_get_car(hamlib_port_t *p, int *state)
|
|||
|
||||
/**
|
||||
* \brief Get Clear to Send (CTS) bit
|
||||
* \param p supposed to be &rig->state.rigport
|
||||
* \param p supposed to be RIGPORT(rig)
|
||||
* \param state non-NULL
|
||||
*/
|
||||
int HAMLIB_API ser_get_cts(hamlib_port_t *p, int *state)
|
||||
|
@ -1232,7 +1232,7 @@ int HAMLIB_API ser_get_cts(hamlib_port_t *p, int *state)
|
|||
|
||||
/**
|
||||
* \brief Get Data Set Ready (DSR) bit
|
||||
* \param p supposed to be &rig->state.rigport
|
||||
* \param p supposed to be RIGPORT(rig)
|
||||
* \param state non-NULL
|
||||
*/
|
||||
int HAMLIB_API ser_get_dsr(hamlib_port_t *p, int *state)
|
||||
|
|
|
@ -22,7 +22,7 @@ static int snapshot_serialize_rig(cJSON *rig_node, RIG *rig)
|
|||
|
||||
cJSON *id_node = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(id_node, "model", rig->caps->model_name);
|
||||
cJSON_AddStringToObject(id_node, "endpoint", rig->state.rigport.pathname);
|
||||
cJSON_AddStringToObject(id_node, "endpoint", RIGPORT(rig)->pathname);
|
||||
cJSON_AddStringToObject(id_node, "process", snapshot_data_pid);
|
||||
cJSON_AddStringToObject(id_node, "deviceId", rig->state.device_id);
|
||||
cJSON_AddItemToObject(rig_node, "id", id_node);
|
||||
|
|
|
@ -177,6 +177,7 @@ int rig_sprintf_func(char *str, int nlen, setting_t func)
|
|||
|
||||
if (!ms || !ms[0])
|
||||
{
|
||||
rig_debug(RIG_EINTERNAL, "%s: unknown RIG_FUNC=%x\n", __func__, i);
|
||||
continue; /* unknown, FIXME! */
|
||||
}
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@ int main()
|
|||
/* Instantiate a rig */
|
||||
my_rig = rig_init(MODEL); // your rig model.
|
||||
|
||||
strncpy(my_rig->state.rigport.pathname, PATH, HAMLIB_FILPATHLEN - 1);
|
||||
rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), PATH);
|
||||
|
||||
my_rig->state.rigport.parm.serial.rate = BAUD; // your baud rate
|
||||
HAMLIB_RIGPORT(my_rig)->parm.serial.rate = BAUD; // your baud rate
|
||||
|
||||
/* Open my rig */
|
||||
retcode = rig_open(my_rig);
|
||||
|
@ -131,7 +131,7 @@ int main()
|
|||
if (range)
|
||||
{
|
||||
char vfolist[256];
|
||||
rig_sprintf_vfo(vfolist, sizeof(vfo_list), my_rig->state.vfo_list);
|
||||
rig_sprintf_vfo(vfolist, sizeof(vfolist), my_rig->state.vfo_list);
|
||||
printf("Range start=%"PRIfreq", end=%"PRIfreq", low_power=%d, high_power=%d, vfos=%s\n",
|
||||
range->startf, range->endf, range->low_power, range->high_power, vfolist);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue