Fix cppcheck warnings

pull/1404/head
Mike Black W9MDB 2023-10-11 23:22:42 -05:00
rodzic 501c4b62c9
commit d72127f29a
82 zmienionych plików z 571 dodań i 680 usunięć

Wyświetl plik

@ -3694,7 +3694,7 @@ extern HAMLIB_EXPORT(const char *) rig_strfunc(setting_t);
extern HAMLIB_EXPORT(const char *) rig_strlevel(setting_t); extern HAMLIB_EXPORT(const char *) rig_strlevel(setting_t);
extern HAMLIB_EXPORT(const char *) rig_strparm(setting_t); extern HAMLIB_EXPORT(const char *) rig_strparm(setting_t);
extern HAMLIB_EXPORT(const char *) rig_stragclevel(enum agc_level_e level); extern HAMLIB_EXPORT(const char *) rig_stragclevel(enum agc_level_e level);
extern HAMLIB_EXPORT(enum agc_level_e) rig_levelagcstr (char *agcString); extern HAMLIB_EXPORT(enum agc_level_e) rig_levelagcstr (const char *agcString);
extern HAMLIB_EXPORT(enum agc_level_e) rig_levelagcvalue (int agcValue); extern HAMLIB_EXPORT(enum agc_level_e) rig_levelagcvalue (int agcValue);
extern HAMLIB_EXPORT(value_t) rig_valueagclevel (enum agc_level_e agcLevel); extern HAMLIB_EXPORT(value_t) rig_valueagclevel (enum agc_level_e agcLevel);
extern HAMLIB_EXPORT(const char *) rig_strptrshift(rptr_shift_t); extern HAMLIB_EXPORT(const char *) rig_strptrshift(rptr_shift_t);

Wyświetl plik

@ -349,6 +349,7 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
width = flt->filt_list[0].width; width = flt->filt_list[0].width;
f = '1'; f = '1';
} }
// cppcheck-suppress knownConditionTrueFalse
else if ((flt->filt_list[1].width >= width) else if ((flt->filt_list[1].width >= width)
&& (width > flt->filt_list[2].width)) && (width > flt->filt_list[2].width))
{ {

Wyświetl plik

@ -992,7 +992,7 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
char *cmd_data = "DT"; char *cmd_data = "DT";
char *cmd_bw = "BW"; char *cmd_bw = "BW";
int cmd_bw_len = 6; int cmd_bw_len = 6;
struct kenwood_priv_data *priv = rig->state.priv; const struct kenwood_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo)); rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo));
@ -1537,7 +1537,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
char kmode; char kmode;
int err; int err;
char cmd_m[16]; char cmd_m[16];
struct kenwood_priv_data *priv = rig->state.priv; const struct kenwood_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -1813,7 +1813,7 @@ static int k3_get_maxpower(RIG *rig)
//int retval; //int retval;
int maxpower = 15; // K3 default power level int maxpower = 15; // K3 default power level
//char levelbuf[KENWOOD_MAX_BUF_LEN]; //char levelbuf[KENWOOD_MAX_BUF_LEN];
struct kenwood_priv_data *priv = rig->state.priv; const struct kenwood_priv_data *priv = rig->state.priv;
// default range is 0-15 if there is no KPA3 installed // default range is 0-15 if there is no KPA3 installed
if (priv->has_kpa3 || priv->has_kpa100) if (priv->has_kpa3 || priv->has_kpa100)
@ -2004,7 +2004,7 @@ int k3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
int retval; int retval;
int lvl; int lvl;
size_t len; size_t len;
struct kenwood_priv_data *priv = rig->state.priv; const struct kenwood_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);

Wyświetl plik

