[Hamlib-cvs-digest] CVS: hamlib/src rig.c,1.8,1.9
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Stephane F. <f4...@us...> - 2000-11-28 22:33:42
|
Update of /cvsroot/hamlib/hamlib/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv1185 Modified Files: rig.c Log Message: * cleanup, removed "not implemented" misleading comments * added added squelch primitives of DCS/CTCSS * added set/get_RIT and rig_get_info wrappers Index: rig.c =================================================================== RCS file: /cvsroot/hamlib/hamlib/src/rig.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** rig.c 2000/10/29 16:30:43 1.8 --- rig.c 2000/11/28 22:33:37 1.9 *************** *** 358,362 **** if (rig->caps->set_freq == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_freq(rig, freq); --- 358,362 ---- if (rig->caps->set_freq == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_freq(rig, freq); *************** *** 385,389 **** if (rig->caps->get_freq == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else { status = rig->caps->get_freq(rig, freq); --- 385,389 ---- if (rig->caps->get_freq == NULL) ! return -RIG_ENAVAIL; else { status = rig->caps->get_freq(rig, freq); *************** *** 415,419 **** if (rig->caps->set_mode == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_mode(rig, mode); --- 415,419 ---- if (rig->caps->set_mode == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_mode(rig, mode); *************** *** 440,444 **** if (rig->caps->get_mode == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_mode(rig, mode); --- 440,444 ---- if (rig->caps->get_mode == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_mode(rig, mode); *************** *** 456,460 **** if (rig->caps->set_passband == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_passband(rig, width); --- 456,460 ---- if (rig->caps->set_passband == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_passband(rig, width); *************** *** 472,476 **** if (rig->caps->get_passband == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_passband(rig, width); --- 472,476 ---- if (rig->caps->get_passband == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_passband(rig, width); *************** *** 497,501 **** if (rig->caps->set_vfo == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_vfo(rig, vfo); --- 497,501 ---- if (rig->caps->set_vfo == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_vfo(rig, vfo); *************** *** 522,526 **** if (rig->caps->get_vfo == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_vfo(rig, vfo); --- 522,526 ---- if (rig->caps->get_vfo == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_vfo(rig, vfo); *************** *** 548,552 **** case RIG_PTT_RIG: if (rig->caps->set_ptt == NULL) ! return -RIG_ENIMPL; /* not implemented */ else return rig->caps->set_ptt(rig, ptt); --- 548,552 ---- case RIG_PTT_RIG: if (rig->caps->set_ptt == NULL) ! return -RIG_ENIMPL; else return rig->caps->set_ptt(rig, ptt); *************** *** 555,561 **** case RIG_PTT_SERIAL: case RIG_PTT_PARALLEL: case RIG_PTT_NONE: default: ! return -RIG_ENIMPL; /* not implemented */ } } --- 555,563 ---- case RIG_PTT_SERIAL: case RIG_PTT_PARALLEL: + return -RIG_ENIMPL; /* not implemented */ + case RIG_PTT_NONE: default: ! return -RIG_ENAVAIL; /* not available */ } } *************** *** 583,587 **** case RIG_PTT_RIG: if (rig->caps->get_ptt == NULL) ! return -RIG_ENIMPL; /* not implemented */ else return rig->caps->get_ptt(rig, ptt); --- 585,589 ---- case RIG_PTT_RIG: if (rig->caps->get_ptt == NULL) ! return -RIG_ENIMPL; else return rig->caps->get_ptt(rig, ptt); *************** *** 618,622 **** if (rig->caps->set_rptr_shift == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_rptr_shift(rig, rptr_shift); --- 620,624 ---- if (rig->caps->set_rptr_shift == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_rptr_shift(rig, rptr_shift); *************** *** 642,646 **** if (rig->caps->get_rptr_shift == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_rptr_shift(rig, rptr_shift); --- 644,648 ---- if (rig->caps->get_rptr_shift == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_rptr_shift(rig, rptr_shift); *************** *** 667,671 **** if (rig->caps->set_rptr_offs == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_rptr_offs(rig, rptr_offs); --- 669,673 ---- if (rig->caps->set_rptr_offs == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_rptr_offs(rig, rptr_offs); *************** *** 692,696 **** if (rig->caps->get_rptr_offs == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_rptr_offs(rig, rptr_offs); --- 694,698 ---- if (rig->caps->get_rptr_offs == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_rptr_offs(rig, rptr_offs); *************** *** 719,723 **** if (rig->caps->set_split_freq == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_split_freq(rig, rx_freq, tx_freq); --- 721,725 ---- if (rig->caps->set_split_freq == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_split_freq(rig, rx_freq, tx_freq); *************** *** 745,749 **** if (rig->caps->get_split_freq == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_split_freq(rig, rx_freq, tx_freq); --- 747,751 ---- if (rig->caps->get_split_freq == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_split_freq(rig, rx_freq, tx_freq); *************** *** 771,775 **** if (rig->caps->set_split == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_split(rig, split); --- 773,777 ---- if (rig->caps->set_split == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_split(rig, split); *************** *** 795,805 **** if (rig->caps->get_split == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_split(rig, split); } /** * rig_set_ts - set the Tuning Step * @rig: The rig handle --- 797,859 ---- if (rig->caps->get_split == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_split(rig, split); } + /** + * rig_set_rit - set the RIT + * @rig: The rig handle + * @rit: The RIT offset to adjust to + * + * The rig_set_rit() function sets the current RIT offset. + * A value of 0 for @rit disables RIT. + * + * RETURN VALUE: The rig_set_rit() function returns %RIG_OK + * if the operation has been sucessful, or a negative value + * if an error occured (in which case, cause is set appropriately). + * + * SEE ALSO: rig_get_rit() + */ + int rig_set_rit(RIG *rig, signed long rit) + { + if (!rig || !rig->caps) + return -RIG_EINVAL; + + if (rig->caps->set_rit == NULL) + return -RIG_ENAVAIL; + else + return rig->caps->set_rit(rig, rit); + } + /** + * rig_get_rit - get the current RIT offset + * @rig: The rig handle + * @rit: The location where to store the current RIT offset + * + * The rig_get_rit() function retrieves the current RIT offset. + * + * RETURN VALUE: The rig_get_rit() function returns %RIG_OK + * if the operation has been sucessful, or a negative value + * if an error occured (in which case, cause is set appropriately). + * + * SEE ALSO: rig_set_rit() + */ + + int rig_get_rit(RIG *rig, signed long *rit) + { + if (!rig || !rig->caps || !rit) + return -RIG_EINVAL; + + if (rig->caps->get_rit == NULL) + return -RIG_ENAVAIL; + else + return rig->caps->get_rit(rig, rit); + } + + + + /** * rig_set_ts - set the Tuning Step * @rig: The rig handle *************** *** 821,825 **** if (rig->caps->set_ts == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_ts(rig, ts); --- 875,879 ---- if (rig->caps->set_ts == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_ts(rig, ts); *************** *** 846,850 **** if (rig->caps->get_ts == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_ts(rig, ts); --- 900,904 ---- if (rig->caps->get_ts == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_ts(rig, ts); *************** *** 962,966 **** if (rig->caps->set_ctcss == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_ctcss(rig, tone); --- 1016,1020 ---- if (rig->caps->set_ctcss == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_ctcss(rig, tone); *************** *** 996,1000 **** if (rig->caps->get_ctcss == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_ctcss(rig, tone); --- 1050,1054 ---- if (rig->caps->get_ctcss == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_ctcss(rig, tone); *************** *** 1022,1026 **** if (rig->caps->set_dcs == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_dcs(rig, code); --- 1076,1080 ---- if (rig->caps->set_dcs == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_dcs(rig, code); *************** *** 1047,1051 **** if (rig->caps->get_dcs == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_dcs(rig, code); --- 1101,1105 ---- if (rig->caps->get_dcs == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_dcs(rig, code); *************** *** 1053,1056 **** --- 1107,1221 ---- /** + * rig_set_ctcss_sql - set CTCSS squelch + * @rig: The rig handle + * @tone: The PL tone to set the squelch to + * + * The rig_set_ctcss_sql() function sets the current Continuous Tone + * Controlled Squelch System (CTCSS) sub-audible squelch tone. + * NB, @tone is NOT in Hz, but in tenth of Hz! This way, + * if you want to set subaudible tone of 88.5 Hz for example, + * then pass 885 to this function. Also, to disable Tone squelch, + * set @tone to 0. + * + * RETURN VALUE: The rig_set_ctcss_sql() function returns %RIG_OK + * if the operation has been sucessful, or a negative value + * if an error occured (in which case, cause is set appropriately). + * + * SEE ALSO: rig_get_ctcss_sql(), rig_set_ctcss() + */ + + int rig_set_ctcss_sql(RIG *rig, unsigned int tone) + { + if (!rig || !rig->caps) + return -RIG_EINVAL; + + if (rig->caps->set_ctcss_sql == NULL) + return -RIG_ENAVAIL; + else + return rig->caps->set_ctcss_sql(rig, tone); + } + + /** + * rig_get_ctcss_sql - get the current CTCSS squelch + * @rig: The rig handle + * @tone: The location where to store the current tone + * + * The rig_get_ctcss_sql() function retrieves the current Continuous Tone + * Controlled Squelch System (CTCSS) sub-audible squelch tone. + * NB, @tone is NOT in Hz, but in tenth of Hz! This way, + * if the function rig_get_ctcss() returns a subaudible tone of 885 + * for example, then the real tone is 88.5 Hz. + * Also, a value of 0 for @tone means the Tone squelch is disabled. + * + * RETURN VALUE: The rig_get_ctcss_sql() function returns %RIG_OK + * if the operation has been sucessful, or a negative value + * if an error occured (in which case, cause is set appropriately). + * + * SEE ALSO: rig_set_ctcss_sql(), rig_get_ctcss() + */ + int rig_get_ctcss_sql(RIG *rig, unsigned int *tone) + { + if (!rig || !rig->caps || !tone) + return -RIG_EINVAL; + + if (rig->caps->get_ctcss_sql == NULL) + return -RIG_ENAVAIL; + else + return rig->caps->get_ctcss_sql(rig, tone); + } + + /** + * rig_set_dcs_sql - set the current DCS + * @rig: The rig handle + * @code: The tone to set to + * + * The rig_set_dcs_sql() function sets the current Digitally-Coded Squelch + * code. + * + * RETURN VALUE: The rig_set_dcs_sql() function returns %RIG_OK + * if the operation has been sucessful, or a negative value + * if an error occured (in which case, cause is set appropriately). + * + * SEE ALSO: rig_get_dcs_sql(), rig_set_dcs() + */ + + int rig_set_dcs_sql(RIG *rig, unsigned int code) + { + if (!rig || !rig->caps) + return -RIG_EINVAL; + + if (rig->caps->set_dcs_sql == NULL) + return -RIG_ENAVAIL; + else + return rig->caps->set_dcs_sql(rig, code); + } + + /** + * rig_get_dcs_sql - get the current DCS + * @rig: The rig handle + * @code: The location where to store the current tone + * + * The rig_get_dcs_sql() function retrieves the current + * Digitally-Coded Squelch. + * + * RETURN VALUE: The rig_get_dcs_sql() function returns %RIG_OK + * if the operation has been sucessful, or a negative value + * if an error occured (in which case, cause is set appropriately). + * + * SEE ALSO: rig_get_dcs_sql(), rig_get_dcs() + */ + int rig_get_dcs_sql(RIG *rig, unsigned int *code) + { + if (!rig || !rig->caps || !code) + return -RIG_EINVAL; + + if (rig->caps->get_dcs_sql == NULL) + return -RIG_ENAVAIL; + else + return rig->caps->get_dcs_sql(rig, code); + } + + + /** * rig_set_poweron - turn on the radio * @rig: The rig handle *************** *** 1071,1075 **** if (rig->caps->set_poweron == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_poweron(rig); --- 1236,1240 ---- if (rig->caps->set_poweron == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_poweron(rig); *************** *** 1095,1099 **** if (rig->caps->set_poweroff == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_poweroff(rig); --- 1260,1264 ---- if (rig->caps->set_poweroff == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_poweroff(rig); *************** *** 1155,1159 **** if (rig->caps->set_level == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_level(rig, level, val); --- 1320,1324 ---- if (rig->caps->set_level == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_level(rig, level, val); *************** *** 1182,1186 **** if (rig->caps->get_level == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_level(rig, level, val); --- 1347,1351 ---- if (rig->caps->get_level == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_level(rig, level, val); *************** *** 1284,1288 **** if (rig->caps->set_func == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_func(rig, func, status); --- 1449,1453 ---- if (rig->caps->set_func == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_func(rig, func, status); *************** *** 1311,1315 **** if (rig->caps->get_func == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_func(rig, func); --- 1476,1480 ---- if (rig->caps->get_func == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_func(rig, func); *************** *** 1338,1342 **** if (rig->caps->set_mem == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_mem(rig, ch); --- 1503,1507 ---- if (rig->caps->set_mem == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_mem(rig, ch); *************** *** 1364,1368 **** if (rig->caps->get_mem == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_mem(rig, ch); --- 1529,1533 ---- if (rig->caps->get_mem == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_mem(rig, ch); *************** *** 1389,1393 **** if (rig->caps->mv_ctl == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->mv_ctl(rig, op); --- 1554,1558 ---- if (rig->caps->mv_ctl == NULL) ! return -RIG_ENAVAIL; else return rig->caps->mv_ctl(rig, op); *************** *** 1416,1420 **** if (rig->caps->set_bank == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_bank(rig, bank); --- 1581,1585 ---- if (rig->caps->set_bank == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_bank(rig, bank); *************** *** 1443,1447 **** if (rig->caps->set_channel == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->set_channel(rig, chan); --- 1608,1612 ---- if (rig->caps->set_channel == NULL) ! return -RIG_ENAVAIL; else return rig->caps->set_channel(rig, chan); *************** *** 1469,1473 **** if (rig->caps->get_channel == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_channel(rig, chan); --- 1634,1638 ---- if (rig->caps->get_channel == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_channel(rig, chan); *************** *** 1577,1583 **** if (rig->caps->get_trn == NULL) ! return -RIG_ENAVAIL; /* not implemented */ else return rig->caps->get_trn(rig, trn); } --- 1742,1772 ---- if (rig->caps->get_trn == NULL) ! return -RIG_ENAVAIL; else return rig->caps->get_trn(rig, trn); + } + + /** + * rig_get_info - get general information from the radio + * @rig: The rig handle + * + * The rig_get_info() function retrieves some general information + * from the radio. This can include firmware revision, exact + * model name, or just nothing. + * + * RETURN VALUE: The rig_get_info() function returns a pointer + * to freshly allocated memory containing the ASCIIZ string + * if the operation has been sucessful, or NULL + * if an error occured. + */ + unsigned char* rig_get_info(RIG *rig) + { + if (!rig || !rig->caps) + return NULL; + + if (rig->caps->get_info == NULL) + return NULL; + else + return rig->caps->get_info(rig); } |