Hamlib  1.2.14
misc.h
00001 /*
00002  *  Hamlib Interface - toolbox header
00003  *  Copyright (c) 2000-2004 by Stephane Fillod
00004  *
00005  *      $Id: misc.h,v 1.18 2005-01-24 23:03:25 fillods Exp $
00006  *
00007  *   This library is free software; you can redistribute it and/or modify
00008  *   it under the terms of the GNU Library General Public License as
00009  *   published by the Free Software Foundation; either version 2 of
00010  *   the License, or (at your option) any later version.
00011  *
00012  *   This program is distributed in the hope that it will be useful,
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *   GNU Library General Public License for more details.
00016  *
00017  *   You should have received a copy of the GNU Library General Public
00018  *   License along with this library; if not, write to the Free Software
00019  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020  *
00021  */
00022 
00023 #ifndef _MISC_H
00024 #define _MISC_H 1
00025 
00026 #include <hamlib/rig.h>
00027 
00028 
00029 /*
00030  * Carefull!! These marcos are NOT reentrant!
00031  * ie. they may not be executed atomically,
00032  * thus not ensure mutual exclusion.
00033  * Fix it when making Hamlib reentrant!  --SF
00034  */
00035 #define Hold_Decode(rig) {(rig)->state.hold_decode = 1;}
00036 #define Unhold_Decode(rig) {(rig)->state.hold_decode = 0;}
00037 
00038 __BEGIN_DECLS
00039 
00040 /*
00041  * Do a hex dump of the unsigned char array.
00042  */
00043 
00044 void dump_hex(const unsigned char ptr[], size_t size);
00045 
00046 /*
00047  * BCD conversion routines.
00048  * to_bcd converts a long long int to a little endian BCD array,
00049  *      and return a pointer to this array.
00050  * from_bcd converts a little endian BCD array to long long int 
00051  *  reprensentation, and return it.
00052  * bcd_len is the number of digits in the BCD array.
00053  */
00054 extern HAMLIB_EXPORT(unsigned char *) to_bcd(unsigned char bcd_data[], unsigned long long freq, unsigned bcd_len);
00055 extern HAMLIB_EXPORT(unsigned long long) from_bcd(const unsigned char bcd_data[], unsigned bcd_len);
00056 
00057 /*
00058  * same as to_bcd and from_bcd, but in Big Endian mode
00059  */
00060 extern HAMLIB_EXPORT(unsigned char *) to_bcd_be(unsigned char bcd_data[], unsigned long long freq, unsigned bcd_len);
00061 extern HAMLIB_EXPORT(unsigned long long) from_bcd_be(const unsigned char bcd_data[], unsigned bcd_len);
00062 
00063 extern HAMLIB_EXPORT(int) sprintf_freq(char *str, freq_t);
00064 
00065 /* check if it's any of CR or LF */
00066 #define isreturn(c) ((c) == 10 || (c) == 13)
00067 
00068 
00069 /* needs config.h included beforehand in .c file */
00070 #ifdef HAVE_INTTYPES_H
00071 #include <inttypes.h>
00072 #endif
00073 #ifdef HAVE_SYS_TIME_H
00074 #include <sys/time.h>
00075 #endif
00076 
00077 extern HAMLIB_EXPORT(int) rig_check_cache_timeout(const struct timeval *tv, int timeout);
00078 extern HAMLIB_EXPORT(void) rig_force_cache_timeout(struct timeval *tv);
00079 
00080 
00081 #ifdef PRId64 
00082 
00083 #define PRIll PRId64 
00084 #else
00085 #ifdef FBSD4
00086 #define PRIll "qd"
00087 #else
00088 #define PRIll "lld"
00089 #endif
00090 #endif
00091 
00092 #ifdef SCNd64 
00093 
00094 #define SCNll SCNd64 
00095 #else
00096 #ifdef FBSD4
00097 #define SCNll "qd"
00098 #else
00099 #define SCNll "lld"
00100 #endif
00101 #endif
00102 
00103 
00104 
00105 __END_DECLS
00106 
00107 #endif /* _MISC_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated by doxygen 1.7.5

Hamlib documentation for version 1.2.14 -- Fri Dec 23 2011 23:24:31
Project page: http://www.hamlib.org