pull/1878/merge
Nate Bargmann 2025-08-31 20:11:12 -05:00
commit 4c520571df
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: FB2C5130D55A8819
27 zmienionych plików z 34 dodań i 312 usunięć

3
NEWS
Wyświetl plik

@ -14,6 +14,9 @@ Version 5.x -- future
Version 4.7.0
* 2025-12-01 (target)
* POSIX threads are required to build and run Hamlib. Note that it was
actually the case for 4.6.x, but now the configuration step will
fail instead of the compilation.
* Functions rig_get_conf, rot_get_conf, amp_get_conf deprecated;
use *_get_conf2() instead.
* Fix handling of unprintable characters in kenwood.c that broke radios

Wyświetl plik

@ -159,7 +159,7 @@ file. This document introduces hacking the code of Hamlib.
git clone git://git.code.sf.net/p/hamlib/code hamlib
The clone has to only be done the first time.
The clone only has to be done the first time.
After the initial clone, whenever you want to update your local
repository, issue the following command in the root directory of Hamlib:
@ -277,6 +277,9 @@ distributions may differ).
* libtool 2.2.6b+ # libtool --version
* Git for connection to git.code.sf.net/p/hamlib/code
As of Hamlib 4.7, POSIX thread support (pthreads) is required to compile or
run Hamlib.
N.B. Hamlib requires libtool >= 2.2.6b in compliance with CVE-2009-3736.
Optional, but highly recommended:
@ -518,6 +521,7 @@ So far, Hamlib has been tested successfully under the following systems:
* Debian sid mipsel
* Raspbian armhf (Raspberry Pi Debian derivative)
* RedHat i386
* openSUSE (Leap & Tumbleweed)
* Linux ppc
* Slackware i386
* FreeBSD & NetBSD

Wyświetl plik

@ -172,7 +172,7 @@ dnl If pthread support is found, this macro defines HAVE_PTHREAD and
dnl AC_SUBST's PTHREAD_LIBS, PTHREAD_CFLAGS, and PTHREAD_CC making those
dnl variables available in Makefiles.
# macros/ax_pthread.m4
AX_PTHREAD
AX_PTHREAD([], [AC_MSG_ERROR([POSIX threads not found])])
AC_SYS_POSIX_TERMIOS()

Wyświetl plik

@ -178,11 +178,7 @@ typedef struct
int head;
int tail;
int flush; // flush flag for stop_morse
#ifdef _PTHREAD_H
pthread_mutex_t mutex;
#else
int mutex;
#endif
} FIFO_RIG;

Wyświetl plik

@ -24,8 +24,10 @@
#ifndef _RIG_STATE_H
#define _RIG_STATE_H 1
__BEGIN_DECLS
//#include <hamlib/rig.h>
//#include <pthread.h>
__BEGIN_DECLS
/**
* \addtogroup rig

Wyświetl plik

@ -223,9 +223,7 @@ int anytone_init(RIG *rig)
{
STATE(rig)->priv = p;
p->vfo_curr = RIG_VFO_NONE;
#ifdef HAVE_PTHREAD
pthread_mutex_init(&p->mutex, NULL);
#endif
}
}

Wyświetl plik

@ -178,7 +178,6 @@ static void readPacket(int sockfd, char *buf, int buf_len, int expected)
//if (n > 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: buf=%s\n", __func__, buf); }
}
#if defined(HAVE_PTHREAD)
#if 0
typedef struct pstrotator_handler_args_sw
{
@ -245,8 +244,6 @@ static void *pstrotator_handler_start(void *arg)
return NULL;
}
#endif
static int pstrotator_rot_init(ROT *rot)
{
struct pstrotator_rot_priv_data *priv;

Wyświetl plik

@ -40,7 +40,6 @@
extern struct rot_caps pstrotator_caps;
extern struct rot_caps netrotctl_caps;
#if defined(HAVE_PTHREAD)
typedef struct pstrotator_handler_args_sw
{
ROT *rot;
@ -55,8 +54,6 @@ typedef struct pstrotator_handler_priv_data_s
int sockfd2;
} pstrotator_handler_priv_data;
#endif
#endif /* _ROT_PSTROTATOR_H */

Wyświetl plik

