/* * Hamlib Interface - API header * Copyright (c) 2000-2005 by Stephane Fillod and Frank Singleton * * $Id: rig.h,v 1.122 2007-08-18 12:55:46 n0nb Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef _RIG_H #define _RIG_H 1 #include #include #include /* list in another file to not mess up w/ this one */ /** * \addtogroup rig * @{ */ /*! \file rig.h * \brief Hamlib rig data structures. * * This file contains the data structures and definitions for the Hamlib rig API. * see the rig.c file for more details on the rig API. */ /* __BEGIN_DECLS should be used at the beginning of your declarations, * so that C++ compilers don't mangle their names. Use __END_DECLS at * the end of C declarations. */ #undef __BEGIN_DECLS #undef __END_DECLS #ifdef __cplusplus # define __BEGIN_DECLS extern "C" { # define __END_DECLS } #else # define __BEGIN_DECLS /* empty */ # define __END_DECLS /* empty */ #endif /* HAMLIB_PARAMS is a macro used to wrap function prototypes, so that compilers * that don't understand ANSI C prototypes still work, and ANSI C * compilers can issue warnings about type mismatches. */ #undef HAMLIB_PARAMS #if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(__CYGWIN__) || defined(_WIN32) || defined(__cplusplus) # define HAMLIB_PARAMS(protos) protos # define rig_ptr_t void* #else # define HAMLIB_PARAMS(protos) () # define rig_ptr_t char* #endif #include __BEGIN_DECLS extern HAMLIB_EXPORT_VAR(const char) hamlib_version[]; extern HAMLIB_EXPORT_VAR(const char) hamlib_copyright[]; /** * \brief Hamlib error codes * Error codes that can be returned by the Hamlib functions */ enum rig_errcode_e { RIG_OK=0, /*!< No error, operation completed sucessfully */ RIG_EINVAL, /*!< invalid parameter */ RIG_ECONF, /*!< invalid configuration (serial,..) */ RIG_ENOMEM, /*!< memory shortage */ RIG_ENIMPL, /*!< function not implemented, but will be */ RIG_ETIMEOUT, /*!< communication timed out */ RIG_EIO, /*!< IO error, including open failed */ RIG_EINTERNAL, /*!< Internal Hamlib error, huh! */ RIG_EPROTO, /*!< Protocol error */ RIG_ERJCTED, /*!< Command rejected by the rig */ RIG_ETRUNC, /*!< Command performed, but arg truncated */ RIG_ENAVAIL, /*!< function not available */ RIG_ENTARGET, /*!< VFO not targetable */ RIG_BUSERROR, /*!< Error talking on the bus */ RIG_BUSBUSY, /*!< Collision on the bus */ RIG_EARG, /*!< NULL RIG handle or any invalid pointer parameter in get arg */ RIG_EVFO, /*!< Invalid VFO */ RIG_EDOM /*!< Argument out of domain of func */ }; /** *\brief Hamlib debug levels * * REM: Numeric order matters for debug level * * \sa rig_set_debug */ enum rig_debug_level_e { RIG_DEBUG_NONE = 0, /*!< no bug reporting */ RIG_DEBUG_BUG, /*!< serious bug */ RIG_DEBUG_ERR, /*!< error case (e.g. protocol, memory allocation) */ RIG_DEBUG_WARN, /*!< warning */ RIG_DEBUG_VERBOSE, /*!< verbose */ RIG_DEBUG_TRACE /*!< tracing */ }; /* --------------- Rig capabilities -----------------*/ /* Forward struct references */ struct rig; struct rig_state; /*! * \brief Rig structure definition (see rig for details). */ typedef struct rig RIG; #define RIGNAMSIZ 30 #define RIGVERSIZ 8 #define FILPATHLEN 100 #define FRQRANGESIZ 30 #define MAXCHANDESC 30 /* describe channel eg: "WWV 5Mhz" */ #define TSLSTSIZ 20 /* max tuning step list size, zero ended */ #define FLTLSTSIZ 42 /* max mode/filter list size, zero ended */ #define MAXDBLSTSIZ 8 /* max preamp/att levels supported, zero ended */ #define CHANLSTSIZ 16 /* max mem_list size, zero ended */ #define MAX_CAL_LENGTH 32 /* max calibration plots in cal_table_t */ /** * \brief CTCSS and DCS type definition. * * Continuous Tone Controlled Squelch System (CTCSS) * sub-audible tone frequency are expressed in \em tenth of Hz. * For example, the subaudible tone of 88.5 Hz is represented within * Hamlib by 885. * * Digitally-Coded Squelch codes are simple direct integers. */ typedef unsigned int tone_t; /** * \brief Port type */ typedef enum rig_port_e { RIG_PORT_NONE = 0, /*!< No port */ RIG_PORT_SERIAL, /*!< Serial */ RIG_PORT_NETWORK, /*!< Network socket type */ RIG_PORT_DEVICE, /*!< Device driver, like the WiNRADiO */ RIG_PORT_PACKET, /*!< AX.25 network type, e.g. SV8CS protocol */ RIG_PORT_DTMF, /*!< DTMF protocol bridge via another rig, eg. Kenwood Sky Cmd System */ RIG_PORT_ULTRA, /*!< IrDA Ultra protocol! */ RIG_PORT_RPC, /*!< RPC wrapper */ RIG_PORT_PARALLEL, /*!< Parallel port */ RIG_PORT_USB /*!< USB port */ } rig_port_t; /** * \brief Serial parity */ enum serial_parity_e { RIG_PARITY_NONE = 0, /*!< No parity */ RIG_PARITY_ODD, /*!< Odd */ RIG_PARITY_EVEN /*!< Even */ }; /** * \brief Serial handshake */ enum serial_handshake_e { RIG_HANDSHAKE_NONE = 0, /*!< No handshake */ RIG_HANDSHAKE_XONXOFF, /*!< Software XON/XOFF */ RIG_HANDSHAKE_HARDWARE /*!< Hardware CTS/RTS */ }; /** * \brief Serial control state */ enum serial_control_state_e { RIG_SIGNAL_UNSET = 0, /*!< Unset or tri-state */ RIG_SIGNAL_ON, /*!< ON */ RIG_SIGNAL_OFF /*!< OFF */ }; /** \brief Rig type flags */ typedef enum { RIG_FLAG_RECEIVER = (1<<1), /*!< Receiver */ RIG_FLAG_TRANSMITTER = (1<<2), /*!< Transmitter */ RIG_FLAG_SCANNER = (1<<3), /*!< Scanner */ RIG_FLAG_MOBILE = (1<<4), /*!< mobile sized */ RIG_FLAG_HANDHELD = (1<<5), /*!< handheld sized */ RIG_FLAG_COMPUTER = (1<<6), /*!< "Computer" rig */ RIG_FLAG_TRUNKING = (1<<7), /*!< has trunking */ RIG_FLAG_APRS = (1<<8), /*!< has APRS */ RIG_FLAG_TNC = (1<<9), /*!< has TNC */ RIG_FLAG_DXCLUSTER = (1<<10), /*!< has DXCluster */ RIG_FLAG_TUNER = (1<<11) /*!< dumb tuner */ } rig_type_t; #define RIG_FLAG_TRANSCEIVER (RIG_FLAG_RECEIVER|RIG_FLAG_TRANSMITTER) #define RIG_TYPE_MASK (RIG_FLAG_TRANSCEIVER|RIG_FLAG_SCANNER|RIG_FLAG_MOBILE|RIG_FLAG_HANDHELD|RIG_FLAG_COMPUTER|RIG_FLAG_TRUNKING|RIG_FLAG_TUNER) #define RIG_TYPE_OTHER 0 #define RIG_TYPE_TRANSCEIVER RIG_FLAG_TRANSCEIVER #define RIG_TYPE_HANDHELD (RIG_FLAG_TRANSCEIVER|RIG_FLAG_HANDHELD) #define RIG_TYPE_MOBILE (RIG_FLAG_TRANSCEIVER|RIG_FLAG_MOBILE) #define RIG_TYPE_RECEIVER RIG_FLAG_RECEIVER #define RIG_TYPE_PCRECEIVER (RIG_FLAG_COMPUTER|RIG_FLAG_RECEIVER) #define RIG_TYPE_SCANNER (RIG_FLAG_SCANNER|RIG_FLAG_RECEIVER) #define RIG_TYPE_TRUNKSCANNER (RIG_TYPE_SCANNER|RIG_FLAG_TRUNKING) #define RIG_TYPE_COMPUTER (RIG_FLAG_TRANSCEIVER|RIG_FLAG_COMPUTER) #define RIG_TYPE_TUNER RIG_FLAG_TUNER /** * \brief Development status of the backend */ enum rig_status_e { RIG_STATUS_ALPHA = 0, /*!< Alpha quality, i.e. development */ RIG_STATUS_UNTESTED, /*!< Written from available specs, rig unavailable for test, feedback wanted! */ RIG_STATUS_BETA, /*!< Beta quality */ RIG_STATUS_STABLE, /*!< Stable */ RIG_STATUS_BUGGY, /*!< Was stable, but something broke it! */ RIG_STATUS_NEW /*!< Initial release of code */ }; /** * \brief Repeater shift type */ typedef enum { RIG_RPT_SHIFT_NONE = 0, /*!< No repeater shift */ RIG_RPT_SHIFT_MINUS, /*!< "-" shift */ RIG_RPT_SHIFT_PLUS /*!< "+" shift */ } rptr_shift_t; /** * \brief Split mode */ typedef enum { RIG_SPLIT_OFF = 0, /*!< Split mode disabled */ RIG_SPLIT_ON /*!< Split mode enabled */ } split_t; /** * \brief Frequency type, * Frequency type unit in Hz, able to hold SHF frequencies. */ typedef double freq_t; /** \brief printf(3) format to be used for freq_t type */ #define PRIfreq "f" /** \brief scanf(3) format to be used for freq_t type */ #define SCNfreq "lf" #define FREQFMT SCNfreq /** * \brief Short frequency type * Frequency on 31bits, suitable for offsets, shifts, etc.. */ typedef signed long shortfreq_t; #define Hz(f) ((freq_t)(f)) #define kHz(f) ((freq_t)((f)*(freq_t)1000)) #define MHz(f) ((freq_t)((f)*(freq_t)1000000)) #define GHz(f) ((freq_t)((f)*(freq_t)1000000000)) #define s_Hz(f) ((shortfreq_t)(f)) #define s_kHz(f) ((shortfreq_t)((f)*(shortfreq_t)1000)) #define s_MHz(f) ((shortfreq_t)((f)*(shortfreq_t)1000000)) #define s_GHz(f) ((shortfreq_t)((f)*(shortfreq_t)1000000000)) #define RIG_FREQ_NONE Hz(0) /** * \brief VFO definition * * There's several way of using a vfo_t. For most cases, using RIG_VFO_A, * RIG_VFO_B, RIG_VFO_CURR, etc., as opaque macros should suffice. * * Strictly speaking a VFO is Variable Frequency Oscillator. * Here, it is referred as a tunable channel, from the radio operator * point of view. The channel can be designated individualy by its real * number, or using an alias. * Aliases may, or may not be honored by backend, and are defined using * high significant bits, like RIG_VFO_MEM, RIG_VFO_MAIN, etc. * */ typedef int vfo_t; /** \brief used in caps */ #define RIG_VFO_NONE 0 #define RIG_VFO_TX_FLAG ((vfo_t)(1<<30)) /** \brief current "tunable channel"/VFO */ #define RIG_VFO_CURR ((vfo_t)(1<<29)) /** \brief means Memory mode, to be used with set_vfo */ #define RIG_VFO_MEM ((vfo_t)(1<<28)) /** \brief means (last or any)VFO mode, with set_vfo */ #define RIG_VFO_VFO ((vfo_t)(1<<27)) #define RIG_VFO_TX_VFO(v) ((v)|RIG_VFO_TX_FLAG) /** \brief alias for split tx or uplink, of VFO_CURR */ #define RIG_VFO_TX RIG_VFO_TX_VFO(RIG_VFO_CURR) /** \brief alias for split rx or downlink */ #define RIG_VFO_RX RIG_VFO_CURR /** \brief alias for MAIN */ #define RIG_VFO_MAIN ((vfo_t)(1<<26)) /** \brief alias for SUB */ #define RIG_VFO_SUB ((vfo_t)(1<<25)) #define RIG_VFO_N(n) ((vfo_t)(1<<(n))) /** \brief VFO A */ #define RIG_VFO_A RIG_VFO_N(0) /** \brief VFO B */ #define RIG_VFO_B RIG_VFO_N(1) /** \brief VFO C */ #define RIG_VFO_C RIG_VFO_N(2) /* * targetable bitfields, for internal use. * RIG_TARGETABLE_PURE means a pure targetable radio on every command */ #define RIG_TARGETABLE_NONE 0 #define RIG_TARGETABLE_FREQ (1<<0) #define RIG_TARGETABLE_MODE (1<<1) #define RIG_TARGETABLE_PURE (1<<2) #define RIG_TARGETABLE_ALL 0x7fffffff #define RIG_PASSBAND_NORMAL s_Hz(0) /** * \brief Passband width, in Hz * \sa rig_passband_normal, rig_passband_narrow, rig_passband_wide */ typedef shortfreq_t pbwidth_t; /** * \brief DCD status */ typedef enum dcd_e { RIG_DCD_OFF = 0, /*!< Squelch closed */ RIG_DCD_ON /*!< Squelch open */ } dcd_t; /** * \brief DCD type * \sa rig_get_dcd */ typedef enum { RIG_DCD_NONE = 0, /*!< No DCD available */ RIG_DCD_RIG, /*!< Rig has DCD status support, i.e. rig has get_dcd cap */ RIG_DCD_SERIAL_DSR, /*!< DCD status from serial DSR signal */ RIG_DCD_SERIAL_CTS, /*!< DCD status from serial CTS signal */ RIG_DCD_SERIAL_CAR, /*!< DCD status from serial CD signal */ RIG_DCD_PARALLEL /*!< DCD status from parallel port pin */ } dcd_type_t; /** * \brief PTT status */ typedef enum { RIG_PTT_OFF = 0, /*!< PTT activated */ RIG_PTT_ON /*!< PTT desactivated */ } ptt_t; /** * \brief PTT type * \sa rig_get_ptt */ typedef enum { RIG_PTT_NONE = 0, /*!< No PTT available */ RIG_PTT_RIG, /*!< Legacy PTT */ RIG_PTT_SERIAL_DTR, /*!< PTT control through serial DTR signal */ RIG_PTT_SERIAL_RTS, /*!< PTT control through serial RTS signal */ RIG_PTT_PARALLEL /*!< PTT control through parallel port */ } ptt_type_t; /** * \brief Radio power state */ typedef enum { RIG_POWER_OFF = 0, /*!< Power off */ RIG_POWER_ON = (1<<0), /*!< Power on */ RIG_POWER_STANDBY = (1<<1) /*!< Standby */ } powerstat_t; /** * \brief Reset operation */ typedef enum { RIG_RESET_NONE = 0, /*!< No reset */ RIG_RESET_SOFT = (1<<0), /*!< Software reset */ RIG_RESET_VFO = (1<<1), /*!< VFO reset */ RIG_RESET_MCALL = (1<<2), /*!< Memory clear */ RIG_RESET_MASTER = (1<<3) /*!< Master reset */ } reset_t; /** * \brief VFO operation * A VFO operation is an action on a VFO (or memory). * The difference with a function is that an action has no on/off * status, it is performed at once. * * Note: the vfo argument for some vfo operation may be irrelevant, * and thus will be ignored. * * The VFO/MEM "mode" is set by rig_set_vfo. */ typedef enum { RIG_OP_NONE = 0, RIG_OP_CPY = (1<<0), /*!< VFO A = VFO B */ RIG_OP_XCHG = (1<<1), /*!< Exchange VFO A/B */ RIG_OP_FROM_VFO = (1<<2), /*!< VFO->MEM */ RIG_OP_TO_VFO = (1<<3), /*!< MEM->VFO */ RIG_OP_MCL = (1<<4), /*!< Memory clear */ RIG_OP_UP = (1<<5), /*!< UP increment VFO freq by tuning step*/ RIG_OP_DOWN = (1<<6), /*!< DOWN decrement VFO freq by tuning step*/ RIG_OP_BAND_UP = (1<<7), /*!< Band UP */ RIG_OP_BAND_DOWN = (1<<8), /*!< Band DOWN */ RIG_OP_LEFT = (1<<9), /*!< LEFT */ RIG_OP_RIGHT = (1<<10),/*!< RIGHT */ RIG_OP_TUNE = (1<<11),/*!< Start tune */ RIG_OP_TOGGLE = (1<<12) /*!< Toggle VFOA and VFOB */ } vfo_op_t; /** * \brief Scan operation */ typedef enum { RIG_SCAN_NONE = 0, RIG_SCAN_STOP = RIG_SCAN_NONE, /*!< Stop scanning */ RIG_SCAN_MEM = (1<<0), /*!< Scan all memory channels */ RIG_SCAN_SLCT = (1<<1), /*!< Scan all selected memory channels */ RIG_SCAN_PRIO = (1<<2), /*!< Priority watch (mem or call channel) */ RIG_SCAN_PROG = (1<<3), /*!< Programmed(edge) scan */ RIG_SCAN_DELTA = (1<<4), /*!< delta-f scan */ RIG_SCAN_VFO = (1<<5), /*!< most basic scan */ RIG_SCAN_PLT = (1<<6) /*!< Scan using pipelined tuning */ } scan_t; /** * configuration token */ typedef long token_t; #define RIG_CONF_END 0 /** * \brief parameter types * * Used with configuration, parameter and extra-parm tables. * * Current internal implementation * NUMERIC: val.f or val.i * COMBO: val.i, starting from 0. Points to a table of strings or asci stored values. * STRING: val.s or val.cs * CHECKBUTTON: val.i 0/1 */ /* strongly inspired from soundmedem. Thanks Thomas! */ enum rig_conf_e { RIG_CONF_STRING, /*!< String type */ RIG_CONF_COMBO, /*!< Combo type */ RIG_CONF_NUMERIC, /*!< Numeric type integer or real */ RIG_CONF_CHECKBUTTON /*!< on/off type */ }; #define RIG_COMBO_MAX 8 /** * \brief Configuration parameter structure. */ struct confparams { token_t token; /*!< Conf param token ID */ const char *name; /*!< Param name, no spaces allowed */ const char *label; /*!< Human readable label */ const char *tooltip; /*!< Hint on the parameter */ const char *dflt; /*!< Default value */ enum rig_conf_e type; /*!< Type of the parameter */ union { /*!< */ struct { /*!< */ float min; /*!< Minimum value */ float max; /*!< Maximum value */ float step; /*!< Step */ } n; /*!< Numeric type */ struct { /*!< */ const char *combostr[RIG_COMBO_MAX]; /*!< Combo list */ } c; /*!< Combo type */ } u; /*!< Type union */ }; /** \brief Announce * Designate optional speech synthesizer. */ typedef enum { RIG_ANN_NONE = 0, /*!< None */ RIG_ANN_OFF = RIG_ANN_NONE, /*!< disable announces */ RIG_ANN_FREQ = (1<<0), /*!< Announce frequency */ RIG_ANN_RXMODE = (1<<1), /*!< Announce receive mode */ RIG_ANN_CW = (1<<2), /*!< CW */ RIG_ANN_ENG = (1<<3), /*!< English */ RIG_ANN_JAP = (1<<4) /*!< Japan */ } ann_t; /* Antenna number */ typedef int ant_t; #define RIG_ANT_NONE 0 #define RIG_ANT_N(n) ((ant_t)1<<(n)) #define RIG_ANT_1 RIG_ANT_N(0) #define RIG_ANT_2 RIG_ANT_N(1) #define RIG_ANT_3 RIG_ANT_N(2) #define RIG_ANT_4 RIG_ANT_N(3) /** * \brief AGC delay settings */ /* TODO: kill me, and replace by real AGC delay */ enum agc_level_e { RIG_AGC_OFF = 0, RIG_AGC_SUPERFAST, RIG_AGC_FAST, RIG_AGC_SLOW, RIG_AGC_USER, /*!< user selectable */ RIG_AGC_MEDIUM }; /** * \brief Level display meters */ enum meter_level_e { RIG_METER_NONE = 0, /*< No display meter */ RIG_METER_SWR = (1<<0), /*< Stationary Wave Ratio */ RIG_METER_COMP = (1<<1), /*< Compression level */ RIG_METER_ALC = (1<<2), /*< ALC */ RIG_METER_IC = (1<<3), /*< IC */ RIG_METER_DB = (1<<4) /*< DB */ }; /** * \brief Universal approach for passing values * \sa rig_set_level, rig_get_level, rig_set_parm, rig_get_parm */ typedef union { signed int i; /*!< Signed integer */ float f; /*!< Single precision float */ char *s; /*!< Pointer to char string */ const char *cs; /*!< Pointer to constant char string */ } value_t; /** \brief Level */ enum rig_level_e { RIG_LEVEL_NONE = 0, /*!< None */ RIG_LEVEL_PREAMP = (1<<0), /*!< Preamp, arg int (dB) */ RIG_LEVEL_ATT = (1<<1), /*!< Attenuator, arg int (dB) */ RIG_LEVEL_VOX = (1<<2), /*!< VOX delay, arg int (tenth of seconds) */ RIG_LEVEL_AF = (1<<3), /*!< Volume, arg float [0.0..1.0] */ RIG_LEVEL_RF = (1<<4), /*!< RF gain (not TX power), arg float [0.0..1.0] */ RIG_LEVEL_SQL = (1<<5), /*!< Squelch, arg float [0.0 .. 1.0] */ RIG_LEVEL_IF = (1<<6), /*!< IF, arg int (Hz) */ RIG_LEVEL_APF = (1<<7), /*!< APF, arg float [0.0 .. 1.0] */ RIG_LEVEL_NR = (1<<8), /*!< Noise Reduction, arg float [0.0 .. 1.0] */ RIG_LEVEL_PBT_IN = (1<<9), /*!< Twin PBT (inside), arg float [0.0 .. 1.0] */ RIG_LEVEL_PBT_OUT = (1<<10),/*!< Twin PBT (outside), arg float [0.0 .. 1.0] */ RIG_LEVEL_CWPITCH = (1<<11),/*!< CW pitch, arg int (Hz) */ RIG_LEVEL_RFPOWER = (1<<12),/*!< RF Power, arg float [0.0 .. 1.0] */ RIG_LEVEL_MICGAIN = (1<<13),/*!< MIC Gain, arg float [0.0 .. 1.0] */ RIG_LEVEL_KEYSPD = (1<<14),/*!< Key Speed, arg int (WPM) */ RIG_LEVEL_NOTCHF = (1<<15),/*!< Notch Freq., arg int (Hz) */ RIG_LEVEL_COMP = (1<<16),/*!< Compressor, arg float [0.0 .. 1.0] */ RIG_LEVEL_AGC = (1<<17),/*!< AGC, arg int (see enum agc_level_e) */ RIG_LEVEL_BKINDL = (1<<18),/*!< BKin Delay, arg int (tenth of dots) */ RIG_LEVEL_BALANCE = (1<<19),/*!< Balance (Dual Watch), arg float [0.0 .. 1.0] */ RIG_LEVEL_METER = (1<<20),/*!< Display meter, arg int (see enum meter_level_e) */ RIG_LEVEL_VOXGAIN = (1<<21),/*!< VOX gain level, arg float [0.0 .. 1.0] */ RIG_LEVEL_VOXDELAY = RIG_LEVEL_VOX, /*!< VOX delay, arg int (tenth of seconds) */ RIG_LEVEL_ANTIVOX = (1<<22),/*!< anti-VOX level, arg float [0.0 .. 1.0] */ RIG_LEVEL_SLOPE_LOW = (1<<23),/*!