Hamlib 4.7~git
Loading...
Searching...
No Matches
rig.c File Reference

Ham Radio Control Libraries interface. More...

#include "hamlib/config.h"
#include "hamlib/rig.h"
#include "hamlib/rig_state.h"
#include "fifo.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include "mutex.h"
#include "serial.h"
#include "parallel.h"
#include "network.h"
#include "event.h"
#include "cm108.h"
#include "gpio.h"
#include "misc.h"
#include "sprintflst.h"
#include "hamlibdatetime.h"
#include "cache.h"
#include "band_changed.c"
Include dependency graph for rig.c:

Macros

#define ERROR_TBL_SZ   (sizeof(rigerror_table)/sizeof(char *))
 Convenience macro calculating rigerror_table size.
#define MAX_FRAME_LENGTH   1024

Functions

int foreach_opened_rig (int(*cfunc)(RIG *, rig_ptr_t), rig_ptr_t data)
 execs cfunc() on each opened rig
void add2debugmsgsave (const char *s)
 Handle stack trace messages.
const char * rigerror2 (int errnum)
 Get the string describing the passed error code.
const char * rigerror (int errnum)
 Add error message to debug output.
RIGrig_init (rig_model_t rig_model)
 Allocate a new RIG handle.
int rig_open (RIG *rig)
 open the communication to the rig
int rig_close (RIG *rig)
 close the communication to the rig
int rig_cleanup (RIG *rig)
 release a rig handle and free associated memory
int rig_set_twiddle (RIG *rig, int seconds)
 timeout (secs) to stop rigctld when VFO is manually changed
int rig_set_uplink (RIG *rig, int val)
 For GPredict to avoid reading frequency on uplink VFO.
int rig_get_twiddle (RIG *rig, int *seconds)
 get the twiddle timeout value (secs)
int rig_set_freq (RIG *rig, vfo_t vfo, freq_t freq)
 set the frequency of the target VFO
int rig_get_freq (RIG *rig, vfo_t vfo, freq_t *freq)
 get the frequency of the target VFO
int rig_get_freqs (RIG *rig, freq_t *freqA, freq_t freqB)
 get the frequency of VFOA and VFOB
