kopia lustrzana https://github.com/Hamlib/Hamlib
Enable ASYNC and rename async to asynio to avoid python name collision
https://github.com/Hamlib/Hamlib/issues/894pull/948/head
rodzic
a2d5893437
commit
4dfaa03838
|
@ -2225,9 +2225,9 @@ typedef struct hamlib_port {
|
||||||
} parm; /*!< Port parameter union */
|
} parm; /*!< Port parameter union */
|
||||||
int client_port; /*!< client socket port for tcp connection */
|
int client_port; /*!< client socket port for tcp connection */
|
||||||
RIG *rig; /*!< our parent RIG device */
|
RIG *rig; /*!< our parent RIG device */
|
||||||
|
#define ASYNC_BUG 1
|
||||||
#ifdef ASYNC_BUG
|
#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)
|
#if defined(_WIN32)
|
||||||
hamlib_async_pipe_t *sync_data_pipe; /*!< pipe data structure for synchronous data */
|
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 */
|
hamlib_async_pipe_t *sync_data_error_pipe; /*!< pipe data structure for synchronous data error codes */
|
||||||
|
@ -2239,9 +2239,85 @@ typedef struct hamlib_port {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
} hamlib_port_t;
|
} 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 */
|
||||||
|
|
||||||
|
#ifdef ASYNC_BUG
|
||||||
|
int _async; /*!< 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
|
||||||
|
#endif
|
||||||
|
} hamlib_port_t_deprecated;
|
||||||
//! @endcond
|
//! @endcond
|
||||||
|
|
||||||
#if !defined(__APPLE__) || !defined(__cplusplus)
|
#if !defined(__APPLE__) || !defined(__cplusplus)
|
||||||
|
typedef hamlib_port_t_deprecated port_t_deprecated;
|
||||||
typedef hamlib_port_t port_t;
|
typedef hamlib_port_t port_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2364,9 +2440,9 @@ struct rig_state {
|
||||||
// this should allow changes to hamlib_port_t without breaking shared libraries
|
// 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
|
// 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
|
// 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_deprecated rigport_deprecated; /*!< Rig port (internal use). */
|
||||||
hamlib_port_t pttport; /*!< PTT port (internal use). */
|
hamlib_port_t_deprecated pttport_deprecated; /*!< PTT port (internal use). */
|
||||||
hamlib_port_t dcdport; /*!< DCD port (internal use). */
|
hamlib_port_t_deprecated dcdport_deprecated; /*!< DCD port (internal use). */
|
||||||
|
|
||||||
double vfo_comp; /*!< VFO compensation in PPM, 0.0 to disable */
|
double vfo_comp; /*!< VFO compensation in PPM, 0.0 to disable */
|
||||||
|
|
||||||
|
@ -2460,6 +2536,9 @@ struct rig_state {
|
||||||
#ifdef HAVE_PTHREAD
|
#ifdef HAVE_PTHREAD
|
||||||
pthread_mutex_t mutex_set_transaction;
|
pthread_mutex_t mutex_set_transaction;
|
||||||
#endif
|
#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). */
|
||||||
};
|
};
|
||||||
|
|
||||||
//! @cond Doxygen_Suppress
|
//! @cond Doxygen_Suppress
|
||||||
|
|
14
src/iofunc.c
14
src/iofunc.c
|
@ -222,7 +222,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ASYNC_BUG
|
#ifdef ASYNC_BUG
|
||||||
if (p->async)
|
if (p->asyncio)
|
||||||
{
|
{
|
||||||
status = create_sync_data_pipe(p);
|
status = create_sync_data_pipe(p);
|
||||||
if (status < 0)
|
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)
|
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;
|
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)
|
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;
|
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);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called, direct=%d\n", __func__, direct);
|
||||||
|
|
||||||
#ifdef ASYNC_BUG
|
#ifdef ASYNC_BUG
|
||||||
if (!p->async && !direct)
|
if (!p->asyncio && !direct)
|
||||||
#else
|
#else
|
||||||
if (!direct)
|
if (!direct)
|
||||||
#endif
|
#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)
|
int HAMLIB_API read_block(hamlib_port_t *p, unsigned char *rxbuffer, size_t count)
|
||||||
{
|
{
|
||||||
#ifdef ASYNC_BUG
|
#ifdef ASYNC_BUG
|
||||||
return read_block_generic(p, rxbuffer, count, !p->async);
|
return read_block_generic(p, rxbuffer, count, !p->asyncio);
|
||||||
#else
|
#else
|
||||||
return read_block_generic(p, rxbuffer, count, 1);
|
return read_block_generic(p, rxbuffer, count, 1);
|
||||||
#endif
|
#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
|
static int minlen = 1; // dynamic minimum length of rig response data
|
||||||
|
|
||||||
#ifdef ASYNC_BUG
|
#ifdef ASYNC_BUG
|
||||||
if (!p->async && !direct)
|
if (!p->asyncio && !direct)
|
||||||
#else
|
#else
|
||||||
if (!direct)
|
if (!direct)
|
||||||
#endif
|
#endif
|
||||||
|
@ -1412,7 +1412,7 @@ int HAMLIB_API read_string(hamlib_port_t *p,
|
||||||
int expected_len)
|
int expected_len)
|
||||||
{
|
{
|
||||||
#ifdef ASYNC_BUG
|
#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
|
#else
|
||||||
return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, expected_len, 1);
|
return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, expected_len, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -463,7 +463,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
|
||||||
rs->comm_state);
|
rs->comm_state);
|
||||||
rs->rigport.type.rig = caps->port_type; /* default from caps */
|
rs->rigport.type.rig = caps->port_type; /* default from caps */
|
||||||
#if defined(ASYNC_BUG) && defined(HAVE_PTHREAD)
|
#if defined(ASYNC_BUG) && defined(HAVE_PTHREAD)
|
||||||
rs->rigport.async = 0;
|
rs->rigport.asyncio = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (caps->port_type)
|
switch (caps->port_type)
|
||||||
|
@ -721,7 +721,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||||
#if defined(ASYNC_BUG) && defined(HAVE_PTHREAD)
|
#if defined(ASYNC_BUG) && defined(HAVE_PTHREAD)
|
||||||
// Enable async data only if it's enabled through conf settings *and* supported by the backend
|
// 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->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
|
#endif
|
||||||
|
|
||||||
if (strlen(rs->rigport.pathname) > 0)
|
if (strlen(rs->rigport.pathname) > 0)
|
||||||
|
|
Ładowanie…
Reference in New Issue