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_strparm(setting_t);
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(value_t) rig_valueagclevel (enum agc_level_e agcLevel);
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;
f = '1';
}
// cppcheck-suppress knownConditionTrueFalse
else if ((flt->filt_list[1].width >= 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_bw = "BW";
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));
@ -1537,7 +1537,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
char kmode;
int err;
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__);
@ -1813,7 +1813,7 @@ static int k3_get_maxpower(RIG *rig)
//int retval;
int maxpower = 15; // K3 default power level
//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
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 lvl;
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__);

Wyświetl plik

@ -1046,7 +1046,6 @@ int kenwood_open(RIG *rig)
if (kenwood_id_string_list[i].model == rig->caps->rig_model)
{
int retval;
vfo_t tx_vfo;
rig_debug(RIG_DEBUG_VERBOSE, "%s: found the right driver for %s(%u)\n",
__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)
{
int retval;
// call get_split to fill in current split and tx_vfo status
split_t split;
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);
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
@ -3824,6 +3829,7 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_MICGAIN:
{
int micgain_now;
float vali = 0;
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__);
RETURNFUNC(ret);
}
val->f = (val->i - priv->micgain_min) / (float)(priv->micgain_max -
vali = val->i;
val->f = (vali - priv->micgain_min) / (float)(priv->micgain_max -
priv->micgain_min);
RETURNFUNC(RIG_OK);
}
@ -5908,7 +5914,7 @@ const char *kenwood_get_info(RIG *rig)
*/
DECLARE_PROBERIG_BACKEND(kenwood)
{
char idbuf[IDBUFSZ];
char idbuf[IDBUFSZ] = "";
int id_len = -1, i, k_id;
int retval = -1;
int rates[] = { 115200, 57600, 38400, 19200, 9600, 4800, 1200, 0 }; /* possible baud rates */

Wyświetl plik

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

Wyświetl plik

@ -99,7 +99,7 @@ const struct rig_caps pihpsdr_caps =
RIG_MODEL(RIG_MODEL_HPSDR),
.model_name = "PiHPSDR",
.mfg_name = "OpenHPSDR",
.version = BACKEND_VER ".1",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.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;
case RIG_LEVEL_AGC:
if (kenwood_val == RIG_AGC_OFF) { kenwood_val = 0; }
else if (kenwood_val == RIG_AGC_SUPERFAST) { kenwood_val = 5; }
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_MEDIUM) { kenwood_val = 15; }
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);
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)
{
struct kenwood_priv_data *priv = rig->state.priv;
const struct kenwood_priv_data *priv = rig->state.priv;
char cmd[16];
int vfonum, txvfonum, vfomode = 0;
int retval;

Wyświetl plik

@ -192,7 +192,7 @@ static int thd72_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
char vfobuf[16];
struct kenwood_priv_data *priv = rig->state.priv;
const struct kenwood_priv_data *priv = rig->state.priv;
char vfonum = '0';
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,
"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->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->ct, (unsigned int*)&me_struct->dcs,
&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;
}
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 buf[80];
@ -902,7 +902,7 @@ int tmd710_get_memory_name(RIG *rig, int ch, char *name)
return retval;
}
retval = num_sscanf(buf, "MN %d,%s", &ch, name);
retval = num_sscanf(buf, "MN %d,%30s", &ch, name);
if (retval != 2)
{
@ -1240,7 +1240,7 @@ int tmd710_do_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
tmd710_fo fo_struct;
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);
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)
{
tone_t *dcs_list = common_dcs_list;
const tone_t *dcs_list = common_dcs_list;
*code = dcs_list[fo_struct.dcs_val];
}
else
@ -1474,7 +1474,7 @@ static int tmd710_find_dcs_index(tone_t code, int *dcs_index)
int i = 0;
// 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])
{
@ -2206,7 +2206,7 @@ int tmd710_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
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];
}
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)
{
char ackbuf[20];
int retval;
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:
{
int value;
char ackbuf[20];
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); }
retval = RIG_OK;
if (!sf_fails)
{
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");
sscanf(cmd, "SH%d", &lwidth);
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
|| *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)
{
struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
const struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
rig->state.priv;
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,
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;
*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)
{
struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
const struct elektor507_priv_data *priv = (struct elektor507_priv_data *)
rig->state.priv;
int P0, R40, R41, R42;
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)
{
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;
int ret;
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)
{
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;
int ret;
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)
{
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,
"%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)
{
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;
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)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called. level type =%"PRIll"\n", __func__,
level);
rig_debug(RIG_DEBUG_VERBOSE, "%s called. level type =%"PRIll"\n", __func__, level);
char cmdstr[15];
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)
{
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv;
struct solution sols[8];
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)
{
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv;
libusb_device_handle *udh = rig->state.rigport.handle;
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)
{
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv;
libusb_device_handle *udh = rig->state.rigport.handle;
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)
{
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv;
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)
{
struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
const struct si570xxxusb_priv_data *priv = (struct si570xxxusb_priv_data *)
rig->state.priv;
libusb_device_handle *udh = rig->state.rigport.handle;
int ret;

Wyświetl plik

@ -45,7 +45,7 @@ struct usrp_priv_data {
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) {
/* whoops! memory shortage! */
return -RIG_ENOMEM;
@ -68,7 +68,7 @@ int usrp_cleanup(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 decim = 125;
@ -82,7 +82,7 @@ int usrp_open(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;
@ -94,7 +94,7 @@ int usrp_close(RIG *rig)
*/
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) {
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)
{
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) {
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)
{
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;
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)
{
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;
*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];
int freq_len, retval;
float f_freq;
double f_freq;
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';
sscanf(freqbuf + 1, "%f", &f_freq);
sscanf(freqbuf + 1, "%lf", &f_freq);
*freq = f_freq * 1000;
return retval;

Wyświetl plik

@ -557,6 +557,10 @@ int mds_open(RIG *rig)
ENTERFUNC;
mds_get_info(rig);
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);
}

Wyświetl plik

@ -18,7 +18,7 @@
14 - PTT +5V
*/
void serial_num(char *s)
void serial_num(const char *s)
{
char model[16];
char *operation;
@ -28,6 +28,8 @@ void serial_num(char *s)
char *diagnostics;
char *agency;
*rxfreq = 0;
*txfreq = 0;
memcpy(model, s, 5);
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;
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;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
@ -713,7 +713,7 @@ pcr_set_vfo(RIG *rig, vfo_t vfo)
int
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;
return RIG_OK;
@ -782,7 +782,7 @@ int
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_rcvr *rcvr = is_sub_rcvr(rig,
const struct pcr_rcvr *rcvr = is_sub_rcvr(rig,
vfo) ? &priv->sub_rcvr : &priv->main_rcvr;
*freq = rcvr->last_freq;
@ -1101,7 +1101,7 @@ pcr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
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);
}
@ -1168,7 +1168,7 @@ pcr_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
int err;
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;
// 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)
{
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;
rig_debug(RIG_DEBUG_VERBOSE, "%s: status = %d, func = %s\n", __func__,
@ -1399,7 +1399,7 @@ pcr_check_ok(RIG *rig)
static int
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 ||
(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)
{
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;
*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,
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)
{
@ -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]);
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)
{
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;
*tone = rcvr->last_dcs_sql;
@ -1913,7 +1913,7 @@ int pcr_decode_event(RIG *rig)
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)
{
@ -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)
{
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;
if (priv->auto_update == 0)

Wyświetl plik

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

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
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
#if 0
struct ip_mreq
{
int dummy;
};
#endif
#include <stdio.h>
#include <stdlib.h>
@ -22,6 +24,7 @@ struct ip_mreq
#include "../src/misc.h"
#include <termios.h>
#include <unistd.h>
#include "sim.h"
#define BUFSIZE 256
@ -53,25 +56,7 @@ int keyspd = 25;
int datamode = 0;
int filter = 0;
#define write(f,b,l) write_sim(f,b,l,__func__,__LINE__)
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)
void dumphex(const unsigned char *buf, int n)
{
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
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
#if 0
struct ip_mreq
{
int dummy;
};
#endif
#include <hamlib/rig.h>
#include <stdio.h>
#include <stdlib.h>
@ -18,11 +20,11 @@ struct ip_mreq
#include <errno.h>
#include <sys/time.h>
#include "../src/misc.h"
#include "../src/multicast.h"
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include "sim.h"
#define BUFSIZE 256
//#define X25
@ -48,7 +50,7 @@ int agc_time = 1;
int ovf_status = 0;
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]); }
@ -130,7 +132,7 @@ void frameParse(int fd, unsigned char *frame, int len)
if (powerstat)
{
n = write(fd, frame, 11);
write(fd, frame, 11);
}
break;
@ -150,7 +152,7 @@ void frameParse(int fd, unsigned char *frame, int len)
}
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x05:
@ -162,7 +164,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x06:
@ -171,7 +173,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x07:
@ -191,7 +193,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x0f:
@ -203,14 +205,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{
printf("get split %d\n", 1);
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
else
{
printf("set split %d\n", 1);
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
}
break;
@ -233,7 +235,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = 0xfd;
printf("write 8 bytes\n");
dump_hex(frame, 8);
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x14:
@ -247,7 +249,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = 0xfb;
dumphex(frame, 7);
n = write(fd, frame, 7);
write(fd, frame, 7);
printf("ACK x14 x08\n");
}
else
@ -255,7 +257,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)128, 2);
frame[8] = 0xfb;
dumphex(frame, 9);
n = write(fd, frame, 9);
write(fd, frame, 9);
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);
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
break;
}
@ -283,7 +285,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07:
frame[6] = ovf_status;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
ovf_status = ovf_status == 0 ? 1 : 0;
break;
@ -295,7 +297,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)meter_level, 2);
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
break;
}
@ -311,7 +313,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = satmode;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
break;
@ -322,13 +324,13 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x18: // miscellaneous things
frame[5] = 1;
frame[6] = 0xfd;
n = write(fd, frame, 7);
write(fd, frame, 7);
break;
case 0x19: // miscellaneous things
frame[5] = 0x94;
frame[6] = 0xfd;
n = write(fd, frame, 7);
write(fd, frame, 7);
break;
case 0x1a: // miscellaneous things
@ -339,7 +341,7 @@ void frameParse(int fd, unsigned char *frame, int len)
else { frame[6] = widthB; }
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x04: // AGC TIME
@ -349,7 +351,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = agc_time;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
else
{
@ -357,7 +359,7 @@ void frameParse(int fd, unsigned char *frame, int len)
agc_time = frame[6];
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
}
break;
@ -365,7 +367,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07: // satmode
frame[4] = 0;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
}
@ -380,14 +382,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = ptt;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
else
{
ptt = frame[6];
frame[7] = 0xfb;
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
}
break;
@ -427,8 +429,8 @@ void frameParse(int fd, unsigned char *frame, int len)
frame2[8] = 0x03;
frame2[9] = 0x00;
frame2[10] = 0xfd;
n = write(fd, frame2, 11);
n = write(fd, frame, 12);
write(fd, frame2, 11);
write(fd, frame, 12);
}
else
{
@ -440,7 +442,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
// send async frame
frame[2] = 0x00; // async freq
frame[3] = 0xa2;
@ -451,7 +453,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[8] = 0x96;
frame[9] = 0x12;
frame[10] = 0xfd;
n = write(fd, frame, 11);
write(fd, frame, 11);
}
break;
@ -467,7 +469,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
frame[8] = 0xfb;
frame[9] = 0xfd;
n = write(fd, frame, 10);
write(fd, frame, 10);
}
else
{
@ -486,7 +488,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
}
printf("\n");
@ -497,14 +499,14 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("x25 send nak\n");
frame[4] = 0xfa;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x26:
printf("x26 send nak\n");
frame[4] = 0xfa;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
#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
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
#if 0
struct ip_mreq
{
int dummy;
};
#endif
#include <stdio.h>
#include <stdlib.h>
@ -22,6 +24,7 @@ struct ip_mreq
#include "../src/misc.h"
#include <termios.h>
#include <unistd.h>
#include "sim.h"
#define BUFSIZE 256
@ -49,7 +52,7 @@ int agc_time = 1;
int ovf_status = 0;
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]); }
@ -131,7 +134,7 @@ void frameParse(int fd, unsigned char *frame, int len)
if (powerstat)
{
n = write(fd, frame, 11);
write(fd, frame, 11);
}
break;
@ -151,7 +154,7 @@ void frameParse(int fd, unsigned char *frame, int len)
}
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x05:
@ -163,7 +166,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x06:
@ -172,7 +175,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x07:
@ -192,7 +195,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x0f:
@ -204,14 +207,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{
printf("get split %d\n", 1);
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
else
{
printf("set split %d\n", 1);
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
}
break;
@ -234,7 +237,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = 0xfd;
printf("write 8 bytes\n");
dump_hex(frame, 8);
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x14:
@ -248,7 +251,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = 0xfb;
dumphex(frame, 7);
n = write(fd, frame, 7);
write(fd, frame, 7);
printf("ACK x14 x08\n");
}
else
@ -256,7 +259,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)128, 2);
frame[8] = 0xfb;
dumphex(frame, 9);
n = write(fd, frame, 9);
write(fd, frame, 9);
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);
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
break;
}
@ -284,7 +287,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07:
frame[6] = ovf_status;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
ovf_status = ovf_status == 0 ? 1 : 0;
break;
@ -296,7 +299,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)meter_level, 2);
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
break;
}
@ -312,7 +315,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = dualwatch;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
break;
@ -326,7 +329,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = satmode;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
break;
@ -337,13 +340,13 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x18: // miscellaneous things
frame[5] = 1;
frame[6] = 0xfd;
n = write(fd, frame, 7);
write(fd, frame, 7);
break;
case 0x19: // miscellaneous things
frame[5] = 0x94;
frame[6] = 0xfd;
n = write(fd, frame, 7);
write(fd, frame, 7);
break;
case 0x1a: // miscellaneous things
@ -354,7 +357,7 @@ void frameParse(int fd, unsigned char *frame, int len)
else { frame[6] = widthB; }
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x04: // AGC TIME
@ -364,7 +367,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = agc_time;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
else
{
@ -372,7 +375,7 @@ void frameParse(int fd, unsigned char *frame, int len)
agc_time = frame[6];
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
}
break;
@ -380,7 +383,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07: // satmode
frame[4] = 0;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
}
@ -395,14 +398,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = ptt;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
else
{
ptt = frame[6];
frame[7] = 0xfb;
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
}
break;
@ -442,8 +445,8 @@ void frameParse(int fd, unsigned char *frame, int len)
frame2[8] = 0x03;
frame2[9] = 0x00;
frame2[10] = 0xfd;
n = write(fd, frame2, 11);
n = write(fd, frame, 12);
write(fd, frame2, 11);
write(fd, frame, 12);
}
else
{
@ -455,7 +458,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
// send async frame
frame[2] = 0x00; // async freq
frame[3] = 0xa2;
@ -466,7 +469,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[8] = 0x96;
frame[9] = 0x12;
frame[10] = 0xfd;
n = write(fd, frame, 11);
write(fd, frame, 11);
}
break;
@ -482,7 +485,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
frame[8] = 0xfb;
frame[9] = 0xfd;
n = write(fd, frame, 10);
write(fd, frame, 10);
}
else
{
@ -501,7 +504,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
}
printf("\n");
@ -512,14 +515,14 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("x25 send nak\n");
frame[4] = 0xfa;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x26:
printf("x26 send nak\n");
frame[4] = 0xfa;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
#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
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
#if 0
struct ip_mreq
{
int dummy;
};
#endif
#include <stdio.h>
#include <stdlib.h>
@ -19,6 +21,7 @@ struct ip_mreq
#include <sys/time.h>
#include <hamlib/rig.h>
#include "../src/misc.h"
#include "sim.h"
#define BUFSIZE 256
//#define X25
@ -40,7 +43,7 @@ ant_t ant_curr = 0;
int ant_option = 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]); }
@ -74,7 +77,6 @@ frameGet(int fd, unsigned char *buf)
void frameParse(int fd, unsigned char *frame, int len)
{
double freq;
int n;
dumphex(frame, len);
@ -102,9 +104,7 @@ void frameParse(int fd, unsigned char *frame, int len)
}
frame[10] = 0xfd;
n = write(fd, frame, 11);
if (n != 11) {printf("Error!\n"); exit(1);}
write(fd, frame, 11);
break;
@ -123,7 +123,7 @@ void frameParse(int fd, unsigned char *frame, int len)
}
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x05:
@ -135,7 +135,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x06:
@ -144,7 +144,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x07:
@ -164,7 +164,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x0f:
@ -174,7 +174,7 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("set split %d\n", 1);
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
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;
printf("n=write 8 bytes\n");
dump_hex(frame, 8);
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x14:
@ -209,7 +209,7 @@ void frameParse(int fd, unsigned char *frame, int len)
printf("Using AF level %d\n", level);
to_bcd(&frame[6], (long long) level, 2);
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
break;
case 0x0a:
@ -220,7 +220,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)power_level, 2);
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
break;
}
@ -239,7 +239,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)meter_level, 2);
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
break;
}
@ -248,7 +248,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x18: // miscellaneous things
frame[5] = 1;
frame[6] = 0xfd;
n = write(fd, frame, 7);
write(fd, frame, 7);
break;
case 0x1a: // miscellaneous things
@ -259,20 +259,20 @@ void frameParse(int fd, unsigned char *frame, int len)
else { frame[6] = widthB; }
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x04: // IC7200 data mode
frame[6] = 0;
frame[7] = 0;
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
break;
case 0x07: // satmode
frame[6] = 0;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
}
@ -287,14 +287,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = ptt;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
else
{
ptt = frame[6];
frame[7] = 0xfb;
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
}
break;
@ -321,7 +321,7 @@ void frameParse(int fd, unsigned char *frame, int len)
}
frame[11] = 0xfd;
n = write(fd, frame, 12);
write(fd, frame, 12);
}
else
{
@ -333,7 +333,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
}
break;
@ -349,7 +349,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
frame[8] = 0xfb;
frame[9] = 0xfd;
n = write(fd, frame, 10);
write(fd, frame, 10);
}
else
{
@ -368,7 +368,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
}
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
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
#if 0
struct ip_mreq
{
int dummy;
};
#endif
#include <stdio.h>
#include <stdlib.h>
@ -45,7 +47,7 @@ int agc_time = 1;
int ovf_status = 0;
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]); }
@ -96,7 +98,6 @@ again:
void frameParse(int fd, unsigned char *frame, int len)
{
double freq;
int n = 0;
dumphex(frame, len);
@ -133,7 +134,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[8] = 0xfd;
dump_hex(frame, 9);
n = write(fd, frame, 9);
write(fd, frame, 9);
break;
@ -152,7 +153,7 @@ void frameParse(int fd, unsigned char *frame, int len)
}
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x05:
@ -164,7 +165,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x06:
@ -173,7 +174,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x07:
@ -193,7 +194,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
break;
case 0x0f:
@ -205,14 +206,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{
printf("get split %d\n", 1);
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
else
{
printf("set split %d\n", 1);
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
}
break;
@ -235,7 +236,7 @@ void frameParse(int fd, unsigned char *frame, int len)
frame[7] = 0xfd;
printf("write 8 bytes\n");
dump_hex(frame, 8);
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x14:
@ -251,7 +252,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)power_level, 2);
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
break;
}
@ -265,7 +266,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07:
frame[6] = ovf_status;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
ovf_status = ovf_status == 0 ? 1 : 0;
break;
@ -277,7 +278,7 @@ void frameParse(int fd, unsigned char *frame, int len)
to_bcd(&frame[6], (long long)meter_level, 2);
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
break;
}
@ -293,7 +294,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = satmode;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
break;
@ -304,7 +305,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x18: // miscellaneous things
frame[5] = 1;
frame[6] = 0xfd;
n = write(fd, frame, 7);
write(fd, frame, 7);
break;
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; }
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
case 0x04: // AGC TIME
@ -324,7 +325,7 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = agc_time;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
else
{
@ -332,7 +333,7 @@ void frameParse(int fd, unsigned char *frame, int len)
agc_time = frame[6];
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
write(fd, frame, 6);
}
break;
@ -340,7 +341,7 @@ void frameParse(int fd, unsigned char *frame, int len)
case 0x07: // satmode
frame[4] = 0;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
break;
}
@ -355,14 +356,14 @@ void frameParse(int fd, unsigned char *frame, int len)
{
frame[6] = ptt;
frame[7] = 0xfd;
n = write(fd, frame, 8);
write(fd, frame, 8);
}
else
{
ptt = frame[6];
frame[7] = 0xfb;
frame[8] = 0xfd;
n = write(fd, frame, 9);
write(fd, frame, 9);
}
break;
@ -384,8 +385,6 @@ void frameParse(int fd, unsigned char *frame, int len)
default: printf("cmd 0x%02x unknown\n", frame[4]);
}
if (n == 0) { printf("Write failed?\n"); }
// don't care about the rig type yet
}

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -2,10 +2,12 @@
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
#if 0
struct ip_mreq
{
int dummy;
};
#endif
#include <stdio.h>
#include <stdlib.h>
@ -275,7 +277,7 @@ int main(int argc, char *argv[])
hl_usleep(50 * 1000);
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));
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__);
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->caps==NULL?NULL:amp->caps);
amp_debug(RIG_DEBUG_ERR, "%s: NULL ptr? amp=%p\n", __func__, amp);
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;
}

