From: Stephane F. <f4...@us...> - 2000-10-16 22:08:54
|
Update of /cvsroot/hamlib/hamlib/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv15275 Modified Files: rig.c Log Message: * Added rig_[sg]et_passband to [sg]et narrow/normal/wide filter. These are a good companions to rig_[sg]et_mode. Maybe they should be merged? * Added rig_[sg]et_rpt_offs to set/get repeater offset * Added rig_split functions: rig_[sg]et_split_freq (set RX and TX freq) and rig_[sg]et_split to activate split mode * Added rig_[gs]et_level, however rig_set_preamp/rig_set_att/rig_set_ant et al. will be removed very soon. * Added Memory/VFO handling routines (actually wrappers, like the rest) Index: rig.c =================================================================== RCS file: /cvsroot/hamlib/hamlib/src/rig.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** rig.c 2000/10/10 22:11:48 1.4 --- rig.c 2000/10/16 22:08:51 1.5 *************** *** 293,298 **** --- 293,329 ---- } + /* + * rig_set_passband + * + */ + int rig_set_passband(RIG *rig, pbwidth_t width) + { + if (!rig || !rig->caps) + return -RIG_EINVAL; + + if (rig->caps->set_passband == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->set_passband(rig, width); + } + /* + * rig_get_passband + * + */ + + int rig_get_passband(RIG *rig, pbwidth_t *width) + { + if (!rig || !rig->caps || !width) + return -RIG_EINVAL; + + if (rig->caps->get_passband == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->get_passband(rig, width); + } + + /* * rig_set_vfo * *************** *** 405,409 **** return -RIG_EINVAL; ! if (rig->caps->get_ts == NULL) return -RIG_ENAVAIL; /* not implemented */ else --- 436,440 ---- return -RIG_EINVAL; ! if (rig->caps->get_rpt_shift == NULL) return -RIG_ENAVAIL; /* not implemented */ else *************** *** 411,417 **** --- 442,548 ---- } + /* + * rig_set_rpt_offs + * Set the repeater offset + */ + + int rig_set_rpt_offs(RIG *rig, unsigned long rptr_offs) + { + if (!rig || !rig->caps) + return -RIG_EINVAL; + + if (rig->caps->set_rpt_offs == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->set_rpt_offs(rig, rptr_offs); + } + + /* + * rig_get_rpt_offs + * Get the current repeater offset + */ + + int rig_get_rpt_offs(RIG *rig, unsigned long *rptr_offs) + { + if (!rig || !rig->caps || !rptr_offs) + return -RIG_EINVAL; + + if (rig->caps->get_rpt_offs == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->get_rpt_offs(rig, rptr_offs); + } + + + /* + * rig_set_split_freq + * Set the split frequencies + */ + + int rig_set_split_freq(RIG *rig, freq_t rx_freq, freq_t tx_freq) + { + if (!rig || !rig->caps) + return -RIG_EINVAL; + + if (rig->caps->set_split_freq == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->set_split_freq(rig, rx_freq, tx_freq); + } + + /* + * rig_get_split_freq + * Get the current split frequencies + */ + + int rig_get_split_freq(RIG *rig, freq_t *rx_freq, freq_t *tx_freq) + { + if (!rig || !rig->caps || !rx_freq || !tx_freq) + return -RIG_EINVAL; + + if (rig->caps->get_split_freq == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->get_split_freq(rig, rx_freq, tx_freq); + } + /* + * rig_set_split + * Set the split mode + */ + + int rig_set_split(RIG *rig, split_t split) + { + if (!rig || !rig->caps) + return -RIG_EINVAL; + + if (rig->caps->set_split == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->set_split(rig, split); + } + + /* + * rig_get_split + * Get the current split mode + */ + + int rig_get_split(RIG *rig, split_t *split) + { + if (!rig || !rig->caps || !split) + return -RIG_EINVAL; + + 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 *************** *** 445,449 **** } ! /* * rig_set_power --- 576,580 ---- } ! #if 0 /* * rig_set_power *************** *** 478,481 **** --- 609,613 ---- return rig->caps->get_power(rig, power); } + #endif /* *************** *** 531,534 **** --- 663,667 ---- } + #if 0 /* *************** *** 600,604 **** /* ! * rig_set_tonesq * Set CTCSS. * NB: tone is NOT in HZ, but in tenth of Hz! --- 733,850 ---- /* ! * rig_get_squelch_status ! * Read squelch status (open/closed) ! */ ! ! int rig_get_squelch_status(RIG *rig, int *sql_status) ! { ! if (!rig || !rig->caps || !sql_status) ! return -RIG_EINVAL; ! ! if (rig->caps->get_squelch_status == NULL) ! return -RIG_ENAVAIL; /* not implemented */ ! else ! return rig->caps->get_squelch_status(rig, sql_status); ! } ! ! /* ! * rig_set_ant ! * Set antenna number ! */ ! ! int rig_set_ant(RIG *rig, int ant) ! { ! if (!rig || !rig->caps) ! return -RIG_EINVAL; ! ! if (rig->caps->set_ant == NULL) ! return -RIG_ENAVAIL; /* not implemented */ ! else ! return rig->caps->set_ant(rig, ant); ! } ! ! /* ! * rig_get_ant ! * Read squelch condition ! */ ! ! int rig_get_ant(RIG *rig, int *ant) ! { ! if (!rig || !rig->caps || !ant) ! return -RIG_EINVAL; ! ! if (rig->caps->get_ant == NULL) ! return -RIG_ENAVAIL; /* not implemented */ ! else ! return rig->caps->get_ant(rig, ant); ! } ! ! /* ! * rig_set_att ! * Set attenuator (db) ! */ ! ! int rig_set_att(RIG *rig, int att) ! { ! if (!rig || !rig->caps) ! return -RIG_EINVAL; ! ! if (rig->caps->set_att == NULL) ! return -RIG_ENAVAIL; /* not implemented */ ! else ! return rig->caps->set_att(rig, att); ! } ! ! /* ! * rig_get_att ! * Read attenuator (db) ! */ ! ! int rig_get_att(RIG *rig, int *att) ! { ! if (!rig || !rig->caps || !att) ! return -RIG_EINVAL; ! ! if (rig->caps->get_att == NULL) ! return -RIG_ENAVAIL; /* not implemented */ ! else ! return rig->caps->get_att(rig, att); ! } ! ! /* ! * rig_set_preamp ! * Set preamp (db) ! */ ! ! int rig_set_preamp(RIG *rig, int preamp) ! { ! if (!rig || !rig->caps) ! return -RIG_EINVAL; ! ! if (rig->caps->set_preamp == NULL) ! return -RIG_ENAVAIL; /* not implemented */ ! else ! return rig->caps->set_preamp(rig, preamp); ! } ! ! /* ! * rig_get_preamp ! * Read preamp (db) ! */ ! ! int rig_get_preamp(RIG *rig, int *preamp) ! { ! if (!rig || !rig->caps || !preamp) ! return -RIG_EINVAL; ! ! if (rig->caps->get_preamp == NULL) ! return -RIG_ENAVAIL; /* not implemented */ ! else ! return rig->caps->get_preamp(rig, preamp); ! } ! #endif ! ! /* ! * rig_set_ctcss * Set CTCSS. * NB: tone is NOT in HZ, but in tenth of Hz! *************** *** 608,641 **** */ ! int rig_set_tonesq(RIG *rig, unsigned int tone) { if (!rig || !rig->caps) return -RIG_EINVAL; ! if (rig->caps->set_tonesq == NULL) return -RIG_ENAVAIL; /* not implemented */ else ! return rig->caps->set_tonesq(rig, tone); } /* ! * rig_get_tonesq * Read CTCSS * NB: tone is NOT in HZ, but in tenth of Hz! */ ! int rig_get_tonesq(RIG *rig, unsigned int *tone) { if (!rig || !rig->caps || !tone) return -RIG_EINVAL; ! if (rig->caps->get_tonesq == NULL) return -RIG_ENAVAIL; /* not implemented */ else ! return rig->caps->get_tonesq(rig, tone); } /* ! * rig_set_tone * Set subaudible tone to access a repeater. * NB: tone is NOT in HZ, but in tenth of Hz! --- 854,887 ---- */ ! int rig_set_ctcss(RIG *rig, unsigned int tone) { if (!rig || !rig->caps) return -RIG_EINVAL; ! if (rig->caps->set_ctcss == NULL) return -RIG_ENAVAIL; /* not implemented */ else ! return rig->caps->set_ctcss(rig, tone); } /* ! * rig_get_ctcss * Read CTCSS * NB: tone is NOT in HZ, but in tenth of Hz! */ ! int rig_get_ctcss(RIG *rig, unsigned int *tone) { if (!rig || !rig->caps || !tone) return -RIG_EINVAL; ! if (rig->caps->get_ctcss == NULL) return -RIG_ENAVAIL; /* not implemented */ else ! return rig->caps->get_ctcss(rig, tone); } /* ! * rig_set_dcs * Set subaudible tone to access a repeater. * NB: tone is NOT in HZ, but in tenth of Hz! *************** *** 645,677 **** */ ! int rig_set_tone(RIG *rig, unsigned int tone) { if (!rig || !rig->caps) return -RIG_EINVAL; ! if (rig->caps->set_tone == NULL) return -RIG_ENAVAIL; /* not implemented */ else ! return rig->caps->set_tone(rig, tone); } /* ! * rig_get_tone * Read current subaudible tone to access a repeater. * NB: tone is NOT in HZ, but in tenth of Hz! */ ! int rig_get_tone(RIG *rig, unsigned int *tone) { if (!rig || !rig->caps || !tone) return -RIG_EINVAL; ! if (rig->caps->get_tone == NULL) return -RIG_ENAVAIL; /* not implemented */ else ! return rig->caps->get_tone(rig, tone); } /* * rig_get_strength --- 891,924 ---- */ ! int rig_set_dcs(RIG *rig, unsigned int tone) { if (!rig || !rig->caps) return -RIG_EINVAL; ! if (rig->caps->set_dcs == NULL) return -RIG_ENAVAIL; /* not implemented */ else ! return rig->caps->set_dcs(rig, tone); } /* ! * rig_get_dcs * Read current subaudible tone to access a repeater. * NB: tone is NOT in HZ, but in tenth of Hz! */ ! int rig_get_dcs(RIG *rig, unsigned int *tone) { if (!rig || !rig->caps || !tone) return -RIG_EINVAL; ! if (rig->caps->get_dcs == NULL) return -RIG_ENAVAIL; /* not implemented */ else ! return rig->caps->get_dcs(rig, tone); } + #if 0 /* * rig_get_strength *************** *** 690,693 **** --- 937,941 ---- return rig->caps->get_strength(rig, strength); } + #endif /* *************** *** 818,827 **** #endif /* * "macro" to check if a rig has a function, * example: if (rig_has_func(my_rig, RIG_FUNC_FAGC)) disp_fagc_button(); */ ! int rig_has_func(RIG *rig, unsigned long func) { if (!rig || !rig->caps) --- 1066,1130 ---- #endif + /* + * rig_set_level + */ + int rig_set_level(RIG *rig, setting_t set, value_t val) + { + if (!rig || !rig->caps) + return -RIG_EINVAL; + + if (rig->caps->set_level == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->set_level(rig, set, val); + } + + /* + * rig_get_level + */ + + int rig_get_level(RIG *rig, setting_t set, value_t *val) + { + if (!rig || !rig->caps || !val) + return -RIG_EINVAL; + + if (rig->caps->get_level == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->get_level(rig, set, val); + } /* + * "macro" to check if a rig can *get* a level setting, + * example: if (rig_has_set_level(my_rig, RIG_LVL_STRENGTH)) disp_Smeter(); + */ + int rig_has_level(RIG *rig, setting_t level) + { + if (!rig || !rig->caps) + return -1; + + return (rig->caps->has_level & level); + } + + + /* + * "macro" to check if a rig can *set* a level setting, + * example: if (rig_has_set_level(my_rig, RIG_LVL_RFPOWER)) crank_tx(); + */ + int rig_has_set_level(RIG *rig, setting_t level) + { + if (!rig || !rig->caps) + return -1; + + return (rig->caps->has_set_level & level); + } + + + + /* * "macro" to check if a rig has a function, * example: if (rig_has_func(my_rig, RIG_FUNC_FAGC)) disp_fagc_button(); */ ! int rig_has_func(RIG *rig, setting_t func) { if (!rig || !rig->caps) *************** *** 835,839 **** */ ! int rig_set_func(RIG *rig, unsigned long func) { if (!rig || !rig->caps) --- 1138,1142 ---- */ ! int rig_set_func(RIG *rig, setting_t func) { if (!rig || !rig->caps) *************** *** 852,856 **** */ ! int rig_get_func(RIG *rig, unsigned long *func) { if (!rig || !rig->caps || !func) --- 1155,1159 ---- */ ! int rig_get_func(RIG *rig, setting_t *func) { if (!rig || !rig->caps || !func) *************** *** 863,867 **** --- 1166,1249 ---- } + /* + * rig_set_mem + * Set memory channel number. + * Should not be obliged to be in memory mode. Depends on rig. YMMV. + */ + + int rig_set_mem(RIG *rig, int ch) + { + if (!rig || !rig->caps) + return -RIG_EINVAL; + + if (rig->caps->set_mem == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->set_mem(rig, ch); + } + + /* + * rig_get_mem + * Get memory channel number + * Should not be obliged to be in memory mode. Depends on rig. YMMV. + */ + + int rig_get_mem(RIG *rig, int *ch) + { + if (!rig || !rig->caps || !ch) + return -RIG_EINVAL; + + if (rig->caps->get_mem == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->get_mem(rig, ch); + } + + /* + * rig_mv_ctl + * Memory/VFO operations, cf mv_op_t enum + */ + + int rig_mv_ctl(RIG *rig, mv_op_t op) + { + if (!rig || !rig->caps) + return -RIG_EINVAL; + + if (rig->caps->mv_ctl == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->mv_ctl(rig, op); + } + + /* + * rig_set_channel + */ + + int rig_set_channel(RIG *rig, const channel_t *chan) + { + if (!rig || !rig->caps || !chan) + return -RIG_EINVAL; + + if (rig->caps->set_channel == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->set_channel(rig, chan); + } + + /* + * rig_get_channel + * The channel to get data about is stored in chan->channel_num + */ + + int rig_get_channel(RIG *rig, channel_t *chan) + { + if (!rig || !rig->caps || !chan) + return -RIG_EINVAL; + if (rig->caps->get_channel == NULL) + return -RIG_ENAVAIL; /* not implemented */ + else + return rig->caps->get_channel(rig, chan); + } /* |