static int netrigctl_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch) { int ret, len; char cmd[CMD_MAX]; char buf[BUF_MAX]; rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__); len = sprintf(cmd, "g %s %d\n", rig_strscan(scan), ch); ret = netrigctl_transaction(rig, cmd, len, buf); if (ret > 0) return -RIG_EPROTO; else return ret; }
static int netrigctl_set_powerstat(RIG *rig, powerstat_t status) { int ret, len; char cmd[CMD_MAX]; char buf[BUF_MAX]; rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__); len = sprintf(cmd, "\\set_powerstat %d\n", status); ret = netrigctl_transaction(rig, cmd, len, buf); if (ret > 0) return -RIG_EPROTO; else return ret; }
static int netrigctl_set_bank(RIG *rig, vfo_t vfo, int bank) { int ret, len; char cmd[CMD_MAX]; char buf[BUF_MAX]; rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__); len = sprintf(cmd, "B %d\n", bank); ret = netrigctl_transaction(rig, cmd, len, buf); if (ret > 0) return -RIG_EPROTO; else return ret; }
/* * The same for incomplete commands. */ static int ft817_send_icmd(RIG *rig, int index, unsigned char *data) { struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; unsigned char cmd[YAESU_CMD_LENGTH]; if (p->pcs[index].ncomp == 1) { rig_debug(RIG_DEBUG_VERBOSE, "ft817: Complete sequence\n"); return -RIG_EINTERNAL; } cmd[YAESU_CMD_LENGTH - 1] = p->pcs[index].nseq[YAESU_CMD_LENGTH - 1]; memcpy(cmd, data, YAESU_CMD_LENGTH - 1); write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH); return ft817_read_ack(rig); }
/** * \brief Release lock on Parallel Port * \param port * \return RIG_OK or < 0 */ int HAMLIB_API par_unlock(hamlib_port_t *port) { #ifdef HAVE_LINUX_PPDEV_H if (ioctl(port->fd, PPRELEASE) < 0) { rig_debug(RIG_DEBUG_ERR, "Releasing device \"%s\": %s\n", port->pathname, strerror(errno)); return -RIG_EIO; } return RIG_OK; #elif defined(HAVE_DEV_PPBUS_PPI_H) return RIG_OK; #elif defined(WIN32) return RIG_OK; #else return -RIG_ENIMPL; #endif }
static char mode_to_char(rmode_t mode) { switch (mode) { case RIG_MODE_CW: return(MD_CW); case RIG_MODE_CWR: return(MD_CWR); case RIG_MODE_USB: return(MD_USB); case RIG_MODE_LSB: return(MD_LSB); case RIG_MODE_FM: return(MD_FM); case RIG_MODE_AM: return(MD_AM); case RIG_MODE_RTTY: return(MD_FSK); case RIG_MODE_RTTYR: return(MD_FSKR); default: rig_debug(RIG_DEBUG_WARN,"ts570_mode_to_char %s: unsupported mode %d\n", __func__,mode); } return(RIG_MODE_NONE); }
int ft817_init (RIG *rig) { struct ft817_priv_data *p; rig_debug (RIG_DEBUG_VERBOSE,"ft817: ft817_init called \n"); if ((p = calloc(1, sizeof(struct ft817_priv_data))) == NULL) return -RIG_ENOMEM; /* Copy complete native cmd set to private cmd storage area */ memcpy(p->pcs, ncmd, sizeof(ncmd)); rig->state.priv = (void*) p; return RIG_OK; }
static int netrigctl_send_morse(RIG *rig, vfo_t vfo, const char *msg) { int ret, len; char cmd[CMD_MAX]; char buf[BUF_MAX]; rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__); len = sprintf(cmd, "\\send_morse %s\n", msg); ret = netrigctl_transaction(rig, cmd, len, buf); if (ret > 0) return -RIG_EPROTO; else return ret; }
static int netrigctl_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) { int ret, len; char cmd[CMD_MAX]; char buf[BUF_MAX]; rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__); len = sprintf(cmd, "J %s\n", rig_strvfop(op)); ret = netrigctl_transaction(rig, cmd, len, buf); if (ret > 0) return -RIG_EPROTO; else return ret; }
/** * \brief set all channel and non-channel data * \param rig The rig handle * \param chans Channel data * \param cfgps ?? * \param vals ?? * * Writes the data associated with all the memory channels, * and rigs memory parameters. * * \return RIG_OK if the operation has been sucessful, otherwise * a negative value if an error occured (in which case, cause is * set appropriately). * * \sa rig_get_mem_all(), rig_set_mem_all_cb() * * \todo set all parm's * \todo finish coding and testing of mem_all functions */ int HAMLIB_API rig_set_mem_all(RIG *rig, const channel_t chans[], const struct confparams cfgps[], const value_t vals[]) { struct rig_caps *rc; int retval; struct map_all_s mem_all_arg; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); if (CHECK_RIG_ARG(rig) || !chans || !cfgps || !vals) { return -RIG_EINVAL; } rc = rig->caps; mem_all_arg.chans = (channel_t *) chans; mem_all_arg.cfgps = cfgps; mem_all_arg.vals = (value_t *) vals; if (rc->set_mem_all_cb) return rc->set_mem_all_cb(rig, map_chan, map_parm, (rig_ptr_t)&mem_all_arg); /* if not available, emulate it */ retval = rig_set_chan_all(rig, chans); if (retval != RIG_OK) { return retval; } #if 0 retval = rig_set_parm_all(rig, parms); if (retval != RIG_OK) { return retval; } #else return -RIG_ENIMPL; #endif return retval; }
/* * aor_set_level * Assumes rig!=NULL, rig->state.priv!=NULL */ int aor_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { struct rig_state *rs; char lvlbuf[BUFSZ]; int lvl_len; unsigned i; int agc; rs = &rig->state; switch (level) { case RIG_LEVEL_ATT: { unsigned att = 0; for (i=0; i<MAXDBLSTSIZ && !RIG_IS_DBLST_END(rs->attenuator[i]); i++) { if (rs->attenuator[i] == val.i) { att = i+1; break; } } /* should be caught by the front end */ if ((val.i != 0) & (i>=MAXDBLSTSIZ || RIG_IS_DBLST_END(rs->attenuator[i])) ) return -RIG_EINVAL; lvl_len = sprintf(lvlbuf, "AT%u" EOM, att); break; } case RIG_LEVEL_AGC: /* AR5000 & AR5000A */ switch(val.i) { case RIG_AGC_FAST: agc = '0'; break; case RIG_AGC_MEDIUM: agc = '1'; break; case RIG_AGC_SLOW: agc = '2'; break; case RIG_AGC_OFF: default: agc = 'F'; } lvl_len = sprintf(lvlbuf,"AC%c" EOM, agc); break; default: rig_debug(RIG_DEBUG_ERR,"Unsupported aor_set_level %d\n", level); return -RIG_EINVAL; } return aor_transaction (rig, lvlbuf, lvl_len, NULL, NULL); }
static int thd72_set_mem(RIG *rig, vfo_t vfo, int ch) { int retval; char c, cmd[10]; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); retval = thd72_vfoc(rig, vfo, &c); if (retval != RIG_OK) { return retval; } sprintf(cmd, "MR %c,%03d", c, ch); return kenwood_simple_transaction(rig, cmd, 10); }
static int thd72_get_mem(RIG *rig, vfo_t vfo, int *ch) { int retval; char c, cmd[10], buf[10]; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); retval = thd72_vfoc(rig, vfo, &c); if (retval != RIG_OK) return retval; sprintf(cmd, "MR %c", c); retval = kenwood_transaction(rig, cmd, buf, sizeof (buf)); if (retval != RIG_OK) return retval; sscanf(buf+5, "%d", ch); return RIG_OK; }
int ft100_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) { struct ft100_priv_data *priv = (struct ft100_priv_data*)rig->state.priv; int ret; rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __func__); if( !split ) return -RIG_EINVAL; ret = ft100_read_flags(rig); if (ret < 0) return ret; *split = (priv->flags.byte[0] & 0x01) == 0x01 ? RIG_SPLIT_ON : RIG_SPLIT_OFF; return RIG_OK; }
int ft897_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { int index; /* index of sequence to send */ if (vfo != RIG_VFO_CURR) return -RIG_ENTARGET; rig_debug(RIG_DEBUG_VERBOSE,"ft897: generic mode = %x \n", mode); switch(mode) { case RIG_MODE_AM: index = FT897_NATIVE_CAT_SET_MODE_AM; break; case RIG_MODE_CW: index = FT897_NATIVE_CAT_SET_MODE_CW; break; case RIG_MODE_USB: index = FT897_NATIVE_CAT_SET_MODE_USB; break; case RIG_MODE_LSB: index = FT897_NATIVE_CAT_SET_MODE_LSB; break; case RIG_MODE_RTTY: index = FT897_NATIVE_CAT_SET_MODE_DIG; break; case RIG_MODE_FM: index = FT897_NATIVE_CAT_SET_MODE_FM; break; case RIG_MODE_WFM: index = FT897_NATIVE_CAT_SET_MODE_FM; break; case RIG_MODE_CWR: index = FT897_NATIVE_CAT_SET_MODE_CWR; break; case RIG_MODE_PKTFM: index = FT897_NATIVE_CAT_SET_MODE_PKT; break; default: return -RIG_EINVAL; } if (width != RIG_PASSBAND_NORMAL) return -RIG_EINVAL; return ft897_send_cmd(rig, index); }
/* * gp2000_set_freq * Assumes rig!=NULL */ int gp2000_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { char freqbuf[32]; int freq_len, retval; rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s,freq=%.0f\n", __func__, rig_strvfo(vfo), freq); freq_len = snprintf(freqbuf, sizeof(freqbuf), BOM "F%" PRIll ",%" PRIll EOM, (int64_t) freq, (int64_t) freq); retval = gp2000_transaction(rig, freqbuf, freq_len, NULL, NULL); return retval; }
int ft817_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { unsigned char data[YAESU_CMD_LENGTH - 1]; if (vfo != RIG_VFO_CURR) return -RIG_ENTARGET; rig_debug(RIG_DEBUG_VERBOSE,"ft817: requested freq = %"PRIfreq" Hz\n", freq); /* fill in the frequency */ to_bcd_be(data, (freq + 5) / 10, 8); rig_force_cache_timeout( &((struct ft817_priv_data *)rig->state.priv)->fm_status_tv); return ft817_send_icmd(rig, FT817_NATIVE_CAT_SET_FREQ, data); }
int pcr_set_trn(RIG * rig, int trn) { struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv; rig_debug(RIG_DEBUG_VERBOSE, "%s: trn = %d\n", __func__, trn); if (trn == RIG_TRN_OFF) { priv->auto_update = 0; return pcr_transaction(rig, "G300"); } else if (trn == RIG_TRN_RIG) { priv->auto_update = 1; return pcr_send(rig, "G301"); } else return -RIG_EINVAL; }
static int thd72_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *offs) { int retval; char buf[64]; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); retval = thd72_get_freq_info(rig, vfo, buf); if (retval != RIG_OK) { return retval; } sscanf(buf + 42, "%ld", offs); return RIG_OK; }
static int netrigctl_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) { int ret, len; char cmd[CMD_MAX]; char buf[BUF_MAX]; rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__); len = sprintf(cmd, "X %s %li\n", rig_strrmode(tx_mode), tx_width); ret = netrigctl_transaction(rig, cmd, len, buf); if (ret > 0) return -RIG_EPROTO; else return ret; }
static int thd72_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { int retval, modeinx; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); retval = thd72_get_freq_item(rig, vfo, 51, 2, &modeinx); if (retval != RIG_OK) { return retval; } *mode = thd72_mode_table[modeinx]; *width = thd72_width_table[modeinx]; return RIG_OK; }
static int thd72_get_rptr_shft(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift) { int retval, rsinx; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); retval = thd72_get_freq_item(rig, vfo, 18, 3, &rsinx); if (retval != RIG_OK) { return retval; } /* rsinx == 3 indicates split mode? */ *rptr_shift = (rsinx == 3) ? RIG_RPT_SHIFT_NONE : thd72_rshf_table[rsinx]; return RIG_OK; }
static int thd72_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { int retval; char buf[64]; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); retval = thd72_get_freq_info(rig, vfo, buf); if (retval != RIG_OK) { return retval; } sscanf(buf + 5, "%"SCNfreq, freq); return RIG_OK; }
static int thd72_get_freq_info(RIG *rig, vfo_t vfo, char *buf) { int retval; char c, cmd[8]; rig_debug(RIG_DEBUG_TRACE, "%s: called VFO=%s\n", __func__, rig_strvfo(vfo)); retval = thd72_vfoc(rig, vfo, &c); if (retval != RIG_OK) { return retval; } sprintf(cmd, "FO %c", c); retval = kenwood_transaction(rig, cmd, buf, 53); return RIG_OK; }
int barrett_cleanup(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); if (!rig) { return -RIG_EINVAL; } if (rig->state.priv) { free(rig->state.priv); } rig->state.priv = NULL; return RIG_OK; }
static int thd72_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts) { int tsinx; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); for (tsinx = 0; tsinx < 10; tsinx++) { if (thd72tuningstep[tsinx] >= ts) { thd72_set_freq_item(rig, vfo, 16, tsinx); return RIG_OK; } } return -RIG_EINVAL; }
/** * \brief set all channel and non-channel data by call-back * \param rig The rig handle * \param chan_cb The callback for channel data * \param parm_cb The callback for non-channel(aka parm) data * \param arg Cookie passed to \a chan_cb and \a parm_cb * * Writes the data associated with all the memory channels, * and rigs memory parameters, by callback. * This is the preferred method to support clonable rigs. * * \return RIG_OK if the operation has been sucessful, otherwise * a negative value if an error occured (in which case, cause is * set appropriately). * * \sa rig_get_mem_all_cb(), rig_set_mem_all() * \todo finish coding and testing of mem_all functions */ int HAMLIB_API rig_set_mem_all_cb(RIG *rig, chan_cb_t chan_cb, confval_cb_t parm_cb, rig_ptr_t arg) { struct rig_caps *rc; int retval; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); if (CHECK_RIG_ARG(rig) || !chan_cb) { return -RIG_EINVAL; } rc = rig->caps; if (rc->set_mem_all_cb) { return rc->set_mem_all_cb(rig, chan_cb, parm_cb, arg); } /* if not available, emulate it */ retval = rig_set_chan_all_cb(rig, chan_cb, arg); if (retval != RIG_OK) { return retval; } #if 0 retval = rig_set_parm_all_cb(rig, parm_cb, arg); if (retval != RIG_OK) { return retval; } #else return -RIG_ENIMPL; #endif return retval; }
/** * \brief set the current memory channel number * \param rig The rig handle * \param vfo The target VFO * \param ch The memory channel number * * Sets the current memory channel number. * It is not mandatory for the radio to be in memory mode. Actually * it depends on rigs. YMMV. * * \return RIG_OK if the operation has been sucessful, otherwise * a negative value if an error occured (in which case, cause is * set appropriately). * * \sa rig_get_mem() */ int HAMLIB_API rig_set_mem(RIG *rig, vfo_t vfo, int ch) { const struct rig_caps *caps; int retcode; vfo_t curr_vfo; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); if (CHECK_RIG_ARG(rig)) { return -RIG_EINVAL; } caps = rig->caps; if (caps->set_mem == NULL) { return -RIG_ENAVAIL; } if ((caps->targetable_vfo & RIG_TARGETABLE_PURE) || vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) { return caps->set_mem(rig, vfo, ch); } if (!caps->set_vfo) { return -RIG_ENTARGET; } curr_vfo = rig->state.current_vfo; retcode = caps->set_vfo(rig, vfo); if (retcode != RIG_OK) { return retcode; } retcode = caps->set_mem(rig, vfo, ch); caps->set_vfo(rig, curr_vfo); return retcode; }
/** * \brief Get a lock on the Parallel Port * \param port * \return RIG_OK or < 0 */ int HAMLIB_API par_lock(hamlib_port_t *port) { #ifdef HAVE_LINUX_PPDEV_H if (ioctl(port->fd, PPCLAIM) < 0) { rig_debug(RIG_DEBUG_ERR, "Claiming device \"%s\": %s\n", port->pathname, strerror(errno)); return -RIG_EIO; } return RIG_OK; #elif defined(HAVE_DEV_PPBUS_PPI_H) return RIG_OK; #elif defined(__WIN64__) || defined(__WIN32__) return RIG_OK; #else return -RIG_ENIMPL; #endif }
int ft857_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift) { if (vfo != RIG_VFO_CURR) return -RIG_ENTARGET; rig_debug(RIG_DEBUG_VERBOSE, "ft857: set repeter shift = %i\n", shift); switch (shift) { case RIG_RPT_SHIFT_NONE: return ft857_send_cmd(rig, FT857_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX); case RIG_RPT_SHIFT_MINUS: return ft857_send_cmd(rig, FT857_NATIVE_CAT_SET_RPT_SHIFT_MINUS); case RIG_RPT_SHIFT_PLUS: return ft857_send_cmd(rig, FT857_NATIVE_CAT_SET_RPT_SHIFT_PLUS); } return -RIG_EINVAL; }