kopia lustrzana https://github.com/Hamlib/Hamlib
Merge branch 'master' into libusb-1-0
Catch up this branch to changes made in master.Hamlib-3.1
commit
b3e6c460fe
|
@ -6,6 +6,7 @@
|
|||
*.o
|
||||
*.lo
|
||||
*.la
|
||||
*.orig
|
||||
*.swp
|
||||
Makefile
|
||||
Makefile.in
|
||||
|
|
|
@ -542,17 +542,29 @@ readability. Align closing braces with the opening block's keyword. In
|
|||
function definitions put the opening brace on its own line under the
|
||||
definition's parameter line.
|
||||
|
||||
Hamlib source code is no place for an entry into the obsfucated C contest!
|
||||
A configuration file for the Artistic Style (http://astyle.sourceforge.net/)
|
||||
utility can be found in the scripts directory. The settings it provides should
|
||||
conform reasonably close to the Linux style guide referenced above. This file
|
||||
can be copied to $HOME/.astylerc where it will be used as the default
|
||||
configuration. If you already have an existing .astylerc, passing
|
||||
|
||||
--options=/path/to/hamlib/scripts/astylerc
|
||||
|
||||
will use this file as the configuration for formatting. Consider using this
|
||||
utility whenever working on a given C source file in Hamlib.
|
||||
|
||||
Hamlib source code is no place for an entry into the obfuscated C contest!
|
||||
Many of us are hobbyists and write this for fun. Easy to read and
|
||||
understand logic is preferred over a clever solution. If your solution must
|
||||
be written in a clever fashion, please document it well in your comments.
|
||||
|
||||
Any header files included from the hamlib/ directory should be enclosed
|
||||
in <>:
|
||||
Any header files included from the hamlib/ directory should be enclosed in <>:
|
||||
|
||||
#include <hamlib/rig.h> # Per GNU GCC documentation
|
||||
|
||||
Other included header files (backend and rig specific headers) should be
|
||||
enclosed in "":
|
||||
|
||||
#include "yaesu.h"
|
||||
|
||||
Contributed code should always keep the source base in a compilable state,
|
||||
|
@ -581,6 +593,7 @@ Hamlib should also compile with the following common compilers:
|
|||
|
||||
Portability issues to watch:
|
||||
|
||||
* C99 is probably (in 2016) a reasonable target
|
||||
* little vs. big endian systems (use shifts or adhoc functions)
|
||||
* 64 bit int: avoid them in API
|
||||
* printf/scanf of 64bit int: use PRIll (cast value to int64_t) and SCNll
|
||||
|
@ -672,6 +685,9 @@ big, you can send it as a compressed attachment.
|
|||
|
||||
8.3.1 Changelog
|
||||
|
||||
A ChangeLog file is no longer manually maintained. At some point it may be
|
||||
automatically generated from the Git commit log for source tarballs.
|
||||
|
||||
Simply summarize your changes when the files are committed to Git or, if
|
||||
providing patches to the mailing list, provide a summary so the uploader can
|
||||
include it in the commit message which will show in the commit log (Git
|
||||
|
|
877
adat/adat.c
877
adat/adat.c
Plik diff jest za duży
Load Diff
100
drake/drake.c
100
drake/drake.c
|
@ -83,6 +83,7 @@ int drake_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *d
|
|||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
retval = 0;
|
||||
|
||||
if (retval < 0)
|
||||
return retval;
|
||||
|
||||
|
@ -184,9 +185,13 @@ int drake_set_vfo(RIG *rig, vfo_t vfo)
|
|||
|
||||
switch (vfo) {
|
||||
case RIG_VFO_A : vfo_function = 'A'; break;
|
||||
|
||||
case RIG_VFO_B : vfo_function = 'B'; break;
|
||||
|
||||
case RIG_VFO_VFO: vfo_function = 'F'; break;
|
||||
|
||||
case RIG_VFO_MEM: vfo_function = 'C'; break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "drake_set_vfo: unsupported VFO %d\n",
|
||||
vfo);
|
||||
|
@ -197,6 +202,7 @@ int drake_set_vfo(RIG *rig, vfo_t vfo)
|
|||
|
||||
if ((vfo_function == 'A') || (vfo_function == 'B'))
|
||||
cmd_len = sprintf((char *) cmdbuf, "V%c" EOM, vfo_function);
|
||||
|
||||
if ((vfo_function == 'F') || (vfo_function == 'C'))
|
||||
cmd_len = sprintf((char *) cmdbuf, "%c" EOM, vfo_function);
|
||||
|
||||
|
@ -230,9 +236,12 @@ int drake_get_vfo(RIG *rig, vfo_t *vfo)
|
|||
*vfo = RIG_VFO_MEM;
|
||||
else {
|
||||
cvfo = (mdbuf[9] & 0x38);
|
||||
|
||||
switch (cvfo) {
|
||||
case '0' : *vfo = RIG_VFO_B; break;
|
||||
|
||||
case '8' : *vfo = RIG_VFO_A; break;
|
||||
|
||||
default : rig_debug(RIG_DEBUG_ERR,
|
||||
"drake_get_vfo: unsupported vfo %c\n", cvfo);
|
||||
*vfo = RIG_VFO_VFO;
|
||||
|
@ -255,14 +264,20 @@ int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
|
||||
switch (mode) {
|
||||
case RIG_MODE_CW: mode_sel = MD_CW; break;
|
||||
|
||||
case RIG_MODE_ECSSUSB:
|
||||
case RIG_MODE_USB: mode_sel = MD_USB; break;
|
||||
|
||||
case RIG_MODE_ECSSLSB:
|
||||
case RIG_MODE_LSB: mode_sel = MD_LSB; break;
|
||||
|
||||
case RIG_MODE_FM: mode_sel = MD_FM; break;
|
||||
|
||||
case RIG_MODE_AMS:
|
||||
case RIG_MODE_AM: mode_sel = MD_AM; break;
|
||||
|
||||
case RIG_MODE_RTTY: mode_sel = MD_RTTY; break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "drake_set_mode: "
|
||||
"unsupported mode %d\n", mode);
|
||||
|
@ -282,15 +297,21 @@ int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
|
||||
switch (width) {
|
||||
case 500: width_sel = '0'; break;
|
||||
|
||||
case 1800: width_sel = '1'; break;
|
||||
|
||||
case 2300: width_sel = '2'; break;
|
||||
|
||||
case 4000: width_sel = '4'; break;
|
||||
|
||||
case 6000: width_sel = '6'; break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "drake_set_mode: "
|
||||
"unsupported width %d\n", width);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
mdbuf_len = sprintf((char *) mdbuf, "W%c" EOM, width_sel);
|
||||
retval = drake_transaction(rig, (char *) mdbuf, mdbuf_len, (char *) ackbuf, &ack_len);
|
||||
}
|
||||
|
@ -336,10 +357,15 @@ int drake_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
|
||||
switch (cwidth & 0x37) {
|
||||
case '0': *width = s_Hz(500); break;
|
||||
|
||||
case '1': *width = s_Hz(1800); break;
|
||||
|
||||
case '2': *width = s_Hz(2300); break;
|
||||
|
||||
case '3': *width = s_Hz(4000); break;
|
||||
|
||||
case '4': *width = s_Hz(6000); break;
|
||||
|
||||
default :
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"drake_get_mode: unsupported width %c\n",
|
||||
|
@ -351,8 +377,11 @@ int drake_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
if ((cwidth >= '0') && (cwidth <= '4')) {
|
||||
switch (cmode & 0x33) {
|
||||
case '0': *mode = RIG_MODE_LSB; break;
|
||||
|
||||
case '1': *mode = RIG_MODE_RTTY; break;
|
||||
|
||||
case '2': *mode = RIG_MODE_FM; *width = s_Hz(12000); break;
|
||||
|
||||
default :
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"drake_get_mode: unsupported mode %c\n",
|
||||
|
@ -363,8 +392,11 @@ int drake_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
} else {
|
||||
switch (cmode & 0x33) {
|
||||
case '0': *mode = RIG_MODE_USB; break;
|
||||
|
||||
case '1': *mode = RIG_MODE_CW; break;
|
||||
|
||||
case '2': *mode = RIG_MODE_AM; break;
|
||||
|
||||
default :
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"drake_get_mode: unsupported mode %c\n",
|
||||
|
@ -377,13 +409,12 @@ int drake_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
if ((csynch & 0x34) == '4') {
|
||||
if (*mode == RIG_MODE_AM)
|
||||
*mode = RIG_MODE_AMS;
|
||||
else
|
||||
if (*mode == RIG_MODE_USB)
|
||||
else if (*mode == RIG_MODE_USB)
|
||||
*mode = RIG_MODE_ECSSUSB;
|
||||
else
|
||||
if (*mode == RIG_MODE_LSB)
|
||||
else if (*mode == RIG_MODE_LSB)
|
||||
*mode = RIG_MODE_ECSSLSB;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
@ -428,8 +459,11 @@ int drake_get_ant(RIG *rig, vfo_t vfo, ant_t *ant)
|
|||
|
||||
switch (cant & 0x3c) {
|
||||
case '0': *ant = RIG_ANT_1; break;
|
||||
|
||||
case '4': *ant = RIG_ANT_3; break;
|
||||
|
||||
case '8': *ant = RIG_ANT_2; break;
|
||||
|
||||
default :
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"drake_get_ant: unsupported antenna %c\n",
|
||||
|
@ -517,6 +551,7 @@ int drake_set_chan(RIG *rig, const channel_t *chan)
|
|||
if (old_vfo == RIG_VFO_MEM) {
|
||||
old_chan = priv->curr_ch;
|
||||
retval = drake_set_vfo(rig, RIG_VFO_VFO);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
}
|
||||
|
@ -592,11 +627,13 @@ int drake_get_chan(RIG *rig, channel_t *chan)
|
|||
|
||||
//go to new channel
|
||||
retval = drake_set_mem(rig, RIG_VFO_CURR, chan->channel_num);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return RIG_OK;
|
||||
|
||||
//now decypher it
|
||||
retval = drake_transaction(rig, "RA" EOM, 3, mdbuf, &mdbuf_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -611,8 +648,11 @@ int drake_get_chan(RIG *rig, channel_t *chan)
|
|||
|
||||
switch (mdbuf[5] & 0x33) {
|
||||
case '0': chan->levels[rig_setting2idx(RIG_LEVEL_AGC)].i = RIG_AGC_OFF; break;
|
||||
|
||||
case '2': chan->levels[rig_setting2idx(RIG_LEVEL_AGC)].i = RIG_AGC_FAST; break;
|
||||
|
||||
case '3': chan->levels[rig_setting2idx(RIG_LEVEL_AGC)].i = RIG_AGC_SLOW; break;
|
||||
|
||||
default : chan->levels[rig_setting2idx(RIG_LEVEL_AGC)].i = RIG_AGC_FAST;
|
||||
}
|
||||
|
||||
|
@ -627,33 +667,47 @@ int drake_get_chan(RIG *rig, channel_t *chan)
|
|||
|
||||
switch (mdbuf[7] & 0x3c) {
|
||||
case '0': chan->ant = RIG_ANT_1; break;
|
||||
|
||||
case '4': chan->ant = RIG_ANT_3; break;
|
||||
|
||||
case '8': chan->ant = RIG_ANT_2; break;
|
||||
|
||||
default : chan->ant = RIG_ANT_NONE;
|
||||
}
|
||||
|
||||
switch (mdbuf[8] & 0x37) {
|
||||
case '0': chan->width = s_Hz(500); break;
|
||||
|
||||
case '1': chan->width = s_Hz(1800); break;
|
||||
|
||||
case '2': chan->width = s_Hz(2300); break;
|
||||
|
||||
case '3': chan->width = s_Hz(4000); break;
|
||||
|
||||
case '4': chan->width = s_Hz(6000); break;
|
||||
|
||||
default : chan->width = RIG_PASSBAND_NORMAL;
|
||||
}
|
||||
|
||||
if ((mdbuf[8] >= '0') && (mdbuf[8] <= '4')) {
|
||||
switch (mdbuf[7] & 0x33) {
|
||||
case '0': chan->mode = RIG_MODE_LSB; break;
|
||||
|
||||
case '1': chan->mode = RIG_MODE_RTTY; break;
|
||||
|
||||
case '2': chan->mode = RIG_MODE_FM;
|
||||
chan->width = s_Hz(12000); break;
|
||||
|
||||
default : chan->mode = RIG_MODE_NONE;
|
||||
}
|
||||
} else {
|
||||
switch (mdbuf[7] & 0x33) {
|
||||
case '0': chan->mode = RIG_MODE_USB; break;
|
||||
|
||||
case '1': chan->mode = RIG_MODE_CW; break;
|
||||
|
||||
case '2': chan->mode = RIG_MODE_AM; break;
|
||||
|
||||
default : chan->mode = RIG_MODE_NONE;
|
||||
}
|
||||
}
|
||||
|
@ -669,8 +723,10 @@ int drake_get_chan(RIG *rig, channel_t *chan)
|
|||
|
||||
strncpy(freqstr, mdbuf + 11, 9);
|
||||
freqstr[9] = 0x00;
|
||||
|
||||
if ((mdbuf[21] == 'k') || (mdbuf[21] == 'K'))
|
||||
chan->freq = strtod(freqstr, NULL) * 1000.0;
|
||||
|
||||
if ((mdbuf[21] == 'm') || (mdbuf[21] == 'M'))
|
||||
chan->freq = strtod(freqstr, NULL) * 1000000.0;
|
||||
|
||||
|
@ -680,10 +736,12 @@ int drake_get_chan(RIG *rig, channel_t *chan)
|
|||
//now put the radio back the way it was
|
||||
if (old_vfo != RIG_VFO_MEM) {
|
||||
retval = drake_set_vfo(rig, RIG_VFO_VFO);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
} else {
|
||||
retval = drake_set_mem(rig, RIG_VFO_CURR, old_chan);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
}
|
||||
|
@ -705,22 +763,28 @@ int drake_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
|||
case RIG_OP_UP:
|
||||
len = sprintf(buf, "U");
|
||||
break;
|
||||
|
||||
case RIG_OP_DOWN:
|
||||
len = sprintf(buf, "D");
|
||||
break;
|
||||
|
||||
case RIG_OP_CPY:
|
||||
len = sprintf(buf, "A E B" EOM);
|
||||
break;
|
||||
|
||||
case RIG_OP_TO_VFO:
|
||||
/* len = sprintf(buf,"C%03d" EOM, priv->curr_ch); */
|
||||
len = sprintf(buf, "F" EOM);
|
||||
break;
|
||||
|
||||
case RIG_OP_MCL:
|
||||
len = sprintf(buf, "EC%03d" EOM, priv->curr_ch);
|
||||
break;
|
||||
|
||||
case RIG_OP_FROM_VFO:
|
||||
len = sprintf(buf, "PR" EOM "%03d" EOM, priv->curr_ch);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
@ -743,13 +807,16 @@ int drake_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
case RIG_FUNC_MN:
|
||||
len = sprintf(buf, "N%c" EOM, status ? 'O' : 'F');
|
||||
break;
|
||||
|
||||
case RIG_FUNC_LOCK:
|
||||
len = sprintf(buf, "L%c" EOM, status ? 'O' : 'F');
|
||||
break;
|
||||
|
||||
case RIG_FUNC_NB:
|
||||
/* TODO: NB narrow */
|
||||
len = sprintf(buf, "B%c" EOM, status ? 'W' : 'F');
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
@ -785,11 +852,13 @@ int drake_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
|||
mc = mdbuf[2];
|
||||
*status = ((mc & 0x32) == '2');
|
||||
break;
|
||||
|
||||
case RIG_FUNC_NB:
|
||||
/* TODO: NB narrow */
|
||||
mc = mdbuf[1];
|
||||
*status = ((mc >= '4') && (mc <= '?'));
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "Unsupported get func %d\n", func);
|
||||
return -RIG_EINVAL;
|
||||
|
@ -811,14 +880,17 @@ int drake_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
case RIG_LEVEL_PREAMP:
|
||||
len = sprintf(buf, "G%c" EOM, val.i ? '+' : '0');
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_ATT:
|
||||
len = sprintf(buf, "G%c" EOM, val.i ? '-' : '0');
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_AGC:
|
||||
len = sprintf(buf, "A%c" EOM,
|
||||
val.i == RIG_AGC_OFF ? 'O' :
|
||||
(val.i == RIG_AGC_FAST ? 'F' : 'S'));
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
@ -840,6 +912,7 @@ int drake_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
|
||||
if ((level != RIG_LEVEL_RAWSTR) && (level != RIG_LEVEL_STRENGTH)) {
|
||||
retval = drake_transaction(rig, "RM" EOM, 3, lvlbuf, &lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -853,6 +926,7 @@ int drake_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
switch (level) {
|
||||
case RIG_LEVEL_RAWSTR:
|
||||
retval = drake_transaction(rig, "RSS" EOM, 4, lvlbuf, &lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -865,8 +939,10 @@ int drake_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
lvlbuf[3] = '\0';
|
||||
val->i = strtol(lvlbuf + 1, (char **)NULL, 16);
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_STRENGTH:
|
||||
retval = drake_transaction(rig, "RSS" EOM, 4, lvlbuf, &lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -880,29 +956,42 @@ int drake_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
ss = strtol(lvlbuf + 1, (char **)NULL, 16);
|
||||
val->i = (int)rig_raw2val(ss, &rig->caps->str_cal);
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_PREAMP:
|
||||
mc = lvlbuf[2];
|
||||
|
||||
if ((mc & 0x3c) == '8')
|
||||
val->i = 10;
|
||||
else
|
||||
val->i = 0;
|
||||
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_ATT:
|
||||
mc = lvlbuf[2];
|
||||
|
||||
if ((mc & 0x3c) == '4')
|
||||
val->i = 10;
|
||||
else
|
||||
val->i = 0;
|
||||
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_AGC:
|
||||
mc = lvlbuf[1];
|
||||
|
||||
switch (mc & 0x33) {
|
||||
case '0': val->i = RIG_AGC_OFF; break;
|
||||
|
||||
case '2': val->i = RIG_AGC_FAST; break;
|
||||
|
||||
case '3': val->i = RIG_AGC_SLOW; break;
|
||||
|
||||
default : val->i = RIG_AGC_FAST;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "Unsupported get_level %d\n", level);
|
||||
return -RIG_EINVAL;
|
||||
|
@ -1010,11 +1099,14 @@ DECLARE_PROBERIG_BACKEND(drake)
|
|||
if (!strcmp(idbuf, "R8B")) {
|
||||
if (cfunc)
|
||||
(*cfunc)(port, RIG_MODEL_DKR8B, data);
|
||||
|
||||
return RIG_MODEL_DKR8B;
|
||||
}
|
||||
|
||||
if (!strcmp(idbuf, "R8A")) { /* TBC */
|
||||
if (cfunc)
|
||||
(*cfunc)(port, RIG_MODEL_DKR8A, data);
|
||||
|
||||
return RIG_MODEL_DKR8A;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,15 +76,18 @@ int optoscan_open(RIG *rig)
|
|||
priv = (struct icom_priv_data *)rs->priv;
|
||||
|
||||
pltstate = malloc(sizeof(pltstate_t));
|
||||
|
||||
if (!pltstate) {
|
||||
return -RIG_ENOMEM;
|
||||
}
|
||||
|
||||
memset(pltstate, 0, sizeof(pltstate_t));
|
||||
priv->pltstate = pltstate;
|
||||
|
||||
/* select REMOTE control */
|
||||
retval = icom_transaction(rig, C_CTL_MISC, S_OPTO_REMOTE,
|
||||
NULL, 0, ackbuf, &ack_len);
|
||||
|
||||
if (retval != RIG_OK) {
|
||||
free(pltstate);
|
||||
return retval;
|
||||
|
@ -117,6 +120,7 @@ int optoscan_close(RIG *rig)
|
|||
/* select LOCAL control */
|
||||
retval = icom_transaction(rig, C_CTL_MISC, S_OPTO_LOCAL,
|
||||
NULL, 0, ackbuf, &ack_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -144,6 +148,7 @@ const char* optoscan_get_info(RIG *rig)
|
|||
/* select LOCAL control */
|
||||
retval = icom_transaction(rig, C_CTL_MISC, S_OPTO_RDID,
|
||||
NULL, 0, ackbuf, &ack_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return NULL;
|
||||
|
||||
|
@ -173,6 +178,7 @@ int optoscan_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
|
|||
|
||||
retval = icom_transaction(rig, C_CTL_MISC, S_OPTO_RDCTCSS, NULL, 0,
|
||||
tonebuf, &tone_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -202,6 +208,7 @@ int optoscan_get_dcs_code(RIG * rig, vfo_t vfo, tone_t *code)
|
|||
|
||||
retval = icom_transaction(rig, C_CTL_MISC, S_OPTO_RDDCS, NULL, 0,
|
||||
tonebuf, &tone_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -225,12 +232,14 @@ int optoscan_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length)
|
|||
int len, retval, digitpos;
|
||||
unsigned char xlate[] = {'0', '1', '2', '3', '4', '5', '6',
|
||||
'7', '8', '9', 'A', 'B', 'C', 'D',
|
||||
'*','#'};
|
||||
'*', '#'
|
||||
};
|
||||
digitpos = 0;
|
||||
|
||||
do {
|
||||
retval = icom_transaction(rig, C_CTL_MISC, S_OPTO_RDDTMF,
|
||||
NULL, 0, dtmfbuf, &len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -241,8 +250,7 @@ int optoscan_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length)
|
|||
|
||||
digit = dtmfbuf[2];
|
||||
|
||||
if( digit < 0x16 )
|
||||
{
|
||||
if (digit < 0x16) {
|
||||
digits[digitpos] = xlate[digit];
|
||||
digitpos++;
|
||||
}
|
||||
|
@ -251,12 +259,9 @@ int optoscan_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length)
|
|||
*length = digitpos;
|
||||
digits[digitpos] = 0;
|
||||
|
||||
if(*length > 0)
|
||||
{
|
||||
if (*length > 0) {
|
||||
rig_debug(RIG_DEBUG_ERR, "optoscan_recv_dtmf: %d digits - %s\n", *length, digits);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rig_debug(RIG_DEBUG_ERR, "optoscan_recv_dtmf: no digits to read.\n");
|
||||
}
|
||||
|
||||
|
@ -279,33 +284,37 @@ int optoscan_set_ext_parm(RIG *rig, token_t token, value_t val)
|
|||
case TOK_TAPECNTL:
|
||||
if (val.i == 0) {
|
||||
subcode = S_OPTO_TAPE_OFF;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
subcode = S_OPTO_TAPE_ON;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TOK_5KHZWIN:
|
||||
if (val.i == 0) {
|
||||
subcode = S_OPTO_5KSCOFF;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
subcode = S_OPTO_5KSCON;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TOK_SPEAKER:
|
||||
if (val.i == 0) {
|
||||
subcode = S_OPTO_SPKROFF;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
subcode = S_OPTO_SPKRON;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
retval = icom_transaction(rig, C_CTL_MISC, subcode, epbuf, 0,
|
||||
ackbuf, &ack_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -336,27 +345,35 @@ int optoscan_get_ext_parm(RIG *rig, token_t token, value_t *val)
|
|||
case TOK_TAPECNTL:
|
||||
val->i = status_block.tape_enabled;
|
||||
break;
|
||||
|
||||
case TOK_5KHZWIN:
|
||||
val->i = status_block.fivekhz_enabled;
|
||||
break;
|
||||
|
||||
case TOK_SPEAKER:
|
||||
val->i = status_block.speaker_enabled;
|
||||
break;
|
||||
|
||||
case TOK_AUDIO:
|
||||
val->i = status_block.audio_present;
|
||||
break;
|
||||
|
||||
case TOK_DTMFPEND:
|
||||
val->i = status_block.DTMF_pending;
|
||||
break;
|
||||
|
||||
case TOK_DTMFOVRR:
|
||||
val->i = status_block.DTMF_overrun;
|
||||
break;
|
||||
|
||||
case TOK_CTCSSACT:
|
||||
val->i = status_block.CTCSS_active;
|
||||
break;
|
||||
|
||||
case TOK_DCSACT:
|
||||
val->i = status_block.DCS_active;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_ENIMPL;
|
||||
}
|
||||
|
@ -389,13 +406,15 @@ int optoscan_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
switch (level) {
|
||||
case RIG_LEVEL_AF:
|
||||
lvl_cn = C_CTL_MISC;
|
||||
|
||||
if (icom_val == 0) {
|
||||
lvl_sc = S_OPTO_SPKROFF;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
lvl_sc = S_OPTO_SPKRON;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "Unsupported set_level %d", level);
|
||||
return -RIG_EINVAL;
|
||||
|
@ -403,6 +422,7 @@ int optoscan_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
|
||||
retval = icom_transaction(rig, lvl_cn, lvl_sc, lvlbuf, 0,
|
||||
ackbuf, &ack_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -423,19 +443,19 @@ int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
{
|
||||
struct optostat status_block;
|
||||
unsigned char lvlbuf[MAXFRAMELEN];
|
||||
int lvl_len;
|
||||
int lvl_len = 0;
|
||||
int lvl_cn, lvl_sc; /* Command Number, Subcommand */
|
||||
int icom_val;
|
||||
int cmdhead;
|
||||
int retval;
|
||||
|
||||
if( level != RIG_LEVEL_AF )
|
||||
{
|
||||
if (level != RIG_LEVEL_AF) {
|
||||
switch (level) {
|
||||
case RIG_LEVEL_RAWSTR:
|
||||
lvl_cn = C_RD_SQSM;
|
||||
lvl_sc = S_SML;
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "Unsupported get_level %d", level);
|
||||
return -RIG_EINVAL;
|
||||
|
@ -443,6 +463,7 @@ int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
|
||||
retval = icom_transaction(rig, lvl_cn, lvl_sc, NULL, 0,
|
||||
lvlbuf, &lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -463,15 +484,14 @@ int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
* (from_bcd is little endian)
|
||||
*/
|
||||
icom_val = from_bcd_be(lvlbuf + cmdhead, lvl_len * 2);
|
||||
}
|
||||
else /* level == RIG_LEVEL_AF */
|
||||
{
|
||||
} else { /* level == RIG_LEVEL_AF */
|
||||
retval = optoscan_get_status_block(rig, &status_block);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
icom_val = 0;
|
||||
|
||||
if (status_block.speaker_enabled == 1)
|
||||
icom_val = 255;
|
||||
}
|
||||
|
@ -480,6 +500,7 @@ int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
case RIG_LEVEL_RAWSTR:
|
||||
val->i = icom_val;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (RIG_LEVEL_IS_FLOAT(level))
|
||||
val->f = (float)icom_val / 255;
|
||||
|
@ -534,8 +555,7 @@ int optoscan_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch)
|
|||
if (state == NULL)
|
||||
return -RIG_EINTERNAL;
|
||||
|
||||
if(state->freq==0) /* pltstate_t is not initialized - perform setup */
|
||||
{
|
||||
if (state->freq == 0) { /* pltstate_t is not initialized - perform setup */
|
||||
/* time for CIV command to be sent. this is subtracted from */
|
||||
/* rcvr settle time */
|
||||
state->usleep_time = (1000000 / (rig->state.rigport.parm.serial.rate))
|
||||
|
@ -543,6 +563,7 @@ int optoscan_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch)
|
|||
|
||||
rc = cb(rig, vfo, &(state->next_freq), &(state->next_mode),
|
||||
&(state->next_width), rig->callbacks.pltune_arg);
|
||||
|
||||
if (rc == RIG_SCAN_STOP)
|
||||
return RIG_OK; /* callback halted loop */
|
||||
|
||||
|
@ -551,8 +572,8 @@ int optoscan_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch)
|
|||
}
|
||||
|
||||
rc = !RIG_SCAN_STOP;
|
||||
while(rc!=RIG_SCAN_STOP)
|
||||
{
|
||||
|
||||
while (rc != RIG_SCAN_STOP) {
|
||||
optoscan_RTS_toggle(rig); /*Step 3*/
|
||||
|
||||
state->freq = state->next_freq;
|
||||
|
@ -562,16 +583,16 @@ int optoscan_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch)
|
|||
|
||||
rc = cb(rig, vfo, &(state->next_freq), &(state->next_mode),
|
||||
&(state->next_width), rig->callbacks.pltune_arg);
|
||||
if(rc!=RIG_SCAN_STOP)
|
||||
{
|
||||
|
||||
if (rc != RIG_SCAN_STOP) {
|
||||
optoscan_send_freq(rig, state); /*Step 4*/
|
||||
}
|
||||
|
||||
optoscan_wait_timer(rig, state); /*Step 5*/
|
||||
|
||||
ser_get_car(&rs->rigport, &pin_state);
|
||||
if( pin_state ) /*Step 6*/
|
||||
{
|
||||
|
||||
if (pin_state) { /*Step 6*/
|
||||
return RIG_OK; /* we've broken squelch - return(). caller can */
|
||||
/* get current freq & mode out of state str */
|
||||
}
|
||||
|
@ -599,14 +620,15 @@ static int optoscan_get_status_block(RIG *rig, struct optostat *status_block)
|
|||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
switch( rig->caps->rig_model )
|
||||
{
|
||||
switch (rig->caps->rig_model) {
|
||||
case RIG_MODEL_OS456:
|
||||
expected_len = 4;
|
||||
break;
|
||||
|
||||
case RIG_MODEL_OS535:
|
||||
expected_len = 5;
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "optoscan_get_status_block: unknown rig model");
|
||||
return -RIG_ERJCTED;
|
||||
|
@ -620,15 +642,23 @@ static int optoscan_get_status_block(RIG *rig, struct optostat *status_block)
|
|||
}
|
||||
|
||||
if (ackbuf[2] & 1) status_block->remote_control = 1;
|
||||
|
||||
if (ackbuf[2] & 2) status_block->DTMF_pending = 1;
|
||||
|
||||
if (ackbuf[2] & 4) status_block->DTMF_overrun = 1;
|
||||
|
||||
if (ackbuf[2] & 16) status_block->squelch_open = 1;
|
||||
|
||||
if (ackbuf[2] & 32) status_block->CTCSS_active = 1;
|
||||
|
||||
if (ackbuf[2] & 64) status_block->DCS_active = 1;
|
||||
|
||||
if (ackbuf[3] & 1) status_block->tape_enabled = 1;
|
||||
|
||||
if (ackbuf[3] & 2) status_block->speaker_enabled = 1;
|
||||
|
||||
if (ackbuf[3] & 4) status_block->fivekhz_enabled = 1;
|
||||
|
||||
if (ackbuf[3] & 16) status_block->audio_present = 1;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "remote_control = %d\n", status_block->remote_control);
|
||||
|
@ -708,8 +738,7 @@ static int optoscan_wait_timer(RIG *rig, pltstate_t *state)
|
|||
usec_diff = abs((state->timer_current.tv_usec) -
|
||||
(state->timer_start.tv_usec));
|
||||
|
||||
if( usec_diff < settle_usec )
|
||||
{
|
||||
if (usec_diff < settle_usec) {
|
||||
usleep(settle_usec - usec_diff); /* sleep balance of settle_time */
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
# astylerc--custom options for astyle
|
||||
# Intended to follow the Linux style guide as closely as possible:
|
||||
# https://www.kernel.org/doc/Documentation/CodingStyle
|
||||
|
||||
# Linux kernel style formatting/indenting.
|
||||
style=linux
|
||||
|
||||
# Use tabs with a width of 8 spaces.
|
||||
indent=force-tab=8
|
||||
|
||||
# Pad empty lines around header blocks (e.g. 'if', 'for', 'while'...).
|
||||
break-blocks
|
||||
|
||||
# Remove extra space padding around parenthesis on the inside and outside.
|
||||
unpad-paren
|
||||
|
||||
# Insert space padding around operators.
|
||||
pad-oper
|
||||
|
||||
# Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...).
|
||||
pad-header
|
||||
|
||||
# Attach a pointer operator (*) to name (name) and reference operator (&)
|
||||
# to type (type).
|
||||
align-pointer=name
|
||||
align-reference=type
|
||||
|
||||
# Don't break one-line blocks.
|
||||
keep-one-line-blocks
|
||||
|
||||
# Don't break complex statements and multiple statements residing on a single line.
|
||||
keep-one-line-statements
|
|
@ -76,8 +76,7 @@
|
|||
* TODO: add an option to read from a file
|
||||
*/
|
||||
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:T:t:C:lLuovhV"
|
||||
static struct option long_options[] =
|
||||
{
|
||||
static struct option long_options[] = {
|
||||
{"model", 1, 0, 'm'},
|
||||
{"rig-file", 1, 0, 'r'},
|
||||
{"ptt-file", 1, 0, 'p'},
|
||||
|
@ -128,6 +127,7 @@ static void handle_error (enum rig_debug_level_e lvl, const char *msg)
|
|||
|
||||
lpMsgBuf = (LPVOID)"Unknown error";
|
||||
e = WSAGetLastError();
|
||||
|
||||
if (FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
|
@ -141,6 +141,7 @@ static void handle_error (enum rig_debug_level_e lvl, const char *msg)
|
|||
} else {
|
||||
rig_debug(lvl, "%s: Network error %d\n", msg, e);
|
||||
}
|
||||
|
||||
#else
|
||||
e = errno;
|
||||
rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, strerror(e));
|
||||
|
@ -177,6 +178,7 @@ int main (int argc, char *argv[])
|
|||
|
||||
c = getopt_long(argc, argv, SHORT_OPTIONS,
|
||||
long_options, &option_index);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
|
@ -184,42 +186,53 @@ int main (int argc, char *argv[])
|
|||
case 'h':
|
||||
usage();
|
||||
exit(0);
|
||||
|
||||
case 'V':
|
||||
version();
|
||||
exit(0);
|
||||
|
||||
case 'm':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
my_model = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
rig_file = optarg;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ptt_file = optarg;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dcd_file = optarg;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!strcmp(optarg, "RIG"))
|
||||
ptt_type = RIG_PTT_RIG;
|
||||
else if (!strcmp(optarg, "DTR"))
|
||||
|
@ -234,12 +247,15 @@ int main (int argc, char *argv[])
|
|||
ptt_type = RIG_PTT_NONE;
|
||||
else
|
||||
ptt_type = atoi(optarg);
|
||||
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!strcmp(optarg, "RIG"))
|
||||
dcd_type = RIG_DCD_RIG;
|
||||
else if (!strcmp(optarg, "DSR"))
|
||||
|
@ -254,59 +270,77 @@ int main (int argc, char *argv[])
|
|||
dcd_type = RIG_DCD_NONE;
|
||||
else
|
||||
dcd_type = atoi(optarg);
|
||||
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
civaddr = optarg;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
serial_rate = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (*conf_parms != '\0')
|
||||
strcat(conf_parms, ",");
|
||||
|
||||
strncat(conf_parms, optarg, MAXCONFLEN - strlen(conf_parms));
|
||||
break;
|
||||
|
||||
case 't':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
portno = optarg;
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
src_addr = optarg;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
vfo_mode++;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
show_conf++;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
list_models();
|
||||
exit(0);
|
||||
|
||||
case 'u':
|
||||
dump_caps_opt++;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(); /* unknown option? */
|
||||
exit(1);
|
||||
|
@ -343,15 +377,20 @@ int main (int argc, char *argv[])
|
|||
*/
|
||||
if (ptt_type != RIG_PTT_NONE)
|
||||
my_rig->state.pttport.type.ptt = ptt_type;
|
||||
|
||||
if (dcd_type != RIG_DCD_NONE)
|
||||
my_rig->state.dcdport.type.dcd = dcd_type;
|
||||
|
||||
if (ptt_file)
|
||||
strncpy(my_rig->state.pttport.pathname, ptt_file, FILPATHLEN - 1);
|
||||
|
||||
if (dcd_file)
|
||||
strncpy(my_rig->state.dcdport.pathname, dcd_file, FILPATHLEN - 1);
|
||||
|
||||
/* FIXME: bound checking and port type == serial */
|
||||
if (serial_rate != 0)
|
||||
my_rig->state.rigport.parm.serial.rate = serial_rate;
|
||||
|
||||
if (civaddr)
|
||||
rig_set_conf(my_rig, rig_token_lookup(my_rig, "civaddr"), civaddr);
|
||||
|
||||
|
@ -398,6 +437,7 @@ int main (int argc, char *argv[])
|
|||
# endif
|
||||
|
||||
WSADATA wsadata;
|
||||
|
||||
if (WSAStartup(MAKEWORD(1, 1), &wsadata) == SOCKET_ERROR) {
|
||||
fprintf(stderr, "WSAStartup socket error\n");
|
||||
exit(1);
|
||||
|
@ -417,15 +457,18 @@ int main (int argc, char *argv[])
|
|||
hints.ai_protocol = 0; /* Any protocol */
|
||||
|
||||
retcode = getaddrinfo(src_addr, portno, &hints, &result);
|
||||
|
||||
if (retcode != 0) {
|
||||
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(retcode));
|
||||
exit(2);
|
||||
}
|
||||
|
||||
saved_result = result;
|
||||
|
||||
do {
|
||||
sock_listen = socket(result->ai_family, result->ai_socktype,
|
||||
result->ai_protocol);
|
||||
|
||||
if (sock_listen < 0) {
|
||||
handle_error(RIG_DEBUG_ERR, "socket");
|
||||
freeaddrinfo(saved_result); /* No longer needed */
|
||||
|
@ -440,10 +483,12 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
#ifdef IPV6_V6ONLY
|
||||
|
||||
if (AF_INET6 == result->ai_family) {
|
||||
/* allow IPv4 mapped to IPv6 clients Windows and BSD default
|
||||
this to 1 (i.e. disallowed) and we prefer it off */
|
||||
sockopt = 0;
|
||||
|
||||
if (setsockopt(sock_listen, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
(char *)&sockopt, sizeof(sockopt)) < 0) {
|
||||
handle_error(RIG_DEBUG_ERR, "setsockopt");
|
||||
|
@ -451,6 +496,7 @@ int main (int argc, char *argv[])
|
|||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (0 == bind(sock_listen, result->ai_addr, result->ai_addrlen)) {
|
||||
|
@ -520,6 +566,7 @@ int main (int argc, char *argv[])
|
|||
rig_debug(RIG_DEBUG_ERR, "pthread_create: %s\n", strerror(retcode));
|
||||
break;
|
||||
}
|
||||
|
||||
#else
|
||||
handle_socket(arg);
|
||||
#endif
|
||||
|
@ -560,6 +607,7 @@ void * handle_socket(void *arg)
|
|||
#else
|
||||
fsockin = fdopen(handle_data_arg->sock, "rb");
|
||||
#endif
|
||||
|
||||
if (!fsockin) {
|
||||
rig_debug(RIG_DEBUG_ERR, "fdopen in: %s\n", strerror(errno));
|
||||
goto handle_exit;
|
||||
|
@ -570,6 +618,7 @@ void * handle_socket(void *arg)
|
|||
#else
|
||||
fsockout = fdopen(handle_data_arg->sock, "wb");
|
||||
#endif
|
||||
|
||||
if (!fsockout) {
|
||||
rig_debug(RIG_DEBUG_ERR, "fdopen out: %s\n", strerror(errno));
|
||||
fclose(fsockin);
|
||||
|
@ -579,6 +628,7 @@ void * handle_socket(void *arg)
|
|||
|
||||
do {
|
||||
retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0);
|
||||
|
||||
if (ferror(fsockin) || ferror(fsockout))
|
||||
retcode = 1;
|
||||
} while (retcode == 0 || retcode == 2);
|
||||
|
|
|
@ -83,8 +83,7 @@ void usage();
|
|||
* TODO: add an option to read from a file
|
||||
*/
|
||||
#define SHORT_OPTIONS "m:r:s:C:t:T:LuvhVl"
|
||||
static struct option long_options[] =
|
||||
{
|
||||
static struct option long_options[] = {
|
||||
{"model", 1, 0, 'm'},
|
||||
{"rot-file", 1, 0, 'r'},
|
||||
{"serial-speed", 1, 0, 's'},
|
||||
|
@ -133,6 +132,7 @@ static void handle_error (enum rig_debug_level_e lvl, const char *msg)
|
|||
} else {
|
||||
rig_debug(lvl, "%s: Network error %d\n", msg, e);
|
||||
}
|
||||
|
||||
#else
|
||||
e = errno;
|
||||
rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, strerror(e));
|
||||
|
@ -166,6 +166,7 @@ int main (int argc, char *argv[])
|
|||
|
||||
c = getopt_long(argc, argv, SHORT_OPTIONS,
|
||||
long_options, &option_index);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
|
@ -173,65 +174,84 @@ int main (int argc, char *argv[])
|
|||
case 'h':
|
||||
usage();
|
||||
exit(0);
|
||||
|
||||
case 'V':
|
||||
version();
|
||||
exit(0);
|
||||
|
||||
case 'm':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
my_model = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
rot_file = optarg;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
serial_rate = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (*conf_parms != '\0')
|
||||
strcat(conf_parms, ",");
|
||||
|
||||
strncat(conf_parms, optarg, MAXCONFLEN - strlen(conf_parms));
|
||||
break;
|
||||
|
||||
case 't':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
portno = optarg;
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
if (!optarg) {
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
src_addr = optarg;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
show_conf++;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
list_models();
|
||||
exit(0);
|
||||
|
||||
case 'u':
|
||||
dump_caps_opt++;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(); /* unknown option? */
|
||||
exit(1);
|
||||
|
@ -330,6 +350,7 @@ int main (int argc, char *argv[])
|
|||
hints.ai_protocol = 0; /* Any protocol */
|
||||
|
||||
retcode = getaddrinfo(src_addr, portno, &hints, &result);
|
||||
|
||||
if (retcode != 0) {
|
||||
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(retcode));
|
||||
exit(2);
|
||||
|
@ -355,6 +376,7 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
#ifdef IPV6_V6ONLY
|
||||
|
||||
if (AF_INET6 == result->ai_family) {
|
||||
/* allow IPv4 mapped to IPv6 clients, MS & BSD default this
|
||||
to 1 i.e. disallowed */
|
||||
|
@ -367,11 +389,13 @@ int main (int argc, char *argv[])
|
|||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (0 == bind(sock_listen, result->ai_addr, result->ai_addrlen)) {
|
||||
break;
|
||||
}
|
||||
|
||||
handle_error(RIG_DEBUG_WARN, "binding failed (trying next interface)");
|
||||
#ifdef __MINGW32__
|
||||
closesocket(sock_listen);
|
||||
|
@ -438,6 +462,7 @@ int main (int argc, char *argv[])
|
|||
rig_debug(RIG_DEBUG_ERR, "pthread_create: %s\n", strerror(retcode));
|
||||
break;
|
||||
}
|
||||
|
||||
#else
|
||||
handle_socket(arg);
|
||||
#endif
|
||||
|
@ -478,6 +503,7 @@ void * handle_socket(void *arg)
|
|||
#else
|
||||
fsockin = fdopen(handle_data_arg->sock, "rb");
|
||||
#endif
|
||||
|
||||
if (!fsockin) {
|
||||
rig_debug(RIG_DEBUG_ERR, "fdopen in: %s\n", strerror(errno));
|
||||
goto handle_exit;
|
||||
|
@ -488,6 +514,7 @@ void * handle_socket(void *arg)
|
|||
#else
|
||||
fsockout = fdopen(handle_data_arg->sock, "wb");
|
||||
#endif
|
||||
|
||||
if (!fsockout) {
|
||||
rig_debug(RIG_DEBUG_ERR, "fdopen out: %s\n", strerror(errno));
|
||||
fclose(fsockin);
|
||||
|
@ -496,6 +523,7 @@ void * handle_socket(void *arg)
|
|||
|
||||
do {
|
||||
retcode = rotctl_parse(handle_data_arg->rot, fsockin, fsockout, NULL, 0);
|
||||
|
||||
if (ferror(fsockin) || ferror(fsockout))
|
||||
retcode = 1;
|
||||
} while (retcode == 0 || retcode == 2);
|
||||
|
|
Ładowanie…
Reference in New Issue