@ -1046,7 +1046,6 @@ int kenwood_open(RIG *rig)
if (kenwood_id_string_list[i].model == rig->caps->rig_model) if (kenwood_id_string_list[i].model == rig->caps->rig_model)
{ {
int retval;
vfo_t tx_vfo; vfo_t tx_vfo;
rig_debug(RIG_DEBUG_VERBOSE, "%s: found the right driver for %s(%u)\n", rig_debug(RIG_DEBUG_VERBOSE, "%s: found the right driver for %s(%u)\n",
__func__, rig->caps->model_name, rig->caps->rig_model); __func__, rig->caps->model_name, rig->caps->rig_model);
@ -1063,6 +1062,7 @@ int kenwood_open(RIG *rig)
if (!RIG_IS_THD74 && !RIG_IS_THD7A && !RIG_IS_TMD700) if (!RIG_IS_THD74 && !RIG_IS_THD7A && !RIG_IS_TMD700)
{ {
int retval;
// call get_split to fill in current split and tx_vfo status // call get_split to fill in current split and tx_vfo status
split_t split; split_t split;
retval = kenwood_get_split_vfo_if(rig, RIG_VFO_A, &split, &tx_vfo); retval = kenwood_get_split_vfo_if(rig, RIG_VFO_A, &split, &tx_vfo);
@ -2476,6 +2476,11 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{ {
SNPRINTF(buf, sizeof(buf), "MD%c", c); SNPRINTF(buf, sizeof(buf), "MD%c", c);
err = kenwood_transaction(rig, buf, NULL, 0); err = kenwood_transaction(rig, buf, NULL, 0);
if (err != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: MD cmd failed: %s\n", __func__, rigerror(err));
RETURNFUNC2(err);
}
} }
// determine if we need to set datamode on A or B // determine if we need to set datamode on A or B
@ -3824,6 +3829,7 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_MICGAIN: case RIG_LEVEL_MICGAIN:
{ {
int micgain_now; int micgain_now;
float vali = 0;
if (priv->micgain_min == -1) // then we need to know our min/max if (priv->micgain_min == -1) // then we need to know our min/max
{ {
@ -3843,8 +3849,8 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
rig_debug(RIG_DEBUG_ERR, "%s: Error getting MICGAIN\n", __func__); rig_debug(RIG_DEBUG_ERR, "%s: Error getting MICGAIN\n", __func__);
RETURNFUNC(ret); RETURNFUNC(ret);
} }
vali = val->i;
val->f = (val->i - priv->micgain_min) / (float)(priv->micgain_max - val->f = (vali - priv->micgain_min) / (float)(priv->micgain_max -
priv->micgain_min); priv->micgain_min);
RETURNFUNC(RIG_OK); RETURNFUNC(RIG_OK);
} }
@ -5908,7 +5914,7 @@ const char *kenwood_get_info(RIG *rig)
*/ */
DECLARE_PROBERIG_BACKEND(kenwood) DECLARE_PROBERIG_BACKEND(kenwood)
{ {
char idbuf[IDBUFSZ]; char idbuf[IDBUFSZ] = "";
int id_len = -1, i, k_id; int id_len = -1, i, k_id;
int retval = -1; int retval = -1;
int rates[] = { 115200, 57600, 38400, 19200, 9600, 4800, 1200, 0 }; /* possible baud rates */ int rates[] = { 115200, 57600, 38400, 19200, 9600, 4800, 1200, 0 }; /* possible baud rates */

Wyświetl plik

@ -28,7 +28,7 @@
#include "token.h" #include "token.h"
#include "idx_builtin.h" #include "idx_builtin.h"
#define BACKEND_VER "20231002" #define BACKEND_VER "20231011"
#define EOM_KEN ';' #define EOM_KEN ';'
#define EOM_TH '\r' #define EOM_TH '\r'

Wyświetl plik

@ -99,7 +99,7 @@ const struct rig_caps pihpsdr_caps =
RIG_MODEL(RIG_MODEL_HPSDR), RIG_MODEL(RIG_MODEL_HPSDR),
.model_name = "PiHPSDR", .model_name = "PiHPSDR",
.mfg_name = "OpenHPSDR", .mfg_name = "OpenHPSDR",
.version = BACKEND_VER ".1", .version = BACKEND_VER ".2",
.copyright = "LGPL", .copyright = "LGPL",
.status = RIG_STATUS_STABLE, .status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER, .rig_type = RIG_TYPE_TRANSCEIVER,
@ -827,11 +827,15 @@ int pihpsdr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
break; break;
case RIG_LEVEL_AGC: case RIG_LEVEL_AGC:
if (kenwood_val == RIG_AGC_OFF) { kenwood_val = 0; } if (kenwood_val == RIG_AGC_SUPERFAST) { kenwood_val = 5; }
else if (kenwood_val == RIG_AGC_SUPERFAST) { kenwood_val = 5; }
else if (kenwood_val == RIG_AGC_FAST) { kenwood_val = 10; } else if (kenwood_val == RIG_AGC_FAST) { kenwood_val = 10; }
else if (kenwood_val == RIG_AGC_MEDIUM) { kenwood_val = 15; } else if (kenwood_val == RIG_AGC_MEDIUM) { kenwood_val = 15; }
else if (kenwood_val == RIG_AGC_SLOW) { kenwood_val = 20; } else if (kenwood_val == RIG_AGC_SLOW) { kenwood_val = 20; }
else if (kenwood_val != RIG_AGC_OFF)
{
rig_debug(RIG_DEBUG_ERR, "%s: unknown AGC level, expect OFF,SLOW,MEDIUM,FAST,SUPERFAST, got %d\n", __func__, kenwood_val);
return -RIG_EINVAL;
}
SNPRINTF(levelbuf, sizeof(levelbuf), "GT%03d", kenwood_val); SNPRINTF(levelbuf, sizeof(levelbuf), "GT%03d", kenwood_val);
break; break;

Wyświetl plik

@ -624,7 +624,7 @@ th_get_vfo(RIG *rig, vfo_t *vfo)
*/ */
int tm_set_vfo_bc2(RIG *rig, vfo_t vfo) int tm_set_vfo_bc2(RIG *rig, vfo_t vfo)
{ {
struct kenwood_priv_data *priv = rig->state.priv; const struct kenwood_priv_data *priv = rig->state.priv;
char cmd[16]; char cmd[16];
int vfonum, txvfonum, vfomode = 0; int vfonum, txvfonum, vfomode = 0;
int retval; int retval;

Wyświetl plik

@ -192,7 +192,7 @@ static int thd72_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{ {
int retval; int retval;
char vfobuf[16]; char vfobuf[16];
struct kenwood_priv_data *priv = rig->state.priv; const struct kenwood_priv_data *priv = rig->state.priv;
char vfonum = '0'; char vfonum = '0';
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);

Wyświetl plik

@ -816,7 +816,7 @@ static int tmd710_scan_me(char *buf, tmd710_me *me_struct)
retval = num_sscanf(buf, retval = num_sscanf(buf,
"ME %x,%"SCNfreq",%x,%x,%x,%x,%x,%x,%d,%d,%d,%d,%d,%"SCNfreq",%d,%d", "ME %x,%"SCNfreq",%x,%x,%x,%x,%x,%x,%d,%d,%d,%d,%d,%"SCNfreq",%d,%d",
(unsigned int*)&me_struct->channel, &me_struct->freq, (unsigned int*)&me_struct->channel, &me_struct->freq,
(unsigned int*)&me_struct->step, &me_struct->shift, (unsigned int*)&me_struct->step, (unsigned int*)&me_struct->shift,
(unsigned int*)&me_struct->reverse, (unsigned int*)&me_struct->tone, (unsigned int*)&me_struct->reverse, (unsigned int*)&me_struct->tone,
(unsigned int*)&me_struct->ct, (unsigned int*)&me_struct->dcs, (unsigned int*)&me_struct->ct, (unsigned int*)&me_struct->dcs,
&me_struct->tone_freq, &me_struct->ct_freq, &me_struct->tone_freq, &me_struct->ct_freq,
@ -865,7 +865,7 @@ int tmd710_pull_me(RIG *rig, int ch, tmd710_me *me_struct)
return RIG_OK; return RIG_OK;
} }
int tmd710_push_me(RIG *rig, tmd710_me *me_struct) int tmd710_push_me(RIG *rig, const tmd710_me *me_struct)
{ {
char cmdbuf[80]; char cmdbuf[80];
char buf[80]; char buf[80];
@ -902,7 +902,7 @@ int tmd710_get_memory_name(RIG *rig, int ch, char *name)
return retval; return retval;
} }
retval = num_sscanf(buf, "MN %d,%s", &ch, name); retval = num_sscanf(buf, "MN %d,%30s", &ch, name);
if (retval != 2) if (retval != 2)
{ {
@ -1240,7 +1240,7 @@ int tmd710_do_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
tmd710_fo fo_struct; tmd710_fo fo_struct;
int retval; int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: called for vfo: %s(%d)\n", __func__, rig_debug(RIG_DEBUG_TRACE, "%s: called for vfo: %s(%u)\n", __func__,
rig_strvfo(vfo), vfo); rig_strvfo(vfo), vfo);
retval = tmd710_pull_fo(rig, vfo, &fo_struct); retval = tmd710_pull_fo(rig, vfo, &fo_struct);
@ -1458,7 +1458,7 @@ int tmd710_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code)
if (fo_struct.dcs) if (fo_struct.dcs)
{ {
tone_t *dcs_list = common_dcs_list; const tone_t *dcs_list = common_dcs_list;
*code = dcs_list[fo_struct.dcs_val]; *code = dcs_list[fo_struct.dcs_val];
} }
else else
@ -1474,7 +1474,7 @@ static int tmd710_find_dcs_index(tone_t code, int *dcs_index)
int i = 0; int i = 0;
// we only allow exact matches here // we only allow exact matches here
tone_t *dcs_list = common_dcs_list; const tone_t *dcs_list = common_dcs_list;
while (code != dcs_list[i]) while (code != dcs_list[i])
{ {
@ -2206,7 +2206,7 @@ int tmd710_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
if (me_struct.dcs) if (me_struct.dcs)
{ {
tone_t *dcs_list = common_dcs_list; const tone_t *dcs_list = common_dcs_list;
chan->dcs_sql = dcs_list[me_struct.dcs_val]; chan->dcs_sql = dcs_list[me_struct.dcs_val];
} }
else else

Wyświetl plik

@ -902,7 +902,6 @@ static int ts480_set_ext_func(RIG *rig, vfo_t vfo, token_t token, int status)
static int ts480_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status) static int ts480_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status)
{ {
char ackbuf[20];
int retval; int retval;
ENTERFUNC; ENTERFUNC;
@ -912,6 +911,7 @@ static int ts480_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status)
case TOK_FUNC_NOISE_REDUCTION_2: case TOK_FUNC_NOISE_REDUCTION_2:
{ {
int value; int value;
char ackbuf[20];
retval = kenwood_safe_transaction(rig, "NR", ackbuf, sizeof(ackbuf), 3); retval = kenwood_safe_transaction(rig, "NR", ackbuf, sizeof(ackbuf), 3);

Wyświetl plik

@ -258,6 +258,7 @@ static int ts590_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) { vfo = vfo_fixup(rig, vfo, rig->state.cache.split); } if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) { vfo = vfo_fixup(rig, vfo, rig->state.cache.split); }
retval = RIG_OK;
if (!sf_fails) if (!sf_fails)
{ {
SNPRINTF(cmd, sizeof(cmd), "SF%d", vfo == RIG_VFO_A ? 0 : 1); SNPRINTF(cmd, sizeof(cmd), "SF%d", vfo == RIG_VFO_A ? 0 : 1);
@ -288,6 +289,11 @@ static int ts590_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
SNPRINTF(cmd, sizeof(cmd), "SL"); SNPRINTF(cmd, sizeof(cmd), "SL");
sscanf(cmd, "SH%d", &lwidth); sscanf(cmd, "SH%d", &lwidth);
retval = kenwood_safe_transaction(rig, cmd, ackbuf, sizeof(ackbuf), 4); retval = kenwood_safe_transaction(rig, cmd, ackbuf, sizeof(ackbuf), 4);
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: SL command failed: %s\n", __func__, rigerror(retval));
return retval;
}
if (*mode == RIG_MODE_PKTUSB || *mode == RIG_MODE_PKTLSB if (*mode == RIG_MODE_PKTUSB || *mode == RIG_MODE_PKTLSB
|| *mode == RIG_MODE_FM || *mode == RIG_MODE_PKTFM || *mode == RIG_MODE_USB || *mode == RIG_MODE_FM || *mode == RIG_MODE_PKTFM || *mode == RIG_MODE_USB

Wyświetl plik

@ -1119,7 +1119,7 @@ int elektor507_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
int elektor507_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) int elektor507_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{ {
struct elektor507_priv_data *priv = (struct elektor507_priv_data *) const struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
rig->state.priv; rig->state.priv;
int ret = 0; int ret = 0;
@ -1196,7 +1196,7 @@ int elektor507_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx)
{ {
struct elektor507_priv_data *priv = (struct elektor507_priv_data *) const struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
rig->state.priv; rig->state.priv;
*ant_curr = priv->ant; *ant_curr = priv->ant;
@ -1210,7 +1210,7 @@ int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
*/ */
static int cy_update_pll(RIG *rig, unsigned char IICadr) static int cy_update_pll(RIG *rig, unsigned char IICadr)
{ {
struct elektor507_priv_data *priv = (struct elektor507_priv_data *) const struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
rig->state.priv; rig->state.priv;
int P0, R40, R41, R42; int P0, R40, R41, R42;
unsigned char Div1N; unsigned char Div1N;

Wyświetl plik

@ -424,7 +424,7 @@ const char *fifisdr_get_info(RIG *rig)
int fifisdr_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int fifisdr_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{ {
struct fifisdr_priv_instance_data *priv = (struct fifisdr_priv_instance_data *) const struct fifisdr_priv_instance_data *priv = (struct fifisdr_priv_instance_data *)
rig->state.priv; rig->state.priv;
int ret; int ret;
double mhz; double mhz;
@ -450,7 +450,7 @@ int fifisdr_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
int fifisdr_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int fifisdr_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{ {
struct fifisdr_priv_instance_data *priv = (struct fifisdr_priv_instance_data *) const struct fifisdr_priv_instance_data *priv = (struct fifisdr_priv_instance_data *)
rig->state.priv; rig->state.priv;
int ret; int ret;
uint32_t freq1121; uint32_t freq1121;

Wyświetl plik

@ -447,7 +447,7 @@ int funcube_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
int get_freq_v0(RIG *rig, vfo_t vfo, freq_t *freq) int get_freq_v0(RIG *rig, vfo_t vfo, freq_t *freq)
{ {
struct funcube_priv_data *priv = (struct funcube_priv_data *)rig->state.priv; const struct funcube_priv_data *priv = (struct funcube_priv_data *)rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, rig_debug(RIG_DEBUG_TRACE,
"%s: frequency is not read from the device, the value shown is the last successfully set.\n", "%s: frequency is not read from the device, the value shown is the last successfully set.\n",

Wyświetl plik

@ -188,7 +188,7 @@ const struct rig_caps hiqsdr_caps =
static int send_command(RIG *rig) static int send_command(RIG *rig)
{ {
struct hiqsdr_priv_data *priv = (struct hiqsdr_priv_data *)rig->state.priv; const struct hiqsdr_priv_data *priv = (struct hiqsdr_priv_data *)rig->state.priv;
int ret; int ret;
ret = write_block(&rig->state.rigport, (unsigned char *) priv->control_frame, ret = write_block(&rig->state.rigport, (unsigned char *) priv->control_frame,

Wyświetl plik

@ -240,8 +240,7 @@ static int rshfiq_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s called. level type =%"PRIll"\n", __func__, rig_debug(RIG_DEBUG_VERBOSE, "%s called. level type =%"PRIll"\n", __func__, level);
level);
char cmdstr[15]; char cmdstr[15];
char stopset[2]; char stopset[2];

Wyświetl plik

@ -1111,7 +1111,7 @@ static const int HS_DIV_MAP[] = {4, 5, 6, 7, -1, 9, -1, 11};
static int calcDividers(RIG *rig, double f, struct solution *solution) static int calcDividers(RIG *rig, double f, struct solution *solution)
{ {
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *) const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv; rig->state.priv;
struct solution sols[8]; struct solution sols[8];
int i; int i;
@ -1193,7 +1193,7 @@ static int calcDividers(RIG *rig, double f, struct solution *solution)
int si570xxxusb_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int si570xxxusb_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{ {
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *) const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv; rig->state.priv;
libusb_device_handle *udh = rig->state.rigport.handle; libusb_device_handle *udh = rig->state.rigport.handle;
int ret; int ret;
@ -1259,7 +1259,7 @@ int si570xxxusb_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
int si570xxxusb_set_freq_by_value(RIG *rig, vfo_t vfo, freq_t freq) int si570xxxusb_set_freq_by_value(RIG *rig, vfo_t vfo, freq_t freq)
{ {
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *) const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv; rig->state.priv;
libusb_device_handle *udh = rig->state.rigport.handle; libusb_device_handle *udh = rig->state.rigport.handle;
int ret; int ret;
@ -1298,7 +1298,7 @@ int si570xxxusb_set_freq_by_value(RIG *rig, vfo_t vfo, freq_t freq)
static double calculateFrequency(RIG *rig, const unsigned char *buffer) static double calculateFrequency(RIG *rig, const unsigned char *buffer)
{ {
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *) const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv; rig->state.priv;
int RFREQ_int = ((buffer[2] & 0xf0) >> 4) + ((buffer[1] & 0x3f) * 16); int RFREQ_int = ((buffer[2] & 0xf0) >> 4) + ((buffer[1] & 0x3f) * 16);
@ -1361,7 +1361,7 @@ int si570xxxusb_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
int si570xxxusb_get_freq_by_value(RIG *rig, vfo_t vfo, freq_t *freq) int si570xxxusb_get_freq_by_value(RIG *rig, vfo_t vfo, freq_t *freq)
{ {
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *) const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv; rig->state.priv;
libusb_device_handle *udh = rig->state.rigport.handle; libusb_device_handle *udh = rig->state.rigport.handle;
int ret; int ret;

Wyświetl plik

@ -45,7 +45,7 @@ struct usrp_priv_data {
int usrp_init(RIG *rig) int usrp_init(RIG *rig)
{ {
rig->state.priv = (struct usrp_priv_data*)malloc(sizeof(struct usrp_priv_data)); rig->state.priv = static_cast<struct usrp_priv_data*>malloc(sizeof(struct usrp_priv_data));
if (!rig->state.priv) { if (!rig->state.priv) {
/* whoops! memory shortage! */ /* whoops! memory shortage! */
return -RIG_ENOMEM; return -RIG_ENOMEM;
@ -68,7 +68,7 @@ int usrp_cleanup(RIG *rig)
int usrp_open(RIG *rig) int usrp_open(RIG *rig)
{ {
struct usrp_priv_data *priv = (struct usrp_priv_data*)rig->state.priv; struct usrp_priv_data *priv = static_cast<struct usrp_priv_data*>rig->state.priv;
int which_board = 0; int which_board = 0;
int decim = 125; int decim = 125;
@ -82,7 +82,7 @@ int usrp_open(RIG *rig)
int usrp_close(RIG *rig) int usrp_close(RIG *rig)
{ {
struct usrp_priv_data *priv = (struct usrp_priv_data*)rig->state.priv; struct usrp_priv_data *priv = static_cast<struct usrp_priv_data*>rig->state.priv;
delete priv->urx; delete priv->urx;
@ -94,7 +94,7 @@ int usrp_close(RIG *rig)
*/ */
int usrp_set_conf(RIG *rig, token_t token, const char *val) int usrp_set_conf(RIG *rig, token_t token, const char *val)
{ {
struct usrp_priv_data *priv = (struct usrp_priv_data*)rig->state.priv; struct usrp_priv_data *priv = static_cast<struct usrp_priv_data*>rig->state.priv;
switch(token) { switch(token) {
case TOK_IFMIXFREQ: case TOK_IFMIXFREQ:
@ -113,7 +113,7 @@ int usrp_set_conf(RIG *rig, token_t token, const char *val)
*/ */
int usrp_get_conf(RIG *rig, token_t token, char *val) int usrp_get_conf(RIG *rig, token_t token, char *val)
{ {
struct usrp_priv_data *priv = (struct usrp_priv_data*)rig->state.priv; const struct usrp_priv_data *priv = static_cast<struct usrp_priv_data*>rig->state.priv;
switch(token) { switch(token) {
case TOK_IFMIXFREQ: case TOK_IFMIXFREQ:
@ -129,7 +129,7 @@ int usrp_get_conf(RIG *rig, token_t token, char *val)
int usrp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int usrp_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{ {
struct usrp_priv_data *priv = (struct usrp_priv_data*)rig->state.priv; const struct usrp_priv_data *priv = static_cast<struct usrp_priv_data*>rig->state.priv;
int chan = 0; int chan = 0;
if (!priv->urx->set_rx_freq (chan, freq)) if (!priv->urx->set_rx_freq (chan, freq))
@ -141,7 +141,7 @@ int usrp_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
int usrp_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int usrp_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{ {
struct usrp_priv_data *priv = (struct usrp_priv_data*)rig->state.priv; const struct usrp_priv_data *priv = static_cast<struct usrp_priv_data*>rig->state.priv;
int chan = 0; int chan = 0;
*freq = priv->urx->rx_freq (chan); *freq = priv->urx->rx_freq (chan);

Wyświetl plik

@ -114,7 +114,7 @@ int lowe_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{ {
char freqbuf[16]; char freqbuf[16];
int freq_len, retval; int freq_len, retval;
float f_freq; double f_freq;
retval = lowe_transaction(rig, "FRQ?" EOM, 5, freqbuf, &freq_len); retval = lowe_transaction(rig, "FRQ?" EOM, 5, freqbuf, &freq_len);
@ -125,7 +125,7 @@ int lowe_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
freqbuf[freq_len < 16 ? freq_len : 15] = '\0'; freqbuf[freq_len < 16 ? freq_len : 15] = '\0';
sscanf(freqbuf + 1, "%f", &f_freq); sscanf(freqbuf + 1, "%lf", &f_freq);
*freq = f_freq * 1000; *freq = f_freq * 1000;
return retval; return retval;

Wyświetl plik

@ -557,6 +557,10 @@ int mds_open(RIG *rig)
ENTERFUNC; ENTERFUNC;
mds_get_info(rig); mds_get_info(rig);
retval = mds_transaction(rig, "MODEM NONE", 0, &response); retval = mds_transaction(rig, "MODEM NONE", 0, &response);
retval = mds_transaction(rig, "PTT 0", 0, &response); if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: MODEM cmd failed: %s\n", __func__, rigerror(retval));
}
else retval = mds_transaction(rig, "PTT 0", 0, &response);
RETURNFUNC(retval); RETURNFUNC(retval);
} }

Wyświetl plik

@ -18,7 +18,7 @@
14 - PTT +5V 14 - PTT +5V
*/ */
void serial_num(char *s) void serial_num(const char *s)
{ {
char model[16]; char model[16];
char *operation; char *operation;
@ -28,6 +28,8 @@ void serial_num(char *s)
char *diagnostics; char *diagnostics;
char *agency; char *agency;
*rxfreq = 0;
*txfreq = 0;
memcpy(model, s, 5); memcpy(model, s, 5);
model[5] = 0; model[5] = 0;

Wyświetl plik

@ -164,7 +164,7 @@ pcr_read_block(RIG *rig, char *rxbuffer, size_t count)
int read = 0, tries = 4; int read = 0, tries = 4;
struct rig_state *rs = &rig->state; struct rig_state *rs = &rig->state;
struct pcr_priv_caps *caps = pcr_caps(rig); const struct pcr_priv_caps *caps = pcr_caps(rig);
struct pcr_priv_data *priv = (struct pcr_priv_data *) rs->priv; struct pcr_priv_data *priv = (struct pcr_priv_data *) rs->priv;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__); rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
@ -713,7 +713,7 @@ pcr_set_vfo(RIG *rig, vfo_t vfo)
int int
pcr_get_vfo(RIG *rig, vfo_t *vfo) pcr_get_vfo(RIG *rig, vfo_t *vfo)
{ {
struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv; const struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv;
*vfo = priv->current_vfo; *vfo = priv->current_vfo;
return RIG_OK; return RIG_OK;
@ -782,7 +782,7 @@ int
pcr_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) pcr_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{ {
struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv; struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv;
struct pcr_rcvr *rcvr = is_sub_rcvr(rig, const struct pcr_rcvr *rcvr = is_sub_rcvr(rig,
vfo) ? &priv->sub_rcvr : &priv->main_rcvr; vfo) ? &priv->sub_rcvr : &priv->main_rcvr;
*freq = rcvr->last_freq; *freq = rcvr->last_freq;
@ -1101,7 +1101,7 @@ pcr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
} }
else else
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s: level = %s, val = %ul\n", rig_debug(RIG_DEBUG_VERBOSE, "%s: level = %s, val = %d\n",
__func__, rig_strlevel(level), val.i); __func__, rig_strlevel(level), val.i);
} }
@ -1168,7 +1168,7 @@ pcr_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{ {
int err; int err;
struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv; struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv;
struct pcr_rcvr *rcvr = is_sub_rcvr(rig, const struct pcr_rcvr *rcvr = is_sub_rcvr(rig,
vfo) ? &priv->sub_rcvr : &priv->main_rcvr; vfo) ? &priv->sub_rcvr : &priv->main_rcvr;
// rig_debug(RIG_DEBUG_TRACE, "%s: level = %d\n", __func__, level); // rig_debug(RIG_DEBUG_TRACE, "%s: level = %d\n", __func__, level);
@ -1242,7 +1242,7 @@ int
pcr_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) pcr_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{ {
struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv; struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv;
struct pcr_rcvr *rcvr = is_sub_rcvr(rig, const struct pcr_rcvr *rcvr = is_sub_rcvr(rig,
vfo) ? &priv->sub_rcvr : &priv->main_rcvr; vfo) ? &priv->sub_rcvr : &priv->main_rcvr;
rig_debug(RIG_DEBUG_VERBOSE, "%s: status = %d, func = %s\n", __func__, rig_debug(RIG_DEBUG_VERBOSE, "%s: status = %d, func = %s\n", __func__,
@ -1399,7 +1399,7 @@ pcr_check_ok(RIG *rig)
static int static int
is_sub_rcvr(RIG *rig, vfo_t vfo) is_sub_rcvr(RIG *rig, vfo_t vfo)
{ {
struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv; const struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv;
return vfo == RIG_VFO_SUB || return vfo == RIG_VFO_SUB ||
(vfo == RIG_VFO_CURR && priv->current_vfo == RIG_VFO_SUB); (vfo == RIG_VFO_CURR && priv->current_vfo == RIG_VFO_SUB);
@ -1776,7 +1776,7 @@ pcr_set_vsc(RIG *rig, vfo_t vfo, int status) // J50xx
int pcr_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone) int pcr_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
{ {
struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv; struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv;
struct pcr_rcvr *rcvr = is_sub_rcvr(rig, const struct pcr_rcvr *rcvr = is_sub_rcvr(rig,
vfo) ? &priv->sub_rcvr : &priv->main_rcvr; vfo) ? &priv->sub_rcvr : &priv->main_rcvr;
*tone = rcvr->last_ctcss_sql; *tone = rcvr->last_ctcss_sql;
@ -1790,7 +1790,7 @@ int pcr_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
struct pcr_rcvr *rcvr = is_sub_rcvr(rig, struct pcr_rcvr *rcvr = is_sub_rcvr(rig,
vfo) ? &priv->sub_rcvr : &priv->main_rcvr; vfo) ? &priv->sub_rcvr : &priv->main_rcvr;
rig_debug(RIG_DEBUG_VERBOSE, "%s: tone = %d\n", __func__, tone); rig_debug(RIG_DEBUG_VERBOSE, "%s: tone = %u\n", __func__, tone);
if (tone == 0) if (tone == 0)
{ {
@ -1805,7 +1805,7 @@ int pcr_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
} }
} }
rig_debug(RIG_DEBUG_TRACE, "%s: index = %d, tone = %d\n", rig_debug(RIG_DEBUG_TRACE, "%s: index = %d, tone = %u\n",
__func__, i, rig->caps->ctcss_list[i]); __func__, i, rig->caps->ctcss_list[i]);
if (rig->caps->ctcss_list[i] != tone) if (rig->caps->ctcss_list[i] != tone)
@ -1826,7 +1826,7 @@ int pcr_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
int pcr_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *tone) int pcr_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *tone)
{ {
struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv; struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv;
struct pcr_rcvr *rcvr = is_sub_rcvr(rig, const struct pcr_rcvr *rcvr = is_sub_rcvr(rig,
vfo) ? &priv->sub_rcvr : &priv->main_rcvr; vfo) ? &priv->sub_rcvr : &priv->main_rcvr;
*tone = rcvr->last_dcs_sql; *tone = rcvr->last_dcs_sql;
@ -1913,7 +1913,7 @@ int pcr_decode_event(RIG *rig)
int pcr_set_powerstat(RIG *rig, powerstat_t status) int pcr_set_powerstat(RIG *rig, powerstat_t status)
{ {
struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv; const struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv;
if (status == priv->power) if (status == priv->power)
{ {
@ -1955,7 +1955,7 @@ int pcr_get_powerstat(RIG *rig, powerstat_t *status)
int pcr_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) int pcr_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
{ {
struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv; struct pcr_priv_data *priv = (struct pcr_priv_data *) rig->state.priv;
struct pcr_rcvr *rcvr = is_sub_rcvr(rig, const struct pcr_rcvr *rcvr = is_sub_rcvr(rig,
vfo) ? &priv->sub_rcvr : &priv->main_rcvr; vfo) ? &priv->sub_rcvr : &priv->main_rcvr;
if (priv->auto_update == 0) if (priv->auto_update == 0)

Wyświetl plik

@ -15,6 +15,7 @@ struct ip_mreq
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <hamlib/rig.h> #include <hamlib/rig.h>
#include "sim.h"
#define BUFSIZE 256 #define BUFSIZE 256
@ -134,16 +135,14 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(50 * 1000); hl_usleep(50 * 1000);
pbuf = "RM5100000;"; pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
if (n <= 0) { perror("RM5"); } if (n <= 0) { perror("RM5"); }
} }
else if (strcmp(buf, "AI;") == 0) else if (strcmp(buf, "AI;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "AI%d;", ai); SNPRINTF(buf, sizeof(buf), "AI%d;", ai);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("n=%d\n", n);
} }
else if (strncmp(buf, "AI", 2) == 0) else if (strncmp(buf, "AI", 2) == 0)
{ {
@ -155,8 +154,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(50 * 1000); hl_usleep(50 * 1000);
pbuf = "AN030;"; pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
if (n <= 0) { perror("AN"); } if (n <= 0) { perror("AN"); }
} }
@ -166,8 +164,7 @@ int main(int argc, char *argv[])
hl_usleep(50 * 1000); hl_usleep(50 * 1000);
//pbuf = "IF059014200000+000000700000;"; //pbuf = "IF059014200000+000000700000;";
pbuf = "IF00007230000 -000000 0001000001 ;" ; pbuf = "IF00007230000 -000000 0001000001 ;" ;
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
if (n <= 0) { perror("IF"); } if (n <= 0) { perror("IF"); }
} }
@ -177,21 +174,20 @@ int main(int argc, char *argv[])
hl_usleep(50 * 1000); hl_usleep(50 * 1000);
int id = 24; int id = 24;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id); SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("n=%d\n", n);
if (n <= 0) { perror("ID"); } if (n <= 0) { perror("ID"); }
} }
else if (strcmp(buf, "PS;") == 0) else if (strcmp(buf, "PS;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PS1;"); SNPRINTF(buf, sizeof(buf), "PS1;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strcmp(buf, "BW$;") == 0) else if (strcmp(buf, "BW$;") == 0)
{ {
fprintf(stderr, "***** %d\n", __LINE__); fprintf(stderr, "***** %d\n", __LINE__);
SNPRINTF(buf, sizeof(buf), "BW$%04d;", bandwidthB); SNPRINTF(buf, sizeof(buf), "BW$%04d;", bandwidthB);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "BW$", 3) == 0) else if (strncmp(buf, "BW$", 3) == 0)
{ {
@ -200,7 +196,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "BW;") == 0) else if (strcmp(buf, "BW;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "BW%04d;", bandwidthA); SNPRINTF(buf, sizeof(buf), "BW%04d;", bandwidthA);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "BW", 2) == 0) else if (strncmp(buf, "BW", 2) == 0)
{ {
@ -209,7 +205,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "DT;") == 0) else if (strcmp(buf, "DT;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "DT%d;", dt); SNPRINTF(buf, sizeof(buf), "DT%d;", dt);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "DT", 2) == 0) else if (strncmp(buf, "DT", 2) == 0)
{ {
@ -218,7 +214,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "BN;") == 0) else if (strcmp(buf, "BN;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "BN03;"); SNPRINTF(buf, sizeof(buf), "BN03;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strcmp(buf, "SM;") == 0) else if (strcmp(buf, "SM;") == 0)
{ {
@ -227,12 +223,12 @@ int main(int argc, char *argv[])
if (meter > 15) { meter = 0; } if (meter > 15) { meter = 0; }
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strcmp(buf, "RG;") == 0) else if (strcmp(buf, "RG;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "RG%03d;", rfgain); SNPRINTF(buf, sizeof(buf), "RG%03d;", rfgain);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "RG", 2) == 0) else if (strncmp(buf, "RG", 2) == 0)
{ {
@ -241,7 +237,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "MG;") == 0) else if (strcmp(buf, "MG;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "MG%03d;", micgain); SNPRINTF(buf, sizeof(buf), "MG%03d;", micgain);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "MG", 2) == 0) else if (strncmp(buf, "MG", 2) == 0)
{ {
@ -250,7 +246,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "AG;") == 0) else if (strcmp(buf, "AG;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "MG%03d;", afgain); SNPRINTF(buf, sizeof(buf), "MG%03d;", afgain);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "AG", 2) == 0) else if (strncmp(buf, "AG", 2) == 0)
{ {
@ -259,7 +255,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "NB;") == 0) else if (strcmp(buf, "NB;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "NB%d;", noiseblanker); SNPRINTF(buf, sizeof(buf), "NB%d;", noiseblanker);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "NB", 2) == 0) else if (strncmp(buf, "NB", 2) == 0)
{ {
@ -268,7 +264,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "IS;") == 0) else if (strcmp(buf, "IS;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "IS %04d;", ifshift); SNPRINTF(buf, sizeof(buf), "IS %04d;", ifshift);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "IS", 2) == 0) else if (strncmp(buf, "IS", 2) == 0)
{ {
@ -284,7 +280,6 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(50 * 1000); hl_usleep(50 * 1000);
n = fprintf(fp, "%s", "AI0;"); n = fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
if (n <= 0) { perror("AI"); } if (n <= 0) { perror("AI"); }
} }
@ -296,8 +291,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(50 * 1000); hl_usleep(50 * 1000);
pbuf = "VS0;"; pbuf = "VS0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
if (n < 0) { perror("VS"); } if (n < 0) { perror("VS"); }
} }
@ -308,8 +302,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(50 * 1000); hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant); SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("n=%d\n", n);
if (n < 0) { perror("EX032"); } if (n < 0) { perror("EX032"); }
} }
@ -318,32 +311,31 @@ int main(int argc, char *argv[])
// KPA3 SNPRINTF(buf, sizeof(buf), "OM AP----L-----;"); // KPA3 SNPRINTF(buf, sizeof(buf), "OM AP----L-----;");
// K4+KPA3 // K4+KPA3
SNPRINTF(buf, sizeof(buf), "OM AP-S----4---;"); SNPRINTF(buf, sizeof(buf), "OM AP-S----4---;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("n=%d\n", n);
if (n < 0) { perror("OM"); } if (n < 0) { perror("OM"); }
} }
else if (strcmp(buf, "K2;") == 0) else if (strcmp(buf, "K2;") == 0)
{ {
n = write(fd, "K20;", 4); write(fd, "K20;", 4);
} }
else if (strcmp(buf, "K3;") == 0) else if (strcmp(buf, "K3;") == 0)
{ {
n = write(fd, "K30;", 4); write(fd, "K30;", 4);
} }
else if (strcmp(buf, "RVM;") == 0) else if (strcmp(buf, "RVM;") == 0)
{ {
n = write(fd, "RV02.37;", 8); write(fd, "RV02.37;", 8);
} }
else if (strcmp(buf, "MD;") == 0) else if (strcmp(buf, "MD;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "MD%d;", modea); SNPRINTF(buf, sizeof(buf), "MD%d;", modea);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strcmp(buf, "MD$;") == 0) else if (strcmp(buf, "MD$;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "MD$%d;", modeb); SNPRINTF(buf, sizeof(buf), "MD$%d;", modeb);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "MD", 2) == 0) else if (strncmp(buf, "MD", 2) == 0)
{ {
@ -353,12 +345,12 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FA;") == 0) else if (strcmp(buf, "FA;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa); SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strcmp(buf, "FB;") == 0) else if (strcmp(buf, "FB;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb); SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "FA", 2) == 0) else if (strncmp(buf, "FA", 2) == 0)
@ -372,7 +364,7 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "FR;", 3) == 0) else if (strncmp(buf, "FR;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FR0;"); SNPRINTF(buf, sizeof(buf), "FR0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "FR", 2) == 0) else if (strncmp(buf, "FR", 2) == 0)
{ {
@ -381,12 +373,12 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "FT;", 3) == 0) else if (strncmp(buf, "FT;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FT0;"); SNPRINTF(buf, sizeof(buf), "FT0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "KS;", 3) == 0) else if (strncmp(buf, "KS;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "KS%03d;", keyspd); SNPRINTF(buf, sizeof(buf), "KS%03d;", keyspd);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "KS", 2) == 0) else if (strncmp(buf, "KS", 2) == 0)
{ {
@ -395,22 +387,22 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "TQ;", 3) == 0) else if (strncmp(buf, "TQ;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "TQ0;"); SNPRINTF(buf, sizeof(buf), "TQ0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "PC;", 3) == 0) else if (strncmp(buf, "PC;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PC0980;"); SNPRINTF(buf, sizeof(buf), "PC0980;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "PA;", 3) == 0) else if (strncmp(buf, "PA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PA%d;", preampA); SNPRINTF(buf, sizeof(buf), "PA%d;", preampA);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "PA$;", 4) == 0) else if (strncmp(buf, "PA$;", 4) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PA$%d;", preampB); SNPRINTF(buf, sizeof(buf), "PA$%d;", preampB);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "PA", 2) == 0) else if (strncmp(buf, "PA", 2) == 0)
{ {
@ -423,12 +415,12 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "RA;", 3) == 0) else if (strncmp(buf, "RA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "RA%02d;", rxattenuatorA); SNPRINTF(buf, sizeof(buf), "RA%02d;", rxattenuatorA);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "RA$;", 4) == 0) else if (strncmp(buf, "RA$;", 4) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "RA$%02d;", rxattenuatorA); SNPRINTF(buf, sizeof(buf), "RA$%02d;", rxattenuatorA);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "RA", 2) == 0) else if (strncmp(buf, "RA", 2) == 0)
{ {
@ -443,7 +435,7 @@ int main(int argc, char *argv[])
int status = 0; int status = 0;
printf("KY query\n"); printf("KY query\n");
SNPRINTF(buf, sizeof(buf), "KY%d;", status); SNPRINTF(buf, sizeof(buf), "KY%d;", status);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "KY", 2) == 0) else if (strncmp(buf, "KY", 2) == 0)
{ {

Wyświetl plik

@ -6,10 +6,12 @@
// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32 // gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -22,6 +24,7 @@ struct ip_mreq
#include "../src/misc.h" #include "../src/misc.h"
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#include "sim.h"
#define BUFSIZE 256 #define BUFSIZE 256
@ -53,25 +56,7 @@ int keyspd = 25;
int datamode = 0; int datamode = 0;
int filter = 0; int filter = 0;
#define write(f,b,l) write_sim(f,b,l,__func__,__LINE__) void dumphex(const unsigned char *buf, int n)
int write_sim(int fd, const unsigned char *buf, int buflen, const char *func,
int linenum)
{
int n;
dump_hex(buf, buflen);
n = write(fd, buf, buflen);
if (n <= 0)
{
fprintf(stderr, "%s(%d) write error %d: %s\n", func, linenum, n,
strerror(errno));
}
return n;
}
void dumphex(unsigned char *buf, int n)
{ {
for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); } for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); }

Wyświetl plik

@ -6,10 +6,12 @@
// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32 // gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <hamlib/rig.h> #include <hamlib/rig.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -18,11 +20,11 @@ struct ip_mreq
#include <errno.h> #include <errno.h>
#include <sys/time.h> #include <sys/time.h>
#include "../src/misc.h" #include "../src/misc.h"
#include "../src/multicast.h"
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include "sim.h"
#define BUFSIZE 256 #define BUFSIZE 256
//#define X25 //#define X25
@ -48,7 +50,7 @@ int agc_time = 1;
int ovf_status = 0; int ovf_status = 0;
int powerstat = 1; int powerstat = 1;
void dumphex(unsigned char *buf, int n) void dumphex(const unsigned char *buf, int n)
{ {
for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); } for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); }
@ -130,7 +132,7 @@ void frameParse(int fd, unsigned char *frame, int len)
if (powerstat) if (powerstat)
{ {
n = write(fd, frame, 11); write(fd, frame, 11);
} }
break; break;
@ -150,7 +152,7 @@ void frameParse(int fd, unsigned char *frame, int len)
} }
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x05: case 0x05:
@ -162,7 +164,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x06: case 0x06:
@ -171,7 +173,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x07: case 0x07:
@ -191,7 +193,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x0f: case 0x0f:
@ -203,14 +205,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
printf("get split %d\n", 1); printf("get split %d\n", 1);
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
else else
{ {
printf("set split %d\n", 1); printf("set split %d\n", 1);
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
break; break;
@ -233,7 +235,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = 0xfd; frame[7] = 0xfd;
printf("write 8 bytes\n"); printf("write 8 bytes\n");
dump_hex(frame, 8); dump_hex(frame, 8);
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x14: case 0x14:
@ -247,7 +249,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = 0xfb; frame[6] = 0xfb;
dumphex(frame, 7); dumphex(frame, 7);
n = write(fd, frame, 7); write(fd, frame, 7);
printf("ACK x14 x08\n"); printf("ACK x14 x08\n");
} }
else else
@ -255,7 +257,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)128, 2); to_bcd(&frame[6], (long long)128, 2);
frame[8] = 0xfb; frame[8] = 0xfb;
dumphex(frame, 9); dumphex(frame, 9);
n = write(fd, frame, 9); write(fd, frame, 9);
printf("SEND x14 x08\n"); printf("SEND x14 x08\n");
} }
@ -269,7 +271,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)power_level, 2); to_bcd(&frame[6], (long long)power_level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
} }
@ -283,7 +285,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07: case 0x07:
frame[6] = ovf_status; frame[6] = ovf_status;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
ovf_status = ovf_status == 0 ? 1 : 0; ovf_status = ovf_status == 0 ? 1 : 0;
break; break;
@ -295,7 +297,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)meter_level, 2); to_bcd(&frame[6], (long long)meter_level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
} }
@ -311,7 +313,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = satmode; frame[6] = satmode;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
break; break;
@ -322,13 +324,13 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x18: // miscellaneous things case 0x18: // miscellaneous things
frame[5] = 1; frame[5] = 1;
frame[6] = 0xfd; frame[6] = 0xfd;
n = write(fd, frame, 7); write(fd, frame, 7);
break; break;
case 0x19: // miscellaneous things case 0x19: // miscellaneous things
frame[5] = 0x94; frame[5] = 0x94;
frame[6] = 0xfd; frame[6] = 0xfd;
n = write(fd, frame, 7); write(fd, frame, 7);
break; break;
case 0x1a: // miscellaneous things case 0x1a: // miscellaneous things
@ -339,7 +341,7 @@ void frameParse(int fd, unsigned char *frame, int len)
else { frame[6] = widthB; } else { frame[6] = widthB; }
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x04: // AGC TIME case 0x04: // AGC TIME
@ -349,7 +351,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = agc_time; frame[6] = agc_time;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
else else
{ {
@ -357,7 +359,7 @@ void frameParse(int fd, unsigned char *frame, int len)
agc_time = frame[6]; agc_time = frame[6];
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
break; break;
@ -365,7 +367,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07: // satmode case 0x07: // satmode
frame[4] = 0; frame[4] = 0;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
} }
@ -380,14 +382,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = ptt; frame[6] = ptt;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
else else
{ {
ptt = frame[6]; ptt = frame[6];
frame[7] = 0xfb; frame[7] = 0xfb;
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
} }
break; break;
@ -427,8 +429,8 @@ void frameParse(int fd, unsigned char *frame, int len)
frame2[8] = 0x03; frame2[8] = 0x03;
frame2[9] = 0x00; frame2[9] = 0x00;
frame2[10] = 0xfd; frame2[10] = 0xfd;
n = write(fd, frame2, 11); write(fd, frame2, 11);
n = write(fd, frame, 12); write(fd, frame, 12);
} }
else else
{ {
@ -440,7 +442,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
// send async frame // send async frame
frame[2] = 0x00; // async freq frame[2] = 0x00; // async freq
frame[3] = 0xa2; frame[3] = 0xa2;
@ -451,7 +453,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[8] = 0x96; frame[8] = 0x96;
frame[9] = 0x12; frame[9] = 0x12;
frame[10] = 0xfd; frame[10] = 0xfd;
n = write(fd, frame, 11); write(fd, frame, 11);
} }
break; break;
@ -467,7 +469,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = frame[5] == 0 ? datamodeA : datamodeB; frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
frame[8] = 0xfb; frame[8] = 0xfb;
frame[9] = 0xfd; frame[9] = 0xfd;
n = write(fd, frame, 10); write(fd, frame, 10);
} }
else else
{ {
@ -486,7 +488,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
printf("\n"); printf("\n");
@ -497,14 +499,14 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("x25 send nak\n"); printf("x25 send nak\n");
frame[4] = 0xfa; frame[4] = 0xfa;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x26: case 0x26:
printf("x26 send nak\n"); printf("x26 send nak\n");
frame[4] = 0xfa; frame[4] = 0xfa;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
#endif #endif

Wyświetl plik

@ -6,10 +6,12 @@
// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32 // gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -22,6 +24,7 @@ struct ip_mreq
#include "../src/misc.h" #include "../src/misc.h"
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#include "sim.h"
#define BUFSIZE 256 #define BUFSIZE 256
@ -49,7 +52,7 @@ int agc_time = 1;
int ovf_status = 0; int ovf_status = 0;
int powerstat = 1; int powerstat = 1;
void dumphex(unsigned char *buf, int n) void dumphex(const unsigned char *buf, int n)
{ {
for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); } for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); }
@ -131,7 +134,7 @@ void frameParse(int fd, unsigned char *frame, int len)
if (powerstat) if (powerstat)
{ {
n = write(fd, frame, 11); write(fd, frame, 11);
} }
break; break;
@ -151,7 +154,7 @@ void frameParse(int fd, unsigned char *frame, int len)
} }
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x05: case 0x05:
@ -163,7 +166,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x06: case 0x06:
@ -172,7 +175,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x07: case 0x07:
@ -192,7 +195,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x0f: case 0x0f:
@ -204,14 +207,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
printf("get split %d\n", 1); printf("get split %d\n", 1);
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
else else
{ {
printf("set split %d\n", 1); printf("set split %d\n", 1);
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
break; break;
@ -234,7 +237,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = 0xfd; frame[7] = 0xfd;
printf("write 8 bytes\n"); printf("write 8 bytes\n");
dump_hex(frame, 8); dump_hex(frame, 8);
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x14: case 0x14:
@ -248,7 +251,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = 0xfb; frame[6] = 0xfb;
dumphex(frame, 7); dumphex(frame, 7);
n = write(fd, frame, 7); write(fd, frame, 7);
printf("ACK x14 x08\n"); printf("ACK x14 x08\n");
} }
else else
@ -256,7 +259,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)128, 2); to_bcd(&frame[6], (long long)128, 2);
frame[8] = 0xfb; frame[8] = 0xfb;
dumphex(frame, 9); dumphex(frame, 9);
n = write(fd, frame, 9); write(fd, frame, 9);
printf("SEND x14 x08\n"); printf("SEND x14 x08\n");
} }
@ -270,7 +273,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)power_level, 2); to_bcd(&frame[6], (long long)power_level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
} }
@ -284,7 +287,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07: case 0x07:
frame[6] = ovf_status; frame[6] = ovf_status;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
ovf_status = ovf_status == 0 ? 1 : 0; ovf_status = ovf_status == 0 ? 1 : 0;
break; break;
@ -296,7 +299,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)meter_level, 2); to_bcd(&frame[6], (long long)meter_level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
} }
@ -312,7 +315,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = dualwatch; frame[6] = dualwatch;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
break; break;
@ -326,7 +329,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = satmode; frame[6] = satmode;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
break; break;
@ -337,13 +340,13 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x18: // miscellaneous things case 0x18: // miscellaneous things
frame[5] = 1; frame[5] = 1;
frame[6] = 0xfd; frame[6] = 0xfd;
n = write(fd, frame, 7); write(fd, frame, 7);
break; break;
case 0x19: // miscellaneous things case 0x19: // miscellaneous things
frame[5] = 0x94; frame[5] = 0x94;
frame[6] = 0xfd; frame[6] = 0xfd;
n = write(fd, frame, 7); write(fd, frame, 7);
break; break;
case 0x1a: // miscellaneous things case 0x1a: // miscellaneous things
@ -354,7 +357,7 @@ void frameParse(int fd, unsigned char *frame, int len)
else { frame[6] = widthB; } else { frame[6] = widthB; }
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x04: // AGC TIME case 0x04: // AGC TIME
@ -364,7 +367,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = agc_time; frame[6] = agc_time;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
else else
{ {
@ -372,7 +375,7 @@ void frameParse(int fd, unsigned char *frame, int len)
agc_time = frame[6]; agc_time = frame[6];
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
break; break;
@ -380,7 +383,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07: // satmode case 0x07: // satmode
frame[4] = 0; frame[4] = 0;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
} }
@ -395,14 +398,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = ptt; frame[6] = ptt;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
else else
{ {
ptt = frame[6]; ptt = frame[6];
frame[7] = 0xfb; frame[7] = 0xfb;
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
} }
break; break;
@ -442,8 +445,8 @@ void frameParse(int fd, unsigned char *frame, int len)
frame2[8] = 0x03; frame2[8] = 0x03;
frame2[9] = 0x00; frame2[9] = 0x00;
frame2[10] = 0xfd; frame2[10] = 0xfd;
n = write(fd, frame2, 11); write(fd, frame2, 11);
n = write(fd, frame, 12); write(fd, frame, 12);
} }
else else
{ {
@ -455,7 +458,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
// send async frame // send async frame
frame[2] = 0x00; // async freq frame[2] = 0x00; // async freq
frame[3] = 0xa2; frame[3] = 0xa2;
@ -466,7 +469,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[8] = 0x96; frame[8] = 0x96;
frame[9] = 0x12; frame[9] = 0x12;
frame[10] = 0xfd; frame[10] = 0xfd;
n = write(fd, frame, 11); write(fd, frame, 11);
} }
break; break;
@ -482,7 +485,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = frame[5] == 0 ? datamodeA : datamodeB; frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
frame[8] = 0xfb; frame[8] = 0xfb;
frame[9] = 0xfd; frame[9] = 0xfd;
n = write(fd, frame, 10); write(fd, frame, 10);
} }
else else
{ {
@ -501,7 +504,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
printf("\n"); printf("\n");
@ -512,14 +515,14 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("x25 send nak\n"); printf("x25 send nak\n");
frame[4] = 0xfa; frame[4] = 0xfa;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x26: case 0x26:
printf("x26 send nak\n"); printf("x26 send nak\n");
frame[4] = 0xfa; frame[4] = 0xfa;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
#endif #endif

Wyświetl plik

@ -6,10 +6,12 @@
// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32 // gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -19,6 +21,7 @@ struct ip_mreq
#include <sys/time.h> #include <sys/time.h>
#include <hamlib/rig.h> #include <hamlib/rig.h>
#include "../src/misc.h" #include "../src/misc.h"
#include "sim.h"
#define BUFSIZE 256 #define BUFSIZE 256
//#define X25 //#define X25
@ -40,7 +43,7 @@ ant_t ant_curr = 0;
int ant_option = 0; int ant_option = 0;
int ptt = 0; int ptt = 0;
void dumphex(unsigned char *buf, int n) void dumphex(const unsigned char *buf, int n)
{ {
for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); } for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); }
@ -74,7 +77,6 @@ frameGet(int fd, unsigned char *buf)
void frameParse(int fd, unsigned char *frame, int len) void frameParse(int fd, unsigned char *frame, int len)
{ {
double freq; double freq;
int n;
dumphex(frame, len); dumphex(frame, len);
@ -102,9 +104,7 @@ void frameParse(int fd, unsigned char *frame, int len)
} }
frame[10] = 0xfd; frame[10] = 0xfd;
n = write(fd, frame, 11); write(fd, frame, 11);
if (n != 11) {printf("Error!\n"); exit(1);}
break; break;
@ -123,7 +123,7 @@ void frameParse(int fd, unsigned char *frame, int len)
} }
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x05: case 0x05:
@ -135,7 +135,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x06: case 0x06:
@ -144,7 +144,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x07: case 0x07:
@ -164,7 +164,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x0f: case 0x0f:
@ -174,7 +174,7 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("set split %d\n", 1); printf("set split %d\n", 1);
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x12: // we're simulating the 3-byte version -- not the 2-byte case 0x12: // we're simulating the 3-byte version -- not the 2-byte
@ -195,7 +195,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = 0xfd; frame[7] = 0xfd;
printf("n=write 8 bytes\n"); printf("n=write 8 bytes\n");
dump_hex(frame, 8); dump_hex(frame, 8);
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x14: case 0x14:
@ -209,7 +209,7 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("Using AF level %d\n", level); printf("Using AF level %d\n", level);
to_bcd(&frame[6], (long long) level, 2); to_bcd(&frame[6], (long long) level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
case 0x0a: case 0x0a:
@ -220,7 +220,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)power_level, 2); to_bcd(&frame[6], (long long)power_level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
} }
@ -239,7 +239,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)meter_level, 2); to_bcd(&frame[6], (long long)meter_level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
} }
@ -248,7 +248,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x18: // miscellaneous things case 0x18: // miscellaneous things
frame[5] = 1; frame[5] = 1;
frame[6] = 0xfd; frame[6] = 0xfd;
n = write(fd, frame, 7); write(fd, frame, 7);
break; break;
case 0x1a: // miscellaneous things case 0x1a: // miscellaneous things
@ -259,20 +259,20 @@ void frameParse(int fd, unsigned char *frame, int len)
else { frame[6] = widthB; } else { frame[6] = widthB; }
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x04: // IC7200 data mode case 0x04: // IC7200 data mode
frame[6] = 0; frame[6] = 0;
frame[7] = 0; frame[7] = 0;
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
case 0x07: // satmode case 0x07: // satmode
frame[6] = 0; frame[6] = 0;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
} }
@ -287,14 +287,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = ptt; frame[6] = ptt;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
else else
{ {
ptt = frame[6]; ptt = frame[6];
frame[7] = 0xfb; frame[7] = 0xfb;
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
} }
break; break;
@ -321,7 +321,7 @@ void frameParse(int fd, unsigned char *frame, int len)
} }
frame[11] = 0xfd; frame[11] = 0xfd;
n = write(fd, frame, 12); write(fd, frame, 12);
} }
else else
{ {
@ -333,7 +333,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
break; break;
@ -349,7 +349,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = frame[5] == 0 ? datamodeA : datamodeB; frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
frame[8] = 0xfb; frame[8] = 0xfb;
frame[9] = 0xfd; frame[9] = 0xfd;
n = write(fd, frame, 10); write(fd, frame, 10);
} }
else else
{ {
@ -368,7 +368,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
printf("\n"); printf("\n");

Wyświetl plik

@ -6,10 +6,12 @@
// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32 // gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -45,7 +47,7 @@ int agc_time = 1;
int ovf_status = 0; int ovf_status = 0;
int powerstat = 1; int powerstat = 1;
void dumphex(unsigned char *buf, int n) void dumphex(const unsigned char *buf, int n)
{ {
for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); } for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); }
@ -96,7 +98,6 @@ again:
void frameParse(int fd, unsigned char *frame, int len) void frameParse(int fd, unsigned char *frame, int len)
{ {
double freq; double freq;
int n = 0;
dumphex(frame, len); dumphex(frame, len);
@ -133,7 +134,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[8] = 0xfd; frame[8] = 0xfd;
dump_hex(frame, 9); dump_hex(frame, 9);
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
@ -152,7 +153,7 @@ void frameParse(int fd, unsigned char *frame, int len)
} }
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x05: case 0x05:
@ -164,7 +165,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x06: case 0x06:
@ -173,7 +174,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x07: case 0x07:
@ -193,7 +194,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x0f: case 0x0f:
@ -205,14 +206,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
printf("get split %d\n", 1); printf("get split %d\n", 1);
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
else else
{ {
printf("set split %d\n", 1); printf("set split %d\n", 1);
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
break; break;
@ -235,7 +236,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = 0xfd; frame[7] = 0xfd;
printf("write 8 bytes\n"); printf("write 8 bytes\n");
dump_hex(frame, 8); dump_hex(frame, 8);
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x14: case 0x14:
@ -251,7 +252,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)power_level, 2); to_bcd(&frame[6], (long long)power_level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
} }
@ -265,7 +266,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07: case 0x07:
frame[6] = ovf_status; frame[6] = ovf_status;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
ovf_status = ovf_status == 0 ? 1 : 0; ovf_status = ovf_status == 0 ? 1 : 0;
break; break;
@ -277,7 +278,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)meter_level, 2); to_bcd(&frame[6], (long long)meter_level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
} }
@ -293,7 +294,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = satmode; frame[6] = satmode;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
break; break;
@ -304,7 +305,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x18: // miscellaneous things case 0x18: // miscellaneous things
frame[5] = 1; frame[5] = 1;
frame[6] = 0xfd; frame[6] = 0xfd;
n = write(fd, frame, 7); write(fd, frame, 7);
break; break;
case 0x1a: // miscellaneous things case 0x1a: // miscellaneous things
@ -314,7 +315,7 @@ void frameParse(int fd, unsigned char *frame, int len)
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { frame[6] = filterA; } if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { frame[6] = filterA; }
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x04: // AGC TIME case 0x04: // AGC TIME
@ -324,7 +325,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = agc_time; frame[6] = agc_time;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
else else
{ {
@ -332,7 +333,7 @@ void frameParse(int fd, unsigned char *frame, int len)
agc_time = frame[6]; agc_time = frame[6];
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
break; break;
@ -340,7 +341,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07: // satmode case 0x07: // satmode
frame[4] = 0; frame[4] = 0;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
} }
@ -355,14 +356,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = ptt; frame[6] = ptt;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
else else
{ {
ptt = frame[6]; ptt = frame[6];
frame[7] = 0xfb; frame[7] = 0xfb;
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
} }
break; break;
@ -384,8 +385,6 @@ void frameParse(int fd, unsigned char *frame, int len)
default: printf("cmd 0x%02x unknown\n", frame[4]); default: printf("cmd 0x%02x unknown\n", frame[4]);
} }
if (n == 0) { printf("Write failed?\n"); }
// don't care about the rig type yet // don't care about the rig type yet
} }

Wyświetl plik

@ -2,10 +2,12 @@
// gcc -o simft897 simft897.c // gcc -o simft897 simft897.c
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

Wyświetl plik

@ -2,10 +2,12 @@
// gcc -o simyaesu simyaesu.c // gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -106,7 +108,6 @@ int main(int argc, char *argv[])
{ {
char buf[256]; char buf[256];
char *pbuf; char *pbuf;
int n;
int fd = openPort(argv[1]); int fd = openPort(argv[1]);
int freqa = 14074000, freqb = 140735000; int freqa = 14074000, freqb = 140735000;
int modeA = 0; // , modeB = 0; int modeA = 0; // , modeB = 0;
@ -124,10 +125,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RM5100000;"; pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("RM5"); }
} }
else if (strcmp(buf, "AN0;") == 0) else if (strcmp(buf, "AN0;") == 0)
@ -135,10 +133,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AN030;"; pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("AN"); }
} }
else if (strcmp(buf, "IF;") == 0) else if (strcmp(buf, "IF;") == 0)
{ {
@ -148,10 +143,7 @@ int main(int argc, char *argv[])
pbuf = "IF000503130001000+0000000000030000000;"; pbuf = "IF000503130001000+0000000000030000000;";
sprintf(ifbuf, "IF%011d0001000+0000000000030000000;", freqa); sprintf(ifbuf, "IF%011d0001000+0000000000030000000;", freqa);
//pbuf = "IF00010138698 +00000000002000000 ; //pbuf = "IF00010138698 +00000000002000000 ;
n = write(fd, ifbuf, strlen(ifbuf)); write(fd, ifbuf, strlen(ifbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("IF"); }
continue; continue;
} }
@ -159,48 +151,48 @@ int main(int argc, char *argv[])
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "NB0;"; pbuf = "NB0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "RA;") == 0) else if (strcmp(buf, "RA;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RA01;"; pbuf = "RA01;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "RG;") == 0) else if (strcmp(buf, "RG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RG055;"; pbuf = "RG055;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "MG;") == 0) else if (strcmp(buf, "MG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "MG050;"; pbuf = "MG050;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "AG;") == 0) else if (strcmp(buf, "AG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AG100;"; pbuf = "AG100;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "FV;") == 0) else if (strcmp(buf, "FV;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "FV1.2;"; pbuf = "FV1.2;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strncmp(buf, "IS;", 3) == 0) else if (strncmp(buf, "IS;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "IS+0000;"); SNPRINTF(buf, sizeof(buf), "IS+0000;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
@ -211,14 +203,14 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "SM;", 3) == 0) else if (strncmp(buf, "SM;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SM0035;"); SNPRINTF(buf, sizeof(buf), "SM0035;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
else if (strncmp(buf, "PC;", 3) == 0) else if (strncmp(buf, "PC;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PC100;"); SNPRINTF(buf, sizeof(buf), "PC100;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
@ -226,10 +218,10 @@ int main(int argc, char *argv[])
{ {
//usleep(mysleep * 1000); //usleep(mysleep * 1000);
pbuf = "FW240"; pbuf = "FW240";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
hl_usleep(20 * 1000); hl_usleep(20 * 1000);
pbuf = "0;"; pbuf = "0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strncmp(buf, "FW", 2) == 0) else if (strncmp(buf, "FW", 2) == 0)
@ -242,10 +234,7 @@ int main(int argc, char *argv[])
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
int id = 24; int id = 24;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id); SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n <= 0) { perror("ID"); }
continue; continue;
} }
@ -257,10 +246,8 @@ int main(int argc, char *argv[])
{ {
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
n = fprintf(fp, "%s", "AI0;"); fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
if (n <= 0) { perror("AI"); }
} }
} }
@ -270,11 +257,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "VS0;"; pbuf = "VS0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n < 0) { perror("VS"); }
continue; continue;
} }
else if (strcmp(buf, "EX032;") == 0) else if (strcmp(buf, "EX032;") == 0)
@ -284,11 +267,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant); SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n < 0) { perror("EX032"); }
continue; continue;
} }
else if (strncmp(buf, "EX", 2) == 0) else if (strncmp(buf, "EX", 2) == 0)
@ -298,13 +277,13 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FA;") == 0) else if (strcmp(buf, "FA;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa); SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strcmp(buf, "FB;") == 0) else if (strcmp(buf, "FB;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb); SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FA", 2) == 0) else if (strncmp(buf, "FA", 2) == 0)
@ -320,26 +299,26 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "AI;", 3) == 0) else if (strncmp(buf, "AI;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "AI0;"); SNPRINTF(buf, sizeof(buf), "AI0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
if (strncmp(buf, "PS;", 3) == 0) if (strncmp(buf, "PS;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PS1;"); SNPRINTF(buf, sizeof(buf), "PS1;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "SA;", 3) == 0) else if (strncmp(buf, "SA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SA0;"); SNPRINTF(buf, sizeof(buf), "SA0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (strncmp(buf, "MD;", 3) == 0) else if (strncmp(buf, "MD;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "MD%d;", SNPRINTF(buf, sizeof(buf), "MD%d;",
modeA); // not worried about modeB yet for simulator modeA); // not worried about modeB yet for simulator
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "MD", 2) == 0) else if (strncmp(buf, "MD", 2) == 0)
@ -350,7 +329,7 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "FL;", 3) == 0) else if (strncmp(buf, "FL;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FL%03d;", filternum); SNPRINTF(buf, sizeof(buf), "FL%03d;", filternum);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FL", 2) == 0) else if (strncmp(buf, "FL", 2) == 0)
@ -361,7 +340,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FR;") == 0) else if (strcmp(buf, "FR;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo); SNPRINTF(buf, sizeof(buf), "FR%d;", vfo);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FR", 2) == 0) else if (strncmp(buf, "FR", 2) == 0)
@ -371,7 +350,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FT;") == 0) else if (strcmp(buf, "FT;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx); SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FT", 2) == 0) else if (strncmp(buf, "FT", 2) == 0)
@ -381,7 +360,7 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "DA;", 3) == 0) else if (strncmp(buf, "DA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "DA%d;", datamode); SNPRINTF(buf, sizeof(buf), "DA%d;", datamode);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }

Wyświetl plik

@ -2,10 +2,12 @@
// gcc -o simyaesu simyaesu.c // gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

Wyświetl plik

@ -2,10 +2,12 @@
// gcc -o simyaesu simyaesu.c // gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -86,7 +88,6 @@ int main(int argc, char *argv[])
{ {
char buf[256]; char buf[256];
char *pbuf; char *pbuf;
int n;
int fd = openPort(argv[1]); int fd = openPort(argv[1]);
int freqa = 14074000, freqb = 140735000; int freqa = 14074000, freqb = 140735000;
int modeA = 1, modeB = 2; int modeA = 1, modeB = 2;
@ -104,10 +105,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RM5100000;"; pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("RM5"); }
} }
else if (strcmp(buf, "AN0;") == 0) else if (strcmp(buf, "AN0;") == 0)
@ -115,10 +113,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AN030;"; pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("AN"); }
} }
else if (strcmp(buf, "IF;") == 0) else if (strcmp(buf, "IF;") == 0)
{ {
@ -129,59 +124,55 @@ int main(int argc, char *argv[])
// from QMX 1_09 firmware "IF00007074000 +0.0000000002000000 ;" // from QMX 1_09 firmware "IF00007074000 +0.0000000002000000 ;"
sprintf(ifbuf, "IF%011d +0.0000000002000000 ;", freqa); sprintf(ifbuf, "IF%011d +0.0000000002000000 ;", freqa);
//pbuf = "IF00010138698 +00000000002000000 ; //pbuf = "IF00010138698 +00000000002000000 ;
n = write(fd, ifbuf, strlen(ifbuf)); write(fd, ifbuf, strlen(ifbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("IF"); }
continue; continue;
} }
else if (strcmp(buf, "NB;") == 0) else if (strcmp(buf, "NB;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "NB0;"; pbuf = "NB0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "RA;") == 0) else if (strcmp(buf, "RA;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RA01;"; pbuf = "RA01;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "RG;") == 0) else if (strcmp(buf, "RG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RG055;"; pbuf = "RG055;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "MG;") == 0) else if (strcmp(buf, "MG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "MG050;"; pbuf = "MG050;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "AG;") == 0) else if (strcmp(buf, "AG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AG100;"; pbuf = "AG100;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "FV;") == 0) else if (strcmp(buf, "FV;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "FV1.2;"; pbuf = "FV1.2;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strncmp(buf, "IS;", 3) == 0) else if (strncmp(buf, "IS;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "IS+0000;"); SNPRINTF(buf, sizeof(buf), "IS+0000;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
@ -192,14 +183,14 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "SM;", 3) == 0) else if (strncmp(buf, "SM;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SM0035;"); SNPRINTF(buf, sizeof(buf), "SM0035;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
else if (strncmp(buf, "PC;", 3) == 0) else if (strncmp(buf, "PC;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PC100;"); SNPRINTF(buf, sizeof(buf), "PC100;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
@ -207,10 +198,10 @@ int main(int argc, char *argv[])
{ {
//usleep(mysleep * 1000); //usleep(mysleep * 1000);
pbuf = "FW240"; pbuf = "FW240";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
hl_usleep(20 * 1000); hl_usleep(20 * 1000);
pbuf = "0;"; pbuf = "0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strncmp(buf, "FW", 2) == 0) else if (strncmp(buf, "FW", 2) == 0)
@ -222,11 +213,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
SNPRINTF(buf, sizeof(buf), "ID%03d;", 10); SNPRINTF(buf, sizeof(buf), "ID%03d;", 10);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n <= 0) { perror("ID"); }
continue; continue;
} }
@ -237,10 +224,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AI0;"; pbuf = "AI0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
if (n <= 0) { perror("AI"); }
} }
} }
@ -249,11 +233,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "VS0;"; pbuf = "VS0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n < 0) { perror("VS"); }
continue; continue;
} }
else if (strcmp(buf, "EX032;") == 0) else if (strcmp(buf, "EX032;") == 0)
@ -263,11 +243,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant); SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n < 0) { perror("EX032"); }
continue; continue;
} }
else if (strncmp(buf, "EX", 2) == 0) else if (strncmp(buf, "EX", 2) == 0)
@ -277,13 +253,13 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FA;") == 0) else if (strcmp(buf, "FA;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa); SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strcmp(buf, "FB;") == 0) else if (strcmp(buf, "FB;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb); SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FA", 2) == 0) else if (strncmp(buf, "FA", 2) == 0)
@ -299,27 +275,27 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "AI;", 3) == 0) else if (strncmp(buf, "AI;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "AI0;"); SNPRINTF(buf, sizeof(buf), "AI0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "PS;", 3) == 0) else if (strncmp(buf, "PS;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PS1;"); SNPRINTF(buf, sizeof(buf), "PS1;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "SA;", 3) == 0) else if (strncmp(buf, "SA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SA0;"); SNPRINTF(buf, sizeof(buf), "SA0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0) else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2], SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2],
buf[2] == '0' ? freqA : freqB, buf[2] == '0' ? freqA : freqB,
buf[2] == '0' ? modeA + '0' : modeB + '0'); buf[2] == '0' ? modeA + '0' : modeB + '0');
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "SF", 2) == 0) else if (strncmp(buf, "SF", 2) == 0)
@ -337,7 +313,7 @@ int main(int argc, char *argv[])
{ {
SNPRINTF(buf, sizeof(buf), "MD%d;", SNPRINTF(buf, sizeof(buf), "MD%d;",
modeA); // not worried about modeB yet for simulator modeA); // not worried about modeB yet for simulator
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "MD", 2) == 0) else if (strncmp(buf, "MD", 2) == 0)
@ -348,7 +324,7 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "FL;", 3) == 0) else if (strncmp(buf, "FL;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FL%03d;", filternum); SNPRINTF(buf, sizeof(buf), "FL%03d;", filternum);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FL", 2) == 0) else if (strncmp(buf, "FL", 2) == 0)
@ -359,7 +335,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FR;") == 0) else if (strcmp(buf, "FR;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo); SNPRINTF(buf, sizeof(buf), "FR%d;", vfo);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FR", 2) == 0) else if (strncmp(buf, "FR", 2) == 0)
@ -369,7 +345,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FT;") == 0) else if (strcmp(buf, "FT;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx); SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FT", 2) == 0) else if (strncmp(buf, "FT", 2) == 0)
@ -379,7 +355,7 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "DA;", 3) == 0) else if (strncmp(buf, "DA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "DA%d;", datamode); SNPRINTF(buf, sizeof(buf), "DA%d;", datamode);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }

Wyświetl plik

@ -2,10 +2,12 @@
// gcc -o simspid simspid.c // gcc -o simspid simspid.c
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -33,7 +35,7 @@ getmyline(int fd, char *buf)
buf[i++] = c; buf[i++] = c;
n++; n++;
for (int i = 0; i < strlen(buf); ++i) { printf("%02x ", buf[i]); } for (int j = 0; j < strlen(buf); ++j) { printf("%02x ", buf[j]); }
printf("\n"); printf("\n");
} }

