mirror of
https://github.com/Hamlib/Hamlib.git
synced 2024-09-21 10:27:18 +00:00
Add macros for amplifier and rotator state pointers.
This commit is contained in:
parent
2d0b8b807d
commit
295ad74757
@ -2491,6 +2491,8 @@ typedef hamlib_port_t port_t;
|
||||
#define ROTPORT(r) (&r->state.rotport)
|
||||
#define ROTPORT2(r) (&r->state.rotport2)
|
||||
#define STATE(r) (&r->state)
|
||||
#define AMPSTATE(a) (&(a)->state)
|
||||
#define ROTSTATE(r) (&(r)->state)
|
||||
/* 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
|
||||
@ -2506,6 +2508,8 @@ typedef hamlib_port_t port_t;
|
||||
#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))
|
||||
#define HAMLIB_STATE(r) ((struct rig_state *)rig_data_pointer(r, RIG_PTRX_STATE))
|
||||
#define HAMLIB_AMPSTATE(a) ((struct amp_state *)amp_data_pointer(a, RIG_PTRX_AMPSTATE))
|
||||
#define HAMLIB_ROTSTATE(r) ((struct rot_state *)rot_data_pointer(r, RIG_PTRX_ROTSTATE))
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
@ -2518,6 +2522,8 @@ typedef enum {
|
||||
RIG_PTRX_ROTPORT,
|
||||
RIG_PTRX_ROTPORT2,
|
||||
RIG_PTRX_STATE,
|
||||
RIG_PTRX_AMPSTATE,
|
||||
RIG_PTRX_ROTSTATE,
|
||||
// New entries go directly above this line====================
|
||||
RIG_PTRX_MAXIMUM
|
||||
} rig_ptrx_t;
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
/*
|
||||
* Configuration options available in the amp->state struct.
|
||||
* Configuration options available in the amp_state struct.
|
||||
*/
|
||||
static const struct confparams ampfrontend_cfg_params[] =
|
||||
{
|
||||
@ -112,7 +112,7 @@ int frontamp_set_conf(AMP *amp, hamlib_token_t token, const char *val)
|
||||
hamlib_port_t *ampp = AMPPORT(amp);
|
||||
int val_i;
|
||||
|
||||
rs = &->state;
|
||||
rs = AMPSTATE(amp);
|
||||
|
||||
amp_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
|
@ -75,7 +75,7 @@ setting_t HAMLIB_API amp_has_set_level(AMP *amp, setting_t level)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (amp->state.has_set_level & level);
|
||||
return (AMPSTATE(amp)->has_set_level & level);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,7 +108,7 @@ setting_t HAMLIB_API amp_has_get_level(AMP *amp, setting_t level)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (amp->state.has_get_level & level);
|
||||
return (AMPSTATE(amp)->has_get_level & level);
|
||||
}
|
||||
|
||||
/*! @} */
|
||||
|
@ -65,7 +65,7 @@
|
||||
#include "token.h"
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
#define CHECK_AMP_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state)
|
||||
#define CHECK_AMP_ARG(r) (!(r) || !(r)->caps || !AMPSTATE(r)->comm_state)
|
||||
//! @endcond
|
||||
|
||||
/*
|
||||
@ -224,7 +224,7 @@ AMP *HAMLIB_API amp_init(amp_model_t amp_model)
|
||||
/**
|
||||
* \todo Read the Preferences here!
|
||||
*/
|
||||
rs = &->state;
|
||||
rs = AMPSTATE(amp);
|
||||
|
||||
//TODO allocate and link new ampport
|
||||
// For now, use the embedded one
|
||||
@ -285,8 +285,8 @@ 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, ap,
|
||||
sizeof(amp->state.ampport_deprecated));
|
||||
memcpy(&rs->ampport_deprecated, ap,
|
||||
sizeof(rs->ampport_deprecated));
|
||||
|
||||
return amp;
|
||||
}
|
||||
@ -324,7 +324,7 @@ int HAMLIB_API amp_open(AMP *amp)
|
||||
}
|
||||
|
||||
caps = amp->caps;
|
||||
rs = &->state;
|
||||
rs = AMPSTATE(amp);
|
||||
|
||||
if (rs->comm_state)
|
||||
{
|
||||
@ -419,8 +419,8 @@ int HAMLIB_API amp_open(AMP *amp)
|
||||
|
||||
if (status != RIG_OK)
|
||||
{
|
||||
memcpy(&->state.ampport_deprecated, ap,
|
||||
sizeof(amp->state.ampport_deprecated));
|
||||
memcpy(&rs->ampport_deprecated, ap,
|
||||
sizeof(rs->ampport_deprecated));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@ -443,8 +443,8 @@ int HAMLIB_API amp_open(AMP *amp)
|
||||
ser_set_rts(ap, 0);
|
||||
}
|
||||
|
||||
memcpy(&->state.ampport_deprecated, ap,
|
||||
sizeof(amp->state.ampport_deprecated));
|
||||
memcpy(&rs->ampport_deprecated, ap,
|
||||
sizeof(rs->ampport_deprecated));
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
@ -488,7 +488,7 @@ int HAMLIB_API amp_close(AMP *amp)
|
||||
}
|
||||
|
||||
caps = amp->caps;
|
||||
rs = &->state;
|
||||
rs = AMPSTATE(amp);
|
||||
|
||||
if (!rs->comm_state)
|
||||
{
|
||||
@ -571,7 +571,7 @@ int HAMLIB_API amp_cleanup(AMP *amp)
|
||||
/*
|
||||
* check if they forgot to close the amp
|
||||
*/
|
||||
if (amp->state.comm_state)
|
||||
if (AMPSTATE(amp)->comm_state)
|
||||
{
|
||||
amp_close(amp);
|
||||
}
|
||||
@ -969,6 +969,8 @@ void * HAMLIB_API amp_data_pointer(AMP *amp, rig_ptrx_t idx)
|
||||
{
|
||||
case RIG_PTRX_AMPPORT:
|
||||
return AMPPORT(amp);
|
||||
case RIG_PTRX_AMPSTATE:
|
||||
return AMPSTATE(amp);
|
||||
default:
|
||||
amp_debug(RIG_DEBUG_ERR, "%s: Invalid data index=%d\n", __func__, idx);
|
||||
return NULL;
|
||||
|
@ -45,7 +45,7 @@
|
||||
|
||||
|
||||
/*
|
||||
* Configuration options available in the rot->state struct.
|
||||
* Configuration options available in the rot_state struct.
|
||||
*/
|
||||
static const struct confparams rotfrontend_cfg_params[] =
|
||||
{
|
||||
@ -143,7 +143,7 @@ int frontrot_set_conf(ROT *rot, hamlib_token_t token, const char *val)
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
int val_i;
|
||||
|
||||
rs = &rot->state;
|
||||
rs = ROTSTATE(rot);
|
||||
|
||||
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
@ -412,7 +412,7 @@ int frontrot_get_conf(ROT *rot, hamlib_token_t token, char *val, int val_len)
|
||||
hamlib_port_t *rotp = ROTPORT(rot);
|
||||
const char *s;
|
||||
|
||||
rs = &rot->state;
|
||||
rs = ROTSTATE(rot);
|
||||
|
||||
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
|
||||
#ifndef DOC_HIDDEN
|
||||
|
||||
# define CHECK_ROT_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state)
|
||||
# define CHECK_ROT_ARG(r) (!(r) || !(r)->caps || !(ROTSTATE(r)->comm_state))
|
||||
|
||||
#endif /* !DOC_HIDDEN */
|
||||
|
||||
@ -255,7 +255,7 @@ setting_t HAMLIB_API rot_has_get_level(ROT *rot, setting_t level)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (rot->state.has_get_level & level);
|
||||
return (ROTSTATE(rot)->has_get_level & level);
|
||||
}
|
||||
|
||||
|
||||
@ -293,7 +293,7 @@ setting_t HAMLIB_API rot_has_set_level(ROT *rot, setting_t level)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (rot->state.has_set_level & level);
|
||||
return (ROTSTATE(rot)->has_set_level & level);
|
||||
}
|
||||
|
||||
|
||||
@ -330,7 +330,7 @@ setting_t HAMLIB_API rot_has_get_parm(ROT *rot, setting_t parm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (rot->state.has_get_parm & parm);
|
||||
return (ROTSTATE(rot)->has_get_parm & parm);
|
||||
}
|
||||
|
||||
|
||||
@ -367,7 +367,7 @@ setting_t HAMLIB_API rot_has_set_parm(ROT *rot, setting_t parm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (rot->state.has_set_parm & parm);
|
||||
return (ROTSTATE(rot)->has_set_parm & parm);
|
||||
}
|
||||
|
||||
|
||||
@ -404,7 +404,7 @@ setting_t HAMLIB_API rot_has_get_func(ROT *rot, setting_t func)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (rot->state.has_get_func & func);
|
||||
return (ROTSTATE(rot)->has_get_func & func);
|
||||
}
|
||||
|
||||
|
||||
@ -440,7 +440,7 @@ setting_t HAMLIB_API rot_has_set_func(ROT *rot, setting_t func)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (rot->state.has_set_func & func);
|
||||
return (ROTSTATE(rot)->has_set_func & func);
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@
|
||||
# define DEFAULT_PARALLEL_PORT "/dev/parport0"
|
||||
#endif
|
||||
|
||||
#define CHECK_ROT_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state)
|
||||
#define CHECK_ROT_ARG(r) (!(r) || !(r)->caps || !(ROTSTATE(r)->comm_state))
|
||||
|
||||
|
||||
/*
|
||||
@ -258,7 +258,7 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model)
|
||||
/**
|
||||
* \todo Read the Preferences here!
|
||||
*/
|
||||
rs = &rot->state;
|
||||
rs = ROTSTATE(rot);
|
||||
|
||||
//TODO Allocate new rotport[2]
|
||||
// For now, use the embedded ones
|
||||
@ -345,8 +345,8 @@ 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, rotp,
|
||||
sizeof(rot->state.rotport_deprecated));
|
||||
memcpy(&rs->rotport_deprecated, rotp,
|
||||
sizeof(rs->rotport_deprecated));
|
||||
|
||||
return rot;
|
||||
}
|
||||
@ -386,7 +386,7 @@ int HAMLIB_API rot_open(ROT *rot)
|
||||
}
|
||||
|
||||
caps = rot->caps;
|
||||
rs = &rot->state;
|
||||
rs = ROTSTATE(rot);
|
||||
|
||||
if (rs->comm_state)
|
||||
{
|
||||
@ -520,8 +520,8 @@ int HAMLIB_API rot_open(ROT *rot)
|
||||
|
||||
if (status != RIG_OK)
|
||||
{
|
||||
memcpy(&rot->state.rotport_deprecated, rotp,
|
||||
sizeof(rot->state.rotport_deprecated));
|
||||
memcpy(&rs->rotport_deprecated, rotp,
|
||||
sizeof(rs->rotport_deprecated));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@ -544,8 +544,8 @@ int HAMLIB_API rot_open(ROT *rot)
|
||||
ser_set_rts(rotp, 0);
|
||||
}
|
||||
|
||||
memcpy(&rot->state.rotport_deprecated, rotp,
|
||||
sizeof(rot->state.rotport_deprecated));
|
||||
memcpy(&rs->rotport_deprecated, rotp,
|
||||
sizeof(rs->rotport_deprecated));
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
@ -580,7 +580,7 @@ int HAMLIB_API rot_close(ROT *rot)
|
||||
}
|
||||
|
||||
caps = rot->caps;
|
||||
rs = &rot->state;
|
||||
rs = ROTSTATE(rot);
|
||||
|
||||
if (!rs->comm_state)
|
||||
{
|
||||
@ -632,8 +632,8 @@ int HAMLIB_API rot_close(ROT *rot)
|
||||
|
||||
rs->comm_state = 0;
|
||||
|
||||
memcpy(&rot->state.rotport_deprecated, rotp,
|
||||
sizeof(rot->state.rotport_deprecated));
|
||||
memcpy(&rs->rotport_deprecated, rotp,
|
||||
sizeof(rs->rotport_deprecated));
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
@ -667,7 +667,7 @@ int HAMLIB_API rot_cleanup(ROT *rot)
|
||||
/*
|
||||
* check if they forgot to close the rot
|
||||
*/
|
||||
if (rot->state.comm_state)
|
||||
if (ROTSTATE(rot)->comm_state)
|
||||
{
|
||||
rot_close(rot);
|
||||
}
|
||||
@ -726,11 +726,11 @@ int HAMLIB_API rot_set_position(ROT *rot,
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
azimuth += rot->state.az_offset;
|
||||
elevation += rot->state.el_offset;
|
||||
|
||||
caps = rot->caps;
|
||||
rs = &rot->state;
|
||||
rs = ROTSTATE(rot);
|
||||
|
||||
azimuth += rs->az_offset;
|
||||
elevation += rs->el_offset;
|
||||
|
||||
rot_debug(RIG_DEBUG_VERBOSE, "%s: south_zero=%d \n", __func__, rs->south_zero);
|
||||
|
||||
@ -801,7 +801,7 @@ int HAMLIB_API rot_get_position(ROT *rot,
|
||||
}
|
||||
|
||||
caps = rot->caps;
|
||||
rs = &rot->state;
|
||||
rs = ROTSTATE(rot);
|
||||
|
||||
if (caps->get_position == NULL)
|
||||
{
|
||||
@ -820,8 +820,8 @@ int HAMLIB_API rot_get_position(ROT *rot,
|
||||
rot_debug(RIG_DEBUG_VERBOSE, "%s: south adj to az=%.2f\n", __func__, az);
|
||||
}
|
||||
|
||||
*azimuth = az - rot->state.az_offset;
|
||||
*elevation = el - rot->state.el_offset;
|
||||
*azimuth = az - rs->az_offset;
|
||||
*elevation = el - rs->el_offset;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
@ -1057,6 +1057,8 @@ void * HAMLIB_API rot_data_pointer(ROT *rot, rig_ptrx_t idx)
|
||||
return ROTPORT(rot);
|
||||
case RIG_PTRX_ROTPORT2:
|
||||
return ROTPORT2(rot);
|
||||
case RIG_PTRX_ROTSTATE:
|
||||
return ROTSTATE(rot);
|
||||
default:
|
||||
rot_debug(RIG_DEBUG_ERR, "%s: Invalid data index=%d\n", __func__, idx);
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user