@ -301,7 +301,6 @@ int smartsdr_cleanup(RIG *rig)
}
#if 0
#if defined(HAVE_PTHREAD)
typedef struct smartsdr_data_handler_args_s
{
RIG *rig;
@ -370,7 +369,6 @@ static int smartsdr_data_handler_start(RIG *rig)
}
#endif
#endif
/* Example response to "sub slice 0"
511+511+35

Wyświetl plik

@ -9049,7 +9049,6 @@ int icom_mW2power(RIG *rig, float *power, unsigned int mwpower, freq_t freq,
RETURNFUNC(RIG_OK);
}
#if defined(HAVE_PTHREAD)
static int icom_parse_spectrum_frame(RIG *rig, size_t length,
const unsigned char *frame_data)
{
@ -9209,7 +9208,6 @@ static int icom_parse_spectrum_frame(RIG *rig, size_t length,
RETURNFUNC(RIG_OK);
}
#endif
int icom_is_async_frame(RIG *rig, size_t frame_length,
const unsigned char *frame)
@ -9262,9 +9260,7 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
// TODO: Disable cache timeout for frequency after first transceive packet once we figure out how to get active VFO reliably with transceive updates
// TODO: rig_set_cache_timeout_ms(rig, HAMLIB_CACHE_FREQ, HAMLIB_CACHE_ALWAYS);
freq_t freq = (freq_t) from_bcd(frame + 5, (priv->civ_731_mode ? 4 : 5) * 2);
#if defined(HAVE_PTHREAD)
rig_fire_freq_event(rig, RIG_VFO_CURR, freq);
#endif
#if 0
@ -9284,9 +9280,7 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
// TODO: Disable cache timeout for frequency after first transceive packet once we figure out how to get active VFO reliably with transceive updates
// TODO: rig_set_cache_timeout_ms(rig, HAMLIB_CACHE_MODE, HAMLIB_CACHE_ALWAYS);
icom2rig_mode(rig, frame[5], frame[6], &mode, &width);
#if defined(HAVE_PTHREAD)
rig_fire_mode_event(rig, RIG_VFO_CURR, mode, width);
#endif
if (rs->use_cached_mode != 1)
{
@ -9297,8 +9291,6 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
break;
#if defined(HAVE_PTHREAD)
case C_CTL_SCP:
if (frame[5] == S_SCP_DAT)
{
@ -9306,7 +9298,6 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
}
break;
#endif
default:
rig_debug(RIG_DEBUG_VERBOSE, "%s: transceive cmd unsupported %#2.2x\n",

Wyświetl plik

@ -354,25 +354,13 @@ RIG_MODEL(RIG_MODEL_TT565),
.rig_close = tt565_close,
.set_freq = tt565_set_freq,
#if defined(HAVE_PTHREAD)
.get_freq = tt565_get_freq_cache,
#else
.get_freq = tt565_get_freq,
#endif
.set_vfo = tt565_set_vfo,
.get_vfo = tt565_get_vfo,
.set_mode = tt565_set_mode,
#if defined(HAVE_PTHREAD)
.get_mode = tt565_get_mode_cache,
#else
.get_mode = tt565_get_mode,
#endif
.set_split_vfo = tt565_set_split_vfo,
#if defined(HAVE_PTHREAD)
.get_split_vfo = tt565_get_split_vfo_cache,
#else
.get_split_vfo = tt565_get_split_vfo,
#endif
.set_level = tt565_set_level,
.get_level = tt565_get_level,
.set_mem = tt565_set_mem,

Wyświetl plik

@ -27,9 +27,7 @@
#include <sys/ioctl.h>
#endif
#ifdef HAVE_PTHREAD
#include <pthread.h>
#endif
#include "hamlib/rotator.h"
#include "hamlib/rot_state.h"
@ -84,9 +82,7 @@ static int ars_set_position_sync(ROT *rot, azimuth_t az, elevation_t el);
static int ars_set_position(ROT *rot, azimuth_t az, elevation_t el);
static int ars_get_position(ROT *rot, azimuth_t *az, elevation_t *el);
#ifdef HAVE_PTHREAD
static void *handle_set_position(void *);
#endif
/* ************************************************************************* */
@ -193,7 +189,6 @@ ars_open(ROT *rot)
/* make it idle, and known state */
ars_stop(rot);
#ifdef HAVE_PTHREAD
{
struct ars_priv_data *priv = (struct ars_priv_data *)ROTSTATE(rot)->priv;
pthread_attr_t attr;
@ -212,7 +207,6 @@ ars_open(ROT *rot)
return -RIG_ENOMEM;
}
}
#endif
return RIG_OK;
}
@ -220,11 +214,9 @@ ars_open(ROT *rot)
int
ars_close(ROT *rot)
{
#ifdef HAVE_PTHREAD
struct ars_priv_data *priv = (struct ars_priv_data *)ROTSTATE(rot)->priv;
pthread_cancel(priv->thread);
#endif
/* leave it in safe state */
ars_stop(rot);
@ -241,9 +233,7 @@ ars_stop(ROT *rot)
rig_debug(RIG_DEBUG_TRACE, "%s called, brake was %s\n", __func__,
priv->brake_off ? "OFF" : "ON");
#ifdef HAVE_PTHREAD
priv->set_pos_active = 0;
#endif
par_lock(pport);
@ -422,7 +412,6 @@ static int angle_in_range(float angle, float angle_base, float range)
/*
* Thread handler
*/
#ifdef HAVE_PTHREAD
static void *handle_set_position(void *arg)
{
ROT *rot = (ROT *) arg;
@ -453,7 +442,6 @@ static void *handle_set_position(void *arg)
return NULL;
}
#endif
/*
* ars_set_position_sync() is synchronous.
@ -583,7 +571,6 @@ ars_set_position_sync(ROT *rot, azimuth_t az, elevation_t el)
int
ars_set_position(ROT *rot, azimuth_t az, elevation_t el)
{
#ifdef HAVE_PTHREAD
struct ars_priv_data *priv = (struct ars_priv_data *)ROTSTATE(rot)->priv;
/* will be picked by handle_set_position() next polling tick */
@ -592,9 +579,6 @@ ars_set_position(ROT *rot, azimuth_t az, elevation_t el)
priv->set_pos_active = 1;
return RIG_OK;
#else
return ars_set_position_sync(rot, az, el);
#endif
}
static int comparunsigned(const void *a, const void *b)