int rig_set_mode (RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
 set the mode of the target VFO
int rig_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
 get the mode of the target VFO
pbwidth_t rig_passband_normal (RIG *rig, rmode_t mode)
 get the normal passband of a mode
pbwidth_t rig_passband_narrow (RIG *rig, rmode_t mode)
 get the narrow passband of a mode
pbwidth_t rig_passband_wide (RIG *rig, rmode_t mode)
 get the wide passband of a mode
int rig_set_vfo (RIG *rig, vfo_t vfo)
 set the current VFO
int rig_get_vfo (RIG *rig, vfo_t *vfo)
 get the current VFO
int rig_set_ptt (RIG *rig, vfo_t vfo, ptt_t ptt)
 set PTT on/off
int rig_get_ptt (RIG *rig, vfo_t vfo, ptt_t *ptt)
 get the status of the PTT
int rig_get_dcd (RIG *rig, vfo_t vfo, dcd_t *dcd)
 get the status of the DCD
int rig_set_rptr_shift (RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift)
 set the repeater shift
int rig_get_rptr_shift (RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift)
 get the current repeater shift
int rig_set_rptr_offs (RIG *rig, vfo_t vfo, shortfreq_t rptr_offs)
 set the repeater offset
int rig_get_rptr_offs (RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs)
 get the current repeater offset
int rig_set_split_freq (RIG *rig, vfo_t vfo, freq_t tx_freq)
 set the split frequencies
int rig_get_split_freq (RIG *rig, vfo_t vfo, freq_t *tx_freq)
 get the current split frequencies
int rig_set_split_mode (RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
 set the split modes
int rig_get_split_mode (RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth_t *tx_width)
 get the current split modes
int rig_set_split_freq_mode (RIG *rig, vfo_t vfo, freq_t tx_freq, rmode_t tx_mode, pbwidth_t tx_width)
 set the split frequency and mode
int rig_get_split_freq_mode (RIG *rig, vfo_t vfo, freq_t *tx_freq, rmode_t *tx_mode, pbwidth_t *tx_width)
 get the current split frequency and mode
int rig_set_split_vfo (RIG *rig, vfo_t rx_vfo, split_t split, vfo_t tx_vfo)
 set the split mode
int rig_get_split_vfo (RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
 get the current split mode
int rig_set_rit (RIG *rig, vfo_t vfo, shortfreq_t rit)
 set the RIT
int rig_get_rit (RIG *rig, vfo_t vfo, shortfreq_t *rit)
 get the current RIT offset
int rig_set_xit (RIG *rig, vfo_t vfo, shortfreq_t xit)
 set the XIT
int rig_get_xit (RIG *rig, vfo_t vfo, shortfreq_t *xit)
 get the current XIT offset
int rig_set_ts (RIG *rig, vfo_t vfo, shortfreq_t ts)
 set the Tuning Step
int rig_get_ts (RIG *rig, vfo_t vfo, shortfreq_t *ts)
 get the current Tuning Step
int rig_set_ant (RIG *rig, vfo_t vfo, ant_t ant, value_t option)
 set the antenna
int rig_get_ant (RIG *rig, vfo_t vfo, ant_t ant, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx)
 get the current antenna
int rig_power2mW (RIG *rig, unsigned int *mwpower, float power, freq_t freq, rmode_t mode)
 conversion utility from relative range to absolute in mW
int rig_mW2power (RIG *rig, float *power, unsigned int mwpower, freq_t freq, rmode_t mode)
 conversion utility from absolute in mW to relative range
shortfreq_t rig_get_resolution (RIG *rig, rmode_t mode)
 get the best frequency resolution of the rig
int rig_set_powerstat (RIG *rig, powerstat_t status)
 turn on/off the radio
int rig_get_powerstat (RIG *rig, powerstat_t *status)
 get the on/off status of the radio
int rig_reset (RIG *rig, reset_t reset)
 reset the radio
rig_model_t rig_probe (hamlib_port_t *port)
 try to guess a rig
int rig_probe_all (hamlib_port_t *port, rig_probe_func_t cfunc, rig_ptr_t data)
 try to guess rigs
vfo_op_t rig_has_vfo_op (RIG *rig, vfo_op_t op)
 check retrieval ability of VFO operations
int rig_vfo_op (RIG *rig, vfo_t vfo, vfo_op_t op)
 perform Memory/VFO operations
scan_t rig_has_scan (RIG *rig, scan_t scan)
 check availability of scanning functions
int rig_scan (RIG *rig, vfo_t vfo, scan_t scan, int ch)
 perform Memory/VFO operations
int rig_send_dtmf (RIG *rig, vfo_t vfo, const char *digits)
 send DTMF digits
int rig_recv_dtmf (RIG *rig, vfo_t vfo, char *digits, int *length)
 receive DTMF digits
int rig_send_morse (RIG *rig, vfo_t vfo, const char *msg)
 send morse code
int rig_stop_morse (RIG *rig, vfo_t vfo)
 stop morse code
int rig_wait_morse (RIG *rig, vfo_t vfo)
 wait morse code
int rig_send_voice_mem (RIG *rig, vfo_t vfo, int ch)
 send voice memory content
int rig_stop_voice_mem (RIG *rig, vfo_t vfo)
 stop sending voice memory
const freq_range_trig_get_range (const freq_range_t *range_list, freq_t freq, rmode_t mode)
 find the freq_range of freq/mode
int rig_set_vfo_opt (RIG *rig, int status)
 set the vfo option for rigctld
const char * rig_get_info (RIG *rig)
 get general information from the radio
int rig_get_rig_info (RIG *rig, char *response, int max_response_len)
 get freq/mode/width for requested VFO
int rig_get_vfo_info (RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode, pbwidth_t *width, split_t *split, int *satmode)
 get freq/mode/width for requested VFO
int rig_get_vfo_list (RIG *rig, char *buf, int buflen)
 get list of available vfos
int rig_set_clock (RIG *rig, int year, int month, int day, int hour, int min, int sec, double msec, int utc_offset)
 set the rig's clock
int rig_get_clock (RIG *rig, int *year, int *month, int *day, int *hour, int *min, int *sec, double *msec, int *utc_offset)
 get the rig's clock
const char * rig_license ()
 get the Hamlib license
const char * rig_version ()
 get the Hamlib version
const char * rig_copyright ()
 get the Hamlib copyright
int rig_cookie (RIG *rig, enum cookie_e cookie_cmd, char *cookie, int cookie_len)
 get a cookie to grab rig control
void rig_lock (RIG *rig, int lock)
int rig_password (RIG *rig, const char *key1)
int read_icom_frame (hamlib_port_t *p, const unsigned char rxbuffer[], size_t rxbuffer_len)
int rig_send_raw (RIG *rig, const unsigned char *send, int send_len, unsigned char *reply, int reply_len, unsigned char *term)
 Send verbatim data.
int rig_set_lock_mode (RIG *rig, int mode)
int rig_get_lock_mode (RIG *rig, int *mode)
int rig_is_model (RIG *rig, rig_model_t model)
int morse_data_handler_set_keyspd (RIG *rig, int keyspd)
void * rig_data_pointer (RIG *rig, rig_ptrx_t idx)
 Get the address of a Hamlib data structure.

Variables

const char * hamlib_license = "LGPL"
 Hamlib short license name.
const char * hamlib_version2 = "Hamlib " PACKAGE_VERSION " " HAMLIBDATETIME " " ARCHBITS
 Hamlib version string.
 intcookie_use
 intskip_init
 intlock_mode
powerstat_t rig_powerstat
struct rig_caps caps_test
const char * hamlib_copyright2
 Hamlib copyright notice.
char debugmsgsave [DEBUGMSGSAVE_SIZE] = ""
char debugmsgsave2 [DEBUGMSGSAVE_SIZE] = ""
char debugmsgsave3 [DEBUGMSGSAVE_SIZE] = ""
void * caps_test_rig_model = &caps_test.rig_model
void * caps_test_macro_name = &caps_test.macro_name

Detailed Description

Ham Radio Control Libraries interface.

Author
Stephane Fillod
Frank Singleton
Date
2000-2012

Hamlib provides a user-callable API, a set of "front-end" routines that call rig-specific "back-end" routines which actually communicate with the physical rig.

Function Documentation

◆ rig_data_pointer()

void * rig_data_pointer ( RIG * rig,
rig_ptrx_t idx )

Get the address of a Hamlib data structure.

Parameters
rigPointer to main data anchor
idxenum for which pointer requested

Get the address of a structure without relying on changeable internal data organization.

Return values
Theaddress of the enumed structure, NULL if error

Note: This is meant for use by the HAMLIB_???PORT macros mostly. Only compatibility with them is supported.

See also
amp_data_pointer(), rot_data_pointer()
Here is the call graph for this function:

◆ rig_send_raw()

int rig_send_raw ( RIG * rig,
const unsigned char * send,
int send_len,
unsigned char * reply,
int reply_len,
unsigned char * term )

Send verbatim data.

reply_len should be max bytes expected + 1

If term is NULL then will read reply_len bytes exactly and reply will not be '\0' terminated.

Parameters
rigThe rig handle
sendThe buffer containing the data to be sent
send_lenThe length of send buffer
replyThe buffer that will contain the data to be received
reply_lenThe length of the reply buffer
termThe optional 1-char string that will terminate the read
Returns
the number of bytes read if the operation has been successful, otherwise a negative value if an error occurred (in which case, cause is set appropriately).
Here is the call graph for this function: