Remove ASYNC_BUG #ifdef blocks as it is all working now

pull/948/head
Mike Black W9MDB 2022-01-28 09:55:48 -06:00
rodzic 78b9ad122e
commit 86c62d5dbb
4 zmienionych plików z 2 dodań i 91 usunięć

Wyświetl plik

@ -2518,7 +2518,6 @@ 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;

Wyświetl plik

@ -57,8 +57,6 @@
#include "gpio.h"
#include "asyncpipe.h"
#ifdef ASYNC_BUG
#if defined(WIN32) && defined(HAVE_WINDOWS_H)
#include <windows.h>
@ -201,7 +199,6 @@ static int create_sync_data_pipe(hamlib_port_t *p)
RETURNFUNC(RIG_OK);
}
#endif
#endif
/**
@ -217,11 +214,8 @@ int HAMLIB_API port_open(hamlib_port_t *p)
ENTERFUNC;
p->fd = -1;
#ifdef ASYNC_BUG
init_sync_data_pipe(p);
#endif
#ifdef ASYNC_BUG
if (p->asyncio)
{
status = create_sync_data_pipe(p);
@ -230,7 +224,6 @@ int HAMLIB_API port_open(hamlib_port_t *p)
RETURNFUNC(status);
}
}
#endif
switch (p->type.rig)
{
@ -241,9 +234,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
{
rig_debug(RIG_DEBUG_ERR, "%s: serial_open(%s) status=%d, err=%s\n", __func__,
p->pathname, status, strerror(errno));
#ifdef ASYNC_BUG
close_sync_data_pipe(p);
#endif
RETURNFUNC(status);
}
@ -257,9 +248,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status != 0)
{
#ifdef ASYNC_BUG
close_sync_data_pipe(p);
#endif
RETURNFUNC(status);
}
@ -273,9 +262,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status != 0)
{
rig_debug(RIG_DEBUG_ERR, "%s: set_dtr status=%d\n", __func__, status);
#ifdef ASYNC_BUG
close_sync_data_pipe(p);
#endif
RETURNFUNC(status);
}
@ -295,9 +282,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status < 0)
{
#ifdef ASYNC_BUG
close_sync_data_pipe(p);
#endif
RETURNFUNC(status);
}
@ -308,9 +293,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status < 0)
{
#ifdef ASYNC_BUG
close_sync_data_pipe(p);
#endif
RETURNFUNC(status);
}
@ -321,9 +304,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status < 0)
{
#ifdef ASYNC_BUG
close_sync_data_pipe(p);
#endif
RETURNFUNC(-RIG_EIO);
}
@ -337,9 +318,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status < 0)
{
#ifdef ASYNC_BUG
close_sync_data_pipe(p);
#endif
RETURNFUNC(status);
}
@ -357,18 +336,14 @@ int HAMLIB_API port_open(hamlib_port_t *p)
if (status < 0)
{
#ifdef ASYNC_BUG
close_sync_data_pipe(p);
#endif
RETURNFUNC(status);
}
break;
default:
#ifdef ASYNC_BUG
close_sync_data_pipe(p);
#endif
RETURNFUNC(-RIG_EINVAL);
}
@ -420,9 +395,7 @@ int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type)
p->fd = -1;
}
#ifdef ASYNC_BUG
close_sync_data_pipe(p);
#endif
RETURNFUNC(ret);
}
@ -433,7 +406,6 @@ int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type)
extern int is_uh_radio_fd(int fd);
#ifdef ASYNC_BUG
static int port_read_sync_data_error_code(hamlib_port_t *p)
{
ssize_t total_bytes_read = 0;
@ -574,7 +546,6 @@ static ssize_t port_read_sync_data_pipe(hamlib_port_t *p, void *buf, size_t coun
{
return port_read_sync_data(p, buf, count);
}
#endif
/* On MinGW32/MSVC/.. the appropriate accessor must be used
* depending on the port type, sigh.
@ -585,12 +556,10 @@ static ssize_t port_read_generic(hamlib_port_t *p, void *buf, size_t count, int
int i;
ssize_t bytes_read;
#if ASYNC_BUG
if (!direct)
{
return port_read_sync_data_pipe(p, buf, count);
}
#endif
/*
* Since WIN32 does its special serial read, we have
@ -752,14 +721,9 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
{
return port_wait_for_data_direct(p);
}
#ifdef ASYNC_BUG
return port_wait_for_data_sync_pipe(p);
#else
RETURNFUNC(-RIG_EINTERNAL);
#endif
}
#ifdef ASYNC_BUG
int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
{
return async_pipe_write(p->sync_data_pipe, txbuffer, count, p->timeout);
@ -769,7 +733,6 @@ int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txb
{
return async_pipe_write(p->sync_data_error_pipe, txbuffer, count, p->timeout);
}
#endif
#else
@ -777,11 +740,7 @@ int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txb
static ssize_t port_read_generic(hamlib_port_t *p, void *buf, size_t count, int direct)
{
#ifdef ASYNC_BUG
int fd = direct ? p->fd : p->fd_sync_read;
#else
int fd = p->fd;
#endif
if (p->type.rig == RIG_PORT_SERIAL && p->parm.serial.data_bits == 7)
{
@ -866,15 +825,9 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
struct timeval tv, tv_timeout;
int result;
#if ASYNC_BUG
fd = direct ? p->fd : p->fd_sync_read;
errorfd = direct ? -1 : p->fd_sync_error_read;
maxfd = (fd > errorfd) ? fd : errorfd;
#else
fd = p->fd;
errorfd = -1;
maxfd = (fd > errorfd) ? fd : errorfd;
#endif
tv_timeout.tv_sec = p->timeout / 1000;
tv_timeout.tv_usec = (p->timeout % 1000) * 1000;
@ -928,7 +881,6 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
return RIG_OK;
}
#ifdef ASYNC_BUG
int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
{
@ -949,7 +901,6 @@ int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txb
return (int) write(p->fd_sync_error_write, txbuffer, count);
}
#endif
#endif
@ -1094,11 +1045,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->asyncio && !direct)
#else
if (!direct)
#endif
{
return -RIG_EINTERNAL;
}
@ -1191,11 +1138,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->asyncio);
#else
return read_block_generic(p, rxbuffer, count, 1);
#endif
}
/**
@ -1235,11 +1178,7 @@ static int read_string_generic(hamlib_port_t *p,
int i = 0;
static int minlen = 1; // dynamic minimum length of rig response data
#ifdef ASYNC_BUG
if (!p->asyncio && !direct)
#else
if (!direct)
#endif
{
return -RIG_EINTERNAL;
}
@ -1411,11 +1350,7 @@ int HAMLIB_API read_string(hamlib_port_t *p,
int flush_flag,
int expected_len)
{
#ifdef ASYNC_BUG
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
}

Wyświetl plik

@ -41,7 +41,6 @@ extern HAMLIB_EXPORT(int) write_block(hamlib_port_t *p,
const unsigned char *txbuffer,
size_t count);
#ifdef ASYNC_BUG
extern HAMLIB_EXPORT(int) write_block_sync(hamlib_port_t *p,
const unsigned char *txbuffer,
size_t count);
@ -49,7 +48,6 @@ extern HAMLIB_EXPORT(int) write_block_sync(hamlib_port_t *p,
extern HAMLIB_EXPORT(int) write_block_sync_error(hamlib_port_t *p,
const unsigned char *txbuffer,
size_t count);
#endif
extern HAMLIB_EXPORT(int) read_string(hamlib_port_t *p,
unsigned char *rxbuffer,

Wyświetl plik

@ -214,12 +214,10 @@ typedef struct async_data_handler_priv_data_s
async_data_handler_args args;
} async_data_handler_priv_data;
#ifdef ASYNC_BUG
static int async_data_handler_start(RIG *rig);
static int async_data_handler_stop(RIG *rig);
void *async_data_handler(void *arg);
#endif
#endif
/*
* track which rig is opened (with rig_open)
@ -462,7 +460,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==0?=%d\n", __func__, __LINE__, &rs->comm_state,
rs->comm_state);
rs->rigport.type.rig = caps->port_type; /* default from caps */
#if defined(ASYNC_BUG) && defined(HAVE_PTHREAD)
#if defined(HAVE_PTHREAD)
rs->rigport.asyncio = 0;
#endif
@ -724,11 +722,9 @@ int HAMLIB_API rig_open(RIG *rig)
rs = &rig->state;
rs->rigport.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.asyncio = rs->async_data_enabled;
#endif
if (strlen(rs->rigport.pathname) > 0)
{
@ -1052,7 +1048,6 @@ int HAMLIB_API rig_open(RIG *rig)
RETURNFUNC(status);
}
#ifdef ASYNC_BUG
status = async_data_handler_start(rig);
if (status < 0)
@ -1061,7 +1056,6 @@ int HAMLIB_API rig_open(RIG *rig)
RETURNFUNC(status);
}
#endif
add_opened_rig(rig);
rs->comm_state = 1;
@ -1079,9 +1073,7 @@ int HAMLIB_API rig_open(RIG *rig)
if (status != RIG_OK)
{
remove_opened_rig(rig);
#ifdef ASYNC_BUG
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;
@ -1195,9 +1187,7 @@ int HAMLIB_API rig_close(RIG *rig)
caps->rig_close(rig);
}
#ifdef ASYNC_BUG
async_data_handler_stop(rig);
#endif
/*
* FIXME: what happens if PTT and rig ports are the same?
@ -6894,7 +6884,6 @@ HAMLIB_EXPORT(void) sync_callback(int lock)
#define MAX_FRAME_LENGTH 1024
#ifdef ASYNC_BUG
static int async_data_handler_start(RIG *rig)
{
struct rig_state *rs = &rig->state;
@ -6908,7 +6897,6 @@ static int async_data_handler_start(RIG *rig)
RETURNFUNC(RIG_OK);
}
#ifdef ASYNC_BUG
#ifdef HAVE_PTHREAD
rs->async_data_handler_thread_run = 1;
@ -6932,13 +6920,11 @@ static int async_data_handler_start(RIG *rig)
RETURNFUNC(-RIG_EINTERNAL);
}
#endif
#endif
#endif // HAVE_PTHREAD
RETURNFUNC(RIG_OK);
}
#ifdef ASYNC_BUG
static int async_data_handler_stop(RIG *rig)
{
struct rig_state *rs = &rig->state;
@ -6975,19 +6961,15 @@ static int async_data_handler_stop(RIG *rig)
RETURNFUNC(RIG_OK);
}
#endif
#endif
void *async_data_handler(void *arg)
{
#ifdef ASYNC_BUG
struct async_data_handler_args_s *args = (struct async_data_handler_args_s *)
arg;
RIG *rig = args->rig;
unsigned char frame[MAX_FRAME_LENGTH];
struct rig_state *rs = &rig->state;
int result;
#endif
rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting async data handler thread\n", __func__);
@ -6995,8 +6977,6 @@ void *async_data_handler(void *arg)
// TODO: add initial support for async in Kenwood kenwood_transaction (+one) functions -> add transaction_active flag usage
// TODO: add initial support for async in Yaesu newcat_get_cmd/set_cmd (+validate) functions -> add transaction_active flag usage
#ifdef ASYNC_BUG
while (rs->async_data_handler_thread_run)
{
int frame_length;
@ -7058,7 +7038,6 @@ void *async_data_handler(void *arg)
}
}
#endif
rig_debug(RIG_DEBUG_VERBOSE, "%s: Stopping async data handler thread\n", __func__);