2001-06-30 12:36:43 +00:00
/*
* Hamlib Interface - main file
2021-12-18 21:49:45 +00:00
* Copyright ( c ) 2021 by Mikael Nousiainen
2012-01-06 08:28:24 +00:00
* Copyright ( c ) 2000 - 2012 by Stephane Fillod
2009-02-20 14:14:31 +00:00
* Copyright ( c ) 2000 - 2003 by Frank Singleton
2001-06-30 12:36:43 +00:00
*
*
2011-08-22 01:07:57 +00:00
* 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 .
2001-06-30 12:36:43 +00:00
*
2011-08-22 01:07:57 +00:00
* This library is distributed in the hope that it will be useful ,
2001-06-30 12:36:43 +00:00
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
2011-08-22 01:07:57 +00:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* Lesser General Public License for more details .
2001-06-30 12:36:43 +00:00
*
2011-08-22 01:07:57 +00:00
* You should have received a copy of the GNU Lesser General Public
2001-06-30 12:36:43 +00:00
* License along with this library ; if not , write to the Free Software
2011-08-22 01:07:57 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA
2001-06-30 12:36:43 +00:00
*
2000-10-01 12:29:12 +00:00
*/
2006-10-15 00:27:52 +00:00
/**
* \ addtogroup rig
* @ {
*/
2002-11-28 22:32:42 +00:00
/**
* \ file src / rig . c
* \ brief Ham Radio Control Libraries interface
* \ author Stephane Fillod
* \ author Frank Singleton
2012-01-06 08:28:24 +00:00
* \ date 2000 - 2012
2002-11-28 22:32:42 +00:00
*
2006-10-15 00:27:52 +00:00
* Hamlib provides a user - callable API , a set of " front-end " routines that
2010-02-14 21:47:49 +00:00
* call rig - specific " back-end " routines which actually communicate with
2006-10-15 00:27:52 +00:00
* the physical rig .
2002-11-28 22:32:42 +00:00
*/
2017-10-05 02:32:08 +00:00
/**
* \ page rig Rig ( radio ) interface
2002-09-24 21:42:56 +00:00
*
2006-10-15 00:27:52 +00:00
* For us , a " rig " is an item of general remote controllable radio equipment .
* Generally , there are a VFO settings , gain controls , etc .
2002-09-24 21:42:56 +00:00
*/
/**
* \ example . . / tests / testrig . c
*/
2020-01-10 21:58:16 +00:00
# include "hamlib/rig.h"
2022-02-04 04:31:42 +00:00
# include "hamlib/config.h"
2001-02-09 23:06:32 +00:00
2000-10-01 12:29:12 +00:00
# include <stdlib.h>
# include <string.h>
# include <unistd.h>
# include <stdio.h>
# include <sys/types.h>
# include <sys/stat.h>
# include <fcntl.h>
2021-05-25 14:29:27 +00:00
# include <errno.h>
2021-06-04 15:03:40 +00:00
# ifdef HAVE_PTHREAD
2021-05-25 14:29:27 +00:00
# include <pthread.h>
2021-06-04 15:03:40 +00:00
# endif
2000-10-01 12:29:12 +00:00
2017-08-05 14:09:12 +00:00
# include <hamlib/rig.h>
2004-10-02 20:37:24 +00:00
# include "serial.h"
# include "parallel.h"
2005-11-01 23:02:02 +00:00
# include "usb_port.h"
2008-09-21 19:30:35 +00:00
# include "network.h"
2000-10-08 21:45:20 +00:00
# include "event.h"
2012-01-08 23:22:59 +00:00
# include "cm108.h"
2016-05-28 14:00:03 +00:00
# include "gpio.h"
2020-05-01 17:03:54 +00:00
# include "misc.h"
2021-03-03 14:03:18 +00:00
# include "sprintflst.h"
2021-03-20 04:14:13 +00:00
# include "hamlibdatetime.h"
2021-11-28 18:52:29 +00:00
# include "cache.h"
2000-10-01 12:29:12 +00:00
2001-06-30 12:36:43 +00:00
/**
* \ brief Hamlib release number
2017-10-05 02:32:08 +00:00
*
2006-10-15 00:27:52 +00:00
* The version number has the format x . y . z
2001-02-09 23:06:32 +00:00
*/
2010-02-27 16:09:07 +00:00
/*
* Careful : The hamlib 1.2 ABI implicitly specifies a size of 21 bytes for
* the hamlib_version string . Changing the size provokes a warning from the
* dynamic loader .
*/
2016-10-31 16:05:24 +00:00
const char * hamlib_license = " LGPL " ;
2020-04-09 22:56:19 +00:00
//! @cond Doxygen_Suppress
2010-02-27 16:09:07 +00:00
const char hamlib_version [ 21 ] = " Hamlib " PACKAGE_VERSION ;
2021-03-20 03:56:18 +00:00
const char * hamlib_version2 = " Hamlib " PACKAGE_VERSION " " HAMLIBDATETIME ;
2021-05-31 14:05:41 +00:00
HAMLIB_EXPORT_VAR ( int ) cookie_use ;
2022-06-07 03:58:55 +00:00
HAMLIB_EXPORT_VAR ( int ) lock_mode ; // for use by rigctld
2022-07-16 12:54:27 +00:00
HAMLIB_EXPORT_VAR ( powerstat_t ) rig_powerstat ; // for use by rigctld
2020-04-09 22:56:19 +00:00
//! @endcond
2001-02-09 23:06:32 +00:00
2021-01-21 23:18:45 +00:00
struct rig_caps caps_test ;
2001-07-13 19:08:15 +00:00
/**
* \ brief Hamlib copyright notice
*/
2016-08-31 14:05:47 +00:00
const char * hamlib_copyright2 =
2017-08-05 14:09:12 +00:00
" Copyright (C) 2000-2012 Stephane Fillod \n "
" Copyright (C) 2000-2003 Frank Singleton \n "
2020-12-29 15:09:14 +00:00
" Copyright (C) 2014-2020 Michael Black W9MDB \n "
2017-08-05 14:09:12 +00:00
" This is free software; see the source for copying conditions. There is NO \n "
" warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " ;
2020-04-09 22:56:19 +00:00
//! @cond Doxygen_Suppress
2010-02-27 16:09:07 +00:00
const char hamlib_copyright [ 231 ] = /* hamlib 1.2 ABI specifies 231 bytes */
2017-08-05 14:09:12 +00:00
" Copyright (C) 2000-2012 Stephane Fillod \n "
" Copyright (C) 2000-2003 Frank Singleton \n "
" This is free software; see the source for copying conditions. There is NO \n "
" warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " ;
2020-04-09 22:56:19 +00:00
//! @endcond
2002-09-24 21:42:56 +00:00
2001-07-13 19:08:15 +00:00
2002-09-24 21:42:56 +00:00
# ifndef DOC_HIDDEN
2000-10-01 12:29:12 +00:00
2003-08-25 22:33:38 +00:00
# if defined(WIN32) && !defined(__CYGWIN__)
2017-10-05 02:32:08 +00:00
# define DEFAULT_SERIAL_PORT "\\\\.\\COM1"
2008-05-04 15:36:23 +00:00
# elif BSD
2017-10-05 02:32:08 +00:00
# define DEFAULT_SERIAL_PORT " / dev / cuaa0"
2012-01-06 08:28:24 +00:00
# elif MACOSX
2017-10-05 02:32:08 +00:00
# define DEFAULT_SERIAL_PORT " / dev / cu.usbserial"
2003-08-25 22:33:38 +00:00
# else
2017-10-05 02:32:08 +00:00
# define DEFAULT_SERIAL_PORT " / dev / ttyS0"
2003-08-25 22:33:38 +00:00
# endif
# if defined(WIN32)
2017-10-05 02:32:08 +00:00
# define DEFAULT_PARALLEL_PORT "\\\\.\\$VDMLPT1"
2005-02-20 02:38:29 +00:00
# elif defined(HAVE_DEV_PPBUS_PPI_H)
2017-10-05 02:32:08 +00:00
# define DEFAULT_PARALLEL_PORT " / dev / ppi0"
2003-08-25 22:33:38 +00:00
# else
2017-10-05 02:32:08 +00:00
# define DEFAULT_PARALLEL_PORT " / dev / parport0"
2003-08-25 22:33:38 +00:00
# endif
2000-10-01 12:29:12 +00:00
2012-01-08 23:22:59 +00:00
# if defined(WIN32) && !defined(__CYGWIN__)
2017-10-05 02:32:08 +00:00
# define DEFAULT_CM108_PORT "fixme"
2012-01-08 23:22:59 +00:00
# elif BSD
2017-10-05 02:32:08 +00:00
# define DEFAULT_CM108_PORT "fixme"
2012-01-08 23:22:59 +00:00
# else
2017-10-05 02:32:08 +00:00
# define DEFAULT_CM108_PORT " / dev / hidraw0"
2012-01-08 23:22:59 +00:00
# endif
# if defined(WIN32) && !defined(__CYGWIN__)
2014-02-16 13:25:59 +00:00
/* FIXME: Determine correct GPIO bit number for W32 using MinGW. */
2017-10-05 02:32:08 +00:00
# define DEFAULT_CM108_PTT_BITNUM 2
2012-01-08 23:22:59 +00:00
# elif BSD
2014-02-16 13:25:59 +00:00
/* FIXME: Determine correct GPIO bit number for *BSD. */
2017-10-05 02:32:08 +00:00
# define DEFAULT_CM108_PTT_BITNUM 2
2012-01-08 23:22:59 +00:00
# else
2017-10-05 02:32:08 +00:00
# define DEFAULT_CM108_PTT_BITNUM 2
2012-01-08 23:22:59 +00:00
# endif
2016-05-28 14:00:03 +00:00
# define DEFAULT_GPIO_PORT "0"
2012-01-08 23:22:59 +00:00
2002-01-21 08:30:31 +00:00
# define CHECK_RIG_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state)
2022-02-25 13:41:10 +00:00
# define CHECK_RIG_CAPS(r) (!(r) || !(r)->caps)
2002-01-21 08:30:31 +00:00
2021-09-29 03:57:35 +00:00
# define LOCK \
2022-05-23 16:44:19 +00:00
# ifdef 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
# define MUTEX(var)
# define MUTEX_LOCK(var)
# define MUTEX_UNLOCK(var)
# endif
2000-10-01 12:29:12 +00:00
/*
2000-10-08 21:45:20 +00:00
* Data structure to track the opened rig ( by rig_open )
2000-10-01 12:29:12 +00:00
*/
2017-10-05 02:32:08 +00:00
struct opened_rig_l
{
2017-08-05 14:09:12 +00:00
RIG * rig ;
struct opened_rig_l * next ;
2000-10-08 21:45:20 +00:00
} ;
static struct opened_rig_l * opened_rig_list = { NULL } ;
2000-10-01 12:29:12 +00:00
2017-08-05 14:09:12 +00:00
2000-10-08 21:45:20 +00:00
/*
* Careful , the order must be the same as their RIG_E * counterpart !
* TODO : localise the messages . .
*/
2021-08-26 11:49:24 +00:00
static const char * const rigerror_table [ ] =
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
" Command completed successfully " ,
" Invalid parameter " ,
" Invalid configuration " ,
" Memory shortage " ,
" Feature not implemented " ,
" Communication timed out " ,
" IO error " ,
" Internal Hamlib error " ,
" Protocol error " ,
" Command rejected by the rig " ,
" Command performed, but arg truncated, result not guaranteed " ,
" Feature not available " ,
" Target VFO unaccessible " ,
" Communication bus error " ,
" Communication bus collision " ,
" NULL RIG handle or invalid pointer parameter " ,
" Invalid VFO " ,
2021-11-28 18:52:29 +00:00
" Argument out of domain of func " ,
2022-04-29 22:17:43 +00:00
" Function deprecated " ,
2022-07-15 20:41:23 +00:00
" Security error password not provided or crypto failure " ,
" Rig is not powered on "
2000-10-01 12:29:12 +00:00
} ;
2017-08-05 14:09:12 +00:00
2002-09-24 21:42:56 +00:00
# define ERROR_TBL_SZ (sizeof(rigerror_table) / sizeof(char *))
2000-10-01 12:29:12 +00:00
2021-11-20 19:33:29 +00:00
# ifdef HAVE_PTHREAD
2021-11-28 18:52:29 +00:00
typedef struct async_data_handler_args_s
2021-11-20 19:33:29 +00:00
{
RIG * rig ;
} async_data_handler_args ;
2021-11-28 18:52:29 +00:00
typedef struct async_data_handler_priv_data_s
{
pthread_t thread_id ;
async_data_handler_args args ;
} async_data_handler_priv_data ;
static int async_data_handler_start ( RIG * rig ) ;
static int async_data_handler_stop ( RIG * rig ) ;
2021-11-20 19:33:29 +00:00
void * async_data_handler ( void * arg ) ;
# endif
2001-01-05 18:24:20 +00:00
/*
* track which rig is opened ( with rig_open )
* needed at least for transceive mode
*/
2000-10-08 21:45:20 +00:00
static int add_opened_rig ( RIG * rig )
{
2017-08-05 14:09:12 +00:00
struct opened_rig_l * p ;
2005-04-04 18:31:00 +00:00
2017-08-05 14:09:12 +00:00
p = ( struct opened_rig_l * ) malloc ( sizeof ( struct opened_rig_l ) ) ;
2017-10-05 02:32:08 +00:00
if ( ! p )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_ENOMEM ) ;
2017-08-05 14:09:12 +00:00
}
2005-04-04 18:31:00 +00:00
2017-08-05 14:09:12 +00:00
p - > rig = rig ;
p - > next = opened_rig_list ;
opened_rig_list = p ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( RIG_OK ) ;
2000-10-08 21:45:20 +00:00
}
2017-08-05 14:09:12 +00:00
2000-10-08 21:45:20 +00:00
static int remove_opened_rig ( RIG * rig )
2010-02-14 21:47:49 +00:00
{
2017-08-05 14:09:12 +00:00
struct opened_rig_l * p , * q ;
q = NULL ;
2017-10-05 02:32:08 +00:00
for ( p = opened_rig_list ; p ; p = p - > next )
{
if ( p - > rig = = rig )
{
if ( q = = NULL )
{
2017-08-05 14:09:12 +00:00
opened_rig_list = opened_rig_list - > next ;
2017-10-05 02:32:08 +00:00
}
else
{
2017-08-05 14:09:12 +00:00
q - > next = p - > next ;
}
free ( p ) ;
2022-02-05 21:27:43 +00:00
return ( RIG_OK ) ;
2017-08-05 14:09:12 +00:00
}
q = p ;
}
2022-02-05 21:27:43 +00:00
return ( - RIG_EINVAL ) ; /* Not found in list ! */
2000-10-08 21:45:20 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief execs cfunc ( ) on each opened rig
2017-08-05 14:09:12 +00:00
* \ param cfunc The function to be executed on each rig
* \ param data Data pointer to be passed to cfunc ( )
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2010-02-14 21:47:49 +00:00
* Calls cfunc ( ) function for each opened rig .
2001-06-30 12:36:43 +00:00
* The contents of the opened rig table
* is processed in random order according to a function
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* pointed to by \ a cfunc , which is called with two arguments ,
2002-09-24 21:42:56 +00:00
* the first pointing to the RIG handle , the second
2001-06-30 12:36:43 +00:00
* to a data pointer \ a data .
* If \ a data is not needed , then it can be set to NULL .
* The processing of the opened rig table is stopped
* when cfunc ( ) returns 0.
* \ internal
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ return always RIG_OK .
2000-10-08 21:45:20 +00:00
*/
2001-06-11 00:41:28 +00:00
int foreach_opened_rig ( int ( * cfunc ) ( RIG * , rig_ptr_t ) , rig_ptr_t data )
2010-02-14 21:47:49 +00:00
{
2017-08-05 14:09:12 +00:00
struct opened_rig_l * p ;
2017-10-05 02:32:08 +00:00
for ( p = opened_rig_list ; p ; p = p - > next )
{
if ( ( * cfunc ) ( p - > rig , data ) = = 0 )
{
2022-02-05 21:27:43 +00:00
return ( RIG_OK ) ;
2017-08-05 14:09:12 +00:00
}
}
2000-10-08 21:45:20 +00:00
2022-02-05 21:27:43 +00:00
return ( RIG_OK ) ;
2000-10-08 21:45:20 +00:00
}
2000-10-01 12:29:12 +00:00
2002-09-24 21:42:56 +00:00
# endif /* !DOC_HIDDEN */
2017-08-05 14:09:12 +00:00
2022-05-03 17:13:02 +00:00
char debugmsgsave [ DEBUGMSGSAVE_SIZE ] = " " ;
2022-06-06 13:50:29 +00:00
char debugmsgsave2 [ DEBUGMSGSAVE_SIZE ] = " " ; // deprecated
char debugmsgsave3 [ DEBUGMSGSAVE_SIZE ] = " " ; // deprecated
2022-05-03 17:13:02 +00:00
2022-05-23 16:44:19 +00:00
MUTEX ( debugmsgsave ) ;
2022-05-03 17:13:02 +00:00
void add2debugmsgsave ( const char * s )
{
2022-05-23 03:15:55 +00:00
char * p ;
char stmp [ DEBUGMSGSAVE_SIZE ] ;
2022-05-23 15:41:16 +00:00
int i , nlines ;
2022-05-29 17:06:44 +00:00
int maxmsg = DEBUGMSGSAVE_SIZE / 2 ;
2022-05-23 16:44:19 +00:00
MUTEX_LOCK ( debugmsgsave ) ;
2022-05-23 03:15:55 +00:00
memset ( stmp , 0 , sizeof ( stmp ) ) ;
p = debugmsgsave ;
// we'll keep 20 lines including this one
// so count the lines
2022-05-23 15:41:16 +00:00
for ( i = 0 , nlines = 0 ; debugmsgsave [ i ] ! = 0 ; + + i )
2022-05-03 17:13:02 +00:00
{
2022-05-23 15:41:16 +00:00
if ( debugmsgsave [ i ] = = ' \n ' ) { + + nlines ; }
2022-05-23 03:15:55 +00:00
}
2022-05-23 15:41:16 +00:00
2022-05-23 03:15:55 +00:00
// strip the last 19 lines
2022-05-23 15:41:16 +00:00
p = debugmsgsave ;
2022-05-26 13:25:39 +00:00
while ( ( nlines > 19 | | strlen ( debugmsgsave ) > maxmsg ) & & p ! = NULL )
2022-05-23 03:15:55 +00:00
{
2022-05-23 15:41:16 +00:00
p = strchr ( debugmsgsave , ' \n ' ) ;
if ( p & & strlen ( p + 1 ) > 0 )
{
if ( strlen ( p + 1 ) > 0 )
{
strcpy ( stmp , p + 1 ) ;
strcpy ( debugmsgsave , stmp ) ;
}
else
{
debugmsgsave [ 0 ] = ' \0 ' ;
}
}
2022-05-23 03:15:55 +00:00
- - nlines ;
2022-05-29 17:06:44 +00:00
if ( nlines = = 0 & & strlen ( debugmsgsave ) > maxmsg ) { strcpy ( debugmsgsave , " !!!!debugmsgsave too long \n " ) ; }
2022-05-03 17:13:02 +00:00
}
2022-05-13 21:50:13 +00:00
2022-05-23 03:15:55 +00:00
if ( strlen ( stmp ) + strlen ( s ) + 1 < DEBUGMSGSAVE_SIZE )
{
strcat ( debugmsgsave , s ) ;
}
else
{
2022-05-23 15:41:16 +00:00
rig_debug ( RIG_DEBUG_BUG ,
" %s: debugmsgsave overflow!! len of debugmsgsave=%d, len of add=%d \n " , __func__ ,
( int ) strlen ( debugmsgsave ) , ( int ) strlen ( s ) ) ;
2022-05-23 03:15:55 +00:00
}
2022-05-29 17:06:44 +00:00
2022-05-23 16:44:19 +00:00
MUTEX_UNLOCK ( debugmsgsave ) ;
2022-05-03 17:13:02 +00:00
}
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2002-09-24 21:42:56 +00:00
* \ brief get string describing the error code
2017-08-05 14:09:12 +00:00
* \ param errnum The error code
2010-02-14 21:47:49 +00:00
* \ return the appropriate description string , otherwise a NULL pointer
2002-09-24 21:42:56 +00:00
* if the error code is unknown .
*
2017-10-05 02:32:08 +00:00
* Returns a string describing the error code passed in the argument \ a
* errnum .
2002-09-24 21:42:56 +00:00
*
* \ todo support gettext / localization
*/
2022-06-04 13:53:44 +00:00
const char * HAMLIB_API rigerror2 ( int errnum ) // returns single-line message
{
errnum = abs ( errnum ) ;
if ( errnum > = ERROR_TBL_SZ )
{
// This should not happen, but if it happens don't return NULL
return " ERR_OUT_OF_RANGE " ;
}
static char msg [ DEBUGMSGSAVE_SIZE ] ;
snprintf ( msg , sizeof ( msg ) , " %s \n " , rigerror_table [ errnum ] ) ;
return msg ;
}
2019-11-30 16:19:08 +00:00
const char * HAMLIB_API rigerror ( int errnum )
2002-09-24 21:42:56 +00:00
{
2017-08-05 14:09:12 +00:00
errnum = abs ( errnum ) ;
2019-12-09 04:45:29 +00:00
if ( errnum > = ERROR_TBL_SZ )
2017-10-05 02:32:08 +00:00
{
2020-07-17 10:22:21 +00:00
// This should not happen, but if it happens don't return NULL
return " ERR_OUT_OF_RANGE " ;
2017-08-05 14:09:12 +00:00
}
2022-05-04 12:31:18 +00:00
static char msg [ DEBUGMSGSAVE_SIZE ] ;
#if 0
2021-02-03 15:59:14 +00:00
// we have to remove LF from debugmsgsave since calling function controls LF
2021-02-28 15:46:01 +00:00
char * p = & debugmsgsave [ strlen ( debugmsgsave ) - 1 ] ;
if ( * p = = ' \n ' ) { * p = 0 ; }
2022-05-13 21:50:13 +00:00
2022-05-04 12:31:18 +00:00
# endif
2021-02-28 15:46:01 +00:00
2022-05-03 17:13:02 +00:00
#if 0
2022-01-19 15:11:04 +00:00
SNPRINTF ( msg , sizeof ( msg ) , " %.80s \n %.15000s%.15000s%.15000s " ,
2021-03-15 22:51:22 +00:00
rigerror_table [ errnum ] ,
debugmsgsave3 , debugmsgsave2 , debugmsgsave ) ;
2022-05-03 17:13:02 +00:00
# else
2022-05-04 12:31:18 +00:00
snprintf ( msg , sizeof ( msg ) , " %s \n " , rigerror_table [ errnum ] ) ;
add2debugmsgsave ( msg ) ;
2022-05-03 17:13:02 +00:00
snprintf ( msg , sizeof ( msg ) , " %s " , debugmsgsave ) ;
# endif
2021-01-29 14:30:35 +00:00
return msg ;
2002-09-24 21:42:56 +00:00
}
2021-01-21 23:18:45 +00:00
// We use a couple of defined pointer to determine if the shared library changes
void * caps_test_rig_model = & caps_test . rig_model ;
void * caps_test_macro_name = & caps_test . macro_name ;
// check and show WARN if rig_caps structure doesn't match
// this tests for shared library incompatibility
2021-09-09 20:36:43 +00:00
static int rig_check_rig_caps ( )
2021-01-21 23:18:45 +00:00
{
int rc = RIG_OK ;
if ( & caps_test . rig_model ! = caps_test_rig_model )
{
rc = - RIG_EINTERNAL ;
2021-11-20 19:33:29 +00:00
rig_debug ( RIG_DEBUG_WARN , " %s: shared library change#1 \n " , __func__ ) ;
2021-01-21 23:18:45 +00:00
}
if ( & caps_test . macro_name ! = caps_test_macro_name )
{
rc = - RIG_EINTERNAL ;
2021-11-20 19:33:29 +00:00
rig_debug ( RIG_DEBUG_WARN , " %s: shared library change#2 \n " , __func__ ) ;
2021-01-21 23:18:45 +00:00
}
2021-01-22 13:52:15 +00:00
//if (rc != RIG_OK)
2021-01-21 23:18:45 +00:00
{
rig_debug ( RIG_DEBUG_TRACE , " %s: p1=%p, p2=%p, rig_model=%p, macro_name=%p \n " ,
__func__ , caps_test_rig_model , caps_test_macro_name , & caps_test . rig_model ,
& caps_test . macro_name ) ;
}
2022-02-05 21:27:43 +00:00
return ( rc ) ;
2021-01-21 23:18:45 +00:00
}
2017-08-05 14:09:12 +00:00
2002-09-24 21:42:56 +00:00
/**
* \ brief allocate a new RIG handle
2017-08-05 14:09:12 +00:00
* \ param rig_model The rig model for this new handle
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2010-02-14 21:47:49 +00:00
* Allocates a new RIG handle and initializes the associated data
2001-06-30 12:36:43 +00:00
* for \ a rig_model .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ return a pointer to the # RIG handle otherwise NULL if memory allocation
* failed or \ a rig_model is unknown ( e . g . backend autoload failed ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_cleanup ( ) , rig_open ( )
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*/
2019-11-30 16:19:08 +00:00
RIG * HAMLIB_API rig_init ( rig_model_t rig_model )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
RIG * rig ;
const struct rig_caps * caps ;
struct rig_state * rs ;
2019-12-09 04:45:29 +00:00
int i ;
2017-08-05 14:09:12 +00:00
2021-01-21 23:18:45 +00:00
rig_check_rig_caps ( ) ;
2017-08-05 14:09:12 +00:00
rig_check_backend ( rig_model ) ;
caps = rig_get_caps ( rig_model ) ;
2017-10-05 02:32:08 +00:00
if ( ! caps )
{
2021-03-15 22:51:22 +00:00
return ( NULL ) ;
2017-08-05 14:09:12 +00:00
}
2022-01-01 05:49:29 +00:00
if ( caps - > hamlib_check_rig_caps ! = NULL )
{
if ( caps - > hamlib_check_rig_caps [ 0 ] ! = ' H '
| | strncmp ( caps - > hamlib_check_rig_caps , HAMLIB_CHECK_RIG_CAPS ,
strlen ( caps - > hamlib_check_rig_caps ) ) ! = 0 )
{
rig_debug ( RIG_DEBUG_ERR ,
Fix spelling errors
Fixed with:
codespell --summary --skip=.git,extra,,lib,macros,security --ignore-words-list="ans,ba,cant,develope,fo,get's,nin,numer,parm,parms,setts,som,statics,ths,ue,vektor,objext" --write-changes --interactive=2
and manual editing.
2022-07-07 19:25:58 +00:00
" %s: Error validating integrity of rig_caps \n Possible hamlib DLL incompatibility \n " ,
2022-01-01 05:49:29 +00:00
__func__ ) ;
return ( NULL ) ;
}
}
else
{
rig_debug ( RIG_DEBUG_WARN ,
" %s: backend for %s does not contain hamlib_check_rig_caps \n " , __func__ ,
caps - > model_name ) ;
}
2017-08-05 14:09:12 +00:00
/*
* okay , we ' ve found it . Allocate some memory and set it to zeros ,
* and especially the callbacks
*/
rig = calloc ( 1 , sizeof ( RIG ) ) ;
2017-10-05 02:32:08 +00:00
if ( rig = = NULL )
{
2017-08-05 14:09:12 +00:00
/*
* FIXME : how can the caller know it ' s a memory shortage ,
* and not " rig not found " ?
*/
2021-03-15 22:51:22 +00:00
return ( NULL ) ;
2017-08-05 14:09:12 +00:00
}
/* caps is const, so we need to tell compiler
that we know what we are doing */
rig - > caps = ( struct rig_caps * ) caps ;
/*
* populate the rig - > state
* TODO : read the Preferences here !
*/
rs = & rig - > state ;
2022-01-23 15:01:06 +00:00
# ifdef HAVE_PTHREAD
pthread_mutex_init ( & rs - > mutex_set_transaction , NULL ) ;
# endif
2017-08-05 14:09:12 +00:00
2022-01-05 17:12:43 +00:00
rs - > async_data_enabled = 0 ;
2022-01-25 23:41:26 +00:00
rs - > rigport . fd = - 1 ;
rs - > pttport . fd = - 1 ;
2017-08-05 14:09:12 +00:00
rs - > comm_state = 0 ;
2022-02-05 21:27:43 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): %p rs->comm_state==0?=%d \n " , __func__ ,
__LINE__ , & rs - > comm_state ,
2022-01-01 05:49:29 +00:00
rs - > comm_state ) ;
2022-01-25 23:41:26 +00:00
rs - > rigport . type . rig = caps - > port_type ; /* default from caps */
2022-01-28 15:55:48 +00:00
# if defined(HAVE_PTHREAD)
2022-01-26 14:26:12 +00:00
rs - > rigport . asyncio = 0 ;
2022-01-25 23:41:26 +00:00
# endif
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
switch ( caps - > port_type )
{
2017-08-05 14:09:12 +00:00
case RIG_PORT_SERIAL :
2022-01-25 23:41:26 +00:00
strncpy ( rs - > rigport . pathname , DEFAULT_SERIAL_PORT , HAMLIB_FILPATHLEN - 1 ) ;
rs - > rigport . parm . serial . rate = caps - > serial_rate_max ; /* fastest ! */
rs - > rigport . parm . serial . data_bits = caps - > serial_data_bits ;
rs - > rigport . parm . serial . stop_bits = caps - > serial_stop_bits ;
rs - > rigport . parm . serial . parity = caps - > serial_parity ;
rs - > rigport . parm . serial . handshake = caps - > serial_handshake ;
2017-08-05 14:09:12 +00:00
break ;
case RIG_PORT_PARALLEL :
2022-01-25 23:41:26 +00:00
strncpy ( rs - > rigport . pathname , DEFAULT_PARALLEL_PORT , HAMLIB_FILPATHLEN - 1 ) ;
2017-08-05 14:09:12 +00:00
break ;
/* Adding support for CM108 GPIO. This is compatible with CM108 series
* USB audio chips from CMedia and SSS1623 series USB audio chips from 3 S
*/
case RIG_PORT_CM108 :
2022-01-25 23:41:26 +00:00
strncpy ( rs - > rigport . pathname , DEFAULT_CM108_PORT , HAMLIB_FILPATHLEN ) ;
rs - > rigport . parm . cm108 . ptt_bitnum = DEFAULT_CM108_PTT_BITNUM ;
rs - > pttport . parm . cm108 . ptt_bitnum = DEFAULT_CM108_PTT_BITNUM ;
2017-08-05 14:09:12 +00:00
break ;
case RIG_PORT_GPIO :
2022-01-25 23:41:26 +00:00
strncpy ( rs - > rigport . pathname , DEFAULT_GPIO_PORT , HAMLIB_FILPATHLEN ) ;
2017-08-05 14:09:12 +00:00
break ;
case RIG_PORT_NETWORK :
case RIG_PORT_UDP_NETWORK :
2022-01-25 23:41:26 +00:00
strncpy ( rs - > rigport . pathname , " 127.0.0.1:4532 " , HAMLIB_FILPATHLEN - 1 ) ;
2017-08-05 14:09:12 +00:00
break ;
default :
2022-01-25 23:41:26 +00:00
strncpy ( rs - > rigport . pathname , " " , HAMLIB_FILPATHLEN - 1 ) ;
2017-08-05 14:09:12 +00:00
}
2022-01-25 23:41:26 +00:00
rs - > rigport . write_delay = caps - > write_delay ;
rs - > rigport . post_write_delay = caps - > post_write_delay ;
rs - > rigport . timeout = caps - > timeout ;
rs - > rigport . retry = caps - > retry ;
rs - > pttport . type . ptt = caps - > ptt_type ;
rs - > dcdport . type . dcd = caps - > dcd_type ;
2017-08-05 14:09:12 +00:00
rs - > vfo_comp = 0.0 ; /* override it with preferences */
rs - > current_vfo = RIG_VFO_CURR ; /* we don't know yet! */
rs - > tx_vfo = RIG_VFO_CURR ; /* we don't know yet! */
2021-11-28 18:52:29 +00:00
rs - > poll_interval = 0 ; // disable polling by default
2018-11-07 16:11:58 +00:00
rs - > lo_freq = 0 ;
2020-05-01 17:03:54 +00:00
rs - > cache . timeout_ms = 500 ; // 500ms cache timeout by default
2020-03-15 20:32:46 +00:00
2020-03-06 14:49:21 +00:00
// We are using range_list1 as the default
// Eventually we will have separate model number for different rig variations
// So range_list1 will become just range_list (per model)
// See ic9700.c for a 5-model example
2021-01-08 23:49:56 +00:00
// Every rig should have a rx_range
// Rig backends need updating for new range_list format
2020-03-06 14:49:21 +00:00
memcpy ( rs - > rx_range_list , caps - > rx_range_list1 ,
2021-03-06 18:37:53 +00:00
sizeof ( struct freq_range_list ) * HAMLIB_FRQRANGESIZ ) ;
2021-01-08 23:49:56 +00:00
memcpy ( rs - > tx_range_list , caps - > tx_range_list1 ,
2021-03-06 18:37:53 +00:00
sizeof ( struct freq_range_list ) * HAMLIB_FRQRANGESIZ ) ;
2021-01-09 16:13:17 +00:00
2021-01-08 23:49:56 +00:00
// if we don't have list1 we'll try list2
2021-01-17 17:59:26 +00:00
if ( rs - > rx_range_list [ 0 ] . startf = = 0 )
2021-01-08 23:49:56 +00:00
{
2021-01-15 22:48:32 +00:00
rig_debug ( RIG_DEBUG_TRACE ,
" %s: rx_range_list1 is empty, using rx_range_list2 \n " , __func__ ) ;
2021-01-08 23:49:56 +00:00
memcpy ( rs - > tx_range_list , caps - > rx_range_list2 ,
2021-03-06 18:37:53 +00:00
sizeof ( struct freq_range_list ) * HAMLIB_FRQRANGESIZ ) ;
2021-01-08 23:49:56 +00:00
memcpy ( rs - > rx_range_list , caps - > tx_range_list2 ,
2021-03-06 18:37:53 +00:00
sizeof ( struct freq_range_list ) * HAMLIB_FRQRANGESIZ ) ;
2021-01-08 23:49:56 +00:00
}
2021-01-09 16:13:17 +00:00
2021-01-29 08:50:11 +00:00
if ( rs - > tx_range_list [ 0 ] . startf = = 0 )
2021-01-08 23:49:56 +00:00
{
2021-04-03 15:32:43 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s: rig does not have tx_range!! \n " , __func__ ) ;
2021-03-05 18:03:40 +00:00
//return(NULL); // this is not fatal
2021-01-08 23:49:56 +00:00
}
2020-02-17 14:46:01 +00:00
#if 0 // this is no longer applicable -- replace it with something?
2020-02-23 17:26:09 +00:00
2020-02-17 14:46:01 +00:00
// we need to be able to figure out what model radio we have
// before we can set up the rig_state with the rig's specific freq range
// if we can't figure out what model rig we have this is impossible
// so we will likely have to make this a parameter the user provides
// or eliminate this logic entirely and make specific RIG_MODEL entries
2017-10-05 02:32:08 +00:00
switch ( rs - > itu_region )
{
2017-08-05 14:09:12 +00:00
case RIG_ITU_REGION1 :
memcpy ( rs - > tx_range_list , caps - > tx_range_list1 ,
2021-03-06 18:37:53 +00:00
sizeof ( struct freq_range_list ) * HAMLIB_FRQRANGESIZ ) ;
2017-08-05 14:09:12 +00:00
memcpy ( rs - > rx_range_list , caps - > rx_range_list1 ,
2021-03-06 18:37:53 +00:00
sizeof ( struct freq_range_list ) * HAMLIB_FRQRANGESIZ ) ;
2017-08-05 14:09:12 +00:00
break ;
case RIG_ITU_REGION2 :
case RIG_ITU_REGION3 :
default :
memcpy ( rs - > tx_range_list , caps - > tx_range_list2 ,
2021-03-06 18:37:53 +00:00
sizeof ( struct freq_range_list ) * HAMLIB_FRQRANGESIZ ) ;
2017-08-05 14:09:12 +00:00
memcpy ( rs - > rx_range_list , caps - > rx_range_list2 ,
2021-03-06 18:37:53 +00:00
sizeof ( struct freq_range_list ) * HAMLIB_FRQRANGESIZ ) ;
2017-08-05 14:09:12 +00:00
break ;
}
2020-02-23 17:26:09 +00:00
2020-02-17 12:43:41 +00:00
# endif
2017-08-05 14:09:12 +00:00
rs - > vfo_list = 0 ;
rs - > mode_list = 0 ;
2021-03-15 22:51:22 +00:00
for ( i = 0 ; i < HAMLIB_FRQRANGESIZ
& & ! RIG_IS_FRNG_END ( caps - > rx_range_list1 [ i ] ) ; i + + )
2017-10-05 02:32:08 +00:00
{
2020-02-17 14:46:01 +00:00
rs - > vfo_list | = caps - > rx_range_list1 [ i ] . vfo ;
rs - > mode_list | = caps - > rx_range_list1 [ i ] . modes ;
2017-08-05 14:09:12 +00:00
}
2021-03-15 22:51:22 +00:00
for ( i = 0 ; i < HAMLIB_FRQRANGESIZ
& & ! RIG_IS_FRNG_END ( caps - > tx_range_list1 [ i ] ) ; i + + )
2017-10-05 02:32:08 +00:00
{
2020-02-17 14:46:01 +00:00
rs - > vfo_list | = caps - > tx_range_list1 [ i ] . vfo ;
rs - > mode_list | = caps - > tx_range_list1 [ i ] . modes ;
2017-08-05 14:09:12 +00:00
}
2020-03-26 16:11:46 +00:00
2021-03-15 22:51:22 +00:00
for ( i = 0 ; i < HAMLIB_FRQRANGESIZ
& & ! RIG_IS_FRNG_END ( caps - > rx_range_list2 [ i ] ) ; i + + )
2020-03-23 21:22:54 +00:00
{
rs - > vfo_list | = caps - > rx_range_list2 [ i ] . vfo ;
rs - > mode_list | = caps - > rx_range_list2 [ i ] . modes ;
}
2021-03-15 22:51:22 +00:00
for ( i = 0 ; i < HAMLIB_FRQRANGESIZ
& & ! RIG_IS_FRNG_END ( caps - > tx_range_list2 [ i ] ) ; i + + )
2020-03-23 21:22:54 +00:00
{
rs - > vfo_list | = caps - > tx_range_list2 [ i ] . vfo ;
rs - > mode_list | = caps - > tx_range_list2 [ i ] . modes ;
}
2021-01-09 16:13:17 +00:00
if ( rs - > vfo_list & RIG_VFO_A ) { rig_debug ( RIG_DEBUG_VERBOSE , " %s: rig has VFO_A \n " , __func__ ) ; }
if ( rs - > vfo_list & RIG_VFO_B ) { rig_debug ( RIG_DEBUG_VERBOSE , " %s: rig has VFO_B \n " , __func__ ) ; }
if ( rs - > vfo_list & RIG_VFO_C ) { rig_debug ( RIG_DEBUG_VERBOSE , " %s: rig has VFO_C \n " , __func__ ) ; }
if ( rs - > vfo_list & RIG_VFO_SUB_A ) { rig_debug ( RIG_DEBUG_VERBOSE , " %s: rig has VFO_SUB_A \n " , __func__ ) ; }
if ( rs - > vfo_list & RIG_VFO_SUB_B ) { rig_debug ( RIG_DEBUG_VERBOSE , " %s: rig has VFO_SUB_B \n " , __func__ ) ; }
if ( rs - > vfo_list & RIG_VFO_MAIN_A ) { rig_debug ( RIG_DEBUG_VERBOSE , " %s: rig has VFO_MAIN_A \n " , __func__ ) ; }
if ( rs - > vfo_list & RIG_VFO_MAIN_B ) { rig_debug ( RIG_DEBUG_VERBOSE , " %s: rig has VFO_MAIN_B \n " , __func__ ) ; }
if ( rs - > vfo_list & RIG_VFO_SUB ) { rig_debug ( RIG_DEBUG_VERBOSE , " %s: rig has VFO_SUB \n " , __func__ ) ; }
if ( rs - > vfo_list & RIG_VFO_MAIN ) { rig_debug ( RIG_DEBUG_VERBOSE , " %s: rig has VFO_MAIN \n " , __func__ ) ; }
if ( rs - > vfo_list & RIG_VFO_MEM ) { rig_debug ( RIG_DEBUG_VERBOSE , " %s: rig has VFO_MEM \n " , __func__ ) ; }
2017-08-05 14:09:12 +00:00
2021-03-06 18:37:53 +00:00
memcpy ( rs - > preamp , caps - > preamp , sizeof ( int ) * HAMLIB_MAXDBLSTSIZ ) ;
memcpy ( rs - > attenuator , caps - > attenuator , sizeof ( int ) * HAMLIB_MAXDBLSTSIZ ) ;
2017-08-05 14:09:12 +00:00
memcpy ( rs - > tuning_steps , caps - > tuning_steps ,
2021-03-06 18:37:53 +00:00
sizeof ( struct tuning_step_list ) * HAMLIB_TSLSTSIZ ) ;
2017-08-05 14:09:12 +00:00
memcpy ( rs - > filters , caps - > filters ,
2021-03-06 18:37:53 +00:00
sizeof ( struct filter_list ) * HAMLIB_FLTLSTSIZ ) ;
2017-08-05 14:09:12 +00:00
memcpy ( & rs - > str_cal , & caps - > str_cal ,
sizeof ( cal_table_t ) ) ;
2021-03-06 18:37:53 +00:00
memcpy ( rs - > chan_list , caps - > chan_list , sizeof ( chan_t ) * HAMLIB_CHANLSTSIZ ) ;
2017-08-05 14:09:12 +00:00
rs - > has_get_func = caps - > has_get_func ;
rs - > has_set_func = caps - > has_set_func ;
rs - > has_get_level = caps - > has_get_level ;
rs - > has_set_level = caps - > has_set_level ;
rs - > has_get_parm = caps - > has_get_parm ;
rs - > has_set_parm = caps - > has_set_parm ;
/* emulation by frontend */
if ( ( caps - > has_get_level & RIG_LEVEL_STRENGTH ) = = 0
2017-10-05 02:32:08 +00:00
& & ( caps - > has_get_level & RIG_LEVEL_RAWSTR ) = = RIG_LEVEL_RAWSTR )
{
rs - > has_get_level | = RIG_LEVEL_STRENGTH ;
2017-08-05 14:09:12 +00:00
}
memcpy ( rs - > level_gran , caps - > level_gran , sizeof ( gran_t ) * RIG_SETTING_MAX ) ;
memcpy ( rs - > parm_gran , caps - > parm_gran , sizeof ( gran_t ) * RIG_SETTING_MAX ) ;
rs - > max_rit = caps - > max_rit ;
rs - > max_xit = caps - > max_xit ;
rs - > max_ifshift = caps - > max_ifshift ;
rs - > announces = caps - > announces ;
2022-01-25 23:41:26 +00:00
rs - > rigport . fd = rs - > pttport . fd = rs - > dcdport . fd = - 1 ;
2022-07-15 21:41:18 +00:00
rs - > powerstat = RIG_POWER_ON ; // default to power on
2017-08-05 14:09:12 +00:00
/*
* let the backend a chance to setup his private data
* This must be done only once defaults are setup ,
* so the backend init can override rig_state .
*/
2017-10-05 02:32:08 +00:00
if ( caps - > rig_init ! = NULL )
{
2019-12-09 04:45:29 +00:00
int retcode = caps - > rig_init ( rig ) ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2017-08-05 14:09:12 +00:00
rig_debug ( RIG_DEBUG_VERBOSE ,
" %s: backend_init failed! \n " ,
__func__ ) ;
/* cleanup and exit */
free ( rig ) ;
2021-03-15 22:51:22 +00:00
return ( NULL ) ;
2017-08-05 14:09:12 +00:00
}
}
2022-02-05 21:27:43 +00:00
2021-03-15 22:51:22 +00:00
return ( rig ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief open the communication to the rig
2017-08-05 14:09:12 +00:00
* \ param rig The # RIG handle of the radio to be opened
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Opens communication to a radio which \ a RIG handle has been passed
* by argument .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* \ retval RIG_EINVAL \ a rig is NULL or inconsistent .
2017-08-05 14:09:12 +00:00
* \ retval RIG_ENIMPL port type communication is not implemented yet .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_init ( ) , rig_close ( )
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_open ( RIG * rig )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
struct rig_state * rs ;
int status = RIG_OK ;
2020-02-23 16:50:26 +00:00
value_t parm_value ;
2020-06-21 22:47:04 +00:00
//unsigned int net1, net2, net3, net4, net5, net6, net7, net8, port;
2020-06-12 22:40:10 +00:00
int is_network = 0 ;
2000-10-01 12:29:12 +00:00
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2000-10-01 12:29:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! rig | | ! rig - > caps )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2000-10-01 12:29:12 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
rs = & rig - > state ;
2022-01-25 23:41:26 +00:00
rs - > rigport . rig = rig ;
2022-02-06 05:55:46 +00:00
rs - > rigport_deprecated . rig = rig ;
2022-03-01 17:40:14 +00:00
2022-06-04 13:53:44 +00:00
if ( strcmp ( rs - > rigport . pathname , " USB " ) = = 0 )
2022-06-04 13:13:19 +00:00
{
rig_debug ( RIG_DEBUG_ERR , " %s: 'USB' is not a valid COM port name \n " , __func__ ) ;
errno = 2 ;
RETURNFUNC ( - RIG_EINVAL ) ;
}
2022-02-06 05:55:46 +00:00
// rigctl/rigctld may have deprecated values -- backwards compatility
if ( rs - > rigport_deprecated . pathname [ 0 ] ! = 0 )
{
2022-03-01 17:40:14 +00:00
strcpy ( rs - > rigport . pathname , rs - > rigport_deprecated . pathname ) ;
2022-02-06 05:55:46 +00:00
}
2022-03-01 17:40:14 +00:00
2022-02-06 05:55:46 +00:00
if ( rs - > pttport_deprecated . type . ptt ! = RIG_PTT_NONE )
{
rs - > pttport . type . ptt = rs - > pttport_deprecated . type . ptt ;
}
2022-03-01 17:40:14 +00:00
2022-02-06 05:55:46 +00:00
if ( rs - > dcdport_deprecated . type . dcd ! = RIG_DCD_NONE )
{
rs - > dcdport . type . dcd = rs - > dcdport_deprecated . type . dcd ;
}
2022-03-01 17:40:14 +00:00
2022-02-06 05:55:46 +00:00
if ( rs - > pttport_deprecated . pathname [ 0 ] ! = 0 )
{
strcpy ( rs - > pttport . pathname , rs - > pttport_deprecated . pathname ) ;
}
2022-03-01 17:40:14 +00:00
2022-02-06 05:55:46 +00:00
if ( rs - > dcdport_deprecated . pathname [ 0 ] ! = 0 )
{
strcpy ( rs - > dcdport . pathname , rs - > dcdport_deprecated . pathname ) ;
}
2001-02-14 01:08:12 +00:00
2022-06-21 12:55:08 +00:00
rig_settings_load_all ( NULL ) ; // load default .hamlib_settings
2022-05-03 17:13:02 +00:00
// Read in our settings
char * cwd = malloc ( 4096 ) ;
2022-05-13 21:50:13 +00:00
if ( getcwd ( cwd , 4096 ) = = NULL )
2022-05-03 17:13:02 +00:00
{
rig_debug ( RIG_DEBUG_ERR , " %s: getcwd: %s \n " , __func__ , strerror ( errno ) ) ;
}
else
{
rig_debug ( RIG_DEBUG_VERBOSE , " %s: cwd=%s \n " , __func__ , cwd ) ;
char * path = malloc ( 4096 ) ;
extern char * settings_file ;
2022-06-06 13:50:29 +00:00
char * xdgpath = getenv ( " XDG_CONFIG_HOME " ) ;
2022-07-23 16:32:11 +00:00
settings_file = " hamlib_settings " ;
2022-06-06 13:50:29 +00:00
if ( xdgpath )
{
sprintf ( path , " %s/%s/%s " , xdgpath , cwd , settings_file ) ;
}
else
{
sprintf ( path , " %s/%s " , cwd , settings_file ) ;
}
2022-05-03 17:13:02 +00:00
FILE * fp = fopen ( path , " r " ) ;
2022-05-13 21:50:13 +00:00
2022-05-03 17:13:02 +00:00
if ( fp = = NULL )
{
rig_debug ( RIG_DEBUG_VERBOSE , " %s: %s does not exist \n " , __func__ , path ) ;
}
2022-05-13 21:50:13 +00:00
else
{
2022-05-03 17:13:02 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s: reading settings from %s \n " , __func__ , path ) ;
}
2022-05-13 21:50:13 +00:00
2022-05-03 17:13:02 +00:00
free ( path ) ;
}
free ( cwd ) ;
2022-01-05 17:12:43 +00:00
// 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 ;
2022-01-26 14:26:12 +00:00
rs - > rigport . asyncio = rs - > async_data_enabled ;
2022-01-05 17:12:43 +00:00
2022-01-25 23:41:26 +00:00
if ( strlen ( rs - > rigport . pathname ) > 0 )
2020-06-21 22:47:04 +00:00
{
2020-06-22 03:31:31 +00:00
char hoststr [ 256 ] , portstr [ 6 ] ;
2022-02-05 21:27:43 +00:00
status = parse_hoststr ( rs - > rigport . pathname , sizeof ( rs - > rigport . pathname ) ,
hoststr , portstr ) ;
2020-06-21 22:47:04 +00:00
if ( status = = RIG_OK ) { is_network = 1 ; }
}
#if 0
2020-04-03 13:02:31 +00:00
// determine if we have a network address
2020-06-12 22:40:10 +00:00
//
2022-01-25 23:41:26 +00:00
is_network | = sscanf ( rs - > rigport . pathname , " %u.%u.%u.%u:%u " , & net1 , & net2 ,
2020-06-12 22:40:10 +00:00
& net3 , & net4 , & port ) = = 5 ;
2022-01-25 23:41:26 +00:00
is_network | = sscanf ( rs - > rigport . pathname , " :%u " , & port ) = = 1 ;
is_network | = sscanf ( rs - > rigport . pathname , " %u::%u:%u:%u:%u:%u " , & net1 , & net2 ,
2020-06-12 22:40:10 +00:00
& net3 , & net4 , & net5 , & port ) = = 6 ;
2022-01-25 23:41:26 +00:00
is_network | = sscanf ( rs - > rigport . pathname , " %u:%u:%u:%u:%u:%u:%u:%u:%u " , & net1 ,
2020-06-12 22:40:10 +00:00
& net2 , & net3 , & net4 , & net5 , & net6 , & net7 , & net8 , & port ) = = 9 ;
2020-06-13 17:54:33 +00:00
2020-06-13 11:56:15 +00:00
// if we haven't met one of the condition above then we must have a hostname
2022-01-25 23:41:26 +00:00
if ( ! is_network & & ( token = strtok_r ( rs - > rigport . pathname , " : " , & strtokp ) ) )
2020-06-12 22:40:10 +00:00
{
2020-06-13 11:56:15 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: token1=%s \n " , __func__ , token ) ;
2020-06-12 22:40:10 +00:00
token = strtok_r ( strtokp , " : " , & strtokp ) ;
if ( token )
{
2020-06-13 11:56:15 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: token2=%s \n " , __func__ , token ) ;
2020-06-12 22:40:10 +00:00
2020-06-13 21:31:25 +00:00
if ( sscanf ( token , " %u " , & port ) ) { is_network | = 1 ; }
2020-06-12 22:40:10 +00:00
}
}
2020-06-21 22:47:04 +00:00
# endif
2020-06-12 22:40:10 +00:00
if ( is_network )
2020-04-03 13:02:31 +00:00
{
2020-04-10 14:13:35 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: using network address %s \n " , __func__ ,
2022-01-25 23:41:26 +00:00
rs - > rigport . pathname ) ;
rs - > rigport . type . rig = RIG_PORT_NETWORK ;
2021-05-31 14:05:41 +00:00
2021-06-03 04:06:22 +00:00
if ( RIG_BACKEND_NUM ( rig - > caps - > rig_model ) = = RIG_ICOM )
2021-05-31 14:05:41 +00:00
{
2022-04-16 13:18:16 +00:00
// Xiegu X6100 does TCP and does not support UDP spectrum that I know of
if ( rig - > caps - > rig_model ! = RIG_MODEL_X6100 )
{
rig_debug ( RIG_DEBUG_TRACE , " %s(%d): Icom rig UDP network enabled \n " , __FILE__ ,
2022-05-13 21:50:13 +00:00
__LINE__ ) ;
2022-04-16 13:18:16 +00:00
rs - > rigport . type . rig = RIG_PORT_UDP_NETWORK ;
}
2021-05-31 14:05:41 +00:00
}
2020-04-03 13:02:31 +00:00
}
2020-06-20 04:26:59 +00:00
if ( rs - > comm_state )
{
2022-02-05 21:27:43 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): %p rs->comm_state==1?=%d \n " , __func__ ,
__LINE__ , & rs - > comm_state ,
2022-01-01 05:49:29 +00:00
rs - > comm_state ) ;
2022-01-25 23:41:26 +00:00
port_close ( & rs - > rigport , rs - > rigport . type . rig ) ;
2020-06-21 21:15:00 +00:00
rs - > comm_state = 0 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2020-06-20 04:26:59 +00:00
}
2022-01-25 23:41:26 +00:00
rs - > rigport . fd = - 1 ;
2020-06-20 04:26:59 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > rigport . type . rig = = RIG_PORT_SERIAL )
2017-10-05 02:32:08 +00:00
{
2022-01-25 23:41:26 +00:00
if ( rs - > rigport . parm . serial . rts_state ! = RIG_SIGNAL_UNSET
& & rs - > rigport . parm . serial . handshake = = RIG_HANDSHAKE_HARDWARE )
2017-10-05 02:32:08 +00:00
{
rig_debug ( RIG_DEBUG_ERR ,
" %s: cannot set RTS with hardware handshake \" %s \" \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > rigport . pathname ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ECONF ) ;
2017-10-05 02:32:08 +00:00
}
2022-01-25 23:41:26 +00:00
if ( ' \0 ' = = rs - > pttport . pathname [ 0 ]
| | ! strcmp ( rs - > pttport . pathname , rs - > rigport . pathname ) )
2017-10-05 02:32:08 +00:00
{
/* check for control line conflicts */
2022-01-25 23:41:26 +00:00
if ( rs - > rigport . parm . serial . rts_state ! = RIG_SIGNAL_UNSET
& & rs - > pttport . type . ptt = = RIG_PTT_SERIAL_RTS )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
rig_debug ( RIG_DEBUG_ERR ,
2017-10-05 02:32:08 +00:00
" %s: cannot set RTS with PTT by RTS \" %s \" \n " ,
2017-08-05 14:09:12 +00:00
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > rigport . pathname ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ECONF ) ;
2017-10-05 02:32:08 +00:00
}
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > rigport . parm . serial . dtr_state ! = RIG_SIGNAL_UNSET
& & rs - > pttport . type . ptt = = RIG_PTT_SERIAL_DTR )
2017-10-05 02:32:08 +00:00
{
rig_debug ( RIG_DEBUG_ERR ,
" %s: cannot set DTR with PTT by DTR \" %s \" \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > rigport . pathname ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ECONF ) ;
2017-10-05 02:32:08 +00:00
}
2017-08-05 14:09:12 +00:00
}
}
2022-01-25 23:41:26 +00:00
status = port_open ( & rs - > rigport ) ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( status < 0 )
{
2022-01-01 05:49:29 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s: rs->comm_state==0?=%d \n " , __func__ ,
rs - > comm_state ) ;
2021-04-10 19:22:53 +00:00
rs - > comm_state = 0 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( status ) ;
2017-08-05 14:09:12 +00:00
}
2022-01-25 23:41:26 +00:00
switch ( rs - > pttport . type . ptt )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
case RIG_PTT_NONE :
case RIG_PTT_RIG :
case RIG_PTT_RIG_MICDATA :
break ;
case RIG_PTT_SERIAL_RTS :
case RIG_PTT_SERIAL_DTR :
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . pathname [ 0 ] = = ' \0 '
& & rs - > rigport . type . rig = = RIG_PORT_SERIAL )
2017-10-05 02:32:08 +00:00
{
2022-01-25 23:41:26 +00:00
strcpy ( rs - > pttport . pathname , rs - > rigport . pathname ) ;
2017-08-05 14:09:12 +00:00
}
2022-01-25 23:41:26 +00:00
if ( ! strcmp ( rs - > pttport . pathname , rs - > rigport . pathname ) )
2017-10-05 02:32:08 +00:00
{
2022-01-25 23:41:26 +00:00
rs - > pttport . fd = rs - > rigport . fd ;
2017-08-05 14:09:12 +00:00
/* Needed on Linux because the serial port driver sets RTS/DTR
on open - only need to address the PTT line as we offer
config parameters to control the other ( dtr_state &
rts_state ) */
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . type . ptt = = RIG_PTT_SERIAL_DTR )
2017-10-05 02:32:08 +00:00
{
2022-01-25 23:41:26 +00:00
status = ser_set_dtr ( & rs - > pttport , 0 ) ;
2017-08-05 14:09:12 +00:00
}
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . type . ptt = = RIG_PTT_SERIAL_RTS )
2017-10-05 02:32:08 +00:00
{
2022-01-25 23:41:26 +00:00
status = ser_set_rts ( & rs - > pttport , 0 ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
}
else
{
2022-01-25 23:41:26 +00:00
rs - > pttport . fd = ser_open ( & rs - > pttport ) ;
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . fd < 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
rig_debug ( RIG_DEBUG_ERR ,
" %s: cannot open PTT device \" %s \" \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > pttport . pathname ) ;
2017-08-05 14:09:12 +00:00
status = - RIG_EIO ;
2014-10-14 00:33:22 +00:00
}
2017-08-05 14:09:12 +00:00
if ( RIG_OK = = status
2022-01-25 23:41:26 +00:00
& & ( rs - > pttport . type . ptt = = RIG_PTT_SERIAL_DTR
| | rs - > pttport . type . ptt = = RIG_PTT_SERIAL_RTS ) )
2017-10-05 02:32:08 +00:00
{
/* Needed on Linux because the serial port driver sets
RTS / DTR high on open - set both low since we offer no
control of the non - PTT line and low is better than
high */
2022-01-25 23:41:26 +00:00
status = ser_set_dtr ( & rs - > pttport , 0 ) ;
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = status )
{
2022-01-25 23:41:26 +00:00
status = ser_set_rts ( & rs - > pttport , 0 ) ;
2017-10-05 02:32:08 +00:00
}
2014-10-14 00:33:22 +00:00
}
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
ser_close ( & rs - > pttport ) ;
2014-10-14 00:33:22 +00:00
}
2005-11-01 23:02:02 +00:00
2017-08-05 14:09:12 +00:00
break ;
case RIG_PTT_PARALLEL :
2022-01-25 23:41:26 +00:00
rs - > pttport . fd = par_open ( & rs - > pttport ) ;
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . fd < 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
rig_debug ( RIG_DEBUG_ERR ,
" %s: cannot open PTT device \" %s \" \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > pttport . pathname ) ;
2014-10-14 00:33:22 +00:00
status = - RIG_EIO ;
2017-10-05 02:32:08 +00:00
}
else
{
2022-01-25 23:41:26 +00:00
par_ptt_set ( & rs - > pttport , RIG_PTT_OFF ) ;
2017-08-05 14:09:12 +00:00
}
break ;
case RIG_PTT_CM108 :
2022-01-25 23:41:26 +00:00
rs - > pttport . fd = cm108_open ( & rs - > pttport ) ;
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
strncpy ( rs - > rigport . pathname , DEFAULT_CM108_PORT , HAMLIB_FILPATHLEN ) ;
rs - > rigport . parm . cm108 . ptt_bitnum = DEFAULT_CM108_PTT_BITNUM ;
rs - > pttport . parm . cm108 . ptt_bitnum = DEFAULT_CM108_PTT_BITNUM ;
2021-05-24 12:31:02 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . fd < 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
rig_debug ( RIG_DEBUG_ERR ,
" %s: cannot open PTT device \" %s \" \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > pttport . pathname ) ;
2017-08-05 14:09:12 +00:00
status = - RIG_EIO ;
2017-10-05 02:32:08 +00:00
}
else
{
2022-01-25 23:41:26 +00:00
cm108_ptt_set ( & rs - > pttport , RIG_PTT_OFF ) ;
2017-08-05 14:09:12 +00:00
}
break ;
case RIG_PTT_GPIO :
case RIG_PTT_GPION :
2022-01-25 23:41:26 +00:00
rs - > pttport . fd = gpio_open ( & rs - > pttport , 1 ,
RIG_PTT_GPION = = rs - > pttport . type . ptt ? 0 : 1 ) ;
2020-02-23 17:26:09 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . fd < 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
rig_debug ( RIG_DEBUG_ERR ,
2020-01-26 14:46:21 +00:00
" %s: cannot open PTT device \" GPIO%s \" \n " ,
2017-08-05 14:09:12 +00:00
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > pttport . pathname ) ;
2017-08-05 14:09:12 +00:00
status = - RIG_EIO ;
2017-10-05 02:32:08 +00:00
}
else
{
2022-01-25 23:41:26 +00:00
gpio_ptt_set ( & rs - > pttport , RIG_PTT_OFF ) ;
2017-08-05 14:09:12 +00:00
}
break ;
default :
rig_debug ( RIG_DEBUG_ERR ,
" %s: unsupported PTT type %d \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > pttport . type . ptt ) ;
2017-08-05 14:09:12 +00:00
status = - RIG_ECONF ;
}
2022-01-25 23:41:26 +00:00
switch ( rs - > dcdport . type . dcd )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
case RIG_DCD_NONE :
case RIG_DCD_RIG :
break ;
case RIG_DCD_SERIAL_DSR :
case RIG_DCD_SERIAL_CTS :
case RIG_DCD_SERIAL_CAR :
2022-01-25 23:41:26 +00:00
if ( rs - > dcdport . pathname [ 0 ] = = ' \0 '
& & rs - > rigport . type . rig = = RIG_PORT_SERIAL )
2017-10-05 02:32:08 +00:00
{
2022-01-25 23:41:26 +00:00
strcpy ( rs - > dcdport . pathname , rs - > rigport . pathname ) ;
2017-08-05 14:09:12 +00:00
}
2022-01-25 23:41:26 +00:00
if ( strcmp ( rs - > dcdport . pathname , rs - > rigport . pathname ) = = 0 )
2017-10-05 02:32:08 +00:00
{
2022-01-25 23:41:26 +00:00
rs - > dcdport . fd = rs - > rigport . fd ;
2017-09-09 09:50:23 +00:00
}
2017-10-05 02:32:08 +00:00
else
{
2022-01-25 23:41:26 +00:00
rs - > dcdport . fd = ser_open ( & rs - > dcdport ) ;
2017-09-09 09:50:23 +00:00
}
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > dcdport . fd < 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
rig_debug ( RIG_DEBUG_ERR ,
" %s: cannot open DCD device \" %s \" \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > dcdport . pathname ) ;
2017-08-05 14:09:12 +00:00
status = - RIG_EIO ;
}
break ;
case RIG_DCD_PARALLEL :
2022-01-25 23:41:26 +00:00
rs - > dcdport . fd = par_open ( & rs - > dcdport ) ;
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > dcdport . fd < 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
rig_debug ( RIG_DEBUG_ERR ,
" %s: cannot open DCD device \" %s \" \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > dcdport . pathname ) ;
2017-08-05 14:09:12 +00:00
status = - RIG_EIO ;
}
break ;
2018-03-29 21:55:25 +00:00
case RIG_DCD_GPIO :
case RIG_DCD_GPION :
2022-01-25 23:41:26 +00:00
rs - > dcdport . fd = gpio_open ( & rs - > dcdport , 0 ,
RIG_DCD_GPION = = rs - > dcdport . type . dcd ? 0 : 1 ) ;
2020-02-23 17:26:09 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > dcdport . fd < 0 )
2018-03-29 21:55:25 +00:00
{
rig_debug ( RIG_DEBUG_ERR ,
2020-01-26 14:46:21 +00:00
" %s: cannot open DCD device \" GPIO%s \" \n " ,
2018-03-29 21:55:25 +00:00
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > dcdport . pathname ) ;
2018-03-29 21:55:25 +00:00
status = - RIG_EIO ;
}
break ;
2017-08-05 14:09:12 +00:00
default :
rig_debug ( RIG_DEBUG_ERR ,
" %s: unsupported DCD type %d \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > dcdport . type . dcd ) ;
2017-08-05 14:09:12 +00:00
status = - RIG_ECONF ;
}
2017-10-05 02:32:08 +00:00
if ( status < 0 )
{
2022-01-25 23:41:26 +00:00
port_close ( & rs - > rigport , rs - > rigport . type . rig ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( status ) ;
2017-08-05 14:09:12 +00:00
}
2021-11-28 18:52:29 +00:00
status = async_data_handler_start ( rig ) ;
2021-12-25 18:33:32 +00:00
2021-11-28 18:52:29 +00:00
if ( status < 0 )
2021-11-20 19:33:29 +00:00
{
2022-01-25 23:41:26 +00:00
port_close ( & rs - > rigport , rs - > rigport . type . rig ) ;
2021-11-28 18:52:29 +00:00
RETURNFUNC ( status ) ;
2021-11-20 19:33:29 +00:00
}
2022-01-01 05:49:29 +00:00
2017-08-05 14:09:12 +00:00
add_opened_rig ( rig ) ;
rs - > comm_state = 1 ;
2022-02-05 21:27:43 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s: %p rs->comm_state==1?=%d \n " , __func__ ,
& rs - > comm_state ,
2022-01-01 05:49:29 +00:00
rs - > comm_state ) ;
2017-08-05 14:09:12 +00:00
/*
* Maybe the backend has something to initialize
* In case of failure , just close down and report error code .
*/
2022-07-23 16:32:11 +00:00
int retry_save = rs - > rigport . retry ;
rs - > rigport . retry = 1 ;
2017-10-05 02:32:08 +00:00
if ( caps - > rig_open ! = NULL )
{
2017-08-05 14:09:12 +00:00
status = caps - > rig_open ( rig ) ;
2017-10-05 02:32:08 +00:00
if ( status ! = RIG_OK )
{
2022-01-22 21:19:07 +00:00
remove_opened_rig ( rig ) ;
2021-11-28 18:52:29 +00:00
async_data_handler_stop ( rig ) ;
2022-01-25 23:41:26 +00:00
port_close ( & rs - > rigport , rs - > rigport . type . rig ) ;
2022-02-05 21:27:43 +00:00
memcpy ( & rs - > rigport_deprecated , & rs - > rigport , sizeof ( hamlib_port_t_deprecated ) ) ;
2022-01-22 21:19:07 +00:00
rs - > comm_state = 0 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( status ) ;
2017-08-05 14:09:12 +00:00
}
}
/*
* trigger state - > current_vfo first retrieval
*/
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-04-29 22:23:37 +00:00
2021-07-13 20:49:15 +00:00
if ( caps - > get_vfo & & rig_get_vfo ( rig , & rs - > current_vfo ) = = RIG_OK )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
rs - > tx_vfo = rs - > current_vfo ;
}
2021-11-05 22:23:10 +00:00
else // no get_vfo so set some sensible defaults
2020-06-01 19:08:45 +00:00
{
2021-08-13 12:42:39 +00:00
//int backend_num = RIG_BACKEND_NUM(rig->caps->rig_model);
2020-06-01 19:08:45 +00:00
rs - > tx_vfo = RIG_VFO_TX ;
2021-11-28 18:41:10 +00:00
2021-11-05 22:23:10 +00:00
// If we haven't gotten the vfo by now we will default to VFO_CURR
2021-11-28 18:41:10 +00:00
if ( rs - > current_vfo = = RIG_VFO_NONE ) { rs - > current_vfo = RIG_VFO_CURR ; }
rig_debug ( RIG_DEBUG_TRACE , " %s: vfo_curr=%s, tx_vfo=%s \n " , __func__ ,
rig_strvfo ( rs - > current_vfo ) , rig_strvfo ( rs - > tx_vfo ) ) ;
2020-06-03 12:20:48 +00:00
2021-08-13 12:42:39 +00:00
#if 0 // done in the back end
2021-08-26 11:49:24 +00:00
2020-06-03 12:20:48 +00:00
if ( backend_num = = RIG_ICOM )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-04-16 22:30:39 +00:00
rig_set_vfo ( rig , RIG_VFO_A ) ; // force VFOA as our startup VFO
2020-06-03 23:12:17 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: Icom rig so default vfo = %s \n " , __func__ ,
rig_strvfo ( rs - > current_vfo ) ) ;
2020-06-03 12:20:48 +00:00
}
2021-08-26 11:49:24 +00:00
2021-08-13 12:42:39 +00:00
# endif
2021-08-26 11:49:24 +00:00
2021-08-13 12:42:39 +00:00
if ( rig - > caps - > set_vfo = = NULL )
2020-06-03 23:12:17 +00:00
{
// for non-Icom rigs if there's no set_vfo then we need to set one
2021-08-03 04:37:31 +00:00
rs - > current_vfo = vfo_fixup ( rig , RIG_VFO_A , rig - > state . cache . split ) ;
2020-06-03 16:35:16 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: No set_vfo function rig so default vfo = %s \n " ,
2020-06-03 12:20:48 +00:00
__func__ , rig_strvfo ( rs - > current_vfo ) ) ;
}
else
{
2020-06-03 23:12:17 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: default vfo = %s \n " , __func__ ,
rig_strvfo ( rs - > current_vfo ) ) ;
2020-06-03 12:20:48 +00:00
}
2020-06-01 19:08:45 +00:00
}
2002-01-07 18:18:15 +00:00
2020-07-04 16:26:54 +00:00
if ( rs - > auto_disable_screensaver )
{
// try to turn off the screensaver if possible
// don't care about the return here...it's just a nice-to-have
parm_value . i = 0 ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-07-04 16:26:54 +00:00
rig_set_parm ( rig , RIG_PARM_SCREENSAVER , parm_value ) ;
}
2020-02-23 16:50:26 +00:00
2021-01-19 18:12:24 +00:00
// read frequency to update internal status
// freq_t freq;
// if (caps->get_freq) rig_get_freq(rig, RIG_VFO_A, &freq);
// if (caps->get_freq) rig_get_freq(rig, RIG_VFO_B, &freq);
2022-06-07 16:50:25 +00:00
// prime the freq and mode settings
// don't care about the return here -- if it doesn't work so be it
freq_t freq ;
2022-07-18 14:51:45 +00:00
if ( rig - > caps - > get_freq )
{
int retval = rig_get_freq ( rig , RIG_VFO_A , & freq ) ;
2022-07-23 16:32:11 +00:00
if ( retval = = RIG_OK & & rig - > caps - > rig_model ! = RIG_MODEL_F6K )
2022-07-18 14:51:45 +00:00
{
2022-07-26 15:00:36 +00:00
vfo_t tx_vfo ;
split_t split ;
2022-07-18 14:51:45 +00:00
rig_get_freq ( rig , RIG_VFO_B , & freq ) ;
2022-07-26 15:00:36 +00:00
rig_get_split_vfo ( rig , RIG_VFO_RX , & tx_vfo , & split ) ;
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): Current split=%d, tx_vfo=%s \n " , __func__ , __LINE__ , split , rig_strvfo ( tx_vfo ) ) ;
2022-07-18 14:51:45 +00:00
rmode_t mode ;
pbwidth_t width ;
rig_get_mode ( rig , RIG_VFO_A , & mode , & width ) ;
rig_get_mode ( rig , RIG_VFO_B , & mode , & width ) ;
}
}
rs - > rigport . retry = retry_save ;
2021-08-27 17:04:16 +00:00
2022-02-05 21:27:43 +00:00
memcpy ( & rs - > rigport_deprecated , & rs - > rigport , sizeof ( hamlib_port_t_deprecated ) ) ;
memcpy ( & rs - > pttport_deprecated , & rs - > pttport , sizeof ( hamlib_port_t_deprecated ) ) ;
memcpy ( & rs - > dcdport_deprecated , & rs - > dcdport , sizeof ( hamlib_port_t_deprecated ) ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
2001-06-30 12:36:43 +00:00
/**
* \ brief close the communication to the rig
2017-08-05 14:09:12 +00:00
* \ param rig The # RIG handle of the radio to be closed
2001-06-30 12:36:43 +00:00
*
* Closes communication to a radio which \ a RIG handle has been passed
* by argument that was previously open with rig_open ( ) .
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
*
* \ sa rig_cleanup ( ) , rig_open ( )
2000-10-01 12:29:12 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_close ( RIG * rig )
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
struct rig_state * rs ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! rig | | ! rig - > caps )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
rs = & rig - > state ;
2017-10-05 02:32:08 +00:00
if ( ! rs - > comm_state )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
/*
* Let the backend say 73 s to the rig .
* and ignore the return code .
*/
2017-10-05 02:32:08 +00:00
if ( caps - > rig_close )
{
2017-08-05 14:09:12 +00:00
caps - > rig_close ( rig ) ;
}
2021-11-28 18:52:29 +00:00
async_data_handler_stop ( rig ) ;
2017-08-05 14:09:12 +00:00
/*
* FIXME : what happens if PTT and rig ports are the same ?
* ( eg . ptt_type = RIG_PTT_SERIAL )
*/
2022-01-25 23:41:26 +00:00
switch ( rs - > pttport . type . ptt )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
case RIG_PTT_NONE :
case RIG_PTT_RIG :
case RIG_PTT_RIG_MICDATA :
break ;
case RIG_PTT_SERIAL_RTS :
2017-10-05 02:32:08 +00:00
2017-08-05 14:09:12 +00:00
// If port is already closed, do nothing
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . fd > - 1 )
2017-10-05 02:32:08 +00:00
{
2022-01-25 23:41:26 +00:00
ser_set_rts ( & rs - > pttport , 0 ) ;
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . fd ! = rs - > rigport . fd )
2017-10-05 02:32:08 +00:00
{
2022-01-25 23:41:26 +00:00
port_close ( & rs - > pttport , RIG_PORT_SERIAL ) ;
2022-02-05 21:27:43 +00:00
memcpy ( & rs - > rigport_deprecated , & rs - > rigport , sizeof ( hamlib_port_t_deprecated ) ) ;
2017-08-05 14:09:12 +00:00
}
}
break ;
case RIG_PTT_SERIAL_DTR :
2017-10-05 02:32:08 +00:00
2017-08-05 14:09:12 +00:00
// If port is already closed, do nothing
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . fd > - 1 )
2017-10-05 02:32:08 +00:00
{
2022-01-25 23:41:26 +00:00
ser_set_dtr ( & rs - > pttport , 0 ) ;
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . fd ! = rs - > rigport . fd )
2017-10-05 02:32:08 +00:00
{
2022-01-25 23:41:26 +00:00
port_close ( & rs - > pttport , RIG_PORT_SERIAL ) ;
2022-02-05 21:27:43 +00:00
memcpy ( & rs - > rigport_deprecated , & rs - > rigport , sizeof ( hamlib_port_t_deprecated ) ) ;
2017-08-05 14:09:12 +00:00
}
}
break ;
case RIG_PTT_PARALLEL :
2022-01-25 23:41:26 +00:00
par_ptt_set ( & rs - > pttport , RIG_PTT_OFF ) ;
par_close ( & rs - > pttport ) ;
2017-08-05 14:09:12 +00:00
break ;
case RIG_PTT_CM108 :
2022-01-25 23:41:26 +00:00
cm108_ptt_set ( & rs - > pttport , RIG_PTT_OFF ) ;
cm108_close ( & rs - > pttport ) ;
2017-08-05 14:09:12 +00:00
break ;
case RIG_PTT_GPIO :
case RIG_PTT_GPION :
2022-01-25 23:41:26 +00:00
gpio_ptt_set ( & rs - > pttport , RIG_PTT_OFF ) ;
gpio_close ( & rs - > pttport ) ;
2020-01-26 12:50:07 +00:00
break ;
2017-08-05 14:09:12 +00:00
default :
rig_debug ( RIG_DEBUG_ERR ,
" %s: unsupported PTT type %d \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > pttport . type . ptt ) ;
2017-08-05 14:09:12 +00:00
}
2022-01-25 23:41:26 +00:00
switch ( rs - > dcdport . type . dcd )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
case RIG_DCD_NONE :
case RIG_DCD_RIG :
break ;
case RIG_DCD_SERIAL_DSR :
case RIG_DCD_SERIAL_CTS :
case RIG_DCD_SERIAL_CAR :
2022-01-25 23:41:26 +00:00
if ( rs - > dcdport . fd ! = rs - > rigport . fd )
2019-11-30 16:19:08 +00:00
{
2022-01-25 23:41:26 +00:00
port_close ( & rs - > dcdport , RIG_PORT_SERIAL ) ;
2022-02-05 21:27:43 +00:00
memcpy ( & rs - > rigport_deprecated , & rs - > rigport , sizeof ( hamlib_port_t_deprecated ) ) ;
2017-09-09 09:50:23 +00:00
}
2019-11-30 16:19:08 +00:00
2017-08-05 14:09:12 +00:00
break ;
case RIG_DCD_PARALLEL :
2022-01-25 23:41:26 +00:00
par_close ( & rs - > dcdport ) ;
2017-08-05 14:09:12 +00:00
break ;
2018-03-29 21:55:25 +00:00
case RIG_DCD_GPIO :
case RIG_DCD_GPION :
2022-01-25 23:41:26 +00:00
gpio_close ( & rs - > dcdport ) ;
2020-01-26 12:50:07 +00:00
break ;
2018-03-29 21:55:25 +00:00
2017-08-05 14:09:12 +00:00
default :
rig_debug ( RIG_DEBUG_ERR ,
" %s: unsupported DCD type %d \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > dcdport . type . dcd ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-09 23:06:32 +00:00
2022-01-25 23:41:26 +00:00
rs - > dcdport . fd = rs - > pttport . fd = - 1 ;
2001-02-09 23:06:32 +00:00
2022-01-25 23:41:26 +00:00
port_close ( & rs - > rigport , rs - > rigport . type . rig ) ;
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
2017-08-05 14:09:12 +00:00
remove_opened_rig ( rig ) ;
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
2017-08-05 14:09:12 +00:00
rs - > comm_state = 0 ;
2022-02-05 21:27:43 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): %p rs->comm_state==0?=%d \n " , __func__ ,
__LINE__ , & rs - > comm_state ,
2022-01-01 05:49:29 +00:00
rs - > comm_state ) ;
2001-10-25 21:22:49 +00:00
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
}
2000-10-01 12:29:12 +00:00
2017-08-05 14:09:12 +00:00
2001-06-30 12:36:43 +00:00
/**
* \ brief release a rig handle and free associated memory
2017-08-05 14:09:12 +00:00
* \ param rig The # RIG handle of the radio to be closed
2001-06-30 12:36:43 +00:00
*
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* Releases a rig struct which port has eventually been closed already
2001-06-30 12:36:43 +00:00
* with rig_close ( ) .
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
*
* \ sa rig_init ( ) , rig_close ( )
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_cleanup ( RIG * rig )
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
{
2017-10-05 02:32:08 +00:00
if ( ! rig | | ! rig - > caps )
{
2022-02-05 21:27:43 +00:00
return ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
2017-08-05 14:09:12 +00:00
/*
* check if they forgot to close the rig
*/
2017-10-05 02:32:08 +00:00
if ( rig - > state . comm_state )
{
2017-08-05 14:09:12 +00:00
rig_close ( rig ) ;
}
2001-10-16 21:18:02 +00:00
2017-08-05 14:09:12 +00:00
/*
* basically free up the priv struct
*/
2017-10-05 02:32:08 +00:00
if ( rig - > caps - > rig_cleanup )
{
2017-08-05 14:09:12 +00:00
rig - > caps - > rig_cleanup ( rig ) ;
}
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
2017-08-05 14:09:12 +00:00
free ( rig ) ;
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
2022-02-05 21:27:43 +00:00
return ( RIG_OK ) ;
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
}
2020-02-24 15:34:02 +00:00
/**
* \ brief timeout ( secs ) to stop rigctld when VFO is manually changed
* \ param rig The rig handle
2020-04-05 03:49:27 +00:00
* \ param seconds The timeout to set to
2020-02-24 15:34:02 +00:00
*
2020-04-05 03:49:27 +00:00
* timeout seconds to stop rigctld when VFO is manually changed
2020-02-24 15:34:02 +00:00
* turns on / off the radio .
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2020-02-24 15:34:02 +00:00
* set appropriately ) .
*
2020-10-23 16:34:42 +00:00
* \ sa rig_set_twiddle ( )
2020-02-24 15:34:02 +00:00
*/
int HAMLIB_API rig_set_twiddle ( RIG * rig , int seconds )
{
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2020-02-24 15:34:02 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2020-02-24 15:34:02 +00:00
}
rig - > state . twiddle_timeout = seconds ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2020-02-24 15:34:02 +00:00
}
2020-10-23 16:34:42 +00:00
/**
* \ brief For GPredict to avoid reading frequency on uplink VFO
* \ param rig The rig handle
* \ param seconds 1 = Ignore Sub , 2 = Ignore Main
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
2020-10-23 16:34:42 +00:00
* a negative value if an error occurred ( in which case , cause is
* set appropriately ) .
*
* \ sa rig_set_uplink ( )
*/
int HAMLIB_API rig_set_uplink ( RIG * rig , int val )
{
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2020-10-23 16:34:42 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2020-10-23 16:34:42 +00:00
}
rig - > state . uplink = val ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2020-10-23 16:34:42 +00:00
}
2020-02-24 15:34:02 +00:00
/**
* \ brief get the twiddle timeout value ( secs )
* \ param rig The rig handle
* \ param seconds The timeout value
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2020-02-24 15:34:02 +00:00
* set appropriately ) .
*
2020-04-09 22:56:19 +00:00
* \ sa rig_set_twiddle ( )
2020-02-24 15:34:02 +00:00
*/
int HAMLIB_API rig_get_twiddle ( RIG * rig , int * seconds )
{
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2020-02-24 15:34:02 +00:00
if ( CHECK_RIG_ARG ( rig ) | | ! seconds )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2020-02-24 15:34:02 +00:00
}
* seconds = rig - > state . twiddle_timeout ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2020-02-24 15:34:02 +00:00
}
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
2021-03-02 19:02:13 +00:00
// detect if somebody is twiddling the VFO
// indicator is last set freq doesn't match current freq
// so we have to query freq every time we set freq or vfo to handle this
2021-09-09 20:36:43 +00:00
static int twiddling ( RIG * rig )
2021-03-02 19:02:13 +00:00
{
const struct rig_caps * caps ;
if ( rig - > state . twiddle_timeout = = 0 ) { return 0 ; } // don't detect twiddling
caps = rig - > caps ;
if ( caps - > get_freq ) // gotta have get_freq of course
{
freq_t curr_freq = 0 ;
int retval2 ;
int elapsed ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-02 19:02:13 +00:00
retval2 = caps - > get_freq ( rig , RIG_VFO_CURR , & curr_freq ) ;
if ( retval2 = = RIG_OK & & rig - > state . current_freq ! = curr_freq )
{
rig_debug ( RIG_DEBUG_TRACE ,
" %s: Somebody twiddling the VFO? last_freq=%.0f, curr_freq=%.0f \n " , __func__ ,
rig - > state . current_freq , curr_freq ) ;
if ( rig - > state . current_freq = = 0 )
{
rig - > state . current_freq = curr_freq ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( 0 ) ; // not twiddling as first time freq is being set
2021-03-02 19:02:13 +00:00
}
rig - > state . twiddle_time = time ( NULL ) ; // update last twiddle time
rig - > state . current_freq = curr_freq ; // we have a new freq to remember
2021-11-28 18:52:29 +00:00
rig_set_cache_freq ( rig , RIG_VFO_CURR , curr_freq ) ;
2021-03-02 19:02:13 +00:00
}
elapsed = time ( NULL ) - rig - > state . twiddle_time ;
if ( elapsed < rig - > state . twiddle_timeout )
{
2021-04-15 16:47:58 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: Twiddle elapsed < %d, elapsed=%d \n " , __func__ ,
rig - > state . twiddle_timeout , elapsed ) ;
rig - > state . twiddle_state = TWIDDLE_ON ; // gets turned off in rig_set_freq;
2021-03-02 19:02:13 +00:00
RETURNFUNC ( 1 ) ; // would be better as error but other software won't handle it
}
}
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( 0 ) ;
2021-03-02 19:02:13 +00:00
}
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the frequency of the target VFO
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param freq The frequency to set to
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Sets the frequency of the target VFO .
2000-10-01 12:29:12 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_get_freq ( )
2000-10-01 12:29:12 +00:00
*/
2022-01-31 05:37:01 +00:00
# if BUILTINFUNC
# undef rig_set_freq
int HAMLIB_API rig_set_freq ( RIG * rig , vfo_t vfo , freq_t freq , const char * func )
# else
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_set_freq ( RIG * rig , vfo_t vfo , freq_t freq )
2022-01-31 05:37:01 +00:00
# endif
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
2019-12-09 04:37:56 +00:00
int retcode ;
2021-01-02 22:32:16 +00:00
freq_t freq_new = freq ;
2021-04-23 16:01:17 +00:00
vfo_t vfo_save ;
2017-08-05 14:09:12 +00:00
2021-11-10 05:20:02 +00:00
ELAPSED1 ;
2022-01-31 05:37:01 +00:00
# if BUILTINFUNC
2022-02-05 21:27:43 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s called vfo=%s, freq=%.0f, called from %s \n " ,
__func__ ,
2022-01-31 05:37:01 +00:00
rig_strvfo ( vfo ) , freq , func ) ;
# else
2021-01-18 04:24:39 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s called vfo=%s, freq=%.0f \n " , __func__ ,
2020-07-02 16:18:33 +00:00
rig_strvfo ( vfo ) , freq ) ;
2022-01-31 05:37:01 +00:00
# endif
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2021-04-15 16:47:58 +00:00
if ( rig - > state . twiddle_state = = TWIDDLE_ON )
{
// we keep skipping set_freq while the vfo knob is in motion
2021-04-22 04:48:29 +00:00
rig_debug ( RIG_DEBUG_VERBOSE ,
" %s: Twiddle on so skipping this set_freq request one time \n " , __func__ ) ;
2021-04-15 16:47:58 +00:00
rig - > state . twiddle_state = TWIDDLE_OFF ;
}
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2019-11-30 16:19:08 +00:00
2018-11-07 16:11:58 +00:00
if ( rig - > state . lo_freq ! = 0.0 )
{
2019-11-30 16:19:08 +00:00
freq - = rig - > state . lo_freq ;
2018-11-07 16:11:58 +00:00
}
2019-11-30 16:19:08 +00:00
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( rig - > state . vfo_comp ! = 0.0 )
{
2017-08-05 14:09:12 +00:00
freq + = ( freq_t ) ( ( double ) rig - > state . vfo_comp * freq ) ;
}
2017-10-05 02:32:08 +00:00
if ( caps - > set_freq = = NULL )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2021-04-23 16:01:17 +00:00
vfo_save = rig - > state . current_vfo ;
2021-08-03 04:37:31 +00:00
vfo = vfo_fixup ( rig , vfo , rig - > state . cache . split ) ;
2021-04-23 16:01:17 +00:00
2017-08-05 14:09:12 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_FREQ )
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_CURR | | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2020-02-23 17:26:09 +00:00
if ( twiddling ( rig ) )
{
rig_debug ( RIG_DEBUG_TRACE , " %s: Ignoring set_freq due to VFO twiddling \n " ,
__func__ ) ;
2021-04-29 22:23:37 +00:00
if ( vfo ! = vfo_save & & vfo ! = RIG_VFO_CURR )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-04-27 14:36:27 +00:00
rig_set_vfo ( rig , vfo_save ) ;
}
2021-04-29 22:23:37 +00:00
2021-09-25 13:59:57 +00:00
ELAPSED2 ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 (
2021-01-18 14:28:20 +00:00
RIG_OK ) ; // would be better as error but other software won't handle errors
2020-02-23 14:45:25 +00:00
}
2021-11-28 18:41:10 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: TARGETABLE_FREQ vfo=%s \n " , __func__ ,
rig_strvfo ( vfo ) ) ;
2021-02-28 15:46:01 +00:00
int retry = 3 ;
2021-02-26 17:07:32 +00:00
freq_t tfreq = 0 ;
2021-02-28 15:46:01 +00:00
do
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-02-16 21:58:12 +00:00
retcode = caps - > set_freq ( rig , vfo , freq ) ;
2021-02-28 15:46:01 +00:00
2021-12-27 20:46:56 +00:00
// some rig will return -RIG_ENTARGET if cannot set ptt while transmitting
// we will just return RIG_OK and the frequency set will be ignored
2022-01-01 05:49:29 +00:00
if ( retcode = = - RIG_ENTARGET ) { RETURNFUNC ( RIG_OK ) ; }
2021-02-28 15:46:01 +00:00
if ( retcode ! = RIG_OK ) { RETURNFUNC ( retcode ) ; }
2021-11-28 18:52:29 +00:00
rig_set_cache_freq ( rig , vfo , ( freq_t ) 0 ) ;
2021-02-28 15:46:01 +00:00
2021-04-23 16:01:17 +00:00
#if 0 // this verification seems to be causing bad behavior on some rigs
2021-03-26 15:51:00 +00:00
2021-02-27 05:37:25 +00:00
if ( caps - > get_freq )
2021-02-16 21:58:12 +00:00
{
retcode = rig_get_freq ( rig , vfo , & tfreq ) ;
2021-02-28 15:46:01 +00:00
2021-02-27 05:53:31 +00:00
// WSJT-X does a 55Hz check so we can stop early if that's the case
2021-02-28 15:46:01 +00:00
if ( ( long long ) freq % 100 = = 55 ) { retry = 0 ; }
if ( retcode ! = RIG_OK ) { RETURNFUNC ( retcode ) ; }
2021-02-16 21:58:12 +00:00
if ( tfreq ! = freq )
{
2021-02-28 15:46:01 +00:00
hl_usleep ( 50 * 1000 ) ;
rig_debug ( RIG_DEBUG_WARN ,
" %s: freq not set correctly?? got %.0f asked for %.0f, retry=%d \n " , __func__ ,
( double ) tfreq , ( double ) freq , retry ) ;
2021-02-16 21:58:12 +00:00
}
}
2021-02-27 05:53:31 +00:00
else { retry = 0 ; }
2021-03-26 15:51:00 +00:00
2021-03-18 20:40:32 +00:00
# else
tfreq = freq ;
# endif
2021-02-28 15:46:01 +00:00
}
while ( tfreq ! = freq & & retry - - > 0 ) ;
2021-03-08 22:44:29 +00:00
if ( retry = = 0 & & tfreq ! = freq )
2021-02-16 21:58:12 +00:00
{
2021-03-15 22:51:22 +00:00
rig_debug ( RIG_DEBUG_ERR ,
" %s: unable to set frequency!!, asked for %.0f, got %.0f \n " , __func__ , freq ,
tfreq ) ;
2021-02-16 21:58:12 +00:00
}
2017-10-05 02:32:08 +00:00
}
else
{
2021-11-28 18:41:10 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: not a TARGETABLE_FREQ vfo=%s \n " , __func__ ,
rig_strvfo ( vfo ) ) ;
2020-02-23 17:26:09 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2021-09-29 04:03:56 +00:00
retcode = rig_set_vfo ( rig , vfo ) ;
if ( retcode ! = RIG_OK )
{
rig_debug ( RIG_DEBUG_ERR , " %s: set_vfo failed: %s \n " , __func__ ,
2021-09-29 04:13:37 +00:00
rigerror ( retcode ) ) ;
2021-09-29 04:03:56 +00:00
}
2020-02-24 05:20:33 +00:00
if ( twiddling ( rig ) )
{
rig_debug ( RIG_DEBUG_TRACE , " %s: Ignoring set_freq due to VFO twiddling \n " ,
__func__ ) ;
2021-04-29 22:23:37 +00:00
if ( vfo ! = vfo_save & & vfo ! = RIG_VFO_CURR )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-04-27 14:36:27 +00:00
rig_set_vfo ( rig , vfo_save ) ;
}
2021-04-29 22:23:37 +00:00
2021-09-25 13:59:57 +00:00
ELAPSED2 ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 (
2021-01-18 14:28:20 +00:00
RIG_OK ) ; // would be better as error but other software won't handle errors
2020-02-24 05:20:33 +00:00
}
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_freq ( rig , vfo , freq ) ;
}
2021-01-02 21:22:01 +00:00
if ( retcode = = RIG_OK & & caps - > get_freq ! = NULL )
2020-05-05 14:59:55 +00:00
{
2020-07-02 14:40:48 +00:00
// verify our freq to ensure HZ mods are seen
// some rigs truncate or round e.g. 1,2,5,10,20,100Hz intervals
// we'll try this all the time and if it works out OK eliminate the #else
if ( ( unsigned long long ) freq % 100 ! = 0 // only need to do if < 100Hz interval
2020-07-04 16:20:38 +00:00
| | freq > 100e6 // or if we are in the VHF and up range
2020-07-02 14:40:48 +00:00
#if 0
// do we need to only do this when cache is turned on? 2020-07-02 W9MDB
& & rig - > state . cache . timeout_ms > 0
# endif
)
{
2021-11-28 18:52:29 +00:00
rig_set_cache_freq ( rig , RIG_VFO_ALL , ( freq_t ) 0 ) ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-07-02 14:40:48 +00:00
retcode = rig_get_freq ( rig , vfo , & freq_new ) ;
2021-01-17 13:25:28 +00:00
if ( retcode ! = RIG_OK ) { RETURNFUNC ( retcode ) ; }
2020-07-02 14:40:48 +00:00
}
if ( freq_new ! = freq )
{
2021-02-08 23:31:43 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: Asked freq=%.0f, got freq=%.0f \n " , __func__ ,
2020-07-02 14:40:48 +00:00
freq ,
freq_new ) ;
}
2020-05-05 14:59:28 +00:00
}
2021-01-09 16:13:17 +00:00
2021-01-02 21:22:01 +00:00
// update our current freq too
if ( vfo = = RIG_VFO_CURR | | vfo = = rig - > state . current_vfo ) { rig - > state . current_freq = freq_new ; }
2021-03-15 22:51:22 +00:00
2021-11-28 18:52:29 +00:00
rig_set_cache_freq ( rig , vfo , freq_new ) ;
2020-05-01 17:03:54 +00:00
2021-11-11 23:10:57 +00:00
if ( vfo ! = RIG_VFO_CURR )
2021-04-29 22:23:37 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-04-27 14:36:27 +00:00
rig_set_vfo ( rig , vfo_save ) ;
}
2021-04-23 16:01:17 +00:00
2021-09-25 13:59:57 +00:00
ELAPSED2 ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( retcode ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the frequency of the target VFO
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param freq The location where to store the current frequency
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves the frequency of the target VFO .
2017-08-05 14:09:12 +00:00
* The value stored at \ a freq location equals RIG_FREQ_NONE when the current
* frequency of the VFO is not defined ( e . g . blank memory ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2000-10-01 12:29:12 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_freq ( )
2000-10-01 12:29:12 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_get_freq ( RIG * rig , vfo_t vfo , freq_t * freq )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
2019-12-09 04:37:56 +00:00
int retcode ;
2020-06-08 04:31:20 +00:00
vfo_t curr_vfo ;
2021-03-15 16:15:41 +00:00
rmode_t mode ;
pbwidth_t width ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2022-03-01 17:40:14 +00:00
RETURNFUNC2 ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
2021-09-26 04:16:08 +00:00
2021-09-25 13:59:57 +00:00
ELAPSED1 ;
2022-02-05 21:27:43 +00:00
2021-04-10 12:58:38 +00:00
if ( ! freq )
2017-10-05 02:32:08 +00:00
{
2021-04-10 12:58:38 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: freq ptr invalid \n " , __func__ ) ;
2022-03-01 17:40:14 +00:00
RETURNFUNC2 ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2021-08-26 11:49:24 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d) called vfo=%s \n " , __func__ , __LINE__ ,
rig_strvfo ( vfo ) ) ;
2021-11-28 18:52:29 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2021-04-10 12:58:38 +00:00
2021-01-24 16:51:19 +00:00
2020-06-08 04:31:20 +00:00
curr_vfo = rig - > state . current_vfo ; // save vfo for restore later
2021-08-03 04:37:31 +00:00
vfo = vfo_fixup ( rig , vfo , rig - > state . cache . split ) ;
2020-05-30 14:34:13 +00:00
2021-08-26 11:49:24 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d) vfo=%s, curr_vfo=%s \n " , __FILE__ , __LINE__ ,
rig_strvfo ( vfo ) , rig_strvfo ( curr_vfo ) ) ;
2021-06-16 15:11:45 +00:00
2021-04-29 22:23:37 +00:00
if ( vfo = = RIG_VFO_CURR ) { vfo = curr_vfo ; }
2021-04-23 22:43:54 +00:00
2020-10-23 16:34:42 +00:00
// we ignore get_freq for the uplink VFO for gpredict to behave better
if ( ( rig - > state . uplink = = 1 & & vfo = = RIG_VFO_SUB )
| | ( rig - > state . uplink = = 2 & & vfo = = RIG_VFO_MAIN ) )
{
rig_debug ( RIG_DEBUG_TRACE , " %s: uplink=%d, ignoring get_freq \n " , __func__ ,
rig - > state . uplink ) ;
rig_debug ( RIG_DEBUG_TRACE , " %s: split=%d, satmode=%d, tx_vfo=%s \n " , __func__ ,
rig - > state . cache . split , rig - > state . cache . satmode ,
rig_strvfo ( rig - > state . tx_vfo ) ) ;
// always return the cached freq for this clause
2021-03-15 16:15:41 +00:00
int cache_ms_freq , cache_ms_mode , cache_ms_width ;
2021-03-15 22:51:22 +00:00
rig_get_cache ( rig , vfo , freq , & cache_ms_freq , & mode , & cache_ms_mode , & width ,
& cache_ms_width ) ;
2021-09-25 13:59:57 +00:00
ELAPSED2 ;
2022-02-05 21:27:43 +00:00
return ( RIG_OK ) ;
2020-10-23 16:34:42 +00:00
}
2021-11-28 18:52:29 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2021-03-26 15:51:00 +00:00
2020-06-03 23:12:17 +00:00
// there are some rigs that can't get VFOA freq while VFOB is transmitting
// so we'll return the cached VFOA freq for them
2020-06-04 15:27:00 +00:00
// should we use the cached ptt maybe? No -- we have to be 100% sure we're in PTT to ignore this request
if ( ( vfo = = RIG_VFO_A | | vfo = = RIG_VFO_MAIN ) & & rig - > state . cache . split & &
( rig - > caps - > rig_model = = RIG_MODEL_FTDX101D
| | rig - > caps - > rig_model = = RIG_MODEL_IC910 ) )
{
// if we're in PTT don't get VFOA freq -- otherwise we interrupt transmission
2020-06-03 23:12:17 +00:00
ptt_t ptt ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-06-03 23:12:17 +00:00
retcode = rig_get_ptt ( rig , RIG_VFO_CURR , & ptt ) ;
if ( retcode ! = RIG_OK )
{
2022-03-01 17:40:14 +00:00
RETURNFUNC2 ( retcode ) ;
2020-06-03 23:12:17 +00:00
}
if ( ptt )
{
2020-06-04 15:27:00 +00:00
rig_debug ( RIG_DEBUG_TRACE ,
" %s: split is on so returning VFOA last known freq \n " ,
2020-06-03 23:12:17 +00:00
__func__ ) ;
2020-06-04 15:27:00 +00:00
* freq = rig - > state . cache . freqMainA ;
2022-02-05 21:27:43 +00:00
return ( RIG_OK ) ;
2020-06-03 23:12:17 +00:00
}
}
2021-03-15 16:15:41 +00:00
int cache_ms_freq , cache_ms_mode , cache_ms_width ;
2021-03-15 22:51:22 +00:00
rig_get_cache ( rig , vfo , freq , & cache_ms_freq , & mode , & cache_ms_mode , & width ,
& cache_ms_width ) ;
2021-06-01 12:10:44 +00:00
//rig_debug(RIG_DEBUG_TRACE, "%s: cache check1 age=%dms\n", __func__, cache_ms_freq);
2020-06-03 23:12:17 +00:00
2021-11-28 18:52:29 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2021-03-26 15:51:00 +00:00
2021-12-06 16:23:18 +00:00
if ( * freq ! = 0 & & ( cache_ms_freq < rig - > state . cache . timeout_ms
2022-02-05 21:27:43 +00:00
| | ( rig - > state . cache . timeout_ms = = HAMLIB_CACHE_ALWAYS
| | rig - > state . use_cached_freq ) ) )
2020-05-01 17:03:54 +00:00
{
2020-05-18 22:53:49 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: %s cache hit age=%dms, freq=%.0f \n " , __func__ ,
2021-03-15 16:15:41 +00:00
rig_strvfo ( vfo ) , cache_ms_freq , * freq ) ;
2021-09-25 13:59:57 +00:00
ELAPSED2 ;
2022-02-05 21:27:43 +00:00
return ( RIG_OK ) ;
2020-05-01 17:03:54 +00:00
}
else
{
2020-05-03 22:24:42 +00:00
rig_debug ( RIG_DEBUG_TRACE ,
2021-03-15 22:51:22 +00:00
" %s: cache miss age=%dms, cached_vfo=%s, asked_vfo=%s \n " , __func__ ,
cache_ms_freq ,
2021-03-15 16:15:41 +00:00
rig_strvfo ( vfo ) , rig_strvfo ( vfo ) ) ;
2020-05-01 17:03:54 +00:00
}
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > get_freq = = NULL )
{
2022-03-01 17:40:14 +00:00
RETURNFUNC2 ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2021-11-28 18:41:10 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): vfo_opt=%d, model=%d \n " , __func__ ,
__LINE__ , rig - > state . vfo_opt , rig - > caps - > rig_model ) ;
2020-05-25 04:42:35 +00:00
// If we're in vfo_mode then rigctld will do any VFO swapping we need
2017-08-05 14:09:12 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_FREQ )
2020-05-27 17:23:08 +00:00
| | vfo = = RIG_VFO_CURR | | vfo = = rig - > state . current_vfo
2020-06-23 04:16:02 +00:00
| | ( rig - > state . vfo_opt = = 1 & & rig - > caps - > rig_model = = RIG_MODEL_NETRIGCTL ) )
2020-07-02 14:40:48 +00:00
{
// If rig does not have set_vfo we need to change vfo
if ( vfo = = RIG_VFO_CURR & & caps - > set_vfo = = NULL )
2020-06-03 16:27:45 +00:00
{
2021-08-03 04:37:31 +00:00
vfo = vfo_fixup ( rig , RIG_VFO_A , rig - > state . cache . split ) ;
2020-06-03 23:12:17 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: no set_vfo so vfo=%s \n " , __func__ ,
rig_strvfo ( vfo ) ) ;
2020-06-03 16:27:45 +00:00
}
2017-08-05 14:09:12 +00:00
retcode = caps - > get_freq ( rig , vfo , freq ) ;
2020-05-12 17:19:33 +00:00
2021-11-28 18:52:29 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2021-03-26 15:51:00 +00:00
2021-03-15 22:51:22 +00:00
// sometimes a network rig like FLRig will return freq=0
2021-03-12 15:02:26 +00:00
// so we'll just reuse the cache for that condition
2021-03-15 22:51:22 +00:00
if ( * freq = = 0 )
{
int freq_ms , mode_ms , width_ms ;
rig_get_cache ( rig , vfo , freq , & freq_ms , & mode , & mode_ms , & width , & width_ms ) ;
2021-03-12 15:02:26 +00:00
}
2020-05-12 17:19:33 +00:00
if ( retcode = = RIG_OK )
{
2021-11-28 18:52:29 +00:00
rig_set_cache_freq ( rig , vfo , * freq ) ;
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2020-05-11 23:00:52 +00:00
}
2017-10-05 02:32:08 +00:00
}
else
{
2019-12-09 23:12:13 +00:00
int rc2 ;
2020-06-10 03:37:03 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2022-03-01 17:40:14 +00:00
RETURNFUNC2 ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2022-03-01 17:40:14 +00:00
RETURNFUNC2 ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2021-11-28 18:52:29 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2021-03-26 15:51:00 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > get_freq ( rig , vfo , freq ) ;
/* try and revert even if we had an error above */
2021-07-13 20:49:15 +00:00
rc2 = RIG_OK ;
2021-08-26 11:49:24 +00:00
2021-07-13 20:49:15 +00:00
if ( curr_vfo ! = RIG_VFO_NONE )
{
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
}
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2021-11-28 18:52:29 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
rig_set_cache_freq ( rig , vfo , * freq ) ;
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
}
}
/* VFO compensation */
2017-10-05 02:32:08 +00:00
if ( rig - > state . vfo_comp ! = 0.0 )
2020-07-02 14:40:48 +00:00
{
* freq = ( freq_t ) ( * freq / ( 1.0 + ( double ) rig - > state . vfo_comp ) ) ;
2017-08-05 14:09:12 +00:00
}
if ( retcode = = RIG_OK
2019-11-30 16:19:08 +00:00
& & ( vfo = = RIG_VFO_CURR | | vfo = = rig - > state . current_vfo ) )
2020-07-02 14:40:48 +00:00
{
rig - > state . current_freq = * freq ;
}
2019-11-30 16:19:08 +00:00
2020-07-02 14:40:48 +00:00
if ( rig - > state . lo_freq ! = 0.0 )
{
* freq + = rig - > state . lo_freq ;
}
2019-11-30 16:19:08 +00:00
2022-04-29 22:17:43 +00:00
if ( retcode = = RIG_OK )
2022-05-13 21:50:13 +00:00
{
2022-04-29 22:17:43 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2022-05-13 21:50:13 +00:00
}
2021-11-28 18:52:29 +00:00
rig_set_cache_freq ( rig , vfo , * freq ) ;
2022-05-13 21:50:13 +00:00
2022-04-29 22:17:43 +00:00
if ( retcode = = RIG_OK )
2022-05-13 21:50:13 +00:00
{
2022-04-29 22:17:43 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2022-05-13 21:50:13 +00:00
}
2020-05-01 17:03:54 +00:00
2021-09-25 13:59:57 +00:00
ELAPSED2 ;
2022-02-05 21:27:43 +00:00
return ( retcode ) ;
2000-10-01 12:29:12 +00:00
}
2021-02-08 22:29:04 +00:00
/**
* \ brief get the frequency of VFOA and VFOB
* \ param rig The rig handle
* \ param freqA The location where to store the VFOA / Main frequency
* \ param freqB The location where to store the VFOB / Sub frequency
*
* Retrieves the frequency of VFOA / Main and VFOB / Sub
* The value stored at \ a freq location equals RIG_FREQ_NONE when the current
* frequency of the VFO is not defined ( e . g . blank memory ) .
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
2021-02-08 22:29:04 +00:00
* a negative value if an error occurred ( in which case , cause is
* set appropriately ) .
*
* \ sa rig_set_freq ( )
*/
int HAMLIB_API rig_get_freqs ( RIG * rig , freq_t * freqA , freq_t freqB )
{
// we will attempt to avoid vfo swapping in this routine
2022-02-05 21:27:43 +00:00
return ( - RIG_ENIMPL ) ;
2021-02-08 22:29:04 +00:00
}
2000-10-01 12:29:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the mode of the target VFO
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param mode The mode to set to
* \ param width The passband width to set to
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2016-04-09 13:13:49 +00:00
* Sets the mode and associated passband of the target VFO . The
* passband \ a width must be supported by the backend of the rig or
* the special value RIG_PASSBAND_NOCHANGE which leaves the passband
* unchanged from the current value or default for the mode determined
* by the rig .
2000-10-01 12:29:12 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_get_mode ( )
2000-10-01 12:29:12 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_set_mode ( RIG * rig , vfo_t vfo , rmode_t mode , pbwidth_t width )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
2019-12-09 04:37:56 +00:00
int retcode ;
2022-06-07 03:54:10 +00:00
int locked_mode ;
2017-08-05 14:09:12 +00:00
2021-11-10 05:20:02 +00:00
ELAPSED1 ;
2021-11-28 18:41:10 +00:00
rig_debug ( RIG_DEBUG_VERBOSE ,
2022-05-04 18:08:17 +00:00
" %s called, vfo=%s, mode=%s, width=%d, curr_vfo=%s \n " , __func__ ,
2021-11-28 18:41:10 +00:00
rig_strvfo ( vfo ) , rig_strrmode ( mode ) , ( int ) width ,
rig_strvfo ( rig - > state . current_vfo ) ) ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2021-09-29 03:57:35 +00:00
2022-06-07 03:54:10 +00:00
rig_get_lock_mode ( rig , & locked_mode ) ;
if ( locked_mode ) { return ( RIG_OK ) ; }
2021-07-12 13:57:02 +00:00
// do not mess with mode while PTT is on
if ( rig - > state . cache . ptt )
{
rig_debug ( RIG_DEBUG_VERBOSE , " %s PTT on so set_mode ignored \n " , __func__ ) ;
return RIG_OK ;
}
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > set_mode = = NULL )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2022-05-21 18:23:51 +00:00
if ( vfo = = RIG_VFO_CURR )
{
vfo = rig - > state . current_vfo ;
2022-05-17 12:49:44 +00:00
}
2022-05-21 18:23:51 +00:00
2022-05-17 12:49:44 +00:00
if ( mode = = RIG_MODE_NONE ) // the we just use the current mode to set width
2022-05-17 11:39:10 +00:00
{
pbwidth_t twidth ;
rig_get_mode ( rig , vfo , & mode , & twidth ) ;
}
2021-05-04 19:34:51 +00:00
2021-12-29 05:20:57 +00:00
vfo = vfo_fixup ( rig , vfo , rig - > state . cache . split ) ;
2017-08-05 14:09:12 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_MODE )
2019-11-30 16:19:08 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-10-05 02:32:08 +00:00
retcode = caps - > set_mode ( rig , vfo , mode , width ) ;
2022-03-02 13:47:17 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: targetable retcode after set_mode(%s)=%d \n " ,
__func__ , rig_strrmode ( mode ) , retcode ) ;
2017-10-05 02:32:08 +00:00
}
else
{
2019-12-09 23:12:13 +00:00
int rc2 ;
2020-03-20 12:51:32 +00:00
vfo_t curr_vfo ;
2017-08-05 14:09:12 +00:00
2021-11-22 22:54:22 +00:00
// if not a targetable rig we will only set mode on VFOB if it is changing
if ( rig - > state . cache . modeMainB = = mode )
{
2021-11-28 18:41:10 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: VFOB mode not changing so ignoring \n " ,
__func__ ) ;
2022-02-05 21:27:43 +00:00
RETURNFUNC2 ( RIG_OK ) ;
2021-11-22 22:54:22 +00:00
}
2021-11-28 18:41:10 +00:00
2021-03-12 15:02:26 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: not targetable need vfo swap \n " , __func__ ) ;
2021-03-15 22:51:22 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
curr_vfo = rig - > state . current_vfo ;
2022-07-23 16:32:11 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): curr_vfo=%s, vfo=%s \n " , __func__ , __LINE__ , rig_strvfo ( curr_vfo ) , rig_strvfo ( vfo ) ) ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
retcode = caps - > set_mode ( rig , vfo , mode , width ) ;
/* try and revert even if we had an error above */
2019-12-09 23:12:13 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2017-08-05 14:09:12 +00:00
/* return the first error code */
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
retcode = rc2 ;
}
}
2022-04-15 18:21:35 +00:00
if ( retcode ! = RIG_OK )
{
2022-03-02 13:47:17 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: failed set_mode(%s)=%s \n " ,
__func__ , rig_strrmode ( mode ) , rigerror ( retcode ) ) ;
2022-04-15 18:21:35 +00:00
RETURNFUNC ( retcode ) ;
2022-03-02 13:47:17 +00:00
}
2021-03-15 22:51:22 +00:00
2021-11-28 18:52:29 +00:00
rig_set_cache_mode ( rig , vfo , mode , width ) ;
2020-05-01 17:03:54 +00:00
2021-09-26 04:26:49 +00:00
ELAPSED2 ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( retcode ) ;
2000-10-01 12:29:12 +00:00
}
2021-03-26 15:51:00 +00:00
/*
2001-06-30 12:36:43 +00:00
* \ brief get the mode of the target VFO
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param mode The location where to store the current mode
* \ param width The location where to store the current passband width
2000-10-01 12:29:12 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves the mode and passband of the target VFO .
* If the backend is unable to determine the width , the \ a width
* will be set to RIG_PASSBAND_NORMAL as a default .
2017-08-05 14:09:12 +00:00
* The value stored at \ a mode location equals RIG_MODE_NONE when the current
* mode of the VFO is not defined ( e . g . blank memory ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-08-21 19:59:02 +00:00
* Note that if either \ a mode or \ a width is NULL , - RIG_EINVAL is returned .
* Both must be given even if only one is actually wanted .
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_mode ( )
2000-10-01 12:29:12 +00:00
*/
2017-10-05 02:32:08 +00:00
int HAMLIB_API rig_get_mode ( RIG * rig ,
vfo_t vfo ,
rmode_t * mode ,
2017-08-05 14:09:12 +00:00
pbwidth_t * width )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
2019-12-09 04:37:56 +00:00
int retcode ;
2021-03-15 16:15:41 +00:00
freq_t freq ;
2017-08-05 14:09:12 +00:00
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2021-09-26 04:26:49 +00:00
ELAPSED1 ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! mode | | ! width )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > get_mode = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2021-12-29 05:50:32 +00:00
vfo = vfo_fixup ( rig , vfo , rig - > state . cache . split ) ;
2021-03-26 15:51:00 +00:00
* mode = RIG_MODE_NONE ;
2021-11-28 18:52:29 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2021-03-15 16:15:41 +00:00
int cache_ms_freq , cache_ms_mode , cache_ms_width ;
2021-03-15 22:51:22 +00:00
rig_get_cache ( rig , vfo , & freq , & cache_ms_freq , mode , & cache_ms_mode , width ,
& cache_ms_width ) ;
2021-03-02 17:11:12 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: %s cache check age=%dms \n " , __func__ ,
2021-10-14 16:36:34 +00:00
rig_strvfo ( vfo ) , cache_ms_mode ) ;
2020-05-01 17:03:54 +00:00
2021-11-28 18:52:29 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2021-03-26 15:51:00 +00:00
2022-02-05 21:27:43 +00:00
if ( rig - > state . cache . timeout_ms = = HAMLIB_CACHE_ALWAYS
| | rig - > state . use_cached_mode )
2021-12-02 22:53:22 +00:00
{
rig_debug ( RIG_DEBUG_TRACE , " %s: cache hit age mode=%dms, width=%dms \n " ,
__func__ , cache_ms_mode , cache_ms_width ) ;
ELAPSED2 ;
RETURNFUNC ( RIG_OK ) ;
}
2021-12-06 16:23:18 +00:00
2021-03-26 15:51:00 +00:00
if ( ( * mode ! = RIG_MODE_NONE & & cache_ms_mode < rig - > state . cache . timeout_ms )
& & cache_ms_width < rig - > state . cache . timeout_ms )
2020-05-01 17:03:54 +00:00
{
2021-03-15 22:51:22 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: cache hit age mode=%dms, width=%dms \n " ,
__func__ , cache_ms_mode , cache_ms_width ) ;
2021-03-02 17:11:12 +00:00
2021-09-26 04:26:49 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2020-05-01 17:03:54 +00:00
}
else
{
2021-03-15 22:51:22 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: cache miss age mode=%dms, width=%dms \n " ,
__func__ , cache_ms_mode , cache_ms_width ) ;
2020-05-01 17:03:54 +00:00
}
2017-08-05 14:09:12 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_MODE )
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_CURR
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-10-05 02:32:08 +00:00
retcode = caps - > get_mode ( rig , vfo , mode , width ) ;
2020-10-07 04:14:27 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: retcode after get_mode=%d \n " , __func__ ,
retcode ) ;
2021-11-28 18:52:29 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2017-10-05 02:32:08 +00:00
}
else
{
2019-12-09 23:12:13 +00:00
int rc2 ;
2020-03-20 12:51:32 +00:00
vfo_t curr_vfo ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
curr_vfo = rig - > state . current_vfo ;
2021-03-26 15:51:00 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s(%d): vfo=%s, curr_vfo=%s \n " , __func__ , __LINE__ ,
rig_strvfo ( vfo ) , rig_strvfo ( curr_vfo ) ) ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-26 15:51:00 +00:00
retcode = caps - > set_vfo ( rig , vfo = = RIG_VFO_CURR ? RIG_VFO_A : vfo ) ;
2021-11-28 18:52:29 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > get_mode ( rig , vfo , mode , width ) ;
/* try and revert even if we had an error above */
2019-12-09 23:12:13 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
}
}
if ( retcode = = RIG_OK
2019-11-30 16:19:08 +00:00
& & ( vfo = = RIG_VFO_CURR | | vfo = = rig - > state . current_vfo ) )
2017-10-05 02:32:08 +00:00
{
2020-12-13 16:20:02 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s(%d): debug \n " , __func__ , __LINE__ ) ;
2017-10-05 02:32:08 +00:00
rig - > state . current_mode = * mode ;
rig - > state . current_width = * width ;
2021-11-28 18:52:29 +00:00
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( * width = = RIG_PASSBAND_NORMAL & & * mode ! = RIG_MODE_NONE )
{
2020-12-13 16:20:02 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s(%d): debug \n " , __func__ , __LINE__ ) ;
2017-08-05 14:09:12 +00:00
* width = rig_passband_normal ( rig , * mode ) ;
}
2021-11-28 18:52:29 +00:00
rig_set_cache_mode ( rig , vfo , * mode , * width ) ;
rig_cache_show ( rig , __func__ , __LINE__ ) ;
2020-05-01 17:03:54 +00:00
2021-09-26 04:26:49 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-16 22:08:51 +00:00
}
2000-10-01 12:29:12 +00:00
2017-08-05 14:09:12 +00:00
2001-04-24 19:55:29 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the normal passband of a mode
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param mode The mode to get the passband
2001-02-27 23:10:12 +00:00
*
2001-06-30 12:36:43 +00:00
* Returns the normal ( default ) passband for the given \ a mode .
2001-04-24 19:55:29 +00:00
*
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* \ return the passband in Hz if the operation has been successful ,
* or a 0 if an error occurred ( passband not found , whatever ) .
2001-04-24 19:55:29 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_passband_narrow ( ) , rig_passband_wide ( )
2001-02-27 23:10:12 +00:00
*/
2004-10-02 10:32:09 +00:00
pbwidth_t HAMLIB_API rig_passband_normal ( RIG * rig , rmode_t mode )
2001-02-27 23:10:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_state * rs ;
int i ;
2001-02-27 23:10:12 +00:00
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2001-02-27 23:10:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! rig )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_PASSBAND_NORMAL ) ; /* huhu! */
2017-08-05 14:09:12 +00:00
}
2001-02-27 23:10:12 +00:00
2017-08-05 14:09:12 +00:00
rs = & rig - > state ;
2001-04-24 19:55:29 +00:00
2021-05-03 20:35:56 +00:00
// return CW for CWR and RTTY for RTTYR
2021-05-05 15:45:22 +00:00
if ( mode = = RIG_MODE_CWR ) { mode = RIG_MODE_CW ; }
if ( mode = = RIG_MODE_RTTYR ) { mode = RIG_MODE_RTTY ; }
2021-05-03 20:35:56 +00:00
2021-03-06 18:37:53 +00:00
for ( i = 0 ; i < HAMLIB_FLTLSTSIZ & & rs - > filters [ i ] . modes ; i + + )
2017-10-05 02:32:08 +00:00
{
if ( rs - > filters [ i ] . modes & mode )
{
2022-02-05 21:27:43 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %.*s%d:%s: return filter#%d, width=%d \n " ,
rig - > state . depth , spaces ( ) , rig - > state . depth , __func__ , i ,
2020-12-22 05:50:29 +00:00
( int ) rs - > filters [ i ] . width ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( rs - > filters [ i ] . width ) ;
2017-08-05 14:09:12 +00:00
}
}
2020-12-22 05:50:29 +00:00
rig_debug ( RIG_DEBUG_VERBOSE ,
" %s: filter not found...return RIG_PASSBAND_NORMAL=%d \n " , __func__ ,
( int ) RIG_PASSBAND_NORMAL ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_PASSBAND_NORMAL ) ;
2001-02-27 23:10:12 +00:00
}
2017-08-05 14:09:12 +00:00
2001-04-24 19:55:29 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the narrow passband of a mode
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param mode The mode to get the passband
2001-04-24 19:55:29 +00:00
*
2001-06-30 12:36:43 +00:00
* Returns the narrow ( closest ) passband for the given \ a mode .
2017-08-05 14:09:12 +00:00
* EXAMPLE : rig_set_mode ( my_rig , RIG_MODE_LSB ,
* rig_passband_narrow ( my_rig , RIG_MODE_LSB ) ) ;
2001-04-24 19:55:29 +00:00
*
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* \ return the passband in Hz if the operation has been successful ,
* or a 0 if an error occurred ( passband not found , whatever ) .
2001-04-24 19:55:29 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_passband_normal ( ) , rig_passband_wide ( )
2001-04-24 19:55:29 +00:00
*/
2004-10-02 10:32:09 +00:00
pbwidth_t HAMLIB_API rig_passband_narrow ( RIG * rig , rmode_t mode )
2001-02-27 23:10:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_state * rs ;
pbwidth_t normal ;
int i ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! rig )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( 0 ) ; /* huhu! */
2017-08-05 14:09:12 +00:00
}
rs = & rig - > state ;
2021-03-06 18:37:53 +00:00
for ( i = 0 ; i < HAMLIB_FLTLSTSIZ - 1 & & rs - > filters [ i ] . modes ; i + + )
2017-10-05 02:32:08 +00:00
{
if ( rs - > filters [ i ] . modes & mode )
{
2017-08-05 14:09:12 +00:00
normal = rs - > filters [ i ] . width ;
2021-03-06 18:37:53 +00:00
for ( i + + ; i < HAMLIB_FLTLSTSIZ & & rs - > filters [ i ] . modes ; i + + )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
if ( ( rs - > filters [ i ] . modes & mode ) & &
2017-10-05 02:32:08 +00:00
( rs - > filters [ i ] . width < normal ) )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( rs - > filters [ i ] . width ) ;
2017-08-05 14:09:12 +00:00
}
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( 0 ) ;
2017-08-05 14:09:12 +00:00
}
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( 0 ) ;
2001-02-27 23:10:12 +00:00
}
2017-08-05 14:09:12 +00:00
2001-04-24 19:55:29 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the wide passband of a mode
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param mode The mode to get the passband
2001-04-24 19:55:29 +00:00
*
2001-06-30 12:36:43 +00:00
* Returns the wide ( default ) passband for the given \ a mode .
2017-08-05 14:09:12 +00:00
* EXAMPLE : rig_set_mode ( my_rig , RIG_MODE_AM ,
* rig_passband_wide ( my_rig , RIG_MODE_AM ) ) ;
2001-04-24 19:55:29 +00:00
*
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* \ return the passband in Hz if the operation has been successful ,
* or a 0 if an error occurred ( passband not found , whatever ) .
2001-04-24 19:55:29 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_passband_narrow ( ) , rig_passband_normal ( )
2001-04-24 19:55:29 +00:00
*/
2017-08-05 14:09:12 +00:00
pbwidth_t HAMLIB_API rig_passband_wide ( RIG * rig , rmode_t mode )
{
const struct rig_state * rs ;
pbwidth_t normal ;
int i ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! rig )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( 0 ) ; /* huhu! */
2017-08-05 14:09:12 +00:00
}
rs = & rig - > state ;
2021-03-06 18:37:53 +00:00
for ( i = 0 ; i < HAMLIB_FLTLSTSIZ - 1 & & rs - > filters [ i ] . modes ; i + + )
2017-10-05 02:32:08 +00:00
{
if ( rs - > filters [ i ] . modes & mode )
{
2017-08-05 14:09:12 +00:00
normal = rs - > filters [ i ] . width ;
2021-03-06 18:37:53 +00:00
for ( i + + ; i < HAMLIB_FLTLSTSIZ & & rs - > filters [ i ] . modes ; i + + )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
if ( ( rs - > filters [ i ] . modes & mode ) & &
2017-10-05 02:32:08 +00:00
( rs - > filters [ i ] . width > normal ) )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( rs - > filters [ i ] . width ) ;
2017-08-05 14:09:12 +00:00
}
}
2001-04-24 19:55:29 +00:00
2021-01-17 13:25:28 +00:00
RETURNFUNC ( 0 ) ;
2017-08-05 14:09:12 +00:00
}
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( 0 ) ;
2001-02-27 23:10:12 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the current VFO
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The VFO to set to
2000-10-01 12:29:12 +00:00
*
2010-02-14 21:47:49 +00:00
* Sets the current VFO . The VFO can be RIG_VFO_A , RIG_VFO_B , RIG_VFO_C
2001-06-30 12:36:43 +00:00
* for VFOA , VFOB , VFOC respectively or RIG_VFO_MEM for Memory mode .
* Supported VFOs depends on rig capabilities .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_get_vfo ( )
2000-10-01 12:29:12 +00:00
*/
2021-08-13 12:42:39 +00:00
# if BUILTINFUNC
# undef rig_set_vfo
int HAMLIB_API rig_set_vfo ( RIG * rig , vfo_t vfo , const char * func )
# else
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_set_vfo ( RIG * rig , vfo_t vfo )
2021-08-13 12:42:39 +00:00
# endif
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode ;
2020-02-24 05:20:33 +00:00
freq_t curr_freq ;
2022-02-03 16:41:54 +00:00
vfo_t curr_vfo = RIG_VFO_CURR ;
2001-01-05 18:24:20 +00:00
2021-11-10 05:20:02 +00:00
ELAPSED1 ;
2021-01-17 13:32:42 +00:00
ENTERFUNC ;
2021-08-13 12:42:39 +00:00
# if BUILTINFUNC
2021-08-26 11:49:24 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s called vfo=%s, called from %s \n " , __func__ ,
rig_strvfo ( vfo ) , func ) ;
2021-08-13 12:42:39 +00:00
# else
2020-05-27 17:23:08 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s called vfo=%s \n " , __func__ , rig_strvfo ( vfo ) ) ;
2021-08-13 12:42:39 +00:00
# endif
2021-04-22 04:48:29 +00:00
2021-04-18 16:35:35 +00:00
if ( vfo = = RIG_VFO_B | | vfo = = RIG_VFO_SUB )
{
2021-04-22 04:48:29 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s ********************** called vfo=%s \n " ,
__func__ , rig_strvfo ( vfo ) ) ;
2021-04-18 16:35:35 +00:00
}
2000-10-01 12:29:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2021-08-03 04:37:31 +00:00
vfo = vfo_fixup ( rig , vfo , rig - > state . cache . split ) ;
2021-04-15 22:19:42 +00:00
2021-01-17 13:25:28 +00:00
if ( vfo = = RIG_VFO_CURR ) { RETURNFUNC ( RIG_OK ) ; }
2020-06-12 21:34:48 +00:00
2022-06-08 03:50:59 +00:00
if ( rig - > caps - > get_vfo )
2022-01-19 21:40:08 +00:00
{
2022-06-08 03:50:59 +00:00
retcode = rig_get_vfo ( rig , & curr_vfo ) ;
if ( retcode ! = RIG_OK )
{
rig_debug ( RIG_DEBUG_WARN , " %s: rig_get_vfo error=%s \n " , __func__ ,
2022-02-05 21:27:43 +00:00
rigerror ( retcode ) ) ;
2022-06-08 03:50:59 +00:00
}
2022-02-05 21:27:43 +00:00
2022-06-08 03:50:59 +00:00
if ( curr_vfo = = vfo ) { RETURNFUNC ( RIG_OK ) ; }
}
2022-01-19 21:40:08 +00:00
2021-08-03 04:37:31 +00:00
#if 0 // removing this check 20210801 -- should be mapped already
2021-08-26 11:49:24 +00:00
2020-05-21 13:51:41 +00:00
// make sure we are asking for a VFO that the rig actually has
2020-05-27 17:23:08 +00:00
if ( ( vfo = = RIG_VFO_A | | vfo = = RIG_VFO_B ) & & ! VFO_HAS_A_B )
{
rig_debug ( RIG_DEBUG_ERR , " %s: rig does not have %s \n " , __func__ ,
rig_strvfo ( vfo ) ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2020-05-21 13:51:41 +00:00
}
2020-05-27 17:23:08 +00:00
2020-05-21 13:51:41 +00:00
if ( ( vfo = = RIG_VFO_MAIN | | vfo = = RIG_VFO_SUB ) & & ! VFO_HAS_MAIN_SUB )
{
2020-05-27 17:23:08 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: rig does not have %s \n " , __func__ ,
rig_strvfo ( vfo ) ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2020-05-21 13:51:41 +00:00
}
2021-08-26 11:49:24 +00:00
2021-08-03 04:37:31 +00:00
# endif
2020-05-27 17:23:08 +00:00
2021-08-03 04:37:31 +00:00
vfo = vfo_fixup ( rig , vfo , rig - > state . cache . split ) ;
2020-05-21 13:51:41 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > set_vfo = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-27 23:10:12 +00:00
2020-02-23 17:26:09 +00:00
if ( twiddling ( rig ) )
{
rig_debug ( RIG_DEBUG_TRACE , " %s: Ignoring set_vfo due to VFO twiddling \n " ,
__func__ ) ;
2022-02-05 21:27:43 +00:00
RETURNFUNC (
RIG_OK ) ; // would be better as error but other software won't handle errors
2020-02-23 14:28:19 +00:00
}
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-06-16 15:11:45 +00:00
vfo_t vfo_save = rig - > state . current_vfo ;
2021-08-26 11:49:24 +00:00
if ( vfo ! = RIG_VFO_CURR ) { rig - > state . current_vfo = vfo ; }
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-01-05 18:24:20 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode = = RIG_OK )
{
2021-06-16 15:11:45 +00:00
vfo = rig - > state . current_vfo ; // vfo may change in the rig backend
2020-05-08 16:24:33 +00:00
rig - > state . cache . vfo = vfo ;
2021-03-26 15:51:00 +00:00
elapsed_ms ( & rig - > state . cache . time_vfo , HAMLIB_ELAPSED_SET ) ;
2020-06-10 03:37:03 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: rig->state.current_vfo=%s \n " , __func__ ,
rig_strvfo ( vfo ) ) ;
2017-08-05 14:09:12 +00:00
}
2020-05-09 15:22:46 +00:00
else
{
2021-02-03 05:13:12 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: set_vfo %s failed with '%.10000s' \n " , __func__ ,
2020-05-12 17:19:33 +00:00
rig_strvfo ( vfo ) , rigerror ( retcode ) ) ;
2021-06-16 15:11:45 +00:00
rig - > state . current_vfo = vfo_save ;
2020-05-09 15:22:46 +00:00
}
2020-02-24 15:34:02 +00:00
2020-02-24 05:20:33 +00:00
// we need to update our internal freq to avoid getting detected as twiddling
2020-05-09 15:22:46 +00:00
// we only get the freq if we set the vfo OK
2020-05-15 19:17:59 +00:00
if ( retcode = = RIG_OK & & caps - > get_freq )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-26 15:51:00 +00:00
retcode = caps - > get_freq ( rig , vfo , & curr_freq ) ;
2021-02-28 15:46:01 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: retcode from rig_get_freq = %.10000s \n " ,
__func__ ,
2020-06-12 03:29:00 +00:00
rigerror ( retcode ) ) ;
2021-11-28 18:52:29 +00:00
rig_set_cache_freq ( rig , vfo , curr_freq ) ;
2020-05-15 19:17:59 +00:00
}
2021-03-15 16:15:41 +00:00
else
2021-03-15 22:51:22 +00:00
{
// if no get_freq clear all cache to be sure we refresh whatever we can
2021-11-28 18:52:29 +00:00
rig_set_cache_freq ( rig , RIG_VFO_ALL , ( freq_t ) 0 ) ;
2020-10-12 04:40:29 +00:00
}
2020-05-15 19:17:59 +00:00
2021-03-26 15:51:00 +00:00
#if 0 // with new cache should not have to expire here anymore
2020-05-01 17:03:54 +00:00
// expire several cached items when we switch VFOs
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_vfo , HAMLIB_ELAPSED_INVALIDATE ) ;
2021-03-15 16:15:41 +00:00
elapsed_ms ( & rig - > state . cache . time_modeMainA , HAMLIB_ELAPSED_INVALIDATE ) ;
elapsed_ms ( & rig - > state . cache . time_modeMainB , HAMLIB_ELAPSED_INVALIDATE ) ;
elapsed_ms ( & rig - > state . cache . time_modeMainC , HAMLIB_ELAPSED_INVALIDATE ) ;
elapsed_ms ( & rig - > state . cache . time_widthMainA , HAMLIB_ELAPSED_INVALIDATE ) ;
elapsed_ms ( & rig - > state . cache . time_widthMainB , HAMLIB_ELAPSED_INVALIDATE ) ;
elapsed_ms ( & rig - > state . cache . time_widthMainC , HAMLIB_ELAPSED_INVALIDATE ) ;
2021-03-26 15:51:00 +00:00
# endif
2020-05-01 17:03:54 +00:00
2021-08-26 11:49:24 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: return %d, vfo=%s, curr_vfo=%s \n " , __func__ ,
retcode ,
2021-06-16 15:11:45 +00:00
rig_strvfo ( vfo ) , rig_strvfo ( rig - > state . current_vfo ) ) ;
2021-11-10 05:20:02 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the current VFO
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The location where to store the current VFO
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2010-02-14 21:47:49 +00:00
* Retrieves the current VFO . The VFO can be RIG_VFO_A , RIG_VFO_B , RIG_VFO_C
2001-06-30 12:36:43 +00:00
* for VFOA , VFOB , VFOC respectively or RIG_VFO_MEM for Memory mode .
* Supported VFOs depends on rig capabilities .
2000-10-01 12:29:12 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_vfo ( )
2000-10-01 12:29:12 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_get_vfo ( RIG * rig , vfo_t * vfo )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode ;
2020-05-01 17:03:54 +00:00
int cache_ms ;
2001-01-05 18:24:20 +00:00
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2021-09-25 13:59:57 +00:00
ELAPSED1 ;
2000-10-01 12:29:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) | | ! vfo )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! vfo )
{
rig_debug ( RIG_DEBUG_ERR , " %s: no vfo? rig=%p, vfo=%p \n " , __func__ ,
2020-07-02 14:40:48 +00:00
rig , vfo ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > get_vfo = = NULL )
{
2020-06-25 10:54:06 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: no get_vfo \n " , __func__ ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-27 23:10:12 +00:00
2020-07-02 03:33:32 +00:00
cache_ms = elapsed_ms ( & rig - > state . cache . time_vfo , HAMLIB_ELAPSED_GET ) ;
2020-05-01 17:03:54 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: cache check age=%dms \n " , __func__ , cache_ms ) ;
if ( cache_ms < rig - > state . cache . timeout_ms )
{
rig_debug ( RIG_DEBUG_TRACE , " %s: cache hit age=%dms \n " , __func__ , cache_ms ) ;
* vfo = rig - > state . cache . vfo ;
2021-09-25 13:59:57 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2020-05-01 17:03:54 +00:00
}
else
{
rig_debug ( RIG_DEBUG_TRACE , " %s: cache miss age=%dms \n " , __func__ , cache_ms ) ;
}
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > get_vfo ( rig , vfo ) ;
2001-01-05 18:24:20 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode = = RIG_OK )
{
2017-08-05 14:09:12 +00:00
rig - > state . current_vfo = * vfo ;
2020-05-31 03:45:43 +00:00
rig - > state . cache . vfo = * vfo ;
2020-07-02 03:33:32 +00:00
cache_ms = elapsed_ms ( & rig - > state . cache . time_vfo , HAMLIB_ELAPSED_SET ) ;
2017-08-05 14:09:12 +00:00
}
2020-06-03 12:20:48 +00:00
else
{
2020-07-02 03:33:32 +00:00
cache_ms = elapsed_ms ( & rig - > state . cache . time_vfo , HAMLIB_ELAPSED_INVALIDATE ) ;
2020-05-31 15:05:44 +00:00
}
2017-08-05 14:09:12 +00:00
2020-06-25 10:54:06 +00:00
if ( retcode ! = RIG_OK )
{
2021-02-03 05:13:12 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: returning %d(%.10000s) \n " , __func__ , retcode ,
2020-07-02 14:40:48 +00:00
rigerror ( retcode ) ) ;
2020-06-25 10:54:06 +00:00
}
2021-09-25 13:59:57 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set PTT on / off
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param ptt The PTT status to set to
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Sets " Push-To-Talk " on / off .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_get_ptt ( )
2000-10-01 12:29:12 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_set_ptt ( RIG * rig , vfo_t vfo , ptt_t ptt )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
struct rig_state * rs = & rig - > state ;
2017-08-07 13:39:57 +00:00
int retcode = RIG_OK ;
2017-08-05 14:09:12 +00:00
2021-11-10 05:20:02 +00:00
ELAPSED1 ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2022-01-25 23:41:26 +00:00
switch ( rig - > state . pttport . type . ptt )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
case RIG_PTT_RIG :
2017-10-05 02:32:08 +00:00
if ( ptt = = RIG_PTT_ON_MIC | | ptt = = RIG_PTT_ON_DATA )
{
2017-08-05 14:09:12 +00:00
ptt = RIG_PTT_ON ;
}
2022-05-16 03:29:43 +00:00
2017-08-05 14:09:12 +00:00
/* fall through */
case RIG_PTT_RIG_MICDATA :
2017-10-05 02:32:08 +00:00
if ( caps - > set_ptt = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENIMPL ) ;
2017-08-05 14:09:12 +00:00
}
2020-10-31 22:19:08 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_PTT )
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_CURR
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2021-02-25 04:39:45 +00:00
int retry = 3 ;
ptt_t tptt ;
2021-02-28 15:46:01 +00:00
2021-02-25 04:39:45 +00:00
do
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-02-25 04:39:45 +00:00
retcode = caps - > set_ptt ( rig , vfo , ptt ) ;
2021-02-28 15:46:01 +00:00
if ( retcode ! = RIG_OK ) { RETURNFUNC ( retcode ) ; }
2021-03-20 21:57:46 +00:00
#if 0
2021-03-15 22:51:22 +00:00
hl_usleep ( 50 * 1000 ) ; // give PTT a chance to do it's thing
2021-03-06 15:08:13 +00:00
// don't use the cached value and check to see if it worked
2021-03-06 14:47:00 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_INVALIDATE ) ;
2021-02-26 17:35:53 +00:00
tptt = - 1 ;
// IC-9700 is failing on get_ptt right after set_ptt in split mode
2021-02-25 04:39:45 +00:00
retcode = rig_get_ptt ( rig , vfo , & tptt ) ;
2021-02-28 15:46:01 +00:00
2021-02-26 17:35:53 +00:00
if ( retcode ! = RIG_OK )
{
2021-02-28 15:46:01 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: rig_get_ptt failed: %s \b " , __func__ ,
rigerror ( retcode ) ) ;
2021-02-26 17:35:53 +00:00
retcode = RIG_OK ; // fake the retcode so we retry
}
2021-03-26 15:51:00 +00:00
2021-02-28 15:46:01 +00:00
if ( tptt ! = ptt ) { rig_debug ( RIG_DEBUG_WARN , " %s: failed, retry=%d \n " , __func__ , retry ) ; }
2021-03-26 15:51:00 +00:00
2021-03-20 21:57:46 +00:00
# else
tptt = ptt ;
# endif
2021-02-28 15:46:01 +00:00
}
while ( tptt ! = ptt & & retry - - > 0 & & retcode = = RIG_OK ) ;
2017-10-05 02:32:08 +00:00
}
else
{
2020-03-20 12:51:32 +00:00
vfo_t curr_vfo ;
2021-08-27 17:50:53 +00:00
int backend_num ;
int targetable_ptt ;
2020-03-26 16:11:46 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-07 13:39:57 +00:00
}
2017-08-05 14:09:12 +00:00
2017-08-07 13:39:57 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-27 17:50:53 +00:00
backend_num = RIG_BACKEND_NUM ( rig - > caps - > rig_model ) ;
switch ( backend_num )
{
// most rigs have only one PTT VFO so we can set that flag here
case RIG_ICOM :
case RIG_KENWOOD :
case RIG_YAESU :
targetable_ptt = 1 ;
}
if ( ! targetable_ptt )
{
retcode = caps - > set_vfo ( rig , vfo ) ;
}
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode = = RIG_OK )
{
2019-12-09 23:12:13 +00:00
int rc2 ;
2021-02-25 04:39:45 +00:00
int retry = 3 ;
ptt_t tptt ;
2021-02-28 15:46:01 +00:00
2021-02-25 04:39:45 +00:00
do
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-02-25 04:39:45 +00:00
retcode = caps - > set_ptt ( rig , vfo , ptt ) ;
2021-02-28 15:46:01 +00:00
if ( retcode ! = RIG_OK ) { RETURNFUNC ( retcode ) ; }
2021-03-20 21:57:46 +00:00
#if 0
2021-02-25 04:39:45 +00:00
retcode = rig_get_ptt ( rig , vfo , & tptt ) ;
2021-02-28 15:46:01 +00:00
if ( tptt ! = ptt ) { rig_debug ( RIG_DEBUG_WARN , " %s: failed, retry=%d \n " , __func__ , retry ) ; }
2021-03-26 15:51:00 +00:00
2021-03-20 21:57:46 +00:00
# else
tptt = ptt ;
# endif
2021-02-28 15:46:01 +00:00
}
while ( tptt ! = ptt & & retry - - > 0 & & retcode = = RIG_OK ) ;
2017-08-07 13:39:57 +00:00
/* try and revert even if we had an error above */
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-27 17:50:53 +00:00
2021-08-27 20:51:02 +00:00
rc2 = RIG_OK ;
2021-08-28 03:25:53 +00:00
2021-08-27 17:50:53 +00:00
if ( ! targetable_ptt )
{
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
}
2017-08-05 14:09:12 +00:00
2017-08-07 13:39:57 +00:00
/* return the first error code */
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-07 13:39:57 +00:00
retcode = rc2 ;
}
}
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
2017-08-05 14:09:12 +00:00
break ;
case RIG_PTT_SERIAL_DTR :
2019-11-30 16:19:08 +00:00
2017-08-05 14:09:12 +00:00
/* when the PTT port is not the control port we want to free the
port when PTT is reset and seize the port when PTT is set ,
this allows limited sharing of the PTT port between
applications so long as there is no contention */
2022-01-25 23:41:26 +00:00
if ( strcmp ( rs - > pttport . pathname , rs - > rigport . pathname )
& & rs - > pttport . fd < 0
2019-11-30 16:19:08 +00:00
& & RIG_PTT_OFF ! = ptt )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
rs - > pttport . fd = ser_open ( & rs - > pttport ) ;
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . fd < 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
rig_debug ( RIG_DEBUG_ERR ,
" %s: cannot open PTT device \" %s \" \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > pttport . pathname ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EIO ) ;
2017-08-05 14:09:12 +00:00
}
/* Needed on Linux because the serial port driver sets RTS/DTR
2017-08-07 13:39:57 +00:00
high on open - set both since we offer no control of
2017-08-05 14:09:12 +00:00
the non - PTT line and low is better than high */
2022-01-25 23:41:26 +00:00
retcode = ser_set_rts ( & rs - > pttport , 0 ) ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK ! = retcode )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
}
2022-01-25 23:41:26 +00:00
retcode = ser_set_dtr ( & rig - > state . pttport , ptt ! = RIG_PTT_OFF ) ;
2017-08-05 14:09:12 +00:00
2022-01-01 05:49:29 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: rigport=%s, pttport=%s, ptt_share=%d \n " ,
2022-01-25 23:41:26 +00:00
__func__ , rs - > pttport . pathname , rs - > rigport . pathname , rs - > ptt_share ) ;
2022-01-01 05:49:29 +00:00
2022-01-25 23:41:26 +00:00
if ( strcmp ( rs - > pttport . pathname , rs - > rigport . pathname )
2020-10-13 04:27:13 +00:00
& & ptt = = RIG_PTT_OFF & & rs - > ptt_share ! = 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-07 13:39:57 +00:00
/* free the port */
2022-01-25 23:41:26 +00:00
ser_close ( & rs - > pttport ) ;
2017-08-05 14:09:12 +00:00
}
2017-08-07 13:39:57 +00:00
break ;
2017-08-05 14:09:12 +00:00
case RIG_PTT_SERIAL_RTS :
2019-11-30 16:19:08 +00:00
2017-08-05 14:09:12 +00:00
/* when the PTT port is not the control port we want to free the
port when PTT is reset and seize the port when PTT is set ,
this allows limited sharing of the PTT port between
applications so long as there is no contention */
2022-01-25 23:41:26 +00:00
if ( strcmp ( rs - > pttport . pathname , rs - > rigport . pathname )
& & rs - > pttport . fd < 0
2019-11-30 16:19:08 +00:00
& & RIG_PTT_OFF ! = ptt )
2017-10-05 02:32:08 +00:00
{
2020-09-04 22:42:11 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: PTT RTS debug#1 \n " , __func__ ) ;
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
rs - > pttport . fd = ser_open ( & rs - > pttport ) ;
2017-08-05 14:09:12 +00:00
2022-01-25 23:41:26 +00:00
if ( rs - > pttport . fd < 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-07 13:39:57 +00:00
rig_debug ( RIG_DEBUG_ERR ,
" %s: cannot open PTT device \" %s \" \n " ,
__func__ ,
2022-01-25 23:41:26 +00:00
rs - > pttport . pathname ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EIO ) ;
2017-08-07 13:39:57 +00:00
}
2017-08-05 14:09:12 +00:00
2017-08-07 13:39:57 +00:00
/* Needed on Linux because the serial port driver sets RTS/DTR
high on open - set both since we offer no control of the
non - PTT line and low is better than high */
2022-01-25 23:41:26 +00:00
retcode = ser_set_dtr ( & rs - > pttport , 0 ) ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK ! = retcode )
{
2020-05-25 19:35:49 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: ser_set_dtr retcode=%d \n " , __func__ , retcode ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-07 13:39:57 +00:00
}
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
2022-01-25 23:41:26 +00:00
retcode = ser_set_rts ( & rig - > state . pttport , ptt ! = RIG_PTT_OFF ) ;
2017-08-05 14:09:12 +00:00
2022-01-01 05:49:29 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: rigport=%s, pttport=%s, ptt_share=%d \n " ,
2022-01-25 23:41:26 +00:00
__func__ , rs - > pttport . pathname , rs - > rigport . pathname , rs - > ptt_share ) ;
2022-01-01 05:49:29 +00:00
2022-01-25 23:41:26 +00:00
if ( strcmp ( rs - > pttport . pathname , rs - > rigport . pathname )
2020-10-13 04:27:13 +00:00
& & ptt = = RIG_PTT_OFF & & rs - > ptt_share ! = 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-07 13:39:57 +00:00
/* free the port */
2022-01-25 23:41:26 +00:00
ser_close ( & rs - > pttport ) ;
2017-08-07 13:39:57 +00:00
}
2017-10-05 02:32:08 +00:00
2017-08-07 13:39:57 +00:00
break ;
2017-08-05 14:09:12 +00:00
case RIG_PTT_PARALLEL :
2022-01-25 23:41:26 +00:00
retcode = par_ptt_set ( & rig - > state . pttport , ptt ) ;
2017-08-07 13:39:57 +00:00
break ;
2017-08-05 14:09:12 +00:00
case RIG_PTT_CM108 :
2022-01-25 23:41:26 +00:00
retcode = cm108_ptt_set ( & rig - > state . pttport , ptt ) ;
2017-08-07 13:39:57 +00:00
break ;
2017-08-05 14:09:12 +00:00
case RIG_PTT_GPIO :
case RIG_PTT_GPION :
2022-01-25 23:41:26 +00:00
retcode = gpio_ptt_set ( & rig - > state . pttport , ptt ) ;
2017-08-07 13:39:57 +00:00
break ;
2017-08-05 14:09:12 +00:00
default :
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-07 13:39:57 +00:00
rs - > transmit = ptt ! = RIG_PTT_OFF ;
}
2021-05-02 03:18:28 +00:00
// some rigs like the FT-2000 with the SCU-17 need just a bit of time to let the relays work
// can affect fake it mode in WSJT-X when the rig is still in transmit and freq change
// is requested on a rig that can't change freq on a transmitting VFO
2021-05-18 12:10:00 +00:00
if ( ptt ! = RIG_PTT_ON ) { hl_usleep ( 50 * 1000 ) ; }
2021-05-02 03:18:28 +00:00
2020-05-01 17:03:54 +00:00
rig - > state . cache . ptt = ptt ;
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2020-05-27 17:23:08 +00:00
if ( retcode ! = RIG_OK ) { rig_debug ( RIG_DEBUG_ERR , " %s: return code=%d \n " , __func__ , retcode ) ; }
2022-02-05 21:27:43 +00:00
memcpy ( & rig - > state . pttport_deprecated , & rig - > state . pttport ,
sizeof ( rig - > state . pttport_deprecated ) ) ;
2021-10-14 16:32:30 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the status of the PTT
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param ptt The location where to store the status of the PTT
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves the status of PTT ( are we on the air ? ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_ptt ( )
2000-10-01 12:29:12 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_get_ptt ( RIG * rig , vfo_t vfo , ptt_t * ptt )
2010-02-14 21:47:49 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
struct rig_state * rs = & rig - > state ;
int retcode = RIG_OK ;
2021-09-13 22:41:53 +00:00
int status ;
2017-08-05 14:09:12 +00:00
vfo_t curr_vfo ;
2020-05-01 17:03:54 +00:00
int cache_ms ;
2021-08-27 17:32:37 +00:00
int targetable_ptt = 0 ;
int backend_num ;
2017-08-05 14:09:12 +00:00
2021-10-14 16:32:30 +00:00
ELAPSED1 ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! ptt )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2020-07-02 03:33:32 +00:00
cache_ms = elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_GET ) ;
2020-05-01 17:03:54 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: cache check age=%dms \n " , __func__ , cache_ms ) ;
if ( cache_ms < rig - > state . cache . timeout_ms )
{
rig_debug ( RIG_DEBUG_TRACE , " %s: cache hit age=%dms \n " , __func__ , cache_ms ) ;
* ptt = rig - > state . cache . ptt ;
2021-10-14 16:32:30 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2020-05-01 17:03:54 +00:00
}
else
{
rig_debug ( RIG_DEBUG_TRACE , " %s: cache miss age=%dms \n " , __func__ , cache_ms ) ;
}
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2022-01-25 23:41:26 +00:00
switch ( rig - > state . pttport . type . ptt )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
case RIG_PTT_RIG :
case RIG_PTT_RIG_MICDATA :
2017-10-05 02:32:08 +00:00
if ( ! caps - > get_ptt )
{
2017-08-07 13:39:57 +00:00
* ptt = rs - > transmit ? RIG_PTT_ON : RIG_PTT_OFF ;
2021-10-14 16:32:30 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2017-08-05 14:09:12 +00:00
}
2020-10-31 22:19:08 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_PTT )
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_CURR
2021-08-27 17:50:53 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-05-12 17:19:33 +00:00
retcode = caps - > get_ptt ( rig , vfo , ptt ) ;
2017-08-07 13:39:57 +00:00
2020-05-12 17:19:33 +00:00
if ( retcode = = RIG_OK )
{
rig - > state . cache . ptt = * ptt ;
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2020-05-12 17:19:33 +00:00
}
2021-10-14 16:32:30 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-27 17:50:53 +00:00
backend_num = RIG_BACKEND_NUM ( rig - > caps - > rig_model ) ;
switch ( backend_num )
{
// most rigs have only one PTT VFO so we can set that flag here
2021-10-22 22:15:35 +00:00
case 0 :
2021-08-27 17:50:53 +00:00
case RIG_ICOM :
case RIG_KENWOOD :
case RIG_YAESU :
targetable_ptt = 1 ;
}
if ( ! targetable_ptt )
{
retcode = caps - > set_vfo ( rig , vfo ) ;
}
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > get_ptt ( rig , vfo , ptt ) ;
2021-08-27 17:50:53 +00:00
/* try and revert even if we had an error above */
if ( ! targetable_ptt )
2017-10-05 02:32:08 +00:00
{
2021-09-13 22:41:53 +00:00
int rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2021-08-27 17:50:53 +00:00
if ( RIG_OK = = retcode )
{
/* return the first error code */
retcode = rc2 ;
rig - > state . cache . ptt = * ptt ;
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
}
2017-08-05 14:09:12 +00:00
}
2021-10-14 16:32:30 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
case RIG_PTT_SERIAL_RTS :
2017-10-05 02:32:08 +00:00
if ( caps - > get_ptt )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-05-12 17:19:33 +00:00
retcode = caps - > get_ptt ( rig , vfo , ptt ) ;
if ( retcode = = RIG_OK )
{
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2020-05-12 17:19:33 +00:00
rig - > state . cache . ptt = * ptt ;
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2022-01-25 23:41:26 +00:00
if ( strcmp ( rs - > pttport . pathname , rs - > rigport . pathname )
& & rs - > pttport . fd < 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-07 13:39:57 +00:00
/* port is closed so assume PTT off */
* ptt = RIG_PTT_OFF ;
2017-10-05 02:32:08 +00:00
}
else
{
2022-01-25 23:41:26 +00:00
retcode = ser_get_rts ( & rig - > state . pttport , & status ) ;
2017-08-05 14:09:12 +00:00
* ptt = status ? RIG_PTT_ON : RIG_PTT_OFF ;
}
2020-05-12 17:19:33 +00:00
rig - > state . cache . ptt = * ptt ;
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2021-10-14 16:32:30 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
case RIG_PTT_SERIAL_DTR :
2017-10-05 02:32:08 +00:00
if ( caps - > get_ptt )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-05-12 17:19:33 +00:00
retcode = caps - > get_ptt ( rig , vfo , ptt ) ;
if ( retcode = = RIG_OK )
{
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2020-05-12 17:19:33 +00:00
rig - > state . cache . ptt = * ptt ;
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2022-01-25 23:41:26 +00:00
if ( strcmp ( rs - > pttport . pathname , rs - > rigport . pathname )
& & rs - > pttport . fd < 0 )
2017-10-05 02:32:08 +00:00
{
2017-08-07 13:39:57 +00:00
/* port is closed so assume PTT off */
* ptt = RIG_PTT_OFF ;
2017-10-05 02:32:08 +00:00
}
else
{
2022-01-25 23:41:26 +00:00
retcode = ser_get_dtr ( & rig - > state . pttport , & status ) ;
2017-08-05 14:09:12 +00:00
* ptt = status ? RIG_PTT_ON : RIG_PTT_OFF ;
}
2020-05-12 17:19:33 +00:00
rig - > state . cache . ptt = * ptt ;
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2021-10-14 16:32:30 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
case RIG_PTT_PARALLEL :
2017-10-05 02:32:08 +00:00
if ( caps - > get_ptt )
2020-05-12 17:19:33 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-05-12 17:19:33 +00:00
retcode = caps - > get_ptt ( rig , vfo , ptt ) ;
if ( retcode = = RIG_OK )
{
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2020-05-12 17:19:33 +00:00
rig - > state . cache . ptt = * ptt ;
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2020-05-12 17:19:33 +00:00
}
2022-01-25 23:41:26 +00:00
retcode = par_ptt_get ( & rig - > state . pttport , ptt ) ;
2020-05-12 17:19:33 +00:00
if ( retcode = = RIG_OK )
2017-10-05 02:32:08 +00:00
{
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2020-05-12 17:19:33 +00:00
rig - > state . cache . ptt = * ptt ;
2017-08-05 14:09:12 +00:00
}
2021-10-14 16:32:30 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
case RIG_PTT_CM108 :
2019-06-26 11:39:42 +00:00
if ( caps - > get_ptt )
2020-05-12 17:19:33 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-05-12 17:19:33 +00:00
retcode = caps - > get_ptt ( rig , vfo , ptt ) ;
if ( retcode = = RIG_OK )
{
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2020-05-12 17:19:33 +00:00
rig - > state . cache . ptt = * ptt ;
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2020-05-12 17:19:33 +00:00
}
2022-01-25 23:41:26 +00:00
retcode = cm108_ptt_get ( & rig - > state . pttport , ptt ) ;
2020-05-12 17:19:33 +00:00
if ( retcode = = RIG_OK )
2019-06-26 11:39:42 +00:00
{
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2020-05-12 17:19:33 +00:00
rig - > state . cache . ptt = * ptt ;
2019-06-26 11:39:42 +00:00
}
2017-08-05 14:09:12 +00:00
2021-10-14 16:32:30 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
case RIG_PTT_GPIO :
case RIG_PTT_GPION :
2017-10-05 02:32:08 +00:00
if ( caps - > get_ptt )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-05-12 17:19:33 +00:00
retcode = caps - > get_ptt ( rig , vfo , ptt ) ;
if ( retcode = = RIG_OK )
{
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2020-05-12 17:19:33 +00:00
rig - > state . cache . ptt = * ptt ;
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2022-01-25 23:41:26 +00:00
retcode = gpio_ptt_get ( & rig - > state . pttport , ptt ) ;
2021-10-14 16:32:30 +00:00
ELAPSED2 ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
case RIG_PTT_NONE :
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ; /* not available */
2017-08-05 14:09:12 +00:00
default :
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_SET ) ;
2021-10-14 16:32:30 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
2001-02-14 23:59:09 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the status of the DCD
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param dcd The location where to store the status of the DCD
2001-02-14 23:59:09 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves the status of DCD ( is squelch open ? ) .
2001-02-14 23:59:09 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-02-14 23:59:09 +00:00
*
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_get_dcd ( RIG * rig , vfo_t vfo , dcd_t * dcd )
2010-02-14 21:47:49 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 , status ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! dcd )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2022-01-25 23:41:26 +00:00
switch ( rig - > state . dcdport . type . dcd )
2017-10-05 02:32:08 +00:00
{
2017-08-05 14:09:12 +00:00
case RIG_DCD_RIG :
2017-10-05 02:32:08 +00:00
if ( caps - > get_dcd = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENIMPL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-14 23:59:09 +00:00
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > get_dcd ( rig , vfo , dcd ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-14 23:59:09 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-27 23:10:12 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-02-14 23:59:09 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2010-02-14 21:47:49 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > get_dcd ( rig , vfo , dcd ) ;
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2010-02-14 21:47:49 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
}
2014-12-11 17:14:58 +00:00
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2001-02-14 23:59:09 +00:00
2017-08-05 14:09:12 +00:00
break ;
2001-02-14 23:59:09 +00:00
2017-08-05 14:09:12 +00:00
case RIG_DCD_SERIAL_CTS :
2022-01-25 23:41:26 +00:00
retcode = ser_get_cts ( & rig - > state . dcdport , & status ) ;
2022-02-05 21:27:43 +00:00
memcpy ( & rig - > state . dcdport_deprecated , & rig - > state . dcdport ,
sizeof ( rig - > state . dcdport_deprecated ) ) ;
2017-08-05 14:09:12 +00:00
* dcd = status ? RIG_DCD_ON : RIG_DCD_OFF ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2004-10-02 20:18:16 +00:00
2017-08-05 14:09:12 +00:00
case RIG_DCD_SERIAL_DSR :
2022-01-25 23:41:26 +00:00
retcode = ser_get_dsr ( & rig - > state . dcdport , & status ) ;
2022-02-05 21:27:43 +00:00
memcpy ( & rig - > state . dcdport_deprecated , & rig - > state . dcdport ,
sizeof ( rig - > state . dcdport_deprecated ) ) ;
2017-08-05 14:09:12 +00:00
* dcd = status ? RIG_DCD_ON : RIG_DCD_OFF ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2004-10-02 20:18:16 +00:00
2017-08-05 14:09:12 +00:00
case RIG_DCD_SERIAL_CAR :
2022-01-25 23:41:26 +00:00
retcode = ser_get_car ( & rig - > state . dcdport , & status ) ;
2022-02-05 21:27:43 +00:00
memcpy ( & rig - > state . dcdport_deprecated , & rig - > state . dcdport ,
sizeof ( rig - > state . dcdport_deprecated ) ) ;
2017-08-05 14:09:12 +00:00
* dcd = status ? RIG_DCD_ON : RIG_DCD_OFF ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2004-10-02 20:18:16 +00:00
2010-02-14 21:47:49 +00:00
2017-08-05 14:09:12 +00:00
case RIG_DCD_PARALLEL :
2022-01-25 23:41:26 +00:00
retcode = par_dcd_get ( & rig - > state . dcdport , dcd ) ;
2022-02-05 21:27:43 +00:00
memcpy ( & rig - > state . dcdport_deprecated , & rig - > state . dcdport ,
sizeof ( rig - > state . dcdport_deprecated ) ) ;
2021-03-18 12:09:58 +00:00
RETURNFUNC ( retcode ) ;
2001-02-14 23:59:09 +00:00
2018-03-29 21:55:25 +00:00
case RIG_DCD_GPIO :
case RIG_DCD_GPION :
2022-01-25 23:41:26 +00:00
retcode = gpio_dcd_get ( & rig - > state . dcdport , dcd ) ;
2022-02-05 21:27:43 +00:00
memcpy ( & rig - > state . dcdport_deprecated , & rig - > state . dcdport ,
sizeof ( rig - > state . dcdport_deprecated ) ) ;
2021-03-18 12:09:58 +00:00
RETURNFUNC ( retcode ) ;
2018-03-29 21:55:25 +00:00
2017-08-05 14:09:12 +00:00
case RIG_DCD_NONE :
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ; /* not available */
2001-02-14 23:59:09 +00:00
2017-08-05 14:09:12 +00:00
default :
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-14 23:59:09 +00:00
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2001-02-14 23:59:09 +00:00
}
2000-10-01 12:29:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the repeater shift
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param rptr_shift The repeater shift to set to
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Sets the current repeater shift .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_get_rptr_shift ( )
2000-10-01 12:29:12 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_set_rptr_shift ( RIG * rig , vfo_t vfo , rptr_shift_t rptr_shift )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2000-10-01 12:29:12 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2001-02-27 23:10:12 +00:00
2017-10-05 02:32:08 +00:00
if ( caps - > set_rptr_shift = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > set_rptr_shift ( rig , vfo , rptr_shift ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-01-05 18:24:20 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_rptr_shift ( rig , vfo , rptr_shift ) ;
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the current repeater shift
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param rptr_shift The location where to store the current repeater shift
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves the current repeater shift .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_rptr_shift ( )
2000-10-01 12:29:12 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_get_rptr_shift ( RIG * rig , vfo_t vfo , rptr_shift_t * rptr_shift )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2000-10-01 12:29:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! rptr_shift )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > get_rptr_shift = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-27 23:10:12 +00:00
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > get_rptr_shift ( rig , vfo , rptr_shift ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-01-05 18:24:20 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-04-27 14:36:27 +00:00
retcode = caps - > get_rptr_shift ( rig , vfo , rptr_shift ) ;
2017-08-05 14:09:12 +00:00
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the repeater offset
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param rptr_offs The VFO to set to
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Sets the current repeater offset .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_get_rptr_offs ( )
2000-10-16 22:08:51 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_set_rptr_offs ( RIG * rig , vfo_t vfo , shortfreq_t rptr_offs )
2000-10-16 22:08:51 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > set_rptr_offs = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2000-10-16 22:08:51 +00:00
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > set_rptr_offs ( rig , vfo , rptr_offs ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-27 23:10:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-01-05 18:24:20 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2017-08-05 14:09:12 +00:00
retcode = caps - > set_rptr_offs ( rig , vfo , rptr_offs ) ;
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-16 22:08:51 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the current repeater offset
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param rptr_offs The location where to store the current repeater offset
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves the current repeater offset .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_rptr_offs ( )
2000-10-16 22:08:51 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_get_rptr_offs ( RIG * rig , vfo_t vfo , shortfreq_t * rptr_offs )
2000-10-16 22:08:51 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! rptr_offs )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2000-10-16 22:08:51 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2001-02-27 23:10:12 +00:00
2017-10-05 02:32:08 +00:00
if ( caps - > get_rptr_offs = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > get_rptr_offs ( rig , vfo , rptr_offs ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-01-05 18:24:20 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2017-08-05 14:09:12 +00:00
retcode = caps - > get_rptr_offs ( rig , vfo , rptr_offs ) ;
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-16 22:08:51 +00:00
}
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the split frequencies
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param tx_freq The transmit split frequency to set to
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2005-03-26 17:57:14 +00:00
* Sets the split ( TX ) frequency .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2005-03-26 17:57:14 +00:00
* \ sa rig_get_split_freq ( ) , rig_set_split_vfo ( )
2000-10-16 22:08:51 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_set_split_freq ( RIG * rig , vfo_t vfo , freq_t tx_freq )
2000-10-16 22:08:51 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo , tx_vfo ;
2021-11-09 23:06:48 +00:00
freq_t tfreq = 0 ;
2017-08-05 14:09:12 +00:00
2021-11-10 05:20:02 +00:00
ELAPSED1 ;
2021-11-28 18:41:10 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2021-05-21 04:34:48 +00:00
2022-02-05 21:27:43 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s called vfo=%s, curr_vfo=%s, tx_freq=%.0f \n " ,
__func__ ,
2022-01-30 16:51:49 +00:00
rig_strvfo ( vfo ) , rig_strvfo ( rig - > state . current_vfo ) , tx_freq ) ;
2020-06-22 03:31:31 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2021-03-31 04:05:04 +00:00
/* Use previously setup TxVFO */
if ( vfo = = RIG_VFO_CURR | | vfo = = RIG_VFO_TX )
{
tx_vfo = rig - > state . tx_vfo ;
}
else
{
2022-07-05 22:03:21 +00:00
tx_vfo = vfo_fixup ( rig , vfo , rig - > state . cache . split ) ;
2021-03-31 04:05:04 +00:00
}
2021-11-28 18:41:10 +00:00
rig_get_freq ( rig , tx_vfo , & tfreq ) ;
2021-11-09 23:06:48 +00:00
if ( tfreq = = tx_freq )
{
rig_debug ( RIG_DEBUG_TRACE , " %s: freq set not needed \n " , __func__ ) ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( RIG_OK ) ;
2021-11-09 23:06:48 +00:00
}
2017-08-05 14:09:12 +00:00
if ( caps - > set_split_freq
2021-03-09 06:01:05 +00:00
& & ( vfo = = RIG_VFO_CURR
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_TX
2021-08-27 20:46:23 +00:00
| | tx_vfo = = rig - > state . current_vfo
| | ( caps - > targetable_vfo & RIG_TARGETABLE_FREQ ) ) )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > set_split_freq ( rig , vfo , tx_freq ) ;
2021-11-10 05:20:02 +00:00
ELAPSED2 ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2021-08-03 04:37:31 +00:00
vfo = vfo_fixup ( rig , vfo , rig - > state . cache . split ) ;
2020-05-30 14:34:13 +00:00
2017-08-05 14:09:12 +00:00
/* Assisted mode */
curr_vfo = rig - > state . current_vfo ;
2021-08-27 20:46:23 +00:00
if ( caps - > set_freq )
2017-10-05 02:32:08 +00:00
{
2021-02-21 22:44:28 +00:00
int retry = 3 ;
freq_t tfreq ;
2021-02-28 15:46:01 +00:00
do
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-02-21 22:44:28 +00:00
retcode = rig_set_freq ( rig , tx_vfo , tx_freq ) ;
2021-02-28 15:46:01 +00:00
if ( retcode ! = RIG_OK ) { RETURNFUNC ( retcode ) ; }
2021-03-31 12:41:16 +00:00
#if 0 // this verification seems to be causing bad behavior on some rigs
2021-02-21 22:44:28 +00:00
retcode = rig_get_freq ( rig , tx_vfo , & tfreq ) ;
2021-03-18 20:40:32 +00:00
# else
tfreq = tx_freq ;
# endif
2021-02-28 15:46:01 +00:00
}
while ( tfreq ! = tx_freq & & retry - - > 0 & & retcode = = RIG_OK ) ;
2021-11-10 05:20:02 +00:00
ELAPSED2 ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( caps - > set_vfo )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-13 12:42:39 +00:00
retcode = RIG_OK ;
2021-08-26 11:49:24 +00:00
2021-08-27 20:46:23 +00:00
retcode = caps - > set_vfo ( rig , tx_vfo ) ;
2017-10-05 02:32:08 +00:00
}
else if ( rig_has_vfo_op ( rig , RIG_OP_TOGGLE ) & & caps - > vfo_op )
{
2022-07-03 22:24:09 +00:00
retcode = caps - > vfo_op ( rig , vfo , RIG_OP_TOGGLE ) ;
2017-10-05 02:32:08 +00:00
}
else
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2021-02-21 22:44:28 +00:00
int retry = 3 ;
2021-02-28 15:46:01 +00:00
do
{
2021-04-04 17:50:07 +00:00
// doing get_freq seems to break on some rigs that can't read freq immediately after set
2021-02-21 22:44:28 +00:00
if ( caps - > set_split_freq )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-02-21 22:44:28 +00:00
retcode = caps - > set_split_freq ( rig , vfo , tx_freq ) ;
2021-04-04 17:50:07 +00:00
//rig_get_freq(rig, vfo, &tfreq);
2021-02-21 22:44:28 +00:00
}
else
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-02-21 22:44:28 +00:00
retcode = rig_set_freq ( rig , RIG_VFO_CURR , tx_freq ) ;
2021-04-01 13:02:49 +00:00
//rig_get_freq(rig, vfo, &tfreq);
2021-02-21 22:44:28 +00:00
}
2021-03-26 15:51:00 +00:00
2021-03-18 20:40:32 +00:00
tfreq = tx_freq ;
2021-02-28 15:46:01 +00:00
}
while ( tfreq ! = tx_freq & & retry - - > 0 & & retcode = = RIG_OK ) ;
2017-08-05 14:09:12 +00:00
/* try and revert even if we had an error above */
2017-10-05 02:32:08 +00:00
if ( caps - > set_vfo )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-13 12:42:39 +00:00
rc2 = RIG_OK ;
2021-08-26 11:49:24 +00:00
2021-08-13 12:42:39 +00:00
if ( ! ( caps - > targetable_vfo & RIG_TARGETABLE_FREQ ) )
2021-08-26 11:49:24 +00:00
{
2021-08-13 12:42:39 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2021-08-26 11:49:24 +00:00
}
2017-10-05 02:32:08 +00:00
}
else
{
2017-08-05 14:09:12 +00:00
rc2 = caps - > vfo_op ( rig , vfo , RIG_OP_TOGGLE ) ;
}
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
}
2021-11-10 05:20:02 +00:00
ELAPSED2 ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( retcode ) ;
2000-10-16 22:08:51 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the current split frequencies
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param tx_freq The location where to store the current transmit split frequency
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2005-03-26 17:57:14 +00:00
* Retrieves the current split ( TX ) frequency .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_split_freq ( )
2000-10-16 22:08:51 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_get_split_freq ( RIG * rig , vfo_t vfo , freq_t * tx_freq )
2000-10-16 22:08:51 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
2020-06-13 21:31:25 +00:00
int retcode = - RIG_EPROTO , rc2 ;
2020-06-13 03:51:16 +00:00
vfo_t save_vfo , tx_vfo ;
2017-08-05 14:09:12 +00:00
2021-11-10 05:14:44 +00:00
ELAPSED1 ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! tx_freq )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2021-08-03 04:37:31 +00:00
vfo = vfo_fixup ( rig , vfo , rig - > state . cache . split ) ;
2020-06-04 15:27:00 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
if ( caps - > get_split_freq
2021-03-09 06:01:05 +00:00
& & ( vfo = = RIG_VFO_CURR
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_TX
| | vfo = = rig - > state . current_vfo ) )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > get_split_freq ( rig , vfo , tx_freq ) ;
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-03-18 12:09:58 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
/* Assisted mode */
2020-06-13 03:51:16 +00:00
save_vfo = rig - > state . current_vfo ;
2017-08-05 14:09:12 +00:00
/* Use previously setup TxVFO */
2017-10-05 02:32:08 +00:00
if ( vfo = = RIG_VFO_CURR | | vfo = = RIG_VFO_TX )
{
2017-08-05 14:09:12 +00:00
tx_vfo = rig - > state . tx_vfo ;
2017-10-05 02:32:08 +00:00
}
else
{
2017-08-05 14:09:12 +00:00
tx_vfo = vfo ;
}
2017-10-05 02:32:08 +00:00
if ( caps - > get_freq & & ( caps - > targetable_vfo & RIG_TARGETABLE_FREQ ) )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > get_freq ( rig , tx_vfo , tx_freq ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( caps - > set_vfo )
{
2020-06-13 12:36:31 +00:00
// if the underlying rig has OP_XCHG we don't need to set VFO
2021-08-27 20:46:23 +00:00
if ( ! rig_has_vfo_op ( rig , RIG_OP_XCHG )
& & ! ( caps - > targetable_vfo & RIG_TARGETABLE_FREQ ) )
2020-06-12 22:40:10 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-06-12 21:34:48 +00:00
retcode = caps - > set_vfo ( rig , tx_vfo ) ;
2020-06-21 22:47:04 +00:00
2021-01-17 13:25:28 +00:00
if ( retcode ! = RIG_OK ) { RETURNFUNC ( retcode ) ; }
2020-06-12 21:34:48 +00:00
}
2020-06-21 22:47:04 +00:00
retcode = RIG_OK ;
2017-10-05 02:32:08 +00:00
}
else if ( rig_has_vfo_op ( rig , RIG_OP_TOGGLE ) & & caps - > vfo_op )
{
2017-08-05 14:09:12 +00:00
retcode = caps - > vfo_op ( rig , vfo , RIG_OP_TOGGLE ) ;
2017-10-05 02:32:08 +00:00
}
else
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( caps - > get_split_freq )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > get_split_freq ( rig , vfo , tx_freq ) ;
2017-10-05 02:32:08 +00:00
}
else
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-26 11:49:24 +00:00
retcode = caps - > get_freq ? caps - > get_freq ( rig , RIG_VFO_CURR ,
tx_freq ) : - RIG_ENIMPL ;
2017-08-05 14:09:12 +00:00
}
/* try and revert even if we had an error above */
2017-10-05 02:32:08 +00:00
if ( caps - > set_vfo )
{
2020-06-21 22:47:04 +00:00
// If we started with RIG_VFO_CURR we need to choose VFO_A/MAIN as appropriate to return to
2021-04-11 16:49:37 +00:00
//rig_debug(RIG_DEBUG_TRACE, "%s: save_vfo=%s, hasmainsub=%d\n",__func__, rig_strvfo(save_vfo), VFO_HAS_MAIN_SUB);
save_vfo = VFO_HAS_MAIN_SUB ? RIG_VFO_MAIN : RIG_VFO_A ;
2020-06-21 22:47:04 +00:00
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: restoring vfo=%s \n " , __func__ ,
2020-06-21 22:47:04 +00:00
rig_strvfo ( save_vfo ) ) ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-27 20:46:23 +00:00
if ( ! rig_has_vfo_op ( rig , RIG_OP_XCHG )
& & ! ( caps - > targetable_vfo & RIG_TARGETABLE_FREQ ) )
{
rc2 = caps - > set_vfo ( rig , save_vfo ) ;
}
else
{
rc2 = RIG_OK ;
}
2017-10-05 02:32:08 +00:00
}
else
{
2017-08-05 14:09:12 +00:00
rc2 = caps - > vfo_op ( rig , vfo , RIG_OP_TOGGLE ) ;
}
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
}
2020-06-04 15:27:00 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: tx_freq=%.0f \n " , __func__ , * tx_freq ) ;
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-16 22:08:51 +00:00
}
2017-08-05 14:09:12 +00:00
2001-04-28 12:49:12 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the split modes
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param tx_mode The transmit split mode to set to
2016-04-09 13:13:49 +00:00
* \ param tx_width The transmit split width to set to or the special
* value RIG_PASSBAND_NOCHANGE which leaves the passband unchanged
* from the current value or default for the mode determined by the
* rig .
2001-04-28 12:49:12 +00:00
*
2005-03-26 17:57:14 +00:00
* Sets the split ( TX ) mode .
2001-04-28 12:49:12 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-04-28 12:49:12 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_get_split_mode ( )
2001-04-28 12:49:12 +00:00
*/
2017-10-05 02:32:08 +00:00
int HAMLIB_API rig_set_split_mode ( RIG * rig ,
vfo_t vfo ,
rmode_t tx_mode ,
2017-08-05 14:09:12 +00:00
pbwidth_t tx_width )
2001-04-28 12:49:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
2021-11-19 22:19:18 +00:00
vfo_t curr_vfo , tx_vfo , rx_vfo ;
2017-08-05 14:09:12 +00:00
2021-11-10 05:14:44 +00:00
ELAPSED1 ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2022-06-07 16:50:25 +00:00
// we check both VFOs are in the same tx mode -- then we can ignore
2022-06-07 13:33:18 +00:00
// this could be make more intelligent but this should cover all cases where we can skip this
if ( tx_mode = = rig - > state . cache . modeMainA & & tx_mode = = rig - > state . cache . modeMainB )
{
rig_debug ( RIG_DEBUG_TRACE , " %s: mode already %s so no change required \n " , __func__ , rig_strrmode ( tx_mode ) ) ;
return RIG_OK ;
}
2022-06-07 16:50:25 +00:00
else
{
rig_debug ( RIG_DEBUG_TRACE , " %s: mode %s is different from A=%s and B=%s \n " , __func__ , rig_strrmode ( tx_mode ) , rig_strrmode ( rig - > state . cache . modeMainA ) , rig_strrmode ( rig - > state . cache . modeMainB ) ) ;
}
2022-06-07 13:33:18 +00:00
2021-07-12 13:57:02 +00:00
// do not mess with mode while PTT is on
if ( rig - > state . cache . ptt )
{
rig_debug ( RIG_DEBUG_VERBOSE , " %s PTT on so set_split_mode ignored \n " , __func__ ) ;
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-07-12 13:57:02 +00:00
return RIG_OK ;
}
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
if ( caps - > set_split_mode
2021-03-09 06:01:05 +00:00
& & ( vfo = = RIG_VFO_CURR
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_TX
2021-11-24 15:03:26 +00:00
| | vfo = = rig - > state . current_vfo
| | rig - > caps - > rig_model = = RIG_MODEL_NETRIGCTL ) )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > set_split_mode ( rig , vfo , tx_mode , tx_width ) ;
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-03-18 12:09:58 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
/* Assisted mode */
curr_vfo = rig - > state . current_vfo ;
/* Use previously setup TxVFO */
2021-11-28 18:41:10 +00:00
if ( vfo = = RIG_VFO_CURR | | vfo = = RIG_VFO_TX
| | rig - > state . tx_vfo ! = RIG_VFO_NONE )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
tx_vfo = rig - > state . tx_vfo ;
2017-10-05 02:32:08 +00:00
}
else
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
tx_vfo = vfo ;
}
2021-11-28 18:41:10 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s: curr_vfo=%s, tx_vfo=%s \n " , __func__ ,
rig_strvfo ( curr_vfo ) , rig_strvfo ( tx_vfo ) ) ;
if ( caps - > set_mode & & ( ( caps - > targetable_vfo & RIG_TARGETABLE_MODE )
| | ( rig - > caps - > rig_model = = RIG_MODEL_NETRIGCTL ) ) )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > set_mode ( rig , tx_vfo , tx_mode , tx_width ) ;
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-03-18 12:09:58 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2021-11-10 05:52:21 +00:00
// some rigs exhibit undesirable flashing when swapping vfos in split
// so we turn it off, do our thing, and turn split back on
2022-01-30 13:28:52 +00:00
rx_vfo = vfo ;
2022-06-02 20:55:56 +00:00
if ( tx_vfo = = RIG_VFO_B ) { rx_vfo = RIG_VFO_A ; }
2021-11-28 18:41:10 +00:00
if ( vfo = = RIG_VFO_CURR & & tx_vfo = = RIG_VFO_B ) { rx_vfo = RIG_VFO_A ; }
else if ( vfo = = RIG_VFO_CURR & & tx_vfo = = RIG_VFO_A ) { rx_vfo = RIG_VFO_B ; }
else if ( vfo = = RIG_VFO_CURR & & tx_vfo = = RIG_VFO_MAIN ) { rx_vfo = RIG_VFO_SUB ; }
else if ( vfo = = RIG_VFO_CURR & & tx_vfo = = RIG_VFO_SUB ) { rx_vfo = RIG_VFO_MAIN ; }
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): rx_vfo=%s, tx_vfo=%s \n " , __func__ ,
__LINE__ , rig_strvfo ( rx_vfo ) , rig_strvfo ( tx_vfo ) ) ;
2021-11-24 15:03:26 +00:00
// we will reuse cached mode instead of trying to set mode again
2021-11-28 18:41:10 +00:00
if ( ( tx_vfo & ( RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_MAIN_A | RIG_VFO_SUB_A ) )
& & ( tx_mode = = rig - > state . cache . modeMainA ) )
2021-11-24 15:03:26 +00:00
{
2021-11-28 18:41:10 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): VFOA mode=%s already set...ignoring \n " ,
__func__ , __LINE__ , rig_strrmode ( tx_mode ) ) ;
2021-11-24 15:03:26 +00:00
ELAPSED2 ;
RETURNFUNC ( RIG_OK ) ;
}
2021-11-28 18:41:10 +00:00
else if ( ( tx_vfo & ( RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_MAIN_B | RIG_VFO_SUB_B ) )
& & ( tx_mode = = rig - > state . cache . modeMainB ) )
2021-11-24 15:03:26 +00:00
{
2021-11-28 18:41:10 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): VFOB mode=%s already set...ignoring \n " ,
__func__ , __LINE__ , rig_strrmode ( tx_mode ) ) ;
2021-11-24 15:03:26 +00:00
ELAPSED2 ;
RETURNFUNC ( RIG_OK ) ;
}
2021-11-28 18:41:10 +00:00
2022-02-20 02:39:17 +00:00
if ( tx_vfo & ( RIG_VFO_CURR | RIG_VFO_TX ) )
2022-02-07 13:17:51 +00:00
{
rig_debug ( RIG_DEBUG_WARN , " %s(%d): Unhandled TXVFO=%s, tx_mode=%s \n " , __func__ ,
2022-03-01 17:40:14 +00:00
__LINE__ , rig_strvfo ( tx_vfo ) , rig_strrmode ( tx_mode ) ) ;
2022-02-07 13:17:51 +00:00
}
2021-11-24 15:03:26 +00:00
// code below here should be dead code now -- but maybe we have VFO situatiuon we need to handle
if ( caps - > rig_model = = RIG_MODEL_NETRIGCTL )
2021-11-28 18:41:10 +00:00
{
// special handlingt for netrigctl to avoid set_vfo
2021-11-24 15:03:26 +00:00
retcode = caps - > set_split_mode ( rig , vfo , tx_mode , tx_width ) ;
RETURNFUNC ( retcode ) ;
}
2021-11-28 18:41:10 +00:00
rig_set_split_vfo ( rig , rx_vfo , RIG_SPLIT_OFF , rx_vfo ) ;
2021-11-05 11:37:45 +00:00
if ( caps - > set_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-11-03 18:11:11 +00:00
retcode = caps - > set_vfo ( rig , tx_vfo ) ;
2017-10-05 02:32:08 +00:00
}
2021-11-05 11:37:45 +00:00
else if ( rig_has_vfo_op ( rig , RIG_OP_TOGGLE ) & & caps - > vfo_op )
{
retcode = caps - > vfo_op ( rig , vfo , RIG_OP_TOGGLE ) ;
}
2017-10-05 02:32:08 +00:00
else
{
2021-04-29 22:23:37 +00:00
rig_debug ( RIG_DEBUG_WARN ,
" %s: rig does not have set_vfo or vfo_op. Assuming mode already set \n " ,
__func__ ) ;
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-04-27 11:47:58 +00:00
RETURNFUNC ( RIG_OK ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( caps - > set_split_mode )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_split_mode ( rig , vfo , tx_mode , tx_width ) ;
2017-10-05 02:32:08 +00:00
}
else
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-26 11:49:24 +00:00
retcode = caps - > set_mode ? caps - > set_mode ( rig , RIG_VFO_CURR , tx_mode ,
tx_width ) : - RIG_ENIMPL ;
2017-08-05 14:09:12 +00:00
}
/* try and revert even if we had an error above */
2017-10-05 02:32:08 +00:00
if ( caps - > set_vfo )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-11-19 22:19:18 +00:00
rc2 = caps - > set_vfo ( rig , rx_vfo ) ;
2017-10-05 02:32:08 +00:00
}
else
{
2017-08-05 14:09:12 +00:00
rc2 = caps - > vfo_op ( rig , vfo , RIG_OP_TOGGLE ) ;
}
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
}
2021-11-28 18:41:10 +00:00
rig_set_split_vfo ( rig , rx_vfo , RIG_SPLIT_ON , tx_vfo ) ;
2017-08-05 14:09:12 +00:00
2022-06-07 16:50:25 +00:00
if ( vfo = = RIG_VFO_A | | vfo = = RIG_VFO_MAIN )
rig - > state . cache . modeMainA = tx_mode ;
else
rig - > state . cache . modeMainB = tx_mode ;
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2001-04-28 12:49:12 +00:00
}
2017-08-05 14:09:12 +00:00
2001-04-28 12:49:12 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the current split modes
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param tx_mode The location where to store the current transmit split mode
* \ param tx_width The location where to store the current transmit split width
2001-04-28 12:49:12 +00:00
*
2008-10-31 23:08:59 +00:00
* Retrieves the current split ( TX ) mode and passband .
* If the backend is unable to determine the width , the \ a tx_width
* will be set to RIG_PASSBAND_NORMAL as a default .
* The value stored at \ a tx_mode location equals RIG_MODE_NONE
* when the current mode of the VFO is not defined ( e . g . blank memory ) .
2001-04-28 12:49:12 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-04-28 12:49:12 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_split_mode ( )
2001-04-28 12:49:12 +00:00
*/
2017-08-05 14:09:12 +00:00
int HAMLIB_API rig_get_split_mode ( RIG * rig , vfo_t vfo , rmode_t * tx_mode ,
pbwidth_t * tx_width )
2001-04-28 12:49:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo , tx_vfo ;
2001-04-28 12:49:12 +00:00
2021-11-10 05:14:44 +00:00
ELAPSED1 ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2001-04-28 12:49:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! tx_mode | | ! tx_width )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
if ( caps - > get_split_mode
2021-03-09 06:01:05 +00:00
& & ( vfo = = RIG_VFO_CURR
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_TX
| | vfo = = rig - > state . current_vfo ) )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > get_split_mode ( rig , vfo , tx_mode , tx_width ) ;
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-03-18 12:09:58 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-04-28 12:49:12 +00:00
2017-08-05 14:09:12 +00:00
/* Assisted mode */
curr_vfo = rig - > state . current_vfo ;
2001-04-28 12:49:12 +00:00
2017-08-05 14:09:12 +00:00
/* Use previously setup TxVFO */
2017-10-05 02:32:08 +00:00
if ( vfo = = RIG_VFO_CURR | | vfo = = RIG_VFO_TX )
{
2017-08-05 14:09:12 +00:00
tx_vfo = rig - > state . tx_vfo ;
2017-10-05 02:32:08 +00:00
}
else
{
2017-08-05 14:09:12 +00:00
tx_vfo = vfo ;
}
2009-02-20 14:14:31 +00:00
2017-10-05 02:32:08 +00:00
if ( caps - > get_mode & & ( caps - > targetable_vfo & RIG_TARGETABLE_MODE ) )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > get_mode ( rig , tx_vfo , tx_mode , tx_width ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2009-02-20 14:14:31 +00:00
2017-10-05 02:32:08 +00:00
if ( caps - > set_vfo )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , tx_vfo ) ;
2017-10-05 02:32:08 +00:00
}
else if ( rig_has_vfo_op ( rig , RIG_OP_TOGGLE ) & & caps - > vfo_op )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > vfo_op ( rig , vfo , RIG_OP_TOGGLE ) ;
2017-10-05 02:32:08 +00:00
}
else
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2009-02-20 14:14:31 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2009-02-20 14:14:31 +00:00
2017-10-05 02:32:08 +00:00
if ( caps - > get_split_mode )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > get_split_mode ( rig , vfo , tx_mode , tx_width ) ;
2017-10-05 02:32:08 +00:00
}
else
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-26 11:49:24 +00:00
retcode = caps - > get_mode ? caps - > get_mode ( rig , RIG_VFO_CURR , tx_mode ,
tx_width ) : - RIG_ENIMPL ;
2017-08-05 14:09:12 +00:00
}
2001-04-28 12:49:12 +00:00
2017-08-05 14:09:12 +00:00
/* try and revert even if we had an error above */
2017-10-05 02:32:08 +00:00
if ( caps - > set_vfo )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2017-10-05 02:32:08 +00:00
}
else
{
2017-08-05 14:09:12 +00:00
rc2 = caps - > vfo_op ( rig , vfo , RIG_OP_TOGGLE ) ;
}
2005-03-26 17:57:14 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2008-10-31 23:08:59 +00:00
2017-10-05 02:32:08 +00:00
if ( * tx_width = = RIG_PASSBAND_NORMAL & & * tx_mode ! = RIG_MODE_NONE )
{
2017-08-05 14:09:12 +00:00
* tx_width = rig_passband_normal ( rig , * tx_mode ) ;
}
2008-10-31 23:08:59 +00:00
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2001-04-28 12:49:12 +00:00
}
2000-10-16 22:08:51 +00:00
2014-04-28 21:25:06 +00:00
/**
* \ brief set the split frequency and mode
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
2014-04-28 21:25:06 +00:00
* \ param tx_freq The transmit frequency to set to
2017-08-05 14:09:12 +00:00
* \ param tx_mode The transmit split mode to set to
2016-04-09 13:13:49 +00:00
* \ param tx_width The transmit split width to set to or the special
* value RIG_PASSBAND_NOCHANGE which leaves the passband unchanged
* from the current value or default for the mode determined by the
* rig .
2014-04-28 21:25:06 +00:00
*
* Sets the split ( TX ) frequency and mode .
*
* This function maybe optimized on some rig back ends , where the TX
* VFO cannot be directly addressed , to reduce the number of times
* the rig VFOs have to be exchanged or swapped to complete this
* combined function .
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2014-04-28 21:25:06 +00:00
* set appropriately ) .
*
* \ sa rig_set_split_freq ( ) , rig_set_split_mode ( ) , rig_get_split_freq_mode ( )
*/
2017-10-05 02:32:08 +00:00
int HAMLIB_API rig_set_split_freq_mode ( RIG * rig ,
vfo_t vfo ,
freq_t tx_freq ,
rmode_t tx_mode ,
pbwidth_t tx_width )
2014-04-28 21:25:06 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode ;
2014-04-28 21:25:06 +00:00
2021-11-10 05:20:02 +00:00
ELAPSED1 ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2014-04-28 21:25:06 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2021-08-30 13:45:56 +00:00
// if split is off we'll turn it on
if ( rig - > state . cache . split = = 0 )
{
if ( rig - > state . current_vfo & ( RIG_VFO_A | RIG_VFO_MAIN ) )
{
rig_set_split_vfo ( rig , RIG_VFO_A , 1 , RIG_VFO_B ) ;
}
else
{
rig_set_split_vfo ( rig , RIG_VFO_B , 1 , RIG_VFO_A ) ;
}
}
2021-08-03 04:37:31 +00:00
vfo = vfo_fixup ( rig , RIG_VFO_TX , rig - > state . cache . split ) ; // get the TX VFO
2021-04-04 17:50:07 +00:00
rig_debug ( RIG_DEBUG_VERBOSE ,
" %s: vfo=%s, tx_freq=%.0f, tx_mode=%s, tx_width=%d \n " , __func__ ,
rig_strvfo ( vfo ) , tx_freq , rig_strrmode ( tx_mode ) , ( int ) tx_width ) ;
2021-02-28 15:46:01 +00:00
if ( caps - > set_split_freq_mode )
{
2021-03-23 13:57:45 +00:00
#if 0
2021-02-28 15:46:01 +00:00
freq_t tfreq ;
2021-02-28 18:37:54 +00:00
int retry = 3 ;
int retcode2 ;
2021-03-23 13:57:45 +00:00
# endif
2021-03-02 14:36:37 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-23 13:57:45 +00:00
retcode = caps - > set_split_freq_mode ( rig , vfo , tx_freq , tx_mode , tx_width ) ;
#if 0 // this verification seems to be causing bad behavior on some reigs
2021-03-26 15:51:00 +00:00
2021-02-28 15:46:01 +00:00
// we query freq after set to ensure it really gets done
do
2021-02-23 13:44:16 +00:00
{
2021-02-28 15:46:01 +00:00
retcode = caps - > set_split_freq_mode ( rig , vfo , tx_freq , tx_mode , tx_width ) ;
2021-02-28 18:37:54 +00:00
retcode2 = rig_get_split_freq ( rig , vfo , & tfreq ) ;
2021-03-15 22:51:22 +00:00
2021-03-08 22:59:22 +00:00
if ( tfreq ! = tx_freq )
{
2021-03-15 22:51:22 +00:00
rig_debug ( RIG_DEBUG_ERR ,
" %s: txfreq!=tfreq %.0f!=%.0f, retry=%d, rc1=%d, rc2=%d \n " , __func__ , tx_freq ,
tfreq , retry , retcode , retcode2 ) ;
hl_usleep ( 50 * 1000 ) ; // 50ms sleep may help here
2021-03-08 22:59:22 +00:00
}
2021-03-26 15:51:00 +00:00
2021-03-18 20:40:32 +00:00
tfreq = tx_freq ;
retcode2 = RIG_OK ;
2021-02-23 13:44:16 +00:00
}
2021-03-02 14:36:37 +00:00
while ( tfreq ! = tx_freq & & retry - - > 0 & & retcode = = RIG_OK
& & retcode2 = = RIG_OK ) ;
2021-02-28 15:46:01 +00:00
if ( tfreq ! = tx_freq ) { retcode = - RIG_EPROTO ; }
2021-03-26 15:51:00 +00:00
2021-03-23 13:57:45 +00:00
# endif
2021-02-28 15:46:01 +00:00
2021-11-10 05:20:02 +00:00
ELAPSED2 ;
2021-02-28 15:46:01 +00:00
RETURNFUNC ( retcode ) ;
}
else
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-02-28 15:46:01 +00:00
retcode = rig_set_split_freq ( rig , vfo , tx_freq ) ;
}
2014-04-28 21:25:06 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = rig_set_split_mode ( rig , vfo , tx_mode , tx_width ) ;
}
2014-04-28 21:25:06 +00:00
2021-11-10 05:20:02 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2014-04-28 21:25:06 +00:00
}
2017-08-05 14:09:12 +00:00
2014-04-28 21:25:06 +00:00
/**
* \ brief get the current split frequency and mode
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
2014-04-28 21:25:06 +00:00
* \ param tx_freq The location where to store the current transmit frequency
2017-08-05 14:09:12 +00:00
* \ param tx_mode The location where to store the current transmit split mode
* \ param tx_width The location where to store the current transmit split width
2014-04-28 21:25:06 +00:00
*
* Retrieves the current split ( TX ) frequency , mode and passband .
* If the backend is unable to determine the width , the \ a tx_width
* will be set to RIG_PASSBAND_NORMAL as a default .
* The value stored at \ a tx_mode location equals RIG_MODE_NONE
* when the current mode of the VFO is not defined ( e . g . blank memory ) .
*
* This function maybe optimized on some rig back ends , where the TX
* VFO cannot be directly addressed , to reduce the number of times
* the rig VFOs have to be exchanged or swapped to complete this
* combined function .
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2014-04-28 21:25:06 +00:00
* set appropriately ) .
*
* \ sa rig_get_split_freq ( ) , rig_get_split_mode ( ) , rig_set_split_freq_mode ( )
*/
2017-10-05 02:32:08 +00:00
int HAMLIB_API rig_get_split_freq_mode ( RIG * rig ,
vfo_t vfo ,
freq_t * tx_freq ,
rmode_t * tx_mode ,
pbwidth_t * tx_width )
2014-04-28 21:25:06 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode ;
2021-11-10 05:14:44 +00:00
ELAPSED1 ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! tx_freq | | ! tx_mode | | ! tx_width )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2014-04-28 21:25:06 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2014-04-28 21:25:06 +00:00
2017-10-05 02:32:08 +00:00
if ( caps - > get_split_freq_mode )
{
2021-03-18 12:09:58 +00:00
retcode = caps - > get_split_freq_mode ( rig , vfo , tx_freq , tx_mode , tx_width ) ;
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-11-29 22:08:24 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2014-04-28 21:25:06 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = rig_get_split_freq ( rig , vfo , tx_freq ) ;
2014-04-28 21:25:06 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = rig_get_split_mode ( rig , vfo , tx_mode , tx_width ) ;
}
2014-04-28 21:25:06 +00:00
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2014-04-28 21:25:06 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the split mode
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param split The split mode to set to
* \ param tx_vfo The transmit VFO
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Sets the current split mode .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2003-04-06 18:40:36 +00:00
* \ sa rig_get_split_vfo ( )
2000-10-16 22:08:51 +00:00
*/
2017-10-05 02:32:08 +00:00
int HAMLIB_API rig_set_split_vfo ( RIG * rig ,
2021-08-28 14:54:37 +00:00
vfo_t rx_vfo ,
2017-10-05 02:32:08 +00:00
split_t split ,
2017-08-05 14:09:12 +00:00
vfo_t tx_vfo )
2000-10-16 22:08:51 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-11-10 05:20:02 +00:00
ELAPSED1 ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2022-05-13 21:50:13 +00:00
rig_debug ( RIG_DEBUG_VERBOSE ,
" %s: rx_vfo=%s, split=%d, tx_vfo=%s, cache.split=%d \n " , __func__ ,
2022-05-03 17:51:58 +00:00
rig_strvfo ( rx_vfo ) , split , rig_strvfo ( tx_vfo ) , rig - > state . cache . split ) ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > set_split_vfo = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2021-11-28 18:41:10 +00:00
if ( rig - > state . cache . ptt )
{
rig_debug ( RIG_DEBUG_WARN , " %s: cannot execute when PTT is on \n " , __func__ ) ;
ELAPSED2 ;
return RIG_OK ;
}
2017-08-05 14:09:12 +00:00
2021-09-06 12:41:33 +00:00
// We fix up vfos for non-satmode rigs only
if ( rig - > caps - > has_get_func & RIG_FUNC_SATMODE )
{
2021-09-25 13:59:57 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: satmode rig...not fixing up vfos rx=%s tx=%s \n " ,
__func__ , rig_strvfo ( rx_vfo ) , rig_strvfo ( tx_vfo ) ) ;
2021-09-06 12:41:33 +00:00
}
else
2021-09-01 17:45:29 +00:00
{
2021-11-28 18:41:10 +00:00
switch ( tx_vfo )
2021-11-03 20:00:38 +00:00
{
2021-11-28 18:41:10 +00:00
case RIG_VFO_A : rx_vfo = split = = 1 ? RIG_VFO_B : RIG_VFO_A ; break ;
case RIG_VFO_B : rx_vfo = split = = 1 ? RIG_VFO_A : RIG_VFO_B ; break ;
2021-11-03 20:00:38 +00:00
}
2021-11-28 18:41:10 +00:00
2022-05-03 17:59:35 +00:00
//rig->state.cache.split = split; // this gets set later
//rig->state.cache.split_vfo = tx_vfo;
2021-11-25 15:34:23 +00:00
rx_vfo = vfo_fixup ( rig , rx_vfo , split ) ;
tx_vfo = vfo_fixup ( rig , tx_vfo , split ) ;
rig - > state . rx_vfo = rx_vfo ;
rig - > state . tx_vfo = tx_vfo ;
2022-05-13 21:50:13 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s: final rxvfo=%s, txvfo=%s, split=%d \n " ,
__func__ ,
2022-05-03 17:40:23 +00:00
rig_strvfo ( rx_vfo ) , rig_strvfo ( tx_vfo ) , rig - > state . cache . split ) ;
2021-09-01 17:45:29 +00:00
}
2021-08-26 11:49:24 +00:00
2021-08-03 04:37:31 +00:00
// set rig to the the requested RX VFO
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-26 11:49:24 +00:00
2021-11-28 18:41:10 +00:00
if ( ( ! ( caps - > targetable_vfo & RIG_TARGETABLE_FREQ ) )
& & ( ! ( rig - > caps - > rig_model = = RIG_MODEL_NETRIGCTL ) ) )
2021-08-13 12:42:39 +00:00
# if BUILTINFUNC
2021-08-28 14:54:37 +00:00
rig_set_vfo ( rig , rx_vfo = = RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A ,
2021-08-26 11:49:24 +00:00
__builtin_FUNCTION ( ) ) ;
2021-08-13 12:42:39 +00:00
# else
2021-08-28 14:54:37 +00:00
rig_set_vfo ( rig , rx_vfo = = RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A ) ;
2021-08-13 12:42:39 +00:00
# endif
2020-05-30 14:34:13 +00:00
2021-08-28 14:54:37 +00:00
if ( rx_vfo = = RIG_VFO_CURR
| | rx_vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2021-11-24 15:03:26 +00:00
// for non-targetable VFOs we will not set split again
if ( rig - > state . cache . split = = split & & rig - > state . cache . split_vfo = = tx_vfo )
{
2021-11-28 18:41:10 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): split already set...ignoring \n " , __func__ ,
__LINE__ ) ;
2021-11-24 15:03:26 +00:00
RETURNFUNC ( RIG_OK ) ;
}
2021-11-28 18:41:10 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-28 14:54:37 +00:00
retcode = caps - > set_split_vfo ( rig , rx_vfo , split , tx_vfo ) ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode = = RIG_OK )
{
rig - > state . tx_vfo = tx_vfo ;
}
2017-08-05 14:09:12 +00:00
2020-05-25 04:42:35 +00:00
rig - > state . cache . split = split ;
rig - > state . cache . split_vfo = tx_vfo ;
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_split , HAMLIB_ELAPSED_SET ) ;
2021-11-10 05:20:02 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-26 11:49:24 +00:00
2021-08-13 12:42:39 +00:00
if ( ! ( caps - > targetable_vfo & RIG_TARGETABLE_FREQ ) )
{
2021-08-28 14:54:37 +00:00
retcode = caps - > set_vfo ( rig , rx_vfo ) ;
2017-08-05 14:09:12 +00:00
2021-08-26 11:49:24 +00:00
if ( retcode ! = RIG_OK )
{
RETURNFUNC ( retcode ) ;
}
2021-08-13 12:42:39 +00:00
}
2017-08-05 14:09:12 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-08-28 14:54:37 +00:00
retcode = caps - > set_split_vfo ( rig , rx_vfo , split , tx_vfo ) ;
2017-08-05 14:09:12 +00:00
/* try and revert even if we had an error above */
2021-08-26 11:49:24 +00:00
if ( ! ( caps - > targetable_vfo & RIG_TARGETABLE_FREQ ) )
{
2021-08-13 12:42:39 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2017-08-05 14:09:12 +00:00
2021-08-26 11:49:24 +00:00
if ( RIG_OK = = retcode )
{
/* return the first error code */
retcode = rc2 ;
}
2021-08-13 12:42:39 +00:00
}
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode = = RIG_OK )
{
2017-08-05 14:09:12 +00:00
rig - > state . tx_vfo = tx_vfo ;
}
2020-05-01 17:03:54 +00:00
rig - > state . cache . split = split ;
rig - > state . cache . split_vfo = tx_vfo ;
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_split , HAMLIB_ELAPSED_SET ) ;
2021-11-10 05:20:02 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-16 22:08:51 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the current split mode
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param split The location where to store the current split mode
* \ param tx_vfo The transmit VFO
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves the current split mode .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2003-04-06 18:40:36 +00:00
* \ sa rig_set_split_vfo ( )
2000-10-16 22:08:51 +00:00
*/
2017-10-05 02:32:08 +00:00
int HAMLIB_API rig_get_split_vfo ( RIG * rig ,
vfo_t vfo ,
split_t * split ,
2017-08-05 14:09:12 +00:00
vfo_t * tx_vfo )
2000-10-16 22:08:51 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
2020-06-14 15:35:44 +00:00
#if 0
2017-08-05 14:09:12 +00:00
int retcode , rc2 ;
2020-06-14 15:35:44 +00:00
# else
int retcode ;
# endif
#if 0
2017-08-05 14:09:12 +00:00
vfo_t curr_vfo ;
2020-06-14 15:35:44 +00:00
# endif
2020-05-01 17:03:54 +00:00
int cache_ms ;
2000-10-16 22:08:51 +00:00
2021-11-10 05:14:44 +00:00
ELAPSED1 ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2001-02-27 23:10:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! split | | ! tx_vfo )
2017-10-05 02:32:08 +00:00
{
2021-04-22 04:48:29 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: split or tx_vfo is null, split=%p, tx_vfo=%p \n " ,
__func__ , split , tx_vfo ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > get_split_vfo = = NULL )
{
2021-04-18 16:35:35 +00:00
// if we can't get the vfo we will return whatever we have cached
* split = rig - > state . cache . split ;
* tx_vfo = rig - > state . cache . split_vfo ;
2021-04-22 04:48:29 +00:00
rig_debug ( RIG_DEBUG_VERBOSE ,
" %s: no get_split_vfo so returning split=%d, tx_vfo=%s \n " , __func__ , * split ,
rig_strvfo ( * tx_vfo ) ) ;
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-04-18 16:35:35 +00:00
RETURNFUNC ( RIG_OK ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2020-07-02 03:33:32 +00:00
cache_ms = elapsed_ms ( & rig - > state . cache . time_split , HAMLIB_ELAPSED_GET ) ;
2020-05-01 17:03:54 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: cache check age=%dms \n " , __func__ , cache_ms ) ;
if ( cache_ms < rig - > state . cache . timeout_ms )
{
* split = rig - > state . cache . split ;
* tx_vfo = rig - > state . cache . split_vfo ;
2021-11-28 18:41:10 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: cache hit age=%dms, split=%d, tx_vfo=%s \n " ,
__func__ , cache_ms , * split , rig_strvfo ( * tx_vfo ) ) ;
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2020-05-01 17:03:54 +00:00
}
else
{
rig_debug ( RIG_DEBUG_TRACE , " %s: cache miss age=%dms \n " , __func__ , cache_ms ) ;
}
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
/* overridden by backend at will */
2017-08-05 14:09:12 +00:00
* tx_vfo = rig - > state . tx_vfo ;
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-06-13 21:18:46 +00:00
retcode = RIG_OK ;
2021-06-16 15:11:45 +00:00
//if (rig->caps->rig_model != RIG_MODEL_NETRIGCTL)
2021-08-26 11:49:24 +00:00
{
// rigctld doesn't like nested calls
2021-06-12 16:04:10 +00:00
retcode = caps - > get_split_vfo ( rig , vfo , split , tx_vfo ) ;
rig - > state . cache . split = * split ;
rig - > state . cache . split_vfo = * tx_vfo ;
elapsed_ms ( & rig - > state . cache . time_split , HAMLIB_ELAPSED_SET ) ;
2022-05-13 21:50:13 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: cache.split=%d \n " , __func__ ,
rig - > state . cache . split ) ;
2021-06-12 16:04:10 +00:00
}
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2020-06-14 15:29:18 +00:00
#if 0 // why were we doing this? Shouldn't need to set_vfo to figure out tx_vfo
2020-06-14 15:35:44 +00:00
curr_vfo = rig - > state . current_vfo ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2009-02-20 14:14:31 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2020-06-21 22:47:04 +00:00
2020-06-14 15:29:18 +00:00
# endif
2001-01-05 18:24:20 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > get_split_vfo ( rig , vfo , split , tx_vfo ) ;
2020-06-14 15:29:18 +00:00
#if 0 // see above
2017-08-05 14:09:12 +00:00
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2020-06-21 22:47:04 +00:00
2020-06-14 15:29:18 +00:00
# endif
2014-12-11 17:14:58 +00:00
2020-06-14 15:29:18 +00:00
if ( retcode = = RIG_OK ) // only update cache on success
{
rig - > state . cache . split = * split ;
rig - > state . cache . split_vfo = * tx_vfo ;
2020-07-02 03:33:32 +00:00
elapsed_ms ( & rig - > state . cache . time_split , HAMLIB_ELAPSED_SET ) ;
2022-05-13 21:50:13 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s(%d): cache.split=%d \n " , __func__ , __LINE__ ,
rig - > state . cache . split ) ;
2020-06-14 15:29:18 +00:00
}
2020-05-01 17:03:54 +00:00
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-16 22:08:51 +00:00
}
2017-08-05 14:09:12 +00:00
2000-11-28 22:33:37 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the RIT
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param rit The RIT offset to adjust to
2000-11-28 22:33:37 +00:00
*
2001-06-30 12:36:43 +00:00
* Sets the current RIT offset . A value of 0 for \ a rit disables RIT .
2000-11-28 22:33:37 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2000-11-28 22:33:37 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_get_rit ( )
2000-11-28 22:33:37 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_set_rit ( RIG * rig , vfo_t vfo , shortfreq_t rit )
2000-11-28 22:33:37 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > set_rit = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2000-11-28 22:33:37 +00:00
2020-10-31 22:19:08 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_RITXIT )
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_CURR
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > set_rit ( rig , vfo , rit ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-27 23:10:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-01-05 18:24:20 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2017-08-05 14:09:12 +00:00
retcode = caps - > set_rit ( rig , vfo , rit ) ;
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-11-28 22:33:37 +00:00
}
2017-08-05 14:09:12 +00:00
2000-11-28 22:33:37 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the current RIT offset
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param rit The location where to store the current RIT offset
2000-11-28 22:33:37 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves the current RIT offset .
2000-11-28 22:33:37 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2000-11-28 22:33:37 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_rit ( )
2000-11-28 22:33:37 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_get_rit ( RIG * rig , vfo_t vfo , shortfreq_t * rit )
2000-11-28 22:33:37 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! rit )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > get_rit = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2020-10-31 22:19:08 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_RITXIT )
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_CURR
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > get_rit ( rig , vfo , rit ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2000-11-28 22:33:37 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-27 23:10:12 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-01-05 18:24:20 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > get_rit ( rig , vfo , rit ) ;
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-11-28 22:33:37 +00:00
}
2017-08-05 14:09:12 +00:00
2001-05-04 22:44:10 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the XIT
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param xit The XIT offset to adjust to
2001-05-04 22:44:10 +00:00
*
2001-06-30 12:36:43 +00:00
* Sets the current XIT offset . A value of 0 for \ a xit disables XIT .
2001-05-04 22:44:10 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-05-04 22:44:10 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_get_xit ( )
2001-05-04 22:44:10 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_set_xit ( RIG * rig , vfo_t vfo , shortfreq_t xit )
2001-05-04 22:44:10 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2001-05-04 22:44:10 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > set_xit = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2020-10-31 22:19:08 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_RITXIT )
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_CURR
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > set_xit ( rig , vfo , xit ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-05-04 22:44:10 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-05-04 22:44:10 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-05-04 22:44:10 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-05-04 22:44:10 +00:00
2017-08-05 14:09:12 +00:00
retcode = caps - > set_xit ( rig , vfo , xit ) ;
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2001-05-04 22:44:10 +00:00
}
2017-08-05 14:09:12 +00:00
2001-05-04 22:44:10 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the current XIT offset
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param xit The location where to store the current XIT offset
2001-05-04 22:44:10 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves the current XIT offset .
2001-05-04 22:44:10 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-05-04 22:44:10 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_xit ( )
2001-05-04 22:44:10 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_get_xit ( RIG * rig , vfo_t vfo , shortfreq_t * xit )
2001-05-04 22:44:10 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2001-05-04 22:44:10 +00:00
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2001-05-04 22:44:10 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! xit )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2001-05-04 22:44:10 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2001-05-04 22:44:10 +00:00
2017-10-05 02:32:08 +00:00
if ( caps - > get_xit = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-05-04 22:44:10 +00:00
2020-10-31 22:19:08 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_RITXIT )
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_CURR
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > get_xit ( rig , vfo , xit ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2014-12-11 17:14:58 +00:00
}
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-05-04 22:44:10 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > get_xit ( rig , vfo , xit ) ;
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2000-11-28 22:33:37 +00:00
2000-10-16 22:08:51 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the Tuning Step
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param ts The tuning step to set to
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Sets the Tuning Step .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_get_ts ( )
2000-10-01 12:29:12 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_set_ts ( RIG * rig , vfo_t vfo , shortfreq_t ts )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2000-10-01 12:29:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > set_ts = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-27 23:10:12 +00:00
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > set_ts ( rig , vfo , ts ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-01-05 18:24:20 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_ts ( rig , vfo , ts ) ;
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the current Tuning Step
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param ts The location where to store the current tuning step
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves the current tuning step .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_ts ( )
2000-10-01 12:29:12 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_get_ts ( RIG * rig , vfo_t vfo , shortfreq_t * ts )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! ts )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > get_ts = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2000-10-01 12:29:12 +00:00
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > get_ts ( rig , vfo , ts ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-27 23:10:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-01-05 18:24:20 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > get_ts ( rig , vfo , ts ) ;
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
2001-02-14 01:08:12 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief set the antenna
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param ant The anntena to select
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* \ param option An option that the ant command for the rig recognizes
2001-02-14 01:08:12 +00:00
*
2002-11-28 22:32:42 +00:00
* Select the antenna connector .
\ code
2017-08-05 14:09:12 +00:00
rig_set_ant ( rig , RIG_VFO_CURR , RIG_ANT_1 ) ; // apply to both TX&RX
rig_set_ant ( rig , RIG_VFO_RX , RIG_ANT_2 ) ;
2002-11-28 22:32:42 +00:00
\ endcode
2001-02-14 01:08:12 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-02-14 01:08:12 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_get_ant ( )
2001-02-14 01:08:12 +00:00
*/
2020-01-21 23:53:12 +00:00
int HAMLIB_API rig_set_ant ( RIG * rig , vfo_t vfo , ant_t ant , value_t option )
2001-02-14 01:08:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-14 01:08:12 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2001-02-27 23:10:12 +00:00
2017-10-05 02:32:08 +00:00
if ( caps - > set_ant = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2021-01-08 13:16:45 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_ANT )
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_CURR
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > set_ant ( rig , vfo , ant , option ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-14 01:08:12 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-02-14 01:08:12 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-14 01:08:12 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-01-21 23:53:12 +00:00
retcode = caps - > set_ant ( rig , vfo , ant , option ) ;
2017-08-05 14:09:12 +00:00
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2001-02-14 01:08:12 +00:00
}
2017-08-05 14:09:12 +00:00
2001-02-14 01:08:12 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the current antenna
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
2021-08-25 20:13:21 +00:00
* \ param ant The antenna to query option for
* \ param option The option value for the antenna , rig specific .
2020-04-09 22:56:19 +00:00
* \ param ant_curr The currently selected antenna
* \ param ant_tx The currently selected TX antenna
* \ param ant_rx The currently selected RX antenna
2001-02-14 01:08:12 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves the current antenna .
2001-02-14 01:08:12 +00:00
*
2021-08-25 20:13:21 +00:00
* If \ a ant_tx and / or \ a ant_rx are unused by the rig they will be set to
* RIG_ANT_UNKNOWN and only \ a ant_curr will be set .
*
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-02-14 01:08:12 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_set_ant ( )
2001-02-14 01:08:12 +00:00
*/
2020-02-23 17:26:09 +00:00
int HAMLIB_API rig_get_ant ( RIG * rig , vfo_t vfo , ant_t ant , value_t * option ,
ant_t * ant_curr , ant_t * ant_tx , ant_t * ant_rx )
2001-02-14 01:08:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2001-02-14 01:08:12 +00:00
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2001-02-14 01:08:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
2021-05-05 15:45:22 +00:00
if ( ant_curr = = NULL | | ant_tx = = NULL | | ant_rx = = NULL )
2017-10-05 02:32:08 +00:00
{
2021-05-05 15:45:22 +00:00
rig_debug ( RIG_DEBUG_ERR ,
" %s: null pointer in ant_curr=%p, ant_tx=%p, ant_rx=%p \n " , __func__ , ant_curr ,
ant_tx , ant_rx ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-27 23:10:12 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
2001-02-14 01:08:12 +00:00
2017-10-05 02:32:08 +00:00
if ( caps - > get_ant = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-14 01:08:12 +00:00
2021-08-25 20:13:21 +00:00
/* Set antenna default to unknown and clear option.
* So we have sane defaults for all backends */
* ant_tx = * ant_rx = * ant_curr = RIG_ANT_UNKNOWN ;
option - > i = 0 ;
2021-01-08 13:16:45 +00:00
if ( ( caps - > targetable_vfo & RIG_TARGETABLE_ANT )
2019-11-30 16:19:08 +00:00
| | vfo = = RIG_VFO_CURR
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = caps - > get_ant ( rig , vfo , ant , option , ant_curr , ant_tx , ant_rx ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2014-12-11 17:14:58 +00:00
}
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-02-19 05:10:14 +00:00
retcode = caps - > get_ant ( rig , vfo , ant , option , ant_curr , ant_tx , ant_rx ) ;
2017-08-05 14:09:12 +00:00
/* try and revert even if we had an error above */
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
}
2001-02-14 01:08:12 +00:00
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-02-14 01:08:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief conversion utility from relative range to absolute in mW
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param mwpower The location where to store the converted power in mW
* \ param power The relative power
* \ param freq The frequency where the conversion should take place
* \ param mode The mode where the conversion should take place
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2010-02-14 21:47:49 +00:00
* Converts a power value expressed in a range on a [ 0.0 . . 1.0 ] relative
2001-06-30 12:36:43 +00:00
* scale to the real transmit power in milli Watts the radio would emit .
* The \ a freq and \ a mode where the conversion should take place must be
* also provided since the relative power is peculiar to a specific
* freq and mode range of the radio .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_mW2power ( )
2000-10-01 12:29:12 +00:00
*/
2017-10-05 02:32:08 +00:00
int HAMLIB_API rig_power2mW ( RIG * rig ,
unsigned int * mwpower ,
float power ,
freq_t freq ,
rmode_t mode )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const freq_range_t * txrange ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! rig | | ! rig - > caps | | ! mwpower | | power < 0.0 | | power > 1.0 )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( rig - > caps - > power2mW ! = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( rig - > caps - > power2mW ( rig , mwpower , power , freq , mode ) ) ;
2017-08-05 14:09:12 +00:00
}
txrange = rig_get_range ( rig - > state . tx_range_list , freq , mode ) ;
2017-10-05 02:32:08 +00:00
if ( ! txrange )
{
2017-08-05 14:09:12 +00:00
/*
* freq is not on the tx range !
*/
2021-05-25 15:22:52 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
* mwpower = ( unsigned int ) ( power * txrange - > high_power ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief conversion utility from absolute in mW to relative range
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param power The location where to store the converted relative power
* \ param mwpower The power in mW
* \ param freq The frequency where the conversion should take place
* \ param mode The mode where the conversion should take place
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Converts a power value expressed in the real transmit power in milli Watts
* the radio would emit to a range on a [ 0.0 . . 1.0 ] relative scale .
* The \ a freq and \ a mode where the conversion should take place must be
* also provided since the relative power is peculiar to a specific
* freq and mode range of the radio .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_power2mW ( )
2000-10-01 12:29:12 +00:00
*/
2017-10-05 02:32:08 +00:00
int HAMLIB_API rig_mW2power ( RIG * rig ,
float * power ,
unsigned int mwpower ,
freq_t freq ,
rmode_t mode )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
const freq_range_t * txrange ;
2019-12-09 04:45:29 +00:00
if ( ! rig | | ! rig - > caps | | ! power | | mwpower = = 0 )
2017-10-05 02:32:08 +00:00
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( rig - > caps - > mW2power ! = NULL )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( rig - > caps - > mW2power ( rig , power , mwpower , freq , mode ) ) ;
2017-08-05 14:09:12 +00:00
}
txrange = rig_get_range ( rig - > state . tx_range_list , freq , mode ) ;
2017-10-05 02:32:08 +00:00
if ( ! txrange )
{
2017-08-05 14:09:12 +00:00
/*
* freq is not on the tx range !
*/
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_EINVAL ) ; /* could be RIG_EINVAL ? */
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( txrange - > high_power = = 0 )
{
2017-08-05 14:09:12 +00:00
* power = 0.0 ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( RIG_OK ) ;
2017-08-05 14:09:12 +00:00
}
* power = ( float ) mwpower / txrange - > high_power ;
2017-10-05 02:32:08 +00:00
if ( * power > 1.0 )
{
2017-08-05 14:09:12 +00:00
* power = 1.0 ;
}
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( mwpower > txrange - > high_power ? RIG_OK : - RIG_ETRUNC ) ;
2000-10-01 12:29:12 +00:00
}
2017-08-05 14:09:12 +00:00
2001-02-07 23:44:08 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get the best frequency resolution of the rig
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param mode The mode where the conversion should take place
2001-02-07 23:44:08 +00:00
*
2001-06-30 12:36:43 +00:00
* Returns the best frequency resolution of the rig , for a given \ a mode .
2001-02-07 23:44:08 +00:00
*
2001-06-30 12:36:43 +00:00
* \ return the frequency resolution in Hertz if the operation h
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* has been successful , otherwise a negative value if an error occurred .
2001-02-07 23:44:08 +00:00
*
*/
2004-10-02 10:32:09 +00:00
shortfreq_t HAMLIB_API rig_get_resolution ( RIG * rig , rmode_t mode )
2001-02-07 23:44:08 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_state * rs ;
int i ;
2001-02-07 23:44:08 +00:00
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2001-02-07 23:44:08 +00:00
2017-10-05 02:32:08 +00:00
if ( ! rig | | ! rig - > caps | | ! mode )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
rs = & rig - > state ;
2001-02-07 23:44:08 +00:00
2021-03-06 18:37:53 +00:00
for ( i = 0 ; i < HAMLIB_TSLSTSIZ & & rs - > tuning_steps [ i ] . ts ; i + + )
2017-10-05 02:32:08 +00:00
{
if ( rs - > tuning_steps [ i ] . modes & mode )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( rs - > tuning_steps [ i ] . ts ) ;
2017-08-05 14:09:12 +00:00
}
}
2001-02-07 23:44:08 +00:00
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2001-02-07 23:44:08 +00:00
}
2002-07-09 20:40:28 +00:00
/**
2002-11-04 22:22:30 +00:00
* \ brief turn on / off the radio
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param status The status to set to
2002-07-09 20:40:28 +00:00
*
2002-11-04 22:22:30 +00:00
* turns on / off the radio .
* See # RIG_POWER_ON , # RIG_POWER_OFF and # RIG_POWER_STANDBY defines
* for the \ a status .
2002-07-09 20:40:28 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , ortherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2002-07-09 20:40:28 +00:00
* set appropriately ) .
*
2002-11-04 22:22:30 +00:00
* \ sa rig_get_powerstat ( )
2002-07-09 20:40:28 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_set_powerstat ( RIG * rig , powerstat_t status )
2001-07-21 13:00:03 +00:00
{
2021-03-18 12:09:58 +00:00
int retcode ;
2022-05-09 14:13:26 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s called status=%d \n " , __func__ , status ) ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2001-07-21 13:00:03 +00:00
2017-10-05 02:32:08 +00:00
if ( rig - > caps - > set_powerstat = = NULL )
{
2019-12-16 16:51:36 +00:00
rig_debug ( RIG_DEBUG_WARN , " %s set_powerstat not implemented \n " , __func__ ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-07-21 13:00:03 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = rig - > caps - > set_powerstat ( rig , status ) ;
2022-05-09 12:30:21 +00:00
rig_flush ( & rig - > state . rigport ) ; // if anything is queued up flush it
2021-03-18 12:09:58 +00:00
RETURNFUNC ( retcode ) ;
2001-07-21 13:00:03 +00:00
}
2017-08-05 14:09:12 +00:00
2001-07-21 13:00:03 +00:00
/**
2002-11-04 22:22:30 +00:00
* \ brief get the on / off status of the radio
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
2020-02-24 15:34:02 +00:00
* \ param status The location where to store the current status
2001-07-21 13:00:03 +00:00
*
2010-02-14 21:47:49 +00:00
* Retrieve the status of the radio . See RIG_POWER_ON , RIG_POWER_OFF and
2002-11-04 22:22:30 +00:00
* RIG_POWER_STANDBY defines for the \ a status .
2001-07-21 13:00:03 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-07-21 13:00:03 +00:00
* set appropriately ) .
*
2002-11-04 22:22:30 +00:00
* \ sa rig_set_powerstat ( )
2001-07-21 13:00:03 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_get_powerstat ( RIG * rig , powerstat_t * status )
2001-07-21 13:00:03 +00:00
{
2021-03-18 12:09:58 +00:00
int retcode ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2022-07-15 21:09:49 +00:00
* status = RIG_POWER_ON ; // default to power on if not available
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! status )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2001-07-21 13:00:03 +00:00
2017-10-05 02:32:08 +00:00
if ( rig - > caps - > get_powerstat = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-07-21 13:00:03 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-18 12:09:58 +00:00
retcode = rig - > caps - > get_powerstat ( rig , status ) ;
RETURNFUNC ( retcode ) ;
2001-07-21 13:00:03 +00:00
}
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2002-11-04 22:22:30 +00:00
* \ brief reset the radio
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param reset The reset operation to perform
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2002-11-04 22:22:30 +00:00
* Resets the radio .
2021-09-09 20:15:16 +00:00
* See # RIG_RESET_NONE , # RIG_RESET_SOFT and # RIG_RESET_MCALL defines
2002-11-04 22:22:30 +00:00
* for the \ a reset .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2000-10-16 22:08:51 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_reset ( RIG * rig , reset_t reset )
2000-10-16 22:08:51 +00:00
{
2021-03-18 12:09:58 +00:00
int retcode ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2000-10-16 22:08:51 +00:00
2017-10-05 02:32:08 +00:00
if ( rig - > caps - > reset = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2021-03-18 12:09:58 +00:00
retcode = rig - > caps - > reset ( rig , reset ) ;
RETURNFUNC ( retcode ) ;
2000-10-16 22:08:51 +00:00
}
2017-08-05 14:09:12 +00:00
2020-04-09 22:56:19 +00:00
//! @cond Doxygen_Suppress
2005-04-03 12:27:17 +00:00
extern int rig_probe_first ( hamlib_port_t * p ) ;
2017-10-05 02:32:08 +00:00
extern int rig_probe_all_backends ( hamlib_port_t * p ,
rig_probe_func_t cfunc ,
2017-08-05 14:09:12 +00:00
rig_ptr_t data ) ;
2020-04-09 22:56:19 +00:00
//! @endcond
2017-08-05 14:09:12 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2002-11-04 22:22:30 +00:00
* \ brief try to guess a rig
2017-08-05 14:09:12 +00:00
* \ param port A pointer describing a port linking the host to the rig
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2010-02-14 21:47:49 +00:00
* Try to guess what is the model of the first rig attached to the port .
2002-11-04 22:22:30 +00:00
* It can be very buggy , and mess up the radio at the other end .
* ( but fun if it works ! )
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2002-11-04 22:22:30 +00:00
* \ warning this is really Experimental , It has been tested only
* with IC - 706 MkIIG . any feedback welcome ! - - SF
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2010-02-14 21:47:49 +00:00
* \ return the rig model id according to the rig_model_t type if found ,
2002-11-04 22:22:30 +00:00
* otherwise RIG_MODEL_NONE if unable to determine rig model .
2000-10-16 22:08:51 +00:00
*/
2005-04-03 12:27:17 +00:00
rig_model_t HAMLIB_API rig_probe ( hamlib_port_t * port )
2000-10-16 22:08:51 +00:00
{
2017-10-05 02:32:08 +00:00
if ( ! port )
{
2022-02-05 21:27:43 +00:00
return ( RIG_MODEL_NONE ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2017-08-05 14:09:12 +00:00
return rig_probe_first ( port ) ;
2003-03-10 08:26:09 +00:00
}
2017-08-05 14:09:12 +00:00
2003-03-10 08:26:09 +00:00
/**
* \ brief try to guess rigs
2017-08-05 14:09:12 +00:00
* \ param port A pointer describing a port linking the host to the rigs
* \ param cfunc Function to be called each time a rig is found
* \ param data Arbitrary data passed to cfunc
2003-03-10 08:26:09 +00:00
*
2010-02-14 21:47:49 +00:00
* Try to guess what are the model of all rigs attached to the port .
2003-03-10 08:26:09 +00:00
* It can be very buggy , and mess up the radio at the other end .
* ( but fun if it works ! )
*
* \ warning this is really Experimental , It has been tested only
* with IC - 706 MkIIG . any feedback welcome ! - - SF
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2003-03-10 08:26:09 +00:00
* set appropriately ) .
*/
2017-10-05 02:32:08 +00:00
int HAMLIB_API rig_probe_all ( hamlib_port_t * port ,
rig_probe_func_t cfunc ,
2017-08-05 14:09:12 +00:00
rig_ptr_t data )
2003-03-10 08:26:09 +00:00
{
2017-10-05 02:32:08 +00:00
if ( ! port )
{
2022-02-05 21:27:43 +00:00
return ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
return rig_probe_all_backends ( port , cfunc , data ) ;
2000-10-16 22:08:51 +00:00
}
2017-08-05 14:09:12 +00:00
2001-06-03 19:54:05 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief check retrieval ability of VFO operations
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param op The VFO op
2001-06-03 19:54:05 +00:00
*
2010-02-14 21:47:49 +00:00
* Checks if a rig is capable of executing a VFO operation .
2001-06-30 12:36:43 +00:00
* Since the \ a op is an OR ' ed bitmap argument , more than
* one op can be checked at the same time .
2001-06-03 19:54:05 +00:00
*
2017-08-05 14:09:12 +00:00
* EXAMPLE : if ( rig_has_vfo_op ( my_rig , RIG_OP_CPY ) ) disp_VFOcpy_btn ( ) ;
2001-06-03 19:54:05 +00:00
*
2001-06-30 12:36:43 +00:00
* \ return a bit map mask of supported op settings that can be retrieved ,
* otherwise 0 if none supported .
2001-06-03 19:54:05 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_vfo_op ( )
2001-06-03 19:54:05 +00:00
*/
2004-10-02 10:32:09 +00:00
vfo_op_t HAMLIB_API rig_has_vfo_op ( RIG * rig , vfo_op_t op )
2001-06-03 19:54:05 +00:00
{
2021-03-18 12:09:58 +00:00
int retcode ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! rig | | ! rig - > caps )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( 0 ) ;
2017-08-05 14:09:12 +00:00
}
2001-06-03 19:54:05 +00:00
2021-03-18 12:09:58 +00:00
retcode = rig - > caps - > vfo_ops & op ;
RETURNFUNC ( retcode ) ;
2001-06-03 19:54:05 +00:00
}
2017-08-05 14:09:12 +00:00
2001-06-03 19:54:05 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief perform Memory / VFO operations
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param op The Memory / VFO operation to perform
2001-06-03 19:54:05 +00:00
*
2001-06-30 12:36:43 +00:00
* Performs Memory / VFO operation .
* See # vfo_op_t for more information .
2001-06-03 19:54:05 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-06-03 19:54:05 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_has_vfo_op ( )
2001-06-03 19:54:05 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_vfo_op ( RIG * rig , vfo_t vfo , vfo_op_t op )
2001-06-03 19:54:05 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2022-05-16 03:29:43 +00:00
ELAPSED1 ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2022-05-13 21:50:13 +00:00
if ( caps - > vfo_op = = NULL | | rig_has_vfo_op ( rig , op ) = = 0 )
2017-10-05 02:32:08 +00:00
{
2022-05-13 21:50:13 +00:00
rig_debug ( RIG_DEBUG_WARN , " %s: vfo_op=%p, has_vfo_op=%d \n " , __func__ ,
caps - > vfo_op , rig_has_vfo_op ( rig , op ) ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-06-03 19:54:05 +00:00
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2021-03-18 12:09:58 +00:00
retcode = caps - > vfo_op ( rig , vfo , op ) ;
2022-05-16 03:29:43 +00:00
ELAPSED2 ;
2021-03-18 12:09:58 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-06-03 19:54:05 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2022-05-12 16:09:46 +00:00
rig_debug ( RIG_DEBUG_WARN , " %s: no set_vfo \n " , __func__ ) ;
2022-05-16 03:29:43 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-06-03 19:54:05 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-06-03 19:54:05 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-06-03 19:54:05 +00:00
2017-08-05 14:09:12 +00:00
retcode = caps - > vfo_op ( rig , vfo , op ) ;
/* try and revert even if we had an error above */
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2022-05-16 03:29:43 +00:00
ELAPSED2 ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2001-06-03 19:54:05 +00:00
}
2000-10-16 22:08:51 +00:00
2017-08-05 14:09:12 +00:00
2001-06-26 20:55:29 +00:00
/**
2010-02-14 21:47:49 +00:00
* \ brief check availability of scanning functions
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param scan The scan op
2001-06-26 20:55:29 +00:00
*
2010-02-14 21:47:49 +00:00
* Checks if a rig is capable of performing a scan operation .
2001-06-30 12:36:43 +00:00
* Since the \ a scan parameter is an OR ' ed bitmap argument , more than
* one op can be checked at the same time .
2001-06-26 20:55:29 +00:00
*
2017-08-05 14:09:12 +00:00
* EXAMPLE : if ( rig_has_scan ( my_rig , RIG_SCAN_PRIO ) ) disp_SCANprio_btn ( ) ;
2001-06-26 20:55:29 +00:00
*
2001-06-30 12:36:43 +00:00
* \ return a bit map of supported scan settings that can be retrieved ,
* otherwise 0 if none supported .
2001-06-26 20:55:29 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_scan ( )
2001-06-26 20:55:29 +00:00
*/
2004-10-02 10:32:09 +00:00
scan_t HAMLIB_API rig_has_scan ( RIG * rig , scan_t scan )
2001-06-26 20:55:29 +00:00
{
2021-03-18 12:09:58 +00:00
int retcode ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! rig | | ! rig - > caps )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( 0 ) ;
2017-08-05 14:09:12 +00:00
}
2001-06-26 20:55:29 +00:00
2021-03-18 12:09:58 +00:00
retcode = rig - > caps - > scan_ops & scan ;
RETURNFUNC ( retcode ) ;
2001-06-26 20:55:29 +00:00
}
2017-08-05 14:09:12 +00:00
2001-06-26 20:55:29 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief perform Memory / VFO operations
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param scan The scanning operation to perform
* \ param ch Optional channel argument used for the scan .
2001-06-26 20:55:29 +00:00
*
2001-06-30 12:36:43 +00:00
* Performs scanning operation .
* See # scan_t for more information .
2001-06-26 20:55:29 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-06-26 20:55:29 +00:00
*
2001-06-30 12:36:43 +00:00
* \ sa rig_has_scan ( )
2001-06-26 20:55:29 +00:00
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_scan ( RIG * rig , vfo_t vfo , scan_t scan , int ch )
2001-06-26 20:55:29 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
2001-06-26 20:55:29 +00:00
2017-08-05 14:09:12 +00:00
caps = rig - > caps ;
if ( caps - > scan = = NULL
2019-11-30 16:19:08 +00:00
| | ( scan ! = RIG_SCAN_STOP & & ! rig_has_scan ( rig , scan ) ) )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2021-03-18 12:09:58 +00:00
retcode = caps - > scan ( rig , vfo , scan , ch ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-06-26 20:55:29 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-06-26 20:55:29 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-06-26 20:55:29 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-06-26 20:55:29 +00:00
2017-08-05 14:09:12 +00:00
retcode = caps - > scan ( rig , vfo , scan , ch ) ;
/* try and revert even if we had an error above */
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2001-06-26 20:55:29 +00:00
}
2017-08-05 14:09:12 +00:00
2001-03-02 18:41:46 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief send DTMF digits
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param digits Digits to be send
2001-03-02 18:41:46 +00:00
*
2001-06-30 12:36:43 +00:00
* Sends DTMF digits .
* See DTMF change speed , etc . ( TODO ) .
2001-03-02 18:41:46 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-03-02 18:41:46 +00:00
*
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_send_dtmf ( RIG * rig , vfo_t vfo , const char * digits )
2001-03-02 18:41:46 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! digits )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2001-03-02 18:41:46 +00:00
2017-10-05 02:32:08 +00:00
if ( caps - > send_dtmf = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2021-03-18 12:09:58 +00:00
retcode = caps - > send_dtmf ( rig , vfo , digits ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-03-02 18:41:46 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-03-02 18:41:46 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-03-02 18:41:46 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-03-02 18:41:46 +00:00
2017-08-05 14:09:12 +00:00
retcode = caps - > send_dtmf ( rig , vfo , digits ) ;
/* try and revert even if we had an error above */
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2001-03-02 18:41:46 +00:00
}
2017-08-05 14:09:12 +00:00
2001-03-02 18:41:46 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief receive DTMF digits
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param digits Location where the digits are to be stored
* \ param length in : max length of buffer , out : number really read .
2001-03-02 18:41:46 +00:00
*
2001-06-30 12:36:43 +00:00
* Receives DTMF digits ( not blocking ) .
* See DTMF change speed , etc . ( TODO ) .
2001-03-02 18:41:46 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-03-02 18:41:46 +00:00
*
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_recv_dtmf ( RIG * rig , vfo_t vfo , char * digits , int * length )
2001-03-02 18:41:46 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2001-03-02 18:41:46 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! digits | | ! length )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > recv_dtmf = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-03-02 18:41:46 +00:00
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2021-03-18 12:09:58 +00:00
retcode = caps - > recv_dtmf ( rig , vfo , digits , length ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-03-02 18:41:46 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-03-02 18:41:46 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-03-02 18:41:46 +00:00
2017-08-05 14:09:12 +00:00
retcode = caps - > recv_dtmf ( rig , vfo , digits , length ) ;
/* try and revert even if we had an error above */
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2001-03-02 18:41:46 +00:00
}
2017-08-05 14:09:12 +00:00
2001-04-28 12:49:12 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief send morse code
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param msg Message to be sent
2001-04-28 12:49:12 +00:00
*
2001-06-30 12:36:43 +00:00
* Sends morse message .
* See keyer change speed , etc . ( TODO ) .
2001-04-28 12:49:12 +00:00
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2001-06-30 12:36:43 +00:00
* set appropriately ) .
2001-04-28 12:49:12 +00:00
*
*/
2004-10-02 10:32:09 +00:00
int HAMLIB_API rig_send_morse ( RIG * rig , vfo_t vfo , const char * msg )
2001-04-28 12:49:12 +00:00
{
2017-08-05 14:09:12 +00:00
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2017-08-05 14:09:12 +00:00
2021-04-10 12:58:38 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-04-10 12:58:38 +00:00
}
if ( ! msg )
2017-10-05 02:32:08 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2017-08-05 14:09:12 +00:00
}
caps = rig - > caps ;
2017-10-05 02:32:08 +00:00
if ( caps - > send_morse = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-04-28 12:49:12 +00:00
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2017-10-05 02:32:08 +00:00
{
2021-03-18 12:09:58 +00:00
retcode = caps - > send_morse ( rig , vfo , msg ) ;
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-04-28 12:49:12 +00:00
2017-10-05 02:32:08 +00:00
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2017-08-05 14:09:12 +00:00
}
2001-04-28 12:49:12 +00:00
2017-08-05 14:09:12 +00:00
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
2001-04-28 12:49:12 +00:00
2017-10-05 02:32:08 +00:00
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2017-08-05 14:09:12 +00:00
}
2001-04-28 12:49:12 +00:00
2017-08-05 14:09:12 +00:00
retcode = caps - > send_morse ( rig , vfo , msg ) ;
/* try and revert even if we had an error above */
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2017-08-05 14:09:12 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2020-10-16 13:41:57 +00:00
if ( RIG_OK = = retcode )
{
/* return the first error code */
retcode = rc2 ;
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2020-10-16 13:41:57 +00:00
}
/**
* \ brief stop morse code
* \ param rig The rig handle
* \ param vfo The target VFO
*
* Stops the send morse message .
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
2020-10-16 13:41:57 +00:00
* a negative value if an error occurred ( in which case , cause is
* set appropriately ) .
*
*/
int HAMLIB_API rig_stop_morse ( RIG * rig , vfo_t vfo )
{
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2021-09-25 13:59:57 +00:00
2021-09-19 20:12:21 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
RETURNFUNC ( - RIG_EINVAL ) ;
}
2020-10-16 13:41:57 +00:00
caps = rig - > caps ;
if ( caps - > stop_morse = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2020-10-16 13:41:57 +00:00
}
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2020-10-16 13:41:57 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( caps - > stop_morse ( rig , vfo ) ) ;
2020-10-16 13:41:57 +00:00
}
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2020-10-16 13:41:57 +00:00
}
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-10-16 13:41:57 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2020-10-16 13:41:57 +00:00
}
retcode = caps - > stop_morse ( rig , vfo ) ;
/* try and revert even if we had an error above */
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-10-16 13:41:57 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2020-10-18 17:34:36 +00:00
if ( RIG_OK = = retcode )
{
/* return the first error code */
retcode = rc2 ;
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2020-10-18 17:34:36 +00:00
}
/*
* wait_morse_ptt
* generic routine to wait for ptt = 0
* should work on any full breakin CW morse send
* Assumes rig ! = NULL , msg ! = NULL
*/
static int wait_morse_ptt ( RIG * rig , vfo_t vfo )
{
ptt_t pttStatus = RIG_PTT_OFF ;
int loops = 0 ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2020-10-18 17:34:36 +00:00
2020-10-23 16:34:42 +00:00
hl_usleep ( 200 * 1000 ) ; // give little time for CW to start PTT
2020-10-18 17:34:36 +00:00
do
{
2020-10-25 21:30:09 +00:00
int retval ;
2020-10-18 17:34:36 +00:00
rig_debug ( RIG_DEBUG_TRACE , " %s: loop#%d until ptt=0, ptt=%d \n " , __func__ , loops ,
pttStatus ) ;
2020-10-19 17:03:38 +00:00
elapsed_ms ( & rig - > state . cache . time_ptt , HAMLIB_ELAPSED_INVALIDATE ) ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-10-18 17:34:36 +00:00
retval = rig_get_ptt ( rig , vfo , & pttStatus ) ;
if ( retval ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retval ) ;
2020-10-18 17:34:36 +00:00
}
2020-10-23 16:34:42 +00:00
2020-10-19 17:03:38 +00:00
// every 25ms should be short enough
hl_usleep ( 25 * 1000 ) ;
2020-10-18 17:34:36 +00:00
+ + loops ;
}
while ( pttStatus = = RIG_PTT_ON & & loops < = 600 ) ;
2021-01-17 13:25:28 +00:00
RETURNFUNC ( RIG_OK ) ;
2020-10-18 17:34:36 +00:00
}
/**
* \ brief wait morse code
* \ param rig The rig handle
* \ param vfo The target VFO
*
* waits for the end of the morse message to be sent .
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
2020-10-18 17:34:36 +00:00
* a negative value if an error occurred ( in which case , cause is
* set appropriately ) .
*
*/
int HAMLIB_API rig_wait_morse ( RIG * rig , vfo_t vfo )
{
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2021-09-25 13:59:57 +00:00
2021-09-19 20:12:21 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
RETURNFUNC ( - RIG_EINVAL ) ;
}
2020-10-18 17:34:36 +00:00
caps = rig - > caps ;
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2020-10-18 17:34:36 +00:00
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( wait_morse_ptt ( rig , vfo ) ) ;
2020-10-18 17:34:36 +00:00
}
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2020-10-18 17:34:36 +00:00
}
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-10-18 17:34:36 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2020-10-18 17:34:36 +00:00
}
2020-10-19 16:50:02 +00:00
retcode = wait_morse_ptt ( rig , vfo ) ;
2020-10-18 17:34:36 +00:00
/* try and revert even if we had an error above */
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-10-18 17:34:36 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
2005-04-04 18:31:00 +00:00
2017-10-05 02:32:08 +00:00
if ( RIG_OK = = retcode )
{
2017-08-05 14:09:12 +00:00
/* return the first error code */
2020-02-06 00:00:34 +00:00
retcode = rc2 ;
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2020-02-06 00:00:34 +00:00
}
/**
* \ brief send voice memory content
* \ param rig The rig handle
* \ param vfo The target VFO
* \ param ch Voice memory number to be sent
*
* Sends voice memory content .
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* a negative value if an error occurred ( in which case , cause is
2020-02-06 00:00:34 +00:00
* set appropriately ) .
*
*/
int HAMLIB_API rig_send_voice_mem ( RIG * rig , vfo_t vfo , int ch )
{
const struct rig_caps * caps ;
int retcode , rc2 ;
vfo_t curr_vfo ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2020-02-06 00:00:34 +00:00
if CHECK_RIG_ARG ( rig )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2020-02-06 00:00:34 +00:00
}
caps = rig - > caps ;
if ( caps - > send_voice_mem = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2020-02-06 00:00:34 +00:00
}
2021-03-09 06:01:05 +00:00
if ( vfo = = RIG_VFO_CURR
2021-03-15 22:51:22 +00:00
| | vfo = = rig - > state . current_vfo )
2020-02-06 00:00:34 +00:00
{
2021-03-18 12:09:58 +00:00
retcode = caps - > send_voice_mem ( rig , vfo , ch ) ;
RETURNFUNC ( retcode ) ;
2020-02-06 00:00:34 +00:00
}
if ( ! caps - > set_vfo )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2020-02-06 00:00:34 +00:00
}
curr_vfo = rig - > state . current_vfo ;
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-02-06 00:00:34 +00:00
retcode = caps - > set_vfo ( rig , vfo ) ;
if ( retcode ! = RIG_OK )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2020-02-06 00:00:34 +00:00
}
retcode = caps - > send_voice_mem ( rig , vfo , ch ) ;
/* try and revert even if we had an error above */
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2020-02-06 00:00:34 +00:00
rc2 = caps - > set_vfo ( rig , curr_vfo ) ;
if ( RIG_OK = = retcode )
{
/* return the first error code */
2017-08-05 14:09:12 +00:00
retcode = rc2 ;
2014-12-11 17:14:58 +00:00
}
2021-01-17 13:25:28 +00:00
RETURNFUNC ( retcode ) ;
2001-04-28 12:49:12 +00:00
}
2001-03-02 18:41:46 +00:00
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief find the freq_range of freq / mode
2017-08-05 14:09:12 +00:00
* \ param range_list The range list to search from
* \ param freq The frequency that will be part of this range
* \ param mode The mode that will be part of this range
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* Returns a pointer to the # freq_range_t including \ a freq and \ a mode .
* Works for rx and tx range list as well .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2001-06-30 12:36:43 +00:00
* \ return the location of the # freq_range_t if found ,
* otherwise NULL if not found or if \ a range_list is invalid .
* Added "hamlib-doc" source comments, ala kernel-doc,gnome-doc.
See doc/ subdirectory for more info. The work is still in progress,
the current comments are pretty shallow rigth now, they're still
lacking the valuable information like semantics, side effects,
special cases, error definitions, etc. that makes a good API documention.
Please help commenting, fixing typos and mispellings!
* renamed rig_*_rpt_* functions to rig_*_rptr_* to be more uniform
* made use of setting_t type in *_has_* functions
* removed set_volume, get_volume, set_squelch, get_squelch,
get_squelch_status, set_ant, get_ant, int et_att, get_att,
set_preamp, get_preamp, set_power, and get_power
in favor of set_level/get_level.
* set_func takes one more arg for the status (activate or desactivate)
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@234 7ae35d74-ebe9-4afe-98af-79ac388436b8
2000-10-22 16:08:23 +00:00
*
2000-10-01 12:29:12 +00:00
*/
2020-03-05 14:44:18 +00:00
const freq_range_t * HAMLIB_API rig_get_range ( const freq_range_t * range_list ,
2019-11-30 16:19:08 +00:00
freq_t freq ,
rmode_t mode )
2000-10-01 12:29:12 +00:00
{
2017-08-05 14:09:12 +00:00
int i ;
2021-09-19 20:12:21 +00:00
if ( ! range_list )
{
2021-11-29 22:08:24 +00:00
return ( NULL ) ;
2021-09-19 20:12:21 +00:00
}
2021-03-06 18:37:53 +00:00
for ( i = 0 ; i < HAMLIB_FRQRANGESIZ ; i + + )
2017-10-05 02:32:08 +00:00
{
2019-08-18 04:20:48 +00:00
if ( range_list [ i ] . startf = = 0 & & range_list [ i ] . endf = = 0 )
2017-10-05 02:32:08 +00:00
{
2021-03-15 22:51:22 +00:00
return ( NULL ) ;
2017-08-05 14:09:12 +00:00
}
2019-08-18 04:20:48 +00:00
if ( freq > = range_list [ i ] . startf & & freq < = range_list [ i ] . endf & &
2017-10-05 02:32:08 +00:00
( range_list [ i ] . modes & mode ) )
{
2019-12-24 21:47:06 +00:00
const freq_range_t * f = & range_list [ i ] ;
2021-03-15 22:51:22 +00:00
return ( f ) ;
2017-08-05 14:09:12 +00:00
}
}
2021-03-15 22:51:22 +00:00
return ( NULL ) ;
2000-10-01 12:29:12 +00:00
}
2020-05-27 17:21:41 +00:00
/**
* \ brief set the vfo option for rigctld
* \ param status 1 = On , 0 = Off
*
* Returns RIG_OK or - RIG_EPROTO ;
*
*/
int HAMLIB_API rig_set_vfo_opt ( RIG * rig , int status )
{
2021-03-18 12:09:58 +00:00
int retcode ;
2021-01-17 13:25:28 +00:00
ENTERFUNC ;
2021-09-25 13:59:57 +00:00
ELAPSED1 ;
2020-05-27 17:21:41 +00:00
2021-09-19 20:12:21 +00:00
if CHECK_RIG_ARG ( rig )
{
RETURNFUNC ( - RIG_EINVAL ) ;
}
2020-05-27 17:21:41 +00:00
if ( rig - > caps - > set_vfo_opt = = NULL )
{
2021-01-17 13:25:28 +00:00
RETURNFUNC ( - RIG_ENAVAIL ) ;
2020-05-27 17:21:41 +00:00
}
2020-05-27 17:23:08 +00:00
2021-03-18 12:09:58 +00:00
retcode = rig - > caps - > set_vfo_opt ( rig , status ) ;
2021-09-25 13:59:57 +00:00
ELAPSED2 ;
2021-03-18 12:09:58 +00:00
RETURNFUNC ( retcode ) ;
2020-05-27 17:21:41 +00:00
}
2000-10-10 22:11:48 +00:00
2000-11-28 22:33:37 +00:00
/**
2001-06-30 12:36:43 +00:00
* \ brief get general information from the radio
2017-08-05 14:09:12 +00:00
* \ param rig The rig handle
2000-11-28 22:33:37 +00:00
*
2001-06-30 12:36:43 +00:00
* Retrieves some general information from the radio .
2010-02-14 21:47:49 +00:00
* This can include firmware revision , exact model name , or just nothing .
2000-11-28 22:33:37 +00:00
*
2021-09-09 20:42:55 +00:00
* \ return a pointer to memory containing the ASCIIZ string
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
* if the operation has been successful , otherwise NULL if an error occurred
2021-09-09 20:42:55 +00:00
* or if get_info is not part of the capabilities .
2000-11-28 22:33:37 +00:00
*/
2019-11-30 16:19:08 +00:00
const char * HAMLIB_API rig_get_info ( RIG * rig )
2000-11-28 22:33:37 +00:00
{
2017-10-05 02:32:08 +00:00
if ( CHECK_RIG_ARG ( rig ) )
{
2021-03-15 22:51:22 +00:00
return ( NULL ) ;
2017-08-05 14:09:12 +00:00
}
2000-11-28 22:33:37 +00:00
2017-10-05 02:32:08 +00:00
if ( rig - > caps - > get_info = = NULL )
{
2021-03-15 22:51:22 +00:00
return ( NULL ) ;
2017-08-05 14:09:12 +00:00
}
2001-01-05 18:24:20 +00:00
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-15 22:51:22 +00:00
return ( rig - > caps - > get_info ( rig ) ) ;
2000-11-28 22:33:37 +00:00
}
2021-04-30 12:37:07 +00:00
2021-09-09 20:47:57 +00:00
static void make_crc_table ( unsigned long crcTable [ ] )
2021-04-30 12:37:07 +00:00
{
unsigned long POLYNOMIAL = 0xEDB88320 ;
unsigned char b = 0 ;
do
{
// Start with the data byte
2021-09-13 22:41:53 +00:00
unsigned long remainder = b ;
2021-04-30 12:37:07 +00:00
2021-06-16 15:11:45 +00:00
unsigned long bit ;
2021-08-26 11:49:24 +00:00
2021-06-16 15:11:45 +00:00
for ( bit = 8 ; bit > 0 ; - - bit )
2021-04-30 12:37:07 +00:00
{
if ( remainder & 1 )
{
remainder = ( remainder > > 1 ) ^ POLYNOMIAL ;
}
else
{
remainder = ( remainder > > 1 ) ;
}
}
crcTable [ ( size_t ) b ] = remainder ;
}
while ( 0 ! = + + b ) ;
}
static unsigned long crcTable [ 256 ] ;
2021-09-09 20:47:57 +00:00
static unsigned long gen_crc ( unsigned char * p , size_t n )
2021-04-30 12:37:07 +00:00
{
unsigned long crc = 0xfffffffful ;
size_t i ;
if ( crcTable [ 0 ] = = 0 ) { make_crc_table ( crcTable ) ; }
for ( i = 0 ; i < n ; i + + )
{
crc = crcTable [ * p + + ^ ( crc & 0xff ) ] ^ ( crc > > 8 ) ;
}
return ( ( ~ crc ) & 0xffffffff ) ;
}
2021-04-27 15:32:12 +00:00
/**
* \ brief get freq / mode / width for requested VFO
* \ param rig The rig handle
*
* returns a string for all known VFOs plus rig split status and satellite mode status
*/
int HAMLIB_API rig_get_rig_info ( RIG * rig , char * response , int max_response_len )
{
2021-04-29 22:23:37 +00:00
vfo_t vfoA , vfoB ;
freq_t freqA , freqB ;
rmode_t modeA , modeB ;
2021-04-28 11:44:10 +00:00
char * modeAstr , * modeBstr ;
2021-04-29 22:23:37 +00:00
pbwidth_t widthA , widthB ;
2021-04-27 15:32:12 +00:00
split_t split ;
int satmode ;
2021-04-27 16:51:43 +00:00
int ret ;
int rxa , txa , rxb , txb ;
2021-04-27 15:32:12 +00:00
response [ 0 ] = 0 ;
2021-04-27 16:51:43 +00:00
2021-09-19 20:12:21 +00:00
if ( CHECK_RIG_ARG ( rig ) | | ! response )
{
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( - RIG_EINVAL ) ;
2021-09-19 20:12:21 +00:00
}
2021-09-25 13:59:57 +00:00
ELAPSED1 ;
2021-08-03 04:37:31 +00:00
vfoA = vfo_fixup ( rig , RIG_VFO_A , rig - > state . cache . split ) ;
vfoB = vfo_fixup ( rig , RIG_VFO_B , rig - > state . cache . split ) ;
2021-04-29 22:23:37 +00:00
ret = rig_get_vfo_info ( rig , vfoA , & freqA , & modeA , & widthA , & split , & satmode ) ;
2022-02-03 05:48:42 +00:00
if ( ret ! = RIG_OK ) { RETURNFUNC2 ( ret ) ; }
2021-04-29 22:23:37 +00:00
2021-11-30 07:25:51 +00:00
// we need both vfo and mode targetable to avoid vfo swapping
2021-04-29 22:23:37 +00:00
if ( ( rig - > caps - > targetable_vfo & RIG_TARGETABLE_FREQ )
& & ( rig - > caps - > targetable_vfo & RIG_TARGETABLE_MODE ) )
2021-04-27 22:32:10 +00:00
{
2021-04-29 22:23:37 +00:00
ret = rig_get_vfo_info ( rig , vfoB , & freqB , & modeB , & widthB , & split , & satmode ) ;
2022-02-03 05:48:42 +00:00
if ( ret ! = RIG_OK ) { RETURNFUNC2 ( ret ) ; }
2021-04-27 22:32:10 +00:00
}
else
{
// we'll use cached info instead of doing the vfo swapping
int cache_ms_freq , cache_ms_mode , cache_ms_width ;
2021-04-29 22:23:37 +00:00
rig_get_cache ( rig , vfoB , & freqB , & cache_ms_freq , & modeB , & cache_ms_mode ,
& widthB ,
2021-04-27 22:32:10 +00:00
& cache_ms_width ) ;
}
2021-04-29 22:23:37 +00:00
modeAstr = ( char * ) rig_strrmode ( modeA ) ;
modeBstr = ( char * ) rig_strrmode ( modeB ) ;
if ( modeAstr [ 0 ] = = 0 ) { modeAstr = " None " ; }
if ( modeBstr [ 0 ] = = 0 ) { modeBstr = " None " ; }
2021-04-27 16:51:43 +00:00
rxa = 1 ;
txa = split = = 0 ;
rxb = ! rxa ;
txb = split = = 1 ;
2022-02-05 21:27:43 +00:00
SNPRINTF ( response , max_response_len - strlen ( " CRC=0x00000000 \n " ) ,
2022-01-18 20:39:34 +00:00
" VFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d \n VFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d \n Split=%d SatMode=%d \n Rig=%s \n App=Hamlib \n Version=20210506 1.0.0 \n " ,
2021-04-29 22:23:37 +00:00
rig_strvfo ( vfoA ) , freqA , modeAstr , ( int ) widthA , rxa , txa , rig_strvfo ( vfoB ) ,
2021-04-30 12:37:07 +00:00
freqB , modeBstr , ( int ) widthB , rxb , txb , split , satmode , rig - > caps - > model_name ) ;
unsigned long crc = gen_crc ( ( unsigned char * ) response , strlen ( response ) ) ;
2022-01-18 20:39:34 +00:00
char tmpstr [ 32 ] ;
SNPRINTF ( tmpstr , sizeof ( tmpstr ) , " CRC=0x%08lx \n " , crc ) ;
2022-02-05 21:27:43 +00:00
strcat ( response , tmpstr ) ;
2021-05-21 04:34:48 +00:00
2021-05-26 14:30:02 +00:00
if ( strlen ( response ) > = max_response_len - 1 )
2021-05-26 14:05:38 +00:00
{
2021-05-26 14:30:02 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s(%d): response len exceeded max %d chars \n " ,
__FILE__ , __LINE__ , max_response_len ) ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( RIG_EINTERNAL ) ;
2021-05-26 14:05:38 +00:00
}
2021-05-26 14:30:02 +00:00
2021-09-25 13:59:57 +00:00
ELAPSED2 ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( RIG_OK ) ;
2021-04-27 15:32:12 +00:00
}
2021-02-07 18:45:59 +00:00
/**
* \ brief get freq / mode / width for requested VFO
* \ param rig The rig handle
* \ param vfo The VFO to get
2021-02-07 20:58:33 +00:00
* \ param * freq frequency answer
* \ param * mode mode answer
* \ param * width bandwidth answer
2021-02-07 18:45:59 +00:00
*
* Gets the current VFO information . The VFO can be RIG_VFO_A , RIG_VFO_B , RIG_VFO_C
* for VFOA , VFOB , VFOC respectively or RIG_VFO_MEM for Memory mode .
* Supported VFOs depends on rig capabilities .
*
2021-09-08 20:45:36 +00:00
* \ return RIG_OK if the operation has been successful , otherwise
2021-02-07 18:45:59 +00:00
* a negative value if an error occurred ( in which case use rigerror ( return )
* for error message ) .
*
*/
2021-02-28 15:46:01 +00:00
int HAMLIB_API rig_get_vfo_info ( RIG * rig , vfo_t vfo , freq_t * freq ,
2021-04-27 15:32:12 +00:00
rmode_t * mode , pbwidth_t * width , split_t * split , int * satmode )
2021-02-07 18:45:59 +00:00
{
2021-03-02 19:02:13 +00:00
int retval ;
2021-11-10 05:14:44 +00:00
ELAPSED1 ;
2021-02-07 18:45:59 +00:00
ENTERFUNC ;
rig_debug ( RIG_DEBUG_VERBOSE , " %s called vfo=%s \n " , __func__ , rig_strvfo ( vfo ) ) ;
if ( CHECK_RIG_ARG ( rig ) )
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-02-07 18:45:59 +00:00
}
2021-03-26 15:51:00 +00:00
//if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; }
2021-02-28 15:46:01 +00:00
2021-08-03 04:37:31 +00:00
vfo = vfo_fixup ( rig , vfo , rig - > state . cache . split ) ;
2021-03-15 22:51:22 +00:00
// we can't use the cached values as some clients may only call this function
2021-03-02 19:02:13 +00:00
// like Log4OM which mostly does polling
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-02 19:02:13 +00:00
retval = rig_get_freq ( rig , vfo , freq ) ;
2021-03-15 22:51:22 +00:00
if ( retval ! = RIG_OK ) { RETURNFUNC ( retval ) ; }
2021-03-02 17:11:12 +00:00
2021-04-05 16:46:58 +00:00
// we will ask for other vfo mode just once if not targetable
2021-04-06 16:40:02 +00:00
int allTheTimeA = vfo & ( RIG_VFO_A | RIG_VFO_CURR | RIG_VFO_MAIN_A |
RIG_VFO_SUB_A ) ;
int allTheTimeB = ( vfo & ( RIG_VFO_B | RIG_VFO_SUB ) )
& & ( rig - > caps - > targetable_vfo & RIG_TARGETABLE_MODE ) ;
int justOnceB = ( vfo & ( RIG_VFO_B | RIG_VFO_SUB ) )
& & ( rig - > state . cache . modeMainB = = RIG_MODE_NONE ) ;
2021-04-05 16:46:58 +00:00
if ( allTheTimeA | | allTheTimeB | | justOnceB )
2021-04-02 13:03:13 +00:00
{
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-04-02 13:03:13 +00:00
retval = rig_get_mode ( rig , vfo , mode , width ) ;
2021-03-15 22:51:22 +00:00
2021-04-02 13:03:13 +00:00
if ( retval ! = RIG_OK ) { RETURNFUNC ( retval ) ; }
}
else // we'll just us VFOA so we don't swap vfos -- freq is what's important
{
* mode = rig - > state . cache . modeMainA ;
* width = rig - > state . cache . widthMainA ;
}
2021-02-28 15:46:01 +00:00
2021-04-27 15:32:12 +00:00
* satmode = rig - > state . cache . satmode ;
2021-03-26 15:51:00 +00:00
// we should only need to ask for VFO_CURR to minimize display swapping
2022-07-04 12:26:30 +00:00
HAMLIB_TRACE ;
2021-03-26 15:51:00 +00:00
retval = rig_get_split ( rig , RIG_VFO_CURR , split ) ;
2021-03-15 22:51:22 +00:00
if ( retval ! = RIG_OK ) { RETURNFUNC ( retval ) ; }
2021-03-01 20:56:21 +00:00
2021-11-10 05:14:44 +00:00
ELAPSED2 ;
2021-03-02 14:36:37 +00:00
RETURNFUNC ( RIG_OK ) ;
2021-02-07 18:45:59 +00:00
}
2017-08-05 14:09:12 +00:00
2021-02-10 23:30:46 +00:00
/**
2021-02-28 15:46:01 +00:00
* \ brief get list of available vfos
2021-02-10 23:30:46 +00:00
* \ param rig The rig handle
2021-03-03 14:03:18 +00:00
* \ param char * char buffer [ SPRINTF_MAX_SIZE ] to hold result
* \ param len max length of char buffer
2021-02-10 23:30:46 +00:00
*
* Retrieves all usable vfo entries for the rig
*
* \ return a pointer to a string , e . g . " VFOA VFOB Mem "
* if the operation has been successful , otherwise NULL if an error occurred
*/
2021-03-03 14:03:18 +00:00
int HAMLIB_API rig_get_vfo_list ( RIG * rig , char * buf , int buflen )
2021-02-10 23:30:46 +00:00
{
ENTERFUNC ;
2022-02-25 13:41:10 +00:00
if ( CHECK_RIG_CAPS ( rig ) )
2021-02-10 23:30:46 +00:00
{
2021-09-19 20:18:03 +00:00
RETURNFUNC ( - RIG_EINVAL ) ;
2021-02-10 23:30:46 +00:00
}
2021-03-09 05:42:35 +00:00
rig_sprintf_vfo ( buf , buflen - 1 , rig - > state . vfo_list ) ;
2021-03-03 14:03:18 +00:00
RETURNFUNC ( RIG_OK ) ;
2021-02-10 23:30:46 +00:00
}
2021-12-01 17:50:33 +00:00
/**
* \ brief set the rig ' s clock
*
*/
int HAMLIB_API rig_set_clock ( RIG * rig , int year , int month , int day , int hour ,
int min , int sec , double msec , int utc_offset )
{
if ( rig - > caps - > set_clock = = NULL )
{
return - RIG_ENIMPL ;
}
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( rig - > caps - > set_clock ( rig , year , month , day , hour , min , sec ,
2022-02-05 21:27:43 +00:00
msec , utc_offset ) ) ;
2021-12-01 17:50:33 +00:00
}
/**
* \ brief get the rig ' s clock
*
*/
int HAMLIB_API rig_get_clock ( RIG * rig , int * year , int * month , int * day ,
int * hour ,
int * min , int * sec , double * msec , int * utc_offset )
{
int retval ;
if ( rig - > caps - > get_clock = = NULL )
{
return - RIG_ENIMPL ;
}
retval = rig - > caps - > get_clock ( rig , year , month , day , hour , min , sec ,
msec , utc_offset ) ;
2022-02-03 05:48:42 +00:00
RETURNFUNC2 ( retval ) ;
2021-12-01 17:50:33 +00:00
}
2020-04-09 22:56:19 +00:00
/**
* \ brief get the Hamlib license
*
*/
2019-11-30 16:19:08 +00:00
const char * HAMLIB_API rig_license ( )
2016-08-31 14:05:47 +00:00
{
2017-08-05 14:09:12 +00:00
return hamlib_license ;
2016-08-31 14:05:47 +00:00
}
2017-08-05 14:09:12 +00:00
2020-04-09 22:56:19 +00:00
/**
* \ brief get the Hamlib version
*
*/
2019-11-30 16:19:08 +00:00
const char * HAMLIB_API rig_version ( )
2016-08-31 14:05:47 +00:00
{
2017-08-05 14:09:12 +00:00
return hamlib_version2 ;
2016-08-31 14:05:47 +00:00
}
2017-08-05 14:09:12 +00:00
2020-04-09 22:56:19 +00:00
/**
* \ brief get the Hamlib copyright
*
*/
2019-11-30 16:19:08 +00:00
const char * HAMLIB_API rig_copyright ( )
2016-08-31 14:05:47 +00:00
{
2017-08-05 14:09:12 +00:00
return hamlib_copyright2 ;
2016-08-31 14:05:47 +00:00
}
2021-05-21 04:34:48 +00:00
/**
* \ brief get a cookie to grab rig control
2021-09-19 20:52:41 +00:00
* \ param rig Not used
* \ param cookie_cmd The command to execute on \ a cookie .
* \ param cookie The cookie to operate on , cannot be NULL or RIG_EINVAL will be returned .
* \ param cookie_len The length of the cookie , must be # HAMLIB_COOKIE_SIZE or larger .
*
* # RIG_COOKIE_GET will set \ a cookie with a cookie .
* # RIG_COOKIE_RENEW will update the timeout with 1 second .
* # RIG_COOKIE_RELEASE will release the cookie and allow a new one to be grabbed .
2021-05-21 04:34:48 +00:00
*
2021-05-21 20:39:41 +00:00
* Cookies should only be used when needed to keep commands sequenced correctly
* For example , when setting both VFOA and VFOB frequency and mode
* Example to wait for cookie , do rig commands , and release
2021-09-19 20:52:41 +00:00
* \ code
* while ( ( rig_cookie ( NULL , RIG_COOKIE_GET , cookie , sizeof ( cookie ) ) ) ! = RIG_OK )
* hl_usleep ( 10 * 1000 ) ;
*
* //Pseudo code
* set_freq A ; set mode A ; set freq B ; set modeB ;
*
* rig_cookie ( NULL , RIG_COOKIE_RELEASE , cookie , sizeof ( cookie ) ) ) ;
* \ endcode
2021-05-21 04:34:48 +00:00
*/
2021-05-21 20:39:41 +00:00
int HAMLIB_API rig_cookie ( RIG * rig , enum cookie_e cookie_cmd , char * cookie ,
int cookie_len )
2021-05-21 04:34:48 +00:00
{
2021-05-21 20:39:41 +00:00
// only 1 client can have the cookie so these can be static
Fix spelling errors
Fixed with:
codespell --summary --skip=.git,extra,,lib,macros,security --ignore-words-list="ans,ba,cant,develope,fo,get's,nin,numer,parm,parms,setts,som,statics,ths,ue,vektor,objext" --write-changes --interactive=2
and manual editing.
2022-07-07 19:25:58 +00:00
// this should also prevent problems with DLLs & shared libraries
2021-05-21 20:39:41 +00:00
// the debug_msg is another non-thread-safe which this will help fix
2021-05-26 14:30:02 +00:00
static char
2021-09-20 20:10:55 +00:00
cookie_save [ HAMLIB_COOKIE_SIZE ] ; // only one client can have the cookie
2021-05-21 20:39:41 +00:00
static double time_last_used ;
2021-05-21 04:34:48 +00:00
struct timespec tp ;
2021-09-20 20:10:55 +00:00
int ret ;
2021-09-29 03:57:35 +00:00
MUTEX ( mutex_rig_cookie ) ;
2021-05-21 04:34:48 +00:00
2021-09-20 20:10:55 +00:00
/* This is not needed for RIG_COOKIE_RELEASE but keep it simple. */
2021-09-19 20:52:41 +00:00
if ( cookie_len < HAMLIB_COOKIE_SIZE )
2021-05-21 04:34:48 +00:00
{
2021-09-19 20:52:41 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s(%d): cookie_len < %d \n " ,
__FILE__ , __LINE__ , HAMLIB_COOKIE_SIZE ) ;
return - RIG_EINVAL ;
}
if ( ! cookie )
{
rig_debug ( RIG_DEBUG_ERR , " %s(%d): cookie == NULL \n " ,
2021-09-25 13:59:57 +00:00
__FILE__ , __LINE__ ) ;
2021-09-19 20:52:41 +00:00
return - RIG_EINVAL ; // nothing to do
2021-05-21 04:34:48 +00:00
}
2021-05-21 20:39:41 +00:00
Fix spelling errors
Fixed with:
codespell --summary --skip=.git,extra,,lib,macros,security --ignore-words-list="ans,ba,cant,develope,fo,get's,nin,numer,parm,parms,setts,som,statics,ths,ue,vektor,objext" --write-changes --interactive=2
and manual editing.
2022-07-07 19:25:58 +00:00
/* Accessing cookie_save and time_last_used must be done with lock held.
2021-09-20 20:10:55 +00:00
* So keep code simple and lock it during the whole operation . */
2021-09-29 03:57:35 +00:00
MUTEX_LOCK ( mutex_rig_cookie ) ;
2021-09-20 20:10:55 +00:00
2021-05-21 20:39:41 +00:00
switch ( cookie_cmd )
2021-05-21 04:34:48 +00:00
{
2021-05-21 20:39:41 +00:00
case RIG_COOKIE_RELEASE :
2021-05-26 14:30:02 +00:00
if ( cookie_save [ 0 ] ! = 0
& & strcmp ( cookie , cookie_save ) = = 0 ) // matching cookie so we'll clear it
2021-05-21 20:39:41 +00:00
{
2021-09-19 20:52:41 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): %s cookie released \n " ,
2021-05-21 20:39:41 +00:00
__FILE__ , __LINE__ , cookie_save ) ;
memset ( cookie_save , 0 , sizeof ( cookie_save ) ) ;
2021-09-20 20:10:55 +00:00
ret = RIG_OK ;
2021-05-21 20:39:41 +00:00
}
else // not the right cookie!!
{
rig_debug ( RIG_DEBUG_ERR ,
" %s(%d): %s can't release cookie as cookie %s is active \n " , __FILE__ , __LINE__ ,
cookie , cookie_save ) ;
2021-09-20 20:10:55 +00:00
ret = - RIG_BUSBUSY ;
2021-05-21 20:39:41 +00:00
}
break ;
case RIG_COOKIE_RENEW :
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): %s comparing renew request to %s==%d \n " ,
__FILE__ , __LINE__ , cookie , cookie_save , strcmp ( cookie , cookie_save ) ) ;
2021-05-26 14:30:02 +00:00
if ( cookie_save [ 0 ] ! = 0
& & strcmp ( cookie , cookie_save ) = = 0 ) // matching cookie so we'll renew it
2021-05-21 20:39:41 +00:00
{
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d) %s renew request granted \n " , __FILE__ ,
__LINE__ , cookie ) ;
clock_gettime ( CLOCK_REALTIME , & tp ) ;
time_last_used = tp . tv_sec + tp . tv_nsec / 1e9 ;
2021-09-20 20:10:55 +00:00
ret = RIG_OK ;
}
else
{
rig_debug ( RIG_DEBUG_ERR ,
2021-09-25 13:59:57 +00:00
" %s(%d): %s renew request refused %s is active \n " ,
__FILE__ , __LINE__ , cookie , cookie_save ) ;
2021-09-20 20:10:55 +00:00
ret = - RIG_EINVAL ; // wrong cookie
2021-05-21 20:39:41 +00:00
}
break ;
case RIG_COOKIE_GET :
2021-05-31 14:05:41 +00:00
2021-05-21 20:39:41 +00:00
// the way we expire cookies is if somebody else asks for one and the last renewal is > 1 second ago
// a polite client will have released the cookie
// we are just allow for a crashed client that fails to release:q
2021-05-31 14:05:41 +00:00
2021-05-21 04:34:48 +00:00
clock_gettime ( CLOCK_REALTIME , & tp ) ;
2021-09-20 20:10:55 +00:00
double time_curr = tp . tv_sec + tp . tv_nsec / 1e9 ;
2021-05-31 14:05:41 +00:00
2021-05-21 22:04:09 +00:00
if ( cookie_save [ 0 ] ! = 0 & & ( strcmp ( cookie_save , cookie ) = = 0 )
2021-05-21 20:39:41 +00:00
& & ( time_curr - time_last_used < 1 ) ) // then we will deny the request
2021-05-21 04:34:48 +00:00
{
2021-05-21 20:39:41 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s(%d): %s cookie is in use \n " , __FILE__ , __LINE__ ,
cookie_save ) ;
2021-09-20 20:10:55 +00:00
ret = - RIG_BUSBUSY ;
2021-05-21 04:34:48 +00:00
}
2021-09-20 20:10:55 +00:00
else
2021-05-21 04:34:48 +00:00
{
2021-09-20 20:10:55 +00:00
if ( cookie_save [ 0 ] ! = 0 )
{
rig_debug ( RIG_DEBUG_ERR ,
2021-09-25 13:59:57 +00:00
" %s(%d): %s cookie has expired after %.3f seconds....overriding with new cookie \n " ,
__FILE__ , __LINE__ , cookie_save , time_curr - time_last_used ) ;
2021-09-20 20:10:55 +00:00
}
2021-12-06 16:23:18 +00:00
date_strget ( cookie , cookie_len , 0 ) ;
2021-09-20 20:10:55 +00:00
size_t len = strlen ( cookie ) ;
// add on our random number to ensure uniqueness
// The cookie should never be longer then HAMLIB_COOKIE_SIZE
2022-01-19 15:11:04 +00:00
SNPRINTF ( cookie + len , HAMLIB_COOKIE_SIZE - len , " %d \n " , rand ( ) ) ;
2021-09-20 20:10:55 +00:00
strcpy ( cookie_save , cookie ) ;
time_last_used = time_curr ;
rig_debug ( RIG_DEBUG_VERBOSE , " %s(%d): %s new cookie request granted \n " ,
2021-09-25 13:59:57 +00:00
__FILE__ , __LINE__ , cookie_save ) ;
2021-09-20 20:10:55 +00:00
ret = RIG_OK ;
2021-05-21 04:34:48 +00:00
}
2021-09-25 13:59:57 +00:00
2021-09-20 20:10:55 +00:00
break ;
2021-05-21 04:34:48 +00:00
2021-09-20 20:10:55 +00:00
default :
rig_debug ( RIG_DEBUG_ERR , " %s(%d): unknown cmd!! \n ' " , __FILE__ , __LINE__ ) ;
ret = - RIG_EPROTO ;
2021-05-21 20:39:41 +00:00
break ;
2021-05-21 04:34:48 +00:00
}
2021-09-29 03:57:35 +00:00
MUTEX_UNLOCK ( mutex_rig_cookie ) ;
2021-09-20 20:10:55 +00:00
return ret ;
2021-05-21 04:34:48 +00:00
}
2021-05-31 14:05:41 +00:00
HAMLIB_EXPORT ( void ) sync_callback ( int lock )
{
# ifdef HAVE_PTHREAD
static pthread_mutex_t client_lock = PTHREAD_MUTEX_INITIALIZER ;
if ( lock )
{
pthread_mutex_lock ( & client_lock ) ;
rig_debug ( RIG_DEBUG_VERBOSE , " %s: client lock engaged \n " , __func__ ) ;
}
else
{
rig_debug ( RIG_DEBUG_VERBOSE , " %s: client lock disengaged \n " , __func__ ) ;
pthread_mutex_unlock ( & client_lock ) ;
}
# endif
}
2021-05-21 04:34:48 +00:00
2006-10-15 00:27:52 +00:00
/*! @} */
2021-05-31 14:05:41 +00:00
2021-11-20 19:33:29 +00:00
# ifdef HAVE_PTHREAD
# define MAX_FRAME_LENGTH 1024
2021-11-28 18:52:29 +00:00
static int async_data_handler_start ( RIG * rig )
{
struct rig_state * rs = & rig - > state ;
async_data_handler_priv_data * async_data_handler_priv ;
ENTERFUNC ;
2022-01-05 17:12:43 +00:00
if ( ! rs - > async_data_enabled )
{
rig_debug ( RIG_DEBUG_TRACE , " %s: async data support disabled \n " , __func__ ) ;
RETURNFUNC ( RIG_OK ) ;
}
2021-11-28 18:52:29 +00:00
# ifdef HAVE_PTHREAD
2022-01-01 05:49:29 +00:00
2022-01-05 17:12:43 +00:00
rs - > async_data_handler_thread_run = 1 ;
rs - > async_data_handler_priv_data = calloc ( 1 ,
sizeof ( async_data_handler_priv_data ) ) ;
2022-01-01 05:49:29 +00:00
2022-01-05 17:12:43 +00:00
if ( rs - > async_data_handler_priv_data = = NULL )
{
RETURNFUNC ( - RIG_ENOMEM ) ;
}
2021-11-28 18:52:29 +00:00
2022-01-05 17:12:43 +00:00
async_data_handler_priv = ( async_data_handler_priv_data * )
rs - > async_data_handler_priv_data ;
async_data_handler_priv - > args . rig = rig ;
int err = pthread_create ( & async_data_handler_priv - > thread_id , NULL ,
async_data_handler , & async_data_handler_priv - > args ) ;
2021-11-28 18:52:29 +00:00
2022-01-05 17:12:43 +00:00
if ( err )
{
2022-02-05 21:27:43 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: pthread_create error: %s \n " , __func__ ,
strerror ( errno ) ) ;
2022-01-05 17:12:43 +00:00
RETURNFUNC ( - RIG_EINTERNAL ) ;
2021-11-28 18:52:29 +00:00
}
2022-01-01 05:49:29 +00:00
2022-01-28 15:55:48 +00:00
# endif // HAVE_PTHREAD
2021-11-28 18:52:29 +00:00
RETURNFUNC ( RIG_OK ) ;
}
static int async_data_handler_stop ( RIG * rig )
{
struct rig_state * rs = & rig - > state ;
async_data_handler_priv_data * async_data_handler_priv ;
ENTERFUNC ;
# ifdef HAVE_PTHREAD
rs - > async_data_handler_thread_run = 0 ;
2022-01-01 05:49:29 +00:00
async_data_handler_priv = ( async_data_handler_priv_data * )
rs - > async_data_handler_priv_data ;
2021-11-28 18:52:29 +00:00
if ( async_data_handler_priv ! = NULL )
{
if ( async_data_handler_priv - > thread_id ! = 0 )
{
int err = pthread_join ( async_data_handler_priv - > thread_id , NULL ) ;
if ( err )
{
2022-02-05 21:27:43 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: pthread_join error: %s \n " , __func__ ,
strerror ( errno ) ) ;
2021-11-28 18:52:29 +00:00
// just ignore the error
}
async_data_handler_priv - > thread_id = 0 ;
}
free ( rs - > async_data_handler_priv_data ) ;
rs - > async_data_handler_priv_data = NULL ;
}
2022-01-01 05:49:29 +00:00
2021-11-28 18:52:29 +00:00
# endif
RETURNFUNC ( RIG_OK ) ;
}
2021-11-20 19:33:29 +00:00
void * async_data_handler ( void * arg )
{
2022-01-01 05:49:29 +00:00
struct async_data_handler_args_s * args = ( struct async_data_handler_args_s * )
arg ;
2021-11-20 19:33:29 +00:00
RIG * rig = args - > rig ;
2021-12-27 04:24:09 +00:00
unsigned char frame [ MAX_FRAME_LENGTH ] ;
2021-11-20 19:33:29 +00:00
struct rig_state * rs = & rig - > state ;
int result ;
2022-02-05 21:27:43 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s: Starting async data handler thread \n " ,
__func__ ) ;
2021-11-20 19:33:29 +00:00
2021-11-28 18:52:29 +00:00
// TODO: check how to enable "transceive" on recent Kenwood/Yaesu rigs
// 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
while ( rs - > async_data_handler_thread_run )
2021-11-20 19:33:29 +00:00
{
int frame_length ;
int async_frame ;
result = rig - > caps - > read_frame_direct ( rig , sizeof ( frame ) , frame ) ;
2022-01-01 05:49:29 +00:00
2021-11-20 19:33:29 +00:00
if ( result < 0 )
{
2022-01-22 21:19:07 +00:00
// Timeouts occur always if there is nothing to receive, so they are not really errors in this case
2021-11-28 18:52:29 +00:00
if ( result ! = - RIG_ETIMEOUT )
{
2022-01-22 21:19:07 +00:00
// TODO: it may be necessary to have mutex locking on transaction_active flag
if ( rs - > transaction_active )
{
unsigned char data = ( unsigned char ) result ;
2022-01-25 23:41:26 +00:00
write_block_sync_error ( & rs - > rigport , & data , 1 ) ;
2022-01-22 21:19:07 +00:00
}
2021-11-28 18:52:29 +00:00
// TODO: error handling -> store errors in rig state -> to be exposed in async snapshot packets
2022-01-01 05:49:29 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: read_frame_direct() failed, result=%d \n " ,
__func__ , result ) ;
2021-11-28 18:52:29 +00:00
hl_usleep ( 500 * 1000 ) ;
}
2022-01-01 05:49:29 +00:00
2021-11-20 19:33:29 +00:00
continue ;
}
frame_length = result ;
async_frame = rig - > caps - > is_async_frame ( rig , frame_length , frame ) ;
2022-01-01 05:49:29 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s: received frame: len=%d async=%d \n " , __func__ ,
frame_length , async_frame ) ;
2021-11-20 19:33:29 +00:00
if ( async_frame )
{
result = rig - > caps - > process_async_frame ( rig , frame_length , frame ) ;
2022-01-01 05:49:29 +00:00
2021-11-20 19:33:29 +00:00
if ( result < 0 )
{
2021-11-28 18:52:29 +00:00
// TODO: error handling -> store errors in rig state -> to be exposed in async snapshot packets
2022-01-01 05:49:29 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: process_async_frame() failed, result=%d \n " ,
__func__ , result ) ;
2021-11-20 19:33:29 +00:00
continue ;
}
}
else
{
2022-01-25 23:41:26 +00:00
result = write_block_sync ( & rs - > rigport , frame , frame_length ) ;
2022-01-01 05:49:29 +00:00
2021-11-20 19:33:29 +00:00
if ( result < 0 )
{
2021-11-28 18:52:29 +00:00
// TODO: error handling? can writing to a pipe really fail in ways we can recover from?
2022-01-01 05:49:29 +00:00
rig_debug ( RIG_DEBUG_ERR , " %s: write_block_sync() failed, result=%d \n " , __func__ ,
result ) ;
2021-11-20 19:33:29 +00:00
continue ;
}
}
}
2022-01-01 05:49:29 +00:00
2022-02-05 21:27:43 +00:00
rig_debug ( RIG_DEBUG_VERBOSE , " %s: Stopping async data handler thread \n " ,
__func__ ) ;
2021-11-20 19:33:29 +00:00
return NULL ;
}
2022-02-28 19:08:41 +00:00
# endif
2022-02-24 23:13:18 +00:00
2022-04-15 18:21:35 +00:00
HAMLIB_EXPORT ( int ) rig_password ( RIG * rig , const char * key1 )
2022-02-24 23:13:18 +00:00
{
2022-04-15 18:21:35 +00:00
int retval = - RIG_EPROTO ;
2022-02-24 23:13:18 +00:00
ENTERFUNC ;
2022-03-01 17:40:14 +00:00
2022-02-24 23:13:18 +00:00
if ( rig - > caps - > password ! = NULL )
{
2022-04-15 18:21:35 +00:00
retval = rig - > caps - > password ( rig , key1 ) ;
2022-03-01 17:39:11 +00:00
//retval = RIG_OK;
2022-02-24 23:13:18 +00:00
}
2022-03-01 17:40:14 +00:00
2022-02-24 23:13:18 +00:00
RETURNFUNC ( retval ) ;
}
2022-06-01 16:42:54 +00:00
extern int read_icom_frame ( hamlib_port_t * p , const unsigned char rxbuffer [ ] ,
size_t rxbuffer_len ) ;
HAMLIB_EXPORT ( int ) rig_send_raw ( RIG * rig , const unsigned char * send ,
int send_len , unsigned char * reply , int reply_len , unsigned char * term )
{
struct rig_state * rs = & rig - > state ;
unsigned char buf [ 200 ] ;
ENTERFUNC ;
int retval = write_block_sync ( & rs - > rigport , send , send_len ) ;
if ( retval < 0 )
{
// TODO: error handling? can writing to a pipe really fail in ways we can recover from?
rig_debug ( RIG_DEBUG_ERR , " %s: write_block_sync() failed, result=%d \n " , __func__ ,
retval ) ;
}
if ( reply )
{
if ( term = =
NULL ) // we have to have terminating char or else we can't read the response
{
rig_debug ( RIG_DEBUG_ERR , " %s: term==NULL, must have terminator to read reply \n " ,
__func__ ) ;
RETURNFUNC ( - RIG_EINVAL ) ;
}
if ( * term = = 0xfd ) // then we want an Icom frame
{
retval = read_icom_frame ( & rs - > rigport , buf , sizeof ( buf ) ) ;
}
else // we'll assume the provided terminator works
{
retval = read_string_direct ( & rs - > rigport , buf , sizeof ( buf ) , ( const char * ) term ,
1 , 0 , 1 ) ;
}
if ( retval ! = RIG_OK )
{
rig_debug ( RIG_DEBUG_ERR , " %s: write_block_sync() failed, result=%d \n " , __func__ ,
retval ) ;
RETURNFUNC ( retval ) ;
}
}
RETURNFUNC ( retval ) ;
}
2022-06-02 20:55:56 +00:00
HAMLIB_EXPORT ( int ) rig_set_lock_mode ( RIG * rig , int mode )
{
int retcode = - RIG_ENAVAIL ;
if ( rig - > caps - > set_lock_mode )
{
retcode = rig - > caps - > set_lock_mode ( rig , mode ) ;
}
2022-06-06 13:50:29 +00:00
else
{
rig - > state . lock_mode = mode ;
retcode = RIG_OK ;
}
2022-06-02 20:55:56 +00:00
return ( retcode ) ;
}
HAMLIB_EXPORT ( int ) rig_get_lock_mode ( RIG * rig , int * mode )
{
int retcode = - RIG_ENAVAIL ;
if ( rig - > caps - > get_lock_mode )
{
retcode = rig - > caps - > get_lock_mode ( rig , mode ) ;
}
2022-06-06 13:50:29 +00:00
else
{
* mode = rig - > state . lock_mode ;
retcode = RIG_OK ;
}
2022-06-02 20:55:56 +00:00
return ( retcode ) ;
}