Wyświetl plik

@ -593,8 +593,7 @@ int rig_fire_freq_event(RIG *rig, vfo_t vfo, freq_t freq)
{
ENTERFUNC;
rig_debug(RIG_DEBUG_TRACE, "Event: freq changed to %"PRIll"Hz on %s\n",
(int64_t)freq, rig_strvfo(vfo));
rig_debug(RIG_DEBUG_TRACE, "Event: freq changed to %"PRIll"Hz on %s\n", (int64_t)freq, rig_strvfo(vfo));
rig_set_cache_freq(rig, vfo, freq);
// 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)
{
int *ext_tokens = rig->caps->ext_tokens;
const int *ext_tokens = rig->caps->ext_tokens;
int i;
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 bytes_read;
struct timeval tv_timeout;
int result;
signed char data;
do
{
int result;
tv_timeout.tv_sec = 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)
{
int ret;
int method = 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)
{
int i;
method = 1;
for (i = 0; i < count; i++)
{
@ -1107,7 +1105,6 @@ int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer,
}
else
{
method = 2;
ret = port_write(p, txbuffer, 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__,
(int)count, method);
rig_debug(RIG_DEBUG_TRACE, "%s(): TX %d bytes\n", __func__,
(int)count);
dump_hex((unsigned char *) txbuffer, count);
if (p->post_write_delay > 0)
{
method |= 4;
#if 0
#ifdef WANT_NON_ACTIVE_POST_WRITE_DELAY
#define POST_WRITE_DELAY_TRSHLD 10
@ -1431,7 +1427,7 @@ static int read_string_generic(hamlib_port_t *p,
// direct);
}
// special read for FLRig
if (strcmp(stopset, "/methodResponse>") == 0)
if (strcmp(stopset, "</methodResponse>") == 0)
{
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)
{
gran_t *this_gran;
float maxval;
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))
{
float maxval;
/* If min==max==step==0, all values are OK here */
maxval = this_gran->max.f;
@ -1494,7 +1494,7 @@ enum agc_level_e rig_levelagcvalue(int agcValue)
* \param mode AGC string...
* \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;
@ -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)
{
// gmtime is threadsafe in windows because it uses TLS
struct tm *theTm = gmtime(t);
const struct tm *theTm = gmtime(t);
if (theTm)
{
@ -2763,7 +2763,7 @@ char *date_strget(char *buf, int buflen, int localtime)
struct tm *mytm;
time_t t;
struct timeval tv;
struct tm result;
struct tm result = { 0,0,0,0,0,0,0,0,0};
int mytimezone;
t = time(NULL);

Wyświetl plik

@ -206,7 +206,7 @@ typedef enum settings_value_e
} 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_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)
{
int retval;
// 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,
sizeof(rig->state.multicast->mreq))) < 0)
sizeof(rig->state.multicast->mreq)) < 0)
{
rig_debug(RIG_DEBUG_ERR, "%s: setsockopt: %s\n", __func__, strerror(errno));
return;
}
// 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));
}
@ -626,7 +624,7 @@ int multicast_send(RIG *rig, const char *msg, int msglen)
//#define TEST
#ifdef TEST
int main(int argc, char *argv[])
int main(int argc, const char *argv[])
{
RIG *rig;
rig_model_t myrig_model;

Wyświetl plik

@ -80,6 +80,7 @@
#include "snapshot_data.h"
#ifdef HAVE_WINDOWS_H
// cppcheck-suppress missingInclude
#include "io.h"
#endif
@ -161,15 +162,15 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg)
int network_init()
{
int retval = RIG_OK;
#ifdef __MINGW32__
WSADATA wsadata;
if (wsstarted == 0)
{
int ret;
ret = WSAStartup(MAKEWORD(1, 1), &wsadata);
retval = WSAStartup(MAKEWORD(1, 1), &wsadata);
if (ret == 0)
if (retval == 0)
{
wsstarted = 1;
rig_debug(RIG_DEBUG_VERBOSE, "%s: WSAStartup OK\n", __func__);
@ -177,13 +178,13 @@ int network_init()
else
{
rig_debug(RIG_DEBUG_ERR, "%s: error creating socket, WSAStartup ret=%d\n",
__func__, ret);
__func__, retval);
return (-RIG_EIO);
}
}
#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)
{
int fd = mcast_publisher_args->data_write_fd;
@ -627,7 +628,7 @@ static int multicast_publisher_write_data(multicast_publisher_args
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)
{
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)
{
struct rig_state *rs = &rig->state;
const struct rig_state *rs = &rig->state;
multicast_publisher_data_packet packet =
{
.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)
{
struct rig_state *rs = &rig->state;
const struct rig_state *rs = &rig->state;
multicast_publisher_data_packet packet =
{
.type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_TRANSCEIVE,
@ -891,7 +892,6 @@ void *multicast_publisher(void *arg)
struct sockaddr_in dest_addr;
int socket_fd = args->socket_fd;
int result;
ssize_t send_result;
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)
{
int result;
result = multicast_publisher_read_packet(args, &packet_type, &spectrum_line,
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;
q = NULL;
@ -362,7 +362,6 @@ void add2debugmsgsave(const char *s)
int maxmsg = DEBUGMSGSAVE_SIZE / 2;
MUTEX_LOCK(debugmsgsave);
memset(stmp, 0, sizeof(stmp));
p = debugmsgsave;
// we'll keep 20 lines including this one
// 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);
char *path = calloc(1, 4096);
extern char *settings_file;
char *xdgpath = getenv("XDG_CONFIG_HOME");
const char *xdgpath = getenv("XDG_CONFIG_HOME");
settings_file = "hamlib_settings";
@ -953,7 +952,7 @@ int HAMLIB_API rig_open(RIG *rig)
sprintf(path, "%s/%s", cwd, settings_file);
}
FILE *fp = fopen(path, "r");
const FILE *fp = fopen(path, "r");
if (fp == NULL)
{
@ -1984,8 +1983,6 @@ int rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
}
}
else { retry = 0; }
#else
tfreq = freq;
#endif
}
@ -2275,7 +2272,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
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);
// 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)
{
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;
}
ENTERFUNC;
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;
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.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
{
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)
@ -4353,7 +4342,6 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
if (caps->set_freq)
{
int retry = 3;
freq_t tfreq;
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)
{
HAMLIB_TRACE;
retcode = RIG_OK;
retcode = caps->set_vfo(rig, tx_vfo);
}
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)
{
const struct rig_caps *caps;
int retcode, rc2;
int retcode;
vfo_t curr_vfo;
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 */
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)
{
@ -5399,7 +5385,7 @@ int HAMLIB_API rig_get_split_vfo(RIG *rig,
if ((vfo == RIG_VFO_CURR) || (vfo == rig->state.current_vfo))
{
HAMLIB_TRACE;
retcode = RIG_OK;
//retcode = RIG_OK;
//if (rig->caps->rig_model != RIG_MODEL_NETRIGCTL)
{
// 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);
// 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)
{
@ -8010,7 +7996,6 @@ void *async_data_handler(void *arg)
RIG *rig = args->rig;
unsigned char frame[MAX_FRAME_LENGTH];
struct rig_state *rs = &rig->state;
int result;
rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting async data handler thread\n",
__func__);
@ -8023,6 +8008,7 @@ void *async_data_handler(void *arg)
{
int frame_length;
int async_frame;
int result;
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 *) arg;
RIG *rig = args->rig;
struct rig_state *rs = &rig->state;
const struct rig_state *rs = &rig->state;
int result;
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)
{
struct rig_state *rs = &rig->state;
unsigned char buf[200];
int nbytes;
int retval;
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)
{
unsigned char buf[200];
if (simulate)
{
// 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)
{
int retcode = -RIG_ENAVAIL;
int retcode;
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)
{
int retcode = -RIG_ENAVAIL;
int retcode;
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
// 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);
if (len > 0)
@ -1164,7 +1164,7 @@ int HAMLIB_API ser_get_dtr(hamlib_port_t *p, int *state)
* \param state (ignored?)
* \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
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);
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_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_get_dtr(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
char *xdgpath = getenv("XDG_CONFIG_HOME");
const char *xdgpath = getenv("XDG_CONFIG_HOME");
char *home = getenv("HOME");
if (home == NULL) home = "?HOME";
snprintf(path, pathlen, "%s/.config", home);
if (xdgpath)
@ -1062,7 +1063,7 @@ HAMLIB_EXPORT(int) rig_settings_get_path(char *path, int pathlen)
*
* \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)
{
FILE *fp;
@ -1218,8 +1219,8 @@ HAMLIB_EXPORT(int) rig_settings_load_all(char *settings_file)
while (fgets(buf, sizeof(buf), fp))
{
char *s = strtok(buf, "=");
char *v = strtok(NULL, "\r\n");
const char *s = strtok(buf, "=");
const char *v = strtok(NULL, "\r\n");
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
{
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);
}
@ -931,7 +931,7 @@ int rig_sprintf_agc_levels(RIG *rig, char *str, int lenstr)
{
for (i = 0; i <= HAMLIB_MAX_AGC_LEVELS
&& 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, " "); }

Wyświetl plik

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

Wyświetl plik

@ -20,7 +20,7 @@
#include "misc.h"
int main(int argc, char *argv[])
int main(int argc, const char *argv[])
{
RIG *my_rig;
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
&& priv_caps->agc_levels_present)
{
for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST
&& priv_caps->agc_levels[i].icom_level >= 0; i++)
for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST ; i++)
{
fprintf(fout, " %d=%s", 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
*/
int dumpcaps_amp(AMP *amp, FILE *fout)
int dumpcaps_amp(const AMP *amp, FILE *fout)
{
const struct amp_caps *caps;
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);
int main(int argc, char *argv[])
int main(int argc, const char *argv[])
{
RIG *my_rig;
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
&& priv_caps->agc_levels_present)
{
for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST
&& priv_caps->agc_levels[i].icom_level >= 0; i++)
for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST; i++)
{
fprintf(fout, " %d=%s", 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 <string.h>
int main(int argc, char *argv[])
int main(int argc, const char *argv[])
{
char buf[4096];
char buf2[4096];
FILE *fp = fopen(argv[1], "r");
int linenum = 0;
int enterfunc = 0;
int infunc = 0;
int retval = 0;
retval = 0;

Wyświetl plik

@ -29,7 +29,7 @@
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",
caps->rig_model,
caps->mfg_name,

Wyświetl plik

@ -61,7 +61,7 @@ static int tokenize_line(char *line,
size_t siz,
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_load(RIG *rig, const char *infilename);
@ -272,6 +272,7 @@ static char *mystrtok(char *s, char delim)
}
else
{
return NULL;
}
if (str && str[ pos + 1 ] == '\0')
@ -1026,7 +1027,7 @@ int set_channel_data(RIG *rig,
\return string position on the list on success,
-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;

Wyświetl plik

@ -142,13 +142,13 @@ int dump_xml_chan(RIG *rig,
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);
}
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);
}
@ -156,6 +156,7 @@ int dump_xml_chan(RIG *rig,
{
// cppcheck-suppress *
char *fmt = "%"PRIll;
// cppcheck-suppress *
SNPRINTF(attrbuf, sizeof(attrbuf), fmt, (int64_t)chan.freq);
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)
{
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);
}
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);
}
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);
}
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);
}

Wyświetl plik

@ -15,7 +15,7 @@
#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) */
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)
{
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.max,
cfp->u.n.step);
@ -3315,6 +3315,10 @@ declare_proto_rig(set_level)
CHKSCN1ARG(sscanf(arg2, "%d", &val.i));
break;
case RIG_CONF_INT:
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
break;
case RIG_CONF_NUMERIC:
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
break;
@ -3426,7 +3430,7 @@ declare_proto_rig(get_level)
break;
case RIG_CONF_INT:
fprintf(fout, "%d%c", val.i, resp_sep);
fprintf(fout, "%.0f%c", val.f, resp_sep);
break;
case RIG_CONF_STRING:
@ -3653,6 +3657,10 @@ declare_proto_rig(set_parm)
CHKSCN1ARG(sscanf(arg2, "%d", &val.i));
break;
case RIG_CONF_INT:
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
break;
case RIG_CONF_NUMERIC:
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
break;
@ -3767,6 +3775,10 @@ declare_proto_rig(get_parm)
fprintf(fout, "%d%c", val.i, resp_sep);
break;
case RIG_CONF_INT:
fprintf(fout, "%.0f%c", val.f, resp_sep);
break;
case RIG_CONF_NUMERIC:
fprintf(fout, "%f%c", val.f, resp_sep);
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);
break;
case RIG_CONF_INT:
SNPRINTF(lstr, sizeof(lstr), "%.0f", chan->ext_levels[idx].val.f);
break;
case RIG_CONF_NUMERIC:
SNPRINTF(lstr, sizeof(lstr), "%f", chan->ext_levels[idx].val.f);
break;