Wyświetl plik

@ -30,12 +30,10 @@ struct ars_priv_data {
int curr_move;
unsigned char pp_control;
unsigned char pp_data;
#ifdef HAVE_PTHREAD
pthread_t thread;
int set_pos_active;
azimuth_t target_az;
elevation_t target_el;
#endif
};
extern const struct rot_caps rci_az_rot_caps;

Wyświetl plik

@ -39,9 +39,7 @@
#include <stdio.h>
#include <errno.h>
#ifdef HAVE_PTHREAD
# include <pthread.h>
#endif
#include <pthread.h>
#include "hamlib/rig.h"
#include "hamlib/rig_state.h"
@ -52,7 +50,6 @@
#define CHECK_RIG_ARG(r) (!(r) || !(r)->caps || !STATE(r)->comm_state)
#ifdef HAVE_PTHREAD
typedef struct rig_poll_routine_args_s
{
RIG *rig;
@ -362,8 +359,6 @@ int rig_poll_routine_stop(RIG *rig)
RETURNFUNC(RIG_OK);
}
#endif
/**
* \brief set the callback for freq events
* \param rig The rig handle
@ -609,7 +604,6 @@ int HAMLIB_API rig_get_trn(RIG *rig, int *trn)
RETURNFUNC(-RIG_EDEPRECATED);
}
#if defined(HAVE_PTHREAD)
int rig_fire_freq_event(RIG *rig, vfo_t vfo, freq_t freq)
{
ENTERFUNC;
@ -648,9 +642,7 @@ int rig_fire_freq_event(RIG *rig, vfo_t vfo, freq_t freq)
RETURNFUNC(0);
}
#endif
#if defined(HAVE_PTHREAD)
int rig_fire_mode_event(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
ENTERFUNC;
@ -676,10 +668,8 @@ int rig_fire_mode_event(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
RETURNFUNC(0);
}
#endif
#if defined(HAVE_PTHREAD)
int rig_fire_vfo_event(RIG *rig, vfo_t vfo)
{
struct rig_cache *cachep = CACHE(rig);
@ -699,10 +689,8 @@ int rig_fire_vfo_event(RIG *rig, vfo_t vfo)
RETURNFUNC(0);
}
#endif
#if defined(HAVE_PTHREAD)
int rig_fire_ptt_event(RIG *rig, vfo_t vfo, ptt_t ptt)
{
struct rig_cache *cachep = CACHE(rig);
@ -723,10 +711,8 @@ int rig_fire_ptt_event(RIG *rig, vfo_t vfo, ptt_t ptt)
RETURNFUNC(0);
}
#endif
#if defined(HAVE_PTHREAD)
int rig_fire_dcd_event(RIG *rig, vfo_t vfo, dcd_t dcd)
{
ENTERFUNC;
@ -743,10 +729,8 @@ int rig_fire_dcd_event(RIG *rig, vfo_t vfo, dcd_t dcd)
RETURNFUNC(0);
}
#endif
#if defined(HAVE_PTHREAD)
int rig_fire_pltune_event(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode,
pbwidth_t *width)
{
@ -764,10 +748,8 @@ int rig_fire_pltune_event(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode,
RETURNFUNC(RIG_OK);
}
#endif
#if defined(HAVE_PTHREAD)
static int print_spectrum_line(char *str, size_t length,
struct rig_spectrum_line *line)
{
@ -825,10 +807,8 @@ static int print_spectrum_line(char *str, size_t length,
return c;
}
#endif
#if defined(HAVE_PTHREAD)
int rig_fire_spectrum_event(RIG *rig, struct rig_spectrum_line *line)
{
ENTERFUNC;
@ -850,6 +830,5 @@ int rig_fire_spectrum_event(RIG *rig, struct rig_spectrum_line *line)
RETURNFUNC(RIG_OK);
}
#endif
/** @} */

Wyświetl plik

