2000-10-01 12:25:49 +00:00
|
|
|
/*
|
2001-07-13 19:08:15 +00:00
|
|
|
* Hamlib Interface - toolbox header
|
2004-05-17 21:09:45 +00:00
|
|
|
* Copyright (c) 2000-2004 by Stephane Fillod
|
2000-10-01 12:25:49 +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-07-13 19:08:15 +00:00
|
|
|
*
|
2011-08-22 01:07:57 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2001-07-13 19:08:15 +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-07-13 19:08:15 +00:00
|
|
|
*
|
2011-08-22 01:07:57 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2001-07-13 19:08:15 +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
|
2000-10-01 12:25:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MISC_H
|
|
|
|
#define _MISC_H 1
|
|
|
|
|
2001-06-12 23:59:21 +00:00
|
|
|
#include <hamlib/rig.h>
|
2000-10-08 21:43:41 +00:00
|
|
|
|
2001-06-15 07:08:37 +00:00
|
|
|
|
2000-10-08 21:43:41 +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
|
|
|
* Careful!! These macros are NOT reentrant!
|
2000-10-08 21:43:41 +00:00
|
|
|
* ie. they may not be executed atomically,
|
|
|
|
* thus not ensure mutual exclusion.
|
|
|
|
* Fix it when making Hamlib reentrant! --SF
|
|
|
|
*/
|
|
|
|
#define Hold_Decode(rig) {(rig)->state.hold_decode = 1;}
|
|
|
|
#define Unhold_Decode(rig) {(rig)->state.hold_decode = 0;}
|
|
|
|
|
2002-07-06 09:26:59 +00:00
|
|
|
__BEGIN_DECLS
|
2000-10-08 21:43:41 +00:00
|
|
|
|
2000-10-01 12:25:49 +00:00
|
|
|
/*
|
|
|
|
* Do a hex dump of the unsigned char array.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void dump_hex(const unsigned char ptr[], size_t size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BCD conversion routines.
|
2017-08-05 14:09:12 +00:00
|
|
|
*
|
|
|
|
* to_bcd() converts a long long int to a little endian BCD array,
|
|
|
|
* and return a pointer to this array.
|
|
|
|
*
|
|
|
|
* from_bcd() converts a little endian BCD array to long long int
|
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
|
|
|
* representation, and return it.
|
2017-08-05 14:09:12 +00:00
|
|
|
*
|
2000-10-01 12:25:49 +00:00
|
|
|
* bcd_len is the number of digits in the BCD array.
|
|
|
|
*/
|
2017-08-05 14:09:12 +00:00
|
|
|
extern HAMLIB_EXPORT(unsigned char *) to_bcd(unsigned char bcd_data[],
|
|
|
|
unsigned long long freq,
|
|
|
|
unsigned bcd_len);
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
extern HAMLIB_EXPORT(unsigned long long) from_bcd(const unsigned char
|
|
|
|
bcd_data[],
|
2017-08-05 14:09:12 +00:00
|
|
|
unsigned bcd_len);
|
2000-10-01 12:25:49 +00:00
|
|
|
|
2000-10-16 21:53:22 +00:00
|
|
|
/*
|
2017-08-05 14:09:12 +00:00
|
|
|
* same as to_bcd() and from_bcd(), but in Big Endian mode
|
2000-10-16 21:53:22 +00:00
|
|
|
*/
|
2017-08-05 14:09:12 +00:00
|
|
|
extern HAMLIB_EXPORT(unsigned char *) to_bcd_be(unsigned char bcd_data[],
|
|
|
|
unsigned long long freq,
|
|
|
|
unsigned bcd_len);
|
|
|
|
|
2017-10-05 02:32:08 +00:00
|
|
|
extern HAMLIB_EXPORT(unsigned long long) from_bcd_be(const unsigned char
|
|
|
|
bcd_data[],
|
2017-08-05 14:09:12 +00:00
|
|
|
unsigned bcd_len);
|
2000-10-16 21:53:22 +00:00
|
|
|
|
2020-11-07 13:03:54 +00:00
|
|
|
extern HAMLIB_EXPORT(double) morse_code_dot_to_millis(int wpm);
|
|
|
|
extern HAMLIB_EXPORT(int) dot10ths_to_millis(int dot10ths, int wpm);
|
|
|
|
extern HAMLIB_EXPORT(int) millis_to_dot10ths(int millis, int wpm);
|
|
|
|
|
2002-01-27 23:47:41 +00:00
|
|
|
extern HAMLIB_EXPORT(int) sprintf_freq(char *str, freq_t);
|
2002-01-22 00:50:32 +00:00
|
|
|
|
2015-12-04 00:04:51 +00:00
|
|
|
/* flag that determines if AI mode should be restored on exit on
|
|
|
|
applicable rigs - See rig_no_restore_ai() */
|
|
|
|
extern int no_restore_ai;
|
|
|
|
|
2001-06-12 23:59:21 +00:00
|
|
|
/* check if it's any of CR or LF */
|
|
|
|
#define isreturn(c) ((c) == 10 || (c) == 13)
|
2001-04-24 19:52:28 +00:00
|
|
|
|
2005-01-24 23:04:35 +00:00
|
|
|
|
|
|
|
/* needs config.h included beforehand in .c file */
|
|
|
|
#ifdef HAVE_INTTYPES_H
|
2017-10-05 02:32:08 +00:00
|
|
|
# include <inttypes.h>
|
2005-01-24 23:04:35 +00:00
|
|
|
#endif
|
2017-10-05 02:32:08 +00:00
|
|
|
|
2010-03-28 16:33:03 +00:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
2017-10-05 02:32:08 +00:00
|
|
|
# include <sys/time.h>
|
2010-03-28 16:33:03 +00:00
|
|
|
#endif
|
|
|
|
|
2017-08-05 14:09:12 +00:00
|
|
|
extern HAMLIB_EXPORT(int) rig_check_cache_timeout(const struct timeval *tv,
|
|
|
|
int timeout);
|
|
|
|
|
2010-03-28 16:33:03 +00:00
|
|
|
extern HAMLIB_EXPORT(void) rig_force_cache_timeout(struct timeval *tv);
|
|
|
|
|
2018-12-31 21:39:49 +00:00
|
|
|
extern HAMLIB_EXPORT(setting_t) rig_idx2setting(int i);
|
2005-01-24 23:04:35 +00:00
|
|
|
|
2020-06-13 22:40:47 +00:00
|
|
|
extern HAMLIB_EXPORT(int) hl_usleep(rig_useconds_t usec);
|
2020-01-10 21:58:16 +00:00
|
|
|
|
2020-05-16 19:33:14 +00:00
|
|
|
extern HAMLIB_EXPORT(double) elapsed_ms(struct timespec *start, int start_flag);
|
2020-04-26 20:44:38 +00:00
|
|
|
|
2020-06-12 13:28:05 +00:00
|
|
|
extern HAMLIB_EXPORT(vfo_t) vfo_fixup(RIG *rig, vfo_t vfo);
|
|
|
|
|
2020-06-21 22:47:04 +00:00
|
|
|
extern HAMLIB_EXPORT(int) parse_hoststr(char *host, char hoststr[256], char port[6]);
|
|
|
|
|
2011-08-22 01:07:57 +00:00
|
|
|
#ifdef PRId64
|
2005-01-24 23:04:35 +00:00
|
|
|
/** \brief printf(3) format to be used for long long (64bits) type */
|
2017-10-05 02:32:08 +00:00
|
|
|
# define PRIll PRId64
|
2018-12-21 21:46:48 +00:00
|
|
|
# define PRXll PRIx64
|
2005-01-24 23:04:35 +00:00
|
|
|
#else
|
2017-10-05 02:32:08 +00:00
|
|
|
# ifdef FBSD4
|
|
|
|
# define PRIll "qd"
|
2018-12-21 21:46:48 +00:00
|
|
|
# define PRXll "qx"
|
2017-10-05 02:32:08 +00:00
|
|
|
# else
|
|
|
|
# define PRIll "lld"
|
2018-12-21 21:46:48 +00:00
|
|
|
# define PRXll "lld"
|
2017-10-05 02:32:08 +00:00
|
|
|
# endif
|
2005-01-24 23:04:35 +00:00
|
|
|
#endif
|
|
|
|
|
2011-08-22 01:07:57 +00:00
|
|
|
#ifdef SCNd64
|
2005-01-24 23:04:35 +00:00
|
|
|
/** \brief scanf(3) format to be used for long long (64bits) type */
|
2017-10-05 02:32:08 +00:00
|
|
|
# define SCNll SCNd64
|
2018-12-21 21:46:48 +00:00
|
|
|
# define SCNXll SCNx64
|
2005-01-24 23:04:35 +00:00
|
|
|
#else
|
2017-10-05 02:32:08 +00:00
|
|
|
# ifdef FBSD4
|
|
|
|
# define SCNll "qd"
|
2018-12-21 21:46:48 +00:00
|
|
|
# define SCNXll "qx"
|
2017-10-05 02:32:08 +00:00
|
|
|
# else
|
|
|
|
# define SCNll "lld"
|
2018-12-21 21:46:48 +00:00
|
|
|
# define SCNXll "llx"
|
2017-10-05 02:32:08 +00:00
|
|
|
# endif
|
2005-01-24 23:04:35 +00:00
|
|
|
#endif
|
|
|
|
|
2021-01-28 16:25:05 +00:00
|
|
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
2021-01-17 13:25:28 +00:00
|
|
|
void errmsg(int err, char *s, const char *func, const char *file, int line);
|
2021-01-28 16:25:05 +00:00
|
|
|
#define ERRMSG(err, s) errmsg(err, s, __func__, __FILENAME__, __LINE__)
|
|
|
|
#define ENTERFUNC rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):%s entered\n", __FILENAME__, __LINE__, __func__)
|
|
|
|
#define RETURNFUNC(rc) {rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):%s return\n", __FILENAME__, __LINE__, __func__);return rc;}
|
2005-01-24 23:04:35 +00:00
|
|
|
|
2021-01-19 13:17:07 +00:00
|
|
|
#define CACHE_RESET {\
|
|
|
|
elapsed_ms(&rig->state.cache.time_freq, HAMLIB_ELAPSED_INVALIDATE);\
|
|
|
|
elapsed_ms(&rig->state.cache.time_freqCurr, HAMLIB_ELAPSED_INVALIDATE);\
|
|
|
|
elapsed_ms(&rig->state.cache.time_freqMainA, HAMLIB_ELAPSED_INVALIDATE);\
|
|
|
|
elapsed_ms(&rig->state.cache.time_freqMainB, HAMLIB_ELAPSED_INVALIDATE);\
|
|
|
|
elapsed_ms(&rig->state.cache.time_freqMainC, HAMLIB_ELAPSED_INVALIDATE);\
|
|
|
|
elapsed_ms(&rig->state.cache.time_freqSubA, HAMLIB_ELAPSED_INVALIDATE);\
|
|
|
|
elapsed_ms(&rig->state.cache.time_freqSubB, HAMLIB_ELAPSED_INVALIDATE);\
|
|
|
|
elapsed_ms(&rig->state.cache.time_vfo, HAMLIB_ELAPSED_INVALIDATE);\
|
|
|
|
elapsed_ms(&rig->state.cache.time_mode, HAMLIB_ELAPSED_INVALIDATE);\
|
|
|
|
elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_INVALIDATE);\
|
|
|
|
elapsed_ms(&rig->state.cache.time_split, HAMLIB_ELAPSED_INVALIDATE);\
|
|
|
|
}
|
|
|
|
|
2002-07-06 09:26:59 +00:00
|
|
|
__END_DECLS
|
|
|
|
|
2000-10-01 12:25:49 +00:00
|
|
|
#endif /* _MISC_H */
|