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