Wyświetl plik

@ -2,10 +2,12 @@
// gcc -o simspid simspid.c // gcc -o simspid simspid.c
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

Wyświetl plik

@ -2,10 +2,12 @@
// gcc -o simyaesu simyaesu.c // gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

Wyświetl plik

@ -13,6 +13,7 @@ struct ip_mreq
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <hamlib/rig.h> #include <hamlib/rig.h>
#include "sim.h"
#define BUFSIZE 256 #define BUFSIZE 256
@ -86,7 +87,6 @@ int main(int argc, char *argv[])
{ {
char buf[256]; char buf[256];
char *pbuf; char *pbuf;
int n;
int fd = openPort(argv[1]); int fd = openPort(argv[1]);
int freqa = 14074000, freqb = 140735000; int freqa = 14074000, freqb = 140735000;
int modeA = 1, modeB = 2; int modeA = 1, modeB = 2;
@ -104,10 +104,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RM5100000;"; pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("RM5"); }
} }
else if (strcmp(buf, "AN0;") == 0) else if (strcmp(buf, "AN0;") == 0)
@ -115,10 +112,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AN030;"; pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("AN"); }
} }
else if (strcmp(buf, "IF;") == 0) else if (strcmp(buf, "IF;") == 0)
{ {
@ -128,59 +122,55 @@ int main(int argc, char *argv[])
pbuf = "IF000503130001000+0000000000030000000;"; pbuf = "IF000503130001000+0000000000030000000;";
sprintf(ifbuf, "IF%011d0001000+0000000000030000000;", freqa); sprintf(ifbuf, "IF%011d0001000+0000000000030000000;", freqa);
//pbuf = "IF00010138698 +00000000002000000 ; //pbuf = "IF00010138698 +00000000002000000 ;
n = write(fd, ifbuf, strlen(ifbuf)); write(fd, ifbuf, strlen(ifbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("IF"); }
continue; continue;
} }
else if (strcmp(buf, "NB;") == 0) else if (strcmp(buf, "NB;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "NB0;"; pbuf = "NB0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "RA;") == 0) else if (strcmp(buf, "RA;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RA01;"; pbuf = "RA01;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "RG;") == 0) else if (strcmp(buf, "RG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RG055;"; pbuf = "RG055;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "MG;") == 0) else if (strcmp(buf, "MG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "MG050;"; pbuf = "MG050;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "AG;") == 0) else if (strcmp(buf, "AG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AG100;"; pbuf = "AG100;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "FV;") == 0) else if (strcmp(buf, "FV;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "FV1.2;"; pbuf = "FV1.2;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strncmp(buf, "IS;", 3) == 0) else if (strncmp(buf, "IS;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "IS+0000;"); SNPRINTF(buf, sizeof(buf), "IS+0000;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
@ -191,14 +181,14 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "SM;", 3) == 0) else if (strncmp(buf, "SM;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SM0035;"); SNPRINTF(buf, sizeof(buf), "SM0035;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
else if (strncmp(buf, "PC;", 3) == 0) else if (strncmp(buf, "PC;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PC100;"); SNPRINTF(buf, sizeof(buf), "PC100;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
@ -206,10 +196,10 @@ int main(int argc, char *argv[])
{ {
//usleep(mysleep * 1000); //usleep(mysleep * 1000);
pbuf = "FW240"; pbuf = "FW240";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
hl_usleep(20 * 1000); hl_usleep(20 * 1000);
pbuf = "0;"; pbuf = "0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strncmp(buf, "FW", 2) == 0) else if (strncmp(buf, "FW", 2) == 0)
@ -221,11 +211,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
SNPRINTF(buf, sizeof(buf), "ID%03d;", 10); SNPRINTF(buf, sizeof(buf), "ID%03d;", 10);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n <= 0) { perror("ID"); }
continue; continue;
} }
@ -236,10 +222,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AI0;"; pbuf = "AI0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
if (n <= 0) { perror("AI"); }
} }
} }
@ -248,11 +231,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "VS0;"; pbuf = "VS0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n < 0) { perror("VS"); }
continue; continue;
} }
else if (strcmp(buf, "EX032;") == 0) else if (strcmp(buf, "EX032;") == 0)
@ -262,11 +241,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant); SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n < 0) { perror("EX032"); }
continue; continue;
} }
else if (strncmp(buf, "EX", 2) == 0) else if (strncmp(buf, "EX", 2) == 0)
@ -276,13 +251,13 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FA;") == 0) else if (strcmp(buf, "FA;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa); SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strcmp(buf, "FB;") == 0) else if (strcmp(buf, "FB;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb); SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FA", 2) == 0) else if (strncmp(buf, "FA", 2) == 0)
@ -298,27 +273,27 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "AI;", 3) == 0) else if (strncmp(buf, "AI;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "AI0;"); SNPRINTF(buf, sizeof(buf), "AI0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "PS;", 3) == 0) else if (strncmp(buf, "PS;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PS1;"); SNPRINTF(buf, sizeof(buf), "PS1;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "SA;", 3) == 0) else if (strncmp(buf, "SA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SA0;"); SNPRINTF(buf, sizeof(buf), "SA0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0) else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2], SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2],
buf[2] == '0' ? freqA : freqB, buf[2] == '0' ? freqA : freqB,
buf[2] == '0' ? modeA + '0' : modeB + '0'); buf[2] == '0' ? modeA + '0' : modeB + '0');
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "SF", 2) == 0) else if (strncmp(buf, "SF", 2) == 0)
@ -336,7 +311,7 @@ int main(int argc, char *argv[])
{ {
SNPRINTF(buf, sizeof(buf), "MD%d;", SNPRINTF(buf, sizeof(buf), "MD%d;",
modeA); // not worried about modeB yet for simulator modeA); // not worried about modeB yet for simulator
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "MD", 2) == 0) else if (strncmp(buf, "MD", 2) == 0)
@ -347,7 +322,7 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "FL;", 3) == 0) else if (strncmp(buf, "FL;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FL%03d;", filternum); SNPRINTF(buf, sizeof(buf), "FL%03d;", filternum);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FL", 2) == 0) else if (strncmp(buf, "FL", 2) == 0)
@ -358,7 +333,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FR;") == 0) else if (strcmp(buf, "FR;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo); SNPRINTF(buf, sizeof(buf), "FR%d;", vfo);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FR", 2) == 0) else if (strncmp(buf, "FR", 2) == 0)
@ -368,7 +343,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FT;") == 0) else if (strcmp(buf, "FT;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx); SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FT", 2) == 0) else if (strncmp(buf, "FT", 2) == 0)
@ -378,7 +353,7 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "DA;", 3) == 0) else if (strncmp(buf, "DA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "DA%d;", datamode); SNPRINTF(buf, sizeof(buf), "DA%d;", datamode);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }

Wyświetl plik

@ -85,7 +85,6 @@ int main(int argc, char *argv[])
{ {
char buf[256]; char buf[256];
char *pbuf; char *pbuf;
int n;
int fd = openPort(argv[1]); int fd = openPort(argv[1]);
int freqa = 14074000, freqb = 140735000; int freqa = 14074000, freqb = 140735000;
int modeA = 1, modeB = 2; int modeA = 1, modeB = 2;
@ -103,10 +102,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RM5100000;"; pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("RM5"); }
} }
else if (strcmp(buf, "AN0;") == 0) else if (strcmp(buf, "AN0;") == 0)
@ -114,10 +110,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AN030;"; pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("AN"); }
} }
else if (strcmp(buf, "IF;") == 0) else if (strcmp(buf, "IF;") == 0)
{ {
@ -127,59 +120,55 @@ int main(int argc, char *argv[])
pbuf = "IF000503130001000+0000000000030000000;"; pbuf = "IF000503130001000+0000000000030000000;";
sprintf(ifbuf, "IF%011d0001000+0000000000030000000;", freqa); sprintf(ifbuf, "IF%011d0001000+0000000000030000000;", freqa);
//pbuf = "IF00010138698 +00000000002000000 ; //pbuf = "IF00010138698 +00000000002000000 ;
n = write(fd, ifbuf, strlen(ifbuf)); write(fd, ifbuf, strlen(ifbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("IF"); }
continue; continue;
} }
else if (strcmp(buf, "NB;") == 0) else if (strcmp(buf, "NB;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "NB0;"; pbuf = "NB0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "RA;") == 0) else if (strcmp(buf, "RA;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RA01;"; pbuf = "RA01;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "RG;") == 0) else if (strcmp(buf, "RG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RG055;"; pbuf = "RG055;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "MG;") == 0) else if (strcmp(buf, "MG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "MG050;"; pbuf = "MG050;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "AG;") == 0) else if (strcmp(buf, "AG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AG100;"; pbuf = "AG100;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "FV;") == 0) else if (strcmp(buf, "FV;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "FV1.2;"; pbuf = "FV1.2;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strncmp(buf, "IS;", 3) == 0) else if (strncmp(buf, "IS;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "IS+0000;"); SNPRINTF(buf, sizeof(buf), "IS+0000;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
@ -190,14 +179,14 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "SM;", 3) == 0) else if (strncmp(buf, "SM;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SM0035;"); SNPRINTF(buf, sizeof(buf), "SM0035;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
else if (strncmp(buf, "PC;", 3) == 0) else if (strncmp(buf, "PC;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PC100;"); SNPRINTF(buf, sizeof(buf), "PC100;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
@ -205,10 +194,10 @@ int main(int argc, char *argv[])
{ {
//usleep(mysleep * 1000); //usleep(mysleep * 1000);
pbuf = "FW240"; pbuf = "FW240";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
hl_usleep(20 * 1000); hl_usleep(20 * 1000);
pbuf = "0;"; pbuf = "0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strncmp(buf, "FW", 2) == 0) else if (strncmp(buf, "FW", 2) == 0)
@ -221,11 +210,7 @@ int main(int argc, char *argv[])
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
int id = 24; int id = 24;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id); SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n <= 0) { perror("ID"); }
continue; continue;
} }
@ -237,9 +222,6 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
n = fprintf(fp, "%s", "AI0;"); n = fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
if (n <= 0) { perror("AI"); }
} }
} }
@ -249,11 +231,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "VS0;"; pbuf = "VS0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n < 0) { perror("VS"); }
continue; continue;
} }
else if (strcmp(buf, "EX032;") == 0) else if (strcmp(buf, "EX032;") == 0)
@ -263,11 +241,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant); SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n < 0) { perror("EX032"); }
continue; continue;
} }
else if (strncmp(buf, "EX", 2) == 0) else if (strncmp(buf, "EX", 2) == 0)
@ -277,13 +251,13 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FA;") == 0) else if (strcmp(buf, "FA;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa); SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strcmp(buf, "FB;") == 0) else if (strcmp(buf, "FB;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb); SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FA", 2) == 0) else if (strncmp(buf, "FA", 2) == 0)
@ -299,27 +273,27 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "AI;", 3) == 0) else if (strncmp(buf, "AI;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "AI0;"); SNPRINTF(buf, sizeof(buf), "AI0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "PS;", 3) == 0) else if (strncmp(buf, "PS;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PS1;"); SNPRINTF(buf, sizeof(buf), "PS1;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "SA;", 3) == 0) else if (strncmp(buf, "SA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SA0;"); SNPRINTF(buf, sizeof(buf), "SA0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0) else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2], SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2],
buf[2] == '0' ? freqA : freqB, buf[2] == '0' ? freqA : freqB,
buf[2] == '0' ? modeA + '0' : modeB + '0'); buf[2] == '0' ? modeA + '0' : modeB + '0');
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "SF", 2) == 0) else if (strncmp(buf, "SF", 2) == 0)
@ -337,7 +311,7 @@ int main(int argc, char *argv[])
{ {
SNPRINTF(buf, sizeof(buf), "MD%d;", SNPRINTF(buf, sizeof(buf), "MD%d;",
modeA); // not worried about modeB yet for simulator modeA); // not worried about modeB yet for simulator
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "MD", 2) == 0) else if (strncmp(buf, "MD", 2) == 0)
@ -348,7 +322,7 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "FL;", 3) == 0) else if (strncmp(buf, "FL;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FL%03d;", filternum); SNPRINTF(buf, sizeof(buf), "FL%03d;", filternum);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FL", 2) == 0) else if (strncmp(buf, "FL", 2) == 0)
@ -359,7 +333,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FR;") == 0) else if (strcmp(buf, "FR;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo); SNPRINTF(buf, sizeof(buf), "FR%d;", vfo);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FR", 2) == 0) else if (strncmp(buf, "FR", 2) == 0)
@ -369,7 +343,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FT;") == 0) else if (strcmp(buf, "FT;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx); SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FT", 2) == 0) else if (strncmp(buf, "FT", 2) == 0)
@ -379,7 +353,7 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "DA;", 3) == 0) else if (strncmp(buf, "DA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "DA%d;", datamode); SNPRINTF(buf, sizeof(buf), "DA%d;", datamode);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }

Wyświetl plik

@ -2,10 +2,12 @@
// gcc -o simyaesu simyaesu.c // gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -86,7 +88,6 @@ int main(int argc, char *argv[])
{ {
char buf[256]; char buf[256];
char *pbuf; char *pbuf;
int n;
int fd = openPort(argv[1]); int fd = openPort(argv[1]);
int freqa = 14074000, freqb = 140735000; int freqa = 14074000, freqb = 140735000;
int modeA = 1, modeB = 2; int modeA = 1, modeB = 2;
@ -104,10 +105,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RM5100000;"; pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("RM5"); }
} }
else if (strcmp(buf, "AN0;") == 0) else if (strcmp(buf, "AN0;") == 0)
@ -115,10 +113,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AN030;"; pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("AN"); }
} }
else if (strcmp(buf, "IF;") == 0) else if (strcmp(buf, "IF;") == 0)
{ {
@ -128,59 +123,55 @@ int main(int argc, char *argv[])
// pbuf = "IF000503130001000+0000000000030000000;" // pbuf = "IF000503130001000+0000000000030000000;"
sprintf(ifbuf, "IF%011d1000+0000002000000000000;", freqa); sprintf(ifbuf, "IF%011d1000+0000002000000000000;", freqa);
//pbuf = "IF00010138698 +00000000002000000 ; //pbuf = "IF00010138698 +00000000002000000 ;
n = write(fd, ifbuf, strlen(ifbuf)); write(fd, ifbuf, strlen(ifbuf));
// printf("n=%d\n", n);
if (n <= 0) { perror("IF"); }
continue; continue;
} }
else if (strcmp(buf, "NB;") == 0) else if (strcmp(buf, "NB;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "NB0;"; pbuf = "NB0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "RA;") == 0) else if (strcmp(buf, "RA;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RA01;"; pbuf = "RA01;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "RG;") == 0) else if (strcmp(buf, "RG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "RG055;"; pbuf = "RG055;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "MG;") == 0) else if (strcmp(buf, "MG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "MG050;"; pbuf = "MG050;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "AG;") == 0) else if (strcmp(buf, "AG;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "AG100;"; pbuf = "AG100;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strcmp(buf, "FV;") == 0) else if (strcmp(buf, "FV;") == 0)
{ {
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "FV1.2;"; pbuf = "FV1.2;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strncmp(buf, "IS;", 3) == 0) else if (strncmp(buf, "IS;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "IS+0000;"); SNPRINTF(buf, sizeof(buf), "IS+0000;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
@ -191,14 +182,14 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "SM;", 3) == 0) else if (strncmp(buf, "SM;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SM0035;"); SNPRINTF(buf, sizeof(buf), "SM0035;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
else if (strncmp(buf, "PC;", 3) == 0) else if (strncmp(buf, "PC;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PC100;"); SNPRINTF(buf, sizeof(buf), "PC100;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }
@ -206,10 +197,10 @@ int main(int argc, char *argv[])
{ {
//usleep(mysleep * 1000); //usleep(mysleep * 1000);
pbuf = "FW240"; pbuf = "FW240";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
hl_usleep(20 * 1000); hl_usleep(20 * 1000);
pbuf = "0;"; pbuf = "0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
continue; continue;
} }
else if (strncmp(buf, "FW", 2) == 0) else if (strncmp(buf, "FW", 2) == 0)
@ -222,11 +213,7 @@ int main(int argc, char *argv[])
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
int id = 24; int id = 24;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id); SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n <= 0) { perror("ID"); }
continue; continue;
} }
@ -238,9 +225,6 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
n = fprintf(fp, "%s", "AI0;"); n = fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
if (n <= 0) { perror("AI"); }
} }
} }
@ -250,11 +234,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
pbuf = "VS0;"; pbuf = "VS0;";
n = write(fd, pbuf, strlen(pbuf)); write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
if (n < 0) { perror("VS"); }
continue; continue;
} }
else if (strcmp(buf, "EX032;") == 0) else if (strcmp(buf, "EX032;") == 0)
@ -264,11 +244,7 @@ int main(int argc, char *argv[])
printf("%s\n", buf); printf("%s\n", buf);
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant); SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
// printf("n=%d\n", n);
if (n < 0) { perror("EX032"); }
continue; continue;
} }
else if (strncmp(buf, "EX", 2) == 0) else if (strncmp(buf, "EX", 2) == 0)
@ -278,13 +254,13 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FA;") == 0) else if (strcmp(buf, "FA;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa); SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strcmp(buf, "FB;") == 0) else if (strcmp(buf, "FB;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb); SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FA", 2) == 0) else if (strncmp(buf, "FA", 2) == 0)
@ -300,27 +276,27 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "AI;", 3) == 0) else if (strncmp(buf, "AI;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "AI0;"); SNPRINTF(buf, sizeof(buf), "AI0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "PS;", 3) == 0) else if (strncmp(buf, "PS;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "PS1;"); SNPRINTF(buf, sizeof(buf), "PS1;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "SA;", 3) == 0) else if (strncmp(buf, "SA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SA0;"); SNPRINTF(buf, sizeof(buf), "SA0;");
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
} }
else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0) else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2], SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2],
buf[2] == '0' ? freqA : freqB, buf[2] == '0' ? freqA : freqB,
buf[2] == '0' ? modeA + '0' : modeB + '0'); buf[2] == '0' ? modeA + '0' : modeB + '0');
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "SF", 2) == 0) else if (strncmp(buf, "SF", 2) == 0)
@ -338,7 +314,7 @@ int main(int argc, char *argv[])
{ {
SNPRINTF(buf, sizeof(buf), "MD%d;", SNPRINTF(buf, sizeof(buf), "MD%d;",
modeA); // not worried about modeB yet for simulator modeA); // not worried about modeB yet for simulator
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "MD", 2) == 0) else if (strncmp(buf, "MD", 2) == 0)
@ -349,7 +325,7 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "FL;", 3) == 0) else if (strncmp(buf, "FL;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FL%03d%03d;", filternum1, filternum2); SNPRINTF(buf, sizeof(buf), "FL%03d%03d;", filternum1, filternum2);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FL", 2) == 0) else if (strncmp(buf, "FL", 2) == 0)
@ -360,7 +336,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FR;") == 0) else if (strcmp(buf, "FR;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo); SNPRINTF(buf, sizeof(buf), "FR%d;", vfo);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FR", 2) == 0) else if (strncmp(buf, "FR", 2) == 0)
@ -370,7 +346,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "FT;") == 0) else if (strcmp(buf, "FT;") == 0)
{ {
SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx); SNPRINTF(buf, sizeof(buf), "FR%d;", vfo_tx);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
continue; continue;
} }
else if (strncmp(buf, "FT", 2) == 0) else if (strncmp(buf, "FT", 2) == 0)
@ -380,7 +356,7 @@ int main(int argc, char *argv[])
else if (strncmp(buf, "DA;", 3) == 0) else if (strncmp(buf, "DA;", 3) == 0)
{ {
SNPRINTF(buf, sizeof(buf), "DA%d;", datamode); SNPRINTF(buf, sizeof(buf), "DA%d;", datamode);
n = write(fd, buf, strlen(buf)); write(fd, buf, strlen(buf));
printf("%s\n", buf); printf("%s\n", buf);
continue; continue;
} }

Wyświetl plik

@ -41,7 +41,7 @@ int ant_option = 0;
int ptt = 0; int ptt = 0;
int keyspd = 20; int keyspd = 20;
void dumphex(unsigned char *buf, int n) void dumphex(const unsigned char *buf, int n)
{ {
for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); } for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); }
@ -75,7 +75,6 @@ frameGet(int fd, unsigned char *buf)
void frameParse(int fd, unsigned char *frame, int len) void frameParse(int fd, unsigned char *frame, int len)
{ {
double freq; double freq;
int n;
dumphex(frame, len); dumphex(frame, len);
@ -103,9 +102,7 @@ void frameParse(int fd, unsigned char *frame, int len)
} }
frame[10] = 0xfd; frame[10] = 0xfd;
n = write(fd, frame, 11); write(fd, frame, 11);
if (n != 11) {printf("Error!\n"); exit(1);}
break; break;
@ -124,7 +121,7 @@ void frameParse(int fd, unsigned char *frame, int len)
} }
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
case 0x05: case 0x05:
@ -136,7 +133,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x06: case 0x06:
@ -145,7 +142,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x07: case 0x07:
@ -164,7 +161,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
case 0x0f: case 0x0f:
@ -174,7 +171,7 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("set split %d\n", 1); printf("set split %d\n", 1);
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
break; break;
#if 0 #if 0
@ -197,7 +194,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = 0xfd; frame[7] = 0xfd;
printf("n=write 8 bytes\n"); printf("n=write 8 bytes\n");
dump_hex(frame, 8); dump_hex(frame, 8);
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
#endif #endif
@ -212,7 +209,7 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("Using AF level %d\n", level); printf("Using AF level %d\n", level);
to_bcd(&frame[6], (long long) level, 2); to_bcd(&frame[6], (long long) level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
case 0x0a: case 0x0a:
@ -223,7 +220,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)power_level, 2); to_bcd(&frame[6], (long long)power_level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
case 0x0c: case 0x0c:
@ -235,14 +232,14 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("subcmd=0x0c #1\n"); printf("subcmd=0x0c #1\n");
keyspd = from_bcd(&frame[6], 2); keyspd = from_bcd(&frame[6], 2);
frame[6] = 0xfb; frame[6] = 0xfb;
n = write(fd, frame, 7); write(fd, frame, 7);
} }
else else
{ {
printf("subcmd=0x0c #1\n"); printf("subcmd=0x0c #1\n");
to_bcd(&frame[6], keyspd, 2); to_bcd(&frame[6], keyspd, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
} }
break; break;
@ -264,7 +261,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)meter_level, 2); to_bcd(&frame[6], (long long)meter_level, 2);
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
break; break;
} }
@ -275,7 +272,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x18: // miscellaneous things case 0x18: // miscellaneous things
frame[5] = 1; frame[5] = 1;
frame[6] = 0xfd; frame[6] = 0xfd;
n = write(fd, frame, 7); write(fd, frame, 7);
break; break;
#endif #endif
@ -287,7 +284,7 @@ void frameParse(int fd, unsigned char *frame, int len)
else { frame[6] = widthB; } else { frame[6] = widthB; }
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
break; break;
} }
@ -301,14 +298,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{ {
frame[6] = ptt; frame[6] = ptt;
frame[7] = 0xfd; frame[7] = 0xfd;
n = write(fd, frame, 8); write(fd, frame, 8);
} }
else else
{ {
ptt = frame[6]; ptt = frame[6];
frame[7] = 0xfb; frame[7] = 0xfb;
frame[8] = 0xfd; frame[8] = 0xfd;
n = write(fd, frame, 9); write(fd, frame, 9);
} }
break; break;
@ -335,7 +332,7 @@ void frameParse(int fd, unsigned char *frame, int len)
} }
frame[11] = 0xfd; frame[11] = 0xfd;
n = write(fd, frame, 12); write(fd, frame, 12);
} }
else else
{ {
@ -347,7 +344,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
break; break;
@ -363,7 +360,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = frame[5] == 0 ? datamodeA : datamodeB; frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
frame[8] = 0xfb; frame[8] = 0xfb;
frame[9] = 0xfd; frame[9] = 0xfd;
n = write(fd, frame, 10); write(fd, frame, 10);
} }
else else
{ {
@ -382,7 +379,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb; frame[4] = 0xfb;
frame[5] = 0xfd; frame[5] = 0xfd;
n = write(fd, frame, 6); write(fd, frame, 6);
} }
printf("\n"); printf("\n");

Wyświetl plik

@ -2,10 +2,12 @@
// gcc -o simyaesu simyaesu.c // gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
// since we are POSIX here we need this // since we are POSIX here we need this
#if 0
struct ip_mreq struct ip_mreq
{ {
int dummy; int dummy;
}; };
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -275,7 +277,7 @@ int main(int argc, char *argv[])
hl_usleep(50 * 1000); hl_usleep(50 * 1000);
pbuf = "VS0;"; pbuf = "VS0;";
if (curr_vfo == RIG_VFO_B || curr_vfo == RIG_VFO_SUB) { pbuf[2] = '1'; } if (curr_vfo == RIG_VFO_B || curr_vfo == RIG_VFO_SUB) { pbuf = "VS1"; }
n = write(fd, pbuf, strlen(pbuf)); n = write(fd, pbuf, strlen(pbuf));
printf("%s\n", pbuf); printf("%s\n", pbuf);

Wyświetl plik

@ -466,10 +466,14 @@ int HAMLIB_API amp_close(AMP *amp)
amp_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); amp_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (amp == NULL || amp->caps == NULL) if (amp == NULL)
{ {
amp_debug(RIG_DEBUG_ERR, "%s: NULL ptr? amp=%p, amp->caps=%p\n", __func__, amp, amp_debug(RIG_DEBUG_ERR, "%s: NULL ptr? amp=%p\n", __func__, amp);
amp->caps==NULL?NULL:amp->caps); return -RIG_EINVAL;
}
if (amp->caps == NULL)
{
amp_debug(RIG_DEBUG_ERR, "%s: NULL ptr? amp->caps=%p\n", __func__, amp->caps);
return -RIG_EINVAL; return -RIG_EINVAL;
} }

Wyświetl plik

@ -593,8 +593,7 @@ int rig_fire_freq_event(RIG *rig, vfo_t vfo, freq_t freq)
{ {
ENTERFUNC; ENTERFUNC;
rig_debug(RIG_DEBUG_TRACE, "Event: freq changed to %"PRIll"Hz on %s\n", rig_debug(RIG_DEBUG_TRACE, "Event: freq changed to %"PRIll"Hz on %s\n", (int64_t)freq, rig_strvfo(vfo));
(int64_t)freq, rig_strvfo(vfo));
rig_set_cache_freq(rig, vfo, freq); rig_set_cache_freq(rig, vfo, freq);
// This doesn't work well for Icom rigs -- no way to tell which VFO we're on // This doesn't work well for Icom rigs -- no way to tell which VFO we're on

Wyświetl plik

@ -46,7 +46,7 @@
static int rig_has_ext_token(RIG *rig, token_t token) static int rig_has_ext_token(RIG *rig, token_t token)
{ {
int *ext_tokens = rig->caps->ext_tokens; const int *ext_tokens = rig->caps->ext_tokens;
int i; int i;
if (ext_tokens == NULL) if (ext_tokens == NULL)

Wyświetl plik

@ -839,11 +839,11 @@ static int port_read_sync_data_error_code(hamlib_port_t *p, int fd, int direct)
ssize_t total_bytes_read = 0; ssize_t total_bytes_read = 0;
ssize_t bytes_read; ssize_t bytes_read;
struct timeval tv_timeout; struct timeval tv_timeout;
int result;
signed char data; signed char data;
do do
{ {
int result;
tv_timeout.tv_sec = 0; tv_timeout.tv_sec = 0;
tv_timeout.tv_usec = 0; tv_timeout.tv_usec = 0;
@ -1047,7 +1047,6 @@ int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer,
size_t count) size_t count)
{ {
int ret; int ret;
int method = 0;
if (p->fd < 0) if (p->fd < 0)
{ {
@ -1084,7 +1083,6 @@ int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer,
if (p->write_delay > 0) if (p->write_delay > 0)
{ {
int i; int i;
method = 1;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
@ -1107,7 +1105,6 @@ int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer,
} }
else else
{ {
method = 2;
ret = port_write(p, txbuffer, count); ret = port_write(p, txbuffer, count);
if (ret != count) if (ret != count)
@ -1123,13 +1120,12 @@ int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer,
} }
} }
rig_debug(RIG_DEBUG_TRACE, "%s(): TX %d bytes, method=%d\n", __func__, rig_debug(RIG_DEBUG_TRACE, "%s(): TX %d bytes\n", __func__,
(int)count, method); (int)count);
dump_hex((unsigned char *) txbuffer, count); dump_hex((unsigned char *) txbuffer, count);
if (p->post_write_delay > 0) if (p->post_write_delay > 0)
{ {
method |= 4;
#if 0 #if 0
#ifdef WANT_NON_ACTIVE_POST_WRITE_DELAY #ifdef WANT_NON_ACTIVE_POST_WRITE_DELAY
#define POST_WRITE_DELAY_TRSHLD 10 #define POST_WRITE_DELAY_TRSHLD 10
@ -1431,7 +1427,7 @@ static int read_string_generic(hamlib_port_t *p,
// direct); // direct);
} }
// special read for FLRig // special read for FLRig
if (strcmp(stopset, "/methodResponse>") == 0) if (strcmp(stopset, "</methodResponse>") == 0)
{ {
if (strstr((char*)rxbuffer, stopset)) if (strstr((char*)rxbuffer, stopset))
{ {

Wyświetl plik

@ -1035,7 +1035,6 @@ static const struct
int check_level_param(RIG *rig, setting_t level, value_t val, gran_t **gran) int check_level_param(RIG *rig, setting_t level, value_t val, gran_t **gran)
{ {
gran_t *this_gran; gran_t *this_gran;
float maxval;
this_gran = &rig->caps->level_gran[rig_setting2idx(level)]; this_gran = &rig->caps->level_gran[rig_setting2idx(level)];
@ -1046,6 +1045,7 @@ int check_level_param(RIG *rig, setting_t level, value_t val, gran_t **gran)
if (RIG_LEVEL_IS_FLOAT(level)) if (RIG_LEVEL_IS_FLOAT(level))
{ {
float maxval;
/* If min==max==step==0, all values are OK here */ /* If min==max==step==0, all values are OK here */
maxval = this_gran->max.f; maxval = this_gran->max.f;
@ -1494,7 +1494,7 @@ enum agc_level_e rig_levelagcvalue(int agcValue)
* \param mode AGC string... * \param mode AGC string...
* \return agc_level_e * \return agc_level_e
*/ */
enum agc_level_e rig_levelagcstr(char *agcString) enum agc_level_e rig_levelagcstr(const char *agcString)
{ {
enum agc_level_e agcLevel; enum agc_level_e agcLevel;
@ -2741,7 +2741,7 @@ uint32_t CRC32_function(uint8_t *buf, uint32_t len)
static struct tm *gmtime_r(const time_t *t, struct tm *r) static struct tm *gmtime_r(const time_t *t, struct tm *r)
{ {
// gmtime is threadsafe in windows because it uses TLS // gmtime is threadsafe in windows because it uses TLS
struct tm *theTm = gmtime(t); const struct tm *theTm = gmtime(t);
if (theTm) if (theTm)
{ {
@ -2763,7 +2763,7 @@ char *date_strget(char *buf, int buflen, int localtime)
struct tm *mytm; struct tm *mytm;
time_t t; time_t t;
struct timeval tv; struct timeval tv;
struct tm result; struct tm result = { 0,0,0,0,0,0,0,0,0};
int mytimezone; int mytimezone;
t = time(NULL); t = time(NULL);

Wyświetl plik

@ -206,7 +206,7 @@ typedef enum settings_value_e
} settings_value_t; } settings_value_t;
extern HAMLIB_EXPORT(int) rig_settings_save(char *setting, void *value, settings_value_t valuet); extern HAMLIB_EXPORT(int) rig_settings_save(const char *setting, void *value, settings_value_t valuet);
extern HAMLIB_EXPORT(int) rig_settings_load(char *setting, void *value, settings_value_t valuet); extern HAMLIB_EXPORT(int) rig_settings_load(char *setting, void *value, settings_value_t valuet);
extern HAMLIB_EXPORT(int) rig_settings_load_all(char *settings_file); extern HAMLIB_EXPORT(int) rig_settings_load_all(char *settings_file);

Wyświetl plik

@ -575,19 +575,17 @@ int multicast_init(RIG *rig, char *addr, int port)
void multicast_close(RIG *rig) void multicast_close(RIG *rig)
{ {
int retval;
// Leave the multicast group // Leave the multicast group
if ((retval = setsockopt(rig->state.multicast->sock, IPPROTO_IP, if (setsockopt(rig->state.multicast->sock, IPPROTO_IP,
IP_DROP_MEMBERSHIP, (char *)&rig->state.multicast->mreq, IP_DROP_MEMBERSHIP, (char *)&rig->state.multicast->mreq,
sizeof(rig->state.multicast->mreq))) < 0) sizeof(rig->state.multicast->mreq)) < 0)
{ {
rig_debug(RIG_DEBUG_ERR, "%s: setsockopt: %s\n", __func__, strerror(errno)); rig_debug(RIG_DEBUG_ERR, "%s: setsockopt: %s\n", __func__, strerror(errno));
return; return;
} }
// Close the socket // Close the socket
if ((retval = close(rig->state.multicast->sock))) if (close(rig->state.multicast->sock))
{ {
rig_debug(RIG_DEBUG_ERR, "%s: close: %s\n", __func__, strerror(errno)); rig_debug(RIG_DEBUG_ERR, "%s: close: %s\n", __func__, strerror(errno));
} }
@ -626,7 +624,7 @@ int multicast_send(RIG *rig, const char *msg, int msglen)
//#define TEST //#define TEST
#ifdef TEST #ifdef TEST
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
RIG *rig; RIG *rig;
rig_model_t myrig_model; rig_model_t myrig_model;

Wyświetl plik

@ -80,6 +80,7 @@
#include "snapshot_data.h" #include "snapshot_data.h"
#ifdef HAVE_WINDOWS_H #ifdef HAVE_WINDOWS_H
// cppcheck-suppress missingInclude
#include "io.h" #include "io.h"
#endif #endif
@ -161,15 +162,15 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg)
int network_init() int network_init()
{ {
int retval = RIG_OK;
#ifdef __MINGW32__ #ifdef __MINGW32__
WSADATA wsadata; WSADATA wsadata;
if (wsstarted == 0) if (wsstarted == 0)
{ {
int ret; retval = WSAStartup(MAKEWORD(1, 1), &wsadata);
ret = WSAStartup(MAKEWORD(1, 1), &wsadata);
if (ret == 0) if (retval == 0)
{ {
wsstarted = 1; wsstarted = 1;
rig_debug(RIG_DEBUG_VERBOSE, "%s: WSAStartup OK\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s: WSAStartup OK\n", __func__);
@ -177,13 +178,13 @@ int network_init()
else else
{ {
rig_debug(RIG_DEBUG_ERR, "%s: error creating socket, WSAStartup ret=%d\n", rig_debug(RIG_DEBUG_ERR, "%s: error creating socket, WSAStartup ret=%d\n",
__func__, ret); __func__, retval);
return (-RIG_EIO); return (-RIG_EIO);
} }
} }
#endif #endif
return RIG_OK; return retval;
} }
/** /**
@ -599,7 +600,7 @@ static void multicast_publisher_close_data_pipe(multicast_publisher_priv_data
} }
} }
static int multicast_publisher_write_data(multicast_publisher_args static int multicast_publisher_write_data(const multicast_publisher_args
*mcast_publisher_args, size_t length, const unsigned char *data) *mcast_publisher_args, size_t length, const unsigned char *data)
{ {
int fd = mcast_publisher_args->data_write_fd; int fd = mcast_publisher_args->data_write_fd;
@ -627,7 +628,7 @@ static int multicast_publisher_write_data(multicast_publisher_args
return (RIG_OK); return (RIG_OK);
} }
static int multicast_publisher_read_data(multicast_publisher_args static int multicast_publisher_read_data(const multicast_publisher_args
*mcast_publisher_args, size_t length, unsigned char *data) *mcast_publisher_args, size_t length, unsigned char *data)
{ {
int fd = mcast_publisher_args->data_read_fd; int fd = mcast_publisher_args->data_read_fd;
@ -726,7 +727,7 @@ static int multicast_publisher_write_packet_header(RIG *rig,
int network_publish_rig_poll_data(RIG *rig) int network_publish_rig_poll_data(RIG *rig)
{ {
struct rig_state *rs = &rig->state; const struct rig_state *rs = &rig->state;
multicast_publisher_data_packet packet = multicast_publisher_data_packet packet =
{ {
.type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_POLL, .type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_POLL,
@ -745,7 +746,7 @@ int network_publish_rig_poll_data(RIG *rig)
int network_publish_rig_transceive_data(RIG *rig) int network_publish_rig_transceive_data(RIG *rig)
{ {
struct rig_state *rs = &rig->state; const struct rig_state *rs = &rig->state;
multicast_publisher_data_packet packet = multicast_publisher_data_packet packet =
{ {
.type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_TRANSCEIVE, .type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_TRANSCEIVE,
@ -891,7 +892,6 @@ void *multicast_publisher(void *arg)
struct sockaddr_in dest_addr; struct sockaddr_in dest_addr;
int socket_fd = args->socket_fd; int socket_fd = args->socket_fd;
int result;
ssize_t send_result; ssize_t send_result;
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Starting multicast publisher\n", __FILE__, rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Starting multicast publisher\n", __FILE__,
@ -906,6 +906,7 @@ void *multicast_publisher(void *arg)
while (rs->multicast_publisher_run) while (rs->multicast_publisher_run)
{ {
int result;
result = multicast_publisher_read_packet(args, &packet_type, &spectrum_line, result = multicast_publisher_read_packet(args, &packet_type, &spectrum_line,
spectrum_data); spectrum_data);

Wyświetl plik

@ -283,7 +283,7 @@ static int add_opened_rig(RIG *rig)
} }
static int remove_opened_rig(RIG *rig) static int remove_opened_rig(const RIG *rig)
{ {
struct opened_rig_l *p, *q; struct opened_rig_l *p, *q;
q = NULL; q = NULL;
@ -362,7 +362,6 @@ void add2debugmsgsave(const char *s)
int maxmsg = DEBUGMSGSAVE_SIZE / 2; int maxmsg = DEBUGMSGSAVE_SIZE / 2;
MUTEX_LOCK(debugmsgsave); MUTEX_LOCK(debugmsgsave);
memset(stmp, 0, sizeof(stmp)); memset(stmp, 0, sizeof(stmp));
p = debugmsgsave;
// we'll keep 20 lines including this one // we'll keep 20 lines including this one
// so count the lines // so count the lines
@ -940,7 +939,7 @@ int HAMLIB_API rig_open(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s: cwd=%s\n", __func__, cwd); rig_debug(RIG_DEBUG_VERBOSE, "%s: cwd=%s\n", __func__, cwd);
char *path = calloc(1, 4096); char *path = calloc(1, 4096);
extern char *settings_file; extern char *settings_file;
char *xdgpath = getenv("XDG_CONFIG_HOME"); const char *xdgpath = getenv("XDG_CONFIG_HOME");
settings_file = "hamlib_settings"; settings_file = "hamlib_settings";
@ -953,7 +952,7 @@ int HAMLIB_API rig_open(RIG *rig)
sprintf(path, "%s/%s", cwd, settings_file); sprintf(path, "%s/%s", cwd, settings_file);
} }
FILE *fp = fopen(path, "r"); const FILE *fp = fopen(path, "r");
if (fp == NULL) if (fp == NULL)
{ {
@ -1984,8 +1983,6 @@ int rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
} }
} }
else { retry = 0; } else { retry = 0; }
#else
tfreq = freq; tfreq = freq;
#endif #endif
} }
@ -2275,7 +2272,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
RETURNFUNC(-RIG_ENAVAIL); RETURNFUNC(-RIG_ENAVAIL);
} }
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo_opt=%d, model=%d\n", __func__, rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo_opt=%d, model=%u\n", __func__,
__LINE__, rig->state.vfo_opt, rig->caps->rig_model); __LINE__, rig->state.vfo_opt, rig->caps->rig_model);
// If we're in vfo_mode then rigctld will do any VFO swapping we need // If we're in vfo_mode then rigctld will do any VFO swapping we need
@ -3108,21 +3105,13 @@ int HAMLIB_API rig_get_vfo(RIG *rig, vfo_t *vfo)
if (CHECK_RIG_ARG(rig) || !vfo) if (CHECK_RIG_ARG(rig) || !vfo)
{ {
rig_debug(RIG_DEBUG_ERR, "%s: rig or rig->caps is null\n",__func__); rig_debug(RIG_DEBUG_ERR, "%s: rig or *vfo is null\n",__func__);
return -RIG_EINVAL; return -RIG_EINVAL;
} }
ENTERFUNC; ENTERFUNC;
ELAPSED1; ELAPSED1;
if (!vfo)
{
rig_debug(RIG_DEBUG_ERR, "%s: no vfo? rig=%p, vfo=%p\n", __func__,
rig, vfo);
ELAPSED2;
RETURNFUNC(-RIG_EINVAL);
}
caps = rig->caps; caps = rig->caps;
if (caps->get_vfo == NULL) if (caps->get_vfo == NULL)
@ -3156,11 +3145,11 @@ int HAMLIB_API rig_get_vfo(RIG *rig, vfo_t *vfo)
{ {
rig->state.current_vfo = *vfo; rig->state.current_vfo = *vfo;
rig->state.cache.vfo = *vfo; rig->state.cache.vfo = *vfo;
cache_ms = elapsed_ms(&rig->state.cache.time_vfo, HAMLIB_ELAPSED_SET); //cache_ms = elapsed_ms(&rig->state.cache.time_vfo, HAMLIB_ELAPSED_SET);
} }
else else
{ {
cache_ms = elapsed_ms(&rig->state.cache.time_vfo, HAMLIB_ELAPSED_INVALIDATE); //cache_ms = elapsed_ms(&rig->state.cache.time_vfo, HAMLIB_ELAPSED_INVALIDATE);
} }
if (retcode != RIG_OK) if (retcode != RIG_OK)
@ -4353,7 +4342,6 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
if (caps->set_freq) if (caps->set_freq)
{ {
int retry = 3; int retry = 3;
freq_t tfreq;
do do
{ {
@ -4377,8 +4365,6 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
if (caps->set_vfo) if (caps->set_vfo)
{ {
HAMLIB_TRACE; HAMLIB_TRACE;
retcode = RIG_OK;
retcode = caps->set_vfo(rig, tx_vfo); retcode = caps->set_vfo(rig, tx_vfo);
} }
else if (rig_has_vfo_op(rig, RIG_OP_TOGGLE) && caps->vfo_op) else if (rig_has_vfo_op(rig, RIG_OP_TOGGLE) && caps->vfo_op)
@ -5173,7 +5159,7 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
vfo_t tx_vfo) vfo_t tx_vfo)
{ {
const struct rig_caps *caps; const struct rig_caps *caps;
int retcode, rc2; int retcode;
vfo_t curr_vfo; vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig)) if (CHECK_RIG_ARG(rig))
@ -5292,7 +5278,7 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
/* try and revert even if we had an error above */ /* try and revert even if we had an error above */
if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ))
{ {
rc2 = caps->set_vfo(rig, curr_vfo); int rc2 = caps->set_vfo(rig, curr_vfo);
if (RIG_OK == retcode) if (RIG_OK == retcode)
{ {
@ -5399,7 +5385,7 @@ int HAMLIB_API rig_get_split_vfo(RIG *rig,
if ((vfo == RIG_VFO_CURR) || (vfo == rig->state.current_vfo)) if ((vfo == RIG_VFO_CURR) || (vfo == rig->state.current_vfo))
{ {
HAMLIB_TRACE; HAMLIB_TRACE;
retcode = RIG_OK; //retcode = RIG_OK;
//if (rig->caps->rig_model != RIG_MODEL_NETRIGCTL) //if (rig->caps->rig_model != RIG_MODEL_NETRIGCTL)
{ {
// rigctld doesn't like nested calls // rigctld doesn't like nested calls
@ -6126,15 +6112,15 @@ int HAMLIB_API rig_power2mW(RIG *rig,
txrange = rig_get_range(rig->state.tx_range_list, freq, mode); txrange = rig_get_range(rig->state.tx_range_list, freq, mode);
// check all the range lists // check all the range lists
if (txrange == NULL) { rig_get_range(rig->caps->tx_range_list1, freq, mode); } if (txrange == NULL) { txrange = rig_get_range(rig->caps->tx_range_list1, freq, mode); }
if (txrange == NULL) { rig_get_range(rig->caps->tx_range_list2, freq, mode); } if (txrange == NULL) { txrange = rig_get_range(rig->caps->tx_range_list2, freq, mode); }
if (txrange == NULL) { rig_get_range(rig->caps->tx_range_list3, freq, mode); } if (txrange == NULL) { txrange = rig_get_range(rig->caps->tx_range_list3, freq, mode); }
if (txrange == NULL) { rig_get_range(rig->caps->tx_range_list4, freq, mode); } if (txrange == NULL) { txrange = rig_get_range(rig->caps->tx_range_list4, freq, mode); }
if (txrange == NULL) { rig_get_range(rig->caps->tx_range_list5, freq, mode); } if (txrange == NULL) { txrange = rig_get_range(rig->caps->tx_range_list5, freq, mode); }
if (txrange == NULL) if (txrange == NULL)
{ {
@ -8010,7 +7996,6 @@ void *async_data_handler(void *arg)
RIG *rig = args->rig; RIG *rig = args->rig;
unsigned char frame[MAX_FRAME_LENGTH]; unsigned char frame[MAX_FRAME_LENGTH];
struct rig_state *rs = &rig->state; struct rig_state *rs = &rig->state;
int result;
rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting async data handler thread\n", rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting async data handler thread\n",
__func__); __func__);
@ -8023,6 +8008,7 @@ void *async_data_handler(void *arg)
{ {
int frame_length; int frame_length;
int async_frame; int async_frame;
int result;
result = rig->caps->read_frame_direct(rig, sizeof(frame), frame); result = rig->caps->read_frame_direct(rig, sizeof(frame), frame);
@ -8093,7 +8079,7 @@ void *morse_data_handler(void *arg)
struct morse_data_handler_args_s *args = struct morse_data_handler_args_s *args =
(struct morse_data_handler_args_s *) arg; (struct morse_data_handler_args_s *) arg;
RIG *rig = args->rig; RIG *rig = args->rig;
struct rig_state *rs = &rig->state; const struct rig_state *rs = &rig->state;
int result; int result;
rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting morse data handler thread\n", rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting morse data handler thread\n",
@ -8224,7 +8210,6 @@ HAMLIB_EXPORT(int) rig_send_raw(RIG *rig, const unsigned char *send,
int send_len, unsigned char *reply, int reply_len, unsigned char *term) int send_len, unsigned char *reply, int reply_len, unsigned char *term)
{ {
struct rig_state *rs = &rig->state; struct rig_state *rs = &rig->state;
unsigned char buf[200];
int nbytes; int nbytes;
int retval; int retval;
int simulate = rig->caps->rig_model == RIG_MODEL_DUMMY || int simulate = rig->caps->rig_model == RIG_MODEL_DUMMY ||
@ -8258,6 +8243,7 @@ HAMLIB_EXPORT(int) rig_send_raw(RIG *rig, const unsigned char *send,
if (reply) if (reply)
{ {
unsigned char buf[200];
if (simulate) if (simulate)
{ {
// Simulate a response by copying the command // Simulate a response by copying the command
@ -8323,7 +8309,7 @@ HAMLIB_EXPORT(int) rig_send_raw(RIG *rig, const unsigned char *send,
HAMLIB_EXPORT(int) rig_set_lock_mode(RIG *rig, int mode) HAMLIB_EXPORT(int) rig_set_lock_mode(RIG *rig, int mode)
{ {
int retcode = -RIG_ENAVAIL; int retcode;
if (rig->caps->set_lock_mode) if (rig->caps->set_lock_mode)
{ {
@ -8340,7 +8326,7 @@ HAMLIB_EXPORT(int) rig_set_lock_mode(RIG *rig, int mode)
HAMLIB_EXPORT(int) rig_get_lock_mode(RIG *rig, int *mode) HAMLIB_EXPORT(int) rig_get_lock_mode(RIG *rig, int *mode)
{ {
int retcode = -RIG_ENAVAIL; int retcode;
if (rig->caps->get_lock_mode) if (rig->caps->get_lock_mode)
{ {

Wyświetl plik

@ -782,7 +782,7 @@ int HAMLIB_API serial_flush(hamlib_port_t *p)
{ {
// we pass an empty stopset so read_string can determine // we pass an empty stopset so read_string can determine
// the appropriate stopset for async data // the appropriate stopset for async data
char stopset[1]; const char stopset[1];
len = read_string(p, buf, sizeof(buf) - 1, stopset, 0, 1, 1); len = read_string(p, buf, sizeof(buf) - 1, stopset, 0, 1, 1);
if (len > 0) if (len > 0)
@ -1164,7 +1164,7 @@ int HAMLIB_API ser_get_dtr(hamlib_port_t *p, int *state)
* \param state (ignored?) * \param state (ignored?)
* \return RIG_OK or < 0 * \return RIG_OK or < 0
*/ */
int HAMLIB_API ser_set_brk(hamlib_port_t *p, int state) int HAMLIB_API ser_set_brk(const hamlib_port_t *p, int state)
{ {
// ignore this for microHam ports // ignore this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd) if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)

Wyświetl plik

@ -36,7 +36,7 @@ int ser_open(hamlib_port_t *p);
int ser_close(hamlib_port_t *p); int ser_close(hamlib_port_t *p);
extern HAMLIB_EXPORT(int) ser_set_rts(hamlib_port_t *p, int state); extern HAMLIB_EXPORT(int) ser_set_rts(hamlib_port_t *p, int state);
extern HAMLIB_EXPORT(int) ser_get_rts(hamlib_port_t *p, int *state); extern HAMLIB_EXPORT(int) ser_get_rts(hamlib_port_t *p, int *state);
extern HAMLIB_EXPORT(int) ser_set_brk(hamlib_port_t *p, int state); extern HAMLIB_EXPORT(int) ser_set_brk(const hamlib_port_t *p, int state);
extern HAMLIB_EXPORT(int) ser_set_dtr(hamlib_port_t *p, int state); extern HAMLIB_EXPORT(int) ser_set_dtr(hamlib_port_t *p, int state);
extern HAMLIB_EXPORT(int) ser_get_dtr(hamlib_port_t *p, int *state); extern HAMLIB_EXPORT(int) ser_get_dtr(hamlib_port_t *p, int *state);
extern HAMLIB_EXPORT(int) ser_get_cts(hamlib_port_t *p, int *state); extern HAMLIB_EXPORT(int) ser_get_cts(hamlib_port_t *p, int *state);

Wyświetl plik

@ -1028,8 +1028,9 @@ HAMLIB_EXPORT(int) rig_settings_get_path(char *path, int pathlen)
#endif #endif
#endif #endif
char *xdgpath = getenv("XDG_CONFIG_HOME"); const char *xdgpath = getenv("XDG_CONFIG_HOME");
char *home = getenv("HOME"); char *home = getenv("HOME");
if (home == NULL) home = "?HOME";
snprintf(path, pathlen, "%s/.config", home); snprintf(path, pathlen, "%s/.config", home);
if (xdgpath) if (xdgpath)
@ -1062,7 +1063,7 @@ HAMLIB_EXPORT(int) rig_settings_get_path(char *path, int pathlen)
* *
* \sa rig_setting_load() * \sa rig_setting_load()
*/ */
HAMLIB_EXPORT(int) rig_settings_save(char *setting, void *value, HAMLIB_EXPORT(int) rig_settings_save(const char *setting, void *value,
settings_value_t valuetype) settings_value_t valuetype)
{ {
FILE *fp; FILE *fp;
@ -1218,8 +1219,8 @@ HAMLIB_EXPORT(int) rig_settings_load_all(char *settings_file)
while (fgets(buf, sizeof(buf), fp)) while (fgets(buf, sizeof(buf), fp))
{ {
char *s = strtok(buf, "="); const char *s = strtok(buf, "=");
char *v = strtok(NULL, "\r\n"); const char *v = strtok(NULL, "\r\n");
if (strcmp(s, "sharedkey") == 0) if (strcmp(s, "sharedkey") == 0)
{ {

Wyświetl plik

@ -45,7 +45,7 @@ int check_buffer_overflow(char *str, int len, int nlen)
if (len + 32 >= nlen) // make sure at least 32 bytes are available if (len + 32 >= nlen) // make sure at least 32 bytes are available
{ {
rig_debug(RIG_DEBUG_ERR, rig_debug(RIG_DEBUG_ERR,
"%s: buffer overflow, len=%u, nlen=%d, str='%s', len+32 must be >= nlen\n", "%s: buffer overflow, len=%d, nlen=%d, str='%s', len+32 must be >= nlen\n",
__func__, len, nlen, str); __func__, len, nlen, str);
} }
@ -931,7 +931,7 @@ int rig_sprintf_agc_levels(RIG *rig, char *str, int lenstr)
{ {
for (i = 0; i <= HAMLIB_MAX_AGC_LEVELS for (i = 0; i <= HAMLIB_MAX_AGC_LEVELS
&& priv_caps->agc_levels[i].level != RIG_AGC_LAST && priv_caps->agc_levels[i].level != RIG_AGC_LAST
&& priv_caps->agc_levels[i].icom_level >= 0; i++) ;i++)
{ {
if (strlen(str) > 0) { strcat(str, " "); } if (strlen(str) > 0) { strcat(str, " "); }

Wyświetl plik

@ -33,7 +33,7 @@
* external prototype * external prototype
*/ */
int dumpcaps_amp(AMP *, FILE *); int dumpcaps_amp(const AMP *, FILE *);
/* /*

Wyświetl plik

@ -20,7 +20,7 @@
#include "misc.h" #include "misc.h"
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
RIG *my_rig; RIG *my_rig;
char *rig_file, *info_buf; char *rig_file, *info_buf;

Wyświetl plik

@ -302,8 +302,7 @@ int dumpcaps(RIG *rig, FILE *fout)
if (priv_caps && RIG_BACKEND_NUM(rig->caps->rig_model) == RIG_ICOM if (priv_caps && RIG_BACKEND_NUM(rig->caps->rig_model) == RIG_ICOM
&& priv_caps->agc_levels_present) && priv_caps->agc_levels_present)
{ {
for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST ; i++)
&& priv_caps->agc_levels[i].icom_level >= 0; i++)
{ {
fprintf(fout, " %d=%s", priv_caps->agc_levels[i].level, fprintf(fout, " %d=%s", priv_caps->agc_levels[i].level,
rig_stragclevel(priv_caps->agc_levels[i].level)); rig_stragclevel(priv_caps->agc_levels[i].level));

Wyświetl plik

@ -31,7 +31,7 @@
/* /*
* the amp may be in amp_init state, but not opened * the amp may be in amp_init state, but not opened
*/ */
int dumpcaps_amp(AMP *amp, FILE *fout) int dumpcaps_amp(const AMP *amp, FILE *fout)
{ {
const struct amp_caps *caps; const struct amp_caps *caps;
int backend_warnings = 0; int backend_warnings = 0;

Wyświetl plik

@ -37,7 +37,7 @@ static char *decode_modes(rmode_t modes);
static int dump_chan(RIG *rig, int chan_num); static int dump_chan(RIG *rig, int chan_num);
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
RIG *my_rig; RIG *my_rig;
int status, i, j; int status, i, j;

Wyświetl plik

@ -302,8 +302,7 @@ int dumpstate(RIG *rig, FILE *fout)
if (priv_caps && RIG_BACKEND_NUM(rig->state.rig_model) == RIG_ICOM if (priv_caps && RIG_BACKEND_NUM(rig->state.rig_model) == RIG_ICOM
&& priv_caps->agc_levels_present) && priv_caps->agc_levels_present)
{ {
for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST; i++)
&& priv_caps->agc_levels[i].icom_level >= 0; i++)
{ {
fprintf(fout, " %d=%s", priv_caps->agc_levels[i].level, fprintf(fout, " %d=%s", priv_caps->agc_levels[i].level,
rig_stragclevel(priv_caps->agc_levels[i].level)); rig_stragclevel(priv_caps->agc_levels[i].level));

Wyświetl plik

@ -3,14 +3,13 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
char buf[4096]; char buf[4096];
char buf2[4096]; char buf2[4096];
FILE *fp = fopen(argv[1], "r"); FILE *fp = fopen(argv[1], "r");
int linenum = 0; int linenum = 0;
int enterfunc = 0; int enterfunc = 0;
int infunc = 0;
int retval = 0; int retval = 0;
retval = 0; retval = 0;

Wyświetl plik

@ -29,7 +29,7 @@
int print_caps_sum(const struct rig_caps *caps, void *data) int print_caps_sum(const struct rig_caps *caps, void *data)
{ {
char *fmt1 = "%-13s"; const char *fmt1 = "%-13s";
printf("%6u \t%-22s \t%-23s\t%-8s \t", printf("%6u \t%-22s \t%-23s\t%-8s \t",
caps->rig_model, caps->rig_model,
caps->mfg_name, caps->mfg_name,

Wyświetl plik

@ -61,7 +61,7 @@ static int tokenize_line(char *line,
size_t siz, size_t siz,
char delim); char delim);
static int find_on_list(char **list, char *what); static int find_on_list(char **list, const char *what);
int csv_save(RIG *rig, const char *outfilename); int csv_save(RIG *rig, const char *outfilename);
int csv_load(RIG *rig, const char *infilename); int csv_load(RIG *rig, const char *infilename);
@ -272,6 +272,7 @@ static char *mystrtok(char *s, char delim)
} }
else else
{ {
return NULL;
} }
if (str && str[ pos + 1 ] == '\0') if (str && str[ pos + 1 ] == '\0')
@ -1026,7 +1027,7 @@ int set_channel_data(RIG *rig,
\return string position on the list on success, \return string position on the list on success,
-1 if string not found or if string is empty -1 if string not found or if string is empty
*/ */
int find_on_list(char **list, char *what) int find_on_list(char **list, const char *what)
{ {
int i = 0; int i = 0;

Wyświetl plik

@ -142,13 +142,13 @@ int dump_xml_chan(RIG *rig,
if (mem_caps->vfo) if (mem_caps->vfo)
{ {
SNPRINTF(attrbuf, sizeof(attrbuf), "%d", chan.vfo); SNPRINTF(attrbuf, sizeof(attrbuf), "%u", chan.vfo);
xmlNewProp(node, (unsigned char *) "vfo", (unsigned char *) attrbuf); xmlNewProp(node, (unsigned char *) "vfo", (unsigned char *) attrbuf);
} }
if (mem_caps->ant && chan.ant != RIG_ANT_NONE) if (mem_caps->ant && chan.ant != RIG_ANT_NONE)
{ {
SNPRINTF(attrbuf, sizeof(attrbuf), "%d", chan.ant); SNPRINTF(attrbuf, sizeof(attrbuf), "%u", chan.ant);
xmlNewProp(node, (unsigned char *) "ant", (unsigned char *) attrbuf); xmlNewProp(node, (unsigned char *) "ant", (unsigned char *) attrbuf);
} }
@ -156,6 +156,7 @@ int dump_xml_chan(RIG *rig,
{ {
// cppcheck-suppress * // cppcheck-suppress *
char *fmt = "%"PRIll; char *fmt = "%"PRIll;
// cppcheck-suppress *
SNPRINTF(attrbuf, sizeof(attrbuf), fmt, (int64_t)chan.freq); SNPRINTF(attrbuf, sizeof(attrbuf), fmt, (int64_t)chan.freq);
xmlNewProp(node, (unsigned char *) "freq", (unsigned char *) attrbuf); xmlNewProp(node, (unsigned char *) "freq", (unsigned char *) attrbuf);
} }
@ -245,25 +246,25 @@ int dump_xml_chan(RIG *rig,
if (mem_caps->ctcss_tone && chan.ctcss_tone != 0) if (mem_caps->ctcss_tone && chan.ctcss_tone != 0)
{ {
SNPRINTF(attrbuf, sizeof(attrbuf), "%d", chan.ctcss_tone); SNPRINTF(attrbuf, sizeof(attrbuf), "%u", chan.ctcss_tone);
xmlNewProp(node, (unsigned char *) "ctcss_tone", (unsigned char *) attrbuf); xmlNewProp(node, (unsigned char *) "ctcss_tone", (unsigned char *) attrbuf);
} }
if (mem_caps->ctcss_sql && chan.ctcss_sql != 0) if (mem_caps->ctcss_sql && chan.ctcss_sql != 0)
{ {
SNPRINTF(attrbuf, sizeof(attrbuf), "%d", chan.ctcss_sql); SNPRINTF(attrbuf, sizeof(attrbuf), "%u", chan.ctcss_sql);
xmlNewProp(node, (unsigned char *) "ctcss_sql", (unsigned char *) attrbuf); xmlNewProp(node, (unsigned char *) "ctcss_sql", (unsigned char *) attrbuf);
} }
if (mem_caps->dcs_code && chan.dcs_code != 0) if (mem_caps->dcs_code && chan.dcs_code != 0)
{ {
SNPRINTF(attrbuf, sizeof(attrbuf), "%d", chan.dcs_code); SNPRINTF(attrbuf, sizeof(attrbuf), "%u", chan.dcs_code);
xmlNewProp(node, (unsigned char *) "dcs_code", (unsigned char *) attrbuf); xmlNewProp(node, (unsigned char *) "dcs_code", (unsigned char *) attrbuf);
} }
if (mem_caps->dcs_sql && chan.dcs_sql != 0) if (mem_caps->dcs_sql && chan.dcs_sql != 0)
{ {
SNPRINTF(attrbuf, sizeof(attrbuf), "%d", chan.dcs_sql); SNPRINTF(attrbuf, sizeof(attrbuf), "%u", chan.dcs_sql);
xmlNewProp(node, (unsigned char *) "dcs_sql", (unsigned char *) attrbuf); xmlNewProp(node, (unsigned char *) "dcs_sql", (unsigned char *) attrbuf);
} }

Wyświetl plik

@ -15,7 +15,7 @@
#define SERIAL_PORT "/dev/ttyUSB0" #define SERIAL_PORT "/dev/ttyUSB0"
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
RIG *my_rig; /* handle to rig (nstance) */ RIG *my_rig; /* handle to rig (nstance) */
int retcode; /* generic return code from functions */ int retcode; /* generic return code from functions */

Wyświetl plik

@ -1942,7 +1942,7 @@ int print_conf_list(const struct confparams *cfp, rig_ptr_t data)
switch (cfp->type) switch (cfp->type)
{ {
case RIG_CONF_INT: case RIG_CONF_INT:
printf("\tRange: %d..%d, step %d\n", printf("\tRange: %.0f..%.0f, step %.0f\n",
cfp->u.n.min, cfp->u.n.min,
cfp->u.n.max, cfp->u.n.max,
cfp->u.n.step); cfp->u.n.step);
@ -3315,6 +3315,10 @@ declare_proto_rig(set_level)
CHKSCN1ARG(sscanf(arg2, "%d", &val.i)); CHKSCN1ARG(sscanf(arg2, "%d", &val.i));
break; break;
case RIG_CONF_INT:
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
break;
case RIG_CONF_NUMERIC: case RIG_CONF_NUMERIC:
CHKSCN1ARG(sscanf(arg2, "%f", &val.f)); CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
break; break;
@ -3426,7 +3430,7 @@ declare_proto_rig(get_level)
break; break;
case RIG_CONF_INT: case RIG_CONF_INT:
fprintf(fout, "%d%c", val.i, resp_sep); fprintf(fout, "%.0f%c", val.f, resp_sep);
break; break;
case RIG_CONF_STRING: case RIG_CONF_STRING:
@ -3653,6 +3657,10 @@ declare_proto_rig(set_parm)
CHKSCN1ARG(sscanf(arg2, "%d", &val.i)); CHKSCN1ARG(sscanf(arg2, "%d", &val.i));
break; break;
case RIG_CONF_INT:
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
break;
case RIG_CONF_NUMERIC: case RIG_CONF_NUMERIC:
CHKSCN1ARG(sscanf(arg2, "%f", &val.f)); CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
break; break;
@ -3767,6 +3775,10 @@ declare_proto_rig(get_parm)
fprintf(fout, "%d%c", val.i, resp_sep); fprintf(fout, "%d%c", val.i, resp_sep);
break; break;
case RIG_CONF_INT:
fprintf(fout, "%.0f%c", val.f, resp_sep);
break;
case RIG_CONF_NUMERIC: case RIG_CONF_NUMERIC:
fprintf(fout, "%f%c", val.f, resp_sep); fprintf(fout, "%f%c", val.f, resp_sep);
break; break;
@ -4458,6 +4470,10 @@ int dump_chan(FILE *fout, RIG *rig, channel_t *chan)
SNPRINTF(lstr, sizeof(lstr), "%d", chan->ext_levels[idx].val.i); SNPRINTF(lstr, sizeof(lstr), "%d", chan->ext_levels[idx].val.i);
break; break;
case RIG_CONF_INT:
SNPRINTF(lstr, sizeof(lstr), "%.0f", chan->ext_levels[idx].val.f);
break;
case RIG_CONF_NUMERIC: case RIG_CONF_NUMERIC:
SNPRINTF(lstr, sizeof(lstr), "%f", chan->ext_levels[idx].val.f); SNPRINTF(lstr, sizeof(lstr), "%f", chan->ext_levels[idx].val.f);
break; break;

Wyświetl plik

@ -801,7 +801,7 @@ int main(int argc, char *argv[])
if (verbose > RIG_DEBUG_ERR) if (verbose > RIG_DEBUG_ERR)
{ {
printf("Closed rig model %d, '%s - will reopen for clients'\n", printf("Closed rig model %u, '%s - will reopen for clients'\n",
my_rig->caps->rig_model, my_rig->caps->rig_model,
my_rig->caps->model_name); my_rig->caps->model_name);
} }
@ -1048,7 +1048,7 @@ int main(int argc, char *argv[])
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s: ignoring interrupted system call\n", rig_debug(RIG_DEBUG_VERBOSE, "%s: ignoring interrupted system call\n",
__func__); __func__);
retcode = 0; //retcode = 0; // not used?
} }
} }
else if (retcode == 0) else if (retcode == 0)
@ -1336,7 +1336,7 @@ void *handle_socket(void *arg)
#ifdef HAVE_PTHREAD #ifdef HAVE_PTHREAD
--client_count; --client_count;
if (rigctld_idle && client_count > 0) { printf("%d client%s still connected so rig remains open\n", client_count, client_count > 1 ? "s" : ""); } if (rigctld_idle && client_count > 0) { printf("%u client%s still connected so rig remains open\n", client_count, client_count > 1 ? "s" : ""); }
#if 0 #if 0
mutex_rigctld(1); mutex_rigctld(1);

Wyświetl plik

@ -629,7 +629,7 @@ int main(int argc, char *argv[])
if (verbose > 0) if (verbose > 0)
{ {
printf("Opened rig model %d, '%s'\n", printf("Opened rig model %u, '%s'\n",
my_rig->caps->rig_model, my_rig->caps->rig_model,
my_rig->caps->model_name); my_rig->caps->model_name);
} }
@ -651,12 +651,6 @@ int main(int argc, char *argv[])
rigerror(retcode)); rigerror(retcode));
} }
if (retcode != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: Error in rig_set_freq: %s\n", __func__,
rigerror(retcode));
}
retcode = rig_set_freq(my_rig_sync, RIG_VFO_CURR, freq); retcode = rig_set_freq(my_rig_sync, RIG_VFO_CURR, freq);
hl_usleep(400 * 1000); // fairly fast to keep up hl_usleep(400 * 1000); // fairly fast to keep up
@ -671,7 +665,7 @@ int main(int argc, char *argv[])
void usage() void usage()
{ {
char *name = "rigctlsync"; const char *name = "rigctlsync";
printf("Usage: %s -m rignumber -r comport -s baud -M rignumber -R comport [OPTIONS]...\n\n" printf("Usage: %s -m rignumber -r comport -s baud -M rignumber -R comport [OPTIONS]...\n\n"
"Will copy frequency from -m rig to -M rig\n" "Will copy frequency from -m rig to -M rig\n"
"e.g. will keep SDR# synchronized to a rig.\n\n", "e.g. will keep SDR# synchronized to a rig.\n\n",

Wyświetl plik

@ -787,7 +787,7 @@ int main(int argc, char *argv[])
if (verbose > RIG_DEBUG_ERR) if (verbose > RIG_DEBUG_ERR)
{ {
printf("Closed rig model %d, '%s - will reopen for clients'\n", printf("Closed rig model %u, '%s - will reopen for clients'\n",
my_rig->caps->rig_model, my_rig->caps->rig_model,
my_rig->caps->model_name); my_rig->caps->model_name);
} }
@ -1034,7 +1034,7 @@ int main(int argc, char *argv[])
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s: ignoring interrupted system call\n", rig_debug(RIG_DEBUG_VERBOSE, "%s: ignoring interrupted system call\n",
__func__); __func__);
retcode = 0; //retcode = 0; // not used?
} }
} }
else if (retcode == 0) else if (retcode == 0)
@ -1244,7 +1244,7 @@ void *handle_socket(void *arg)
mutex_rigctld(0); mutex_rigctld(0);
int nbytes = -1; int nbytes;
if (rig_opened) // only do this if rig is open if (rig_opened) // only do this if rig is open
{ {
@ -1426,7 +1426,7 @@ client_done:
#ifdef HAVE_PTHREAD #ifdef HAVE_PTHREAD
--client_count; --client_count;
if (rigctld_idle && client_count > 0) { printf("%d client%s still connected so rig remains open\n", client_count, client_count > 1 ? "s" : ""); } if (rigctld_idle && client_count > 0) { printf("%u client%s still connected so rig remains open\n", client_count, client_count > 1 ? "s" : ""); }
#if 0 #if 0
mutex_rigctld(1); mutex_rigctld(1);

Wyświetl plik

@ -17,7 +17,7 @@ double history[HISTORYSIZE];
int nhistory; int nhistory;
int historyinit = 1; int historyinit = 1;
double compute_mean(double arr[], int length) double compute_mean(const double arr[], int length)
{ {
double sum = 0.0; double sum = 0.0;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
@ -37,7 +37,7 @@ double sigma(double arr[], int length) {
return sqrt(sum_of_squares / length); return sqrt(sum_of_squares / length);
} }
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
RIG *my_rig; /* handle to rig (nstance) */ RIG *my_rig; /* handle to rig (nstance) */
int strength; /* S-Meter level */ int strength; /* S-Meter level */
@ -62,16 +62,16 @@ int main(int argc, char *argv[])
* allocate memory, setup & open port * allocate memory, setup & open port
*/ */
hamlib_port_t myport; // hamlib_port_t myport;
myrig_model = atoi(argv[1]); myrig_model = atoi(argv[1]);
strncpy(myport.pathname, argv[2], HAMLIB_FILPATHLEN - 1); // strncpy(myport.pathname, argv[2], HAMLIB_FILPATHLEN - 1);
myport.parm.serial.rate = atoi(argv[3]); // myport.parm.serial.rate = atoi(argv[3]);
my_rig = rig_init(myrig_model); my_rig = rig_init(myrig_model);
if (!my_rig) if (!my_rig)
{ {
fprintf(stderr, "Unknown rig num: %d\n", myrig_model); fprintf(stderr, "Unknown rig num: %u\n", myrig_model);
fprintf(stderr, "Please check riglist.h\n"); fprintf(stderr, "Please check riglist.h\n");
exit(1); /* whoops! something went wrong (mem alloc?) */ exit(1); /* whoops! something went wrong (mem alloc?) */
} }

Wyświetl plik

@ -98,7 +98,7 @@ static void print_altsetting(const struct libusb_interface_descriptor
} }
} }
static void print_2_0_ext_cap(struct libusb_usb_2_0_extension_descriptor static void print_2_0_ext_cap(const struct libusb_usb_2_0_extension_descriptor
*usb_2_0_ext_cap) *usb_2_0_ext_cap)
{ {
printf(" USB 2.0 Extension Capabilities:\n"); printf(" USB 2.0 Extension Capabilities:\n");
@ -107,7 +107,7 @@ static void print_2_0_ext_cap(struct libusb_usb_2_0_extension_descriptor
printf(" bmAttributes: %08xh\n", usb_2_0_ext_cap->bmAttributes); printf(" bmAttributes: %08xh\n", usb_2_0_ext_cap->bmAttributes);
} }
static void print_ss_usb_cap(struct libusb_ss_usb_device_capability_descriptor static void print_ss_usb_cap(const struct libusb_ss_usb_device_capability_descriptor
*ss_usb_cap) *ss_usb_cap)
{ {
printf(" USB 3.0 Capabilities:\n"); printf(" USB 3.0 Capabilities:\n");
@ -355,11 +355,10 @@ static int test_wrapped_device(const char *device_name)
} }
#endif #endif
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
const char *device_name = NULL; const char *device_name = NULL;
libusb_device **devs; libusb_device **devs;
ssize_t cnt;
int r, i; int r, i;
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
@ -394,6 +393,7 @@ int main(int argc, char *argv[])
} }
else else
{ {
ssize_t cnt;
cnt = libusb_get_device_list(NULL, &devs); cnt = libusb_get_device_list(NULL, &devs);
if (cnt < 0) if (cnt < 0)

Wyświetl plik

@ -3,7 +3,7 @@
#define TEST #define TEST
#ifdef TEST #ifdef TEST
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
RIG *rig; RIG *rig;
rig_model_t myrig_model; rig_model_t myrig_model;

Wyświetl plik

@ -108,6 +108,8 @@ static struct option long_options[] =
/* variable for readline support */ /* variable for readline support */
#ifdef HAVE_LIBREADLINE #ifdef HAVE_LIBREADLINE
static const int have_rl = 1; static const int have_rl = 1;
#else
static const int have_rl = 0;
#endif #endif
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -357,9 +359,9 @@ int main(int argc, char *argv[])
/* FIXME: bound checking and port type == serial */ /* FIXME: bound checking and port type == serial */
my_rot->state.rotport2.parm.serial.rate = my_rot->state.rotport2.parm.serial.rate =
my_rot->state.rotport2.parm.serial.rate; my_rot->state.rotport.parm.serial.rate;
my_rot->state.rotport2.parm.serial.data_bits = my_rot->state.rotport2.parm.serial.data_bits =
my_rot->state.rotport2.parm.serial.data_bits; my_rot->state.rotport.parm.serial.data_bits;
if (serial_rate != 0) if (serial_rate != 0)
{ {

Wyświetl plik

@ -308,7 +308,7 @@ void hash_add_model(int id,
/* Hash sorting functions */ /* Hash sorting functions */
int hash_model_id_sort(struct mod_lst *a, struct mod_lst *b) int hash_model_id_sort(const struct mod_lst *a, const struct mod_lst *b)
{ {
return (a->id > b->id); return (a->id > b->id);
} }
@ -431,7 +431,7 @@ static int scanfc(FILE *fin, const char *format, void *p)
* returns <0 is error number * returns <0 is error number
* returns >=0 when successful * returns >=0 when successful
*/ */
static int next_word(char *buffer, int argc, char *argv[], int newline) static int next_word(char *buffer, int argc, const char **argv, int newline)
{ {
int ret; int ret;
char c; char c;
@ -526,7 +526,7 @@ static int next_word(char *buffer, int argc, char *argv[], int newline)
}) })
int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc, int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, const char *argv[], int argc,
int interactive, int prompt, char send_cmd_term) int interactive, int prompt, char send_cmd_term)
{ {
int retcode; /* generic return code from functions */ int retcode; /* generic return code from functions */
@ -1528,32 +1528,29 @@ void usage_rot(FILE *fout)
for (i = 0; test_list[i].cmd != 0; i++) for (i = 0; test_list[i].cmd != 0; i++)
{ {
int nbspaces;
fprintf(fout, fprintf(fout,
"%c: %-12s(", "%c: %-12s(",
isprint(test_list[i].cmd) ? test_list[i].cmd : '?', isprint(test_list[i].cmd) ? test_list[i].cmd : '?',
test_list[i].name); test_list[i].name);
nbspaces = 16;
if (test_list[i].arg1 && (test_list[i].flags & ARG_IN1)) if (test_list[i].arg1 && (test_list[i].flags & ARG_IN1))
{ {
nbspaces -= fprintf(fout, "%s", test_list[i].arg1); fprintf(fout, "%s", test_list[i].arg1);
} }
if (test_list[i].arg2 && (test_list[i].flags & ARG_IN2)) if (test_list[i].arg2 && (test_list[i].flags & ARG_IN2))
{ {
nbspaces -= fprintf(fout, ", %s", test_list[i].arg2); fprintf(fout, ", %s", test_list[i].arg2);
} }
if (test_list[i].arg3 && (test_list[i].flags & ARG_IN3)) if (test_list[i].arg3 && (test_list[i].flags & ARG_IN3))
{ {
nbspaces -= fprintf(fout, ", %s", test_list[i].arg3); fprintf(fout, ", %s", test_list[i].arg3);
} }
if (test_list[i].arg4 && (test_list[i].flags & ARG_IN4)) if (test_list[i].arg4 && (test_list[i].flags & ARG_IN4))
{ {
nbspaces -= fprintf(fout, ", %s", test_list[i].arg4); fprintf(fout, ", %s", test_list[i].arg4);
} }
fprintf(fout, ")\n"); fprintf(fout, ")\n");
@ -1671,14 +1668,13 @@ void list_models()
int set_conf(ROT *my_rot, char *conf_parms) int set_conf(ROT *my_rot, char *conf_parms)
{ {
char *p; char *p;
int token;
rot_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); rot_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
p = conf_parms; p = conf_parms;
while (p && *p != '\0') while (p && *p != '\0')
{ {
int ret; int token;
char *q, *n = NULL; char *q, *n = NULL;
/* FIXME: left hand value of = cannot be null */ /* FIXME: left hand value of = cannot be null */
q = strchr(p, '='); q = strchr(p, '=');
@ -1700,6 +1696,7 @@ int set_conf(ROT *my_rot, char *conf_parms)
if (token != 0) if (token != 0)
{ {
int ret;
ret = rot_set_conf(my_rot, token, q); ret = rot_set_conf(my_rot, token, q);
if (ret != RIG_OK) if (ret != RIG_OK)

Wyświetl plik

@ -44,7 +44,7 @@ void list_models();
int print_conf_list(const struct confparams *cfp, rig_ptr_t data); int print_conf_list(const struct confparams *cfp, rig_ptr_t data);
int set_conf(ROT *my_rot, char *conf_parms); int set_conf(ROT *my_rot, char *conf_parms);
int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc, int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, const char **argv, int argc,
int interactive, int prompt, char send_cmd_term); int interactive, int prompt, char send_cmd_term);
#endif /* ROTCTL_PARSE_H */ #endif /* ROTCTL_PARSE_H */

Wyświetl plik

@ -7,7 +7,7 @@ int
main() main()
{ {
RIG *my_rig; RIG *my_rig;
unsigned char sendCmd[] = "FA;"; const unsigned char sendCmd[] = "FA;";
int sendCmdLen = 3; int sendCmdLen = 3;
unsigned char term[] = ";"; unsigned char term[] = ";";
unsigned char rcvdCmd[100]; unsigned char rcvdCmd[100];

Wyświetl plik

@ -37,7 +37,7 @@ int main(int argc, char *argv[])
char vfo[16]; char vfo[16];
char mode[16]; char mode[16];
double freq; double freq;
sscanf(riginfo, "VFO=%s Freq=%lf Mode=%s", vfo, &freq, mode); sscanf(riginfo, "VFO=%16s Freq=%lf Mode=%16s", vfo, &freq, mode);
printf("VFO=%s Freq=%.0f Mode=%s\n", vfo, freq, mode); printf("VFO=%s Freq=%.0f Mode=%s\n", vfo, freq, mode);
printf("=========================\nEntire response:\n%s", riginfo); printf("=========================\nEntire response:\n%s", riginfo);
rig_close(rig); rig_close(rig);

Wyświetl plik

@ -72,6 +72,12 @@ int main(int argc, char *argv[])
vfo_t vfo; vfo_t vfo;
retcode = rig_get_vfo(my_rig, &vfo); retcode = rig_get_vfo(my_rig, &vfo);
if (retcode != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: rig_get_vfo: %s\n", __func__, rigerror(retcode));
return retcode;
}
if (vfo != RIG_VFO_A) if (vfo != RIG_VFO_A)
{ {

Wyświetl plik

@ -96,7 +96,7 @@ static int test3_invalid_input()
{ {
retcode = rig_cookie(NULL, RIG_COOKIE_GET, cookie, i); retcode = rig_cookie(NULL, RIG_COOKIE_GET, cookie, i);
if (retcode != -RIG_EINVAL) { n++; printf("Test#3a failed at %d bytes\n", i); } if (retcode != -RIG_EINVAL) { n++; printf("Test#3a failed at %u bytes\n", i); }
} }
if (n == 0) { printf("Test#3a OK\n"); } if (n == 0) { printf("Test#3a OK\n"); }

Wyświetl plik

@ -52,7 +52,7 @@ int callback(const struct rig_caps *caps, rig_ptr_t rigp)
if (fpow < 0.009 || fpow > .11) if (fpow < 0.009 || fpow > .11)
{ {
// printf("rig=%d, fpow=%g, min=%d, max=%d\n", caps->rig_model, fpow, caps->); // printf("rig=%d, fpow=%g, min=%d, max=%d\n", caps->rig_model, fpow, caps->);
printf("rig=%d, fpow=%g\n", caps->rig_model, fpow); printf("rig=%u, fpow=%g\n", caps->rig_model, fpow);
// we call again to make debugging this section easier // we call again to make debugging this section easier
rig_mW2power(rig, &fpow, mwpower, freq, RIG_MODE_CW); rig_mW2power(rig, &fpow, mwpower, freq, RIG_MODE_CW);
} }

Wyświetl plik

@ -29,7 +29,7 @@ int callback(const struct rig_caps *caps, rig_ptr_t rigp)
exit(1); /* whoops! something went wrong (mem alloc?) */ exit(1); /* whoops! something went wrong (mem alloc?) */
} }
char *port = "/dev/pts/3"; const char *port = "/dev/pts/3";
strcpy(rig->state.rigport.pathname, port); strcpy(rig->state.rigport.pathname, port);
printf("%20s:", caps->model_name); printf("%20s:", caps->model_name);

Wyświetl plik

@ -34,7 +34,7 @@
static struct tm *gmtime_r(const time_t *t, struct tm *r) static struct tm *gmtime_r(const time_t *t, struct tm *r)
{ {
// gmtime is threadsafe in windows because it uses TLS // gmtime is threadsafe in windows because it uses TLS
struct tm *theTm = gmtime(t); const struct tm *theTm = gmtime(t);
if (theTm) if (theTm)
{ {
@ -67,7 +67,7 @@ static int my_rand(int max)
void rig_make_key(char key[33]) void rig_make_key(char key[33])
{ {
char *all = const char *all =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123467890!@#$%^&*()_=~<>/?"; "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123467890!@#$%^&*()_=~<>/?";
int max = strlen(all); int max = strlen(all);
int i; int i;

Wyświetl plik

@ -25,7 +25,7 @@ int myfreq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg)
} }
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
RIG *my_rig; /* handle to rig (nstance) */ RIG *my_rig; /* handle to rig (nstance) */
int retcode; /* generic return code from functions */ int retcode; /* generic return code from functions */