@ -10,10 +10,8 @@ void initFIFO(FIFO_RIG *fifo)
{
fifo->head = 0;
fifo->tail = 0;
#ifdef _PTHREAD_H
static pthread_mutex_t t = PTHREAD_MUTEX_INITIALIZER;
fifo->mutex = t;
#endif
}
void resetFIFO(FIFO_RIG *fifo)
@ -27,9 +25,7 @@ void resetFIFO(FIFO_RIG *fifo)
// return -RIG error if overflow
int push(FIFO_RIG *fifo, const char *msg)
{
#ifdef _PTHREAD_H
pthread_mutex_lock(&fifo->mutex);
#endif
int len = strlen(msg);
for (int i = 0; i < len; ++i)
@ -59,9 +55,7 @@ int push(FIFO_RIG *fifo, const char *msg)
fifo->tail = (fifo->tail + 1) % HAMLIB_FIFO_SIZE;
}
#ifdef _PTHREAD_H
pthread_mutex_unlock(&fifo->mutex);
#endif
return RIG_OK;
}
@ -75,9 +69,7 @@ int peek(FIFO_RIG *fifo)
if (fifo->tail == fifo->head) { return -1; }
#ifdef _PTHREAD_H
pthread_mutex_lock(&fifo->mutex);
#endif
char c = fifo->data[fifo->head];
#if 0
@ -91,9 +83,7 @@ int peek(FIFO_RIG *fifo)
fifo->tail);
#endif
#ifdef _PTHREAD_H
pthread_mutex_unlock(&fifo->mutex);
#endif
return c;
}
@ -101,9 +91,7 @@ int pop(FIFO_RIG *fifo)
{
if (fifo->tail == fifo->head) { return -1; }
#ifdef _PTHREAD_H
pthread_mutex_lock(&fifo->mutex);
#endif
char c = fifo->data[fifo->head];
#if 0
@ -117,9 +105,7 @@ int pop(FIFO_RIG *fifo)
#endif
fifo->head = (fifo->head + 1) % HAMLIB_FIFO_SIZE;
#ifdef _PTHREAD_H
pthread_mutex_unlock(&fifo->mutex);
#endif
return c;
}

Wyświetl plik

@ -88,18 +88,12 @@ static int uh_wkey_in_use;
static int statusbyte = 0;
#ifdef HAVE_PTHREAD
#include <pthread.h>
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_t readthread;
#define getlock() if (pthread_mutex_lock(&mutex)) perror("GETLOCK:")
#define freelock() if (pthread_mutex_unlock(&mutex)) perror("FREELOCK:")
#else
#define getlock()
#define freelock()
#endif
#if defined(HAVE_SELECT)
//
@ -108,7 +102,7 @@ static pthread_t readthread;
static time_t lastbeat = 0;
#endif
#if defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT)
#if defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT)
static time_t starttime;
#define TIME ((int) (time(NULL) - starttime))
@ -176,10 +170,8 @@ static void close_microham()
TRACE("%10d:Closing MicroHam device\n", TIME);
uh_is_initialized = 0;
#ifdef HAVE_PTHREAD
// wait for read_device thread to finish
pthread_join(readthread, NULL);
#endif
close_all_files();
}
@ -717,7 +709,7 @@ static void writeControl(const unsigned char *data, int len)
}
#if defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT)
#if defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT)
//
// send a heartbeat and record time
// The "last heartbeat" time is recorded in a global variable
@ -733,7 +725,7 @@ static void heartbeat()
writeControl(seq, 2);
lastbeat = time(NULL);
}
#endif /* defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) */
#endif /* defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) */
#if defined(HAVE_SELECT)
@ -770,7 +762,7 @@ static void *read_device(void *p)
}
#if defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT)
#if defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT)
//
// This is the right place to ensure that a heartbeat is sent
@ -906,7 +898,7 @@ static void *read_device(void *p)
*/
static void start_thread()
{
#if defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT)
#if defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT)
/*
* Find a microHam device and open serial port to it.
* If successful, create sockets for doing I/O from within hamlib

Wyświetl plik

@ -23,20 +23,15 @@
#ifndef _MISC_H
#define _MISC_H 1
#include "hamlib/rig.h"
#include "hamlib/config.h"
#include "hamlib/rig.h"
/*
*/
#ifdef HAVE_PTHREAD
#include <pthread.h>
#define set_transaction_active(rig) {pthread_mutex_lock(&STATE(rig)->mutex_set_transaction);STATE(rig)->transaction_active = 1;}
#define set_transaction_inactive(rig) {STATE(rig)->transaction_active = 0;pthread_mutex_unlock(&STATE(rig)->mutex_set_transaction);}
#else
#define set_transaction_active(rig) {STATE(rig)->transaction_active = 1;}
#define set_transaction_inactive(rig) {STATE(rig)->transaction_active = 0;}
#endif
__BEGIN_DECLS

Wyświetl plik

@ -1,18 +1,9 @@
#include "hamlib/config.h"
#if defined(HAVE_PTHREAD)
#include <pthread.h>
#endif
#ifdef HAVE_PTHREAD
#define MUTEX(var) static pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER
#define MUTEX_LOCK(var) pthread_mutex_lock(&var)
#define MUTEX_UNLOCK(var) pthread_mutex_unlock(&var)
#else
#warning NOT PTHREAD
#define MUTEX(var)
#define MUTEX_LOCK(var)
#define MUTEX_UNLOCK(var)
#endif
extern int MUTEX_CHECK(pthread_mutex_t *m);

Wyświetl plik

@ -124,9 +124,7 @@ typedef struct multicast_publisher_args_s
int data_read_fd;
#endif
#ifdef HAVE_PTHREAD
pthread_mutex_t write_lock;
#endif
} multicast_publisher_args;
typedef struct multicast_publisher_priv_data_s
@ -510,9 +508,9 @@ int network_close(hamlib_port_t *rp)
}
//! @endcond
extern void sync_callback(int lock);
//TODO See defn in rig.c
//extern void sync_callback(int lock);
#ifdef HAVE_PTHREAD
//! @cond Doxygen_Suppress
#define MULTICAST_DATA_PIPE_TIMEOUT_MILLIS 1000
@ -1952,5 +1950,4 @@ int network_multicast_receiver_stop(RIG *rig)
RETURNFUNC(RIG_OK);
}
#endif
/** @} */

