kopia lustrzana https://github.com/Hamlib/Hamlib
Fix anytone thread deletion
rodzic
c85cf58235
commit
5745457d7f
|
@ -285,6 +285,7 @@
|
|||
#define RIG_MODEL_X6100 RIG_MAKE_MODEL(RIG_ICOM, 87) /* Xiegu X6100 */
|
||||
#define RIG_MODEL_G90 RIG_MAKE_MODEL(RIG_ICOM, 88) /* Xiegu G90 */
|
||||
#define RIG_MODEL_X5105 RIG_MAKE_MODEL(RIG_ICOM, 89) /* Xiegu X5105 -- G90 compatible */
|
||||
#define RIG_MODEL_IC905 RIG_MAKE_MODEL(RIG_ICOM, 90)
|
||||
|
||||
/*
|
||||
* Optoelectronics (CI-V)
|
||||
|
|
|
@ -300,6 +300,7 @@ int anytone_open(RIG *rig)
|
|||
// can we ask for any information? Maybe just toggle A/B?
|
||||
}
|
||||
|
||||
#if 0
|
||||
pthread_t id;
|
||||
int err = pthread_create(&id, NULL, anytone_thread, (void *)rig);
|
||||
|
||||
|
@ -309,6 +310,7 @@ int anytone_open(RIG *rig)
|
|||
strerror(errno));
|
||||
RETURNFUNC(-RIG_EINTERNAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "hamlib/rig.h"
|
||||
|
||||
#define BACKEND_VER "20230529"
|
||||
#define BACKEND_VER "20230530"
|
||||
|
||||
#define ANYTONE_RESPSZ 64
|
||||
|
||||
|
|
|
@ -546,6 +546,128 @@ static const struct icom_priv_caps IC705_priv_caps =
|
|||
.extcmds = ic705_extcmds, /* Custom parameters */
|
||||
};
|
||||
|
||||
static const struct icom_priv_caps IC905_priv_caps =
|
||||
{
|
||||
0xAC, /* default address */
|
||||
0, /* 731 mode */
|
||||
1, /* no XCHG to avoid display flickering */
|
||||
ic705_ts_sc_list,
|
||||
.serial_USB_echo_check = 1, /* USB CI-V may not echo */
|
||||
.agc_levels_present = 1,
|
||||
.agc_levels = {
|
||||
{ .level = RIG_AGC_FAST, .icom_level = 1 },
|
||||
{ .level = RIG_AGC_MEDIUM, .icom_level = 2 },
|
||||
{ .level = RIG_AGC_SLOW, .icom_level = 3 },
|
||||
{ .level = RIG_AGC_LAST, .icom_level = -1 },
|
||||
},
|
||||
.spectrum_scope_caps = {
|
||||
.spectrum_line_length = 475,
|
||||
.single_frame_data_length = 50,
|
||||
.data_level_min = 0,
|
||||
.data_level_max = 160,
|
||||
.signal_strength_min = -80, // TODO: signal strength to be confirmed
|
||||
.signal_strength_max = 0,
|
||||
},
|
||||
.spectrum_edge_frequency_ranges = {
|
||||
{
|
||||
.range_id = 1,
|
||||
.low_freq = 30000,
|
||||
.high_freq = 1600000,
|
||||
},
|
||||
{
|
||||
.range_id = 2,
|
||||
.low_freq = 1600000,
|
||||
.high_freq = 2000000,
|
||||
},
|
||||
{
|
||||
.range_id = 3,
|
||||
.low_freq = 2000000,
|
||||
.high_freq = 6000000,
|
||||
},
|
||||
{
|
||||
.range_id = 4,
|
||||
.low_freq = 6000000,
|
||||
.high_freq = 8000000,
|
||||
},
|
||||
{
|
||||
.range_id = 5,
|
||||
.low_freq = 8000000,
|
||||
.high_freq = 11000000,
|
||||
},
|
||||
{
|
||||
.range_id = 6,
|
||||
.low_freq = 11000000,
|
||||
.high_freq = 15000000,
|
||||
},
|
||||
{
|
||||
.range_id = 7,
|
||||
.low_freq = 15000000,
|
||||
.high_freq = 20000000,
|
||||
},
|
||||
{
|
||||
.range_id = 8,
|
||||
.low_freq = 20000000,
|
||||
.high_freq = 22000000,
|
||||
},
|
||||
{
|
||||
.range_id = 9,
|
||||
.low_freq = 22000000,
|
||||
.high_freq = 26000000,
|
||||
},
|
||||
{
|
||||
.range_id = 10,
|
||||
.low_freq = 26000000,
|
||||
.high_freq = 30000000,
|
||||
},
|
||||
{
|
||||
.range_id = 11,
|
||||
.low_freq = 30000000,
|
||||
.high_freq = 45000000,
|
||||
},
|
||||
{
|
||||
.range_id = 12,
|
||||
.low_freq = 45000000,
|
||||
.high_freq = 60000000,
|
||||
},
|
||||
{
|
||||
.range_id = 13,
|
||||
.low_freq = 60000000,
|
||||
.high_freq = 74800000,
|
||||
},
|
||||
{
|
||||
.range_id = 13,
|
||||
.low_freq = 60000000,
|
||||
.high_freq = 74800000,
|
||||
},
|
||||
{
|
||||
.range_id = 14,
|
||||
.low_freq = 74800000,
|
||||
.high_freq = 108000000,
|
||||
},
|
||||
{
|
||||
.range_id = 15,
|
||||
.low_freq = 108000000,
|
||||
.high_freq = 137000000,
|
||||
},
|
||||
{
|
||||
.range_id = 16,
|
||||
.low_freq = 137000000,
|
||||
.high_freq = 200000000,
|
||||
},
|
||||
{
|
||||
.range_id = 17,
|
||||
.low_freq = 400000000,
|
||||
.high_freq = 470000000,
|
||||
},
|
||||
{
|
||||
.range_id = 0,
|
||||
.low_freq = 0,
|
||||
.high_freq = 0,
|
||||
},
|
||||
},
|
||||
.extcmds = ic705_extcmds, /* Custom parameters */
|
||||
};
|
||||
|
||||
const struct rig_caps ic7300_caps =
|
||||
{
|
||||
RIG_MODEL(RIG_MODEL_IC7300),
|
||||
|
@ -1363,6 +1485,270 @@ const struct rig_caps ic705_caps =
|
|||
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
|
||||
};
|
||||
|
||||
const struct rig_caps ic905_caps =
|
||||
{
|
||||
RIG_MODEL(RIG_MODEL_IC905),
|
||||
.model_name = "IC-905",
|
||||
.mfg_name = "Icom",
|
||||
.version = BACKEND_VER ".0",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
.ptt_type = RIG_PTT_RIG,
|
||||
.dcd_type = RIG_DCD_RIG,
|
||||
.port_type = RIG_PORT_SERIAL,
|
||||
.serial_rate_min = 4800,
|
||||
.serial_rate_max = 230400,
|
||||
.serial_data_bits = 8,
|
||||
.serial_stop_bits = 1,
|
||||
.serial_parity = RIG_PARITY_NONE,
|
||||
.serial_handshake = RIG_HANDSHAKE_NONE,
|
||||
.write_delay = 0,
|
||||
.post_write_delay = 0,
|
||||
.timeout = 1000,
|
||||
.retry = 3,
|
||||
.has_get_func = IC7300_FUNCS,
|
||||
.has_set_func = IC7300_FUNCS,
|
||||
.has_get_level = IC705_LEVELS,
|
||||
.has_set_level = RIG_LEVEL_SET(IC705_LEVELS),
|
||||
.has_get_parm = IC7300_PARMS,
|
||||
.has_set_parm = RIG_PARM_SET(IC7300_PARMS),
|
||||
.level_gran = {
|
||||
#include "level_gran_icom.h"
|
||||
[LVL_RAWSTR] = {.min = {.i = 0}, .max = {.i = 255}},
|
||||
[LVL_VOXDELAY] = {.min = {.i = 0}, .max = {.i = 20}, .step = {.i = 1}},
|
||||
[LVL_KEYSPD] = {.min = {.i = 6}, .max = {.i = 48}, .step = {.i = 1}},
|
||||
[LVL_CWPITCH] = {.min = {.i = 300}, .max = {.i = 900}, .step = {.i = 1}},
|
||||
[LVL_SPECTRUM_SPEED] = {.min = {.i = 0}, .max = {.i = 2}, .step = {.i = 1}},
|
||||
[LVL_SPECTRUM_REF] = {.min = {.f = -20.0f}, .max = {.f = 20.0f}, .step = {.f = 0.5f}},
|
||||
[LVL_SPECTRUM_AVG] = {.min = {.i = 0}, .max = {.i = 3}, .step = {.i = 1}},
|
||||
[LVL_USB_AF] = {.min = {.f = 0.0f}, .max = {.f = 1.0f}, .step = {.f = 1.0f / 255.0f }},
|
||||
},
|
||||
.parm_gran = {},
|
||||
.ext_tokens = ic705_ext_tokens,
|
||||
.extlevels = icom_ext_levels,
|
||||
.ctcss_list = full_ctcss_list,
|
||||
.dcs_list = NULL,
|
||||
.preamp = { 1, 2, RIG_DBLST_END, },
|
||||
.attenuator = { 20, RIG_DBLST_END, },
|
||||
.max_rit = Hz(9999),
|
||||
.max_xit = Hz(9999),
|
||||
.max_ifshift = Hz(0),
|
||||
.agc_level_count = 3,
|
||||
.agc_levels = { RIG_AGC_OFF, RIG_AGC_FAST, RIG_AGC_MEDIUM, RIG_AGC_SLOW },
|
||||
.targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
|
||||
.vfo_ops = IC7300_VFO_OPS,
|
||||
.scan_ops = IC7300_SCAN_OPS,
|
||||
.transceive = RIG_TRN_RIG,
|
||||
.bank_qty = 5,
|
||||
.chan_desc_sz = 0,
|
||||
|
||||
.chan_list = {
|
||||
{ 1, 99, RIG_MTYPE_MEM },
|
||||
RIG_CHAN_END,
|
||||
},
|
||||
|
||||
.rx_range_list1 = {
|
||||
{MHz(144), MHz(148), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "USA"},
|
||||
{MHz(430), MHz(450), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "USA"},
|
||||
{MHz(1240), MHz(1300), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "USA"},
|
||||
{MHz(2300), MHz(2309.999999), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "USA"},
|
||||
{MHz(5650), MHz(5925), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "USA"},
|
||||
{MHz(10000), MHz(10500), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "USA"},
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
.tx_range_list1 = {
|
||||
{ MHz(144), MHz(148), IC705_ALL_TX_MODES, W(0.1), W(10), IC7300_VFOS, RIG_ANT_1, "USA" },
|
||||
{ MHz(430), MHz(450), IC705_ALL_TX_MODES, W(0.1), W(10), IC7300_VFOS, RIG_ANT_1, "USA" },
|
||||
{ MHz(1240), MHz(1300), IC705_ALL_TX_MODES, W(0.1), W(10), IC7300_VFOS, RIG_ANT_1, "USA" },
|
||||
{ MHz(2300), MHz(2309.999999), IC705_ALL_TX_MODES, W(0.1), W(2), IC7300_VFOS, RIG_ANT_1, "USA" },
|
||||
{ MHz(2390.000001), MHz(2450), IC705_ALL_TX_MODES, W(0.1), W(2), IC7300_VFOS, RIG_ANT_1, "USA" },
|
||||
{ MHz(5650), MHz(5925), IC705_ALL_TX_MODES, W(0.1), W(2), IC7300_VFOS, RIG_ANT_1, "USA" },
|
||||
{ MHz(10000), MHz(10500), IC705_ALL_TX_MODES, W(0.1), W(2), IC7300_VFOS, RIG_ANT_1, "USA" },
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
|
||||
.rx_range_list2 = {
|
||||
{MHz(144), MHz(146), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "EUR"},
|
||||
{MHz(430), MHz(440), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "EUR"},
|
||||
{MHz(1240), MHz(1300), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "EUR"},
|
||||
{MHz(2300), MHz(2450), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "EUR"},
|
||||
{MHz(5650), MHz(5850), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "EUR"},
|
||||
{MHz(10000), MHz(10500), IC705_ALL_RX_MODES, -1, -1, IC7300_VFOS, RIG_ANT_1, "USA"},
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
.tx_range_list2 = {
|
||||
{ MHz(144), MHz(148), IC705_ALL_TX_MODES, W(0.1), W(10), IC7300_VFOS, RIG_ANT_1, "EUR" },
|
||||
{ MHz(430), MHz(450), IC705_ALL_TX_MODES, W(0.1), W(10), IC7300_VFOS, RIG_ANT_1, "EUR" },
|
||||
{ MHz(1240), MHz(1300), IC705_ALL_TX_MODES, W(0.1), W(10), IC7300_VFOS, RIG_ANT_1, "EUR" },
|
||||
{ MHz(2300), MHz(2309.999999), IC705_ALL_TX_MODES, W(0.1), W(2), IC7300_VFOS, RIG_ANT_1, "EUR" },
|
||||
{ MHz(2390), MHz(2450), IC705_ALL_TX_MODES, W(0.1), W(2), IC7300_VFOS, RIG_ANT_1, "EUR" },
|
||||
{ MHz(5650), MHz(5925), IC705_ALL_TX_MODES, W(0.1), W(2), IC7300_VFOS, RIG_ANT_1, "EUR" },
|
||||
{ MHz(10000), MHz(10500), IC705_ALL_TX_MODES, W(0.1), W(2), IC7300_VFOS, RIG_ANT_1, "USA" },
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
|
||||
.tuning_steps = {
|
||||
{IC7300_ALL_RX_MODES, Hz(100)},
|
||||
{IC7300_ALL_RX_MODES, kHz(.5)},
|
||||
{IC7300_ALL_RX_MODES, kHz(1)},
|
||||
{IC7300_ALL_RX_MODES, kHz(5)},
|
||||
{IC7300_ALL_RX_MODES, kHz(6.25)},
|
||||
{IC7300_ALL_RX_MODES, kHz(8.33)},
|
||||
{IC7300_ALL_RX_MODES, kHz(9)},
|
||||
{IC7300_ALL_RX_MODES, kHz(10)},
|
||||
{IC7300_ALL_RX_MODES, kHz(12.5)},
|
||||
{IC7300_ALL_RX_MODES, kHz(20)},
|
||||
{IC7300_ALL_RX_MODES, kHz(25)},
|
||||
{IC7300_ALL_RX_MODES, kHz(50)},
|
||||
{IC7300_ALL_RX_MODES, kHz(100)},
|
||||
RIG_TS_END,
|
||||
},
|
||||
|
||||
/* mode/filter list, remember: order matters! But duplication may speed up search. Put the most commonly used modes first! Remember these are defaults, with dsp rigs you can change them to anything you want except FM and WFM which are fixed */
|
||||
.filters = {
|
||||
{RIG_MODE_SSB | RIG_MODE_PKTLSB | RIG_MODE_PKTUSB, kHz(2.4)},
|
||||
{RIG_MODE_SSB | RIG_MODE_PKTLSB | RIG_MODE_PKTUSB, kHz(1.8)},
|
||||
{RIG_MODE_SSB | RIG_MODE_PKTLSB | RIG_MODE_PKTUSB, kHz(3.0)},
|
||||
{RIG_MODE_CW | RIG_MODE_CWR | RIG_MODE_RTTY | RIG_MODE_RTTYR, Hz(500)},
|
||||
{RIG_MODE_CW | RIG_MODE_CWR | RIG_MODE_RTTY | RIG_MODE_RTTYR, Hz(250)},
|
||||
{RIG_MODE_CW | RIG_MODE_CWR, kHz(1.2)},
|
||||
{RIG_MODE_RTTY | RIG_MODE_RTTYR, kHz(2.4)},
|
||||
{RIG_MODE_AM | RIG_MODE_PKTAM, kHz(6)},
|
||||
{RIG_MODE_AM | RIG_MODE_PKTAM, kHz(3)},
|
||||
{RIG_MODE_AM | RIG_MODE_PKTAM, kHz(9)},
|
||||
{RIG_MODE_FM | RIG_MODE_PKTFM, kHz(10)},
|
||||
{RIG_MODE_FM | RIG_MODE_PKTFM, kHz(7)},
|
||||
{RIG_MODE_FM | RIG_MODE_PKTFM, kHz(15)},
|
||||
RIG_FLT_END,
|
||||
},
|
||||
|
||||
.str_cal = IC7300_STR_CAL,
|
||||
.swr_cal = IC7300_SWR_CAL,
|
||||
.alc_cal = IC7300_ALC_CAL,
|
||||
.rfpower_meter_cal = IC7300_RFPOWER_METER_CAL,
|
||||
.comp_meter_cal = IC7300_COMP_METER_CAL,
|
||||
.vd_meter_cal = IC7300_VD_METER_CAL,
|
||||
.id_meter_cal = IC7300_ID_METER_CAL,
|
||||
|
||||
.spectrum_scopes = {
|
||||
{
|
||||
.id = 0,
|
||||
.name = "Main",
|
||||
},
|
||||
{
|
||||
.id = -1,
|
||||
.name = NULL,
|
||||
},
|
||||
},
|
||||
.spectrum_modes = {
|
||||
RIG_SPECTRUM_MODE_CENTER,
|
||||
RIG_SPECTRUM_MODE_FIXED,
|
||||
RIG_SPECTRUM_MODE_CENTER_SCROLL,
|
||||
RIG_SPECTRUM_MODE_FIXED_SCROLL,
|
||||
RIG_SPECTRUM_MODE_NONE,
|
||||
},
|
||||
.spectrum_spans = {
|
||||
5000,
|
||||
10000,
|
||||
20000,
|
||||
50000,
|
||||
100000,
|
||||
200000,
|
||||
500000,
|
||||
1000000,
|
||||
0,
|
||||
},
|
||||
.spectrum_avg_modes = {
|
||||
{
|
||||
.id = 0,
|
||||
.name = "OFF",
|
||||
},
|
||||
{
|
||||
.id = 1,
|
||||
.name = "2",
|
||||
},
|
||||
{
|
||||
.id = 2,
|
||||
.name = "3",
|
||||
},
|
||||
{
|
||||
.id = 3,
|
||||
.name = "4",
|
||||
},
|
||||
},
|
||||
|
||||
.async_data_supported = 1,
|
||||
.read_frame_direct = icom_read_frame_direct,
|
||||
.is_async_frame = icom_is_async_frame,
|
||||
.process_async_frame = icom_process_async_frame,
|
||||
|
||||
.cfgparams = icom_cfg_params,
|
||||
.set_conf = icom_set_conf,
|
||||
.get_conf = icom_get_conf,
|
||||
|
||||
.priv = (void *)& IC905_priv_caps,
|
||||
.rig_init = icom_init,
|
||||
.rig_cleanup = icom_cleanup,
|
||||
.rig_open = icom_rig_open,
|
||||
.rig_close = icom_rig_close,
|
||||
|
||||
.set_freq = icom_set_freq,
|
||||
.get_freq = icom_get_freq,
|
||||
.set_mode = icom_set_mode_with_data,
|
||||
.get_mode = icom_get_mode_with_data,
|
||||
// .get_vfo = icom_get_vfo,
|
||||
.set_vfo = icom_set_vfo,
|
||||
.set_ant = NULL,
|
||||
.get_ant = NULL,
|
||||
|
||||
.set_rit = icom_set_rit_new,
|
||||
.get_rit = icom_get_rit_new,
|
||||
.get_xit = icom_get_rit_new,
|
||||
.set_xit = icom_set_xit_new,
|
||||
|
||||
.decode_event = icom_decode_event,
|
||||
.set_level = icom_set_level,
|
||||
.get_level = icom_get_level,
|
||||
.set_ext_level = icom_set_ext_level,
|
||||
.get_ext_level = icom_get_ext_level,
|
||||
.set_func = icom_set_func,
|
||||
.get_func = icom_get_func,
|
||||
.set_parm = icom_set_parm,
|
||||
.get_parm = icom_get_parm,
|
||||
.set_mem = icom_set_mem,
|
||||
.vfo_op = icom_vfo_op,
|
||||
.scan = icom_scan,
|
||||
.set_ptt = icom_set_ptt,
|
||||
.get_ptt = icom_get_ptt,
|
||||
.get_dcd = icom_get_dcd,
|
||||
.set_ts = icom_set_ts,
|
||||
.get_ts = icom_get_ts,
|
||||
.set_rptr_shift = icom_set_rptr_shift,
|
||||
.get_rptr_shift = icom_get_rptr_shift,
|
||||
.set_rptr_offs = icom_set_rptr_offs,
|
||||
.get_rptr_offs = icom_get_rptr_offs,
|
||||
.set_ctcss_tone = icom_set_ctcss_tone,
|
||||
.get_ctcss_tone = icom_get_ctcss_tone,
|
||||
.set_ctcss_sql = icom_set_ctcss_sql,
|
||||
.get_ctcss_sql = icom_get_ctcss_sql,
|
||||
.set_split_freq = icom_set_split_freq,
|
||||
.get_split_freq = icom_get_split_freq,
|
||||
.set_split_mode = icom_set_split_mode,
|
||||
.get_split_mode = icom_get_split_mode,
|
||||
.set_split_vfo = icom_set_split_vfo,
|
||||
.get_split_vfo = icom_get_split_vfo,
|
||||
.set_powerstat = icom_set_powerstat,
|
||||
.get_powerstat = icom_get_powerstat,
|
||||
.power2mW = icom_power2mW,
|
||||
.mW2power = icom_mW2power,
|
||||
.send_morse = icom_send_morse,
|
||||
.stop_morse = icom_stop_morse,
|
||||
.wait_morse = rig_wait_morse,
|
||||
.send_voice_mem = icom_send_voice_mem,
|
||||
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS,
|
||||
};
|
||||
|
||||
int ic7300_set_parm(RIG *rig, setting_t parm, value_t val)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
|
|
@ -869,9 +869,10 @@ static vfo_t icom_current_vfo(RIG *rig)
|
|||
vfo_t chkVFO = RIG_VFO_A;
|
||||
struct rig_state *rs = &rig->state;
|
||||
struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
|
||||
struct icom_priv_caps *priv_caps = (struct icom_priv_caps*)rig->caps->priv;
|
||||
struct icom_priv_caps *priv_caps = (struct icom_priv_caps *)rig->caps->priv;
|
||||
|
||||
if (priv->x25cmdfails <= 0 || priv_caps->x25_always) // these newer rigs get special treatment
|
||||
if (priv->x25cmdfails <= 0
|
||||
|| priv_caps->x25_always) // these newer rigs get special treatment
|
||||
{
|
||||
return icom_current_vfo_x25(rig);
|
||||
}
|
||||
|
@ -1340,6 +1341,8 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
|
||||
freq_len = priv->civ_731_mode ? 4 : 5;
|
||||
|
||||
if (rig->caps->rig_model == RIG_MODEL_IC905) { freq_len = 6; }
|
||||
|
||||
/*
|
||||
* to_bcd requires nibble len
|
||||
*/
|
||||
|
@ -1704,8 +1707,8 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
#endif
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
if (vfo == RIG_VFO_MEM && civ_731_mode)
|
||||
{
|
||||
if (vfo == RIG_VFO_MEM && civ_731_mode)
|
||||
{
|
||||
priv->civ_731_mode = 1;
|
||||
}
|
||||
|
@ -1736,7 +1739,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: 3-byte ID5100/4100 length - turn off XONXOFF flow control\n", __func__);
|
||||
}
|
||||
else if (freq_len != 4 && freq_len != 5)
|
||||
else if (freq_len != 4 && freq_len != 5 && freq_len != 6)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: wrong frame len=%d\n",
|
||||
__func__, freq_len);
|
||||
|
@ -1746,7 +1749,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
RETURNFUNC(-RIG_ERJCTED);
|
||||
}
|
||||
|
||||
if (freq_len != 3 && freq_len != (priv->civ_731_mode ? 4 : 5))
|
||||
if (freq_len != 3 && freq_len != 6 && freq_len != (priv->civ_731_mode ? 4 : 5))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: freq len (%d) differs from expected\n",
|
||||
__func__, freq_len);
|
||||
|
@ -2777,14 +2780,17 @@ int icom_get_vfo(RIG *rig, vfo_t *vfo)
|
|||
unsigned char ackbuf[MAXFRAMELEN];
|
||||
int ack_len = sizeof(ackbuf), retval;
|
||||
retval = icom_transaction(rig, 0x07, 0xd2, NULL, 0, ackbuf, &ack_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: %s\n", __func__, rigerror(retval));
|
||||
return -retval;
|
||||
}
|
||||
|
||||
dump_hex(ackbuf, ack_len);
|
||||
if (ackbuf[2] == 0) *vfo = RIG_VFO_MAIN;
|
||||
else *vfo = RIG_VFO_SUB;
|
||||
|
||||
if (ackbuf[2] == 0) { *vfo = RIG_VFO_MAIN; }
|
||||
else { *vfo = RIG_VFO_SUB; }
|
||||
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
@ -3055,6 +3061,7 @@ int icom_set_vfo(RIG *rig, vfo_t vfo)
|
|||
{
|
||||
case RIG_VFO_CURR:
|
||||
break; // no change needed
|
||||
|
||||
case RIG_VFO_A:
|
||||
icvfo = vfo = RIG_VFO_B;
|
||||
break;
|
||||
|
@ -5800,7 +5807,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
|
|||
RETURNFUNC2(retval);
|
||||
}
|
||||
|
||||
if (priv->x25cmdfails < 0) priv->x25cmdfails = 1;
|
||||
if (priv->x25cmdfails < 0) { priv->x25cmdfails = 1; }
|
||||
}
|
||||
}
|
||||
else // we're in satmode so we try another command
|
||||
|
@ -8079,7 +8086,8 @@ int icom_set_powerstat(RIG *rig, powerstat_t status)
|
|||
|
||||
if (retval != RIG_OK) { sleep(1); }
|
||||
}
|
||||
if (retval == RIG_OK) priv->poweron = 1;
|
||||
|
||||
if (retval == RIG_OK) { priv->poweron = 1; }
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
@ -8182,7 +8190,7 @@ int icom_get_powerstat(RIG *rig, powerstat_t *status)
|
|||
if (rig->caps->rig_model == RIG_MODEL_ICR75)
|
||||
{
|
||||
/* getting the mode doesn't work if a memory is blank */
|
||||
/* so use one of the more innculous 'set mode' commands instead */
|
||||
/* so use one of the more innocuous 'set mode' commands instead */
|
||||
int cmd_len = 1;
|
||||
unsigned char cmdbuf[MAXFRAMELEN];
|
||||
cmdbuf[0] = S_PRM_TIME;
|
||||
|
@ -8198,13 +8206,14 @@ int icom_get_powerstat(RIG *rig, powerstat_t *status)
|
|||
RIG_POWER_ON : RIG_POWER_OFF;
|
||||
}
|
||||
|
||||
if (rig->caps->rig_model == RIG_MODEL_IC2730
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7100
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7300
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7600
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7610
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7700
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7800)
|
||||
if (rig->caps->rig_model == RIG_MODEL_IC2730
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7100
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7300
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7600
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7610
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7700
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC7800
|
||||
|| rig->caps->rig_model == RIG_MODEL_IC905)
|
||||
{
|
||||
freq_t freq;
|
||||
int retrysave = rig->caps->retry;
|
||||
|
@ -9071,12 +9080,14 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
|
|||
rig_fire_freq_event(rig, RIG_VFO_CURR, freq);
|
||||
|
||||
#if 0
|
||||
|
||||
if (rs->use_cached_freq != 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): use_cached_freq turning on\n", __func__,
|
||||
__LINE__);
|
||||
rs->use_cached_freq = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
@ -9844,6 +9855,7 @@ DECLARE_INITRIG_BACKEND(icom)
|
|||
|
||||
rig_register(&ic820h_caps);
|
||||
rig_register(&ic821h_caps);
|
||||
rig_register(&ic905_caps);
|
||||
rig_register(&ic910_caps);
|
||||
rig_register(&ic9100_caps);
|
||||
rig_register(&ic970_caps);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#define BACKEND_VER "20230520"
|
||||
#define BACKEND_VER "20230530"
|
||||
|
||||
#define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31)
|
||||
#define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51)
|
||||
|
@ -459,6 +459,7 @@ extern const struct rig_caps ic7300_caps;
|
|||
extern const struct rig_caps ic781_caps;
|
||||
extern const struct rig_caps ic820h_caps;
|
||||
extern const struct rig_caps ic821h_caps;
|
||||
extern const struct rig_caps ic905_caps;
|
||||
extern const struct rig_caps ic910_caps;
|
||||
extern const struct rig_caps ic9100_caps;
|
||||
extern const struct rig_caps ic970_caps;
|
||||
|
|
|
@ -8,7 +8,7 @@ DISTCLEANFILES =
|
|||
|
||||
bin_PROGRAMS =
|
||||
|
||||
check_PROGRAMS = simelecraft simicom simkenwood simyaesu simicom9100 simicom9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simicom7300 simicom7100 simatd578
|
||||
check_PROGRAMS = simelecraft simicom simkenwood simyaesu simicom9100 simicom9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simicom7300 simicom7100 simatd578 simicom905
|
||||
|
||||
simelecraft_SOURCES = simelecraft.c
|
||||
simicom_SOURCES = simicom.c
|
||||
|
|
|
@ -0,0 +1,618 @@
|
|||
// simicom will show the pts port to use for rigctl on Unix
|
||||
// using virtual serial ports on Windows is to be developed yet
|
||||
// Needs a lot of improvement to work on all Icoms
|
||||
// gcc -g -Wall -o simicom simicom.c -lhamlib
|
||||
// On mingw in the hamlib src directory
|
||||
// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32
|
||||
#define _XOPEN_SOURCE 700
|
||||
// since we are POSIX here we need this
|
||||
struct ip_mreq
|
||||
{
|
||||
int dummy;
|
||||
};
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <hamlib/rig.h>
|
||||
#include "../src/misc.h"
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#define BUFSIZE 256
|
||||
#define X25
|
||||
|
||||
int civ_731_mode = 0;
|
||||
vfo_t current_vfo = RIG_VFO_A;
|
||||
int split = 0;
|
||||
|
||||
// we make B different from A to ensure we see a difference at startup
|
||||
float freqA = 14074000;
|
||||
float freqB = 14074500;
|
||||
mode_t modeA = RIG_MODE_PKTUSB;
|
||||
mode_t modeB = RIG_MODE_PKTUSB;
|
||||
int datamodeA = 0;
|
||||
int datamodeB = 0;
|
||||
pbwidth_t widthA = 0;
|
||||
pbwidth_t widthB = 1;
|
||||
ant_t ant_curr = 0;
|
||||
int ant_option = 0;
|
||||
int ptt = 0;
|
||||
int satmode = 0;
|
||||
int agc_time = 1;
|
||||
int ovf_status = 0;
|
||||
int powerstat = 1;
|
||||
|
||||
void dumphex(unsigned char *buf, int n)
|
||||
{
|
||||
for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); }
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int
|
||||
frameGet(int fd, unsigned char *buf)
|
||||
{
|
||||
int i = 0;
|
||||
memset(buf, 0, BUFSIZE);
|
||||
unsigned char c;
|
||||
|
||||
again:
|
||||
|
||||
while (read(fd, &c, 1) > 0)
|
||||
{
|
||||
buf[i++] = c;
|
||||
//printf("i=%d, c=0x%02x\n",i,c);
|
||||
|
||||
if (c == 0xfd)
|
||||
{
|
||||
dumphex(buf, i);
|
||||
return i;
|
||||
}
|
||||
|
||||
if (i > 2 && c == 0xfe)
|
||||
{
|
||||
printf("Turning power on due to 0xfe string\n");
|
||||
powerstat = 1;
|
||||
int j;
|
||||
|
||||
for (j = i; j < 175; ++j)
|
||||
{
|
||||
if (read(fd, &c, 1) < 0) { break; }
|
||||
}
|
||||
|
||||
i = 0;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Error??? c=x%02x\n", c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void frameParse(int fd, unsigned char *frame, int len)
|
||||
{
|
||||
double freq;
|
||||
int n = 0;
|
||||
|
||||
dumphex(frame, len);
|
||||
|
||||
if (frame[0] != 0xfe && frame[1] != 0xfe)
|
||||
{
|
||||
printf("expected fe fe, got ");
|
||||
dumphex(frame, len);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (frame[4])
|
||||
{
|
||||
case 0x03:
|
||||
|
||||
//from_bcd(frameackbuf[2], (civ_731_mode ? 4 : 5) * 2);
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN)
|
||||
{
|
||||
printf("get_freqA\n");
|
||||
to_bcd(&frame[5], (long long)freqA, (civ_731_mode ? 4 : 5) * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("get_freqB\n");
|
||||
to_bcd(&frame[5], (long long)freqB, (civ_731_mode ? 4 : 5) * 2);
|
||||
}
|
||||
|
||||
frame[10] = 0xfd;
|
||||
|
||||
if (powerstat)
|
||||
{
|
||||
n = write(fd, frame, 11);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN)
|
||||
{
|
||||
printf("get_modeA\n");
|
||||
frame[5] = modeA;
|
||||
frame[6] = widthA;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("get_modeB\n");
|
||||
frame[5] = modeB;
|
||||
frame[6] = widthB;
|
||||
}
|
||||
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
break;
|
||||
|
||||
case 0x05:
|
||||
freq = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2);
|
||||
printf("set_freq to %.0f\n", freq);
|
||||
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { freqA = freq; }
|
||||
else { freqB = freq; }
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
case 0x06:
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { modeA = frame[6]; }
|
||||
else { modeB = frame[6]; }
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
case 0x07:
|
||||
|
||||
switch (frame[5])
|
||||
{
|
||||
case 0x00: current_vfo = RIG_VFO_A; break;
|
||||
|
||||
case 0x01: current_vfo = RIG_VFO_B; break;
|
||||
|
||||
case 0xd0: current_vfo = RIG_VFO_MAIN; break;
|
||||
|
||||
case 0xd1: current_vfo = RIG_VFO_SUB; break;
|
||||
}
|
||||
|
||||
printf("set_vfo to %s\n", rig_strvfo(current_vfo));
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
case 0x0f:
|
||||
if (frame[5] == 0) { split = 0; }
|
||||
else if (frame[5] == 1) { split = 1; }
|
||||
else { frame[6] = split; }
|
||||
|
||||
if (frame[5] == 0xfd)
|
||||
{
|
||||
printf("get split %d\n", 1);
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("set split %d\n", 1);
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x12: // we're simulating the 3-byte version -- not the 2-byte
|
||||
if (frame[5] != 0xfd)
|
||||
{
|
||||
printf("Set ant %d\n", -1);
|
||||
ant_curr = frame[5];
|
||||
ant_option = frame[6];
|
||||
dump_hex(frame, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Get ant\n");
|
||||
}
|
||||
|
||||
frame[5] = ant_curr;
|
||||
frame[6] = ant_option;
|
||||
frame[7] = 0xfd;
|
||||
printf("write 8 bytes\n");
|
||||
dump_hex(frame, 8);
|
||||
n = write(fd, frame, 8);
|
||||
break;
|
||||
|
||||
case 0x14:
|
||||
switch (frame[5])
|
||||
{
|
||||
static int power_level = 0;
|
||||
|
||||
case 0x07:
|
||||
case 0x08:
|
||||
if (frame[6] != 0xfd)
|
||||
{
|
||||
frame[6] = 0xfb;
|
||||
dumphex(frame, 7);
|
||||
n = write(fd, frame, 7);
|
||||
printf("ACK x14 x08\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
to_bcd(&frame[6], (long long)128, 2);
|
||||
frame[8] = 0xfb;
|
||||
dumphex(frame, 9);
|
||||
n = write(fd, frame, 9);
|
||||
printf("SEND x14 x08\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x0a:
|
||||
printf("Using power level %d\n", power_level);
|
||||
power_level += 10;
|
||||
|
||||
if (power_level > 250) { power_level = 0; }
|
||||
|
||||
to_bcd(&frame[6], (long long)power_level, 2);
|
||||
frame[8] = 0xfd;
|
||||
n = write(fd, frame, 9);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x15:
|
||||
switch (frame[5])
|
||||
{
|
||||
static int meter_level = 0;
|
||||
|
||||
case 0x07:
|
||||
frame[6] = ovf_status;
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
ovf_status = ovf_status == 0 ? 1 : 0;
|
||||
break;
|
||||
|
||||
case 0x11:
|
||||
printf("Using meter level %d\n", meter_level);
|
||||
meter_level += 10;
|
||||
|
||||
if (meter_level > 250) { meter_level = 0; }
|
||||
|
||||
to_bcd(&frame[6], (long long)meter_level, 2);
|
||||
frame[8] = 0xfd;
|
||||
n = write(fd, frame, 9);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x16:
|
||||
switch (frame[5])
|
||||
{
|
||||
case 0x5a:
|
||||
if (frame[6] == 0xfe)
|
||||
{
|
||||
satmode = frame[6];
|
||||
}
|
||||
else
|
||||
{
|
||||
frame[6] = satmode;
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x18: // miscellaneous things
|
||||
frame[5] = 1;
|
||||
frame[6] = 0xfd;
|
||||
n = write(fd, frame, 7);
|
||||
break;
|
||||
|
||||
case 0x19: // miscellaneous things
|
||||
frame[5] = 0x94;
|
||||
frame[6] = 0xfd;
|
||||
n = write(fd, frame, 7);
|
||||
break;
|
||||
|
||||
case 0x1a: // miscellaneous things
|
||||
switch (frame[5])
|
||||
{
|
||||
case 0x03: // width
|
||||
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { frame[6] = widthA; }
|
||||
else { frame[6] = widthB; }
|
||||
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
break;
|
||||
|
||||
case 0x04: // AGC TIME
|
||||
printf("frame[6]==x%02x, frame[7]=0%02x\n", frame[6], frame[7]);
|
||||
|
||||
if (frame[6] == 0xfd) // the we are reading
|
||||
{
|
||||
frame[6] = agc_time;
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("AGC_TIME RESPONSE******************************");
|
||||
agc_time = frame[6];
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x07: // satmode
|
||||
frame[4] = 0;
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x1c:
|
||||
switch (frame[5])
|
||||
{
|
||||
case 0:
|
||||
if (frame[6] == 0xfd)
|
||||
{
|
||||
frame[6] = ptt;
|
||||
frame[7] = 0xfd;
|
||||
n = write(fd, frame, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptt = frame[6];
|
||||
frame[7] = 0xfb;
|
||||
frame[8] = 0xfd;
|
||||
n = write(fd, frame, 9);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
#ifdef X25
|
||||
|
||||
case 0x25:
|
||||
if (frame[6] == 0xfd)
|
||||
{
|
||||
if (frame[5] == 0x00)
|
||||
{
|
||||
to_bcd(&frame[6], (long long)freqA, 6 * 2);
|
||||
printf("X25 get_freqA=%.0f\n", freqA);
|
||||
}
|
||||
else
|
||||
{
|
||||
to_bcd(&frame[6], (long long)freqB, 6 * 2);
|
||||
printf("X25 get_freqB=%.0f\n", freqB);
|
||||
}
|
||||
|
||||
frame[12] = 0xfd;
|
||||
unsigned char frame2[12];
|
||||
|
||||
frame2[0] = 0xfe;
|
||||
frame2[1] = 0xfe;
|
||||
frame2[2] = 0x00; // send transceive frame
|
||||
frame2[3] = frame[3]; // send transceive frame
|
||||
frame2[4] = 0x00;
|
||||
frame2[5] = 0x70;
|
||||
frame2[6] = 0x28;
|
||||
frame2[7] = 0x57;
|
||||
frame2[8] = 0x03;
|
||||
frame2[9] = 0x00;
|
||||
frame2[10] = 0x00;
|
||||
frame2[11] = 0xfd;
|
||||
n = write(fd, frame2, 12);
|
||||
n = write(fd, frame, 13);
|
||||
}
|
||||
else
|
||||
{
|
||||
freq = from_bcd(&frame[6], (civ_731_mode ? 4 : 5) * 2);
|
||||
printf("set_freq to %.0f\n", freq);
|
||||
|
||||
if (frame[5] == 0x00) { freqA = freq; }
|
||||
else { freqB = freq; }
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
// send async frame
|
||||
frame[2] = 0x00; // async freq
|
||||
frame[3] = 0xa2;
|
||||
frame[4] = 0x00;
|
||||
frame[5] = 0x00;
|
||||
frame[6] = 0x10;
|
||||
frame[7] = 0x01;
|
||||
frame[8] = 0x96;
|
||||
frame[9] = 0x12;
|
||||
frame[10] = 0xfd;
|
||||
n = write(fd, frame, 11);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x26:
|
||||
for (int i = 0; i < 6; ++i) { printf("%02x:", frame[i]); }
|
||||
|
||||
if (frame[6] == 0xfd) // then a query
|
||||
{
|
||||
for (int i = 0; i < 6; ++i) { printf("%02x:", frame[i]); }
|
||||
|
||||
frame[6] = frame[5] == 0 ? modeA : modeB;
|
||||
frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
|
||||
frame[8] = 0xfb;
|
||||
frame[9] = 0xfd;
|
||||
n = write(fd, frame, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 12; ++i) { printf("%02x:", frame[i]); }
|
||||
|
||||
if (frame[6] == 0)
|
||||
{
|
||||
modeA = frame[7];
|
||||
datamodeA = frame[8];
|
||||
}
|
||||
else
|
||||
{
|
||||
modeB = frame[7];
|
||||
datamodeB = frame[8];
|
||||
}
|
||||
|
||||
frame[4] = 0xfb;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
break;
|
||||
#else
|
||||
|
||||
case 0x25:
|
||||
printf("x25 send nak\n");
|
||||
frame[4] = 0xfa;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
break;
|
||||
|
||||
case 0x26:
|
||||
printf("x26 send nak\n");
|
||||
frame[4] = 0xfa;
|
||||
frame[5] = 0xfd;
|
||||
n = write(fd, frame, 6);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default: printf("cmd 0x%02x unknown\n", frame[4]);
|
||||
}
|
||||
|
||||
if (n == 0) { printf("Write failed=%s\n", strerror(errno)); }
|
||||
|
||||
// don't care about the rig type yet
|
||||
|
||||
}
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
int openPort(char *comport) // doesn't matter for using pts devices
|
||||
{
|
||||
int fd;
|
||||
fd = open(comport, O_RDWR);
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
perror(comport);
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
#else
|
||||
int openPort(char *comport) // doesn't matter for using pts devices
|
||||
{
|
||||
int fd = posix_openpt(O_RDWR);
|
||||
char *name = ptsname(fd);
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
perror("pstname");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("name=%s\n", name);
|
||||
|
||||
if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1)
|
||||
{
|
||||
perror("posix_openpt");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
void rigStatus()
|
||||
{
|
||||
char vfoa = current_vfo == RIG_VFO_A ? '*' : ' ';
|
||||
char vfob = current_vfo == RIG_VFO_B ? '*' : ' ';
|
||||
printf("%cVFOA: mode=%d datamode=%d width=%ld freq=%.0f\n", vfoa, modeA,
|
||||
datamodeA,
|
||||
widthA,
|
||||
freqA);
|
||||
printf("%cVFOB: mode=%d datamode=%d width=%ld freq=%.0f\n", vfob, modeB,
|
||||
datamodeB,
|
||||
widthB,
|
||||
freqB);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unsigned char buf[256];
|
||||
int fd = openPort(argv[1]);
|
||||
|
||||
printf("%s: %s\n", argv[0], rig_version());
|
||||
#ifdef X25
|
||||
printf("x25/x26 command recognized\n");
|
||||
#else
|
||||
printf("x25/x26 command rejected\n");
|
||||
#endif
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("Missing comport argument\n");
|
||||
printf("%s [comport]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
int len = frameGet(fd, buf);
|
||||
|
||||
if (len <= 0)
|
||||
{
|
||||
close(fd);
|
||||
fd = openPort(argv[1]);
|
||||
}
|
||||
|
||||
if (powerstat)
|
||||
{
|
||||
frameParse(fd, buf, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
hl_usleep(1000 * 1000);
|
||||
}
|
||||
|
||||
rigStatus();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -201,7 +201,7 @@ int HAMLIB_API rig_register(const struct rig_caps *caps)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: rig_register (%u)\n",
|
||||
__func__,
|
||||
|
|
Ładowanie…
Reference in New Issue