Merge remote-tracking branch 'mdblack/master'

merge mdblack master
This commit is contained in:
Malcolm Herring 2020-01-06 07:06:09 +00:00
commit c897ce9084
7 changed files with 78 additions and 23 deletions

View File

@ -134,8 +134,7 @@ static int netrigctl_vfostr(RIG *rig, char *vfostr, int len, vfo_t vfo)
static int netrigctl_init(RIG *rig)
{
// cppcheck says leak here but it's freed in cleanup
struct netrigctl_priv_data *priv = (struct netrigctl_priv_data *)malloc(sizeof(
struct netrigctl_priv_data));
struct netrigctl_priv_data *priv;
if (!rig || !rig->caps)
{
@ -143,6 +142,7 @@ static int netrigctl_init(RIG *rig)
}
priv = (struct netrigctl_priv_data *)malloc(sizeof(struct netrigctl_priv_data));
if (!priv)
{

View File

@ -93,7 +93,7 @@ extern rmode_t elad_mode_table[ELAD_MODE_TABLE_MAX];
extern const tone_t elad38_ctcss_list[];
extern const tone_t elad42_ctcss_list[];
int elad_transaction(RIG *rig, const char *cmd, char *data, size_t data_len);
int elad_transaction(RIG *rig, const char *cmdstr, char *data, size_t datasize);
int elad_safe_transaction(RIG *rig, const char *cmd, char *buf,
size_t buf_size, size_t expected);

View File

@ -5846,6 +5846,7 @@ static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo)
__func__);
vfo = RIG_VFO_CURR;
retval = RIG_OK;
}
if (retval != RIG_OK)

View File

@ -93,24 +93,6 @@
#endif
#include <time.h>
#undef sleep
#undef usleep
#define usleep(n)\
do {\
unsigned long sec = n/1000000ul;\
unsigned long nsec = n*1000ul - (sec * 1000000000ul);\
struct timespec t;\
t.tv_sec=sec;\
t.tv_nsec = nsec;\
nanosleep(&t,NULL);\
} while(0)
#define sleep(n)\
do {\
struct timespec t;\
t.tv_sec=n;\
t.tv_nsec = 0;\
nanosleep(&t,NULL);\
} while(0)
__BEGIN_DECLS

View File

@ -5,7 +5,7 @@ RIGSRC = rig.c serial.c serial.h misc.c misc.h register.c register.h event.c \
rot_conf.c rot_conf.h iofunc.c iofunc.h ext.c mem.c settings.c \
parallel.c parallel.h usb_port.c usb_port.h debug.c network.c network.h \
cm108.c cm108.h gpio.c gpio.h idx_builtin.h token.h par_nt.h microham.c microham.h \
amplifier.c amp_reg.c amp_conf.c amp_conf.h extamp.c
amplifier.c amp_reg.c amp_conf.c amp_conf.h extamp.c sleep.c
lib_LTLIBRARIES = libhamlib.la
libhamlib_la_SOURCES = $(RIGSRC)

72
src/sleep.c Normal file
View File

@ -0,0 +1,72 @@
/**
* \addtogroup rig
* @{
*/
/**
* \file src/sleep.c
* \brief Replacements for sleep and usleep
* \author Michael Black W9MDB
* \date 2020
*/
/*
* Hamlib Interface - Replacements for sleep and usleep
* Copyright (c) 2020 by Michael Black W9MDB
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/**
* \brief provide sleep and usleep replacements
* \param same as man page for each
*
*/
#include <unistd.h>
#include <errno.h>
#include "hamlib/rig.h"
unsigned int sleep(unsigned int secs)
{
int retval;
struct timespec t;
struct timespec tleft;
t.tv_sec = secs;
t.tv_nsec = 0;
retval = nanosleep(&t, &tleft);
if (retval == -1) { return tleft.tv_sec; }
return 0;
}
// Does not have the same 1000000 limit as usleep
int usleep(useconds_t usec)
{
int retval;
unsigned long sec = usec / 1000000ul;
unsigned long nsec = usec * 1000ul - (sec * 1000000000ul);
struct timespec t;
t.tv_sec = sec;
t.tv_nsec = nsec;
retval = nanosleep(&t, NULL);
// EINTR is the only error return usleep should need
// since EINVAL should not be a problem
if (retval == -1) { return EINTR; }
return 0;
}

View File

@ -352,7 +352,7 @@ int ft991_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
return err;
}
strncat(restore_commands, priv->ret_data, NEWCAT_DATA_LEN-1);
strncat(restore_commands, priv->ret_data, NEWCAT_DATA_LEN-strlen(restore_commands));
/* Change mode on VFOA */
if (RIG_OK != (err = newcat_set_mode(rig, RIG_VFO_A, tx_mode,