Porównaj commity

...

21 Commity

Autor SHA1 Wiadomość Data
Michael Black 697c090935
Merge pull request #1501 from GeoBaltz/fix9
Add calibration table for RFPOWER_METER_WATTS in ts890.c
2024-02-01 16:50:48 -06:00
George Baltz N3GB b6dc6110a6 Bring simts890.c a little closer to the real thing
Still needs more work.
2024-02-01 17:34:47 -05:00
George Baltz N3GB 4ef5bd4142 Add calibration table for TS-890S RFPOWER_METER_WATTS
Make sure we only get RFPOWER_WATTS during xmit, and STRENGTH during receive; else return -RIG_ENAVAIL.
2024-02-01 17:34:47 -05:00
Mike Black W9MDB a03a79c864 Add tone_enable in more places to cover all set_split_freq cases 2024-02-01 15:48:01 -06:00
Mike Black W9MDB 7436e4395f Add FUNC_TONE tone_enable to icom_set_split_freq too 2024-02-01 15:41:36 -06:00
Mike Black W9MDB 7310f370c1 IC705 remove get_powerstat -- doesn't work
Icom do not get width for FM or FMN -- doesn't work
Add tone_enable option to overcome bug in IC-705 where changing freq turns off TONE
2024-02-01 15:35:19 -06:00
Mike Black W9MDB d9bae6f46f Add simxiegux108g 2024-02-01 12:39:07 -06:00
Mike Black W9MDB 434f399d12 Update simulators 2024-02-01 12:38:12 -06:00
Mike Black W9MDB 68fca2c73d Some more places where band_index needs updating 2024-01-31 17:43:10 -06:00
Mike Black W9MDB 75a4d324de Update band_index in newcat.c when BS is executed 2024-01-31 17:39:49 -06:00
Mike Black W9MDB c969405c26 Fix rigctlsync for FT991
2efc2069f5 (commitcomment-138121815)
2024-01-31 17:30:36 -06:00
Michael Black 2707863209
Merge pull request #1498 from GeoBaltz/fix8
Make simulator match the Real World(TM)
2024-01-31 16:38:26 -06:00
George Baltz N3GB 35e49ffdfc Make simulator match the Real World(TM)
Add missing P4
Repair RIG_LEVEL_STRENGTH
2024-01-31 12:37:14 -05:00
Mike Black W9MDB 4fe6ea7cc4 Remove unused variables 2024-01-31 10:32:00 -06:00
Mike Black W9MDB fff1bbc8cd Add RFPOWER_METER_WATTS to TS890
https://github.com/Hamlib/Hamlib/issues/1497
2024-01-31 10:29:46 -06:00
Mike Black W9MDB b4ec8a427c Fix return value in test_2038
https://github.com/Hamlib/Hamlib/issues/1492
2024-01-30 11:02:05 -06:00
Michael Black 25a8d65860
Merge pull request #1495 from wvolz/flex6k-add-rfpower
flex6xxx Add get and set RFPOWER level capability
2024-01-30 06:47:26 -06:00
Warren Volz 1ea95c94ee flex6xxx add ability to set rfpower level 2024-01-29 23:22:47 -07:00
Warren Volz 9f6ca84572 flex6xxx add rfpower level 2024-01-29 16:37:58 -07:00
Mike Black W9MDB 8d59c9302f Change test_2038 routine to return error on time_t size==4
Seems ctime might be seg faulting on the test
https://github.com/Hamlib/Hamlib/issues/1492
2024-01-29 07:52:56 -06:00
Mike Black W9MDB 793bc1a0dc Update simic9700.c 2024-01-28 12:56:01 -06:00
14 zmienionych plików z 1200 dodań i 46 usunięć

Wyświetl plik

@ -1306,7 +1306,7 @@ struct rig_caps ic705_caps =
RIG_MODEL(RIG_MODEL_IC705),
.model_name = "IC-705",
.mfg_name = "Icom",
.version = BACKEND_VER ".9",
.version = BACKEND_VER ".10",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -1562,7 +1562,7 @@ struct rig_caps ic705_caps =
.set_split_vfo = icom_set_split_vfo,
.get_split_vfo = icom_get_split_vfo,
.set_powerstat = icom_set_powerstat,
.get_powerstat = icom_get_powerstat,
// .get_powerstat = icom_get_powerstat, // powerstat is write only
.power2mW = icom_power2mW,
.mW2power = icom_mW2power,
.send_morse = icom_send_morse,

Wyświetl plik

@ -436,6 +436,7 @@ struct icom_addr
#define TOK_CIVADDR TOKEN_BACKEND(1)
#define TOK_MODE731 TOKEN_BACKEND(2)
#define TOK_NOXCHG TOKEN_BACKEND(3)
#define TOK_TONE_ENABLE TOKEN_BACKEND(4)
const struct confparams icom_cfg_params[] =
{
@ -453,6 +454,11 @@ const struct confparams icom_cfg_params[] =
"Don't Use VFO XCHG to set other VFO mode and Frequency",
"0", RIG_CONF_CHECKBUTTON
},
{
TOK_TONE_ENABLE, "tone_enable", "Turn tone on",
"Overcome a bug in IC-705 to enable tone after frequency change",
"0", RIG_CONF_CHECKBUTTON
},
{RIG_CONF_END, NULL,}
};
@ -1606,6 +1612,11 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
RETURNFUNC2(retval);
}
if (priv->tone_enable)
{
// IC-705 as of 2024-02-01 turn off TONE on freq change so we turn it back on if enabled
rig_set_func(rig, RIG_VFO_CURR, RIG_FUNC_TONE,1);
}
RETURNFUNC2(RIG_OK);
}
@ -1908,7 +1919,8 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode)
}
// TODO: Skip for Xiegu G90 too????
if (RIG_MODEL_X108G == rig->caps->rig_model
if (mode == RIG_MODE_FM || mode == RIG_MODE_FMN
|| RIG_MODEL_X108G == rig->caps->rig_model
|| RIG_MODEL_X5105 == rig->caps->rig_model)
{
priv->no_1a_03_cmd = ENUM_1A_03_NO;
@ -4933,6 +4945,10 @@ int icom_set_conf(RIG *rig, hamlib_token_t token, const char *val)
priv->no_xchg = atoi(val) ? 1 : 0;
break;
case TOK_TONE_ENABLE:
priv->tone_enable = atoi(val) ? 1 : 0;
break;
default:
RETURNFUNC(-RIG_EINVAL);
}
@ -5446,6 +5462,10 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
if (retval == RIG_OK)
{
if (priv->tone_enable)
{
rig_set_func(rig, RIG_VFO_CURR, RIG_FUNC_TONE, 1);
}
RETURNFUNC2(retval);
}
}
@ -5550,6 +5570,10 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
RETURNFUNC2(retval);
}
}
if (priv->tone_enable)
{
rig_set_func(rig, RIG_VFO_CURR, RIG_FUNC_TONE, 1);
}
RETURNFUNC2(retval);
}

Wyświetl plik

@ -35,7 +35,7 @@
#include <sys/time.h>
#endif
#define BACKEND_VER "20231209"
#define BACKEND_VER "20240201"
#define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31)
#define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51)
@ -292,6 +292,7 @@ struct icom_priv_data
freq_t other_freq_deprecated; /*!< @deprecated Use rig_cache.freqOther - Our other freq depending on which vfo is selected */
int vfo_flag; // used to skip vfo check when frequencies are equal
int dual_watch_main_sub; // 0=main, 1=sub
int tone_enable; /*!< Re-enable tone after freq change -- IC-705 bug with gpredict */
};
extern const struct ts_sc_list r8500_ts_sc_list[];

Wyświetl plik

@ -37,7 +37,7 @@
#define F6K_FUNC_ALL (RIG_FUNC_VOX|RIG_FUNC_TUNER)
#define F6K_LEVEL_ALL (RIG_LEVEL_SLOPE_HIGH|RIG_LEVEL_SLOPE_LOW|RIG_LEVEL_KEYSPD)
#define F6K_LEVEL_ALL (RIG_LEVEL_SLOPE_HIGH|RIG_LEVEL_SLOPE_LOW|RIG_LEVEL_KEYSPD|RIG_LEVEL_RFPOWER)
#define F6K_VFO (RIG_VFO_A|RIG_VFO_B)
#define POWERSDR_VFO_OP (RIG_OP_BAND_UP|RIG_OP_BAND_DOWN|RIG_OP_UP|RIG_OP_DOWN)
@ -738,6 +738,105 @@ int powersdr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
return RIG_OK;
}
/*
* flek6k_set_level
*/
int flex6k_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
char cmd[KENWOOD_MAX_BUF_LEN];
int retval;
int ival;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (level)
{
case RIG_LEVEL_RFPOWER:
if (val.f > 1.0) { return -RIG_EINVAL; }
ival = val.f * 100;
SNPRINTF(cmd, sizeof(cmd) - 1, "ZZPC%03d", ival);
break;
default:
return kenwood_set_level(rig, vfo, level, val);
}
retval = kenwood_transaction(rig, cmd, NULL, 0);
if (retval != RIG_OK)
{
return retval;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s exiting\n", __func__);
return RIG_OK;
}
/*
* flex6k_get_level
*/
int flex6k_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
char lvlbuf[KENWOOD_MAX_BUF_LEN];
char *cmd;
int retval;
int len, ans;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!val)
{
return -RIG_EINVAL;
}
switch (level)
{
case RIG_LEVEL_RFPOWER:
cmd = "ZZPC";
len = 4;
ans = 3;
break;
default:
return kenwood_get_level(rig, vfo, level, val);
}
retval = kenwood_safe_transaction(rig, cmd, lvlbuf, sizeof(lvlbuf), len + ans);
if (retval != RIG_OK)
{
return retval;
}
int n;
switch (level)
{
case RIG_LEVEL_RFPOWER:
n = sscanf(lvlbuf, "ZZPC%f", &val->f);
if (n != 1)
{
rig_debug(RIG_DEBUG_ERR, "%s: Error parsing value from lvlbuf='%s'\n",
__func__, lvlbuf);
val->f = 0;
return -RIG_EPROTO;
}
val->f /= 100;
break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: should never get here\n", __func__);
}
return RIG_OK;
}
/*
* powersdr_get_level
*/
@ -1241,7 +1340,7 @@ struct rig_caps f6k_caps =
RIG_MODEL(RIG_MODEL_F6K),
.model_name = "6xxx",
.mfg_name = "FlexRadio",
.version = "20230606.0",
.version = "20240129.0",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -1359,8 +1458,8 @@ struct rig_caps f6k_caps =
.set_ptt = kenwood_set_ptt,
// TODO copy over kenwood_[set|get]_level and modify to handle DSP filter values
// correctly - use actual values instead of indices
.set_level = kenwood_set_level,
.get_level = kenwood_get_level,
.set_level = flex6k_set_level,
.get_level = flex6k_get_level,
//.set_ant = kenwood_set_ant_no_ack,
//.get_ant = kenwood_get_ant,
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS

Wyświetl plik

@ -36,7 +36,7 @@
#define TS890_AM_TX_MODES RIG_MODE_AM
#define TS890_LEVEL_SET (RIG_LEVEL_RFPOWER|RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_SQL|RIG_LEVEL_AGC|RIG_LEVEL_KEYSPD|RIG_LEVEL_CWPITCH|RIG_LEVEL_ATT|RIG_LEVEL_USB_AF|RIG_LEVEL_USB_AF_INPUT)
#define TS890_LEVEL_GET (RIG_LEVEL_RFPOWER|RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_SQL|RIG_LEVEL_AGC|RIG_LEVEL_KEYSPD|RIG_LEVEL_ALC|RIG_LEVEL_SWR|RIG_LEVEL_COMP_METER|RIG_LEVEL_ID_METER|RIG_LEVEL_VD_METER|RIG_LEVEL_TEMP_METER|RIG_LEVEL_CWPITCH|RIG_LEVEL_RAWSTR|RIG_LEVEL_STRENGTH|RIG_LEVEL_ATT|RIG_LEVEL_USB_AF|RIG_LEVEL_USB_AF_INPUT)
#define TS890_LEVEL_GET (RIG_LEVEL_RFPOWER|RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_SQL|RIG_LEVEL_AGC|RIG_LEVEL_KEYSPD|RIG_LEVEL_ALC|RIG_LEVEL_SWR|RIG_LEVEL_COMP_METER|RIG_LEVEL_ID_METER|RIG_LEVEL_VD_METER|RIG_LEVEL_TEMP_METER|RIG_LEVEL_CWPITCH|RIG_LEVEL_RAWSTR|RIG_LEVEL_STRENGTH|RIG_LEVEL_ATT|RIG_LEVEL_USB_AF|RIG_LEVEL_USB_AF_INPUT|RIG_LEVEL_RFPOWER_METER_WATTS)
#define TS890_FUNC_ALL (RIG_FUNC_NB|RIG_FUNC_NB2|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_NR|RIG_FUNC_BC|RIG_FUNC_BC2|RIG_FUNC_RIT|RIG_FUNC_XIT|RIG_FUNC_TUNER|RIG_FUNC_SEND_MORSE|RIG_FUNC_TONE|RIG_FUNC_TSQL)
#define TS890_VFO_OPS (RIG_OP_UP|RIG_OP_DOWN|RIG_OP_BAND_UP|RIG_OP_BAND_DOWN|RIG_OP_CPY|RIG_OP_TUNE)
@ -289,8 +289,10 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return -RIG_ENIMPL;
case RIG_LEVEL_STRENGTH:
case RIG_LEVEL_RFPOWER_METER_WATTS:
{
cal_table_float_t *table;
ptt_t ptt;
/* Values taken from the TS-890S In-Depth Manual (IDM), p. 8
* 0.03 - 21.5 MHz, Preamp 1
*/
@ -310,6 +312,20 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{48, 20}, {59, 40}, {70, 60}
}
};
static cal_table_t power_meter =
{
7, { { 0, 0}, { 5, 5}, { 10, 10}, {19, 25},
{ 35, 50}, { 59, 100}, { 70, 150}
}
};
/* Make sure we're asking the right question */
kenwood_get_ptt(rig, vfo, &ptt);
if ((ptt == RIG_PTT_OFF) != (level == RIG_LEVEL_STRENGTH))
{
/* We're sorry, the number you have dialed is not in service */
return -RIG_ENAVAIL;
}
/* Find out which meter type is in use */
retval = kenwood_safe_transaction(rig, "EX00011", ackbuf, sizeof(ackbuf), 11);
@ -341,8 +357,17 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
}
sscanf(ackbuf + 2, "%d", &val->i);
/* Convert reading back to dB (rounded) */
val->i = (int)floorf(rig_raw2val_float(val->i, table) + 0.5f);
if (level == RIG_LEVEL_RFPOWER_METER_WATTS)
{
val->f = rig_raw2val(val->i, &power_meter);
}
else
{
/* Convert reading back to dB (rounded) */
val->i = (int)floorf(rig_raw2val_float(val->i, table) + 0.5f);
}
return RIG_OK;
}
@ -376,22 +401,26 @@ int ts890_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
char current[4];
switch (func)
{
case RIG_FUNC_TONE:
mask = 1;
break;
case RIG_FUNC_TSQL:
mask = 2;
break;
default:
return (kenwood_set_func(rig, vfo, func, status));
}
{
case RIG_FUNC_TONE:
mask = 1;
break;
case RIG_FUNC_TSQL:
mask = 2;
break;
default:
return (kenwood_set_func(rig, vfo, func, status));
}
retval = kenwood_safe_transaction(rig, "TO", current, sizeof(current), 3);
if (retval != RIG_OK)
{
return (retval);
}
{
return (retval);
}
current[2] &= ~mask;
current[2] |= status == 0 ? 0 : mask;
return kenwood_transaction(rig, current, NULL, 0);
@ -401,24 +430,28 @@ int ts890_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
{
int mask, retval;
char current[4];
switch (func)
{
case RIG_FUNC_TONE:
mask = 1;
break;
case RIG_FUNC_TSQL:
mask = 2;
break;
default:
return (kenwood_get_func(rig, vfo, func, status));
}
{
case RIG_FUNC_TONE:
mask = 1;
break;
case RIG_FUNC_TSQL:
mask = 2;
break;
default:
return (kenwood_get_func(rig, vfo, func, status));
}
retval = kenwood_safe_transaction(rig, "TO", current, sizeof(current), 3);
if (retval != RIG_OK)
{
return retval;
}
{
return retval;
}
*status = current[2] & mask ? 1 : 0;
return RIG_OK;
}
@ -451,7 +484,7 @@ struct rig_caps ts890s_caps =
RIG_MODEL(RIG_MODEL_TS890S),
.model_name = "TS-890S",
.mfg_name = "Kenwood",
.version = BACKEND_VER ".12",
.version = BACKEND_VER ".13",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -477,7 +510,7 @@ struct rig_caps ts890s_caps =
.transceive = RIG_TRN_RIG,
.agc_level_count = 5,
.agc_levels = { RIG_AGC_OFF, RIG_AGC_SLOW, RIG_AGC_MEDIUM, RIG_AGC_FAST, RIG_AGC_ON },
.chan_list = {
.chan_list = {
{ 1, 6, RIG_MTYPE_VOICE },
{ 1, 8, RIG_MTYPE_MORSE },
RIG_CHAN_END,

Wyświetl plik

@ -688,6 +688,7 @@ int newcat_open(RIG *rig)
}
#endif
priv->band_index = -1;
RETURNFUNC(RIG_OK);
}
@ -1332,7 +1333,10 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
rig_debug(RIG_DEBUG_ERR, "%s: is_ft991=%d, rig->state.cache.split=%d, vfo=%s\n",
__func__, is_ft991, rig->state.cache.split, rig_strvfo(vfo));
if (is_ft991 && vfo == RIG_VFO_A)
if (priv->band_index < 0) priv->band_index = newcat_band_index(freq);
// only use bandstack method when actually changing bands
// there are multiple bandstacks so we just use the 1st one
if (is_ft991 && vfo == RIG_VFO_A && priv->band_index != newcat_band_index(freq))
{
if (rig->state.cache.split)
{
@ -1346,6 +1350,7 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "BS%02d;FA%09.0f;",
newcat_band_index(freq), freq);
}
priv->band_index = newcat_band_index(freq);
}
else if (RIG_MODEL_FT450 == caps->rig_model)
@ -4860,6 +4865,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "BS%02d%c", band, cat_term);
priv->band_index = band;
}
break;
@ -6923,6 +6929,7 @@ int newcat_set_parm(RIG *rig, setting_t parm, value_t val)
{
RETURNFUNC(retval);
}
priv->band_index = band;
RETURNFUNC(RIG_OK);
}
@ -6933,6 +6940,7 @@ int newcat_set_parm(RIG *rig, setting_t parm, value_t val)
int newcat_get_parm(RIG *rig, setting_t parm, value_t *val)
{
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
int retval;
ENTERFUNC;
@ -6954,6 +6962,7 @@ int newcat_get_parm(RIG *rig, setting_t parm, value_t *val)
hamlib_band_t band = rig_get_band(rig, freq, 0);
val->cs = rig_get_band_str(rig, band, 0);
priv->band_index = band;
RETURNFUNC(RIG_OK);

Wyświetl plik

@ -50,7 +50,7 @@
typedef char ncboolean;
/* shared function version */
#define NEWCAT_VER "20240127"
#define NEWCAT_VER "20240131"
/* Hopefully large enough for future use, 128 chars plus '\0' */
#define NEWCAT_DATA_LEN 129
@ -130,6 +130,7 @@ struct newcat_priv_data
int question_mark_response_means_rejected; /* the question mark response has multiple meanings */
char front_rear_status; /* e.g. FTDX5000 EX103 status */
int split_st_command_missing; /* is ST command gone? assume not until proven otherwise */
int band_index;
};
/*

Wyświetl plik

@ -8,7 +8,7 @@ DISTCLEANFILES =
bin_PROGRAMS =
check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 simic275 simtrusdx simft1000 simtmd710
check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 simic275 simtrusdx simft1000 simtmd710 simts890 simxiegux108g
simelecraft_SOURCES = simelecraft.c
simkenwood_SOURCES = simkenwood.c

Wyświetl plik

@ -453,7 +453,7 @@ void frameParse(int fd, unsigned char *frame, int len)
}
frame[11] = 0xfd;
#if 1
#if 0
unsigned char frame2[11];
frame2[0] = 0xfe;
@ -509,7 +509,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[6] = frame[5] == 0 ? modeA : modeB;
frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
frame[8] = 0xfb;
frame[8] = 0x01;
frame[9] = 0xfd;
n = write(fd, frame, 10);
}

Wyświetl plik

@ -51,6 +51,7 @@ int satmode = 0;
int agc_time = 1;
int ovf_status = 0;
int powerstat = 1;
int keyspd = 90;
void dumphex(const unsigned char *buf, int n)
{
@ -282,6 +283,25 @@ void frameParse(int fd, unsigned char *frame, int len)
break;
}
case 0x0c:
if (frame[6] != 0xfd)
{
frame[6] = 0xfb;
dumphex(frame, 7);
WRITE(fd, frame, 7);
printf("ACK x14 x0c\n");
}
else
{
frame[6] = 0;
frame[7] = keyspd;
frame[8] = 0xfd;
dumphex(frame, 9);
WRITE(fd, frame, 9);
printf("SEND x14 x0c\n");
}
break;
case 0x15:

Wyświetl plik

@ -0,0 +1,461 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simts890 -l hamlib simts890.c
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
#if 0
struct ip_mreq
{
int dummy;
};
#endif
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <hamlib/rig.h>
#define BUFSIZE 256
int mysleep = 20;
float freqA = 14074000;
float freqB = 14074500;
int filternum1 = 7;
int filternum2 = 8;
int datamode = 0;
int vfo, vfo_tx, ptt, ptt_data, ptt_mic, ptt_tune;
int operatingband;
int split;
int modeMain = 2;
int modeSub = 2;
int keyspd = 20;
#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
int
getmyline(int fd, char *buf)
{
char c;
int i = 0;
memset(buf, 0, BUFSIZE);
int retval;
while ((retval = read(fd, &c, 1)) > 0)
{
buf[i++] = c;
if (c == ';') { return strlen(buf); }
}
if (retval != 0)
{
perror("read failed:");
close(fd);
fd = openPort("");
}
if (strlen(buf) == 0) { hl_usleep(10 * 1000); }
return strlen(buf);
}
int main(int argc, char *argv[])
{
char buf[256];
char *pbuf;
int fd = openPort(argv[1]);
int freqa = 14074000, freqb = 140735000;
int modeA = 1, modeB = 2;
while (1)
{
hl_usleep(10);
buf[0] = 0;
if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); }
// else { return 0; }
if (strncmp(buf, "RM2", 3) == 0)
{
pbuf = "RM20020;";
write(fd, pbuf, strlen(pbuf));
}
else if (strcmp(buf, "RM5;") == 0)
{
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
pbuf = "RM5100000;";
write(fd, pbuf, strlen(pbuf));
}
else if (strcmp(buf, "AN0;") == 0)
{
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
pbuf = "AN030;";
write(fd, pbuf, strlen(pbuf));
}
else if (strcmp(buf, "IF;") == 0)
{
char ifbuf[256];
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
// pbuf = "IF000503130001000+0000000000030000000;"
sprintf(ifbuf, "IF%011d1000+0000002000000000000;", freqa);
//pbuf = "IF00010138698 +00000000002000000 ;
write(fd, ifbuf, strlen(ifbuf));
continue;
}
else if (strcmp(buf, "NB1;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "NB10;";
write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "RA;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "RA1;"; /* -6dB */
write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "RG;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "RG255;";
write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "MG;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "MG050;";
write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "AG;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "AG100;";
write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "FV;") == 0)
{
hl_usleep(mysleep * 1000);
pbuf = "FV1.04;";
write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strncmp(buf, "IS;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "IS+0000;");
write(fd, buf, strlen(buf));
printf("%s\n", buf);
continue;
}
else if (strncmp(buf, "IS", 2) == 0)
{
continue;
}
else if (strncmp(buf, "SM;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "SM0035;");
write(fd, buf, strlen(buf));
printf("%s\n", buf);
continue;
}
else if (strncmp(buf, "PC;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "PC100;");
write(fd, buf, strlen(buf));
printf("%s\n", buf);
continue;
}
else if (strcmp(buf, "FW1;") == 0)
{
//usleep(mysleep * 1000);
pbuf = "FW10;";
write(fd, pbuf, strlen(pbuf));
hl_usleep(20 * 1000);
continue;
}
else if (strncmp(buf, "FW", 2) == 0)
{
continue;
}
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
int id = 24;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
write(fd, buf, strlen(buf));
continue;
}
#if 0
else if (strncmp(buf, "AI", 2) == 0)
{
if (strcmp(buf, "AI;"))
{
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
n = fprintf(fp, "%s", "AI0;");
}
}
#endif
else if (strcmp(buf, "EX00011;") == 0)
{
pbuf = "EX00011 001;";
write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strncmp(buf, "EX", 2) == 0)
{
continue;
}
else if (strcmp(buf, "FA;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa);
write(fd, buf, strlen(buf));
continue;
}
else if (strcmp(buf, "FB;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb);
write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "FA", 2) == 0)
{
sscanf(buf, "FA%d", &freqa);
continue;
}
else if (strncmp(buf, "FB", 2) == 0)
{
sscanf(buf, "FB%d", &freqb);
continue;
}
else if (strncmp(buf, "AI;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "AI0;");
write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "PS;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "PS1;");
write(fd, buf, strlen(buf));
continue;
}
else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0)
{
SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2],
buf[2] == '0' ? freqA : freqB,
buf[2] == '0' ? modeA + '0' : modeB + '0');
write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "SF", 2) == 0)
{
mode_t tmpmode = buf[14];
if (buf[2] == '0') { modeA = tmpmode - '0'; }
else { modeB = tmpmode - '0'; }
printf("modeA=%c, modeB=%c\n", modeA, modeB);
continue;
}
else if (strncmp(buf, "MD;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "MD%d;",
modeA); // not worried about modeB yet for simulator
write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "MD", 2) == 0)
{
sscanf(buf, "MD%d", &modeA); // not worried about modeB yet for simulator
continue;
}
else if (strncmp(buf, "FL;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "FL%03d%03d;", filternum1, filternum2);
write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "FL", 2) == 0)
{
sscanf(buf, "FL%3d%3d", &filternum1, &filternum2);
continue;
}
else if (strcmp(buf, "FR;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo);
write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "FR", 2) == 0)
{
sscanf(buf, "FR%d", &vfo);
}
else if (strcmp(buf, "FT;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx);
write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "FT", 2) == 0)
{
sscanf(buf, "FT%d", &vfo_tx);
}
else if (strncmp(buf, "DA;", 3) == 0)
{
SNPRINTF(buf, sizeof(buf), "DA%d;", datamode);
write(fd, buf, strlen(buf));
printf("%s\n", buf);
continue;
}
else if (strncmp(buf, "DA", 2) == 0)
{
sscanf(buf, "DA%d", &datamode);
printf("%s\n", buf);
continue;
}
else if (strncmp(buf, "BD;", 3) == 0)
{
continue;
}
else if (strncmp(buf, "BU;", 3) == 0)
{
continue;
}
else if (strcmp(buf, "RX;") == 0)
{
ptt = ptt_mic = ptt_data = ptt_tune = 0;
}
else if (strncmp(buf, "TX", 2) == 0)
{
ptt = ptt_mic = ptt_data = ptt_tune = 0;
switch (buf[2])
{
case ';':
case '0': ptt = ptt_mic = 1;
break;
case '1': ptt_data = 1;
break;
case '2': ptt_tune = 1;
break;
}
continue;
}
else if (strncmp(buf, "CB;", 3) == 0)
{
sprintf(buf, "CB%d;", operatingband);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "CB", 2) == 0)
{
sscanf(buf, "CB%d", &operatingband);
}
else if (strncmp(buf, "TB;", 3) == 0)
{
sprintf(buf, "TB%d;", split);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "TB", 2) == 0)
{
sscanf(buf, "TB%d", &split);
}
else if (strncmp(buf, "KS;", 3) == 0)
{
sprintf(buf, "KS%03d;", keyspd);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "KS", 2) == 0)
{
sscanf(buf, "KS%03d", &keyspd);
}
else if (strncmp(buf, "OM0;", 4) == 0)
{
sprintf(buf, "OM0%d;", modeMain);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "OM0", 3) == 0)
{
sscanf(buf, "OM0%d", &modeMain);
}
else if (strncmp(buf, "OM1;", 4) == 0)
{
sprintf(buf, "OM1%d;", modeSub);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "OM1", 3) == 0)
{
sscanf(buf, "OM1%d", &modeSub);
}
else if (strcmp(buf, "RM;") == 0)
{
sprintf(buf, "RM2%04d;", 10);
write(fd, buf, strlen(buf));
}
else if (strlen(buf) > 0)
{
fprintf(stderr, "Unknown command: %s\n", buf);
}
}
return 0;
}

Wyświetl plik

@ -438,7 +438,7 @@ int main(int argc, char *argv[])
}
else if (strncmp(buf, "KS;", 3) == 0)
{
sprintf(buf, "KS%d;", keyspd);
sprintf(buf, "KS%03d;", keyspd);
write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "KS", 2) == 0)

Wyświetl plik

@ -0,0 +1,498 @@
// 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
#if 0
struct ip_mreq
{
int dummy;
};
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/time.h>
#include <hamlib/rig.h>
#include "../src/misc.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_CW;
mode_t modeB = RIG_MODE_USB;
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 keyspd = 20;
void dumphex(const 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;
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;
}
}
//printf("Error %s\n", strerror(errno));
return 0;
}
void frameParse(int fd, unsigned char *frame, int len)
{
double freq;
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;
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;
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;
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;
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 0xb0: freq = freqA; freqA = freqB; freqB = freq; break;
}
printf("set_vfo to %s\n", rig_strvfo(current_vfo));
frame[4] = 0xfb;
frame[5] = 0xfd;
write(fd, frame, 6);
break;
case 0x0f:
if (frame[5] == 0) { split = 0; }
else { split = 1; }
printf("set split %d\n", 1);
frame[4] = 0xfb;
frame[5] = 0xfd;
write(fd, frame, 6);
break;
#if 0
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("n=write 8 bytes\n");
dump_hex(frame, 8);
write(fd, frame, 8);
break;
#endif
case 0x14:
switch (frame[5])
{
static int power_level = 0;
static int level = 0;
case 0x01:
level = 255;
printf("Using AF level %d\n", level);
to_bcd(&frame[6], (long long) level, 2);
frame[8] = 0xfd;
write(fd, frame, 9);
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;
write(fd, frame, 9);
break;
case 0x0c:
dumphex(frame, 10);
printf("subcmd=0x0c #1\n");
if (frame[6] != 0xfd) // then we have data
{
printf("subcmd=0x0c #1\n");
keyspd = from_bcd(&frame[6], 2);
frame[6] = 0xfb;
write(fd, frame, 7);
}
else
{
printf("subcmd=0x0c #1\n");
to_bcd(&frame[6], keyspd, 2);
frame[8] = 0xfd;
write(fd, frame, 9);
}
break;
}
break;
case 0x15:
switch (frame[5])
{
static int meter_level = 0;
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;
write(fd, frame, 9);
break;
}
break;
#if 0
case 0x18: // miscellaneous things
frame[5] = 1;
frame[6] = 0xfd;
write(fd, frame, 7);
break;
#endif
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;
write(fd, frame, 8);
break;
}
break;
case 0x1c:
switch (frame[5])
{
case 0:
if (frame[6] == 0xfd)
{
frame[6] = ptt;
frame[7] = 0xfd;
write(fd, frame, 8);
}
else
{
ptt = frame[6];
frame[7] = 0xfb;
frame[8] = 0xfd;
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, (civ_731_mode ? 4 : 5) * 2);
printf("get_freqA=%.0f\n", freqA);
}
else
{
to_bcd(&frame[6], (long long)freqB, (civ_731_mode ? 4 : 5) * 2);
printf("get_freqB=%.0f\n", freqB);
}
frame[11] = 0xfd;
write(fd, frame, 12);
}
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;
write(fd, frame, 6);
}
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;
write(fd, frame, 10);
}
else
{
for (int i = 0; i < 12; ++i) { printf("%02x:", frame[i]); }
if (frame[5] == 0)
{
modeA = frame[6];
datamodeA = frame[7];
}
else
{
modeB = frame[6];
datamodeB = frame[7];
}
frame[4] = 0xfb;
frame[5] = 0xfd;
write(fd, frame, 6);
}
printf("\n");
break;
#else
case 0x25:
frame[4] = 0xfa;
frame[5] = 0xfd;
break;
case 0x26:
frame[4] = 0xfa;
frame[5] = 0xfd;
break;
#endif
default: printf("cmd 0x%02x unknown\n", frame[4]);
}
// 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]);
}
frameParse(fd, buf, len);
rigStatus();
}
return 0;
}

Wyświetl plik

@ -3048,6 +3048,13 @@ int rig_test_2038(RIG *rig)
time_t x;
rig_debug(RIG_DEBUG_TRACE, "%s: enter\n", __func__);
if (sizeof(time_t) == 4)
{
rig_debug(RIG_DEBUG_TRACE, "%s: ctime is null, 2038 test failed\n", __func__);
return 1;
}
x = (time_t)((1U << 31) - 1);
char *s = ctime(&x);
@ -3056,6 +3063,7 @@ int rig_test_2038(RIG *rig)
rig_debug(RIG_DEBUG_TRACE, "%s: ctime is null, 2038 test failed\n", __func__);
return 1;
}
if (!strstr(s, "2038")) { return 1; }
x += 1;