mirror of
https://github.com/Hamlib/Hamlib.git
synced 2024-09-22 10:57:21 +00:00
Revert "Revert "Deprecate hamlib_port_t to hamlib_port_t_deprecated""
Fixing hamlib_port_t deprecation
This reverts commit f696123a3b
.
https://github.com/Hamlib/Hamlib/issues/894
This commit is contained in:
parent
f7ab1e62cc
commit
fab7f4d54c
@ -280,7 +280,7 @@ struct amp_state
|
||||
/*
|
||||
* non overridable fields, internal use
|
||||
*/
|
||||
hamlib_port_t ampport; /*!< Amplifier port (internal use). */
|
||||
hamlib_port_t_deprecated ampport_deprecated; /*!< Amplifier port (internal use). Deprecated */
|
||||
|
||||
int comm_state; /*!< Comm port state, opened/closed. */
|
||||
rig_ptr_t priv; /*!< Pointer to private amplifier state data. */
|
||||
@ -290,6 +290,7 @@ struct amp_state
|
||||
|
||||
gran_t level_gran[RIG_SETTING_MAX]; /*!< Level granularity. */
|
||||
gran_t parm_gran[RIG_SETTING_MAX]; /*!< Parameter granularity. */
|
||||
hamlib_port_t ampport; /*!< Amplifier port (internal use). */
|
||||
};
|
||||
|
||||
|
||||
|
@ -2225,9 +2225,7 @@ typedef struct hamlib_port {
|
||||
} parm; /*!< Port parameter union */
|
||||
int client_port; /*!< client socket port for tcp connection */
|
||||
RIG *rig; /*!< our parent RIG device */
|
||||
|
||||
#ifdef ASYNC_BUG
|
||||
int async; /*!< enable asynchronous data handling if true */
|
||||
int asyncio; /*!< enable asynchronous data handling if true -- async collides with python keyword so _async is used */
|
||||
#if defined(_WIN32)
|
||||
hamlib_async_pipe_t *sync_data_pipe; /*!< pipe data structure for synchronous data */
|
||||
hamlib_async_pipe_t *sync_data_error_pipe; /*!< pipe data structure for synchronous data error codes */
|
||||
@ -2237,11 +2235,84 @@ typedef struct hamlib_port {
|
||||
int fd_sync_error_write; /*!< file descriptor for writing synchronous data error codes */
|
||||
int fd_sync_error_read; /*!< file descriptor for reading synchronous data error codes */
|
||||
#endif
|
||||
#endif
|
||||
} hamlib_port_t;
|
||||
|
||||
|
||||
typedef struct hamlib_port_deprecated {
|
||||
union {
|
||||
rig_port_t rig; /*!< Communication port type */
|
||||
ptt_type_t ptt; /*!< PTT port type */
|
||||
dcd_type_t dcd; /*!< DCD port type */
|
||||
} type;
|
||||
|
||||
int fd; /*!< File descriptor */
|
||||
void *handle; /*!< handle for USB */
|
||||
|
||||
int write_delay; /*!< Delay between each byte sent out, in mS */
|
||||
int post_write_delay; /*!< Delay between each commands send out, in mS */
|
||||
|
||||
struct {
|
||||
int tv_sec, tv_usec;
|
||||
} post_write_date; /*!< hamlib internal use */
|
||||
|
||||
int timeout; /*!< Timeout, in mS */
|
||||
short retry; /*!< Maximum number of retries, 0 to disable */
|
||||
short flushx; /*!< If true flush is done with read instead of TCFLUSH - MicroHam */
|
||||
|
||||
char pathname[HAMLIB_FILPATHLEN]; /*!< Port pathname */
|
||||
|
||||
union {
|
||||
struct {
|
||||
int rate; /*!< Serial baud rate */
|
||||
int data_bits; /*!< Number of data bits */
|
||||
int stop_bits; /*!< Number of stop bits */
|
||||
enum serial_parity_e parity; /*!< Serial parity */
|
||||
enum serial_handshake_e handshake; /*!< Serial handshake */
|
||||
enum serial_control_state_e rts_state; /*!< RTS set state */
|
||||
enum serial_control_state_e dtr_state; /*!< DTR set state */
|
||||
} serial; /*!< serial attributes */
|
||||
|
||||
struct {
|
||||
int pin; /*!< Parallel port pin number */
|
||||
} parallel; /*!< parallel attributes */
|
||||
|
||||
struct {
|
||||
int ptt_bitnum; /*!< Bit number for CM108 GPIO PTT */
|
||||
} cm108; /*!< CM108 attributes */
|
||||
|
||||
struct {
|
||||
int vid; /*!< Vendor ID */
|
||||
int pid; /*!< Product ID */
|
||||
int conf; /*!< Configuration */
|
||||
int iface; /*!< interface */
|
||||
int alt; /*!< alternate */
|
||||
char *vendor_name; /*!< Vendor name (opt.) */
|
||||
char *product; /*!< Product (opt.) */
|
||||
} usb; /*!< USB attributes */
|
||||
|
||||
struct {
|
||||
int on_value; /*!< GPIO: 1 == normal, GPION: 0 == inverted */
|
||||
int value; /*!< Toggle PTT ON or OFF */
|
||||
} gpio; /*!< GPIO attributes */
|
||||
} parm; /*!< Port parameter union */
|
||||
int client_port; /*!< client socket port for tcp connection */
|
||||
RIG *rig; /*!< our parent RIG device */
|
||||
|
||||
int asyncio; /*!< enable asynchronous data handling if true -- async collides with python keyword so _async is used */
|
||||
#if defined(_WIN32)
|
||||
hamlib_async_pipe_t *sync_data_pipe; /*!< pipe data structure for synchronous data */
|
||||
hamlib_async_pipe_t *sync_data_error_pipe; /*!< pipe data structure for synchronous data error codes */
|
||||
#else
|
||||
int fd_sync_write; /*!< file descriptor for writing synchronous data */
|
||||
int fd_sync_read; /*!< file descriptor for reading synchronous data */
|
||||
int fd_sync_error_write; /*!< file descriptor for writing synchronous data error codes */
|
||||
int fd_sync_error_read; /*!< file descriptor for reading synchronous data error codes */
|
||||
#endif
|
||||
} hamlib_port_t_deprecated;
|
||||
//! @endcond
|
||||
|
||||
#if !defined(__APPLE__) || !defined(__cplusplus)
|
||||
typedef hamlib_port_t_deprecated port_t_deprecated;
|
||||
typedef hamlib_port_t port_t;
|
||||
#endif
|
||||
|
||||
@ -2354,19 +2425,20 @@ struct rig_cache {
|
||||
*
|
||||
* It is NOT fine to move fields around as it can break share library offset
|
||||
* As of 2021-03-03 vfo_list is the last known item being reference externally
|
||||
* So any additions or changes to this structure must be after vfo_list.
|
||||
* So any additions or changes to this structure must be at the end of the structure
|
||||
*/
|
||||
struct rig_state {
|
||||
/********* ENSURE ANY NEW ITEMS ARE ADDED AT BOTTOM OF THIS STRUCTURE *********/
|
||||
/*
|
||||
* overridable fields
|
||||
*/
|
||||
// moving the hamlib_port_t to the end of rig_state and making it a pointer
|
||||
// this should allow changes to hamlib_port_t without breaking shared libraries
|
||||
// these will maintain a copy of the new port_t for backwards compatiblity
|
||||
// to these offsets -- note these must stay until a major version update is done
|
||||
hamlib_port_t rigport; /*!< Rig port (internal use). */
|
||||
hamlib_port_t pttport; /*!< PTT port (internal use). */
|
||||
hamlib_port_t dcdport; /*!< DCD port (internal use). */
|
||||
// to these offsets -- note these must stay until a major version update is done like 5.0
|
||||
hamlib_port_t_deprecated rigport_deprecated; /*!< Rig port (internal use). */
|
||||
hamlib_port_t_deprecated pttport_deprecated; /*!< PTT port (internal use). */
|
||||
hamlib_port_t_deprecated dcdport_deprecated; /*!< DCD port (internal use). */
|
||||
|
||||
double vfo_comp; /*!< VFO compensation in PPM, 0.0 to disable */
|
||||
|
||||
@ -2451,6 +2523,7 @@ struct rig_state {
|
||||
|
||||
volatile unsigned int snapshot_packet_sequence_number;
|
||||
|
||||
#define ASYNC_BUG 1
|
||||
volatile int multicast_publisher_run;
|
||||
void *multicast_publisher_priv_data;
|
||||
volatile int async_data_handler_thread_run;
|
||||
@ -2460,6 +2533,11 @@ struct rig_state {
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_t mutex_set_transaction;
|
||||
#endif
|
||||
hamlib_port_t rigport; /*!< Rig port (internal use). */
|
||||
hamlib_port_t pttport; /*!< PTT port (internal use). */
|
||||
hamlib_port_t dcdport; /*!< DCD port (internal use). */
|
||||
/********* DO NOT ADD or CHANGE anything (or than to rename) ABOVE THIS LINE *********/
|
||||
/********* ENSURE ANY NEW ITEMS ARE ADDED AFTER HERE *********/
|
||||
};
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
|
@ -497,15 +497,16 @@ struct rot_state {
|
||||
/*
|
||||
* non overridable fields, internal use
|
||||
*/
|
||||
hamlib_port_t rotport; /*!< Rotator port (internal use). */
|
||||
hamlib_port_t rotport2; /*!< 2nd Rotator port (internal use). */
|
||||
hamlib_port_t_deprecated rotport_deprecated; /*!< Rotator port (internal use). Deprecated */
|
||||
hamlib_port_t_deprecated rotport2_deprecated; /*!< 2nd Rotator port (internal use). Deprecated */
|
||||
|
||||
int comm_state; /*!< Comm port state, i.e. opened or closed. */
|
||||
rig_ptr_t priv; /*!< Pointer to private rotator state data. */
|
||||
rig_ptr_t obj; /*!< Internal use by hamlib++ for event handling. */
|
||||
|
||||
int current_speed; /*!< Current speed 1-100, to be used when no change to speed is requested. */
|
||||
/* etc... */
|
||||
hamlib_port_t rotport; /*!< Rotator port (internal use). */
|
||||
hamlib_port_t rotport2; /*!< 2nd Rotator port (internal use). */
|
||||
};
|
||||
|
||||
|
||||
|
@ -277,6 +277,10 @@ AMP *HAMLIB_API amp_init(amp_model_t amp_model)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
// 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, sizeof(amp->state.ampport_deprecated));
|
||||
|
||||
return amp;
|
||||
}
|
||||
|
@ -1032,6 +1032,8 @@ 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));
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
14
src/iofunc.c
14
src/iofunc.c
@ -222,7 +222,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
||||
#endif
|
||||
|
||||
#ifdef ASYNC_BUG
|
||||
if (p->async)
|
||||
if (p->asyncio)
|
||||
{
|
||||
status = create_sync_data_pipe(p);
|
||||
if (status < 0)
|
||||
@ -932,7 +932,7 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
|
||||
int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
|
||||
{
|
||||
|
||||
if (!p->async)
|
||||
if (!p->asyncio)
|
||||
{
|
||||
return -RIG_EINTERNAL;
|
||||
}
|
||||
@ -942,7 +942,7 @@ int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer,
|
||||
|
||||
int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
|
||||
{
|
||||
if (!p->async)
|
||||
if (!p->asyncio)
|
||||
{
|
||||
return -RIG_EINTERNAL;
|
||||
}
|
||||
@ -1095,7 +1095,7 @@ static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called, direct=%d\n", __func__, direct);
|
||||
|
||||
#ifdef ASYNC_BUG
|
||||
if (!p->async && !direct)
|
||||
if (!p->asyncio && !direct)
|
||||
#else
|
||||
if (!direct)
|
||||
#endif
|
||||
@ -1192,7 +1192,7 @@ static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t
|
||||
int HAMLIB_API read_block(hamlib_port_t *p, unsigned char *rxbuffer, size_t count)
|
||||
{
|
||||
#ifdef ASYNC_BUG
|
||||
return read_block_generic(p, rxbuffer, count, !p->async);
|
||||
return read_block_generic(p, rxbuffer, count, !p->asyncio);
|
||||
#else
|
||||
return read_block_generic(p, rxbuffer, count, 1);
|
||||
#endif
|
||||
@ -1236,7 +1236,7 @@ static int read_string_generic(hamlib_port_t *p,
|
||||
static int minlen = 1; // dynamic minimum length of rig response data
|
||||
|
||||
#ifdef ASYNC_BUG
|
||||
if (!p->async && !direct)
|
||||
if (!p->asyncio && !direct)
|
||||
#else
|
||||
if (!direct)
|
||||
#endif
|
||||
@ -1412,7 +1412,7 @@ int HAMLIB_API read_string(hamlib_port_t *p,
|
||||
int expected_len)
|
||||
{
|
||||
#ifdef ASYNC_BUG
|
||||
return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, expected_len, !p->async);
|
||||
return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, expected_len, !p->asyncio);
|
||||
#else
|
||||
return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, expected_len, 1);
|
||||
#endif
|
||||
|
14
src/rig.c
14
src/rig.c
@ -463,7 +463,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
|
||||
rs->comm_state);
|
||||
rs->rigport.type.rig = caps->port_type; /* default from caps */
|
||||
#if defined(ASYNC_BUG) && defined(HAVE_PTHREAD)
|
||||
rs->rigport.async = 0;
|
||||
rs->rigport.asyncio = 0;
|
||||
#endif
|
||||
|
||||
switch (caps->port_type)
|
||||
@ -677,6 +677,12 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
// 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(&rig->state.rigport_deprecated, &rig->state.rigport, sizeof(rig->state.rigport_deprecated));
|
||||
memcpy(&rig->state.pttport_deprecated, &rig->state.pttport, sizeof(rig->state.pttport_deprecated));
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
|
||||
|
||||
return (rig);
|
||||
}
|
||||
@ -721,7 +727,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
#if defined(ASYNC_BUG) && defined(HAVE_PTHREAD)
|
||||
// Enable async data only if it's enabled through conf settings *and* supported by the backend
|
||||
rs->async_data_enabled = rs->async_data_enabled && caps->async_data_supported;
|
||||
rs->rigport.async = rs->async_data_enabled;
|
||||
rs->rigport.asyncio = rs->async_data_enabled;
|
||||
#endif
|
||||
|
||||
if (strlen(rs->rigport.pathname) > 0)
|
||||
@ -1077,6 +1083,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||
async_data_handler_stop(rig);
|
||||
#endif
|
||||
port_close(&rs->rigport, rs->rigport.type.rig);
|
||||
memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
|
||||
rs->comm_state = 0;
|
||||
RETURNFUNC(status);
|
||||
}
|
||||
@ -1213,6 +1220,7 @@ int HAMLIB_API rig_close(RIG *rig)
|
||||
if (rs->pttport.fd != rs->rigport.fd)
|
||||
{
|
||||
port_close(&rs->pttport, RIG_PORT_SERIAL);
|
||||
memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1228,6 +1236,7 @@ int HAMLIB_API rig_close(RIG *rig)
|
||||
if (rs->pttport.fd != rs->rigport.fd)
|
||||
{
|
||||
port_close(&rs->pttport, RIG_PORT_SERIAL);
|
||||
memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1268,6 +1277,7 @@ int HAMLIB_API rig_close(RIG *rig)
|
||||
if (rs->dcdport.fd != rs->rigport.fd)
|
||||
{
|
||||
port_close(&rs->dcdport, RIG_PORT_SERIAL);
|
||||
memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -330,6 +330,10 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
// 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, sizeof(rot->state.rotport_deprecated));
|
||||
|
||||
return rot;
|
||||
}
|
||||
@ -466,6 +470,7 @@ int HAMLIB_API rot_open(ROT *rot)
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport, sizeof(rot->state.rotport_deprecated));
|
||||
|
||||
add_opened_rot(rot);
|
||||
|
||||
@ -568,6 +573,8 @@ int HAMLIB_API rot_close(ROT *rot)
|
||||
|
||||
rs->comm_state = 0;
|
||||
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport, sizeof(rot->state.rotport_deprecated));
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user