Wyświetl plik

@ -191,7 +191,6 @@ const char hamlib_copyright[231] = /* hamlib 1.2 ABI specifies 231 bytes */
MUTEX(morse_mutex);
#ifdef HAVE_PTHREAD
// returns true if mutex is busy
int MUTEX_CHECK(pthread_mutex_t *m)
{
@ -204,9 +203,6 @@ int MUTEX_CHECK(pthread_mutex_t *m)
return trylock == EBUSY;
}
#else
#define MUTEX_CHECK(var) 0
#endif
/*
@ -254,7 +250,6 @@ static const char *const rigerror_table[] =
#define ERROR_TBL_SZ (sizeof(rigerror_table)/sizeof(char *))
#if defined(HAVE_PTHREAD)
typedef struct async_data_handler_args_s
{
RIG *rig;
@ -269,9 +264,7 @@ typedef struct async_data_handler_priv_data_s
static int async_data_handler_start(RIG *rig);
static int async_data_handler_stop(RIG *rig);
static void *async_data_handler(void *arg);
#endif
#if defined(HAVE_PTHREAD)
typedef struct morse_data_handler_args_s
{
RIG *rig;
@ -289,7 +282,6 @@ static int morse_data_handler_start(RIG *rig);
static int morse_data_handler_stop(RIG *rig);
int morse_data_handler_set_keyspd(RIG *rig, int keyspd);
static void *morse_data_handler(void *arg);
#endif
/*
* track which rig is opened (with rig_open)
@ -641,9 +633,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
* TODO: read the Preferences here!
*/
rs = STATE(rig);
#if defined(HAVE_PTHREAD)
pthread_mutex_init(&rs->mutex_set_transaction, NULL);
#endif
//TODO Allocate and link ports
// For now, use the embedded ones
@ -680,9 +670,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
rs->comm_state);
#endif
rp->type.rig = caps->port_type; /* default from caps */
#if defined(HAVE_PTHREAD)
rp->asyncio = 0;
#endif
switch (caps->port_type)
{
@ -1547,8 +1535,6 @@ int HAMLIB_API rig_open(RIG *rig)
if (skip_init) { RETURNFUNC2(RIG_OK); }
#if defined(HAVE_PTHREAD)
status = async_data_handler_start(rig);
if (status < 0)
@ -1572,8 +1558,6 @@ int HAMLIB_API rig_open(RIG *rig)
}
}
#endif
if (rs->auto_disable_screensaver)
{
// try to turn off the screensaver if possible
@ -1645,7 +1629,6 @@ int HAMLIB_API rig_open(RIG *rig)
rig_flush_force(rp, 1);
rs->timeout = timesave;
#if defined(HAVE_PTHREAD)
enum multicast_item_e items = RIG_MULTICAST_POLL | RIG_MULTICAST_TRANSCEIVE
| RIG_MULTICAST_SPECTRUM;
retval = network_multicast_publisher_start(rig, rs->multicast_data_addr,
@ -1679,8 +1662,6 @@ int HAMLIB_API rig_open(RIG *rig)
// we will consider this non-fatal for now
}
#endif
rs->comm_status = RIG_COMM_STATUS_OK;
add_opened_rig(rig);
@ -1732,8 +1713,6 @@ int HAMLIB_API rig_close(RIG *rig)
rs->comm_status = RIG_COMM_STATUS_DISCONNECTED;
#if defined(HAVE_PTHREAD)
if (!skip_init)
{
morse_data_handler_stop(rig);
@ -1743,8 +1722,6 @@ int HAMLIB_API rig_close(RIG *rig)
network_multicast_publisher_stop(rig);
}
#endif
// Let the backend say 73 to the rig.
// and ignore the return code.
if (caps->rig_close)
@ -8394,13 +8371,12 @@ int HAMLIB_API rig_cookie(RIG *rig, enum cookie_e cookie_cmd, char *cookie,
return ret;
}
#if defined(HAVE_PTHREAD)
//TODO FIX THIS!!!! (presently unused)
#if 0
static pthread_mutex_t initializer = PTHREAD_MUTEX_INITIALIZER;
#endif
HAMLIB_EXPORT(void) sync_callback(int lock)
{
#if defined(HAVE_PTHREAD)
pthread_mutex_t client_lock = initializer;
if (lock)
@ -8414,12 +8390,11 @@ HAMLIB_EXPORT(void) sync_callback(int lock)
pthread_mutex_unlock(&client_lock);
}
#endif
}
#endif
void rig_lock(RIG *rig, int lock)
{
#if defined(HAVE_PTHREAD)
struct rig_state *rs = STATE(rig);
@ -8434,8 +8409,6 @@ void rig_lock(RIG *rig, int lock)
pthread_mutex_unlock(&rs->api_mutex);
}
#endif
}
@ -8444,7 +8417,6 @@ void rig_lock(RIG *rig, int lock)
#define MAX_FRAME_LENGTH 1024
#if defined(HAVE_PTHREAD)
static int async_data_handler_start(RIG *rig)
{
struct rig_state *rs = STATE(rig);
@ -8486,9 +8458,7 @@ static int async_data_handler_start(RIG *rig)
RETURNFUNC(RIG_OK);
}
#endif
#if defined(HAVE_PTHREAD)
static int morse_data_handler_start(RIG *rig)
{
struct rig_state *rs = STATE(rig);
@ -8526,10 +8496,8 @@ static int morse_data_handler_start(RIG *rig)
RETURNFUNC(RIG_OK);
}
#endif
#if defined(HAVE_PTHREAD)
static int async_data_handler_stop(RIG *rig)
{
struct rig_state *rs = STATE(rig);
@ -8568,9 +8536,7 @@ static int async_data_handler_stop(RIG *rig)
RETURNFUNC(RIG_OK);
}
#endif
#if defined(HAVE_PTHREAD)
static int morse_data_handler_stop(RIG *rig)
{
struct rig_state *rs = STATE(rig);
@ -8624,9 +8590,7 @@ static int morse_data_handler_stop(RIG *rig)
RETURNFUNC(RIG_OK);
}
#endif
#if defined(HAVE_PTHREAD)
static void *async_data_handler(void *arg)
{
struct async_data_handler_args_s *args = (struct async_data_handler_args_s *)
@ -8720,9 +8684,7 @@ again:
pthread_exit(NULL);
return NULL;
}
#endif
#if defined(HAVE_PTHREAD)
static void *morse_data_handler(void *arg)
{
struct morse_data_handler_args_s *args =
@ -8865,7 +8827,6 @@ static void *morse_data_handler(void *arg)
pthread_exit(NULL);
return NULL;
}
#endif
HAMLIB_EXPORT(int) rig_password(RIG *rig, const char *key1)
@ -9064,7 +9025,6 @@ HAMLIB_EXPORT(int) rig_is_model(RIG *rig, rig_model_t model)
}
#if defined(HAVE_PTHREAD)
int morse_data_handler_set_keyspd(RIG *rig, int keyspd)
{
struct rig_state *rs = STATE(rig);
@ -9074,7 +9034,6 @@ int morse_data_handler_set_keyspd(RIG *rig, int keyspd)
rig_debug(RIG_DEBUG_VERBOSE, "%s: keyspd=%d\n", __func__, keyspd);
return RIG_OK;
}
#endif
/**
* \brief Get the address of a Hamlib data structure

Wyświetl plik

@ -96,7 +96,6 @@ int HAMLIB_API rig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|| vfo == RIG_VFO_CURR
|| vfo == STATE(rig)->current_vfo)
{
#if defined(HAVE_PTHREAD)
if (level == RIG_LEVEL_KEYSPD)
{
@ -104,7 +103,6 @@ int HAMLIB_API rig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
morse_data_handler_set_keyspd(rig, val.i);
}
#endif
retcode = caps->set_level(rig, vfo, level, val);
rig_lock(rig, 0);
return retcode;

Wyświetl plik

@ -72,11 +72,9 @@ extern int read_history();
/* Hash table implementation See: http://uthash.sourceforge.net/ */
#include "uthash.h"
#ifdef HAVE_PTHREAD
# include <pthread.h>
#include <pthread.h>
static pthread_mutex_t amp_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
#define STR1(S) #S
#define STR(S) STR1(S)
@ -1339,9 +1337,7 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc)
* mutex locking needed because ampctld is multithreaded
* and hamlib is not MT-safe
*/
#ifdef HAVE_PTHREAD
pthread_mutex_lock(&amp_mutex);
#endif
if (!prompt)
{
@ -1389,9 +1385,7 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc)
"");
#endif
#ifdef HAVE_PTHREAD
pthread_mutex_unlock(&amp_mutex);
#endif
if (retcode == -RIG_EIO) { return retcode; }

Wyświetl plik

@ -54,9 +54,7 @@
# include <netdb.h>
#endif
#ifdef HAVE_PTHREAD
# include <pthread.h>
#endif
#include <pthread.h>
#include "hamlib/amplifier.h"
@ -168,10 +166,8 @@ int main(int argc, char *argv[])
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
#ifdef HAVE_PTHREAD
pthread_t thread;
pthread_attr_t attr;
#endif
struct handle_data *arg;
#ifdef SIGPIPE
#if HAVE_SIGACTION
@ -557,7 +553,6 @@ int main(int argc, char *argv[])
host,
serv);
#ifdef HAVE_PTHREAD
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
@ -569,9 +564,6 @@ int main(int argc, char *argv[])
break;
}
#else
handle_socket(arg);
#endif
}
while (retcode == 0);
@ -676,9 +668,7 @@ handle_exit:
#endif
free(arg);
#ifdef HAVE_PTHREAD
pthread_exit(NULL);
#endif
return NULL;
}

Wyświetl plik

@ -64,9 +64,7 @@
# include <netdb.h>
#endif
#ifdef HAVE_PTHREAD
# include <pthread.h>
#endif
#include <pthread.h>
#include "hamlib/rig.h"
#include "misc.h"
@ -129,9 +127,7 @@ void *handle_socket(void *arg);
void usage(void);
#ifdef HAVE_PTHREAD
static unsigned client_count;
#endif
static RIG *my_rig; /* handle to rig (instance) */
static volatile int rig_opened = 0;
@ -159,7 +155,6 @@ static int bind_all = 0;
void mutex_rigctld(int lock)
{
#ifdef HAVE_PTHREAD
static pthread_mutex_t client_lock = PTHREAD_MUTEX_INITIALIZER;
if (lock)
@ -173,7 +168,6 @@ void mutex_rigctld(int lock)
pthread_mutex_unlock(&client_lock);
}
#endif
}
#ifdef WIN32
@ -273,10 +267,8 @@ int main(int argc, char *argv[])
struct sigaction act;
#endif
#ifdef HAVE_PTHREAD
pthread_t thread;
pthread_attr_t attr;
#endif
struct handle_data *arg;
int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
int i;
@ -1070,7 +1062,6 @@ int main(int argc, char *argv[])
host,
serv);
#ifdef HAVE_PTHREAD
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
@ -1082,16 +1073,12 @@ int main(int argc, char *argv[])
break;
}
#else
handle_socket(arg);
#endif
}
}
while (!ctrl_c);
rig_debug(RIG_DEBUG_VERBOSE, "%s: while loop done\n", __func__);
#ifdef HAVE_PTHREAD
/* allow threads to finish current action */
mutex_rigctld(1);
@ -1107,9 +1094,6 @@ int main(int argc, char *argv[])
#endif
rig_close(my_rig);
mutex_rigctld(0);
#else
rig_close(my_rig); /* close port */
#endif
rig_cleanup(my_rig); /* if you care about memory */
@ -1185,7 +1169,6 @@ void *handle_socket(void *arg)
goto handle_exit;
}
#ifdef HAVE_PTHREAD
mutex_rigctld(1);
++client_count;
@ -1206,19 +1189,6 @@ void *handle_socket(void *arg)
#endif
mutex_rigctld(0);
#else
mutex_rigctld(1);
retcode = rig_open(my_rig);
mutex_rigctld(0);
if (RIG_OK == retcode && verbose > RIG_DEBUG_ERR)
{
printf("Opened rig model %d, '%s'\n",
my_rig->caps->rig_model,
my_rig->caps->model_name);
}
#endif
if (my_rig->caps->get_powerstat)
{
@ -1314,21 +1284,16 @@ void *handle_socket(void *arg)
}
while (!ctrl_c && (retcode == RIG_OK || RIG_IS_SOFT_ERRCODE(retcode)));
#if defined(HAVE_PTHREAD)
mutex_rigctld(1);
if (rigctld_idle && client_count == 1)
#else
if (rigctld_idle)
#endif
{
rig_close(my_rig);
if (verbose > RIG_DEBUG_ERR) { printf("Closed rig model %s. Will reopen for new clients\n", my_rig->caps->model_name); }
}
#ifdef HAVE_PTHREAD
--client_count;
mutex_rigctld(0);
if (rigctld_idle && client_count > 0) { printf("%u client%s still connected so rig remains open\n", client_count, client_count > 1 ? "s" : ""); }
@ -1349,17 +1314,6 @@ void *handle_socket(void *arg)
}
mutex_rigctld(0);
#endif
#else
rig_close(my_rig);
if (verbose > RIG_DEBUG_ERR)
{
printf("Closed rig model %d, '%s - will reopen for new clients'\n",
my_rig->caps->rig_model,
my_rig->caps->model_name);
}
#endif
if ((retcode = getnameinfo((struct sockaddr const *)&handle_data_arg->cli_addr,
@ -1404,9 +1358,7 @@ handle_exit:
free(arg);
#ifdef HAVE_PTHREAD
pthread_exit(NULL);
#endif
return NULL;
}

Wyświetl plik

@ -68,9 +68,7 @@
# include <netdb.h>
#endif
#ifdef HAVE_PTHREAD
# include <pthread.h>
#endif
#include <pthread.h>
#include "hamlib/rig.h"
#include "misc.h"
@ -132,10 +130,7 @@ struct handle_data
void *handle_socket(void *arg);
void usage(void);
#ifdef HAVE_PTHREAD
static unsigned client_count;
#endif
static RIG *my_rig; /* handle to rig (instance) */
static volatile int rig_opened = 0;
@ -163,7 +158,6 @@ static int rigctld_idle =
void mutex_rigctld(int lock)
{
#ifdef HAVE_PTHREAD
static pthread_mutex_t client_lock = PTHREAD_MUTEX_INITIALIZER;
if (lock)
@ -177,7 +171,6 @@ void mutex_rigctld(int lock)
pthread_mutex_unlock(&client_lock);
}
#endif
}
#ifdef WIN32
@ -273,10 +266,8 @@ int main(int argc, char *argv[])
struct sigaction act;
#endif
#ifdef HAVE_PTHREAD
pthread_t thread;
pthread_attr_t attr;
#endif
struct handle_data *arg;
int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
int i;
@ -980,7 +971,6 @@ int main(int argc, char *argv[])
host,
serv);
#ifdef HAVE_PTHREAD
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
@ -992,16 +982,12 @@ int main(int argc, char *argv[])
break;
}
#else
handle_socket(arg);
#endif
}
}
while (!ctrl_c);
rig_debug(RIG_DEBUG_VERBOSE, "%s: while loop done\n", __func__);
#ifdef HAVE_PTHREAD
/* allow threads to finish current action */
mutex_rigctld(1);
@ -1012,9 +998,6 @@ int main(int argc, char *argv[])
rig_close(my_rig);
mutex_rigctld(0);
#else
rig_close(my_rig); /* close port */
#endif
network_multicast_publisher_stop(my_rig);
@ -1088,7 +1071,6 @@ void *handle_socket(void *arg)
goto handle_exit;
}
#ifdef HAVE_PTHREAD
mutex_rigctld(1);
++client_count;
@ -1109,19 +1091,6 @@ void *handle_socket(void *arg)
#endif
mutex_rigctld(0);
#else
mutex_rigctld(1);
retcode = rig_open(my_rig);
mutex_rigctld(1);
if (RIG_OK == retcode && verbose > RIG_DEBUG_ERR)
{
printf("Opened rig model %d, '%s'\n",
my_rig->caps->rig_model,
my_rig->caps->model_name);
}
#endif
if (my_rig->caps->get_powerstat)
{
@ -1316,23 +1285,18 @@ void *handle_socket(void *arg)
client_done:
#if defined(HAVE_PTHREAD)
if (rigctld_idle && client_count == 1)
#else
if (rigctld_idle)
#endif
{
rig_close(my_rig);
if (verbose > RIG_DEBUG_ERR) { printf("Closed rig model %s. Will reopen for new clients\n", my_rig->caps->model_name); }
}
#ifdef HAVE_PTHREAD
mutex_rigctld(1);
--client_count;
if (rigctld_idle && client_count > 0) { printf("%u client%s still connected so rig remains open\n", client_count, client_count > 1 ? "s" : ""); }
mutex_rigctld(0);
#if 0
mutex_rigctld(1);
@ -1351,17 +1315,6 @@ client_done:
}
mutex_rigctld(0);
#endif
#else
rig_close(my_rig);
if (verbose > RIG_DEBUG_ERR)
{
printf("Closed rig model %d, '%s - will reopen for new clients'\n",
my_rig->caps->rig_model,
my_rig->caps->model_name);
}
#endif
if ((retcode = getnameinfo((struct sockaddr const *)&handle_data_arg->cli_addr,
@ -1406,9 +1359,7 @@ handle_exit:
free(arg);
#ifdef HAVE_PTHREAD
pthread_exit(NULL);
#endif
return NULL;
}

Wyświetl plik

@ -88,11 +88,9 @@ extern int read_history();
/* Hash table implementation See: http://uthash.sourceforge.net/ */
#include "uthash.h"
#ifdef HAVE_PTHREAD
# include <pthread.h>
#include <pthread.h>
static pthread_mutex_t rot_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
#define STR1(S) #S
#define STR(S) STR1(S)
@ -1413,9 +1411,7 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, const char *argv[],
* mutex locking needed because rotctld is multithreaded
* and hamlib is not MT-safe
*/
#ifdef HAVE_PTHREAD
pthread_mutex_lock(&rot_mutex);
#endif
if (!prompt)
{
@ -1467,9 +1463,7 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, const char *argv[],
"");
#endif
#ifdef HAVE_PTHREAD
pthread_mutex_unlock(&rot_mutex);
#endif
if (retcode == -RIG_EIO) { return retcode; }

Wyświetl plik

@ -51,9 +51,7 @@
# include <netdb.h>
#endif
#ifdef HAVE_PTHREAD
# include <pthread.h>
#endif
#include <pthread.h>
#include "hamlib/rotator.h"
@ -166,10 +164,8 @@ int main(int argc, char *argv[])
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
#ifdef HAVE_PTHREAD
pthread_t thread;
pthread_attr_t attr;
#endif
struct handle_data *arg;
rig_set_debug(verbose);
@ -575,7 +571,6 @@ int main(int argc, char *argv[])
host,
serv);
#ifdef HAVE_PTHREAD
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
@ -587,12 +582,7 @@ int main(int argc, char *argv[])
break;
}
#else
handle_socket(arg);
retcode = 1;
#endif
}
while (retcode == 0);
rot_close(my_rot); /* close port */
@ -702,9 +692,7 @@ handle_exit:
#endif
free(arg);
#ifdef HAVE_PTHREAD
pthread_exit(NULL);
#endif
return NULL;
}