bool rigControl::setMode(QString mode) { QString orgMode; int i; int pos=-1; if(catParams.enableXMLRPC) { orgMode=xmlIntfPtr->getMode(); for(i=0;i<xmlModes.count();i++) { pos=orgMode.indexOf(xmlModes.at(i),Qt::CaseInsensitive); if(pos>=0) { orgMode.replace(xmlModes.at(i),mode); break; } } if(pos>=0) xmlIntfPtr->setMode(orgMode); } else { rmode_t rmode=rig_parse_mode(mode.toLatin1().data()); int retcode; if(!rigControlEnabled) return false; retcode = rig_set_mode(my_rig, RIG_VFO_CURR, rmode, rig_passband_normal(my_rig,rmode)); if (retcode != RIG_OK ) {errorMessage(retcode,"setMode"); return false; } } return true; }
static int netrigctl_get_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\n"); ret = netrigctl_transaction(rig, cmd, len, buf); if (ret <= 0) return (ret < 0) ? ret : -RIG_EPROTO; if (ret > 0 && buf[ret-1]=='\n') buf[ret-1] = '\0'; /* chomp */ *tx_mode = rig_parse_mode(buf); ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); if (ret <= 0) return (ret < 0) ? ret : -RIG_EPROTO; *tx_width = atoi(buf); return RIG_OK; }
/* * gp2000_get_mode * Assumes rig!=NULL */ int gp2000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { char buf[RESPSZ]; int buf_len, retval; rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo)); #define DEM_QUERY BOM "I?" EOM retval = gp2000_transaction(rig, DEM_QUERY, strlen(DEM_QUERY), buf, &buf_len); if (retval < 0) { return retval; } int nmode; char *pmode = "UNKNOWN"; int n = sscanf(buf, "%*cI%d", &nmode); if (n != 1) { return -RIG_EPROTO; } switch (nmode) { case 1: pmode = "AM"; break; case 2: pmode = "USB"; break; case 3: pmode = "LSB"; break; case 5: pmode = "CW"; break; case 9: pmode = "FM"; break; case 13: pmode = "PKTUSB"; break; case 14: pmode = "PKTLSB"; break; } *mode = rig_parse_mode(pmode); #define BAND_QUERY BOM "W?" EOM retval = gp2000_transaction(rig, BAND_QUERY, strlen(BAND_QUERY), buf, &buf_len); if (retval < 0) { return retval; } *width = atoi(&buf[2]); return retval; }
/* * rs_get_mode * Assumes rig!=NULL */ int rs_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { char buf[RESPSZ]; int buf_len, retval; #define DEM_QUERY BOM "DEM?" EOM retval = rs_transaction(rig, DEM_QUERY, strlen(DEM_QUERY), buf, &buf_len); if (retval < 0) return retval; *mode = rig_parse_mode(buf); #define BAND_QUERY BOM "BAND?" EOM retval = rs_transaction(rig, BAND_QUERY, strlen(BAND_QUERY), buf, &buf_len); if (retval < 0) return retval; *width = atoi(buf); return retval; }
/** Function to parse a line read from csv file and store the data into appropriate fields of channel_t. The function must be consistent with dump_csv_name and dump_csv_chan. \param rig - a pointer to the rig \param chan - a pointer to channel_t structure with channel data \param line_key_list - a pointer to a table of strings with "keys" \param line_data_list - a pointer to a table of strings with values \return 0 on success, negative value on error */ int set_channel_data(RIG *rig, channel_t *chan, char **line_key_list, char **line_data_list) { int i, j, n; memset(chan, 0, sizeof(channel_t)); chan->vfo = RIG_VFO_CURR; i = find_on_list(line_key_list, "num"); if (i < 0) { fprintf(stderr, "No channel number\n"); return -1; } n = chan->channel_num = atoi(line_data_list[ i ]); /* find chanel caps of appropriate memory group? */ for (j = 0; j < CHANLSTSIZ; j++) { if (rig->state.chan_list[j].start <= n && rig->state.chan_list[j].end >= n) { break; } } printf("Requested channel number %d, list number %d\n", n, j); const channel_cap_t *mem_caps = &rig->state.chan_list[j].mem_caps; if (mem_caps->bank_num) { i = find_on_list(line_key_list, "bank_num"); if (i >= 0) { chan->bank_num = atoi(line_data_list[ i ]); } } if (mem_caps->channel_desc) { i = find_on_list(line_key_list, "channel_desc"); if (i >= 0) { strncpy(chan->channel_desc, line_data_list[ i ], rig->caps->chan_desc_sz - 1); chan->channel_desc[ rig->caps->chan_desc_sz ] = '\0'; } } if (mem_caps->ant) { i = find_on_list(line_key_list, "ant"); if (i >= 0) { chan->ant = atoi(line_data_list[ i ]); } } if (mem_caps->freq) { i = find_on_list(line_key_list, "freq"); if (i >= 0) { chan->freq = atoi(line_data_list[ i ]); } } if (mem_caps->mode) { i = find_on_list(line_key_list, "mode"); if (i >= 0) { chan->mode = rig_parse_mode(line_data_list[ i ]); } } if (mem_caps->width) { i = find_on_list(line_key_list, "width"); if (i >= 0) { chan->width = atoi(line_data_list[ i ]); } } if (mem_caps->tx_freq) { i = find_on_list(line_key_list, "tx_freq"); if (i >= 0) { sscanf(line_data_list[i], "%"SCNfreq, &chan->tx_freq); } } if (mem_caps->tx_mode) { i = find_on_list(line_key_list, "tx_mode"); if (i >= 0) { chan->tx_mode = rig_parse_mode(line_data_list[ i ]); } } if (mem_caps->tx_width) { i = find_on_list(line_key_list, "tx_width"); if (i >= 0) { chan->tx_width = atoi(line_data_list[ i ]); } } if (mem_caps->split) { chan->split = RIG_SPLIT_OFF; i = find_on_list(line_key_list, "split"); if (i >= 0) { if (strcmp(line_data_list[i], "on") == 0) { chan->split = RIG_SPLIT_ON; if (mem_caps->tx_vfo) { i = find_on_list(line_key_list, "tx_vfo"); if (i >= 0) { sscanf(line_data_list[i], "%x", &chan->tx_vfo); } } } } } if (mem_caps->rptr_shift) { i = find_on_list(line_key_list, "rptr_shift"); if (i >= 0) { switch (line_data_list[i][0]) { case '=': chan->rptr_shift = RIG_RPT_SHIFT_NONE; break; case '+': chan->rptr_shift = RIG_RPT_SHIFT_PLUS; break; case '-': chan->rptr_shift = RIG_RPT_SHIFT_MINUS; break; } if (mem_caps->rptr_offs && chan->rptr_shift != RIG_RPT_SHIFT_NONE) { i = find_on_list(line_key_list, "rptr_offs"); if (i >= 0) { chan->rptr_offs = atoi(line_data_list[ i ]); } } } } if (mem_caps->tuning_step) { i = find_on_list(line_key_list, "tuning_step"); if (i >= 0) { chan->tuning_step = atoi(line_data_list[ i ]); } } if (mem_caps->rit) { i = find_on_list(line_key_list, "rit"); if (i >= 0) { chan->rit = atoi(line_data_list[ i ]); } } if (mem_caps->xit) { i = find_on_list(line_key_list, "xit"); if (i >= 0) { chan->xit = atoi(line_data_list[ i ]); } } if (mem_caps->funcs) { i = find_on_list(line_key_list, "funcs"); if (i >= 0) { sscanf(line_data_list[i], "%"SCNXll, &chan->funcs); } } if (mem_caps->ctcss_tone) { i = find_on_list(line_key_list, "ctcss_tone"); if (i >= 0) { chan->ctcss_tone = atoi(line_data_list[ i ]); } } if (mem_caps->ctcss_sql) { i = find_on_list(line_key_list, "ctcss_sql"); if (i >= 0) { chan->ctcss_sql = atoi(line_data_list[ i ]); } } if (mem_caps->dcs_code) { i = find_on_list(line_key_list, "dcs_code"); if (i >= 0) { chan->dcs_code = atoi(line_data_list[ i ]); } } if (mem_caps->dcs_sql) { i = find_on_list(line_key_list, "dcs_sql"); if (i >= 0) { chan->dcs_sql = atoi(line_data_list[ i ]); } } if (mem_caps->scan_group) { i = find_on_list(line_key_list, "scan_group"); if (i >= 0) { chan->scan_group = atoi(line_data_list[ i ]); } } if (mem_caps->flags) { i = find_on_list(line_key_list, "flags"); if (i >= 0) { sscanf(line_data_list[i], "%x", &chan->flags); } } return 0; }