kopia lustrzana https://github.com/Hamlib/Hamlib
Implement function to get structure address
Add AMPPORT and ROTPORT macrospull/1476/head
rodzic
e178a984ca
commit
cd1f4d3929
|
@ -2479,6 +2479,8 @@ typedef hamlib_port_t port_t;
|
||||||
#define PTTPORT(r) (&r->state.pttport)
|
#define PTTPORT(r) (&r->state.pttport)
|
||||||
#define DCDPORT(r) (&r->state.dcdport)
|
#define DCDPORT(r) (&r->state.dcdport)
|
||||||
#define CACHE(r) (&r->state.cache)
|
#define CACHE(r) (&r->state.cache)
|
||||||
|
#define AMPPORT(a) (&a->state.ampport)
|
||||||
|
#define ROTPORT(r) (&r->state.rotport)
|
||||||
/* Then when the rigport address is stored as a pointer somewhere else(say,
|
/* Then when the rigport address is stored as a pointer somewhere else(say,
|
||||||
* in the rig structure itself), the definition could be changed to
|
* in the rig structure itself), the definition could be changed to
|
||||||
* #define RIGPORT(r) r->somewhereelse
|
* #define RIGPORT(r) r->somewhereelse
|
||||||
|
@ -2486,13 +2488,26 @@ typedef hamlib_port_t port_t;
|
||||||
*/
|
*/
|
||||||
#else
|
#else
|
||||||
/* Define external unique names */
|
/* Define external unique names */
|
||||||
/* These will be changed to a function call before release */
|
#define HAMLIB_RIGPORT(r) (hamlib_port_t *)rig_data_pointer(r, RIG_PTRX_RIGPORT)
|
||||||
#define HAMLIB_RIGPORT(r) (&r->state.rigport)
|
#define HAMLIB_PTTPORT(r) (hamlib_port_t *)rig_data_pointer(r, RIG_PTRX_PTTPORT)
|
||||||
#define HAMLIB_PTTPORT(r) (&r->state.pttport)
|
#define HAMLIB_DCDPORT(r) (hamlib_port_t *)rig_data_pointer(r, RIG_PTRX_DCDPORT)
|
||||||
#define HAMLIB_DCDPORT(r) (&r->state.dcdport)
|
//#define HAMLIB_CACHE(r) (struct rig_cache *)rig_data_pointer(r, RIG_PTRX_CACHE)
|
||||||
//#define HAMLIB_CACHE(r) (&r->state.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)
|
||||||
#endif
|
#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,
|
||||||
|
// New entries go directly above this line====================
|
||||||
|
RIG_PTRX_MAXIMUM
|
||||||
|
} rig_ptrx_t;
|
||||||
|
|
||||||
#define HAMLIB_ELAPSED_GET 0
|
#define HAMLIB_ELAPSED_GET 0
|
||||||
#define HAMLIB_ELAPSED_SET 1
|
#define HAMLIB_ELAPSED_SET 1
|
||||||
#define HAMLIB_ELAPSED_INVALIDATE 2
|
#define HAMLIB_ELAPSED_INVALIDATE 2
|
||||||
|
@ -3829,6 +3844,7 @@ 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_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_cm108_set_bit(hamlib_port_t *p, enum GPIO gpio, int bit);
|
||||||
|
|
||||||
|
extern HAMLIB_EXPORT(void *) rig_data_pointer(RIG *rig, rig_ptrx_t idx);
|
||||||
|
|
||||||
//! @endcond
|
//! @endcond
|
||||||
|
|
||||||
|
|
34
src/rig.c
34
src/rig.c
|
@ -20,6 +20,7 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup rig
|
* \addtogroup rig
|
||||||
|
@ -8614,3 +8615,36 @@ int morse_data_handler_set_keyspd(RIG *rig, int keyspd)
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \brief Get the address of a Hamlib data structure
|
||||||
|
* \param rig Pointer to main data anchor
|
||||||
|
* \param idx enum for which pointer requested
|
||||||
|
*
|
||||||
|
* Get the address of a structure without relying on changeable
|
||||||
|
* internal data organization.
|
||||||
|
*
|
||||||
|
* \retval The address of the enumed structure
|
||||||
|
*
|
||||||
|
* Note: This is meant for use by the HAMLIB_???PORT macros mostly. Only
|
||||||
|
* compatiblity with them is supported.
|
||||||
|
*
|
||||||
|
* \sa amp_data_pointer, rot_data_pointer
|
||||||
|
*/
|
||||||
|
HAMLIB_EXPORT(void *) rig_data_pointer(RIG *rig, rig_ptrx_t idx)
|
||||||
|
{
|
||||||
|
switch(idx)
|
||||||
|
{
|
||||||
|
case RIG_PTRX_RIGPORT:
|
||||||
|
return RIGPORT(rig);
|
||||||
|
case RIG_PTRX_PTTPORT:
|
||||||
|
return PTTPORT(rig);
|
||||||
|
case RIG_PTRX_DCDPORT:
|
||||||
|
return DCDPORT(rig);
|
||||||
|
case RIG_PTRX_CACHE:
|
||||||
|
return CACHE(rig);
|
||||||
|
default:
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: Invalid data index=%d\n", __func__, idx);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue