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
|
|
|
/*
|
|
|
|
* Carefull!! These marcos are NOT reentrant!
|
|
|
|
* 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.
|
|
|
|
* to_bcd converts a long long int to a little endian BCD array,
|
|
|
|
* and return a pointer to this array.
|
2011-08-22 01:07:57 +00:00
|
|
|
* from_bcd converts a little endian BCD array to long long int
|
2000-10-01 12:25:49 +00:00
|
|
|
* reprensentation, and return it.
|
|
|
|
* bcd_len is the number of digits in the BCD array.
|
|
|
|
*/
|
2002-10-07 21:57:17 +00:00
|
|
|
extern HAMLIB_EXPORT(unsigned char *) to_bcd(unsigned char bcd_data[], unsigned long long freq, unsigned bcd_len);
|
|
|
|
extern HAMLIB_EXPORT(unsigned long long) from_bcd(const unsigned char bcd_data[], unsigned bcd_len);
|
2000-10-01 12:25:49 +00:00
|
|
|
|
2000-10-16 21:53:22 +00:00
|
|
|
/*
|
|
|
|
* same as to_bcd and from_bcd, but in Big Endian mode
|
|
|
|
*/
|
2002-10-07 21:57:17 +00:00
|
|
|
extern HAMLIB_EXPORT(unsigned char *) to_bcd_be(unsigned char bcd_data[], unsigned long long freq, unsigned bcd_len);
|
|
|
|
extern HAMLIB_EXPORT(unsigned long long) from_bcd_be(const unsigned char bcd_data[], unsigned bcd_len);
|
2000-10-16 21:53:22 +00:00
|
|
|
|
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
|
|
|
|
#include <inttypes.h>
|
|
|
|
#endif
|
2010-03-28 16:33:03 +00:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern HAMLIB_EXPORT(int) rig_check_cache_timeout(const struct timeval *tv, int timeout);
|
|
|
|
extern HAMLIB_EXPORT(void) rig_force_cache_timeout(struct timeval *tv);
|
|
|
|
|
2005-01-24 23:04:35 +00:00
|
|
|
|
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 */
|
2011-08-22 01:07:57 +00:00
|
|
|
#define PRIll PRId64
|
2005-01-24 23:04:35 +00:00
|
|
|
#else
|
|
|
|
#ifdef FBSD4
|
|
|
|
#define PRIll "qd"
|
|
|
|
#else
|
|
|
|
#define PRIll "lld"
|
|
|
|
#endif
|
|
|
|
#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 */
|
2011-08-22 01:07:57 +00:00
|
|
|
#define SCNll SCNd64
|
2005-01-24 23:04:35 +00:00
|
|
|
#else
|
|
|
|
#ifdef FBSD4
|
|
|
|
#define SCNll "qd"
|
|
|
|
#else
|
|
|
|
#define SCNll "lld"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-07-06 09:26:59 +00:00
|
|
|
__END_DECLS
|
|
|
|
|
2000-10-01 12:25:49 +00:00
|
|
|
#endif /* _MISC_H */
|