int sprintf_mode(char *str, rmode_t mode) { int i, len = 0; *str = '\0'; if (mode == RIG_MODE_NONE) { return 0; } for (i = 0; i < 30; i++) { const char *ms = rig_strrmode(mode & (1UL << i)); if (!ms || !ms[0]) { continue; /* unknown, FIXME! */ } strcat(str, ms); strcat(str, " "); len += strlen(ms) + 1; } return len; }
static int flex6k_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); if (!rig) return -RIG_EINVAL; struct kenwood_priv_caps *caps = kenwood_caps(rig); char buf[10]; char kmode; int idx; int err; kmode = rmode2kenwood(mode, caps->mode_table); if (kmode < 0 ) { rig_debug(RIG_DEBUG_WARN, "%s: unsupported mode '%s'\n", __func__, rig_strrmode(mode)); return -RIG_EINVAL; } sprintf(buf, "MD%c", '0' + kmode); err = kenwood_simple_cmd(rig, buf); if (err != RIG_OK) return err; err = flex6k_find_width(mode, width, &idx); if (err != RIG_OK) return err; if ((vfo == RIG_VFO_VFO) || (vfo == RIG_VFO_CURR)) { vfo = rig->state.current_vfo; rig_debug(RIG_DEBUG_VERBOSE, "%s: setting VFO to current\n", __func__); } /* * The Flex CAT interface does not support FW for reading filter width, * so use the ZZFI or ZZFJ command */ switch (vfo) { case RIG_VFO_A: sprintf(buf, "ZZFI%02d;", idx); break; case RIG_VFO_B: sprintf(buf, "ZZFJ%02d;", idx); break; default: rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); return -RIG_EINVAL; } err = kenwood_simple_cmd(rig, buf); if (err != RIG_OK) return err; return RIG_OK; }
/* * barrett_get_mode * Assumes rig!=NULL * Note that 2050 does not have set or get width */ int barrett_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __FUNCTION__, rig_strvfo(vfo)); char *result = NULL; int retval = barrett_transaction(rig, "IB", 0, &result); if (retval != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s: bad response=%s\n", __FUNCTION__, result); return retval; } //dump_hex((unsigned char *)result,strlen(result)); switch (result[1]) { case 'L': *mode = RIG_MODE_LSB; break; case 'U': *mode = RIG_MODE_USB; break; case 'A': *mode = RIG_MODE_AM; break; case 'F': *mode = RIG_MODE_RTTY; break; case 'C': *mode = RIG_MODE_CW; break; default: rig_debug(RIG_DEBUG_ERR, "%s: Unknown mode='%c%c'\n", __FUNCTION__, result[0], result[1]); return -RIG_EPROTO; } *width = 3000; // we'll default this to 3000 for now rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s mode=%s width=%d\n", __FUNCTION__, rig_strvfo(vfo), rig_strrmode(*mode), *width); 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; }
bool rigControl::getMode(QString &mode) { if(catParams.enableXMLRPC) { mode =xmlIntfPtr->getMode(); } else { rmode_t rmode; pbwidth_t width; int retcode; if(!rigControlEnabled) return false; retcode = rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); if (retcode != RIG_OK ) {errorMessage(retcode,"getMode"); return false; } mode=QString(rig_strrmode(rmode)); } return true; }
/* * th_set_mode * Assumes rig!=NULL */ int th_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { char kmode, mdbuf[8]; int retval; const struct kenwood_priv_caps *priv=(const struct kenwood_priv_caps *)rig->caps->priv; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); if (vfo != RIG_VFO_CURR && vfo != rig->state.current_vfo) return kenwood_wrong_vfo(__func__, vfo); if (priv->mode_table) { kmode = rmode2kenwood(mode, priv->mode_table); if (kmode == -1) { rig_debug(RIG_DEBUG_WARN, "%s: Unsupported Mode value '%s'\n", __func__, rig_strrmode(mode)); return -RIG_EINVAL; } kmode += '0'; } else { switch (mode) { case RIG_MODE_FM: kmode = '0'; break; /* TH-D7A(G) modes */ case RIG_MODE_AM: kmode = '1'; break; default: rig_debug(RIG_DEBUG_ERR, "%s: Unsupported Mode %d\n", __func__, mode); return -RIG_EINVAL; } } sprintf(mdbuf, "MD %c", kmode); retval = kenwood_cmd(rig, mdbuf); if (retval != RIG_OK) return retval; return RIG_OK; }
int main(int argc, char *argv[]) { RIG *my_rig; /* handle to rig (nstance) */ freq_t freq; /* frequency */ rmode_t rmode; /* radio mode of operation */ pbwidth_t width; vfo_t vfo; /* vfo selection */ int strength; /* S-Meter level */ int rit = 0; /* RIT status */ int xit = 0; /* XIT status */ int retcode; /* generic return code from functions */ rig_model_t myrig_model; printf("testrig: Hello, I am your main() !\n"); /* Turn off backend debugging ouput */ rig_set_debug_level(RIG_DEBUG_NONE); /* * allocate memory, setup & open port */ if (argc < 2) { hamlib_port_t myport; /* may be overriden by backend probe */ myport.type.rig = RIG_PORT_SERIAL; myport.parm.serial.rate = 9600; myport.parm.serial.data_bits = 8; myport.parm.serial.stop_bits = 1; myport.parm.serial.parity = RIG_PARITY_NONE; myport.parm.serial.handshake = RIG_HANDSHAKE_NONE; strncpy(myport.pathname, SERIAL_PORT, FILPATHLEN - 1); rig_load_all_backends(); myrig_model = rig_probe(&myport); } else { myrig_model = atoi(argv[1]); } my_rig = rig_init(myrig_model); if (!my_rig) { fprintf(stderr, "Unknown rig num: %d\n", myrig_model); fprintf(stderr, "Please check riglist.h\n"); exit(1); /* whoops! something went wrong (mem alloc?) */ } strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, FILPATHLEN - 1); retcode = rig_open(my_rig); if (retcode != RIG_OK) { printf("rig_open: error = %s\n", rigerror(retcode)); exit(2); } printf("Port %s opened ok\n", SERIAL_PORT); /* * Below are examples of set/get routines. * Must add checking of functionality map prior to command execution -- FS * */ /* * Example of setting rig paameters * and some error checking on the return code. */ retcode = rig_set_vfo(my_rig, RIG_VFO_B); if (retcode != RIG_OK) { printf("rig_set_vfo: error = %s \n", rigerror(retcode)); } /* * Lets try some frequencies and modes. Return code is not checked. * Examples of checking return code are further down. * */ /* 10m FM Narrow */ printf("\nSetting 10m FM Narrow...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 29620000); /* 10m */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_FM, rig_passband_narrow(my_rig, RIG_MODE_FM)); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n", freq / 1000000, rig_strrmode(rmode), width / 1000.0); sleep(1); /* so you can see it -- FS */ /* 15m USB */ printf("Setting 15m USB...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 21235175); /* 15m */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_USB, rig_passband_normal(my_rig, RIG_MODE_USB)); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n", freq / 1000000, rig_strrmode(rmode), width / 1000.0); sleep(1); /* 40m LSB */ printf("Setting 40m LSB...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 7250100); /* 40m */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_LSB, RIG_PASSBAND_NORMAL); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n", freq / 1000000, rig_strrmode(rmode), width / 1000.0); sleep(1); /* 80m AM Narrow */ printf("Setting 80m AM Narrow...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 3885000); /* 80m */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_AM, rig_passband_narrow(my_rig, RIG_MODE_AM)); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n", freq / 1000000, rig_strrmode(rmode), width / 1000.0); sleep(1); /* 160m CW Normal */ printf("Setting 160m CW...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 1875000); /* 160m */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_CW, RIG_PASSBAND_NORMAL); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.3f kHz, Mode: %s, Passband: %li Hz\n\n", freq / 1000, rig_strrmode(rmode), width); sleep(1); /* 160m CW Narrow -- The band is noisy tonight -- FS*/ printf("Setting 160m CW Narrow...\n"); retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_CW, rig_passband_narrow(my_rig, RIG_MODE_CW)); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.3f kHz, Mode: %s, Passband: %li Hz\n\n", freq / 1000, rig_strrmode(rmode), width); sleep(1); /* AM Broadcast band */ printf("Setting Medium Wave AM...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 770000); /* KAAM */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_AM, RIG_PASSBAND_NORMAL); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.3f kHz, Mode: %s, Passband: %.3f kHz\n\n", freq / 1000, rig_strrmode(rmode), width / 1000.0); sleep(1); /* 20m USB on VFO_A */ printf("Setting 20m on VFO A with two functions...\n"); retcode = rig_set_vfo(my_rig, RIG_VFO_A); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 14250375); /* cq de vk3fcs */ if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_vfo(my_rig, &vfo); printf(" Freq: %.6f MHz, VFO: %s\n\n", freq / 1000000, rig_strvfo(vfo)); sleep(1); /* 20m USB on VFO_A , with only 1 call */ printf("Setting 20m on VFO A with one function...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_A, 14295125); /* cq de vk3fcs */ if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_vfo(my_rig, &vfo); printf(" Freq: %.6f MHz, VFO: %s\n\n", freq / 1000000, rig_strvfo(vfo)); sleep(1); #if 0 retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 145100000); /* 2m */ sleep(2); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 435125000); /* 70cm */ sleep(2); #endif printf("Setting rig Mode to LSB.\n"); retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_LSB, RIG_PASSBAND_NORMAL); if (retcode != RIG_OK) { printf("rig_set_mode: error = %s \n", rigerror(retcode)); } sleep(1); printf("Setting rig PTT ON.\n"); retcode = rig_set_ptt(my_rig, RIG_VFO_A, RIG_PTT_ON); /* stand back ! */ if (retcode != RIG_OK) { printf("rig_set_ptt: error = %s \n", rigerror(retcode)); } sleep(1); printf("Setting rig PTT OFF.\n"); retcode = rig_set_ptt(my_rig, RIG_VFO_A, RIG_PTT_OFF); /* phew ! */ if (retcode != RIG_OK) { printf("rig_set_ptt: error = %s \n", rigerror(retcode)); } sleep(1); /* * Simple examples of getting rig information -- FS * */ printf("\nGet various raw rig values:\n"); retcode = rig_get_vfo(my_rig, &vfo); /* try to get vfo info */ if (retcode == RIG_OK) { printf("rig_get_vfo: vfo = %i \n", vfo); } else { printf("rig_get_vfo: error = %s \n", rigerror(retcode)); } retcode = rig_get_freq(my_rig, RIG_VFO_CURR, &freq); if (retcode == RIG_OK) { printf("rig_get_freq: freq = %"PRIfreq"\n", freq); } else { printf("rig_get_freq: error = %s \n", rigerror(retcode)); } retcode = rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); if (retcode == RIG_OK) { printf("rig_get_mode: mode = %"PRIll"\n", rmode); } else { printf("rig_get_mode: error = %s \n", rigerror(retcode)); } retcode = rig_get_strength(my_rig, RIG_VFO_CURR, &strength); if (retcode == RIG_OK) { printf("rig_get_strength: strength = %i \n", strength); } else { printf("rig_get_strength: error = %s \n", rigerror(retcode)); } if (rig_has_set_func(my_rig, RIG_FUNC_RIT)) { retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_RIT, 1); printf("rig_set_func: Setting RIT ON\n"); } if (rig_has_get_func(my_rig, RIG_FUNC_RIT)) { retcode = rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_RIT, &rit); printf("rig_get_func: RIT: %d\n", rit); } if (rig_has_set_func(my_rig, RIG_FUNC_XIT)) { retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_XIT, 1); printf("rig_set_func: Setting XIT ON\n"); } if (rig_has_get_func(my_rig, RIG_FUNC_XIT)) { retcode = rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_XIT, &xit); printf("rig_get_func: XIT: %d\n", xit); } rig_close(my_rig); /* close port */ rig_cleanup(my_rig); /* if you care about memory */ printf("port %s closed ok \n", SERIAL_PORT); return 0; }
int ft847_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { unsigned char cmd_index; /* index of sequence to send */ struct rig_state *rs = &rig->state; unsigned char p_cmd[YAESU_CMD_LENGTH]; /* sequence to send */ int ret; /* * translate mode from generic to ft847 specific */ rig_debug(RIG_DEBUG_VERBOSE,"ft847: generic mode = %x \n", mode); switch(mode) { case RIG_MODE_AM: cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_AM; break; case RIG_MODE_CW: cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_CW; break; case RIG_MODE_CWR: cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_CWR; break; case RIG_MODE_USB: cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_USB; break; case RIG_MODE_LSB: cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_LSB; break; case RIG_MODE_FM: cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_FM; break; default: return -RIG_EINVAL; /* sorry, wrong MODE */ } /* * Now set width */ if (width != RIG_PASSBAND_NOCHANGE) { if (width == rig_passband_narrow(rig, mode)) { switch(mode) { case RIG_MODE_AM: cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_AMN; break; case RIG_MODE_FM: cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_FMN; break; case RIG_MODE_CW: cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_CWN; break; case RIG_MODE_CWR: cmd_index = FT_847_NATIVE_CAT_SET_MODE_MAIN_CWRN; break; case RIG_MODE_USB: case RIG_MODE_LSB: break; default: rig_debug(RIG_DEBUG_ERR,"%s: unsupported mode/width: %s/%d, narrow: %d\n", __FUNCTION__, rig_strrmode(mode), width, rig_passband_narrow(rig, mode)); return -RIG_EINVAL; /* sorry, wrong MODE/WIDTH combo */ } } else { if (width != RIG_PASSBAND_NORMAL && width != rig_passband_normal(rig, mode)) { return -RIG_EINVAL; /* sorry, wrong MODE/WIDTH combo */ } } } /* * Now send the command */ ret = opcode_vfo(rig, p_cmd, cmd_index, vfo); if (ret != RIG_OK) return ret; return write_block(&rs->rigport, (char*)p_cmd, YAESU_CMD_LENGTH); }
int ts2000_set_channel(RIG *rig, const channel_t *chan) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); if (!rig || !chan) return -RIG_EINVAL; char buf[128]; char mode, tx_mode = 0; int err; int tone = 0; struct kenwood_priv_caps *caps = kenwood_caps(rig); mode = rmode2kenwood(chan->mode, caps->mode_table); if (mode < 0 ) { rig_debug(RIG_DEBUG_ERR, "%s: unsupported mode '%s'\n", __func__, rig_strrmode(chan->mode)); return -RIG_EINVAL; } if (chan->split == RIG_SPLIT_ON) { tx_mode = rmode2kenwood(chan->tx_mode, caps->mode_table); if (tx_mode < 0 ) { rig_debug(RIG_DEBUG_ERR, "%s: unsupported mode '%s'\n", __func__, rig_strrmode(chan->tx_mode)); return -RIG_EINVAL; } } /* find tone */ char sqltype = '0'; if (chan->ctcss_tone) { for (; rig->caps->ctcss_list[tone] != 0; tone++) { if (chan->ctcss_tone == rig->caps->ctcss_list[tone]) break; } if (chan->ctcss_tone != rig->caps->ctcss_list[tone]) tone = -1; else sqltype = '1'; }else{ tone = -1; /* -1 because we will add 1 when outputing; this is necessary as CTCSS codes are numbered from 1 */ } /* find CTCSS code */ short code = 0; if (chan->ctcss_sql) { for (; rig->caps->ctcss_list[code] != 0; code++) { if (chan->ctcss_sql == rig->caps->ctcss_list[code]) break; } if (chan->ctcss_sql != rig->caps->ctcss_list[code]) code = -1; else sqltype = '2'; }else{ code = -1; } /* find DCS code */ short dcscode = 0; if (chan->dcs_code) { for (; rig->caps->dcs_list[dcscode] != 0; dcscode++) { if (chan->dcs_code == rig->caps->dcs_list[dcscode]) break; } if (chan->dcs_code != rig->caps->dcs_list[dcscode]) dcscode = 0; else sqltype = '3'; }else{ dcscode = 0; } char shift = '0'; if( chan->rptr_shift == RIG_RPT_SHIFT_PLUS ){ shift = '1'; } if( chan->rptr_shift == RIG_RPT_SHIFT_MINUS ){ shift = '2'; } int tstep = 0; if( (chan->mode == RIG_MODE_AM) || (chan->mode == RIG_MODE_FM) ){ switch( chan->tuning_step ){ case s_kHz(6.25): tstep = 1; break; case s_kHz(10): tstep = 2; break; case s_kHz(12.5): tstep = 3; break; case s_kHz(15): tstep = 4; break; case s_kHz(20): tstep = 5; break; case s_kHz(25): tstep = 6; break; case s_kHz(30): tstep = 7; break; case s_kHz(50): tstep = 8; break; case s_kHz(100): tstep = 9; break; default: tstep = 0; } }else{ switch( chan->tuning_step ){ case s_kHz(2.5): tstep = 1; break; case s_kHz(5): tstep = 2; break; case s_kHz(10): tstep = 3; break; default: tstep = 0; } } /* P-number 2-3 4 5 6 7 8 9 101112 13 141516 */ snprintf(buf, sizeof(buf), "MW0%03d%011u%c%c%c%02d%02d%03d%c%c%09d0%c%c%s;", chan->channel_num, (unsigned) chan->freq, /* 4 - frequency */ '0' + mode, /* 5 - mode */ (chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0', /* 6 - lockout status */ sqltype, /* 7 - squelch and tone type */ tone+1, /* 8 - tone code */ code+1, /* 9 - CTCSS code */ dcscode, /* 10 - DCS code */ (chan->funcs & RIG_FUNC_REV ) ? '1' : '0',/* 11 - Reverse status */ shift, /* 12 - shift type */ (int) chan->rptr_offs, /* 13 - offset frequency */ tstep + '0', /* 14 - Step size */ chan->scan_group + '0', /* 15 - Memory group no */ chan->channel_desc /* 16 - description */ ); rig_debug( RIG_DEBUG_VERBOSE, "The command will be: %s\n", buf ); err = kenwood_transaction(rig, buf, NULL, 0); if (err != RIG_OK) return err; if( chan->split == RIG_SPLIT_ON ){ sprintf(buf, "MW1%03d%011u%c%c%c%02d%02d%03d%c%c%09d0%c%c%s;\n", chan->channel_num, (unsigned) chan->tx_freq, /* 4 - frequency */ '0' + tx_mode, /* 5 - mode */ (chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0', /* 6 - lockout status */ sqltype, /* 7 - squelch and tone type */ tone+1, /* 8 - tone code */ code+1, /* 9 - CTCSS code */ dcscode+1, /* 10 - DCS code */ (chan->funcs & RIG_FUNC_REV ) ? '1' : '0',/* 11 - Reverse status */ shift, /* 12 - shift type */ (int) chan->rptr_offs, /* 13 - offset frequency */ tstep + '0', /* 14 - Step size */ chan->scan_group + '0', /* Memory group no */ chan->channel_desc /* 16 - description */ ); rig_debug( RIG_DEBUG_VERBOSE, "Split, the command will be: %s\n", buf ); err = kenwood_transaction(rig, buf, NULL, 0); } return err; }
int pcr_set_mode(RIG * rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv; struct pcr_rcvr *rcvr = is_sub_rcvr(rig, vfo) ? &priv->sub_rcvr : &priv->main_rcvr; unsigned char buf[20]; int buf_len, err; int pcrmode, pcrfilter; rig_debug(RIG_DEBUG_VERBOSE, "%s: mode = %d (%s), width = %d\n", __func__, mode, rig_strrmode(mode), width); /* XXX? */ if (mode == RIG_MODE_NONE) mode = RIG_MODE_FM; /* * not so sure about modes and filters * as I write this from manual (no testing) --SF */ switch (mode) { case RIG_MODE_CW: pcrmode = MD_CW; break; case RIG_MODE_USB: pcrmode = MD_USB; break; case RIG_MODE_LSB: pcrmode = MD_LSB; break; case RIG_MODE_AM: pcrmode = MD_AM; break; case RIG_MODE_WFM: pcrmode = MD_WFM; break; case RIG_MODE_FM: pcrmode = MD_FM; break; default: rig_debug(RIG_DEBUG_ERR, "%s: unsupported mode %d\n", __func__, mode); return -RIG_EINVAL; } if (width == RIG_PASSBAND_NORMAL) width = rig_passband_normal(rig, mode); rig_debug(RIG_DEBUG_VERBOSE, "%s: will set to %d\n", __func__, width); switch (width) { /* nop, pcrfilter already set * TODO: use rig_passband_normal instead? */ case s_kHz(2.8): pcrfilter = FLT_2_8kHz; break; case s_kHz(6): pcrfilter = FLT_6kHz; break; case s_kHz(15): pcrfilter = FLT_15kHz; break; case s_kHz(50): pcrfilter = FLT_50kHz; break; case s_kHz(230): pcrfilter = FLT_230kHz; break; default: rig_debug(RIG_DEBUG_ERR, "%s: unsupported width %d\n", __func__, width); return -RIG_EINVAL; } rig_debug(RIG_DEBUG_VERBOSE, "%s: filter set to %d (%c)\n", __func__, width, pcrfilter); buf_len = sprintf((char *) buf, "K%c%010" PRIll "0%c0%c00", is_sub_rcvr(rig, vfo) ? '1':'0', (int64_t) rcvr->last_freq, pcrmode, pcrfilter); if (buf_len < 0) return -RIG_ETRUNC; err = pcr_transaction(rig, (char *) buf); if (err != RIG_OK) return err; rig_debug(RIG_DEBUG_VERBOSE, "%s: saving values\n", __func__); rcvr->last_mode = pcrmode; rcvr->last_filter = pcrfilter; return RIG_OK; }
/* Caution! Keep the function consistent with dump_csv_name and set_channel_data! */ int dump_csv_chan(RIG *rig, channel_t **chan_pp, int channel_num, const chan_t *chan_list, rig_ptr_t arg) { FILE *f = arg; static channel_t chan; static int first_time = 1; const channel_cap_t *mem_caps = &chan_list->mem_caps; if (first_time) { dump_csv_name(mem_caps, f); first_time = 0; } if (*chan_pp == NULL) { /* * Hamlib frontend demand application an allocated * channel_t pointer for next round. */ *chan_pp = &chan; return RIG_OK; } fprintf(f, "%d%c", chan.channel_num, csv_sep); if (mem_caps->bank_num) { fprintf(f, "%d%c", chan.bank_num, csv_sep); } if (mem_caps->channel_desc) { fprintf(f, "%s%c", chan.channel_desc, csv_sep); } if (mem_caps->vfo) { fprintf(f, "%s%c", rig_strvfo(chan.vfo), csv_sep); } if (mem_caps->ant) { fprintf(f, "%d%c", chan.ant, csv_sep); } if (mem_caps->freq) { fprintf(f, "%.0"PRIfreq"%c", chan.freq, csv_sep); } if (mem_caps->mode) { fprintf(f, "%s%c", rig_strrmode(chan.mode), csv_sep); } if (mem_caps->width) { fprintf(f, "%d%c", (int)chan.width, csv_sep); } if (mem_caps->tx_freq) { fprintf(f, "%.0"PRIfreq"%c", chan.tx_freq, csv_sep); } if (mem_caps->tx_mode) { fprintf(f, "%s%c", rig_strrmode(chan.tx_mode), csv_sep); } if (mem_caps->tx_width) { fprintf(f, "%d%c", (int)chan.tx_width, csv_sep); } if (mem_caps->split) { fprintf(f, "%s%c", chan.split == RIG_SPLIT_ON ? "on" : "off", csv_sep); } if (mem_caps->tx_vfo) { fprintf(f, "%s%c", rig_strvfo(chan.tx_vfo), csv_sep); } if (mem_caps->rptr_shift) { fprintf(f, "%s%c", rig_strptrshift(chan.rptr_shift), csv_sep); } if (mem_caps->rptr_offs) { fprintf(f, "%d%c", (int)chan.rptr_offs, csv_sep); } if (mem_caps->tuning_step) { fprintf(f, "%d%c", (int)chan.tuning_step, csv_sep); } if (mem_caps->rit) { fprintf(f, "%d%c", (int)chan.rit, csv_sep); } if (mem_caps->xit) { fprintf(f, "%d%c", (int)chan.xit, csv_sep); } if (mem_caps->funcs) { fprintf(f, "%"PRXll"%c", chan.funcs, csv_sep); } if (mem_caps->ctcss_tone) { fprintf(f, "%d%c", chan.ctcss_tone, csv_sep); } if (mem_caps->ctcss_sql) { fprintf(f, "%d%c", chan.ctcss_sql, csv_sep); } if (mem_caps->dcs_code) { fprintf(f, "%d%c", chan.dcs_code, csv_sep); } if (mem_caps->dcs_sql) { fprintf(f, "%d%c", chan.dcs_sql, csv_sep); } if (mem_caps->scan_group) { fprintf(f, "%d%c", chan.scan_group, csv_sep); } if (mem_caps->flags) { fprintf(f, "%x%c", chan.flags, csv_sep); } fprintf(f, "\n"); /* * keep the same *chan_pp for next round, thanks * to chan being static */ return RIG_OK; }