Wyświetl plik

@ -801,7 +801,7 @@ int main(int argc, char *argv[])
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->model_name);
}
@ -1048,7 +1048,7 @@ int main(int argc, char *argv[])
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: ignoring interrupted system call\n",
__func__);
retcode = 0;
//retcode = 0; // not used?
}
}
else if (retcode == 0)
@ -1336,7 +1336,7 @@ void *handle_socket(void *arg)
#ifdef HAVE_PTHREAD
--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
mutex_rigctld(1);

Wyświetl plik

@ -629,7 +629,7 @@ int main(int argc, char *argv[])
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->model_name);
}
@ -651,12 +651,6 @@ int main(int argc, char *argv[])
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);
hl_usleep(400 * 1000); // fairly fast to keep up
@ -671,7 +665,7 @@ int main(int argc, char *argv[])
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"
"Will copy frequency from -m rig to -M rig\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)
{
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->model_name);
}
@ -1034,7 +1034,7 @@ int main(int argc, char *argv[])
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: ignoring interrupted system call\n",
__func__);
retcode = 0;
//retcode = 0; // not used?
}
}
else if (retcode == 0)
@ -1244,7 +1244,7 @@ void *handle_socket(void *arg)
mutex_rigctld(0);
int nbytes = -1;
int nbytes;
if (rig_opened) // only do this if rig is open
{
@ -1426,7 +1426,7 @@ client_done:
#ifdef HAVE_PTHREAD
--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
mutex_rigctld(1);

Wyświetl plik

@ -17,7 +17,7 @@ double history[HISTORYSIZE];
int nhistory;
int historyinit = 1;
double compute_mean(double arr[], int length)
double compute_mean(const double arr[], int length)
{
double sum = 0.0;
for (int i = 0; i < length; i++) {
@ -37,7 +37,7 @@ double sigma(double arr[], int 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) */
int strength; /* S-Meter level */
@ -62,16 +62,16 @@ int main(int argc, char *argv[])
* allocate memory, setup & open port
*/
hamlib_port_t myport;
// hamlib_port_t myport;
myrig_model = atoi(argv[1]);
strncpy(myport.pathname, argv[2], HAMLIB_FILPATHLEN - 1);
myport.parm.serial.rate = atoi(argv[3]);
// strncpy(myport.pathname, argv[2], HAMLIB_FILPATHLEN - 1);
// myport.parm.serial.rate = atoi(argv[3]);
my_rig = rig_init(myrig_model);
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");
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)
{
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);
}
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)
{
printf(" USB 3.0 Capabilities:\n");
@ -355,11 +355,10 @@ static int test_wrapped_device(const char *device_name)
}
#endif
int main(int argc, char *argv[])
int main(int argc, const char *argv[])
{
const char *device_name = NULL;
libusb_device **devs;
ssize_t cnt;
int r, i;
for (i = 1; i < argc; i++)
@ -394,6 +393,7 @@ int main(int argc, char *argv[])
}
else
{
ssize_t cnt;
cnt = libusb_get_device_list(NULL, &devs);
if (cnt < 0)

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -308,7 +308,7 @@ void hash_add_model(int id,
/* 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);
}
@ -431,7 +431,7 @@ static int scanfc(FILE *fin, const char *format, void *p)
* returns <0 is error number
* 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;
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 retcode; /* generic return code from functions */
@ -1528,32 +1528,29 @@ void usage_rot(FILE *fout)
for (i = 0; test_list[i].cmd != 0; i++)
{
int nbspaces;
fprintf(fout,
"%c: %-12s(",
isprint(test_list[i].cmd) ? test_list[i].cmd : '?',
test_list[i].name);
nbspaces = 16;
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))
{
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))
{
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))
{
nbspaces -= fprintf(fout, ", %s", test_list[i].arg4);
fprintf(fout, ", %s", test_list[i].arg4);
}
fprintf(fout, ")\n");
@ -1671,14 +1668,13 @@ void list_models()
int set_conf(ROT *my_rot, char *conf_parms)
{
char *p;
int token;
rot_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
p = conf_parms;
while (p && *p != '\0')
{
int ret;
int token;
char *q, *n = NULL;
/* FIXME: left hand value of = cannot be null */
q = strchr(p, '=');
@ -1700,6 +1696,7 @@ int set_conf(ROT *my_rot, char *conf_parms)
if (token != 0)
{
int ret;
ret = rot_set_conf(my_rot, token, q);
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 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);
#endif /* ROTCTL_PARSE_H */

Wyświetl plik

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

Wyświetl plik

@ -37,7 +37,7 @@ int main(int argc, char *argv[])
char vfo[16];
char mode[16];
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("=========================\nEntire response:\n%s", riginfo);
rig_close(rig);

Wyświetl plik

@ -72,6 +72,12 @@ int main(int argc, char *argv[])
vfo_t 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)
{

Wyświetl plik

@ -96,7 +96,7 @@ static int test3_invalid_input()
{
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"); }

Wyświetl plik

@ -52,7 +52,7 @@ int callback(const struct rig_caps *caps, rig_ptr_t rigp)
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\n", caps->rig_model, fpow);
printf("rig=%u, fpow=%g\n", caps->rig_model, fpow);
// we call again to make debugging this section easier
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?) */
}
char *port = "/dev/pts/3";
const char *port = "/dev/pts/3";
strcpy(rig->state.rigport.pathname, port);
printf("%20s:", caps->model_name);

Wyświetl plik

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