kopia lustrzana https://github.com/Hamlib/Hamlib
astyle source code
rodzic
db1de6bfd2
commit
8c34ce1a2d
|
@ -127,7 +127,8 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
|
|||
|
||||
if (err != RIG_OK) { return err; }
|
||||
|
||||
len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";", 1, 0, 1);
|
||||
len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";",
|
||||
1, 0, 1);
|
||||
|
||||
if (len < 0) { return len; }
|
||||
}
|
||||
|
@ -141,7 +142,8 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
|
|||
if (response) // if response expected get it
|
||||
{
|
||||
response[0] = 0;
|
||||
len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";", 1, 0, 1);
|
||||
len = read_string(&rs->ampport, (unsigned char *) response, response_len, ";",
|
||||
1, 0, 1);
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
|
@ -167,7 +169,8 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
|
|||
|
||||
if (err != RIG_OK) { return err; }
|
||||
|
||||
len = read_string(&rs->ampport, (unsigned char *) responsebuf, KPABUFSZ, ";", 1, 0, 1);
|
||||
len = read_string(&rs->ampport, (unsigned char *) responsebuf, KPABUFSZ, ";", 1,
|
||||
0, 1);
|
||||
|
||||
if (len < 0) { return len; }
|
||||
}
|
||||
|
@ -370,7 +373,8 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
|
|||
//
|
||||
do
|
||||
{
|
||||
retval = read_string(&rs->ampport, (unsigned char *) responsebuf, sizeof(responsebuf), ";", 1, 0,
|
||||
retval = read_string(&rs->ampport, (unsigned char *) responsebuf,
|
||||
sizeof(responsebuf), ";", 1, 0,
|
||||
1);
|
||||
|
||||
if (retval != RIG_OK) { return retval; }
|
||||
|
@ -487,7 +491,8 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
|
|||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_ERR, "%s unknown fault from %s\n", __func__, responsebuf);
|
||||
SNPRINTF(priv->tmpbuf, sizeof(priv->tmpbuf), "Unknown fault code=0x%02x", fault);
|
||||
SNPRINTF(priv->tmpbuf, sizeof(priv->tmpbuf), "Unknown fault code=0x%02x",
|
||||
fault);
|
||||
val->s = priv->tmpbuf;
|
||||
return RIG_OK;
|
||||
|
||||
|
|
|
@ -6,13 +6,15 @@
|
|||
|
||||
static volatile long pipe_serial_nunber;
|
||||
|
||||
int async_pipe_create(hamlib_async_pipe_t **pipe_out, unsigned long pipe_buffer_size, unsigned long pipe_connect_timeout_millis)
|
||||
int async_pipe_create(hamlib_async_pipe_t **pipe_out,
|
||||
unsigned long pipe_buffer_size, unsigned long pipe_connect_timeout_millis)
|
||||
{
|
||||
DWORD error_code;
|
||||
CHAR pipe_name[MAX_PATH];
|
||||
hamlib_async_pipe_t *pipe;
|
||||
|
||||
pipe = calloc(1, sizeof(hamlib_async_pipe_t));
|
||||
|
||||
if (pipe == NULL)
|
||||
{
|
||||
return -RIG_ENOMEM;
|
||||
|
@ -108,6 +110,7 @@ void async_pipe_close(hamlib_async_pipe_t *pipe)
|
|||
CloseHandle(pipe->read);
|
||||
pipe->read = NULL;
|
||||
}
|
||||
|
||||
if (pipe->write != NULL)
|
||||
{
|
||||
CloseHandle(pipe->write);
|
||||
|
@ -119,6 +122,7 @@ void async_pipe_close(hamlib_async_pipe_t *pipe)
|
|||
CloseHandle(pipe->read_overlapped.hEvent);
|
||||
pipe->read_overlapped.hEvent = NULL;
|
||||
}
|
||||
|
||||
if (pipe->write_overlapped.hEvent != NULL)
|
||||
{
|
||||
CloseHandle(pipe->write_overlapped.hEvent);
|
||||
|
@ -128,9 +132,11 @@ void async_pipe_close(hamlib_async_pipe_t *pipe)
|
|||
free(pipe);
|
||||
}
|
||||
|
||||
ssize_t async_pipe_read(hamlib_async_pipe_t *pipe, void *buf, size_t count, int timeout)
|
||||
ssize_t async_pipe_read(hamlib_async_pipe_t *pipe, void *buf, size_t count,
|
||||
int timeout)
|
||||
{
|
||||
HANDLE event_handles[1] = {
|
||||
HANDLE event_handles[1] =
|
||||
{
|
||||
pipe->read_overlapped.hEvent,
|
||||
};
|
||||
HANDLE read_handle = pipe->read;
|
||||
|
@ -140,14 +146,17 @@ ssize_t async_pipe_read(hamlib_async_pipe_t *pipe, void *buf, size_t count, int
|
|||
ssize_t bytes_read;
|
||||
|
||||
result = ReadFile(read_handle, buf, count, NULL, overlapped);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
result = GetLastError();
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
// No error?
|
||||
break;
|
||||
|
||||
case ERROR_IO_PENDING:
|
||||
wait_result = WaitForMultipleObjects(1, event_handles, FALSE, timeout);
|
||||
|
||||
|
@ -172,30 +181,39 @@ ssize_t async_pipe_read(hamlib_async_pipe_t *pipe, void *buf, size_t count, int
|
|||
|
||||
default:
|
||||
result = GetLastError();
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: WaitForMultipleObjects() error: %d\n", __func__, result);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: WaitForMultipleObjects() error: %d\n", __func__,
|
||||
result);
|
||||
return -RIG_EINTERNAL;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: ReadFile() error: %d\n", __func__, result);
|
||||
return -RIG_EIO;
|
||||
}
|
||||
}
|
||||
|
||||
result = GetOverlappedResult(read_handle, overlapped, (LPDWORD) &bytes_read, FALSE);
|
||||
result = GetOverlappedResult(read_handle, overlapped, (LPDWORD) &bytes_read,
|
||||
FALSE);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
result = GetLastError();
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
// No error?
|
||||
break;
|
||||
|
||||
case ERROR_IO_PENDING:
|
||||
// Shouldn't happen?
|
||||
return -RIG_ETIMEOUT;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: GetOverlappedResult() error: %d\n", __func__, result);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: GetOverlappedResult() error: %d\n", __func__,
|
||||
result);
|
||||
return -RIG_EIO;
|
||||
}
|
||||
}
|
||||
|
@ -219,9 +237,11 @@ int async_pipe_wait_for_data(hamlib_async_pipe_t *pipe, int timeout)
|
|||
return result;
|
||||
}
|
||||
|
||||
ssize_t async_pipe_write(hamlib_async_pipe_t *pipe, const unsigned char *buf, size_t count, int timeout)
|
||||
ssize_t async_pipe_write(hamlib_async_pipe_t *pipe, const unsigned char *buf,
|
||||
size_t count, int timeout)
|
||||
{
|
||||
HANDLE event_handles[1] = {
|
||||
HANDLE event_handles[1] =
|
||||
{
|
||||
pipe->write_overlapped.hEvent,
|
||||
};
|
||||
HANDLE write_handle = pipe->write;
|
||||
|
@ -231,14 +251,17 @@ ssize_t async_pipe_write(hamlib_async_pipe_t *pipe, const unsigned char *buf, si
|
|||
ssize_t bytes_written;
|
||||
|
||||
result = WriteFile(write_handle, buf, count, NULL, overlapped);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
result = GetLastError();
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
// No error?
|
||||
break;
|
||||
|
||||
case ERROR_IO_PENDING:
|
||||
wait_result = WaitForMultipleObjects(1, event_handles, FALSE, timeout);
|
||||
|
||||
|
@ -253,30 +276,39 @@ ssize_t async_pipe_write(hamlib_async_pipe_t *pipe, const unsigned char *buf, si
|
|||
|
||||
default:
|
||||
result = GetLastError();
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: WaitForMultipleObjects() error: %d\n", __func__, result);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: WaitForMultipleObjects() error: %d\n", __func__,
|
||||
result);
|
||||
return -RIG_EINTERNAL;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: WriteFile() error: %d\n", __func__, result);
|
||||
return -RIG_EIO;
|
||||
}
|
||||
}
|
||||
|
||||
result = GetOverlappedResult(write_handle, overlapped, (LPDWORD) &bytes_written, FALSE);
|
||||
result = GetOverlappedResult(write_handle, overlapped, (LPDWORD) &bytes_written,
|
||||
FALSE);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
result = GetLastError();
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
// No error?
|
||||
break;
|
||||
|
||||
case ERROR_IO_PENDING:
|
||||
// Shouldn't happen?
|
||||
return -RIG_ETIMEOUT;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: GetOverlappedResult() error: %d\n", __func__, result);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: GetOverlappedResult() error: %d\n", __func__,
|
||||
result);
|
||||
return -RIG_EIO;
|
||||
}
|
||||
}
|
||||
|
|
1385
lib/cJSON.c
1385
lib/cJSON.c
Plik diff jest za duży
Load Diff
|
@ -1422,7 +1422,8 @@ int win32_serial_open(const char *filename, int flags, ...)
|
|||
|
||||
if (open_port(index))
|
||||
{
|
||||
SNPRINTF(message, sizeof(message), "serial_open(): Invalid Port Reference for %s\n",
|
||||
SNPRINTF(message, sizeof(message),
|
||||
"serial_open(): Invalid Port Reference for %s\n",
|
||||
fullfilename);
|
||||
report(message);
|
||||
win32_serial_close(index->fd);
|
||||
|
@ -2788,7 +2789,8 @@ int tcsetattr(int fd, int when, struct termios *s_termios)
|
|||
#ifdef DEBUG_VERBOSE
|
||||
{
|
||||
char message[32];
|
||||
SNPRINTF(message, sizeof(message), "VTIME:%d, VMIN:%d\n", s_termios->c_cc[VTIME],
|
||||
SNPRINTF(message, sizeof(message), "VTIME:%d, VMIN:%d\n",
|
||||
s_termios->c_cc[VTIME],
|
||||
s_termios->c_cc[VMIN]);
|
||||
report(message);
|
||||
}
|
||||
|
@ -3352,7 +3354,8 @@ int win32_serial_ioctl(int fd, int request, ...)
|
|||
report("DTR is unchanged\n");
|
||||
}
|
||||
|
||||
SNPRINTF(message, sizeof(message), "DTR %i %i\n", *arg & TIOCM_DTR, index->MSR & TIOCM_DTR);
|
||||
SNPRINTF(message, sizeof(message), "DTR %i %i\n", *arg & TIOCM_DTR,
|
||||
index->MSR & TIOCM_DTR);
|
||||
report(message);
|
||||
|
||||
if (*arg & TIOCM_DTR)
|
||||
|
@ -3380,7 +3383,8 @@ int win32_serial_ioctl(int fd, int request, ...)
|
|||
report("RTS is unchanged\n");
|
||||
}
|
||||
|
||||
SNPRINTF(message, sizeof(message), "RTS %i %i\n", *arg & TIOCM_RTS, index->MSR & TIOCM_RTS);
|
||||
SNPRINTF(message, sizeof(message), "RTS %i %i\n", *arg & TIOCM_RTS,
|
||||
index->MSR & TIOCM_RTS);
|
||||
report(message);
|
||||
|
||||
if (*arg & TIOCM_RTS)
|
||||
|
@ -3791,7 +3795,8 @@ int win32_serial_select(int n, fd_set *readfds, fd_set *writefds,
|
|||
|
||||
while (timeout_usec > 0)
|
||||
{
|
||||
SNPRINTF(message, sizeof(message), "wait for data in read buffer%d\n", (int)Stat.cbInQue);
|
||||
SNPRINTF(message, sizeof(message), "wait for data in read buffer%d\n",
|
||||
(int)Stat.cbInQue);
|
||||
report(message);
|
||||
|
||||
if (Stat.cbInQue != 0)
|
||||
|
@ -3938,7 +3943,8 @@ int win32_serial_select(int n, fd_set *readfds, fd_set *writefds,
|
|||
|
||||
if (GetLastError() != ERROR_IO_PENDING)
|
||||
{
|
||||
SNPRINTF(message, sizeof(message), "WaitCommEvent filename = %s\n", index->filename);
|
||||
SNPRINTF(message, sizeof(message), "WaitCommEvent filename = %s\n",
|
||||
index->filename);
|
||||
report(message);
|
||||
return (1);
|
||||
/*
|
||||
|
|
|
@ -1264,7 +1264,8 @@ int adat_send(RIG *pRig,
|
|||
|
||||
rig_flush(&pRigState->rigport);
|
||||
|
||||
nRC = write_block(&pRigState->rigport, (unsigned char *) pcData, strlen(pcData));
|
||||
nRC = write_block(&pRigState->rigport, (unsigned char *) pcData,
|
||||
strlen(pcData));
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"*** ADAT: %d %s (%s:%d): EXIT. Return Code = %d\n",
|
||||
|
|
|
@ -759,7 +759,8 @@ int dx77_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
|
|||
}
|
||||
|
||||
/* at least 6 digits */
|
||||
SNPRINTF(freqbuf, sizeof(freqbuf), AL CMD_TXFREQ "%06"PRIll EOM, (int64_t)tx_freq);
|
||||
SNPRINTF(freqbuf, sizeof(freqbuf), AL CMD_TXFREQ "%06"PRIll EOM,
|
||||
(int64_t)tx_freq);
|
||||
|
||||
retval = dx77_transaction(rig, freqbuf, strlen(freqbuf), NULL, NULL);
|
||||
|
||||
|
@ -1274,7 +1275,8 @@ int dx77_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
|
|||
|
||||
SNPRINTF((char *) tonebuf, sizeof(tonebuf), AL CMD_CTCSS "%02d" EOM, i + 1);
|
||||
|
||||
return dx77_transaction(rig, (char *) tonebuf, strlen((char*)tonebuf), NULL, NULL);
|
||||
return dx77_transaction(rig, (char *) tonebuf, strlen((char *)tonebuf), NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -353,7 +353,8 @@ int aor_get_vfo(RIG *rig, vfo_t *vfo)
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
int format8k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode, pbwidth_t width)
|
||||
int format8k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode,
|
||||
pbwidth_t width)
|
||||
{
|
||||
int aormode;
|
||||
|
||||
|
@ -1045,9 +1046,11 @@ int aor_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
|
|||
cmd_len += snprintf(aorcmd + cmd_len, sizeof(aorcmd) - cmd_len, " AU%d ST%06d ",
|
||||
0, (int)chan->tuning_step);
|
||||
|
||||
cmd_len += priv->format_mode(rig, aorcmd + cmd_len, sizeof(aorcmd) - cmd_len, chan->mode, chan->width);
|
||||
cmd_len += priv->format_mode(rig, aorcmd + cmd_len, sizeof(aorcmd) - cmd_len,
|
||||
chan->mode, chan->width);
|
||||
|
||||
cmd_len += snprintf(aorcmd + cmd_len, sizeof(aorcmd) - cmd_len, " AT%d TM%12s%s",
|
||||
cmd_len += snprintf(aorcmd + cmd_len, sizeof(aorcmd) - cmd_len,
|
||||
" AT%d TM%12s%s",
|
||||
chan->levels[LVL_ATT].i ? 1 : 0, chan->channel_desc, EOM);
|
||||
|
||||
return aor_transaction(rig, aorcmd, cmd_len, NULL, NULL);
|
||||
|
@ -1427,7 +1430,7 @@ int aor_get_chan_all_cb(RIG *rig, vfo_t vfo, chan_cb_t chan_cb, rig_ptr_t arg)
|
|||
* get next line
|
||||
*/
|
||||
retval = read_string(&rig->state.rigport, (unsigned char *) chanbuf, BUFSZ,
|
||||
EOM, strlen(EOM), 0,1);
|
||||
EOM, strlen(EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -58,7 +58,8 @@
|
|||
.funcs = RIG_FUNC_ABM, \
|
||||
}
|
||||
|
||||
static int format2700_mode(RIG *rig, char *buf, int buf_len, rmode_t mode, pbwidth_t width);
|
||||
static int format2700_mode(RIG *rig, char *buf, int buf_len, rmode_t mode,
|
||||
pbwidth_t width);
|
||||
static int parse2700_aor_mode(RIG *rig, char aormode, char aorwidth,
|
||||
rmode_t *mode, pbwidth_t *width);
|
||||
|
||||
|
@ -210,7 +211,8 @@ const struct rig_caps ar2700_caps =
|
|||
#define AR2700_NFM '1'
|
||||
#define AR2700_AM '2'
|
||||
|
||||
int format2700_mode(RIG *rig, char *buf, int buf_len, rmode_t mode, pbwidth_t width)
|
||||
int format2700_mode(RIG *rig, char *buf, int buf_len, rmode_t mode,
|
||||
pbwidth_t width)
|
||||
{
|
||||
int aormode;
|
||||
|
||||
|
|
|
@ -79,7 +79,8 @@
|
|||
}
|
||||
|
||||
|
||||
static int format5k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode, pbwidth_t width);
|
||||
static int format5k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode,
|
||||
pbwidth_t width);
|
||||
static int parse5k_aor_mode(RIG *rig, char aormode, char aorwidth,
|
||||
rmode_t *mode, pbwidth_t *width);
|
||||
|
||||
|
@ -398,7 +399,8 @@ const struct rig_caps ar5000a_caps =
|
|||
#define AR5K_SAL '6'
|
||||
#define AR5K_SAH '7'
|
||||
|
||||
int format5k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode, pbwidth_t width)
|
||||
int format5k_mode(RIG *rig, char *buf, int buf_len, rmode_t mode,
|
||||
pbwidth_t width)
|
||||
{
|
||||
int aormode;
|
||||
|
||||
|
|
|
@ -305,7 +305,8 @@ static int sr2200_transaction(RIG *rig, const char *cmd, int cmd_len,
|
|||
/*
|
||||
* Do wait for a reply
|
||||
*/
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM, strlen(EOM), 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM,
|
||||
strlen(EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -200,7 +200,7 @@ int barrett950_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
return retval;
|
||||
}
|
||||
|
||||
if (strstr(response,"E5"))
|
||||
if (strstr(response, "E5"))
|
||||
{
|
||||
freq_rx = freq_tx = 0;
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: new channel being programmed\n", __func__);
|
||||
|
@ -224,7 +224,8 @@ int barrett950_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
|
||||
// New freq so let's update the channel
|
||||
// We do not support split mode -- too many writes to EEPROM to support it
|
||||
SNPRINTF((char *) cmd_buf, sizeof(cmd_buf), "PC%04dR%08.0lfT%08.0lf", chan, freq, freq);
|
||||
SNPRINTF((char *) cmd_buf, sizeof(cmd_buf), "PC%04dR%08.0lfT%08.0lf", chan,
|
||||
freq, freq);
|
||||
retval = barrett_transaction(rig, cmd_buf, 0, &response);
|
||||
|
||||
if (retval != RIG_OK || strncmp(response, "OK", 2) != 0)
|
||||
|
|
|
@ -273,16 +273,20 @@ int barrett_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
rig_strvfo(vfo), freq);
|
||||
|
||||
retval = rig_get_freq(rig, vfo, &tfreq);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: get_freq failed: %s\n", __func__, strerror(retval));
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: get_freq failed: %s\n", __func__,
|
||||
strerror(retval));
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (tfreq == freq)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: freq not changing\n", __func__);
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
// If we are not explicitly asking for VFO_B then we'll set the receive side also
|
||||
if (vfo != RIG_VFO_B)
|
||||
{
|
||||
|
@ -423,11 +427,14 @@ int barrett_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: get_mode failed %s\n", __func__, strerror(retval));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: get_mode failed %s\n", __func__,
|
||||
strerror(retval));
|
||||
}
|
||||
|
||||
if (tmode == mode)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: already mode %s so not changing\n", __func__, rig_strrmode(mode));
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: already mode %s so not changing\n", __func__,
|
||||
rig_strrmode(mode));
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -302,7 +302,8 @@ int codan_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
rig_strvfo(vfo), freq);
|
||||
|
||||
// Purportedly can't do split so we just set VFOB=VFOA
|
||||
SNPRINTF(cmd_buf, sizeof(cmd_buf), "connect tcvr rf %.0f %.0f\rfreq", freq, freq);
|
||||
SNPRINTF(cmd_buf, sizeof(cmd_buf), "connect tcvr rf %.0f %.0f\rfreq", freq,
|
||||
freq);
|
||||
|
||||
char *response = NULL;
|
||||
retval = codan_transaction(rig, cmd_buf, 0, &response);
|
||||
|
@ -395,7 +396,8 @@ int codan_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: ptt=%d\n", __func__, ptt);
|
||||
|
||||
SNPRINTF(cmd_buf, sizeof(cmd_buf), "connect tcvr rf ptt %s\rptt", ptt == 0 ? "off" : "on");
|
||||
SNPRINTF(cmd_buf, sizeof(cmd_buf), "connect tcvr rf ptt %s\rptt",
|
||||
ptt == 0 ? "off" : "on");
|
||||
response = NULL;
|
||||
retval = codan_transaction(rig, cmd_buf, 0, &response);
|
||||
|
||||
|
|
|
@ -139,8 +139,10 @@ int drake_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
* 10Hz resolution
|
||||
* TODO: round nearest?
|
||||
*/
|
||||
SNPRINTF((char *) freqbuf, sizeof(freqbuf), "F%07u" EOM, (unsigned int)freq / 10);
|
||||
retval = drake_transaction(rig, (char *) freqbuf, strlen((char*)freqbuf), (char *) ackbuf,
|
||||
SNPRINTF((char *) freqbuf, sizeof(freqbuf), "F%07u" EOM,
|
||||
(unsigned int)freq / 10);
|
||||
retval = drake_transaction(rig, (char *) freqbuf, strlen((char *)freqbuf),
|
||||
(char *) ackbuf,
|
||||
&ack_len);
|
||||
|
||||
return retval;
|
||||
|
@ -226,7 +228,8 @@ int drake_set_vfo(RIG *rig, vfo_t vfo)
|
|||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "%c" EOM, vfo_function);
|
||||
}
|
||||
|
||||
retval = drake_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) ackbuf,
|
||||
retval = drake_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) ackbuf,
|
||||
&ack_len);
|
||||
return retval;
|
||||
}
|
||||
|
@ -313,7 +316,8 @@ int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
}
|
||||
|
||||
SNPRINTF((char *) mdbuf, sizeof(mdbuf), "M%c" EOM, mode_sel);
|
||||
retval = drake_transaction(rig, (char *) mdbuf, strlen((char*)mdbuf), (char *) ackbuf,
|
||||
retval = drake_transaction(rig, (char *) mdbuf, strlen((char *)mdbuf),
|
||||
(char *) ackbuf,
|
||||
&ack_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -354,7 +358,8 @@ int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
}
|
||||
|
||||
SNPRINTF((char *) mdbuf, sizeof(mdbuf), "W%c" EOM, width_sel);
|
||||
retval = drake_transaction(rig, (char *) mdbuf, strlen((char*)mdbuf), (char *) ackbuf,
|
||||
retval = drake_transaction(rig, (char *) mdbuf, strlen((char *)mdbuf),
|
||||
(char *) ackbuf,
|
||||
&ack_len);
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +372,8 @@ int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
((mode == RIG_MODE_AMS) || (mode == RIG_MODE_ECSSUSB)
|
||||
|| (mode == RIG_MODE_ECSSLSB))
|
||||
? 'O' : 'F');
|
||||
retval = drake_transaction(rig, (char *) mdbuf, strlen((char*)mdbuf), (char *) ackbuf,
|
||||
retval = drake_transaction(rig, (char *) mdbuf, strlen((char *)mdbuf),
|
||||
(char *) ackbuf,
|
||||
&ack_len);
|
||||
}
|
||||
|
||||
|
@ -493,7 +499,8 @@ int drake_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
|
|||
SNPRINTF((char *) buf, sizeof(buf), "A%c" EOM,
|
||||
ant == RIG_ANT_1 ? '1' : (ant == RIG_ANT_2 ? '2' : 'C'));
|
||||
|
||||
retval = drake_transaction(rig, (char *) buf, strlen((char*)buf), (char *) ackbuf, &ack_len);
|
||||
retval = drake_transaction(rig, (char *) buf, strlen((char *)buf),
|
||||
(char *) ackbuf, &ack_len);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -913,6 +920,7 @@ int drake_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
|||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
len = strlen(buf);
|
||||
retval = drake_transaction(rig, buf, len, buf[len - 1] == 0x0d ? ackbuf : NULL,
|
||||
&ack_len);
|
||||
|
|
|
@ -50,7 +50,8 @@ static int netampctl_transaction(AMP *amp, char *cmd, int len, char *buf)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n",
|
||||
sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -93,7 +94,8 @@ static int netampctl_open(AMP *amp)
|
|||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n",
|
||||
sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -102,7 +104,8 @@ static int netampctl_open(AMP *amp)
|
|||
|
||||
do
|
||||
{
|
||||
ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
ret = read_string(&->state.ampport, (unsigned char *) buf, BUF_MAX, "\n",
|
||||
sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret > 0)
|
||||
{
|
||||
|
|
|
@ -77,7 +77,8 @@ static int netrigctl_transaction(RIG *rig, char *cmd, int len, char *buf)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -308,14 +309,16 @@ static int netrigctl_open(RIG *rig)
|
|||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||
}
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -326,7 +329,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
for (i = 0; i < HAMLIB_FRQRANGESIZ; i++)
|
||||
{
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -356,7 +360,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
for (i = 0; i < HAMLIB_FRQRANGESIZ; i++)
|
||||
{
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -398,7 +403,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
for (i = 0; i < HAMLIB_TSLSTSIZ; i++)
|
||||
{
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -422,7 +428,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
for (i = 0; i < HAMLIB_FLTLSTSIZ; i++)
|
||||
{
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -449,7 +456,8 @@ static int netrigctl_open(RIG *rig)
|
|||
chan_t chan_list[HAMLIB_CHANLSTSIZ]; /*!< Channel list, zero ended */
|
||||
#endif
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -458,7 +466,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->max_rit = rs->max_rit = atol(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -467,7 +476,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->max_xit = rs->max_xit = atol(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -476,7 +486,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->max_ifshift = rs->max_ifshift = atol(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -485,7 +496,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rs->announces = atoi(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -512,7 +524,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->preamp[ret] = rs->preamp[ret] = RIG_DBLST_END;
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -539,7 +552,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->attenuator[ret] = rs->attenuator[ret] = RIG_DBLST_END;
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -548,7 +562,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->has_get_func = rs->has_get_func = strtoll(buf, NULL, 0);
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -557,7 +572,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->has_set_func = rs->has_set_func = strtoll(buf, NULL, 0);
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -579,7 +595,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
#endif
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -588,7 +605,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rig->caps->has_set_level = rs->has_set_level = strtoll(buf, NULL, 0);
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -597,7 +615,8 @@ static int netrigctl_open(RIG *rig)
|
|||
|
||||
rs->has_get_parm = strtoll(buf, NULL, 0);
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -640,7 +659,8 @@ static int netrigctl_open(RIG *rig)
|
|||
do
|
||||
{
|
||||
char setting[32], value[1024];
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
strtok(buf, "\r\n"); // chop the EOL
|
||||
|
||||
if (ret <= 0)
|
||||
|
@ -970,7 +990,8 @@ static int netrigctl_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
|
|||
|
||||
*mode = rig_parse_mode(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -1583,7 +1604,8 @@ static int netrigctl_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
|
|||
|
||||
*tx_mode = rig_parse_mode(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -1650,7 +1672,8 @@ static int netrigctl_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
|
|||
|
||||
*split = atoi(buf);
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -2172,7 +2195,8 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
|
|||
ret);
|
||||
}
|
||||
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1);
|
||||
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
||||
0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -2567,7 +2591,8 @@ static int netrigctl_mW2power(RIG *rig, float *power, unsigned int mwpower,
|
|||
|
||||
ENTERFUNC;
|
||||
|
||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\mW2power %u %.0f %s\n", mwpower, freq, rig_strrmode(mode));
|
||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\mW2power %u %.0f %s\n", mwpower, freq,
|
||||
rig_strrmode(mode));
|
||||
ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf);
|
||||
|
||||
if (ret <= 0)
|
||||
|
|
|
@ -55,7 +55,8 @@ static int netrotctl_transaction(ROT *rot, char *cmd, int len, char *buf)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
|
||||
sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -98,14 +99,16 @@ static int netrotctl_open(ROT *rot)
|
|||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
|
||||
sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
return (ret < 0) ? ret : -RIG_EPROTO;
|
||||
}
|
||||
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
|
||||
sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -114,7 +117,8 @@ static int netrotctl_open(ROT *rot)
|
|||
|
||||
rs->min_az = atof(buf);
|
||||
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
|
||||
sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -123,7 +127,8 @@ static int netrotctl_open(ROT *rot)
|
|||
|
||||
rs->max_az = atof(buf);
|
||||
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
|
||||
sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -132,7 +137,8 @@ static int netrotctl_open(ROT *rot)
|
|||
|
||||
rs->min_el = atof(buf);
|
||||
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
|
||||
sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
@ -196,7 +202,8 @@ static int netrotctl_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
|
|||
|
||||
*az = atof(buf);
|
||||
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1);
|
||||
ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n",
|
||||
sizeof("\n"), 0, 1);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
|
|
|
@ -261,10 +261,10 @@ static int check_vfo(vfo_t vfo)
|
|||
break; // will default to A in which_vfo
|
||||
|
||||
default:
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -509,7 +509,7 @@ static const char *modeMapGetTCI(rmode_t modeHamlib)
|
|||
static rmode_t modeMapGetHamlib(const char *modeTCI)
|
||||
{
|
||||
int i;
|
||||
char modeTCICheck[MAXBUFLEN+2];
|
||||
char modeTCICheck[MAXBUFLEN + 2];
|
||||
|
||||
SNPRINTF(modeTCICheck, sizeof(modeTCICheck), "|%s|", modeTCI);
|
||||
|
||||
|
@ -521,13 +521,13 @@ static rmode_t modeMapGetHamlib(const char *modeTCI)
|
|||
if (modeMap[i].mode_tci1x
|
||||
&& strcmp(modeMap[i].mode_tci1x, modeTCICheck) == 0)
|
||||
{
|
||||
return(modeMap[i].mode_hamlib);
|
||||
return (modeMap[i].mode_hamlib);
|
||||
}
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: mode requested: %s, not in modeMap\n", __func__,
|
||||
modeTCI);
|
||||
return(RIG_MODE_NONE);
|
||||
return (RIG_MODE_NONE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1196,7 +1196,8 @@ static int tci1x_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
|
||||
if (p) { *p = 0; } // remove any other pipe
|
||||
|
||||
SNPRINTF(cmd_arg, sizeof(cmd_arg), "<params><param><value>%s</value></param></params>", pttmode);
|
||||
SNPRINTF(cmd_arg, sizeof(cmd_arg),
|
||||
"<params><param><value>%s</value></param></params>", pttmode);
|
||||
free(ttmode);
|
||||
|
||||
if (!priv->has_get_modeA)
|
||||
|
@ -1252,7 +1253,8 @@ static int tci1x_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
// Need to update the bandwidth
|
||||
if (width > 0 && needBW)
|
||||
{
|
||||
SNPRINTF(cmd_arg, sizeof(cmd_arg), "<params><param><value><i4>%ld</i4></value></param></params>",
|
||||
SNPRINTF(cmd_arg, sizeof(cmd_arg),
|
||||
"<params><param><value><i4>%ld</i4></value></param></params>",
|
||||
width);
|
||||
|
||||
retval = tci1x_transaction(rig, "rig.set_bandwidth", cmd_arg, NULL, 0);
|
||||
|
@ -1489,7 +1491,8 @@ static int tci1x_set_vfo(RIG *rig, vfo_t vfo)
|
|||
vfo = rig->state.current_vfo;
|
||||
}
|
||||
|
||||
SNPRINTF(cmd_arg, sizeof(cmd_arg), "<params><param><value>%s</value></param></params>",
|
||||
SNPRINTF(cmd_arg, sizeof(cmd_arg),
|
||||
"<params><param><value>%s</value></param></params>",
|
||||
vfo == RIG_VFO_A ? "A" : "B");
|
||||
retval = tci1x_transaction(rig, "rig.set_AB", cmd_arg, NULL, 0);
|
||||
|
||||
|
@ -1507,7 +1510,8 @@ static int tci1x_set_vfo(RIG *rig, vfo_t vfo)
|
|||
/* so if we are in split and asked for A we have to turn split back on */
|
||||
if (priv->split && vfo == RIG_VFO_A)
|
||||
{
|
||||
SNPRINTF(cmd_arg, sizeof(cmd_arg), "<params><param><value><i4>%d</i4></value></param></params>",
|
||||
SNPRINTF(cmd_arg, sizeof(cmd_arg),
|
||||
"<params><param><value><i4>%d</i4></value></param></params>",
|
||||
priv->split);
|
||||
retval = tci1x_transaction(rig, "rig.set_split", cmd_arg, NULL, 0);
|
||||
|
||||
|
@ -1661,7 +1665,8 @@ static int tci1x_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
|||
RETURNFUNC(RIG_OK); // just return OK and ignore this
|
||||
}
|
||||
|
||||
SNPRINTF(cmd_arg, sizeof(cmd_arg), "<params><param><value><i4>%d</i4></value></param></params>",
|
||||
SNPRINTF(cmd_arg, sizeof(cmd_arg),
|
||||
"<params><param><value><i4>%d</i4></value></param></params>",
|
||||
split);
|
||||
retval = tci1x_transaction(rig, "rig.set_split", cmd_arg, NULL, 0);
|
||||
|
||||
|
|
|
@ -241,7 +241,8 @@ static int read_transaction(RIG *rig, char *response, int response_len)
|
|||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
|
||||
|
||||
len = read_string(&rs->rigport, (unsigned char *) response, response_len, delims,
|
||||
len = read_string(&rs->rigport, (unsigned char *) response, response_len,
|
||||
delims,
|
||||
strlen(delims), 0, 1);
|
||||
|
||||
if (len <= 0)
|
||||
|
|
|
@ -292,7 +292,8 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
|
|||
/*
|
||||
* Transceiver sends an echo of cmd followed by a CR/LF
|
||||
*/
|
||||
retval = read_string(&rs->rigport, (unsigned char *) respbuf, BUFSZ, LF, strlen(LF), 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) respbuf, BUFSZ, LF,
|
||||
strlen(LF), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
* NB: the frame array must be big enough to hold the frame.
|
||||
* The smallest frame is 6 bytes, the biggest is at least 13 bytes.
|
||||
*/
|
||||
int make_cmd_frame(unsigned char frame[], unsigned char re_id, unsigned char ctrl_id,
|
||||
int make_cmd_frame(unsigned char frame[], unsigned char re_id,
|
||||
unsigned char ctrl_id,
|
||||
unsigned char cmd, int subcmd,
|
||||
const unsigned char *data, int data_len)
|
||||
{
|
||||
|
@ -83,7 +84,7 @@ int make_cmd_frame(unsigned char frame[], unsigned char re_id, unsigned char ctr
|
|||
|
||||
frame[i++] = FI; /* EOM code */
|
||||
|
||||
return(i);
|
||||
return (i);
|
||||
}
|
||||
|
||||
int icom_frame_fix_preamble(int frame_len, unsigned char *frame)
|
||||
|
@ -101,7 +102,7 @@ int icom_frame_fix_preamble(int frame_len, unsigned char *frame)
|
|||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: invalid Icom CI-V frame, no preamble found\n",
|
||||
__func__);
|
||||
return(-RIG_EPROTO);
|
||||
return (-RIG_EPROTO);
|
||||
}
|
||||
|
||||
return frame_len;
|
||||
|
@ -196,16 +197,22 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd,
|
|||
set_transaction_inactive(rig);
|
||||
RETURNFUNC(-RIG_EPROTO);
|
||||
}
|
||||
|
||||
// we might have 0xfe string during rig wakeup
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: DEBUG retval=%d, frm_len=%d, cmd=0x%02x\n", __func__, retval, frm_len, cmd);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: DEBUG retval=%d, frm_len=%d, cmd=0x%02x\n",
|
||||
__func__, retval, frm_len, cmd);
|
||||
|
||||
if (retval != frm_len && cmd == C_SET_PWR)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: removing 0xfe power up echo, len=%d", __func__, frm_len);
|
||||
while(buf[2] == 0xfe)
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: removing 0xfe power up echo, len=%d", __func__,
|
||||
frm_len);
|
||||
|
||||
while (buf[2] == 0xfe)
|
||||
{
|
||||
memmove(buf,&buf[1],frm_len--);
|
||||
memmove(buf, &buf[1], frm_len--);
|
||||
}
|
||||
dump_hex(buf,frm_len);
|
||||
|
||||
dump_hex(buf, frm_len);
|
||||
}
|
||||
|
||||
switch (buf[retval - 1])
|
||||
|
@ -458,7 +465,8 @@ static const char icom_block_end[2] = { FI, COL};
|
|||
* TODO: strips padding/collisions
|
||||
* FIXME: check return codes/bytes read
|
||||
*/
|
||||
static int read_icom_frame_generic(hamlib_port_t *p, const unsigned char rxbuffer[],
|
||||
static int read_icom_frame_generic(hamlib_port_t *p,
|
||||
const unsigned char rxbuffer[],
|
||||
size_t rxbuffer_len, int direct)
|
||||
{
|
||||
int read = 0;
|
||||
|
@ -476,6 +484,7 @@ static int read_icom_frame_generic(hamlib_port_t *p, const unsigned char rxbuffe
|
|||
do
|
||||
{
|
||||
int i;
|
||||
|
||||
if (direct)
|
||||
{
|
||||
i = read_string_direct(p, rx_ptr, MAXFRAMELEN - read,
|
||||
|
@ -489,14 +498,14 @@ static int read_icom_frame_generic(hamlib_port_t *p, const unsigned char rxbuffe
|
|||
|
||||
if (i < 0 && i != RIG_BUSBUSY) /* die on errors */
|
||||
{
|
||||
return(i);
|
||||
return (i);
|
||||
}
|
||||
|
||||
if (i == 0) /* nothing read?*/
|
||||
{
|
||||
if (--retries <= 0) /* Tried enough times? */
|
||||
{
|
||||
return(read);
|
||||
return (read);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -510,7 +519,7 @@ static int read_icom_frame_generic(hamlib_port_t *p, const unsigned char rxbuffe
|
|||
while ((read < rxbuffer_len) && (rxbuffer[read - 1] != FI)
|
||||
&& (rxbuffer[read - 1] != COL));
|
||||
|
||||
return(read);
|
||||
return (read);
|
||||
}
|
||||
|
||||
int read_icom_frame(hamlib_port_t *p, const unsigned char rxbuffer[],
|
||||
|
|
|
@ -248,7 +248,8 @@ const char *ic92d_get_info(RIG *rig)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SNPRINTF(info, sizeof(info), "ID %02x%02x%02x\n", ackbuf[1], ackbuf[2], ackbuf[3]);
|
||||
SNPRINTF(info, sizeof(info), "ID %02x%02x%02x\n", ackbuf[1], ackbuf[2],
|
||||
ackbuf[3]);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
|
|
@ -754,8 +754,10 @@ int icom_get_usb_echo_off(RIG *rig)
|
|||
// we should have a freq response so we'll read it and don't really care
|
||||
// flushing doesn't always work as it depends on timing
|
||||
retval = read_icom_frame(&rs->rigport, buf, sizeof(buf));
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected, get freq retval=%d\n", __func__, retval);
|
||||
if (retval <= 0) RETURNFUNC(-RIG_ETIMEOUT);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected, get freq retval=%d\n",
|
||||
__func__, retval);
|
||||
|
||||
if (retval <= 0) { RETURNFUNC(-RIG_ETIMEOUT); }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -940,7 +942,8 @@ icom_rig_open(RIG *rig)
|
|||
retry_open:
|
||||
retval_echo = icom_get_usb_echo_off(rig);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: echo status result=%d\n", __func__, retval_echo);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: echo status result=%d\n", __func__,
|
||||
retval_echo);
|
||||
|
||||
if (retval_echo == 0 || retval_echo == 1)
|
||||
{
|
||||
|
@ -953,13 +956,15 @@ retry_open:
|
|||
|
||||
if (retval == RIG_OK) // then we know our echo status
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: echo status known, getting frequency\n", __func__);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: echo status known, getting frequency\n",
|
||||
__func__);
|
||||
rs->rigport.retry = 0;
|
||||
rig->state.current_vfo = icom_current_vfo(rig);
|
||||
// some rigs like the IC7100 still echo when in standby
|
||||
// so asking for freq now should timeout if such a rig
|
||||
freq_t tfreq;
|
||||
retval = rig_get_freq(rig, RIG_VFO_CURR, &tfreq);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: rig error getting frequency retry=%d, err=%s\n",
|
||||
|
@ -988,7 +993,8 @@ retry_open:
|
|||
|
||||
if (retval == RIG_ENIMPL || retval == RIG_ENAVAIL)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: rig_set_powerstat not implemented for rig\n", __func__);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: rig_set_powerstat not implemented for rig\n",
|
||||
__func__);
|
||||
RETURNFUNC(-RIG_ECONF);
|
||||
}
|
||||
|
||||
|
@ -2527,7 +2533,9 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
else
|
||||
{
|
||||
priv_data->filter = 0;
|
||||
if (mode_len == 2) priv_data->filter = modebuf[2];
|
||||
|
||||
if (mode_len == 2) { priv_data->filter = modebuf[2]; }
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: modebuf[0]=0x%02x, modebuf[1]=0x%02x, mode_len=%d\n", __func__, modebuf[0],
|
||||
modebuf[1], mode_len);
|
||||
|
@ -7181,6 +7189,7 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
|||
fct_cn = C_SET_VFO;
|
||||
fct_sc = S_DUAL;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIG_FUNC_SATMODE:
|
||||
|
@ -8735,7 +8744,8 @@ static int icom_parse_spectrum_frame(RIG *rig, size_t length,
|
|||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
int icom_is_async_frame(RIG *rig, size_t frame_length, const unsigned char *frame)
|
||||
int icom_is_async_frame(RIG *rig, size_t frame_length,
|
||||
const unsigned char *frame)
|
||||
{
|
||||
if (frame_length < ACKFRMLEN)
|
||||
{
|
||||
|
@ -8767,7 +8777,8 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
|
|||
*/
|
||||
switch (frame[4])
|
||||
{
|
||||
case C_SND_FREQ: {
|
||||
case C_SND_FREQ:
|
||||
{
|
||||
// TODO: The freq length might be less than 4 or 5 bytes on older rigs!
|
||||
// TODO: Disable cache timeout for frequency after first transceive packet once we figure out how to get active VFO reliably with transceive updates
|
||||
// TODO: rig_set_cache_timeout_ms(rig, HAMLIB_CACHE_FREQ, HAMLIB_CACHE_ALWAYS);
|
||||
|
@ -8790,6 +8801,7 @@ int icom_process_async_frame(RIG *rig, size_t frame_length,
|
|||
{
|
||||
icom_parse_spectrum_frame(rig, frame_length - (6 + 1), frame + 6);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -8873,7 +8885,8 @@ int icom_decode_event(RIG *rig)
|
|||
RETURNFUNC(icom_process_async_frame(rig, frm_len, buf));
|
||||
}
|
||||
|
||||
int icom_read_frame_direct(RIG *rig, size_t buffer_length, const unsigned char *buffer)
|
||||
int icom_read_frame_direct(RIG *rig, size_t buffer_length,
|
||||
const unsigned char *buffer)
|
||||
{
|
||||
return read_icom_frame_direct(&rig->state.rigport, buffer, buffer_length);
|
||||
}
|
||||
|
@ -9302,12 +9315,12 @@ DECLARE_PROBERIG_BACKEND(icom)
|
|||
|
||||
if (!port)
|
||||
{
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
if (port->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
port->write_delay = port->post_write_delay = 0;
|
||||
|
@ -9326,7 +9339,7 @@ DECLARE_PROBERIG_BACKEND(icom)
|
|||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -9365,7 +9378,7 @@ DECLARE_PROBERIG_BACKEND(icom)
|
|||
* is this a CI-V device?
|
||||
*/
|
||||
close(port->fd);
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
else if (buf[4] == NAK)
|
||||
{
|
||||
|
@ -9476,11 +9489,11 @@ DECLARE_PROBERIG_BACKEND(icom)
|
|||
*/
|
||||
if (model != RIG_MODEL_NONE)
|
||||
{
|
||||
return(model);
|
||||
return (model);
|
||||
}
|
||||
}
|
||||
|
||||
return(model);
|
||||
return (model);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -9578,5 +9591,5 @@ DECLARE_INITRIG_BACKEND(icom)
|
|||
rig_register(&x6100_caps);
|
||||
rig_register(&g90_caps);
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
|
|
@ -123,9 +123,11 @@ static int x108g_rig_open(RIG *rig)
|
|||
int retval;
|
||||
|
||||
retval = icom_rig_open(rig);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: rig_open failed with %s\n", __func__, rigerror(retval));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: rig_open failed with %s\n", __func__,
|
||||
rigerror(retval));
|
||||
RETURNFUNC(retval);
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,8 @@
|
|||
* Otherwise, you'll get a nice seg fault. You've been warned!
|
||||
* TODO: error case handling
|
||||
*/
|
||||
int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *data_len)
|
||||
int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||
int *data_len)
|
||||
{
|
||||
int retval;
|
||||
struct rig_state *rs;
|
||||
|
@ -90,7 +91,8 @@ int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *dat
|
|||
return 0;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM, strlen(EOM), 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM,
|
||||
strlen(EOM), 0, 1);
|
||||
|
||||
set_transaction_inactive(rig);
|
||||
|
||||
|
@ -295,7 +297,8 @@ int jrc_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
|
||||
// cppcheck-suppress *
|
||||
// suppressing bogus cppcheck error in ver 1.90
|
||||
SNPRINTF(freqbuf, sizeof(freqbuf), "F%0*"PRIll EOM, priv->max_freq_len, (int64_t)freq);
|
||||
SNPRINTF(freqbuf, sizeof(freqbuf), "F%0*"PRIll EOM, priv->max_freq_len,
|
||||
(int64_t)freq);
|
||||
|
||||
return jrc_transaction(rig, freqbuf, strlen(freqbuf), NULL, NULL);
|
||||
}
|
||||
|
@ -378,7 +381,8 @@ int jrc_set_vfo(RIG *rig, vfo_t vfo)
|
|||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "%c" EOM, vfo_function);
|
||||
|
||||
retval = jrc_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
retval = jrc_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -1430,7 +1434,8 @@ int jrc_set_chan(RIG *rig, vfo_t vfo, const channel_t *chan)
|
|||
return retval;
|
||||
}
|
||||
|
||||
SNPRINTF(cmdbuf + 7, sizeof(cmdbuf)-7, "%0*"PRIll, priv->max_freq_len, (int64_t)chan->freq);
|
||||
SNPRINTF(cmdbuf + 7, sizeof(cmdbuf) - 7, "%0*"PRIll, priv->max_freq_len,
|
||||
(int64_t)chan->freq);
|
||||
|
||||
if (priv->mem_len == 17)
|
||||
{
|
||||
|
@ -1447,7 +1452,8 @@ int jrc_set_chan(RIG *rig, vfo_t vfo, const channel_t *chan)
|
|||
}
|
||||
else
|
||||
{
|
||||
SNPRINTF(cmdbuf + priv->mem_len - 4, sizeof(cmdbuf)-(priv->mem_len - 4), "%03d",
|
||||
SNPRINTF(cmdbuf + priv->mem_len - 4, sizeof(cmdbuf) - (priv->mem_len - 4),
|
||||
"%03d",
|
||||
chan->levels[rig_setting2idx(RIG_LEVEL_AGC)].i);
|
||||
}
|
||||
|
||||
|
@ -1625,7 +1631,8 @@ int jrc_decode_event(RIG *rig)
|
|||
//#define SETUP_STATUS_LEN 17
|
||||
|
||||
//count = read_string(&rs->rigport, buf, SETUP_STATUS_LEN, "", 0);
|
||||
count = read_string(&rs->rigport, (unsigned char *) buf, priv->info_len, "", 0, 0, 1);
|
||||
count = read_string(&rs->rigport, (unsigned char *) buf, priv->info_len, "", 0,
|
||||
0, 1);
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
|
|
|
@ -387,7 +387,8 @@ static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
priv->freqA = freq;
|
||||
}
|
||||
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) freqbuf, strlen(freqbuf));
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) freqbuf,
|
||||
strlen(freqbuf));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -471,7 +472,8 @@ static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) modestr, strlen(modestr));
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) modestr,
|
||||
strlen(modestr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -533,8 +535,10 @@ static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
switch (level)
|
||||
{
|
||||
|
||||
case RIG_LEVEL_AGC: {
|
||||
char *cmd = val.i == RIG_AGC_SLOW ? "G0\r" : (val.i == RIG_AGC_FAST ? "G1\r" : "G2\r");
|
||||
case RIG_LEVEL_AGC:
|
||||
{
|
||||
char *cmd = val.i == RIG_AGC_SLOW ? "G0\r" : (val.i == RIG_AGC_FAST ? "G1\r" :
|
||||
"G2\r");
|
||||
return write_block(&rig->state.rigport, (unsigned char *) cmd, 3);
|
||||
}
|
||||
|
||||
|
@ -551,7 +555,8 @@ static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch)
|
|||
|
||||
SNPRINTF(membuf, sizeof(membuf), "C%03d\r", ch);
|
||||
|
||||
return write_block(&rig->state.rigport, (unsigned char *) membuf, strlen(membuf));
|
||||
return write_block(&rig->state.rigport, (unsigned char *) membuf,
|
||||
strlen(membuf));
|
||||
}
|
||||
|
||||
static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
||||
|
|
|
@ -167,7 +167,8 @@ static int nrd525_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
|
||||
SNPRINTF(freqbuf, sizeof(freqbuf), "F%08u", (unsigned)(freq / 10));
|
||||
|
||||
return write_block(&rig->state.rigport, (unsigned char *) freqbuf, strlen(freqbuf));
|
||||
return write_block(&rig->state.rigport, (unsigned char *) freqbuf,
|
||||
strlen(freqbuf));
|
||||
}
|
||||
|
||||
static int nrd525_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
|
@ -195,7 +196,8 @@ static int nrd525_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) modestr, strlen(modestr));
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) modestr,
|
||||
strlen(modestr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -219,11 +221,12 @@ static int nrd525_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
switch (level)
|
||||
{
|
||||
case RIG_LEVEL_ATT:
|
||||
return write_block(&rig->state.rigport, (unsigned char *) (val.i != 0 ? "A1" : "A0"), 2);
|
||||
return write_block(&rig->state.rigport,
|
||||
(unsigned char *)(val.i != 0 ? "A1" : "A0"), 2);
|
||||
|
||||
case RIG_LEVEL_AGC:
|
||||
return write_block(&rig->state.rigport,
|
||||
(unsigned char *) (val.i == RIG_AGC_SLOW ? "G0" :
|
||||
(unsigned char *)(val.i == RIG_AGC_SLOW ? "G0" :
|
||||
(val.i == RIG_AGC_FAST ? "G1" : "G2")), 2);
|
||||
|
||||
default:
|
||||
|
@ -237,7 +240,8 @@ static int nrd525_set_mem(RIG *rig, vfo_t vfo, int ch)
|
|||
|
||||
SNPRINTF(membuf, sizeof(membuf), "C%03d", ch);
|
||||
|
||||
return write_block(&rig->state.rigport, (unsigned char *) membuf, strlen(membuf));
|
||||
return write_block(&rig->state.rigport, (unsigned char *) membuf,
|
||||
strlen(membuf));
|
||||
}
|
||||
|
||||
static int nrd525_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
||||
|
|
|
@ -101,13 +101,15 @@ transaction:
|
|||
char buffer[50];
|
||||
struct kenwood_priv_data *priv = rig->state.priv;
|
||||
|
||||
if (RIG_OK != (retval = write_block(&rs->rigport, (unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd))))
|
||||
if (RIG_OK != (retval = write_block(&rs->rigport,
|
||||
(unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd))))
|
||||
{
|
||||
return retval;
|
||||
}
|
||||
|
||||
// this should be the ID response
|
||||
retval = read_string(&rs->rigport, (unsigned char *) buffer, sizeof(buffer), ";", 1, 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) buffer, sizeof(buffer),
|
||||
";", 1, 0, 1);
|
||||
|
||||
// might be ?; too
|
||||
if (buffer[0] == '?' && retry_cmd++ < rs->rigport.retry)
|
||||
|
@ -468,7 +470,8 @@ int ic10_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
}
|
||||
|
||||
// cppcheck-suppress *
|
||||
SNPRINTF(freqbuf, sizeof(freqbuf), "F%c%011"PRIll";", vfo_letter, (int64_t)freq);
|
||||
SNPRINTF(freqbuf, sizeof(freqbuf), "F%c%011"PRIll";", vfo_letter,
|
||||
(int64_t)freq);
|
||||
retval = ic10_transaction(rig, freqbuf, strlen(freqbuf), NULL, 0);
|
||||
|
||||
return retval;
|
||||
|
|
|
@ -357,7 +357,8 @@ transaction_write:
|
|||
/* no reply expected so we need to write a command that always
|
||||
gives a reply so we can read any error replies from the actual
|
||||
command being sent without blocking */
|
||||
if (RIG_OK != (retval = write_block(&rs->rigport, (unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd))))
|
||||
if (RIG_OK != (retval = write_block(&rs->rigport,
|
||||
(unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd))))
|
||||
{
|
||||
goto transaction_quit;
|
||||
}
|
||||
|
@ -659,10 +660,10 @@ rmode_t kenwood2rmode(unsigned char mode, const rmode_t mode_table[])
|
|||
|
||||
if (mode >= KENWOOD_MODE_TABLE_MAX)
|
||||
{
|
||||
return(RIG_MODE_NONE);
|
||||
return (RIG_MODE_NONE);
|
||||
}
|
||||
|
||||
return(mode_table[mode]);
|
||||
return (mode_table[mode]);
|
||||
}
|
||||
|
||||
char rmode2kenwood(rmode_t mode, const rmode_t mode_table[])
|
||||
|
@ -679,12 +680,12 @@ char rmode2kenwood(rmode_t mode, const rmode_t mode_table[])
|
|||
if (mode_table[i] == mode)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: returning %d\n", __func__, i);
|
||||
return(i);
|
||||
return (i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int kenwood_init(RIG *rig)
|
||||
|
@ -1317,7 +1318,7 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
|
|||
|
||||
if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; }
|
||||
|
||||
if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) vfo = vfo_fixup(rig, vfo, split);
|
||||
if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) { vfo = vfo_fixup(rig, vfo, split); }
|
||||
|
||||
switch (vfo)
|
||||
{
|
||||
|
@ -1666,7 +1667,8 @@ int kenwood_get_vfo_if(RIG *rig, vfo_t *vfo)
|
|||
switch (priv->info[30])
|
||||
{
|
||||
case '0':
|
||||
*vfo = rig->state.rx_vfo = rig->state.tx_vfo = priv->tx_vfo = split_and_transmitting ? RIG_VFO_B : RIG_VFO_A;
|
||||
*vfo = rig->state.rx_vfo = rig->state.tx_vfo = priv->tx_vfo =
|
||||
split_and_transmitting ? RIG_VFO_B : RIG_VFO_A;
|
||||
|
||||
if (priv->info[32] == '1') { priv->tx_vfo = RIG_VFO_B; }
|
||||
|
||||
|
@ -2467,7 +2469,8 @@ static int kenwood_get_filter_width(RIG *rig, rmode_t mode, pbwidth_t *width)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (filter_value >=50) // then it's probably a custom filter width
|
||||
|
||||
if (filter_value >= 50) // then it's probably a custom filter width
|
||||
{
|
||||
*width = filter_value;
|
||||
return (RIG_OK);
|
||||
|
@ -2699,7 +2702,8 @@ static int kenwood_get_micgain_minmax(RIG *rig, int *micgain_now,
|
|||
|
||||
if (retval != RIG_OK) { RETURNFUNC(retval); }
|
||||
|
||||
retval = read_string(&rs->rigport, (unsigned char *) levelbuf, sizeof(levelbuf), NULL, 0, 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) levelbuf, sizeof(levelbuf),
|
||||
NULL, 0, 0, 1);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval);
|
||||
|
||||
|
@ -2798,7 +2802,8 @@ static int kenwood_get_power_minmax(RIG *rig, int *power_now, int *power_min,
|
|||
|
||||
if (retval != RIG_OK) { RETURNFUNC(retval); }
|
||||
|
||||
retval = read_string(&rs->rigport, (unsigned char *) levelbuf, sizeof(levelbuf), NULL, 0, 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) levelbuf, sizeof(levelbuf),
|
||||
NULL, 0, 0, 1);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval);
|
||||
|
||||
|
@ -5432,12 +5437,12 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
|
||||
if (!port)
|
||||
{
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
if (port->type.rig != RIG_PORT_SERIAL)
|
||||
{
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
port->write_delay = port->post_write_delay = 0;
|
||||
|
@ -5458,7 +5463,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
{
|
||||
port->write_delay = write_delay;
|
||||
port->retry = retry;
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
retval = write_block(port, (unsigned char *) "ID;", 3);
|
||||
|
@ -5475,7 +5480,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
{
|
||||
port->write_delay = write_delay;
|
||||
port->retry = retry;
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -5489,7 +5494,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
6, id_len, idbuf);
|
||||
port->write_delay = write_delay;
|
||||
port->retry = retry;
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5508,7 +5513,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
|
||||
port->write_delay = write_delay;
|
||||
port->retry = retry;
|
||||
return(kenwood_id_string_list[i].model);
|
||||
return (kenwood_id_string_list[i].model);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5525,7 +5530,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
retval = write_block(port, (unsigned char *) "K2;", 3);
|
||||
|
@ -5534,7 +5539,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -5549,7 +5554,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
(*cfunc)(port, RIG_MODEL_K2, data);
|
||||
}
|
||||
|
||||
return(RIG_MODEL_K2);
|
||||
return (RIG_MODEL_K2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5565,7 +5570,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
(*cfunc)(port, kenwood_id_list[i].model, data);
|
||||
}
|
||||
|
||||
return(kenwood_id_list[i].model);
|
||||
return (kenwood_id_list[i].model);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5579,7 +5584,7 @@ DECLARE_PROBERIG_BACKEND(kenwood)
|
|||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: post_write_delay=%d\n", __func__,
|
||||
port->post_write_delay);
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5645,5 +5650,5 @@ DECLARE_INITRIG_BACKEND(kenwood)
|
|||
rig_register(&malachite_caps);
|
||||
rig_register(&tx500_caps);
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
|
|
@ -1979,7 +1979,8 @@ int th_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
|
|||
else
|
||||
{
|
||||
SNPRINTF(req, sizeof(req), "MR %s0,PR%01d", mr_extra, channel_num + 1);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "Pr%01d", channel_num + 1);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "Pr%01d",
|
||||
channel_num + 1);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1995,7 +1996,8 @@ int th_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
|
|||
|
||||
case RIG_MTYPE_BAND:
|
||||
SNPRINTF(req, sizeof(req), "VR %01X", channel_num);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "BAND %01X", channel_num);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "BAND %01X",
|
||||
channel_num);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2433,7 +2435,8 @@ int th_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
|
|||
{
|
||||
|
||||
/* Without DCS,mode */
|
||||
SNPRINTF(membuf, sizeof(membuf), "%s,%011"PRIll",%X,%d,%d,%d,%d,,%02d,,%02d,%09"PRIll"%s",
|
||||
SNPRINTF(membuf, sizeof(membuf),
|
||||
"%s,%011"PRIll",%X,%d,%d,%d,%d,,%02d,,%02d,%09"PRIll"%s",
|
||||
req, (int64_t)chan->freq, step, shift, rev, tone,
|
||||
ctcss, tonefq, ctcssfq,
|
||||
(int64_t)labs((long)(chan->rptr_offs)), lockoutstr
|
||||
|
@ -2455,7 +2458,8 @@ int th_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
|
|||
|
||||
req[3 + strlen(mr_extra)] = '1';
|
||||
|
||||
SNPRINTF(membuf, sizeof(membuf), "%s,%011"PRIll",%X", req, (int64_t)chan->tx_freq, step);
|
||||
SNPRINTF(membuf, sizeof(membuf), "%s,%011"PRIll",%X", req,
|
||||
(int64_t)chan->tx_freq, step);
|
||||
retval = kenwood_transaction(rig, membuf, membuf, sizeof(membuf));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -2470,11 +2474,13 @@ int th_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
|
|||
/* TODO: check strlen(channel_desc) < rig->caps->chan_desc_sz */
|
||||
if (chan_caps[1].type == RIG_MTYPE_PRIO)
|
||||
{
|
||||
SNPRINTF(membuf, sizeof(membuf), "MNA %sI-%01d,%s", mr_extra, channel_num, channel_desc);
|
||||
SNPRINTF(membuf, sizeof(membuf), "MNA %sI-%01d,%s", mr_extra, channel_num,
|
||||
channel_desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
SNPRINTF(membuf, sizeof(membuf), "MNA %s%03d,%s", mr_extra, channel_num, channel_desc);
|
||||
SNPRINTF(membuf, sizeof(membuf), "MNA %s%03d,%s", mr_extra, channel_num,
|
||||
channel_desc);
|
||||
}
|
||||
|
||||
retval = kenwood_transaction(rig, membuf, membuf, sizeof(membuf));
|
||||
|
|
|
@ -420,7 +420,7 @@ int tmv7_set_vfo(RIG *rig, vfo_t vfo)
|
|||
break;
|
||||
|
||||
case RIG_VFO_B:
|
||||
SNPRINTF(vfobuf, sizeof(vfobuf),"BC 1,1");
|
||||
SNPRINTF(vfobuf, sizeof(vfobuf), "BC 1,1");
|
||||
break;
|
||||
|
||||
case RIG_VFO_MEM:
|
||||
|
@ -515,22 +515,26 @@ int tmv7_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only)
|
|||
else if (chan->channel_num < 204)
|
||||
{
|
||||
SNPRINTF(req, sizeof(req), "MR 0,0,L%01d", chan->channel_num - 200);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "L%01d/V", chan->channel_num - 200);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "L%01d/V",
|
||||
chan->channel_num - 200);
|
||||
}
|
||||
else if (chan->channel_num < 211)
|
||||
{
|
||||
SNPRINTF(req, sizeof(req), "MR 1,0,L%01d", chan->channel_num - 203);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "L%01d/U", chan->channel_num - 203);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "L%01d/U",
|
||||
chan->channel_num - 203);
|
||||
}
|
||||
else if (chan->channel_num < 214)
|
||||
{
|
||||
SNPRINTF(req, sizeof(req), "MR 0,0,U%01d", chan->channel_num - 210);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "U%01d/V", chan->channel_num - 210);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "U%01d/V",
|
||||
chan->channel_num - 210);
|
||||
}
|
||||
else if (chan->channel_num < 220)
|
||||
{
|
||||
SNPRINTF(req, sizeof(req), "MR 1,0,U%01d", chan->channel_num - 213);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "U%01d/U", chan->channel_num - 213);
|
||||
SNPRINTF(chan->channel_desc, sizeof(chan->channel_desc), "U%01d/U",
|
||||
chan->channel_num - 213);
|
||||
}
|
||||
else if (chan->channel_num < 223)
|
||||
{
|
||||
|
@ -775,13 +779,15 @@ int tmv7_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
|
|||
|
||||
if (chan->channel_num < 221)
|
||||
{
|
||||
SNPRINTF(membuf, sizeof(membuf), "%s,%011ld,%01d,%01d,0,%01d,%01d,0,%02d,000,%02d,0,0",
|
||||
SNPRINTF(membuf, sizeof(membuf),
|
||||
"%s,%011ld,%01d,%01d,0,%01d,%01d,0,%02d,000,%02d,0,0",
|
||||
req, (long)freq, step, shift, tone,
|
||||
ctcss, tonefq, ctcssfq);
|
||||
}
|
||||
else
|
||||
{
|
||||
SNPRINTF(membuf, sizeof(membuf), "%s,%011ld,%01d,%01d,0,%01d,%01d,0,%02d,000,%02d,",
|
||||
SNPRINTF(membuf, sizeof(membuf),
|
||||
"%s,%011ld,%01d,%01d,0,%01d,%01d,0,%02d,000,%02d,",
|
||||
req, (long)freq, step, shift, tone,
|
||||
ctcss, tonefq, ctcssfq);
|
||||
}
|
||||
|
@ -797,7 +803,8 @@ int tmv7_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
|
|||
{
|
||||
req[5] = '1';
|
||||
// cppcheck-suppress *
|
||||
SNPRINTF(membuf, sizeof(membuf), "%s,%011"PRIll",%01d", req, (int64_t)chan->tx_freq, step);
|
||||
SNPRINTF(membuf, sizeof(membuf), "%s,%011"PRIll",%01d", req,
|
||||
(int64_t)chan->tx_freq, step);
|
||||
retval = kenwood_transaction(rig, membuf, NULL, 0);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -810,11 +817,13 @@ int tmv7_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
|
|||
{
|
||||
if (chan->channel_num < 100)
|
||||
{
|
||||
SNPRINTF(membuf, sizeof(membuf), "MNA 0,%03d,%s", chan->channel_num, chan->channel_desc);
|
||||
SNPRINTF(membuf, sizeof(membuf), "MNA 0,%03d,%s", chan->channel_num,
|
||||
chan->channel_desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
SNPRINTF(membuf, sizeof(membuf), "MNA 1,%03d,%s", chan->channel_num - 100, chan->channel_desc);
|
||||
SNPRINTF(membuf, sizeof(membuf), "MNA 1,%03d,%s", chan->channel_num - 100,
|
||||
chan->channel_desc);
|
||||
}
|
||||
|
||||
retval = kenwood_transaction(rig, membuf, NULL, 0);
|
||||
|
|
|
@ -440,7 +440,8 @@ static int ts480_read_meters(RIG *rig, int *swr, int *comp, int *alc)
|
|||
|
||||
// TS-480 returns values for all meters at the same time, for example: RM10000;RM20000;RM30000;
|
||||
|
||||
retval = read_string(&rs->rigport, (unsigned char *) ackbuf, expected_len + 1, NULL, 0, 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) ackbuf, expected_len + 1,
|
||||
NULL, 0, 0, 1);
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: read_string retval=%d\n", __func__, retval);
|
||||
|
||||
|
|
|
@ -592,6 +592,7 @@ int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
__func__, lvlbuf[2]);
|
||||
RETURNFUNC(-RIG_EPROTO);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
||||
case RIG_LEVEL_ATT:
|
||||
|
@ -617,6 +618,7 @@ int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
__func__, lvlbuf[2]);
|
||||
RETURNFUNC(-RIG_EPROTO);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
||||
case RIG_LEVEL_RAWSTR:
|
||||
|
|
|
@ -196,14 +196,17 @@ static int send_command(RIG *rig)
|
|||
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, CTRL_FRAME_LEN);
|
||||
ret = write_block(&rig->state.rigport, (unsigned char *) priv->control_frame,
|
||||
CTRL_FRAME_LEN);
|
||||
#if 0
|
||||
ret = read_block(&rig->state.rigport, (unsigned char *) priv->control_frame, CTRL_FRAME_LEN);
|
||||
ret = read_block(&rig->state.rigport, (unsigned char *) priv->control_frame,
|
||||
CTRL_FRAME_LEN);
|
||||
|
||||
if (ret != CTRL_FRAME_LEN)
|
||||
{
|
||||
ret = ret < 0 ? ret : -RIG_EPROTO;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -46,9 +46,11 @@ static int miniVNA_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
|
||||
rig_flush(&rig->state.rigport);
|
||||
|
||||
SNPRINTF(cmdstr, sizeof(cmdstr), "0\r%lu\r1\r0\r", (unsigned long int)(freq * DDS_RATIO));
|
||||
SNPRINTF(cmdstr, sizeof(cmdstr), "0\r%lu\r1\r0\r",
|
||||
(unsigned long int)(freq * DDS_RATIO));
|
||||
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -93,7 +93,8 @@ static int rshfiq_open(RIG *rig)
|
|||
rig_flush(&rig->state.rigport);
|
||||
SNPRINTF(versionstr, sizeof(versionstr), "*w\r");
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, versionstr);
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) versionstr, strlen(versionstr));
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) versionstr,
|
||||
strlen(versionstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -160,7 +161,8 @@ static int rshfiq_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
|
||||
SNPRINTF(cmdstr, sizeof(cmdstr), "*f%lu\r", (unsigned long int)(freq));
|
||||
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -183,7 +185,8 @@ static int rshfiq_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, cmdstr);
|
||||
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -232,7 +235,8 @@ static int rshfiq_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, cmdstr);
|
||||
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -266,7 +270,8 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
|
||||
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER command=%s\n", cmdstr);
|
||||
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -305,7 +310,8 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
|
||||
rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER command=%s\n", cmdstr);
|
||||
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
retval = write_block(&rig->state.rigport, (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -1102,7 +1102,8 @@ const char *si570xxxusb_get_info(RIG *rig)
|
|||
/* always succeeds since libusb-1.0.16 */
|
||||
libusb_get_device_descriptor(libusb_get_device(udh), &desc);
|
||||
|
||||
SNPRINTF(buf, sizeof(buf), "USB dev %04d, version: %d.%d", desc.bcdDevice, buffer[1],
|
||||
SNPRINTF(buf, sizeof(buf), "USB dev %04d, version: %d.%d", desc.bcdDevice,
|
||||
buffer[1],
|
||||
buffer[0]);
|
||||
|
||||
return buf;
|
||||
|
|
|
@ -168,7 +168,8 @@ static int read_prompt_and_send(hamlib_port_t *rigport,
|
|||
|
||||
buflen = (data_len == NULL) ? sizeof(buf) : *data_len;
|
||||
|
||||
retval = read_string(rigport, (unsigned char *) data, buflen, delimiter, 1, 0, 1);
|
||||
retval = read_string(rigport, (unsigned char *) data, buflen, delimiter, 1, 0,
|
||||
1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -644,7 +645,7 @@ static int prm80_do_read_system_state(hamlib_port_t *rigport, char *statebuf)
|
|||
|
||||
if (ret < 0)
|
||||
{
|
||||
return(ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
// The response length is fixed
|
||||
|
@ -664,7 +665,7 @@ static int prm80_do_read_system_state(hamlib_port_t *rigport, char *statebuf)
|
|||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: len=%d < %d, statebuf='%s'\n", __func__,
|
||||
ret, CMD_E_RSP_LEN, statebuf);
|
||||
return(-RIG_EPROTO);
|
||||
return (-RIG_EPROTO);
|
||||
}
|
||||
|
||||
p = strchr(statebuf, '>');
|
||||
|
@ -673,7 +674,8 @@ static int prm80_do_read_system_state(hamlib_port_t *rigport, char *statebuf)
|
|||
{
|
||||
int left_to_read = (p - statebuf) + 1;
|
||||
memmove(statebuf, p + 1, CMD_E_RSP_LEN - left_to_read);
|
||||
ret = read_block(rigport, (unsigned char *) statebuf + CMD_E_RSP_LEN - left_to_read,
|
||||
ret = read_block(rigport,
|
||||
(unsigned char *) statebuf + CMD_E_RSP_LEN - left_to_read,
|
||||
left_to_read);
|
||||
|
||||
if (ret < 0)
|
||||
|
@ -908,7 +910,8 @@ int prm80_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
|
|||
if (ret == 3 && buf[2] == 'T')
|
||||
{
|
||||
// Read the question
|
||||
ret = read_string(&rs->rigport, (unsigned char *) buf, sizeof(buf), "?", 1, 0, 1);
|
||||
ret = read_string(&rs->rigport, (unsigned char *) buf, sizeof(buf), "?", 1, 0,
|
||||
1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
|
@ -119,7 +119,8 @@ static int ra37xx_one_transaction(RIG *rig, const char *cmd, char *data,
|
|||
|
||||
do
|
||||
{
|
||||
retval = read_string(&rs->rigport, (unsigned char *) respbuf, BUFSZ, EOM, strlen(EOM), 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) respbuf, BUFSZ, EOM,
|
||||
strlen(EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -578,7 +579,8 @@ int ra37xx_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
default: return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "AGC%d,%d", val.i == RIG_AGC_USER ? 1 : 0, agc);
|
||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "AGC%d,%d", val.i == RIG_AGC_USER ? 1 : 0,
|
||||
agc);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -97,7 +97,8 @@ static int racal_transaction(RIG *rig, const char *cmd, char *data,
|
|||
return retval;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM, strlen(EOM), 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM,
|
||||
strlen(EOM), 0, 1);
|
||||
|
||||
if (retval <= 0)
|
||||
{
|
||||
|
|
|
@ -86,7 +86,8 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len,
|
|||
* Transceiver sends back ">"
|
||||
*/
|
||||
char retbuf[BUFSZ + 1];
|
||||
retval = read_string(&rs->rigport, (unsigned char *) retbuf, BUFSZ, PROMPT, strlen(PROMPT), 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) retbuf, BUFSZ, PROMPT,
|
||||
strlen(PROMPT), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
@ -105,7 +106,8 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len,
|
|||
}
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, LF, strlen(LF), 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, LF,
|
||||
strlen(LF), 0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
|
|
@ -447,6 +447,7 @@ int cu_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
|
|||
int cu_set_parm(RIG *rig, setting_t parm, value_t val)
|
||||
{
|
||||
char cmdbuf[16];
|
||||
|
||||
switch (parm)
|
||||
{
|
||||
case RIG_PARM_TIME:
|
||||
|
|
|
@ -402,7 +402,8 @@ int tt538_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?%c" EOM, which_vfo(rig, vfo));
|
||||
resp_len = 7;
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) respbuf,
|
||||
&resp_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -455,7 +456,8 @@ int tt538_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
which_vfo(rig, vfo),
|
||||
bytes[3], bytes[2], bytes[1], bytes[0]);
|
||||
|
||||
return tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
return tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -521,7 +523,8 @@ int tt538_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
/* Query mode */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?M" EOM);
|
||||
resp_len = 5;
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) respbuf,
|
||||
&resp_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -574,7 +577,8 @@ int tt538_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
/* Query passband width (filter) */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?W" EOM);
|
||||
resp_len = 4;
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) respbuf,
|
||||
&resp_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -636,7 +640,8 @@ int tt538_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
/* Query mode for both VFOs. */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?M" EOM);
|
||||
resp_len = 5;
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) respbuf,
|
||||
&resp_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -691,7 +696,8 @@ int tt538_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -709,7 +715,8 @@ int tt538_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
width = tt538_filter_number((int) width);
|
||||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*W%c" EOM, (unsigned char) width);
|
||||
return tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
return tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
@ -831,7 +838,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
/* Read rig's AGC level setting. */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?G" EOM);
|
||||
lvl_len = 4;
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) lvlbuf,
|
||||
&lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -866,7 +874,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
/* Volume returned as single byte. */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?U" EOM);
|
||||
lvl_len = 4;
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) lvlbuf,
|
||||
&lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -888,7 +897,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?I" EOM);
|
||||
lvl_len = 4;
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) lvlbuf,
|
||||
&lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -913,7 +923,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?P" EOM);
|
||||
lvl_len = 5;
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) lvlbuf,
|
||||
& lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -935,7 +946,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?J" EOM);
|
||||
lvl_len = 4;
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) lvlbuf,
|
||||
&lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -957,7 +969,8 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?H" EOM);
|
||||
lvl_len = 4;
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), (char *) lvlbuf,
|
||||
retval = tt538_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) lvlbuf,
|
||||
&lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -1048,7 +1061,7 @@ int tt538_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
retval = tt538_transaction(rig, cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
retval = tt538_transaction(rig, cmdbuf, strlen((char *)cmdbuf), NULL, NULL);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -286,7 +286,8 @@ static int tt588_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
|
||||
if (data)
|
||||
{
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, (*data_len) + 1, term, strlen(term), 0,
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, (*data_len) + 1,
|
||||
term, strlen(term), 0,
|
||||
1);
|
||||
|
||||
if (retval != -RIG_ETIMEOUT)
|
||||
|
@ -475,7 +476,8 @@ int tt588_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?%c" EOM, which_vfo(rig, vfo));
|
||||
resp_len = 6;
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) respbuf,
|
||||
&resp_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -547,7 +549,8 @@ int tt588_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
which_vfo(rig, vfo),
|
||||
bytes[3], bytes[2], bytes[1], bytes[0]);
|
||||
|
||||
return tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
return tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -619,7 +622,8 @@ int tt588_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
// Query mode
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?M" EOM);
|
||||
resp_len = 4;
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) respbuf,
|
||||
&resp_len);
|
||||
|
||||
if (resp_len > 4)
|
||||
|
@ -677,7 +681,8 @@ int tt588_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
/* Query passband width (filter) */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?W" EOM);
|
||||
resp_len = 3;
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) respbuf,
|
||||
&resp_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -819,7 +824,8 @@ int tt588_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
/* Query mode for both VFOs. */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?M" EOM);
|
||||
resp_len = 4;
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) respbuf,
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) respbuf,
|
||||
&resp_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -874,7 +880,8 @@ int tt588_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -891,7 +898,8 @@ int tt588_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
|
||||
width = tt588_filter_number((int) width);
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*W%c" EOM, (unsigned char) width);
|
||||
return tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
return tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1009,7 +1017,8 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
/* Read rig's AGC level setting. */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?G" EOM);
|
||||
lvl_len = 3;
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) lvlbuf,
|
||||
&lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -1043,7 +1052,8 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
/* Volume returned as single byte. */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?U" EOM);
|
||||
lvl_len = 3;
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) lvlbuf,
|
||||
&lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -1069,7 +1079,8 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
case RIG_LEVEL_RF:
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?I" EOM);
|
||||
lvl_len = 3;
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) lvlbuf,
|
||||
&lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -1090,7 +1101,8 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?J" EOM);
|
||||
lvl_len = 33;
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) lvlbuf,
|
||||
&lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -1119,7 +1131,8 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "?H" EOM);
|
||||
lvl_len = 3;
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), (char *) lvlbuf,
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf),
|
||||
(char *) lvlbuf,
|
||||
&lvl_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -1188,7 +1201,8 @@ int tt588_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
|
||||
/* Volume */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*U%c" EOM, (char)(val.f * 127));
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -1200,8 +1214,10 @@ int tt588_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
case RIG_LEVEL_RF:
|
||||
|
||||
/* RF gain. Omni-VII expects value 0 for full gain, and 127 for lowest gain */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*I%c" EOM, 127 - (char)(val.f * 127));
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*I%c" EOM,
|
||||
127 - (char)(val.f * 127));
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -1227,7 +1243,8 @@ int tt588_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*Gx" EOM);
|
||||
cmdbuf[2] = agcmode;
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -1246,7 +1263,8 @@ int tt588_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
}
|
||||
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*J%c" EOM, ii + '0');
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -1258,7 +1276,8 @@ int tt588_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
case RIG_LEVEL_SQL:
|
||||
/* Squelch level, float 0.0 - 1.0 */
|
||||
SNPRINTF((char *) cmdbuf, sizeof(cmdbuf), "*H%c" EOM, (int)(val.f * 127));
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char*)cmdbuf), NULL, NULL);
|
||||
retval = tt588_transaction(rig, (char *) cmdbuf, strlen((char *)cmdbuf), NULL,
|
||||
NULL);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -1413,7 +1432,8 @@ int tt588_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
cmdbuf[2] = 0;
|
||||
}
|
||||
|
||||
retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, 0); // no response
|
||||
retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL,
|
||||
0); // no response
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -1436,7 +1456,8 @@ const char *tt588_get_info(RIG *rig)
|
|||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "?V" EOM);
|
||||
memset(firmware, 0, sizeof(firmware));
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: firmware_len=%d\n", __func__, firmware_len);
|
||||
retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), firmware, &firmware_len);
|
||||
retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), firmware,
|
||||
&firmware_len);
|
||||
|
||||
// Response should be "VER 1010-588 " plus "RADIO x\r" or "REMOTEx\r"
|
||||
// if x=blank ham band transmit only
|
||||
|
@ -1519,7 +1540,8 @@ static int set_rit_xit(RIG *rig, vfo_t vfo, shortfreq_t rit, int which)
|
|||
cmdbuf[2] = which; // set xit bit. 0=off,1=rit, 2=xit, 3=both
|
||||
cmdbuf[3] = rit >> 8;
|
||||
cmdbuf[4] = rit & 0xff;
|
||||
retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, 0); // no response
|
||||
retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL,
|
||||
0); // no response
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -1617,7 +1639,8 @@ int tt588_set_ant(RIG *rig, vfo_t vfo, ant_t ant)
|
|||
// 3 = RX=RXAUC, TX=ANT2
|
||||
cmdbuf[4] = ant;
|
||||
// this should be the only line needing change for remote operation
|
||||
retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, 0); // no response
|
||||
retval = tt588_transaction(rig, cmdbuf, strlen(cmdbuf), NULL,
|
||||
0); // no response
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -937,7 +937,7 @@ int tt565_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
struct rig_state *rs = &rig->state;
|
||||
|
||||
return write_block(&rs->rigport,
|
||||
(unsigned char *) (ptt == RIG_PTT_ON ? "*TK" EOM : "*TU" EOM), 4);
|
||||
(unsigned char *)(ptt == RIG_PTT_ON ? "*TK" EOM : "*TU" EOM), 4);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -589,7 +589,7 @@ int tt585_get_status_data(RIG *rig)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_block(rigport, (unsigned char *) (char *) priv->status_data,
|
||||
ret = read_block(rigport, (unsigned char *)(char *) priv->status_data,
|
||||
sizeof(priv->status_data));
|
||||
|
||||
if (ret < 0)
|
||||
|
|
|
@ -274,7 +274,7 @@ static int rx331_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return retval;
|
||||
}
|
||||
|
||||
SNPRINTF(fmt, sizeof(fmt)-1, "%%i%%%ds", BUFSZ);
|
||||
SNPRINTF(fmt, sizeof(fmt) - 1, "%%i%%%ds", BUFSZ);
|
||||
sscanf(data + 1, fmt, &rig_id, data);
|
||||
|
||||
if (rig_id != priv->receiver_id)
|
||||
|
@ -483,7 +483,8 @@ int rx331_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
/*
|
||||
* Set DETECTION MODE and IF FILTER
|
||||
*/
|
||||
mdbuf_len = num_snprintf(mdbuf, sizeof(mdbuf), "$%uD%cI%.02f" EOM, priv->receiver_id,
|
||||
mdbuf_len = num_snprintf(mdbuf, sizeof(mdbuf), "$%uD%cI%.02f" EOM,
|
||||
priv->receiver_id,
|
||||
dmode, (float)width / 1e3);
|
||||
}
|
||||
else
|
||||
|
@ -491,7 +492,8 @@ int rx331_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
/*
|
||||
* Set DETECTION MODE
|
||||
*/
|
||||
mdbuf_len = num_snprintf(mdbuf, sizeof(mdbuf), "$%uD%c" EOM, priv->receiver_id, dmode);
|
||||
mdbuf_len = num_snprintf(mdbuf, sizeof(mdbuf), "$%uD%c" EOM, priv->receiver_id,
|
||||
dmode);
|
||||
}
|
||||
|
||||
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, mdbuf_len);
|
||||
|
|
|
@ -280,7 +280,8 @@ int rx340_open(RIG *rig)
|
|||
struct rig_state *rs = &rig->state;
|
||||
|
||||
#define REMOTE_CMD "*R1"EOM
|
||||
return write_block(&rs->rigport, (unsigned char *) REMOTE_CMD, strlen(REMOTE_CMD));
|
||||
return write_block(&rs->rigport, (unsigned char *) REMOTE_CMD,
|
||||
strlen(REMOTE_CMD));
|
||||
}
|
||||
|
||||
int rx340_close(RIG *rig)
|
||||
|
@ -288,7 +289,8 @@ int rx340_close(RIG *rig)
|
|||
struct rig_state *rs = &rig->state;
|
||||
|
||||
#define LOCAL_CMD "*R0"EOM
|
||||
return write_block(&rs->rigport, (unsigned char *) LOCAL_CMD, strlen(LOCAL_CMD));
|
||||
return write_block(&rs->rigport, (unsigned char *) LOCAL_CMD,
|
||||
strlen(LOCAL_CMD));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -83,7 +83,8 @@ int tentec_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, *data_len, NULL, 0, 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, *data_len, NULL, 0,
|
||||
0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
|
|
@ -101,7 +101,8 @@ tt550_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, *data_len, NULL, 0, 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, *data_len, NULL, 0,
|
||||
0, 1);
|
||||
|
||||
if (retval == -RIG_ETIMEOUT)
|
||||
{
|
||||
|
@ -1457,19 +1458,20 @@ tt550_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
case RIG_FUNC_VOX:
|
||||
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "U%c" EOM, status == 0 ? '0' : '1');
|
||||
priv->vox = status;
|
||||
return write_block(&rs->rigport, fctbuf, strlen((char*)fctbuf));
|
||||
return write_block(&rs->rigport, fctbuf, strlen((char *)fctbuf));
|
||||
|
||||
case RIG_FUNC_NR:
|
||||
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "K%c%c" EOM, status == 0 ? '0' : '1',
|
||||
priv->anf == 0 ? '0' : '1');
|
||||
priv->en_nr = status;
|
||||
return write_block(&rs->rigport, fctbuf, strlen((char*)fctbuf));
|
||||
return write_block(&rs->rigport, fctbuf, strlen((char *)fctbuf));
|
||||
|
||||
case RIG_FUNC_ANF:
|
||||
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "K%c%c" EOM, priv->en_nr == 0 ? '0' : '1',
|
||||
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "K%c%c" EOM,
|
||||
priv->en_nr == 0 ? '0' : '1',
|
||||
status == 0 ? '0' : '1');
|
||||
priv->anf = status;
|
||||
return write_block(&rs->rigport, fctbuf, strlen((char*)fctbuf));
|
||||
return write_block(&rs->rigport, fctbuf, strlen((char *)fctbuf));
|
||||
|
||||
|
||||
case RIG_FUNC_TUNER:
|
||||
|
|
|
@ -154,7 +154,8 @@ transaction_write:
|
|||
}
|
||||
|
||||
memset(data, 0, *datasize);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, *datasize, EOM, strlen(EOM), 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, *datasize, EOM,
|
||||
strlen(EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -136,7 +136,8 @@ transaction_write:
|
|||
}
|
||||
|
||||
memset(data, 0, *datasize);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, *datasize, EOM, strlen(EOM), 0, 1);
|
||||
retval = read_string(&rs->rigport, (unsigned char *) data, *datasize, EOM,
|
||||
strlen(EOM), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -548,7 +548,8 @@ static int ft100_read_status(RIG *rig)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_block(&rig->state.rigport, (unsigned char *) &priv->status, sizeof(FT100_STATUS_INFO));
|
||||
ret = read_block(&rig->state.rigport, (unsigned char *) &priv->status,
|
||||
sizeof(FT100_STATUS_INFO));
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: read status=%i \n", __func__, ret);
|
||||
|
||||
if (ret < 0)
|
||||
|
@ -575,7 +576,8 @@ static int ft100_read_flags(RIG *rig)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_block(&rig->state.rigport, (unsigned char *) &priv->flags, sizeof(FT100_FLAG_INFO));
|
||||
ret = read_block(&rig->state.rigport, (unsigned char *) &priv->flags,
|
||||
sizeof(FT100_FLAG_INFO));
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: read flags=%i \n", __func__, ret);
|
||||
|
||||
if (ret < 0)
|
||||
|
@ -989,7 +991,8 @@ int ft100_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = read_block(&rig->state.rigport, (unsigned char *) &ft100_meter, sizeof(FT100_METER_INFO));
|
||||
ret = read_block(&rig->state.rigport, (unsigned char *) &ft100_meter,
|
||||
sizeof(FT100_METER_INFO));
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: read meters=%d\n", __func__, ret);
|
||||
|
||||
if (ret < 0)
|
||||
|
|
|
@ -2490,7 +2490,7 @@ static int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level,
|
|||
return err;
|
||||
}
|
||||
|
||||
err = read_block(&rig->state.rigport, mdata,FT1000D_READ_METER_LENGTH);
|
||||
err = read_block(&rig->state.rigport, mdata, FT1000D_READ_METER_LENGTH);
|
||||
|
||||
if (err < 0)
|
||||
{
|
||||
|
@ -3494,7 +3494,8 @@ static int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci,
|
|||
priv->p_cmd[1] = p3;
|
||||
priv->p_cmd[0] = p4;
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
@ -3552,7 +3553,8 @@ static int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq)
|
|||
rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd,
|
||||
FT1000D_BCD_DIAL) * 10);
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
@ -3617,7 +3619,8 @@ static int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit)
|
|||
// Store bcd format into privat command storage area
|
||||
to_bcd(priv->p_cmd, labs(rit) / 10, FT1000D_BCD_RIT);
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -396,7 +396,8 @@ static int ft600_send_priv_cmd(RIG *rig, unsigned char cmd_index)
|
|||
|
||||
if (!rig) { return -RIG_EINVAL; }
|
||||
|
||||
return write_block(&rig->state.rigport, (unsigned char *) &ncmd[cmd_index].nseq, YAESU_CMD_LENGTH);
|
||||
return write_block(&rig->state.rigport, (unsigned char *) &ncmd[cmd_index].nseq,
|
||||
YAESU_CMD_LENGTH);
|
||||
}
|
||||
|
||||
static int ft600_read_status(RIG *rig)
|
||||
|
|
|
@ -1848,7 +1848,8 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci,
|
|||
priv->p_cmd[P3] = p3;
|
||||
priv->p_cmd[P4] = p4;
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
@ -1908,7 +1909,8 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq)
|
|||
rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd,
|
||||
FT840_BCD_DIAL) * 10);
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -2000,7 +2000,8 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci,
|
|||
priv->p_cmd[P3] = p3;
|
||||
priv->p_cmd[P4] = p4;
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
@ -2060,7 +2061,8 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq)
|
|||
rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd,
|
||||
FT890_BCD_DIAL) * 10);
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
@ -2140,7 +2142,8 @@ static int ft890_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit)
|
|||
priv->p_cmd[P1] = p1; /* ick */
|
||||
priv->p_cmd[P2] = p2;
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -386,7 +386,8 @@ static int ft891_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
|||
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "ST%c;", ci);
|
||||
|
||||
if (RIG_OK != (err = write_block(&state->rigport, (unsigned char *) priv->cmd_str, strlen(priv->cmd_str))))
|
||||
if (RIG_OK != (err = write_block(&state->rigport,
|
||||
(unsigned char *) priv->cmd_str, strlen(priv->cmd_str))))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: write_block err = %d\n", __func__, err);
|
||||
return err;
|
||||
|
@ -557,7 +558,8 @@ static int ft891_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
|
|||
// Copy A to B
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "AB;");
|
||||
|
||||
if (RIG_OK != (err = write_block(&state->rigport, (unsigned char *) priv->cmd_str, strlen(priv->cmd_str))))
|
||||
if (RIG_OK != (err = write_block(&state->rigport,
|
||||
(unsigned char *) priv->cmd_str, strlen(priv->cmd_str))))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s:%d write_block err = %d\n", __func__, __LINE__,
|
||||
err);
|
||||
|
|
|
@ -2740,7 +2740,8 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci,
|
|||
priv->p_cmd[P3] = p3;
|
||||
priv->p_cmd[P4] = p4;
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
@ -2804,7 +2805,8 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq)
|
|||
rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd,
|
||||
FT920_BCD_DIAL) * 10);
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
@ -2887,7 +2889,8 @@ static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit)
|
|||
priv->p_cmd[P1] = p1; /* ick */
|
||||
priv->p_cmd[P2] = p2;
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -585,7 +585,8 @@ int ft980_transaction(RIG *rig, const unsigned char *cmd, unsigned char *data,
|
|||
return retval;
|
||||
}
|
||||
|
||||
if (retval != YAESU_CMD_LENGTH || (memcmp(echo_back, cmd, YAESU_CMD_LENGTH) != 0))
|
||||
if (retval != YAESU_CMD_LENGTH
|
||||
|| (memcmp(echo_back, cmd, YAESU_CMD_LENGTH) != 0))
|
||||
{
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
|
|
@ -3396,7 +3396,8 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci,
|
|||
priv->p_cmd[1] = p3;
|
||||
priv->p_cmd[0] = p4;
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
@ -3454,7 +3455,8 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq)
|
|||
rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd,
|
||||
FT990_BCD_DIAL) * 10);
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
@ -3518,7 +3520,8 @@ int ft990_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit)
|
|||
// Store bcd format into privat command storage area
|
||||
to_bcd(priv->p_cmd, labs(rit) / 10, FT990_BCD_RIT);
|
||||
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd, YAESU_CMD_LENGTH);
|
||||
err = write_block(&rig->state.rigport, (unsigned char *) &priv->p_cmd,
|
||||
YAESU_CMD_LENGTH);
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -437,7 +437,7 @@ static int newcat_band_index(freq_t freq)
|
|||
else if (freq >= MHz(0.5) && freq < MHz(1.705)) { band = 12; } // MW Medium Wave
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: freq=%g, band=%d\n", __func__, freq, band);
|
||||
return(band);
|
||||
return (band);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -514,7 +514,7 @@ int newcat_open(RIG *rig)
|
|||
{
|
||||
struct newcat_priv_data *priv = rig->state.priv;
|
||||
struct rig_state *rig_s = &rig->state;
|
||||
const char *handshake[3] = {"None","Xon/Xoff", "Hardware"};
|
||||
const char *handshake[3] = {"None", "Xon/Xoff", "Hardware"};
|
||||
|
||||
ENTERFUNC;
|
||||
|
||||
|
@ -590,6 +590,7 @@ int newcat_open(RIG *rig)
|
|||
rig->state.disable_yaesu_bandselect = 1;
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: disabling FTDX3000 band select\n", __func__);
|
||||
}
|
||||
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
|
@ -773,7 +774,8 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
// disabled to check 2019 firmware on FTDX5000 and FT450 behavior
|
||||
//special_60m = newcat_is_rig(rig, RIG_MODEL_FTDX5000);
|
||||
//special_60m |= newcat_is_rig(rig, RIG_MODEL_FT450);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: special_60m=%d, 60m freq=%d, is_ftdx3000=%d,is_ftdx3000dm=%d\n",
|
||||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: special_60m=%d, 60m freq=%d, is_ftdx3000=%d,is_ftdx3000dm=%d\n",
|
||||
__func__, special_60m, freq >= 5300000
|
||||
&& freq <= 5410000, is_ftdx3000, is_ftdx3000dm);
|
||||
|
||||
|
@ -2312,7 +2314,8 @@ int newcat_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
|
|||
RETURNFUNC(err);
|
||||
}
|
||||
|
||||
if (tmp_mode == tx_mode && (tmp_width == tx_width || tmp_width == RIG_PASSBAND_NOCHANGE))
|
||||
if (tmp_mode == tx_mode && (tmp_width == tx_width
|
||||
|| tmp_width == RIG_PASSBAND_NOCHANGE))
|
||||
{
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
@ -3262,7 +3265,8 @@ int newcat_set_powerstat(RIG *rig, powerstat_t status)
|
|||
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "PS%c%c", ps, cat_term);
|
||||
|
||||
retval = write_block(&state->rigport, (unsigned char *) priv->cmd_str, strlen(priv->cmd_str));
|
||||
retval = write_block(&state->rigport, (unsigned char *) priv->cmd_str,
|
||||
strlen(priv->cmd_str));
|
||||
|
||||
retry_save = rig->state.rigport.retry;
|
||||
rig->state.rigport.retry = 0;
|
||||
|
@ -3282,7 +3286,8 @@ int newcat_set_powerstat(RIG *rig, powerstat_t status)
|
|||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: Wait #%d for power up\n", __func__, i + 1);
|
||||
retval = write_block(&state->rigport, (unsigned char *) priv->cmd_str, strlen(priv->cmd_str));
|
||||
retval = write_block(&state->rigport, (unsigned char *) priv->cmd_str,
|
||||
strlen(priv->cmd_str));
|
||||
|
||||
if (retval != RIG_OK) { RETURNFUNC(retval); }
|
||||
}
|
||||
|
@ -3519,32 +3524,50 @@ int newcat_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
|
|||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
static int band2rig (hamlib_band_t band)
|
||||
static int band2rig(hamlib_band_t band)
|
||||
{
|
||||
int retval = 0;
|
||||
switch(band)
|
||||
|
||||
switch (band)
|
||||
{
|
||||
case RIG_BAND_160M: retval = 0;break;
|
||||
case RIG_BAND_80M: retval = 1;break;
|
||||
case RIG_BAND_60M: retval = 2;break;
|
||||
case RIG_BAND_40M: retval = 3;break;
|
||||
case RIG_BAND_30M: retval = 4;break;
|
||||
case RIG_BAND_20M: retval = 5;break;
|
||||
case RIG_BAND_17M: retval = 6;break;
|
||||
case RIG_BAND_15M: retval = 7;break;
|
||||
case RIG_BAND_12M: retval = 8;break;
|
||||
case RIG_BAND_10M: retval = 9;break;
|
||||
case RIG_BAND_6M: retval = 10;break;
|
||||
case RIG_BAND_GEN: retval = 11;break;
|
||||
case RIG_BAND_MW: retval = 12;break;
|
||||
case RIG_BAND_AIR: retval = 14;break;
|
||||
case RIG_BAND_144MHZ: retval = 15;break;
|
||||
case RIG_BAND_430MHZ: retval = 16;break;
|
||||
case RIG_BAND_160M: retval = 0; break;
|
||||
|
||||
case RIG_BAND_80M: retval = 1; break;
|
||||
|
||||
case RIG_BAND_60M: retval = 2; break;
|
||||
|
||||
case RIG_BAND_40M: retval = 3; break;
|
||||
|
||||
case RIG_BAND_30M: retval = 4; break;
|
||||
|
||||
case RIG_BAND_20M: retval = 5; break;
|
||||
|
||||
case RIG_BAND_17M: retval = 6; break;
|
||||
|
||||
case RIG_BAND_15M: retval = 7; break;
|
||||
|
||||
case RIG_BAND_12M: retval = 8; break;
|
||||
|
||||
case RIG_BAND_10M: retval = 9; break;
|
||||
|
||||
case RIG_BAND_6M: retval = 10; break;
|
||||
|
||||
case RIG_BAND_GEN: retval = 11; break;
|
||||
|
||||
case RIG_BAND_MW: retval = 12; break;
|
||||
|
||||
case RIG_BAND_AIR: retval = 14; break;
|
||||
|
||||
case RIG_BAND_144MHZ: retval = 15; break;
|
||||
|
||||
case RIG_BAND_430MHZ: retval = 16; break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unknown band index=%d\n", __func__, band);
|
||||
retval = -RIG_EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -3602,7 +3625,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
|
||||
fpf = newcat_scale_float(scale, val.f);
|
||||
|
||||
if (is_ft950 || is_ft891 || is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx101d
|
||||
if (is_ft950 || is_ft891 || is_ft991 || is_ftdx3000 || is_ftdx3000dm
|
||||
|| is_ftdx101d
|
||||
|| is_ftdx101mp || is_ftdx10)
|
||||
{
|
||||
// Minimum is 5 watts on these rigs
|
||||
|
@ -3677,7 +3701,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
newcat_get_mode(rig, vfo, &mode, &width);
|
||||
}
|
||||
|
@ -3719,7 +3744,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
}
|
||||
|
||||
// Some Yaesu rigs reject this command in AM/FM modes
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN
|
||||
|| mode & RIG_MODE_FMN)
|
||||
|
@ -3787,14 +3813,16 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
newcat_get_mode(rig, vfo, &mode, &width);
|
||||
}
|
||||
|
||||
if (val.f > 1.0) { RETURNFUNC(-RIG_EINVAL); }
|
||||
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991 || is_ftdx101d
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
|
||||
|| is_ftdx101d
|
||||
|| is_ftdx101mp
|
||||
|| is_ftdx10)
|
||||
{
|
||||
|
@ -3808,7 +3836,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "MG%03d%c", fpf, cat_term);
|
||||
|
||||
// Some Yaesu rigs reject this command in RTTY modes
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
if (mode & RIG_MODE_RTTY || mode & RIG_MODE_RTTYR)
|
||||
{
|
||||
|
@ -4355,7 +4384,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
|
||||
if (val.f > 1.0) { RETURNFUNC(-RIG_EINVAL); }
|
||||
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991 || is_ftdx101d
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
|
||||
|| is_ftdx101d
|
||||
|| is_ftdx101mp
|
||||
|| is_ftdx10)
|
||||
{
|
||||
|
@ -4381,12 +4411,15 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
if (newcat_valid_command(rig, "BS"))
|
||||
{
|
||||
int band = band2rig((hamlib_band_t)val.i);
|
||||
|
||||
if (band < 0)
|
||||
{
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "BS%02d%c", band, cat_term);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_NB:
|
||||
|
@ -4507,7 +4540,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
newcat_get_mode(rig, vfo, &mode, &width);
|
||||
}
|
||||
|
@ -4521,7 +4555,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
}
|
||||
|
||||
// Some Yaesu rigs reject this command in AM/FM modes
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN
|
||||
|| mode & RIG_MODE_FMN)
|
||||
|
@ -4561,7 +4596,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
newcat_get_mode(rig, vfo, &mode, &width);
|
||||
}
|
||||
|
@ -4569,7 +4605,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "MG%c", cat_term);
|
||||
|
||||
// Some Yaesu rigs reject this command in RTTY modes
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
if (mode & RIG_MODE_RTTY || mode & RIG_MODE_RTTYR)
|
||||
{
|
||||
|
@ -4940,7 +4977,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
switch (level)
|
||||
{
|
||||
case RIG_LEVEL_RFPOWER:
|
||||
if (is_ft950 || is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
|
||||
if (is_ft950 || is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891
|
||||
|| is_ft991
|
||||
|| is_ftdx101d || is_ftdx101mp || is_ftdx10)
|
||||
{
|
||||
scale = 100.;
|
||||
|
@ -5111,7 +5149,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
break;
|
||||
|
||||
case RIG_LEVEL_MICGAIN:
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991 || is_ftdx101d
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
|
||||
|| is_ftdx101d
|
||||
|| is_ftdx101mp
|
||||
|| is_ftdx10)
|
||||
{
|
||||
|
@ -5208,7 +5247,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
break;
|
||||
}
|
||||
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ft891 || is_ft991
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ft891
|
||||
|| is_ft991
|
||||
|| is_ftdx101d || is_ftdx101mp || is_ftdx10)
|
||||
{
|
||||
val->i = round(rig_raw2val(atoi(retlvl), &yaesu_default_str_cal));
|
||||
|
@ -5434,7 +5474,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
break;
|
||||
|
||||
case RIG_LEVEL_MONITOR_GAIN:
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991 || is_ftdx101d
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
|
||||
|| is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
scale = 100.;
|
||||
|
@ -5492,7 +5533,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
err = newcat_get_mode(rig, vfo, &mode, &width);
|
||||
}
|
||||
|
@ -5506,7 +5548,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
}
|
||||
|
||||
// Some Yaesu rigs reject this command in FM mode
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
if (mode & RIG_MODE_FM || mode & RIG_MODE_FMN)
|
||||
{
|
||||
|
@ -5527,7 +5570,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
newcat_get_mode(rig, vfo, &mode, &width);
|
||||
}
|
||||
|
@ -5541,7 +5585,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
}
|
||||
|
||||
// Some Yaesu rigs reject this command in FM mode
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
if (mode & RIG_MODE_FM || mode & RIG_MODE_FMN)
|
||||
{
|
||||
|
@ -5600,7 +5645,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
// These rigs can lock Main/Sub VFO dials individually
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "LK%d%c", status ? 7 : 4,
|
||||
|
@ -5650,7 +5696,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
newcat_get_mode(rig, vfo, &mode, &width);
|
||||
}
|
||||
|
@ -5664,7 +5711,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
}
|
||||
|
||||
// Some Yaesu rigs reject this command in FM mode
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
if (mode & RIG_MODE_FM || mode & RIG_MODE_FMN)
|
||||
{
|
||||
|
@ -5685,12 +5733,14 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
newcat_get_mode(rig, vfo, &mode, &width);
|
||||
}
|
||||
|
||||
if (is_ft891 || is_ft991 || is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx101d
|
||||
if (is_ft891 || is_ft991 || is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm
|
||||
|| is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
// There seems to be an error in the manuals for some of these rigs stating that values should be 1 = OFF and 2 = ON, but they are 0 = OFF and 1 = ON instead
|
||||
|
@ -5704,7 +5754,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|||
}
|
||||
|
||||
// Some Yaesu rigs reject this command in AM/FM/RTTY modes
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN
|
||||
|| mode & RIG_MODE_FMN ||
|
||||
|
@ -5833,7 +5884,8 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
|||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
err = newcat_get_mode(rig, vfo, &mode, &width);
|
||||
}
|
||||
|
@ -5846,7 +5898,8 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
|||
}
|
||||
|
||||
// Some Yaesu rigs reject this command in FM mode
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ft991 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
if (mode & RIG_MODE_FM || mode & RIG_MODE_FMN)
|
||||
{
|
||||
|
@ -5965,7 +6018,8 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
|||
RETURNFUNC(-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991 || is_ftdx101d
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ft891 || is_ft991
|
||||
|| is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "PR0%c", cat_term);
|
||||
|
@ -6085,7 +6139,8 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
|||
break;
|
||||
|
||||
case RIG_FUNC_LOCK:
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d || is_ftdx101mp)
|
||||
if (is_ftdx1200 || is_ftdx3000 || is_ftdx3000dm || is_ftdx5000 || is_ftdx101d
|
||||
|| is_ftdx101mp)
|
||||
{
|
||||
// These rigs can lock Main/Sub VFO dials individually
|
||||
*status = (retfunc[0] == '0' || retfunc[0] == '4') ? 0 : 1;
|
||||
|
@ -7408,13 +7463,18 @@ int newcat_set_vfo_from_alias(RIG *rig, vfo_t *vfo)
|
|||
if (*vfo == RIG_VFO_NONE)
|
||||
{
|
||||
int rc = rig_get_vfo(rig, vfo);
|
||||
|
||||
if (rc != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: rig_get_vfo failed: %s\n", __func__, rig_strvfo(*vfo));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: rig_get_vfo failed: %s\n", __func__,
|
||||
rig_strvfo(*vfo));
|
||||
RETURNFUNC(rc);
|
||||
}
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: vfo==None so get vfo=%s\n", __func__, rig_strvfo(*vfo));
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: vfo==None so get vfo=%s\n", __func__,
|
||||
rig_strvfo(*vfo));
|
||||
}
|
||||
|
||||
switch (*vfo)
|
||||
{
|
||||
case RIG_VFO_A:
|
||||
|
@ -9840,6 +9900,7 @@ int newcat_get_rigid(RIG *rig)
|
|||
s += 2; /* ID0310, jump past ID */
|
||||
priv->rig_id = atoi(s);
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "rig_id = %d, idstr = %s\n", priv->rig_id,
|
||||
s == NULL ? "NULL" : s);
|
||||
}
|
||||
|
@ -10065,7 +10126,8 @@ int newcat_get_cmd(RIG *rig)
|
|||
/* send the command */
|
||||
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
|
||||
|
||||
if (RIG_OK != (rc = write_block(&state->rigport, (unsigned char *) priv->cmd_str,
|
||||
if (RIG_OK != (rc = write_block(&state->rigport,
|
||||
(unsigned char *) priv->cmd_str,
|
||||
strlen(priv->cmd_str))))
|
||||
{
|
||||
RETURNFUNC(rc);
|
||||
|
@ -10073,7 +10135,8 @@ int newcat_get_cmd(RIG *rig)
|
|||
}
|
||||
|
||||
/* read the reply */
|
||||
if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data, sizeof(priv->ret_data),
|
||||
if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data,
|
||||
sizeof(priv->ret_data),
|
||||
&cat_term, sizeof(cat_term), 0, 1)) <= 0)
|
||||
{
|
||||
continue; /* usually a timeout - retry */
|
||||
|
@ -10216,6 +10279,7 @@ int newcat_set_cmd_validate(RIG *rig)
|
|||
if ((strncmp(priv->cmd_str, "FA", 2) == 0) && (strlen(priv->cmd_str) > 3))
|
||||
{
|
||||
strcpy(valcmd, "FA;");
|
||||
|
||||
if (priv->rig_id == NC_RIGID_FTDX3000)
|
||||
{
|
||||
strcpy(valcmd, "");
|
||||
|
@ -10224,6 +10288,7 @@ int newcat_set_cmd_validate(RIG *rig)
|
|||
else if ((strncmp(priv->cmd_str, "FB", 2) == 0) && (strlen(priv->cmd_str) > 3))
|
||||
{
|
||||
strcpy(valcmd, "FB;");
|
||||
|
||||
if (priv->rig_id == NC_RIGID_FTDX3000)
|
||||
{
|
||||
strcpy(valcmd, "");
|
||||
|
@ -10250,6 +10315,7 @@ int newcat_set_cmd_validate(RIG *rig)
|
|||
else if ((strncmp(priv->cmd_str, "VS", 2) == 0) && (strlen(priv->cmd_str) > 3))
|
||||
{
|
||||
strcpy(valcmd, "VS;");
|
||||
|
||||
// Some models treat the 2nd VS as a mute request
|
||||
if (is_ftdx3000 || is_ftdx9000)
|
||||
{
|
||||
|
@ -10294,7 +10360,8 @@ int newcat_set_cmd_validate(RIG *rig)
|
|||
|
||||
if (strlen(valcmd) == 0) { RETURNFUNC(RIG_OK); }
|
||||
|
||||
bytes = read_string(&state->rigport, (unsigned char *) priv->ret_data, sizeof(priv->ret_data),
|
||||
bytes = read_string(&state->rigport, (unsigned char *) priv->ret_data,
|
||||
sizeof(priv->ret_data),
|
||||
&cat_term, sizeof(cat_term), 0, 1);
|
||||
|
||||
// FA and FB success is now verified in rig.c with a followup query
|
||||
|
@ -10384,7 +10451,8 @@ int newcat_set_cmd(RIG *rig)
|
|||
rig_debug(RIG_DEBUG_TRACE,
|
||||
"%s: newcat_set_cmd_validate not implemented...continuing\n", __func__);
|
||||
|
||||
if (RIG_OK != (rc = write_block(&state->rigport, (unsigned char *) priv->cmd_str,
|
||||
if (RIG_OK != (rc = write_block(&state->rigport,
|
||||
(unsigned char *) priv->cmd_str,
|
||||
strlen(priv->cmd_str))))
|
||||
{
|
||||
RETURNFUNC(rc);
|
||||
|
@ -10422,7 +10490,8 @@ int newcat_set_cmd(RIG *rig)
|
|||
}
|
||||
|
||||
/* read the reply */
|
||||
if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data, sizeof(priv->ret_data),
|
||||
if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data,
|
||||
sizeof(priv->ret_data),
|
||||
&cat_term, sizeof(cat_term), 0, 1)) <= 0)
|
||||
{
|
||||
continue; /* usually a timeout - retry */
|
||||
|
@ -10492,7 +10561,8 @@ int newcat_set_cmd(RIG *rig)
|
|||
priv->cmd_str);
|
||||
|
||||
/* read/flush the verify command reply which should still be there */
|
||||
if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data, sizeof(priv->ret_data),
|
||||
if ((rc = read_string(&state->rigport, (unsigned char *) priv->ret_data,
|
||||
sizeof(priv->ret_data),
|
||||
&cat_term, sizeof(cat_term), 0, 1)) > 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s\n",
|
||||
|
@ -10557,11 +10627,11 @@ rmode_t newcat_rmode(char mode)
|
|||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: %s for %c\n", __func__,
|
||||
rig_strrmode(newcat_mode_conv[i].mode), mode);
|
||||
return(newcat_mode_conv[i].mode);
|
||||
return (newcat_mode_conv[i].mode);
|
||||
}
|
||||
}
|
||||
|
||||
return(RIG_MODE_NONE);
|
||||
return (RIG_MODE_NONE);
|
||||
}
|
||||
|
||||
char newcat_modechar(rmode_t rmode)
|
||||
|
@ -10574,11 +10644,11 @@ char newcat_modechar(rmode_t rmode)
|
|||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: return %c for %s\n", __func__,
|
||||
newcat_mode_conv[i].modechar, rig_strrmode(rmode));
|
||||
return(newcat_mode_conv[i].modechar);
|
||||
return (newcat_mode_conv[i].modechar);
|
||||
}
|
||||
}
|
||||
|
||||
return('0');
|
||||
return ('0');
|
||||
}
|
||||
|
||||
rmode_t newcat_rmode_width(RIG *rig, vfo_t vfo, char mode, pbwidth_t *width)
|
||||
|
|
|
@ -48,7 +48,8 @@ cnctrk_set_position(ROT *rot, azimuth_t az, elevation_t el)
|
|||
return retval;
|
||||
}
|
||||
|
||||
SNPRINTF(axcmd, sizeof(axcmd), "/usr/bin/axis-remote --mdi 'G00 X %6.2f Y %6.2f' \n", az, el);
|
||||
SNPRINTF(axcmd, sizeof(axcmd),
|
||||
"/usr/bin/axis-remote --mdi 'G00 X %6.2f Y %6.2f' \n", az, el);
|
||||
return system(axcmd);
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,8 @@ static int
|
|||
gs232_wo_transaction(ROT *rot, const char *cmdstr,
|
||||
char *data, size_t data_len)
|
||||
{
|
||||
return write_block(&rot->state.rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
return write_block(&rot->state.rotport, (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -106,7 +106,8 @@ transaction_write:
|
|||
|
||||
/** the answer */
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, ACK, strlen(ACK), 0, 1);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, ACK,
|
||||
strlen(ACK), 0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -202,13 +202,15 @@ transaction_write:
|
|||
|
||||
/* then comes the answer */
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, CR, strlen(CR), 0, 1);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, CR,
|
||||
strlen(CR), 0, 1);
|
||||
|
||||
// some models seem to echo -- so we'll check and read again if echoed
|
||||
if (cmdstr && strcmp(data, cmdstr) == 0)
|
||||
{
|
||||
memset(data, 0, data_len);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, CR, strlen(CR), 0, 1);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, CR,
|
||||
strlen(CR), 0, 1);
|
||||
}
|
||||
|
||||
if (retval < 0)
|
||||
|
|
|
@ -113,7 +113,8 @@ transaction:
|
|||
|
||||
if (cmdstr)
|
||||
{
|
||||
return_value = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
return_value = write_block(&rs->rotport, (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
|
||||
if (return_value != RIG_OK)
|
||||
{
|
||||
|
@ -126,7 +127,8 @@ transaction:
|
|||
return value is expected, Strings end with '#' */
|
||||
if (data != NULL)
|
||||
{
|
||||
return_value = read_string(&rs->rotport, (unsigned char *) data, expected_return_length + 1,
|
||||
return_value = read_string(&rs->rotport, (unsigned char *) data,
|
||||
expected_return_length + 1,
|
||||
"\r\n", strlen("\r\n"), 0, 1);
|
||||
|
||||
if (return_value > 0)
|
||||
|
@ -444,7 +446,8 @@ static const char *meade_get_info(ROT *rot)
|
|||
struct meade_priv_data *priv = (struct meade_priv_data *)rot->state.priv;
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
SNPRINTF(buf, sizeof(buf), "Meade telescope rotator with LX200 protocol.\nModel: %s",
|
||||
SNPRINTF(buf, sizeof(buf),
|
||||
"Meade telescope rotator with LX200 protocol.\nModel: %s",
|
||||
priv->product_name);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,8 @@ transaction_write:
|
|||
}
|
||||
|
||||
// Remember to check for STXA,G,R or STXA,?,XXX,R 10 bytes
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, 20, CR, strlen(CR), 0, 1);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, 20, CR, strlen(CR),
|
||||
0, 1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -77,7 +77,8 @@ radant_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len)
|
|||
return RIG_OK; /* don't want a reply */
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, "\n", 1, 0, 1);
|
||||
retval = read_string(&rs->rotport, (unsigned char *) data, data_len, "\n", 1, 0,
|
||||
1);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
|
|
|
@ -434,7 +434,8 @@ static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth,
|
|||
azimuth = 0;
|
||||
}
|
||||
|
||||
SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%03.0f;", azimuth); /* Target bearing */
|
||||
SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%03.0f;",
|
||||
azimuth); /* Target bearing */
|
||||
err = rotorez_send_priv_cmd(rot, cmdstr);
|
||||
|
||||
if (err != RIG_OK)
|
||||
|
@ -479,7 +480,8 @@ static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth,
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%05.1f\r;", azimuth); /* Total field width of 5 chars */
|
||||
SNPRINTF(cmdstr, sizeof(cmdstr), "AP1%05.1f\r;",
|
||||
azimuth); /* Total field width of 5 chars */
|
||||
err = rotorez_send_priv_cmd(rot, cmdstr);
|
||||
|
||||
if (err != RIG_OK)
|
||||
|
@ -499,6 +501,7 @@ static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth,
|
|||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
@ -760,7 +763,8 @@ static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth,
|
|||
|
||||
rs = &rot->state;
|
||||
|
||||
err = read_string(&rs->rotport, (unsigned char *) az, RT21_AZ_LEN + 1, ";", strlen(";"), 0, 1);
|
||||
err = read_string(&rs->rotport, (unsigned char *) az, RT21_AZ_LEN + 1, ";",
|
||||
strlen(";"), 0, 1);
|
||||
|
||||
if (err < 0) /* read_string returns negative on error. */
|
||||
{
|
||||
|
|
|
@ -127,7 +127,8 @@ static int sartek_rot_set_position(ROT *rot, azimuth_t azimuth,
|
|||
|
||||
SNPRINTF(cmdstr, sizeof(cmdstr), "P%c", (int)((azimuth * 255) / 360));
|
||||
|
||||
err = write_block(&rot->state.rotport, (unsigned char *) cmdstr, strlen(cmdstr));
|
||||
err = write_block(&rot->state.rotport, (unsigned char *) cmdstr,
|
||||
strlen(cmdstr));
|
||||
|
||||
if (err != RIG_OK)
|
||||
{
|
||||
|
|
|
@ -161,7 +161,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
|
||||
|
||||
// read motion state
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -171,7 +172,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
stat->motion_enabled = strcmp(resbuf, "Motion ENABLED") == 0 ? true : false;
|
||||
|
||||
// XXX skip mode
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -179,7 +181,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
}
|
||||
|
||||
// XXX skip time
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -187,7 +190,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
}
|
||||
|
||||
// read azimuth line
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -199,7 +203,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
stat->az = (int)strtof(p, NULL);
|
||||
|
||||
// read elevation line
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -211,7 +216,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
stat->el = (int)strtof(p, NULL);
|
||||
|
||||
// skip blank line
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -219,7 +225,8 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat)
|
|||
}
|
||||
|
||||
// XXX skip stored position count
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0, 1);
|
||||
ret = read_string(&rs->rotport, (unsigned char *) resbuf, BUF_SIZE, "\n", 1, 0,
|
||||
1);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
|
@ -185,33 +185,41 @@ void frameParse(int fd, unsigned char *frame, int len)
|
|||
break;
|
||||
|
||||
case 0x14:
|
||||
switch(frame[5])
|
||||
switch (frame[5])
|
||||
{
|
||||
static int power_level = 0;
|
||||
|
||||
case 0x0a:
|
||||
printf("Using power level %d\n", power_level);
|
||||
power_level += 10;
|
||||
if (power_level > 250) power_level = 0;
|
||||
|
||||
if (power_level > 250) { power_level = 0; }
|
||||
|
||||
to_bcd(&frame[6], (long long)power_level, 2);
|
||||
frame[8] = 0xfd;
|
||||
write(fd, frame, 9);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x15:
|
||||
switch(frame[5])
|
||||
switch (frame[5])
|
||||
{
|
||||
static int meter_level = 0;
|
||||
|
||||
case 0x11:
|
||||
printf("Using meter level %d\n", meter_level);
|
||||
meter_level += 10;
|
||||
if (meter_level > 250) meter_level = 0;
|
||||
|
||||
if (meter_level > 250) { meter_level = 0; }
|
||||
|
||||
to_bcd(&frame[6], (long long)meter_level, 2);
|
||||
frame[8] = 0xfd;
|
||||
write(fd, frame, 9);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x1a: // miscellaneous things
|
||||
|
|
|
@ -219,7 +219,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
else if (strncmp(buf, "MD;", 3) == 0)
|
||||
{
|
||||
SNPRINTF(buf, sizeof(buf), "MD%d;", modeA); // not worried about modeB yet for simulator
|
||||
SNPRINTF(buf, sizeof(buf), "MD%d;",
|
||||
modeA); // not worried about modeB yet for simulator
|
||||
write(fd, buf, strlen(buf));
|
||||
}
|
||||
else if (strncmp(buf, "MD", 2) == 0)
|
||||
|
|
|
@ -197,9 +197,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
#endif
|
||||
else if (strcmp(buf, "VS") == 0 && strlen(buf)>3)
|
||||
else if (strcmp(buf, "VS") == 0 && strlen(buf) > 3)
|
||||
{
|
||||
curr_vfo = buf[3] == '1'?RIG_VFO_B:RIG_VFO_A;
|
||||
curr_vfo = buf[3] == '1' ? RIG_VFO_B : RIG_VFO_A;
|
||||
usleep(50 * 1000);
|
||||
}
|
||||
else if (strcmp(buf, "VS;") == 0)
|
||||
|
@ -207,7 +207,9 @@ int main(int argc, char *argv[])
|
|||
printf("%s\n", buf);
|
||||
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[2] = '1'; }
|
||||
|
||||
n = write(fd, pbuf, strlen(pbuf));
|
||||
printf("n=%d\n", n);
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ int frontamp_get_conf2(AMP *amp, token_t token, char *val, int val_len)
|
|||
switch (token)
|
||||
{
|
||||
case TOK_PATHNAME:
|
||||
strncpy(val, rs->ampport.pathname, val_len-1);
|
||||
strncpy(val, rs->ampport.pathname, val_len - 1);
|
||||
break;
|
||||
|
||||
case TOK_WRITE_DELAY:
|
||||
|
@ -428,7 +428,7 @@ int frontamp_get_conf2(AMP *amp, token_t token, char *val, int val_len)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
strncpy(val, s, val_len-1);
|
||||
strncpy(val, s, val_len - 1);
|
||||
break;
|
||||
|
||||
case TOK_HANDSHAKE:
|
||||
|
|
|
@ -275,10 +275,12 @@ AMP *HAMLIB_API amp_init(amp_model_t amp_model)
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Now we have to copy our new rig state hamlib_port structure to the deprecated one
|
||||
// Clients built on older 4.X versions will use the old structure
|
||||
// Clients built on newer 4.5 versions will use the new structure
|
||||
memcpy(&->state.ampport_deprecated, &->state.ampport, sizeof(amp->state.ampport_deprecated));
|
||||
memcpy(&->state.ampport_deprecated, &->state.ampport,
|
||||
sizeof(amp->state.ampport_deprecated));
|
||||
|
||||
return amp;
|
||||
}
|
||||
|
|
|
@ -197,16 +197,16 @@ int rig_set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo?, vfo=%s\n", __func__,
|
||||
rig_strvfo(vfo));
|
||||
return(-RIG_EINVAL);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
|
||||
if (rig_need_debug(RIG_DEBUG_CACHE))
|
||||
{
|
||||
rig_cache_show(rig, __func__, __LINE__);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -536,6 +536,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
{
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
// JTDX and WSJTX currently use state.pttport to check for PTT_NONE
|
||||
rig->state.pttport.type.ptt = rs->pttport.type.ptt;
|
||||
rs->pttport_deprecated.type.ptt = rs->pttport.type.ptt;
|
||||
|
@ -1067,7 +1068,7 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
|
52
src/event.c
52
src/event.c
|
@ -78,10 +78,12 @@ void *rig_poll_routine(void *arg)
|
|||
freq_t freq_main = 0, freq_sub = 0, freq_main_prev = 0, freq_sub_prev = 0;
|
||||
rmode_t mode_main = RIG_MODE_NONE, mode_sub = RIG_MODE_NONE,
|
||||
mode_main_prev = RIG_MODE_NONE, mode_sub_prev = RIG_MODE_NONE;
|
||||
pbwidth_t width_main = 0, width_sub = 0, width_main_prev = 0, width_sub_prev = 0;
|
||||
pbwidth_t width_main = 0, width_sub = 0, width_main_prev = 0,
|
||||
width_sub_prev = 0;
|
||||
split_t split, split_prev = -1;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Starting rig poll routine thread\n", __FILE__, __LINE__);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Starting rig poll routine thread\n",
|
||||
__FILE__, __LINE__);
|
||||
|
||||
// Rig cache time should be equal to rig poll interval (should be set automatically by rigctld at least)
|
||||
rig_set_cache_timeout_ms(rig, HAMLIB_CACHE_ALL, rs->poll_interval);
|
||||
|
@ -93,9 +95,11 @@ void *rig_poll_routine(void *arg)
|
|||
if (rig->caps->get_vfo)
|
||||
{
|
||||
result = rig_get_vfo(rig, &vfo);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_vfo error %s\n", __FILE__, __LINE__, rigerror(result));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_vfo error %s\n", __FILE__, __LINE__,
|
||||
rigerror(result));
|
||||
}
|
||||
|
||||
if (vfo != vfo_prev)
|
||||
|
@ -119,20 +123,23 @@ void *rig_poll_routine(void *arg)
|
|||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_freqA error %s\n", __FILE__, __LINE__, rigerror(result));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_freqA error %s\n", __FILE__, __LINE__,
|
||||
rigerror(result));
|
||||
}
|
||||
|
||||
result = rig_get_freq(rig, RIG_VFO_B, &freq_sub);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_freqB error %s\n", __FILE__, __LINE__, rigerror(result));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_freqB error %s\n", __FILE__, __LINE__,
|
||||
rigerror(result));
|
||||
}
|
||||
|
||||
if (freq_main != freq_main_prev)
|
||||
{
|
||||
rig_fire_freq_event(rig, RIG_VFO_A, freq_main);
|
||||
}
|
||||
|
||||
if (freq_sub != freq_sub_prev)
|
||||
{
|
||||
rig_fire_freq_event(rig, RIG_VFO_B, freq_sub);
|
||||
|
@ -155,20 +162,23 @@ void *rig_poll_routine(void *arg)
|
|||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeA error %s\n", __FILE__, __LINE__, rigerror(result));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeA error %s\n", __FILE__, __LINE__,
|
||||
rigerror(result));
|
||||
}
|
||||
|
||||
result = rig_get_mode(rig, RIG_VFO_B, &mode_sub, &width_sub);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeB error %s\n", __FILE__, __LINE__, rigerror(result));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeB error %s\n", __FILE__, __LINE__,
|
||||
rigerror(result));
|
||||
}
|
||||
|
||||
if (mode_main != mode_main_prev || width_main != width_main_prev)
|
||||
{
|
||||
rig_fire_mode_event(rig, RIG_VFO_A, mode_main, width_main);
|
||||
}
|
||||
|
||||
if (mode_sub != mode_sub_prev || width_sub != width_sub_prev)
|
||||
{
|
||||
rig_fire_mode_event(rig, RIG_VFO_B, mode_sub, width_sub);
|
||||
|
@ -202,12 +212,14 @@ void *rig_poll_routine(void *arg)
|
|||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeA error %s\n", __FILE__, __LINE__, rigerror(result));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig_get_modeA error %s\n", __FILE__, __LINE__,
|
||||
rigerror(result));
|
||||
}
|
||||
|
||||
if (split != split_prev)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_CACHE, "%s(%d) split=%d was %d\n", __FILE__, __LINE__, split,
|
||||
rig_debug(RIG_DEBUG_CACHE, "%s(%d) split=%d was %d\n", __FILE__, __LINE__,
|
||||
split,
|
||||
split_prev);
|
||||
update_occurred = 1;
|
||||
split_prev = split;
|
||||
|
@ -222,7 +234,8 @@ void *rig_poll_routine(void *arg)
|
|||
hl_usleep(rs->poll_interval * 1000);
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Stopping rig poll routine thread\n", __FILE__,
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Stopping rig poll routine thread\n",
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
|
||||
return NULL;
|
||||
|
@ -244,7 +257,8 @@ int rig_poll_routine_start(RIG *rig)
|
|||
|
||||
if (rs->poll_interval < 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): rig poll routine disabled, poll interval set to zero\n", __FILE__,
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s(%d): rig poll routine disabled, poll interval set to zero\n", __FILE__,
|
||||
__LINE__);
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
@ -258,6 +272,7 @@ int rig_poll_routine_start(RIG *rig)
|
|||
|
||||
rs->poll_routine_thread_run = 1;
|
||||
rs->poll_routine_priv_data = calloc(1, sizeof(rig_poll_routine_priv_data));
|
||||
|
||||
if (rs->poll_routine_priv_data == NULL)
|
||||
{
|
||||
RETURNFUNC(-RIG_ENOMEM);
|
||||
|
@ -270,7 +285,8 @@ int rig_poll_routine_start(RIG *rig)
|
|||
|
||||
if (err)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d) pthread_create error: %s\n", __FILE__, __LINE__,
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d) pthread_create error: %s\n", __FILE__,
|
||||
__LINE__,
|
||||
strerror(errno));
|
||||
RETURNFUNC(-RIG_EINTERNAL);
|
||||
}
|
||||
|
@ -637,7 +653,8 @@ int rig_fire_ptt_event(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
{
|
||||
ENTERFUNC;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "Event: PTT changed to %i on %s\n", ptt, rig_strvfo(vfo));
|
||||
rig_debug(RIG_DEBUG_TRACE, "Event: PTT changed to %i on %s\n", ptt,
|
||||
rig_strvfo(vfo));
|
||||
|
||||
rig->state.cache.ptt = ptt;
|
||||
elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_SET);
|
||||
|
@ -657,7 +674,8 @@ int rig_fire_dcd_event(RIG *rig, vfo_t vfo, dcd_t dcd)
|
|||
{
|
||||
ENTERFUNC;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "Event: DCD changed to %i on %s\n", dcd, rig_strvfo(vfo));
|
||||
rig_debug(RIG_DEBUG_TRACE, "Event: DCD changed to %i on %s\n", dcd,
|
||||
rig_strvfo(vfo));
|
||||
|
||||
network_publish_rig_transceive_data(rig);
|
||||
|
||||
|
@ -670,11 +688,13 @@ int rig_fire_dcd_event(RIG *rig, vfo_t vfo, dcd_t dcd)
|
|||
}
|
||||
|
||||
|
||||
int rig_fire_pltune_event(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode, pbwidth_t *width)
|
||||
int rig_fire_pltune_event(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode,
|
||||
pbwidth_t *width)
|
||||
{
|
||||
ENTERFUNC;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "Event: Pipelined tuning event, vfo=%s\n", rig_strvfo(vfo));
|
||||
rig_debug(RIG_DEBUG_TRACE, "Event: Pipelined tuning event, vfo=%s\n",
|
||||
rig_strvfo(vfo));
|
||||
|
||||
network_publish_rig_transceive_data(rig);
|
||||
|
||||
|
|
223
src/iofunc.c
223
src/iofunc.c
|
@ -83,23 +83,28 @@ static int create_sync_data_pipe(hamlib_port_t *p)
|
|||
{
|
||||
int status;
|
||||
|
||||
status = async_pipe_create(&p->sync_data_pipe, PIPE_BUFFER_SIZE_DEFAULT, p->timeout);
|
||||
status = async_pipe_create(&p->sync_data_pipe, PIPE_BUFFER_SIZE_DEFAULT,
|
||||
p->timeout);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
close_sync_data_pipe(p);
|
||||
return(-RIG_EINTERNAL);
|
||||
return (-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
status = async_pipe_create(&p->sync_data_error_pipe, PIPE_BUFFER_SIZE_DEFAULT, p->timeout);
|
||||
status = async_pipe_create(&p->sync_data_error_pipe, PIPE_BUFFER_SIZE_DEFAULT,
|
||||
p->timeout);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
close_sync_data_pipe(p);
|
||||
return(-RIG_EINTERNAL);
|
||||
return (-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: created data pipe for synchronous transactions\n", __func__);
|
||||
rig_debug(RIG_DEBUG_VERBOSE,
|
||||
"%s: created data pipe for synchronous transactions\n", __func__);
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -114,21 +119,27 @@ static void init_sync_data_pipe(hamlib_port_t *p)
|
|||
|
||||
static void close_sync_data_pipe(hamlib_port_t *p)
|
||||
{
|
||||
if (p->fd_sync_read != -1) {
|
||||
if (p->fd_sync_read != -1)
|
||||
{
|
||||
close(p->fd_sync_read);
|
||||
p->fd_sync_read = -1;
|
||||
}
|
||||
if (p->fd_sync_write != -1) {
|
||||
|
||||
if (p->fd_sync_write != -1)
|
||||
{
|
||||
close(p->fd_sync_write);
|
||||
p->fd_sync_write = -1;
|
||||
}
|
||||
|
||||
|
||||
if (p->fd_sync_error_read != -1) {
|
||||
if (p->fd_sync_error_read != -1)
|
||||
{
|
||||
close(p->fd_sync_error_read);
|
||||
p->fd_sync_error_read = -1;
|
||||
}
|
||||
if (p->fd_sync_error_write != -1) {
|
||||
|
||||
if (p->fd_sync_error_write != -1)
|
||||
{
|
||||
close(p->fd_sync_error_write);
|
||||
p->fd_sync_error_write = -1;
|
||||
}
|
||||
|
@ -143,22 +154,29 @@ static int create_sync_data_pipe(hamlib_port_t *p)
|
|||
status = pipe(sync_pipe_fds);
|
||||
flags = fcntl(sync_pipe_fds[0], F_GETFL);
|
||||
flags |= O_NONBLOCK;
|
||||
|
||||
if (fcntl(sync_pipe_fds[0], F_SETFL, flags))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on sync_read=%s\n", __func__, strerror(errno));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on sync_read=%s\n",
|
||||
__func__, strerror(errno));
|
||||
}
|
||||
|
||||
flags = fcntl(sync_pipe_fds[1], F_GETFL);
|
||||
flags |= O_NONBLOCK;
|
||||
|
||||
if (fcntl(sync_pipe_fds[1], F_SETFL, flags))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on sync_write=%s\n", __func__, strerror(errno));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on sync_write=%s\n",
|
||||
__func__, strerror(errno));
|
||||
}
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: synchronous data pipe open status=%d, err=%s\n", __func__,
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: synchronous data pipe open status=%d, err=%s\n",
|
||||
__func__,
|
||||
status, strerror(errno));
|
||||
close_sync_data_pipe(p);
|
||||
return(-RIG_EINTERNAL);
|
||||
return (-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
p->fd_sync_read = sync_pipe_fds[0];
|
||||
|
@ -167,30 +185,38 @@ static int create_sync_data_pipe(hamlib_port_t *p)
|
|||
status = pipe(sync_pipe_fds);
|
||||
flags = fcntl(sync_pipe_fds[0], F_GETFL);
|
||||
flags |= O_NONBLOCK;
|
||||
|
||||
if (fcntl(sync_pipe_fds[0], F_SETFL, flags))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on error_read=%s\n", __func__, strerror(errno));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on error_read=%s\n",
|
||||
__func__, strerror(errno));
|
||||
}
|
||||
|
||||
flags = fcntl(sync_pipe_fds[1], F_GETFL);
|
||||
flags |= O_NONBLOCK;
|
||||
|
||||
if (fcntl(sync_pipe_fds[1], F_SETFL, flags))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on error_write=%s\n", __func__, strerror(errno));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on error_write=%s\n",
|
||||
__func__, strerror(errno));
|
||||
}
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: synchronous data error code pipe open status=%d, err=%s\n", __func__,
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: synchronous data error code pipe open status=%d, err=%s\n", __func__,
|
||||
status, strerror(errno));
|
||||
close_sync_data_pipe(p);
|
||||
return(-RIG_EINTERNAL);
|
||||
return (-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
p->fd_sync_error_read = sync_pipe_fds[0];
|
||||
p->fd_sync_error_write = sync_pipe_fds[1];
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: created data pipe for synchronous transactions\n", __func__);
|
||||
rig_debug(RIG_DEBUG_VERBOSE,
|
||||
"%s: created data pipe for synchronous transactions\n", __func__);
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -211,9 +237,10 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
|||
if (p->asyncio)
|
||||
{
|
||||
status = create_sync_data_pipe(p);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,7 +254,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
|||
rig_debug(RIG_DEBUG_ERR, "%s: serial_open(%s) status=%d, err=%s\n", __func__,
|
||||
p->pathname, status, strerror(errno));
|
||||
close_sync_data_pipe(p);
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
if (p->parm.serial.rts_state != RIG_SIGNAL_UNSET
|
||||
|
@ -241,7 +268,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
|||
if (status != 0)
|
||||
{
|
||||
close_sync_data_pipe(p);
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
if (p->parm.serial.dtr_state != RIG_SIGNAL_UNSET)
|
||||
|
@ -255,7 +282,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
|||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: set_dtr status=%d\n", __func__, status);
|
||||
close_sync_data_pipe(p);
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -275,7 +302,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
|||
if (status < 0)
|
||||
{
|
||||
close_sync_data_pipe(p);
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -286,7 +313,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
|||
if (status < 0)
|
||||
{
|
||||
close_sync_data_pipe(p);
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -297,7 +324,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
|||
if (status < 0)
|
||||
{
|
||||
close_sync_data_pipe(p);
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
p->fd = status;
|
||||
|
@ -311,7 +338,7 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
|||
if (status < 0)
|
||||
{
|
||||
close_sync_data_pipe(p);
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -329,17 +356,17 @@ int HAMLIB_API port_open(hamlib_port_t *p)
|
|||
if (status < 0)
|
||||
{
|
||||
close_sync_data_pipe(p);
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
close_sync_data_pipe(p);
|
||||
return(-RIG_EINVAL);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -387,7 +414,7 @@ int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type)
|
|||
|
||||
close_sync_data_pipe(p);
|
||||
|
||||
return(ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
|
@ -402,9 +429,11 @@ static int port_read_sync_data_error_code(hamlib_port_t *p)
|
|||
signed char data;
|
||||
int result;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
// Wait for data using a zero-length read
|
||||
result = async_pipe_read(p->sync_data_error_pipe, &data, 0, p->timeout);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
if (result == -RIG_ETIMEOUT)
|
||||
|
@ -419,6 +448,7 @@ static int port_read_sync_data_error_code(hamlib_port_t *p)
|
|||
}
|
||||
|
||||
result = async_pipe_read(p->sync_data_error_pipe, &data, 1, p->timeout);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
if (result == -RIG_ETIMEOUT)
|
||||
|
@ -433,7 +463,8 @@ static int port_read_sync_data_error_code(hamlib_port_t *p)
|
|||
}
|
||||
|
||||
total_bytes_read += result;
|
||||
} while (result > 0);
|
||||
}
|
||||
while (result > 0);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -441,7 +472,8 @@ static int port_read_sync_data_error_code(hamlib_port_t *p)
|
|||
static int port_read_sync_data(hamlib_port_t *p, void *buf, size_t count)
|
||||
{
|
||||
// Wait for data in both the response data pipe and the error code pipe to detect errors occurred during read
|
||||
HANDLE event_handles[2] = {
|
||||
HANDLE event_handles[2] =
|
||||
{
|
||||
p->sync_data_pipe->read_overlapped.hEvent,
|
||||
p->sync_data_error_pipe->read_overlapped.hEvent,
|
||||
};
|
||||
|
@ -452,14 +484,17 @@ static int port_read_sync_data(hamlib_port_t *p, void *buf, size_t count)
|
|||
ssize_t bytes_read;
|
||||
|
||||
result = ReadFile(p->sync_data_pipe->read, buf, count, NULL, overlapped);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
result = GetLastError();
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
// No error?
|
||||
break;
|
||||
|
||||
case ERROR_IO_PENDING:
|
||||
wait_result = WaitForMultipleObjects(2, event_handles, FALSE, p->timeout);
|
||||
|
||||
|
@ -485,30 +520,39 @@ static int port_read_sync_data(hamlib_port_t *p, void *buf, size_t count)
|
|||
|
||||
default:
|
||||
result = GetLastError();
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): WaitForMultipleObjects() error: %d\n", __func__, result);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): WaitForMultipleObjects() error: %d\n", __func__,
|
||||
result);
|
||||
return -RIG_EINTERNAL;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): ReadFile() error: %d\n", __func__, result);
|
||||
return -RIG_EIO;
|
||||
}
|
||||
}
|
||||
|
||||
result = GetOverlappedResult(read_handle, overlapped, (LPDWORD) &bytes_read, FALSE);
|
||||
result = GetOverlappedResult(read_handle, overlapped, (LPDWORD) &bytes_read,
|
||||
FALSE);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
result = GetLastError();
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
// No error?
|
||||
break;
|
||||
|
||||
case ERROR_IO_PENDING:
|
||||
// Shouldn't happen?
|
||||
return -RIG_ETIMEOUT;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): GetOverlappedResult() error: %d\n", __func__, result);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): GetOverlappedResult() error: %d\n", __func__,
|
||||
result);
|
||||
return -RIG_EIO;
|
||||
}
|
||||
}
|
||||
|
@ -532,7 +576,8 @@ static int port_wait_for_data_sync_pipe(hamlib_port_t *p)
|
|||
return result;
|
||||
}
|
||||
|
||||
static ssize_t port_read_sync_data_pipe(hamlib_port_t *p, void *buf, size_t count)
|
||||
static ssize_t port_read_sync_data_pipe(hamlib_port_t *p, void *buf,
|
||||
size_t count)
|
||||
{
|
||||
return port_read_sync_data(p, buf, count);
|
||||
}
|
||||
|
@ -540,7 +585,8 @@ static ssize_t port_read_sync_data_pipe(hamlib_port_t *p, void *buf, size_t coun
|
|||
/* On MinGW32/MSVC/.. the appropriate accessor must be used
|
||||
* depending on the port type, sigh.
|
||||
*/
|
||||
static ssize_t port_read_generic(hamlib_port_t *p, void *buf, size_t count, int direct)
|
||||
static ssize_t port_read_generic(hamlib_port_t *p, void *buf, size_t count,
|
||||
int direct)
|
||||
{
|
||||
int fd = p->fd;
|
||||
int i;
|
||||
|
@ -711,15 +757,18 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
|
|||
{
|
||||
return port_wait_for_data_direct(p);
|
||||
}
|
||||
|
||||
return port_wait_for_data_sync_pipe(p);
|
||||
}
|
||||
|
||||
int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
|
||||
int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer,
|
||||
size_t count)
|
||||
{
|
||||
return async_pipe_write(p->sync_data_pipe, txbuffer, count, p->timeout);
|
||||
}
|
||||
|
||||
int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
|
||||
int HAMLIB_API write_block_sync_error(hamlib_port_t *p,
|
||||
const unsigned char *txbuffer, size_t count)
|
||||
{
|
||||
return async_pipe_write(p->sync_data_error_pipe, txbuffer, count, p->timeout);
|
||||
}
|
||||
|
@ -728,7 +777,8 @@ int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txb
|
|||
|
||||
/* POSIX */
|
||||
|
||||
static ssize_t port_read_generic(hamlib_port_t *p, void *buf, size_t count, int direct)
|
||||
static ssize_t port_read_generic(hamlib_port_t *p, void *buf, size_t count,
|
||||
int direct)
|
||||
{
|
||||
int fd = direct ? p->fd : p->fd_sync_read;
|
||||
|
||||
|
@ -768,7 +818,8 @@ static int port_read_sync_data_error_code(hamlib_port_t *p, int fd, int direct)
|
|||
int result;
|
||||
signed char data;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
tv_timeout.tv_sec = 0;
|
||||
tv_timeout.tv_usec = 0;
|
||||
|
||||
|
@ -777,15 +828,20 @@ static int port_read_sync_data_error_code(hamlib_port_t *p, int fd, int direct)
|
|||
efds = rfds;
|
||||
|
||||
result = port_select(p, fd + 1, &rfds, NULL, &efds, &tv_timeout, direct);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(): select() timeout, direct=%d\n", __func__, direct);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(): select() timeout, direct=%d\n", __func__,
|
||||
direct);
|
||||
return -RIG_ETIMEOUT;
|
||||
}
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
if (total_bytes_read > 0) {
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(): returning error code %d, direct=%d\n", __func__, (int) data, direct);
|
||||
if (total_bytes_read > 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(): returning error code %d, direct=%d\n",
|
||||
__func__, (int) data, direct);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -801,7 +857,8 @@ static int port_read_sync_data_error_code(hamlib_port_t *p, int fd, int direct)
|
|||
|
||||
bytes_read = read(fd, &data, 1);
|
||||
total_bytes_read += bytes_read;
|
||||
} while (bytes_read > 0);
|
||||
}
|
||||
while (bytes_read > 0);
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(): returning error code %d\n", __func__, data);
|
||||
|
||||
|
@ -826,10 +883,12 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
|
|||
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(fd, &rfds);
|
||||
|
||||
if (!direct)
|
||||
{
|
||||
FD_SET(errorfd, &rfds);
|
||||
}
|
||||
|
||||
efds = rfds;
|
||||
|
||||
result = port_select(p, maxfd + 1, &rfds, NULL, &efds, &tv, direct);
|
||||
|
@ -853,17 +912,20 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
|
|||
rig_debug(RIG_DEBUG_ERR, "%s(): fd error, direct=%d\n", __func__, direct);
|
||||
return -RIG_EIO;
|
||||
}
|
||||
|
||||
if (!direct)
|
||||
{
|
||||
if (FD_ISSET(errorfd, &efds))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): fd error from sync error pipe, direct=%d\n", __func__, direct);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): fd error from sync error pipe, direct=%d\n",
|
||||
__func__, direct);
|
||||
return -RIG_EIO;
|
||||
}
|
||||
|
||||
if (FD_ISSET(errorfd, &rfds))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(): attempting to read error code, direct=%d\n", __func__, direct);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(): attempting to read error code, direct=%d\n",
|
||||
__func__, direct);
|
||||
return port_read_sync_data_error_code(p, errorfd, 0);
|
||||
}
|
||||
}
|
||||
|
@ -871,7 +933,8 @@ static int port_wait_for_data(hamlib_port_t *p, int direct)
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
|
||||
int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer,
|
||||
size_t count)
|
||||
{
|
||||
|
||||
if (!p->asyncio)
|
||||
|
@ -882,7 +945,8 @@ int HAMLIB_API write_block_sync(hamlib_port_t *p, const unsigned char *txbuffer,
|
|||
return (int) write(p->fd_sync_write, txbuffer, count);
|
||||
}
|
||||
|
||||
int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
|
||||
int HAMLIB_API write_block_sync_error(hamlib_port_t *p,
|
||||
const unsigned char *txbuffer, size_t count)
|
||||
{
|
||||
if (!p->asyncio)
|
||||
{
|
||||
|
@ -923,16 +987,18 @@ int HAMLIB_API write_block_sync_error(hamlib_port_t *p, const unsigned char *txb
|
|||
* it could work very well also with any file handle, like a socket.
|
||||
*/
|
||||
|
||||
int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer, size_t count)
|
||||
int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer,
|
||||
size_t count)
|
||||
{
|
||||
int ret;
|
||||
int method=0;
|
||||
int method = 0;
|
||||
|
||||
if (p->fd < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: port not open\n", __func__);
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
#ifdef WANT_NON_ACTIVE_POST_WRITE_DELAY
|
||||
|
||||
if (p->post_write_date.tv_sec != 0)
|
||||
|
@ -1001,7 +1067,8 @@ int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer, size
|
|||
}
|
||||
}
|
||||
|
||||
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, method=%d\n", __func__,
|
||||
(int)count, method);
|
||||
dump_hex((unsigned char *) txbuffer, count);
|
||||
|
||||
if (p->post_write_delay > 0)
|
||||
|
@ -1028,7 +1095,8 @@ int HAMLIB_API write_block(hamlib_port_t *p, const unsigned char *txbuffer, size
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t count, int direct)
|
||||
static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer,
|
||||
size_t count, int direct)
|
||||
{
|
||||
struct timeval start_time, end_time, elapsed_time;
|
||||
int total_count = 0;
|
||||
|
@ -1078,7 +1146,9 @@ static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t
|
|||
{
|
||||
dump_hex((unsigned char *) rxbuffer, total_count);
|
||||
}
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): I/O error after %d chars, direct=%d: %d\n", __func__, total_count, direct, result);
|
||||
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): I/O error after %d chars, direct=%d: %d\n",
|
||||
__func__, total_count, direct, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1090,7 +1160,8 @@ static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t
|
|||
|
||||
if (rd_count < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): read failed, direct=%d - %s\n", __func__, direct, strerror(errno));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): read failed, direct=%d - %s\n", __func__,
|
||||
direct, strerror(errno));
|
||||
return -RIG_EIO;
|
||||
}
|
||||
|
||||
|
@ -1100,7 +1171,8 @@ static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t
|
|||
|
||||
if (direct)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s(): RX %d bytes, direct=%d\n", __func__, total_count, direct);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s(): RX %d bytes, direct=%d\n", __func__,
|
||||
total_count, direct);
|
||||
dump_hex((unsigned char *) rxbuffer, total_count);
|
||||
}
|
||||
|
||||
|
@ -1126,7 +1198,8 @@ static int read_block_generic(hamlib_port_t *p, unsigned char *rxbuffer, size_t
|
|||
* it could work very well also with any file handle, like a socket.
|
||||
*/
|
||||
|
||||
int HAMLIB_API read_block(hamlib_port_t *p, unsigned char *rxbuffer, size_t count)
|
||||
int HAMLIB_API read_block(hamlib_port_t *p, unsigned char *rxbuffer,
|
||||
size_t count)
|
||||
{
|
||||
return read_block_generic(p, rxbuffer, count, !p->asyncio);
|
||||
}
|
||||
|
@ -1149,7 +1222,8 @@ int HAMLIB_API read_block(hamlib_port_t *p, unsigned char *rxbuffer, size_t coun
|
|||
* it could work very well also with any file handle, like a socket.
|
||||
*/
|
||||
|
||||
int HAMLIB_API read_block_direct(hamlib_port_t *p, unsigned char *rxbuffer, size_t count)
|
||||
int HAMLIB_API read_block_direct(hamlib_port_t *p, unsigned char *rxbuffer,
|
||||
size_t count)
|
||||
{
|
||||
return read_block_generic(p, rxbuffer, count, 1);
|
||||
}
|
||||
|
@ -1173,7 +1247,8 @@ static int read_string_generic(hamlib_port_t *p,
|
|||
return -RIG_EINTERNAL;
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called, rxmax=%d direct=%d\n", __func__, (int)rxmax, direct);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called, rxmax=%d direct=%d\n", __func__,
|
||||
(int)rxmax, direct);
|
||||
|
||||
if (!p || !rxbuffer)
|
||||
{
|
||||
|
@ -1213,6 +1288,7 @@ static int read_string_generic(hamlib_port_t *p,
|
|||
{
|
||||
dump_hex((unsigned char *) rxbuffer, total_count);
|
||||
}
|
||||
|
||||
if (!flush_flag)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN,
|
||||
|
@ -1236,7 +1312,9 @@ static int read_string_generic(hamlib_port_t *p,
|
|||
{
|
||||
dump_hex(rxbuffer, total_count);
|
||||
}
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): I/O error after %d chars, direct=%d: %d\n", __func__, total_count, direct, result);
|
||||
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): I/O error after %d chars, direct=%d: %d\n",
|
||||
__func__, total_count, direct, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1246,12 +1324,15 @@ static int read_string_generic(hamlib_port_t *p,
|
|||
*/
|
||||
do
|
||||
{
|
||||
rd_count = port_read_generic(p, &rxbuffer[total_count], expected_len == 1 ? 1 : minlen, direct);
|
||||
rd_count = port_read_generic(p, &rxbuffer[total_count],
|
||||
expected_len == 1 ? 1 : minlen, direct);
|
||||
minlen -= rd_count;
|
||||
|
||||
if (errno == EAGAIN)
|
||||
{
|
||||
hl_usleep(5 * 1000);
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: port_read is busy? direct=%d\n", __func__, direct);
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: port_read is busy? direct=%d\n", __func__,
|
||||
direct);
|
||||
}
|
||||
}
|
||||
while (++i < 10 && errno == EBUSY); // 50ms should be enough
|
||||
|
@ -1263,7 +1344,9 @@ static int read_string_generic(hamlib_port_t *p,
|
|||
{
|
||||
dump_hex((unsigned char *) rxbuffer, total_count);
|
||||
}
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): read failed, direct=%d - %s\n", __func__, direct, strerror(errno));
|
||||
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): read failed, direct=%d - %s\n", __func__,
|
||||
direct, strerror(errno));
|
||||
|
||||
return -RIG_EIO;
|
||||
}
|
||||
|
@ -1340,7 +1423,8 @@ int HAMLIB_API read_string(hamlib_port_t *p,
|
|||
int flush_flag,
|
||||
int expected_len)
|
||||
{
|
||||
return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, expected_len, !p->asyncio);
|
||||
return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag,
|
||||
expected_len, !p->asyncio);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1378,7 +1462,8 @@ int HAMLIB_API read_string_direct(hamlib_port_t *p,
|
|||
int flush_flag,
|
||||
int expected_len)
|
||||
{
|
||||
return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, expected_len, 1);
|
||||
return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag,
|
||||
expected_len, 1);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -1179,7 +1179,7 @@ int HAMLIB_API rig_set_chan_all(RIG *rig, vfo_t vfo, const channel_t chans[])
|
|||
}
|
||||
|
||||
rc = rig->caps;
|
||||
memset(&map_arg,0,sizeof(map_arg));
|
||||
memset(&map_arg, 0, sizeof(map_arg));
|
||||
map_arg.chans = (channel_t *) chans;
|
||||
|
||||
if (rc->set_chan_all_cb)
|
||||
|
@ -1222,7 +1222,7 @@ int HAMLIB_API rig_get_chan_all(RIG *rig, vfo_t vfo, channel_t chans[])
|
|||
}
|
||||
|
||||
rc = rig->caps;
|
||||
memset(&map_arg,0,sizeof(map_arg));
|
||||
memset(&map_arg, 0, sizeof(map_arg));
|
||||
map_arg.chans = chans;
|
||||
|
||||
if (rc->get_chan_all_cb)
|
||||
|
|
10
src/misc.c
10
src/misc.c
|
@ -313,7 +313,7 @@ size_t HAMLIB_API to_hex(size_t source_length, const unsigned char *source_data,
|
|||
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
SNPRINTF(dest, dest_length - 2*i, "%02X", source[0]);
|
||||
SNPRINTF(dest, dest_length - 2 * i, "%02X", source[0]);
|
||||
source++;
|
||||
dest += 2;
|
||||
}
|
||||
|
@ -1867,7 +1867,8 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split)
|
|||
__func__, funcname, linenum,
|
||||
rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo), split);
|
||||
|
||||
if (vfo == RIG_VFO_NONE) vfo = RIG_VFO_A;
|
||||
if (vfo == RIG_VFO_NONE) { vfo = RIG_VFO_A; }
|
||||
|
||||
if (vfo == RIG_VFO_CURR || vfo == RIG_VFO_VFO)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: Leaving currVFO alone\n", __func__);
|
||||
|
@ -1962,7 +1963,8 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split)
|
|||
return vfo;
|
||||
}
|
||||
|
||||
int HAMLIB_API parse_hoststr(char *hoststr, int hoststr_len, char host[256], char port[6])
|
||||
int HAMLIB_API parse_hoststr(char *hoststr, int hoststr_len, char host[256],
|
||||
char port[6])
|
||||
{
|
||||
unsigned int net1, net2, net3, net4, net5, net6, net7, net8;
|
||||
char dummy[6], link[32], *p;
|
||||
|
@ -2467,7 +2469,7 @@ long long HAMLIB_API rig_get_caps_int(rig_model_t rig_model,
|
|||
|
||||
default:
|
||||
//rig_debug(RIG_DEBUG_ERR, "%s: Unknown rig_caps value=%lld\n", __func__, rig_caps);
|
||||
return(-RIG_EINVAL);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
295
src/network.c
295
src/network.c
|
@ -179,7 +179,7 @@ int network_init()
|
|||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error creating socket, WSAStartup ret=%d\n",
|
||||
__func__, ret);
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,13 +209,13 @@ int network_open(hamlib_port_t *rp, int default_port)
|
|||
#ifdef __MINGW32__
|
||||
status = network_init();
|
||||
|
||||
if (status != RIG_OK) { return(status); }
|
||||
if (status != RIG_OK) { return (status); }
|
||||
|
||||
#endif
|
||||
|
||||
if (!rp)
|
||||
{
|
||||
return(-RIG_EINVAL);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
|
@ -241,7 +241,7 @@ int network_open(hamlib_port_t *rp, int default_port)
|
|||
{
|
||||
status = parse_hoststr(rp->pathname, sizeof(rp->pathname), hoststr, portstr);
|
||||
|
||||
if (status != RIG_OK) { return(status); }
|
||||
if (status != RIG_OK) { return (status); }
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: hoststr=%s, portstr=%s\n", __func__, hoststr,
|
||||
portstr);
|
||||
|
@ -287,7 +287,7 @@ int network_open(hamlib_port_t *rp, int default_port)
|
|||
__func__,
|
||||
rp->pathname,
|
||||
gai_strerror(status));
|
||||
return(-RIG_ECONF);
|
||||
return (-RIG_ECONF);
|
||||
}
|
||||
|
||||
saved_res = res;
|
||||
|
@ -306,7 +306,7 @@ int network_open(hamlib_port_t *rp, int default_port)
|
|||
{
|
||||
handle_error(RIG_DEBUG_ERR, "socket");
|
||||
freeaddrinfo(saved_res);
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
if (connect(fd, res->ai_addr, res->ai_addrlen) == 0)
|
||||
|
@ -334,7 +334,7 @@ int network_open(hamlib_port_t *rp, int default_port)
|
|||
"%s: failed to connect to %s\n",
|
||||
__func__,
|
||||
rp->pathname);
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
rp->fd = fd;
|
||||
|
@ -344,7 +344,7 @@ int network_open(hamlib_port_t *rp, int default_port)
|
|||
rig_debug(RIG_DEBUG_TRACE, "%s: client port=%d\n", __func__, client.sin_port);
|
||||
rp->client_port = client.sin_port;
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -437,7 +437,7 @@ int network_close(hamlib_port_t *rp)
|
|||
}
|
||||
|
||||
#endif
|
||||
return(ret);
|
||||
return (ret);
|
||||
}
|
||||
//! @endcond
|
||||
|
||||
|
@ -450,146 +450,186 @@ extern void sync_callback(int lock);
|
|||
|
||||
#if defined(WIN32) && defined(HAVE_WINDOWS_H)
|
||||
|
||||
static int multicast_publisher_create_data_pipe(multicast_publisher_priv_data *mcast_publisher_priv)
|
||||
static int multicast_publisher_create_data_pipe(multicast_publisher_priv_data
|
||||
*mcast_publisher_priv)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = async_pipe_create(&mcast_publisher_priv->args.data_pipe, PIPE_BUFFER_SIZE_DEFAULT, MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
|
||||
status = async_pipe_create(&mcast_publisher_priv->args.data_pipe,
|
||||
PIPE_BUFFER_SIZE_DEFAULT, MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: multicast publisher data pipe creation failed with status=%d, err=%s\n", __func__,
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: multicast publisher data pipe creation failed with status=%d, err=%s\n",
|
||||
__func__,
|
||||
status, strerror(errno));
|
||||
return(-RIG_EINTERNAL);
|
||||
return (-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
static void multicast_publisher_close_data_pipe(multicast_publisher_priv_data *mcast_publisher_priv)
|
||||
static void multicast_publisher_close_data_pipe(multicast_publisher_priv_data
|
||||
*mcast_publisher_priv)
|
||||
{
|
||||
if (mcast_publisher_priv->args.data_pipe != NULL) {
|
||||
if (mcast_publisher_priv->args.data_pipe != NULL)
|
||||
{
|
||||
async_pipe_close(mcast_publisher_priv->args.data_pipe);
|
||||
mcast_publisher_priv->args.data_pipe = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int multicast_publisher_write_data(multicast_publisher_args *mcast_publisher_args, size_t length, const unsigned char *data)
|
||||
static int multicast_publisher_write_data(multicast_publisher_args
|
||||
*mcast_publisher_args, size_t length, const unsigned char *data)
|
||||
{
|
||||
ssize_t result;
|
||||
|
||||
result = async_pipe_write(mcast_publisher_args->data_pipe, data, length, MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
|
||||
result = async_pipe_write(mcast_publisher_args->data_pipe, data, length,
|
||||
MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error writing to multicast publisher data pipe, result=%d\n", __func__, (int)result);
|
||||
return(-RIG_EIO);
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: error writing to multicast publisher data pipe, result=%d\n", __func__,
|
||||
(int)result);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
if (result != length)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: could not write to multicast publisher data pipe, expected %d bytes, wrote %d bytes\n",
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: could not write to multicast publisher data pipe, expected %d bytes, wrote %d bytes\n",
|
||||
__func__, (int)length, (int)result);
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
static int multicast_publisher_read_data(multicast_publisher_args *mcast_publisher_args, size_t length, unsigned char *data)
|
||||
static int multicast_publisher_read_data(multicast_publisher_args
|
||||
*mcast_publisher_args, size_t length, unsigned char *data)
|
||||
{
|
||||
ssize_t result;
|
||||
|
||||
result = async_pipe_wait_for_data(mcast_publisher_args->data_pipe, MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
|
||||
result = async_pipe_wait_for_data(mcast_publisher_args->data_pipe,
|
||||
MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
// Timeout is expected when there is no data
|
||||
if (result != -RIG_ETIMEOUT)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error waiting for multicast publisher data, result=%ld\n", __func__, (long) result);
|
||||
}
|
||||
return(result);
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: error waiting for multicast publisher data, result=%ld\n", __func__,
|
||||
(long) result);
|
||||
}
|
||||
|
||||
result = async_pipe_read(mcast_publisher_args->data_pipe, data, length, MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
|
||||
return (result);
|
||||
}
|
||||
|
||||
result = async_pipe_read(mcast_publisher_args->data_pipe, data, length,
|
||||
MULTICAST_DATA_PIPE_TIMEOUT_MILLIS);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error reading multicast publisher data, result=%ld\n", __func__, (long) result);
|
||||
return(-RIG_EIO);
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: error reading multicast publisher data, result=%ld\n", __func__,
|
||||
(long) result);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
if (result != length)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: could not read from multicast publisher data pipe, expected %ld bytes, read %ld bytes\n",
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: could not read from multicast publisher data pipe, expected %ld bytes, read %ld bytes\n",
|
||||
__func__, (long) length, (long) result);
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int multicast_publisher_create_data_pipe(multicast_publisher_priv_data *mcast_publisher_priv)
|
||||
static int multicast_publisher_create_data_pipe(multicast_publisher_priv_data
|
||||
*mcast_publisher_priv)
|
||||
{
|
||||
int data_pipe_fds[2];
|
||||
int status;
|
||||
|
||||
status = pipe(data_pipe_fds);
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: multicast publisher data pipe creation failed with status=%d, err=%s\n", __func__,
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: multicast publisher data pipe creation failed with status=%d, err=%s\n",
|
||||
__func__,
|
||||
status, strerror(errno));
|
||||
return(-RIG_EINTERNAL);
|
||||
return (-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
int flags = fcntl(data_pipe_fds[0], F_GETFD);
|
||||
flags |= O_NONBLOCK;
|
||||
|
||||
if (fcntl(data_pipe_fds[0], F_SETFD, flags))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on pipe=%s\n", __func__, strerror(errno));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on pipe=%s\n", __func__,
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
mcast_publisher_priv->args.data_read_fd = data_pipe_fds[0];
|
||||
mcast_publisher_priv->args.data_write_fd = data_pipe_fds[1];
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
static void multicast_publisher_close_data_pipe(multicast_publisher_priv_data *mcast_publisher_priv)
|
||||
static void multicast_publisher_close_data_pipe(multicast_publisher_priv_data
|
||||
*mcast_publisher_priv)
|
||||
{
|
||||
if (mcast_publisher_priv->args.data_read_fd != -1) {
|
||||
if (mcast_publisher_priv->args.data_read_fd != -1)
|
||||
{
|
||||
close(mcast_publisher_priv->args.data_read_fd);
|
||||
mcast_publisher_priv->args.data_read_fd = -1;
|
||||
}
|
||||
if (mcast_publisher_priv->args.data_write_fd != -1) {
|
||||
|
||||
if (mcast_publisher_priv->args.data_write_fd != -1)
|
||||
{
|
||||
close(mcast_publisher_priv->args.data_write_fd);
|
||||
mcast_publisher_priv->args.data_write_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int multicast_publisher_write_data(multicast_publisher_args *mcast_publisher_args, size_t length, const unsigned char *data)
|
||||
static int multicast_publisher_write_data(multicast_publisher_args
|
||||
*mcast_publisher_args, size_t length, const unsigned char *data)
|
||||
{
|
||||
int fd = mcast_publisher_args->data_write_fd;
|
||||
ssize_t result;
|
||||
|
||||
result = write(fd, data, length);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error writing to multicast publisher data pipe, result=%d, err=%s\n", __func__,
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: error writing to multicast publisher data pipe, result=%d, err=%s\n",
|
||||
__func__,
|
||||
(int)result, strerror(errno));
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
if (result != length)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: could not write to multicast publisher data pipe, expected %ld bytes, wrote %ld bytes\n",
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: could not write to multicast publisher data pipe, expected %ld bytes, wrote %ld bytes\n",
|
||||
__func__, (long) length, (long) result);
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
static int multicast_publisher_read_data(multicast_publisher_args *mcast_publisher_args, size_t length, unsigned char *data)
|
||||
static int multicast_publisher_read_data(multicast_publisher_args
|
||||
*mcast_publisher_args, size_t length, unsigned char *data)
|
||||
{
|
||||
int fd = mcast_publisher_args->data_read_fd;
|
||||
fd_set rfds, efds;
|
||||
|
@ -605,9 +645,10 @@ static int multicast_publisher_read_data(multicast_publisher_args *mcast_publish
|
|||
efds = rfds;
|
||||
|
||||
retval = select(fd + 1, &rfds, NULL, &efds, &timeout);
|
||||
|
||||
if (retval == 0)
|
||||
{
|
||||
return(-RIG_ETIMEOUT);
|
||||
return (-RIG_ETIMEOUT);
|
||||
}
|
||||
|
||||
if (retval < 0)
|
||||
|
@ -622,35 +663,40 @@ static int multicast_publisher_read_data(multicast_publisher_args *mcast_publish
|
|||
|
||||
if (FD_ISSET(fd, &efds))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(): fd error when reading multicast publisher data\n", __func__);
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s(): fd error when reading multicast publisher data\n", __func__);
|
||||
return -RIG_EIO;
|
||||
}
|
||||
|
||||
result = read(fd, data, length);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
if (errno == EAGAIN)
|
||||
{
|
||||
return(-RIG_ETIMEOUT);
|
||||
return (-RIG_ETIMEOUT);
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error reading multicast publisher data: %s\n", __func__, strerror(errno));
|
||||
return(-RIG_EIO);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error reading multicast publisher data: %s\n",
|
||||
__func__, strerror(errno));
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
if (result != length)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: could not read from multicast publisher data pipe, expected %ld bytes, read %ld bytes\n",
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: could not read from multicast publisher data pipe, expected %ld bytes, read %ld bytes\n",
|
||||
__func__, (long) length, (long) result);
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int multicast_publisher_write_packet_header(RIG *rig, multicast_publisher_data_packet *packet)
|
||||
static int multicast_publisher_write_packet_header(RIG *rig,
|
||||
multicast_publisher_data_packet *packet)
|
||||
{
|
||||
struct rig_state *rs = &rig->state;
|
||||
multicast_publisher_priv_data *mcast_publisher_priv;
|
||||
|
@ -663,11 +709,14 @@ static int multicast_publisher_write_packet_header(RIG *rig, multicast_publisher
|
|||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
mcast_publisher_priv = (multicast_publisher_priv_data *) rs->multicast_publisher_priv_data;
|
||||
mcast_publisher_priv = (multicast_publisher_priv_data *)
|
||||
rs->multicast_publisher_priv_data;
|
||||
mcast_publisher_args = &mcast_publisher_priv->args;
|
||||
|
||||
result = multicast_publisher_write_data(
|
||||
mcast_publisher_args, sizeof(multicast_publisher_data_packet), (unsigned char *) packet);
|
||||
mcast_publisher_args, sizeof(multicast_publisher_data_packet),
|
||||
(unsigned char *) packet);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
RETURNFUNC(result);
|
||||
|
@ -679,7 +728,8 @@ static int multicast_publisher_write_packet_header(RIG *rig, multicast_publisher
|
|||
int network_publish_rig_poll_data(RIG *rig)
|
||||
{
|
||||
struct rig_state *rs = &rig->state;
|
||||
multicast_publisher_data_packet packet = {
|
||||
multicast_publisher_data_packet packet =
|
||||
{
|
||||
.type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_POLL,
|
||||
.padding = 0,
|
||||
.data_length = 0,
|
||||
|
@ -697,7 +747,8 @@ int network_publish_rig_poll_data(RIG *rig)
|
|||
int network_publish_rig_transceive_data(RIG *rig)
|
||||
{
|
||||
struct rig_state *rs = &rig->state;
|
||||
multicast_publisher_data_packet packet = {
|
||||
multicast_publisher_data_packet packet =
|
||||
{
|
||||
.type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_TRANSCEIVE,
|
||||
.padding = 0,
|
||||
.data_length = 0,
|
||||
|
@ -718,7 +769,8 @@ int network_publish_rig_spectrum_data(RIG *rig, struct rig_spectrum_line *line)
|
|||
struct rig_state *rs = &rig->state;
|
||||
multicast_publisher_priv_data *mcast_publisher_priv;
|
||||
multicast_publisher_args *mcast_publisher_args;
|
||||
multicast_publisher_data_packet packet = {
|
||||
multicast_publisher_data_packet packet =
|
||||
{
|
||||
.type = MULTICAST_PUBLISHER_DATA_PACKET_TYPE_SPECTRUM,
|
||||
.padding = 0,
|
||||
.data_length = sizeof(struct rig_spectrum_line) + line->spectrum_data_length,
|
||||
|
@ -731,16 +783,19 @@ int network_publish_rig_spectrum_data(RIG *rig, struct rig_spectrum_line *line)
|
|||
}
|
||||
|
||||
result = multicast_publisher_write_packet_header(rig, &packet);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
RETURNFUNC(result);
|
||||
}
|
||||
|
||||
mcast_publisher_priv = (multicast_publisher_priv_data *) rs->multicast_publisher_priv_data;
|
||||
mcast_publisher_priv = (multicast_publisher_priv_data *)
|
||||
rs->multicast_publisher_priv_data;
|
||||
mcast_publisher_args = &mcast_publisher_priv->args;
|
||||
|
||||
result = multicast_publisher_write_data(
|
||||
mcast_publisher_args, sizeof(struct rig_spectrum_line), (unsigned char *) line);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
RETURNFUNC(result);
|
||||
|
@ -748,6 +803,7 @@ int network_publish_rig_spectrum_data(RIG *rig, struct rig_spectrum_line *line)
|
|||
|
||||
result = multicast_publisher_write_data(
|
||||
mcast_publisher_args, line->spectrum_data_length, line->spectrum_data);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
RETURNFUNC(result);
|
||||
|
@ -756,16 +812,20 @@ int network_publish_rig_spectrum_data(RIG *rig, struct rig_spectrum_line *line)
|
|||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
static int multicast_publisher_read_packet(multicast_publisher_args *mcast_publisher_args,
|
||||
uint8_t *type, struct rig_spectrum_line *spectrum_line, unsigned char *spectrum_data)
|
||||
static int multicast_publisher_read_packet(multicast_publisher_args
|
||||
*mcast_publisher_args,
|
||||
uint8_t *type, struct rig_spectrum_line *spectrum_line,
|
||||
unsigned char *spectrum_data)
|
||||
{
|
||||
int result;
|
||||
multicast_publisher_data_packet packet;
|
||||
|
||||
result = multicast_publisher_read_data(mcast_publisher_args, sizeof(packet), (unsigned char *) &packet);
|
||||
result = multicast_publisher_read_data(mcast_publisher_args, sizeof(packet),
|
||||
(unsigned char *) &packet);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
return(result);
|
||||
return (result);
|
||||
}
|
||||
|
||||
switch (packet.type)
|
||||
|
@ -773,37 +833,49 @@ static int multicast_publisher_read_packet(multicast_publisher_args *mcast_publi
|
|||
case MULTICAST_PUBLISHER_DATA_PACKET_TYPE_POLL:
|
||||
case MULTICAST_PUBLISHER_DATA_PACKET_TYPE_TRANSCEIVE:
|
||||
break;
|
||||
|
||||
case MULTICAST_PUBLISHER_DATA_PACKET_TYPE_SPECTRUM:
|
||||
result = multicast_publisher_read_data(
|
||||
mcast_publisher_args, sizeof(struct rig_spectrum_line), (unsigned char *) spectrum_line);
|
||||
mcast_publisher_args, sizeof(struct rig_spectrum_line),
|
||||
(unsigned char *) spectrum_line);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
return(result);
|
||||
return (result);
|
||||
}
|
||||
|
||||
if (packet.data_length - sizeof(struct rig_spectrum_line) != spectrum_line->spectrum_data_length)
|
||||
if (packet.data_length - sizeof(struct rig_spectrum_line) !=
|
||||
spectrum_line->spectrum_data_length)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: multicast publisher data error, expected %d bytes of spectrum data, got %d bytes\n",
|
||||
__func__, (int)spectrum_line->spectrum_data_length, (int)(packet.data_length - sizeof(struct rig_spectrum_line)));
|
||||
return(-RIG_EPROTO);
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: multicast publisher data error, expected %d bytes of spectrum data, got %d bytes\n",
|
||||
__func__, (int)spectrum_line->spectrum_data_length,
|
||||
(int)(packet.data_length - sizeof(struct rig_spectrum_line)));
|
||||
return (-RIG_EPROTO);
|
||||
}
|
||||
|
||||
spectrum_line->spectrum_data = spectrum_data;
|
||||
|
||||
result = multicast_publisher_read_data(mcast_publisher_args, spectrum_line->spectrum_data_length, spectrum_data);
|
||||
result = multicast_publisher_read_data(mcast_publisher_args,
|
||||
spectrum_line->spectrum_data_length, spectrum_data);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
return(result);
|
||||
return (result);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unexpected multicast publisher data packet type: %d\n", __func__, packet.type);
|
||||
return(-RIG_EPROTO);
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: unexpected multicast publisher data packet type: %d\n", __func__,
|
||||
packet.type);
|
||||
return (-RIG_EPROTO);
|
||||
}
|
||||
|
||||
*type = packet.type;
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
void *multicast_publisher(void *arg)
|
||||
|
@ -811,7 +883,8 @@ void *multicast_publisher(void *arg)
|
|||
unsigned char spectrum_data[HAMLIB_MAX_SPECTRUM_DATA];
|
||||
char snapshot_buffer[HAMLIB_MAX_SNAPSHOT_PACKET_SIZE];
|
||||
|
||||
struct multicast_publisher_args_s *args = (struct multicast_publisher_args_s *)arg;
|
||||
struct multicast_publisher_args_s *args = (struct multicast_publisher_args_s *)
|
||||
arg;
|
||||
RIG *rig = args->rig;
|
||||
struct rig_state *rs = &rig->state;
|
||||
struct rig_spectrum_line spectrum_line;
|
||||
|
@ -822,7 +895,8 @@ void *multicast_publisher(void *arg)
|
|||
int result;
|
||||
ssize_t send_result;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Starting multicast publisher\n", __FILE__, __LINE__);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Starting multicast publisher\n", __FILE__,
|
||||
__LINE__);
|
||||
|
||||
memset(&dest_addr, 0, sizeof(dest_addr));
|
||||
dest_addr.sin_family = AF_INET;
|
||||
|
@ -831,7 +905,9 @@ void *multicast_publisher(void *arg)
|
|||
|
||||
while (rs->multicast_publisher_run)
|
||||
{
|
||||
result = multicast_publisher_read_packet(args, &packet_type, &spectrum_line, spectrum_data);
|
||||
result = multicast_publisher_read_packet(args, &packet_type, &spectrum_line,
|
||||
spectrum_data);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
if (result == -RIG_ETIMEOUT)
|
||||
|
@ -846,14 +922,18 @@ void *multicast_publisher(void *arg)
|
|||
}
|
||||
|
||||
result = snapshot_serialize(sizeof(snapshot_buffer), snapshot_buffer, rig,
|
||||
packet_type == MULTICAST_PUBLISHER_DATA_PACKET_TYPE_SPECTRUM ? &spectrum_line : NULL);
|
||||
packet_type == MULTICAST_PUBLISHER_DATA_PACKET_TYPE_SPECTRUM ? &spectrum_line :
|
||||
NULL);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error serializing rig snapshot data, result=%d\n", __func__, result);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error serializing rig snapshot data, result=%d\n",
|
||||
__func__, result);
|
||||
continue;
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: sending rig snapshot data: %s\n", __func__, snapshot_buffer);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: sending rig snapshot data: %s\n", __func__,
|
||||
snapshot_buffer);
|
||||
|
||||
send_result = sendto(
|
||||
socket_fd,
|
||||
|
@ -863,8 +943,11 @@ void *multicast_publisher(void *arg)
|
|||
(struct sockaddr *) &dest_addr,
|
||||
sizeof(dest_addr)
|
||||
);
|
||||
if (send_result < 0) {
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error sending UDP packet: %s\n", __func__, strerror(errno));
|
||||
|
||||
if (send_result < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error sending UDP packet: %s\n", __func__,
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -899,13 +982,15 @@ int network_multicast_publisher_start(RIG *rig, const char *multicast_addr,
|
|||
|
||||
if (strcmp(multicast_addr, "0.0.0.0") == 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s(%d): not starting multicast publisher\n", __FILE__, __LINE__);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s(%d): not starting multicast publisher\n",
|
||||
__FILE__, __LINE__);
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
if (rs->multicast_publisher_priv_data != NULL)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): multicast publisher already running\n", __FILE__,
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d): multicast publisher already running\n",
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
RETURNFUNC(-RIG_EINVAL);
|
||||
}
|
||||
|
@ -918,19 +1003,24 @@ int network_multicast_publisher_start(RIG *rig, const char *multicast_addr,
|
|||
}
|
||||
|
||||
socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (socket_fd < 0) {
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error opening new UDP socket: %s", __func__, strerror(errno));
|
||||
|
||||
if (socket_fd < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error opening new UDP socket: %s", __func__,
|
||||
strerror(errno));
|
||||
RETURNFUNC(-RIG_EIO);
|
||||
}
|
||||
|
||||
if (items & RIG_MULTICAST_TRANSCEIVE)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) MULTICAST_TRANSCEIVE enabled\n", __FILE__, __LINE__);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) MULTICAST_TRANSCEIVE enabled\n", __FILE__,
|
||||
__LINE__);
|
||||
}
|
||||
|
||||
if (items & RIG_MULTICAST_SPECTRUM)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) MULTICAST_SPECTRUM enabled\n", __FILE__, __LINE__);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) MULTICAST_SPECTRUM enabled\n", __FILE__,
|
||||
__LINE__);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -940,30 +1030,37 @@ int network_multicast_publisher_start(RIG *rig, const char *multicast_addr,
|
|||
|
||||
rs->snapshot_packet_sequence_number = 0;
|
||||
rs->multicast_publisher_run = 1;
|
||||
rs->multicast_publisher_priv_data = calloc(1, sizeof(multicast_publisher_priv_data));
|
||||
rs->multicast_publisher_priv_data = calloc(1,
|
||||
sizeof(multicast_publisher_priv_data));
|
||||
|
||||
if (rs->multicast_publisher_priv_data == NULL)
|
||||
{
|
||||
close(socket_fd);
|
||||
RETURNFUNC(-RIG_ENOMEM);
|
||||
}
|
||||
|
||||
mcast_publisher_priv = (multicast_publisher_priv_data *) rs->multicast_publisher_priv_data;
|
||||
mcast_publisher_priv = (multicast_publisher_priv_data *)
|
||||
rs->multicast_publisher_priv_data;
|
||||
mcast_publisher_priv->args.socket_fd = socket_fd;
|
||||
mcast_publisher_priv->args.multicast_addr = multicast_addr;
|
||||
mcast_publisher_priv->args.multicast_port = multicast_port;
|
||||
mcast_publisher_priv->args.rig = rig;
|
||||
|
||||
status = multicast_publisher_create_data_pipe(mcast_publisher_priv);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
free(rs->multicast_publisher_priv_data);
|
||||
rs->multicast_publisher_priv_data = NULL;
|
||||
close(socket_fd);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: multicast publisher data pipe creation failed, result=%d\n", __func__, status);
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: multicast publisher data pipe creation failed, result=%d\n", __func__,
|
||||
status);
|
||||
RETURNFUNC(-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
int err = pthread_create(&mcast_publisher_priv->thread_id, NULL, multicast_publisher,
|
||||
int err = pthread_create(&mcast_publisher_priv->thread_id, NULL,
|
||||
multicast_publisher,
|
||||
&mcast_publisher_priv->args);
|
||||
|
||||
if (err)
|
||||
|
@ -996,7 +1093,9 @@ int network_multicast_publisher_stop(RIG *rig)
|
|||
|
||||
rs->multicast_publisher_run = 0;
|
||||
|
||||
mcast_publisher_priv = (multicast_publisher_priv_data *) rs->multicast_publisher_priv_data;
|
||||
mcast_publisher_priv = (multicast_publisher_priv_data *)
|
||||
rs->multicast_publisher_priv_data;
|
||||
|
||||
if (mcast_publisher_priv == NULL)
|
||||
{
|
||||
RETURNFUNC(RIG_OK);
|
||||
|
|
139
src/rig.c
139
src/rig.c
|
@ -259,13 +259,13 @@ static int remove_opened_rig(RIG *rig)
|
|||
}
|
||||
|
||||
free(p);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
q = p;
|
||||
}
|
||||
|
||||
return(-RIG_EINVAL); /* Not found in list ! */
|
||||
return (-RIG_EINVAL); /* Not found in list ! */
|
||||
}
|
||||
|
||||
|
||||
|
@ -295,11 +295,11 @@ int foreach_opened_rig(int (*cfunc)(RIG *, rig_ptr_t), rig_ptr_t data)
|
|||
{
|
||||
if ((*cfunc)(p->rig, data) == 0)
|
||||
{
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
#endif /* !DOC_HIDDEN */
|
||||
|
@ -371,7 +371,7 @@ static int rig_check_rig_caps()
|
|||
&caps_test.macro_name);
|
||||
}
|
||||
|
||||
return(rc);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -455,7 +455,8 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
|
|||
rs->rigport.fd = -1;
|
||||
rs->pttport.fd = -1;
|
||||
rs->comm_state = 0;
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==0?=%d\n", __func__, __LINE__, &rs->comm_state,
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==0?=%d\n", __func__,
|
||||
__LINE__, &rs->comm_state,
|
||||
rs->comm_state);
|
||||
rs->rigport.type.rig = caps->port_type; /* default from caps */
|
||||
#if defined(HAVE_PTHREAD)
|
||||
|
@ -673,12 +674,16 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
|
|||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// Now we have to copy our new rig state hamlib_port structure to the deprecated one
|
||||
// Clients built on older 4.X versions will use the old structure
|
||||
// Clients built on newer 4.5 versions will use the new structure
|
||||
memcpy(&rig->state.rigport_deprecated, &rig->state.rigport, sizeof(rig->state.rigport_deprecated));
|
||||
memcpy(&rig->state.pttport_deprecated, &rig->state.pttport, sizeof(rig->state.pttport_deprecated));
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
|
||||
memcpy(&rig->state.rigport_deprecated, &rig->state.rigport,
|
||||
sizeof(rig->state.rigport_deprecated));
|
||||
memcpy(&rig->state.pttport_deprecated, &rig->state.pttport,
|
||||
sizeof(rig->state.pttport_deprecated));
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
|
||||
sizeof(rig->state.dcdport_deprecated));
|
||||
|
||||
return (rig);
|
||||
}
|
||||
|
@ -727,7 +732,8 @@ int HAMLIB_API rig_open(RIG *rig)
|
|||
if (strlen(rs->rigport.pathname) > 0)
|
||||
{
|
||||
char hoststr[256], portstr[6];
|
||||
status = parse_hoststr(rs->rigport.pathname, sizeof(rs->rigport.pathname), hoststr, portstr);
|
||||
status = parse_hoststr(rs->rigport.pathname, sizeof(rs->rigport.pathname),
|
||||
hoststr, portstr);
|
||||
|
||||
if (status == RIG_OK) { is_network = 1; }
|
||||
}
|
||||
|
@ -775,7 +781,8 @@ int HAMLIB_API rig_open(RIG *rig)
|
|||
|
||||
if (rs->comm_state)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==1?=%d\n", __func__, __LINE__, &rs->comm_state,
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==1?=%d\n", __func__,
|
||||
__LINE__, &rs->comm_state,
|
||||
rs->comm_state);
|
||||
port_close(&rs->rigport, rs->rigport.type.rig);
|
||||
rs->comm_state = 0;
|
||||
|
@ -1057,7 +1064,8 @@ int HAMLIB_API rig_open(RIG *rig)
|
|||
add_opened_rig(rig);
|
||||
|
||||
rs->comm_state = 1;
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: %p rs->comm_state==1?=%d\n", __func__, &rs->comm_state,
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: %p rs->comm_state==1?=%d\n", __func__,
|
||||
&rs->comm_state,
|
||||
rs->comm_state);
|
||||
|
||||
/*
|
||||
|
@ -1073,7 +1081,7 @@ int HAMLIB_API rig_open(RIG *rig)
|
|||
remove_opened_rig(rig);
|
||||
async_data_handler_stop(rig);
|
||||
port_close(&rs->rigport, rs->rigport.type.rig);
|
||||
memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
|
||||
rs->comm_state = 0;
|
||||
RETURNFUNC(status);
|
||||
}
|
||||
|
@ -1139,9 +1147,9 @@ int HAMLIB_API rig_open(RIG *rig)
|
|||
// if (caps->get_freq) rig_get_freq(rig, RIG_VFO_A, &freq);
|
||||
// if (caps->get_freq) rig_get_freq(rig, RIG_VFO_B, &freq);
|
||||
|
||||
memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->pttport_deprecated,&rs->pttport,sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->dcdport_deprecated,&rs->dcdport,sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->pttport_deprecated, &rs->pttport, sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->dcdport_deprecated, &rs->dcdport, sizeof(hamlib_port_t_deprecated));
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
|
@ -1211,7 +1219,7 @@ int HAMLIB_API rig_close(RIG *rig)
|
|||
if (rs->pttport.fd != rs->rigport.fd)
|
||||
{
|
||||
port_close(&rs->pttport, RIG_PORT_SERIAL);
|
||||
memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1227,7 +1235,7 @@ int HAMLIB_API rig_close(RIG *rig)
|
|||
if (rs->pttport.fd != rs->rigport.fd)
|
||||
{
|
||||
port_close(&rs->pttport, RIG_PORT_SERIAL);
|
||||
memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1268,7 +1276,7 @@ int HAMLIB_API rig_close(RIG *rig)
|
|||
if (rs->dcdport.fd != rs->rigport.fd)
|
||||
{
|
||||
port_close(&rs->dcdport, RIG_PORT_SERIAL);
|
||||
memcpy(&rs->rigport_deprecated,&rs->rigport,sizeof(hamlib_port_t_deprecated));
|
||||
memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated));
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1296,7 +1304,8 @@ int HAMLIB_API rig_close(RIG *rig)
|
|||
remove_opened_rig(rig);
|
||||
|
||||
rs->comm_state = 0;
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==0?=%d\n", __func__, __LINE__, &rs->comm_state,
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==0?=%d\n", __func__,
|
||||
__LINE__, &rs->comm_state,
|
||||
rs->comm_state);
|
||||
|
||||
RETURNFUNC(RIG_OK);
|
||||
|
@ -1320,7 +1329,7 @@ int HAMLIB_API rig_cleanup(RIG *rig)
|
|||
{
|
||||
if (!rig || !rig->caps)
|
||||
{
|
||||
return(-RIG_EINVAL);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1341,7 +1350,7 @@ int HAMLIB_API rig_cleanup(RIG *rig)
|
|||
|
||||
free(rig);
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1501,7 +1510,8 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|||
|
||||
ELAPSED1;
|
||||
#if BUILTINFUNC
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, freq=%.0f, called from %s\n", __func__,
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, freq=%.0f, called from %s\n",
|
||||
__func__,
|
||||
rig_strvfo(vfo), freq, func);
|
||||
#else
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, freq=%.0f\n", __func__,
|
||||
|
@ -1725,14 +1735,15 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
|
||||
if (CHECK_RIG_ARG(rig))
|
||||
{
|
||||
return(-RIG_EINVAL);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
|
||||
ELAPSED1;
|
||||
|
||||
if (!freq)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: freq ptr invalid\n", __func__);
|
||||
return(-RIG_EINVAL);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) called vfo=%s\n", __func__, __LINE__,
|
||||
|
@ -1763,7 +1774,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
rig_get_cache(rig, vfo, freq, &cache_ms_freq, &mode, &cache_ms_mode, &width,
|
||||
&cache_ms_width);
|
||||
ELAPSED2;
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
rig_cache_show(rig, __func__, __LINE__);
|
||||
|
@ -1782,7 +1793,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
return(retcode);
|
||||
return (retcode);
|
||||
}
|
||||
|
||||
if (ptt)
|
||||
|
@ -1791,7 +1802,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
"%s: split is on so returning VFOA last known freq\n",
|
||||
__func__);
|
||||
*freq = rig->state.cache.freqMainA;
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1803,12 +1814,13 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
rig_cache_show(rig, __func__, __LINE__);
|
||||
|
||||
if (*freq != 0 && (cache_ms_freq < rig->state.cache.timeout_ms
|
||||
|| (rig->state.cache.timeout_ms == HAMLIB_CACHE_ALWAYS || rig->state.use_cached_freq)))
|
||||
|| (rig->state.cache.timeout_ms == HAMLIB_CACHE_ALWAYS
|
||||
|| rig->state.use_cached_freq)))
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: %s cache hit age=%dms, freq=%.0f\n", __func__,
|
||||
rig_strvfo(vfo), cache_ms_freq, *freq);
|
||||
ELAPSED2;
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1822,7 +1834,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
|
||||
if (caps->get_freq == NULL)
|
||||
{
|
||||
return(-RIG_ENAVAIL);
|
||||
return (-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo_opt=%d, model=%d\n", __func__,
|
||||
|
@ -1865,7 +1877,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
|
||||
if (!caps->set_vfo)
|
||||
{
|
||||
return(-RIG_ENAVAIL);
|
||||
return (-RIG_ENAVAIL);
|
||||
}
|
||||
|
||||
TRACE;
|
||||
|
@ -1873,7 +1885,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
return(retcode);
|
||||
return (retcode);
|
||||
}
|
||||
|
||||
rig_cache_show(rig, __func__, __LINE__);
|
||||
|
@ -1920,7 +1932,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
rig_cache_show(rig, __func__, __LINE__);
|
||||
|
||||
ELAPSED2;
|
||||
return(retcode);
|
||||
return (retcode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1943,7 +1955,7 @@ int HAMLIB_API rig_get_freqs(RIG *rig, freq_t *freqA, freq_t freqB)
|
|||
{
|
||||
// we will attempt to avoid vfo swapping in this routine
|
||||
|
||||
return(-RIG_ENIMPL);
|
||||
return (-RIG_ENIMPL);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2021,7 +2033,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: VFOB mode not changing so ignoring\n",
|
||||
__func__);
|
||||
RETURNFUNC2 (RIG_OK);
|
||||
RETURNFUNC2(RIG_OK);
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: not targetable need vfo swap\n", __func__);
|
||||
|
@ -2122,7 +2134,8 @@ int HAMLIB_API rig_get_mode(RIG *rig,
|
|||
|
||||
rig_cache_show(rig, __func__, __LINE__);
|
||||
|
||||
if (rig->state.cache.timeout_ms == HAMLIB_CACHE_ALWAYS || rig->state.use_cached_mode)
|
||||
if (rig->state.cache.timeout_ms == HAMLIB_CACHE_ALWAYS
|
||||
|| rig->state.use_cached_mode)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cache hit age mode=%dms, width=%dms\n",
|
||||
__func__, cache_ms_mode, cache_ms_width);
|
||||
|
@ -2249,7 +2262,8 @@ pbwidth_t HAMLIB_API rig_passband_normal(RIG *rig, rmode_t mode)
|
|||
{
|
||||
if (rs->filters[i].modes & mode)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%.*s%d:%s: return filter#%d, width=%d\n", rig->state.depth, spaces(), rig->state.depth, __func__, i,
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%.*s%d:%s: return filter#%d, width=%d\n",
|
||||
rig->state.depth, spaces(), rig->state.depth, __func__, i,
|
||||
(int)rs->filters[i].width);
|
||||
RETURNFUNC(rs->filters[i].width);
|
||||
}
|
||||
|
@ -2418,10 +2432,13 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
|
|||
if (vfo == RIG_VFO_CURR) { RETURNFUNC(RIG_OK); }
|
||||
|
||||
retcode = rig_get_vfo(rig, &curr_vfo);
|
||||
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: rig_get_vfo error=%s\n", __func__, rigerror(retcode));
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: rig_get_vfo error=%s\n", __func__,
|
||||
rigerror(retcode));
|
||||
}
|
||||
|
||||
if (curr_vfo == vfo) { RETURNFUNC(RIG_OK); }
|
||||
|
||||
#if 0 // removing this check 20210801 -- should be mapped already
|
||||
|
@ -2456,7 +2473,8 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
|
|||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: Ignoring set_vfo due to VFO twiddling\n",
|
||||
__func__);
|
||||
RETURNFUNC(RIG_OK); // would be better as error but other software won't handle errors
|
||||
RETURNFUNC(
|
||||
RIG_OK); // would be better as error but other software won't handle errors
|
||||
}
|
||||
|
||||
TRACE;
|
||||
|
@ -2887,7 +2905,8 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
|
||||
if (retcode != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s: return code=%d\n", __func__, retcode); }
|
||||
|
||||
memcpy(&rig->state.pttport_deprecated, &rig->state.pttport, sizeof(rig->state.pttport_deprecated));
|
||||
memcpy(&rig->state.pttport_deprecated, &rig->state.pttport,
|
||||
sizeof(rig->state.pttport_deprecated));
|
||||
ELAPSED2;
|
||||
|
||||
RETURNFUNC(retcode);
|
||||
|
@ -3258,32 +3277,37 @@ int HAMLIB_API rig_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
|
|||
|
||||
case RIG_DCD_SERIAL_CTS:
|
||||
retcode = ser_get_cts(&rig->state.dcdport, &status);
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
|
||||
sizeof(rig->state.dcdport_deprecated));
|
||||
*dcd = status ? RIG_DCD_ON : RIG_DCD_OFF;
|
||||
RETURNFUNC(retcode);
|
||||
|
||||
case RIG_DCD_SERIAL_DSR:
|
||||
retcode = ser_get_dsr(&rig->state.dcdport, &status);
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
|
||||
sizeof(rig->state.dcdport_deprecated));
|
||||
*dcd = status ? RIG_DCD_ON : RIG_DCD_OFF;
|
||||
RETURNFUNC(retcode);
|
||||
|
||||
case RIG_DCD_SERIAL_CAR:
|
||||
retcode = ser_get_car(&rig->state.dcdport, &status);
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
|
||||
sizeof(rig->state.dcdport_deprecated));
|
||||
*dcd = status ? RIG_DCD_ON : RIG_DCD_OFF;
|
||||
RETURNFUNC(retcode);
|
||||
|
||||
|
||||
case RIG_DCD_PARALLEL:
|
||||
retcode = par_dcd_get(&rig->state.dcdport, dcd);
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
|
||||
sizeof(rig->state.dcdport_deprecated));
|
||||
RETURNFUNC(retcode);
|
||||
|
||||
case RIG_DCD_GPIO:
|
||||
case RIG_DCD_GPION:
|
||||
retcode = gpio_dcd_get(&rig->state.dcdport, dcd);
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport, sizeof(rig->state.dcdport_deprecated));
|
||||
memcpy(&rig->state.dcdport_deprecated, &rig->state.dcdport,
|
||||
sizeof(rig->state.dcdport_deprecated));
|
||||
RETURNFUNC(retcode);
|
||||
|
||||
case RIG_DCD_NONE:
|
||||
|
@ -3618,7 +3642,8 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
|
|||
}
|
||||
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, curr_vfo=%s, tx_freq=%.0f\n", __func__,
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, curr_vfo=%s, tx_freq=%.0f\n",
|
||||
__func__,
|
||||
rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo), tx_freq);
|
||||
|
||||
caps = rig->caps;
|
||||
|
@ -5614,7 +5639,7 @@ rig_model_t HAMLIB_API rig_probe(hamlib_port_t *port)
|
|||
{
|
||||
if (!port)
|
||||
{
|
||||
return(RIG_MODEL_NONE);
|
||||
return (RIG_MODEL_NONE);
|
||||
}
|
||||
|
||||
return rig_probe_first(port);
|
||||
|
@ -5644,7 +5669,7 @@ int HAMLIB_API rig_probe_all(hamlib_port_t *port,
|
|||
{
|
||||
if (!port)
|
||||
{
|
||||
return(-RIG_EINVAL);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
|
||||
return rig_probe_all_backends(port, cfunc, data);
|
||||
|
@ -6525,14 +6550,14 @@ int HAMLIB_API rig_get_rig_info(RIG *rig, char *response, int max_response_len)
|
|||
txa = split == 0;
|
||||
rxb = !rxa;
|
||||
txb = split == 1;
|
||||
SNPRINTF(response, max_response_len-strlen("CRC=0x00000000\n"),
|
||||
SNPRINTF(response, max_response_len - strlen("CRC=0x00000000\n"),
|
||||
"VFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nVFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nSplit=%d SatMode=%d\nRig=%s\nApp=Hamlib\nVersion=20210506 1.0.0\n",
|
||||
rig_strvfo(vfoA), freqA, modeAstr, (int)widthA, rxa, txa, rig_strvfo(vfoB),
|
||||
freqB, modeBstr, (int)widthB, rxb, txb, split, satmode, rig->caps->model_name);
|
||||
unsigned long crc = gen_crc((unsigned char *)response, strlen(response));
|
||||
char tmpstr[32];
|
||||
SNPRINTF(tmpstr, sizeof(tmpstr), "CRC=0x%08lx\n", crc);
|
||||
strcat(response,tmpstr);
|
||||
strcat(response, tmpstr);
|
||||
|
||||
|
||||
if (strlen(response) >= max_response_len - 1)
|
||||
|
@ -6926,7 +6951,8 @@ static int async_data_handler_start(RIG *rig)
|
|||
|
||||
if (err)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: pthread_create error: %s\n", __func__, strerror(errno));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: pthread_create error: %s\n", __func__,
|
||||
strerror(errno));
|
||||
RETURNFUNC(-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
|
@ -6956,7 +6982,8 @@ static int async_data_handler_stop(RIG *rig)
|
|||
|
||||
if (err)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: pthread_join error: %s\n", __func__, strerror(errno));
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: pthread_join error: %s\n", __func__,
|
||||
strerror(errno));
|
||||
// just ignore the error
|
||||
}
|
||||
|
||||
|
@ -6981,7 +7008,8 @@ void *async_data_handler(void *arg)
|
|||
struct rig_state *rs = &rig->state;
|
||||
int result;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting async data handler thread\n", __func__);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting async data handler thread\n",
|
||||
__func__);
|
||||
|
||||
// TODO: check how to enable "transceive" on recent Kenwood/Yaesu rigs
|
||||
// TODO: add initial support for async in Kenwood kenwood_transaction (+one) functions -> add transaction_active flag usage
|
||||
|
@ -7049,7 +7077,8 @@ void *async_data_handler(void *arg)
|
|||
}
|
||||
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Stopping async data handler thread\n", __func__);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Stopping async data handler thread\n",
|
||||
__func__);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -391,7 +391,7 @@ int frontrot_get_conf(ROT *rot, token_t token, char *val, int val_len)
|
|||
switch (token)
|
||||
{
|
||||
case TOK_PATHNAME:
|
||||
strncpy(val, rs->rotport.pathname, val_len-1);
|
||||
strncpy(val, rs->rotport.pathname, val_len - 1);
|
||||
break;
|
||||
|
||||
case TOK_WRITE_DELAY:
|
||||
|
@ -798,6 +798,7 @@ int HAMLIB_API rot_get_conf2(ROT *rot, token_t token, char *val, int val_len)
|
|||
{
|
||||
return rot->caps->get_conf2(rot, token, val, val_len);
|
||||
}
|
||||
|
||||
if (rot->caps->get_conf == NULL)
|
||||
{
|
||||
return -RIG_ENAVAIL;
|
||||
|
|
|
@ -328,10 +328,12 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model)
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Now we have to copy our new rig state hamlib_port structure to the deprecated one
|
||||
// Clients built on older 4.X versions will use the old structure
|
||||
// Clients built on newer 4.5 versions will use the new structure
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport, sizeof(rot->state.rotport_deprecated));
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport,
|
||||
sizeof(rot->state.rotport_deprecated));
|
||||
|
||||
return rot;
|
||||
}
|
||||
|
@ -468,7 +470,8 @@ int HAMLIB_API rot_open(ROT *rot)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport, sizeof(rot->state.rotport_deprecated));
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport,
|
||||
sizeof(rot->state.rotport_deprecated));
|
||||
|
||||
add_opened_rot(rot);
|
||||
|
||||
|
@ -567,11 +570,13 @@ int HAMLIB_API rot_close(ROT *rot)
|
|||
|
||||
rs->rotport.fd = -1;
|
||||
}
|
||||
|
||||
remove_opened_rot(rot);
|
||||
|
||||
rs->comm_state = 0;
|
||||
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport, sizeof(rot->state.rotport_deprecated));
|
||||
memcpy(&rot->state.rotport_deprecated, &rot->state.rotport,
|
||||
sizeof(rot->state.rotport_deprecated));
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
|
64
src/serial.c
64
src/serial.c
|
@ -141,7 +141,7 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
|
|||
|
||||
if (!rp)
|
||||
{
|
||||
return(-RIG_EINVAL);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,13 +157,13 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
|
|||
*/
|
||||
if (rp->parm.serial.parity != RIG_PARITY_NONE)
|
||||
{
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
if ((rp->parm.serial.handshake != RIG_HANDSHAKE_HARDWARE) &&
|
||||
(rp->parm.serial.handshake != RIG_HANDSHAKE_NONE))
|
||||
{
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -178,7 +178,7 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
|
|||
|
||||
if (fd == -1)
|
||||
{
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
rp->fd = fd;
|
||||
|
@ -214,7 +214,7 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
|
|||
* from the transceiver will be returned to both applications.
|
||||
*/
|
||||
uh_radio_fd = fd;
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -243,7 +243,7 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
|
|||
__func__,
|
||||
rp->pathname,
|
||||
strerror(errno));
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
rp->fd = fd;
|
||||
|
@ -253,13 +253,13 @@ int HAMLIB_API serial_open(hamlib_port_t *rp)
|
|||
if (err != RIG_OK)
|
||||
{
|
||||
CLOSE(fd);
|
||||
return(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
serial_flush(rp); // ensure nothing is there when we open
|
||||
hl_usleep(50 * 1000); // give a little time for MicroKeyer to finish
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -286,7 +286,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
|
|||
|
||||
if (!rp)
|
||||
{
|
||||
return(-RIG_EINVAL);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
|
||||
fd = rp->fd;
|
||||
|
@ -377,7 +377,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
|
|||
rp->parm.serial.rate);
|
||||
CLOSE(fd);
|
||||
|
||||
return(-RIG_ECONF);
|
||||
return (-RIG_ECONF);
|
||||
}
|
||||
|
||||
/* TODO */
|
||||
|
@ -424,7 +424,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
|
|||
rp->parm.serial.data_bits);
|
||||
CLOSE(fd);
|
||||
|
||||
return(-RIG_ECONF);
|
||||
return (-RIG_ECONF);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
|
|||
rp->parm.serial.stop_bits);
|
||||
CLOSE(fd);
|
||||
|
||||
return(-RIG_ECONF);
|
||||
return (-RIG_ECONF);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -495,7 +495,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
|
|||
rp->parm.serial.parity);
|
||||
CLOSE(fd);
|
||||
|
||||
return(-RIG_ECONF);
|
||||
return (-RIG_ECONF);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -531,7 +531,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
|
|||
rp->parm.serial.handshake);
|
||||
CLOSE(fd);
|
||||
|
||||
return(-RIG_ECONF);
|
||||
return (-RIG_ECONF);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -576,7 +576,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
|
|||
strerror(errno));
|
||||
CLOSE(fd);
|
||||
|
||||
return(-RIG_ECONF); /* arg, so close! */
|
||||
return (-RIG_ECONF); /* arg, so close! */
|
||||
}
|
||||
|
||||
#elif defined(HAVE_TERMIO_H)
|
||||
|
@ -591,7 +591,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
|
|||
strerror(errno));
|
||||
CLOSE(fd);
|
||||
|
||||
return(-RIG_ECONF); /* arg, so close! */
|
||||
return (-RIG_ECONF); /* arg, so close! */
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -607,7 +607,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
|
|||
strerror(errno));
|
||||
CLOSE(fd);
|
||||
|
||||
return(-RIG_ECONF); /* arg, so close! */
|
||||
return (-RIG_ECONF); /* arg, so close! */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -625,7 +625,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp)
|
|||
term_backup->next = term_options_backup_head;
|
||||
term_options_backup_head = term_backup;
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -664,7 +664,7 @@ int HAMLIB_API serial_flush(hamlib_port_t *p)
|
|||
rig_debug(RIG_DEBUG_TRACE, "read flushed %d bytes\n", nbytes);
|
||||
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
timeout_save = p->timeout;
|
||||
|
@ -691,7 +691,7 @@ int HAMLIB_API serial_flush(hamlib_port_t *p)
|
|||
int bytes = len * 3 + 1;
|
||||
char *hbuf = calloc(bytes, 1);
|
||||
|
||||
for (i = 0; i < len; ++i) { SNPRINTF(&hbuf[i * 3], bytes - (i*3), "%02X ", buf[i]); }
|
||||
for (i = 0; i < len; ++i) { SNPRINTF(&hbuf[i * 3], bytes - (i * 3), "%02X ", buf[i]); }
|
||||
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: flush hex:%s\n", __func__, hbuf);
|
||||
free(hbuf);
|
||||
|
@ -707,7 +707,7 @@ int HAMLIB_API serial_flush(hamlib_port_t *p)
|
|||
p->timeout = timeout_save;
|
||||
//rig_debug(RIG_DEBUG_VERBOSE, "tcflush%s\n", "");
|
||||
//tcflush(p->fd, TCIFLUSH);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -768,7 +768,7 @@ int ser_open(hamlib_port_t *p)
|
|||
}
|
||||
|
||||
p->fd = ret;
|
||||
return(ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
|
@ -795,7 +795,7 @@ int ser_close(hamlib_port_t *p)
|
|||
uh_close_ptt();
|
||||
uh_ptt_fd = -1;
|
||||
p->fd = -1;
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (p->fd == uh_radio_fd)
|
||||
|
@ -803,7 +803,7 @@ int ser_close(hamlib_port_t *p)
|
|||
uh_close_radio();
|
||||
uh_radio_fd = -1;
|
||||
p->fd = -1;
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
// Find backup termios options to restore before closing
|
||||
|
@ -877,7 +877,7 @@ int ser_close(hamlib_port_t *p)
|
|||
|
||||
rc = CLOSE(p->fd);
|
||||
p->fd = -1;
|
||||
return(rc);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -897,7 +897,7 @@ int HAMLIB_API ser_set_rts(hamlib_port_t *p, int state)
|
|||
// ignore this for microHam ports
|
||||
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
|
||||
{
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
#if defined(TIOCMBIS) && defined(TIOCMBIC)
|
||||
|
@ -927,10 +927,10 @@ int HAMLIB_API ser_set_rts(hamlib_port_t *p, int state)
|
|||
"%s: Cannot change RTS - %s\n",
|
||||
__func__,
|
||||
strerror(errno));
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -974,13 +974,13 @@ int HAMLIB_API ser_set_dtr(hamlib_port_t *p, int state)
|
|||
// but (un)set ptt on microHam PTT channel.
|
||||
if (p->fd == uh_radio_fd)
|
||||
{
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
if (p->fd == uh_ptt_fd)
|
||||
{
|
||||
uh_set_ptt(state);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
#if defined(TIOCMBIS) && defined(TIOCMBIC)
|
||||
|
@ -1010,10 +1010,10 @@ int HAMLIB_API ser_set_dtr(hamlib_port_t *p, int state)
|
|||
"%s: Cannot change DTR - %s\n",
|
||||
__func__,
|
||||
strerror(errno));
|
||||
return(-RIG_EIO);
|
||||
return (-RIG_EIO);
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,43 +18,55 @@ static int snapshot_serialize_rig(cJSON *rig_node, RIG *rig)
|
|||
|
||||
// TODO: need to assign rig an ID, e.g. from command line
|
||||
node = cJSON_AddStringToObject(rig_node, "id", "rig_id");
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
// TODO: what kind of status should this reflect?
|
||||
node = cJSON_AddStringToObject(rig_node, "status", rig->state.comm_state ? "OK" : "CLOSED");
|
||||
node = cJSON_AddStringToObject(rig_node, "status",
|
||||
rig->state.comm_state ? "OK" : "CLOSED");
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
// TODO: need to store last error code
|
||||
node = cJSON_AddStringToObject(rig_node, "errorMsg", "");
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddStringToObject(rig_node, "name", rig->caps->model_name);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddBoolToObject(rig_node, "split", rig->state.cache.split == RIG_SPLIT_ON ? 1 : 0);
|
||||
node = cJSON_AddBoolToObject(rig_node, "split",
|
||||
rig->state.cache.split == RIG_SPLIT_ON ? 1 : 0);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddStringToObject(rig_node, "splitVfo", rig_strvfo(rig->state.cache.split_vfo));
|
||||
node = cJSON_AddStringToObject(rig_node, "splitVfo",
|
||||
rig_strvfo(rig->state.cache.split_vfo));
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddBoolToObject(rig_node, "satMode", rig->state.cache.satmode ? 1 : 0);
|
||||
node = cJSON_AddBoolToObject(rig_node, "satMode",
|
||||
rig->state.cache.satmode ? 1 : 0);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
|
@ -62,7 +74,7 @@ static int snapshot_serialize_rig(cJSON *rig_node, RIG *rig)
|
|||
|
||||
RETURNFUNC(RIG_OK);
|
||||
|
||||
error:
|
||||
error:
|
||||
RETURNFUNC(-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
|
@ -82,25 +94,33 @@ static int snapshot_serialize_vfo(cJSON *vfo_node, RIG *rig, vfo_t vfo)
|
|||
// TODO: This data should match rig_get_info command response
|
||||
|
||||
node = cJSON_AddStringToObject(vfo_node, "name", rig_strvfo(vfo));
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
result = rig_get_cache(rig, vfo, &freq, &freq_ms, &mode, &mode_ms, &width, &width_ms);
|
||||
result = rig_get_cache(rig, vfo, &freq, &freq_ms, &mode, &mode_ms, &width,
|
||||
&width_ms);
|
||||
|
||||
if (result == RIG_OK)
|
||||
{
|
||||
node = cJSON_AddNumberToObject(vfo_node, "freq", freq);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddStringToObject(vfo_node, "mode", rig_strrmode(mode));
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddNumberToObject(vfo_node, "width", (double) width);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
|
@ -109,6 +129,7 @@ static int snapshot_serialize_vfo(cJSON *vfo_node, RIG *rig, vfo_t vfo)
|
|||
|
||||
ptt = rig->state.cache.ptt;
|
||||
node = cJSON_AddBoolToObject(vfo_node, "ptt", ptt == RIG_PTT_OFF ? 0 : 1);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
|
@ -117,15 +138,19 @@ static int snapshot_serialize_vfo(cJSON *vfo_node, RIG *rig, vfo_t vfo)
|
|||
split = rig->state.cache.split;
|
||||
split_vfo = rig->state.cache.split_vfo;
|
||||
|
||||
is_rx = (split == RIG_SPLIT_OFF && vfo == rig->state.current_vfo) || (split == RIG_SPLIT_ON && vfo != split_vfo);
|
||||
is_rx = (split == RIG_SPLIT_OFF && vfo == rig->state.current_vfo)
|
||||
|| (split == RIG_SPLIT_ON && vfo != split_vfo);
|
||||
node = cJSON_AddBoolToObject(vfo_node, "rx", is_rx);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
is_tx = (split == RIG_SPLIT_OFF && vfo == rig->state.current_vfo) || (split == RIG_SPLIT_ON && vfo == split_vfo);
|
||||
is_tx = (split == RIG_SPLIT_OFF && vfo == rig->state.current_vfo)
|
||||
|| (split == RIG_SPLIT_ON && vfo == split_vfo);
|
||||
node = cJSON_AddBoolToObject(vfo_node, "tx", is_tx);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
|
@ -133,11 +158,12 @@ static int snapshot_serialize_vfo(cJSON *vfo_node, RIG *rig, vfo_t vfo)
|
|||
|
||||
RETURNFUNC(RIG_OK);
|
||||
|
||||
error:
|
||||
error:
|
||||
RETURNFUNC(-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
static int snapshot_serialize_spectrum(cJSON *spectrum_node, RIG *rig, struct rig_spectrum_line *spectrum_line)
|
||||
static int snapshot_serialize_spectrum(cJSON *spectrum_node, RIG *rig,
|
||||
struct rig_spectrum_line *spectrum_line)
|
||||
{
|
||||
// Spectrum data is represented as a hexadecimal ASCII string where each data byte is represented as 2 ASCII letters
|
||||
char spectrum_data_string[HAMLIB_MAX_SPECTRUM_DATA * 2];
|
||||
|
@ -155,12 +181,14 @@ static int snapshot_serialize_spectrum(cJSON *spectrum_node, RIG *rig, struct ri
|
|||
}
|
||||
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "id", spectrum_line->id);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddStringToObject(spectrum_node, "name", name);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
|
@ -169,60 +197,78 @@ static int snapshot_serialize_spectrum(cJSON *spectrum_node, RIG *rig, struct ri
|
|||
node = cJSON_AddStringToObject(spectrum_node, "type",
|
||||
spectrum_line->spectrum_mode == RIG_SPECTRUM_MODE_CENTER ?
|
||||
SPECTRUM_MODE_CENTER : SPECTRUM_MODE_FIXED);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "minLevel", spectrum_line->data_level_min);
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "minLevel",
|
||||
spectrum_line->data_level_min);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "maxLevel", spectrum_line->data_level_max);
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "maxLevel",
|
||||
spectrum_line->data_level_max);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "minStrength", spectrum_line->signal_strength_min);
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "minStrength",
|
||||
spectrum_line->signal_strength_min);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "maxStrength", spectrum_line->signal_strength_max);
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "maxStrength",
|
||||
spectrum_line->signal_strength_max);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "centerFreq", spectrum_line->center_freq);
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "centerFreq",
|
||||
spectrum_line->center_freq);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "span", spectrum_line->span_freq);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "lowFreq", spectrum_line->low_edge_freq);
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "lowFreq",
|
||||
spectrum_line->low_edge_freq);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "highFreq", spectrum_line->high_edge_freq);
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "highFreq",
|
||||
spectrum_line->high_edge_freq);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "length", (double) spectrum_line->spectrum_data_length);
|
||||
node = cJSON_AddNumberToObject(spectrum_node, "length",
|
||||
(double) spectrum_line->spectrum_data_length);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
|
@ -231,6 +277,7 @@ static int snapshot_serialize_spectrum(cJSON *spectrum_node, RIG *rig, struct ri
|
|||
to_hex(spectrum_line->spectrum_data_length, spectrum_line->spectrum_data,
|
||||
sizeof(spectrum_data_string), spectrum_data_string);
|
||||
node = cJSON_AddStringToObject(spectrum_node, "data", spectrum_data_string);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
|
@ -238,11 +285,12 @@ static int snapshot_serialize_spectrum(cJSON *spectrum_node, RIG *rig, struct ri
|
|||
|
||||
RETURNFUNC(RIG_OK);
|
||||
|
||||
error:
|
||||
error:
|
||||
RETURNFUNC(-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_spectrum_line *spectrum_line)
|
||||
int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig,
|
||||
struct rig_spectrum_line *spectrum_line)
|
||||
{
|
||||
cJSON *root_node;
|
||||
cJSON *rig_node, *vfos_array, *vfo_node, *spectra_array, *spectrum_node;
|
||||
|
@ -258,22 +306,30 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
|
|||
vfos[1] = RIG_VFO_B;
|
||||
|
||||
root_node = cJSON_CreateObject();
|
||||
|
||||
if (root_node == NULL)
|
||||
{
|
||||
RETURNFUNC(-RIG_EINTERNAL);
|
||||
}
|
||||
|
||||
node = cJSON_AddStringToObject(root_node, "app", PACKAGE_NAME);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
node = cJSON_AddStringToObject(root_node, "version", PACKAGE_VERSION " " HAMLIBDATETIME);
|
||||
|
||||
node = cJSON_AddStringToObject(root_node, "version",
|
||||
PACKAGE_VERSION " " HAMLIBDATETIME);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
node = cJSON_AddNumberToObject(root_node, "seq", rig->state.snapshot_packet_sequence_number);
|
||||
|
||||
node = cJSON_AddNumberToObject(root_node, "seq",
|
||||
rig->state.snapshot_packet_sequence_number);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
|
@ -281,18 +337,21 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
|
|||
|
||||
// TODO: Calculate 32-bit CRC of the entire JSON record replacing the CRC value with 0
|
||||
node = cJSON_AddNumberToObject(root_node, "crc", 0);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
rig_node = cJSON_CreateObject();
|
||||
|
||||
if (rig_node == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
result = snapshot_serialize_rig(rig_node, rig);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
cJSON_Delete(rig_node);
|
||||
|
@ -302,6 +361,7 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
|
|||
cJSON_AddItemToObject(root_node, "rig", rig_node);
|
||||
|
||||
vfos_array = cJSON_CreateArray();
|
||||
|
||||
if (vfos_array == NULL)
|
||||
{
|
||||
goto error;
|
||||
|
@ -311,6 +371,7 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
|
|||
{
|
||||
vfo_node = cJSON_CreateObject();
|
||||
result = snapshot_serialize_vfo(vfo_node, rig, vfos[i]);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
cJSON_Delete(vfo_node);
|
||||
|
@ -325,6 +386,7 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
|
|||
if (spectrum_line != NULL)
|
||||
{
|
||||
spectra_array = cJSON_CreateArray();
|
||||
|
||||
if (spectra_array == NULL)
|
||||
{
|
||||
goto error;
|
||||
|
@ -332,6 +394,7 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
|
|||
|
||||
spectrum_node = cJSON_CreateObject();
|
||||
result = snapshot_serialize_spectrum(spectrum_node, rig, spectrum_line);
|
||||
|
||||
if (result != RIG_OK)
|
||||
{
|
||||
cJSON_Delete(spectrum_node);
|
||||
|
@ -343,7 +406,8 @@ int snapshot_serialize(size_t buffer_length, char *buffer, RIG *rig, struct rig_
|
|||
cJSON_AddItemToObject(root_node, "spectra", spectra_array);
|
||||
}
|
||||
|
||||
bool_result = cJSON_PrintPreallocated(root_node, buffer, (int) buffer_length, 0);
|
||||
bool_result = cJSON_PrintPreallocated(root_node, buffer, (int) buffer_length,
|
||||
0);
|
||||
|
||||
cJSON_Delete(root_node);
|
||||
|
||||
|
|
|
@ -339,6 +339,7 @@ int sprintf_level_ext(char *str, int nlen, const struct confparams *extlevels)
|
|||
/* ignore case RIG_CONF_BUTTON */
|
||||
break;
|
||||
}
|
||||
|
||||
check_buffer_overflow(str, len, nlen);
|
||||
}
|
||||
|
||||
|
@ -397,6 +398,7 @@ int rig_sprintf_level_gran(char *str, int nlen, setting_t level,
|
|||
gran[i].max.i,
|
||||
gran[i].step.i);
|
||||
}
|
||||
|
||||
check_buffer_overflow(str, len, nlen);
|
||||
}
|
||||
|
||||
|
@ -455,6 +457,7 @@ int rot_sprintf_level_gran(char *str, int nlen, setting_t level,
|
|||
gran[i].max.i,
|
||||
gran[i].step.i);
|
||||
}
|
||||
|
||||
check_buffer_overflow(str, len, nlen);
|
||||
}
|
||||
|
||||
|
@ -573,6 +576,7 @@ int rig_sprintf_parm_gran(char *str, int nlen, setting_t parm,
|
|||
gran[i].max.i,
|
||||
gran[i].step.i);
|
||||
}
|
||||
|
||||
check_buffer_overflow(str, len, nlen);
|
||||
}
|
||||
|
||||
|
@ -631,6 +635,7 @@ int rot_sprintf_parm_gran(char *str, int nlen, setting_t parm,
|
|||
gran[i].max.i,
|
||||
gran[i].step.i);
|
||||
}
|
||||
|
||||
check_buffer_overflow(str, len, nlen);
|
||||
}
|
||||
|
||||
|
@ -720,6 +725,7 @@ int rot_sprintf_status(char *str, int nlen, rot_status_t status)
|
|||
{
|
||||
len += sprintf(str + len, "%s ", sv);
|
||||
}
|
||||
|
||||
check_buffer_overflow(str, len, nlen);
|
||||
}
|
||||
|
||||
|
|
|
@ -677,7 +677,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#1? retcode=%d\n", __func__,
|
||||
retcode);
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
if (cmd != 0xa && cmd != 0xd)
|
||||
|
@ -696,12 +696,12 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
if (scanfc(fin, "%c", &cmd) < 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#2?\n", __func__);
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
}
|
||||
else if (cmd == '+' && prompt)
|
||||
{
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
if (cmd != '\\'
|
||||
|
@ -719,7 +719,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
if (scanfc(fin, "%c", &cmd) < 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#3?\n", __func__);
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
}
|
||||
else if (cmd != '\\'
|
||||
|
@ -732,7 +732,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
&& prompt)
|
||||
{
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
/* command by name */
|
||||
|
@ -743,7 +743,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
if (scanfc(fin, "%c", pcmd) < 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#4?\n", __func__);
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
retcode = fscanf(fin, "%s", ++pcmd);
|
||||
|
@ -770,7 +770,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
fprintf_flush(fout, "\nRig command: ");
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
last_was_ret = 1;
|
||||
|
@ -788,11 +788,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
if (scanfc(fin, "%c", &cmd) < 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#6?\n", __func__);
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
my_rig->state.vfo_opt = *vfo_opt;
|
||||
|
@ -804,14 +804,14 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
if (interactive && !prompt) { fprintf(fout, "%s0\n", NETRIGCTL_RET); }
|
||||
|
||||
fflush(fout);
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
|
||||
if (cmd == '?')
|
||||
{
|
||||
usage_rig(fout);
|
||||
fflush(fout);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -821,11 +821,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
|
||||
if (EOF == retcode)
|
||||
{
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
else if (retcode < 0)
|
||||
{
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
else if ('\0' == command[1])
|
||||
{
|
||||
|
@ -846,7 +846,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
fprintf(stderr, "Command '%c' not found!\n", cmd);
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
if (!(cmd_entry->flags & ARG_NOVFO) && *vfo_opt)
|
||||
|
@ -864,7 +864,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
if (scanfc(fin, "%s", arg1) < 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#7?\n", __func__);
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
vfo = rig_parse_vfo(arg1);
|
||||
|
@ -880,7 +880,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
}
|
||||
else if (retcode < 0)
|
||||
{
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
vfo = rig_parse_vfo(arg1);
|
||||
|
@ -904,7 +904,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
|
||||
if (fgets(arg1, MAXARGSZ, fin) == NULL)
|
||||
{
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
if (arg1[0] == 0xa)
|
||||
|
@ -918,7 +918,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
|
||||
if (fgets(arg1, MAXARGSZ, fin) == NULL)
|
||||
{
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -946,11 +946,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
{
|
||||
fprintf(stderr, "Invalid arg for command '%s'\n",
|
||||
cmd_entry->name);
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
else if (retcode < 0)
|
||||
{
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
p1 = arg1;
|
||||
|
@ -975,7 +975,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
if (scanfc(fin, "%s", arg1) < 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#8?\n", __func__);
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
p1 = arg1;
|
||||
|
@ -988,11 +988,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
{
|
||||
fprintf(stderr, "Invalid arg for command '%s'\n",
|
||||
cmd_entry->name);
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
else if (retcode < 0)
|
||||
{
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
p1 = arg1;
|
||||
|
@ -1025,7 +1025,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
if (scanfc(fin, "%s", arg2) < 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#9?\n", __func__);
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
p2 = arg2;
|
||||
|
@ -1040,11 +1040,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
{
|
||||
fprintf(stderr, "Invalid arg for command '%s'\n",
|
||||
cmd_entry->name);
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
else if (retcode < 0)
|
||||
{
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
p2 = arg2;
|
||||
|
@ -1074,7 +1074,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
if (scanfc(fin, "%s", arg3) < 1)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#10?\n", __func__);
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
p3 = arg3;
|
||||
|
@ -1090,11 +1090,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
fprintf(stderr,
|
||||
"Invalid arg for command '%s'\n",
|
||||
cmd_entry->name);
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
else if (retcode < 0)
|
||||
{
|
||||
return(RIGCTL_PARSE_ERROR);
|
||||
return (RIGCTL_PARSE_ERROR);
|
||||
}
|
||||
|
||||
p3 = arg3;
|
||||
|
@ -1121,13 +1121,13 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
if (!input_line)
|
||||
{
|
||||
fprintf_flush(fout, "\n");
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
|
||||
/* Q or q to quit */
|
||||
if (!(strncasecmp(input_line, "q", 1)))
|
||||
{
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
|
||||
/* '?' for help */
|
||||
|
@ -1135,13 +1135,13 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
{
|
||||
usage_rig(fout);
|
||||
fflush(fout);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
/* '#' for comment */
|
||||
if (!(strncmp(input_line, "#", 1)))
|
||||
{
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
/* Blank line entered */
|
||||
|
@ -1149,7 +1149,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
|
|||
{
|
||||
fprintf(fout, "? for help, q to quit.\n");
|
||||
fflush(fout);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: input_line: %s\n", __func__, input_line);
|
||||
|
@ -1173,7 +1173,7 @@ readline_repeat:
|
|||
{
|
||||
/* Oops! Invoke GDB!! */
|
||||
fprintf_flush(fout, "\n");
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
|
||||
/* At this point parsed_input contains the typed text of the command
|
||||
|
@ -1232,7 +1232,7 @@ readline_repeat:
|
|||
{
|
||||
fprintf(stderr,
|
||||
"Valid multiple character command names contain alphanumeric characters plus '_'\n");
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1241,13 +1241,13 @@ readline_repeat:
|
|||
/* Single '\' entered, prompt again */
|
||||
else if ((*parsed_input[0] == '\\') && (strlen(parsed_input[0]) == 1))
|
||||
{
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
/* Multiple characters but no leading '\' */
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Precede multiple character command names with '\\'\n");
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
cmd_entry = find_cmd_entry(cmd);
|
||||
|
@ -1263,7 +1263,7 @@ readline_repeat:
|
|||
fprintf(stderr, "Command '%c' not found!\n", cmd);
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
/* If vfo_opt is enabled (-o|--vfo) check if already given
|
||||
|
@ -1288,7 +1288,7 @@ readline_repeat:
|
|||
if (!input_line)
|
||||
{
|
||||
fprintf_flush(fout, "\n");
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
|
||||
/* Blank line entered */
|
||||
|
@ -1296,7 +1296,7 @@ readline_repeat:
|
|||
{
|
||||
fprintf(fout, "? for help, q to quit.\n");
|
||||
fflush(fout);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
/* Get the first token of input, the rest, if any, will be
|
||||
|
@ -1311,7 +1311,7 @@ readline_repeat:
|
|||
else
|
||||
{
|
||||
fprintf_flush(fout, "\n");
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1390,7 +1390,7 @@ readline_repeat:
|
|||
{
|
||||
fprintf(fout, "? for help, q to quit.\n");
|
||||
fflush(fout);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
if (input_line)
|
||||
|
@ -1400,7 +1400,7 @@ readline_repeat:
|
|||
else
|
||||
{
|
||||
fprintf_flush(fout, "\n");
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1452,7 +1452,7 @@ readline_repeat:
|
|||
{
|
||||
fprintf(fout, "? for help, q to quit.\n");
|
||||
fflush(fout);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
result = strtok(input_line, " ");
|
||||
|
@ -1464,7 +1464,7 @@ readline_repeat:
|
|||
else
|
||||
{
|
||||
fprintf_flush(fout, "\n");
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1518,7 +1518,7 @@ readline_repeat:
|
|||
{
|
||||
fprintf(fout, "? for help, q to quit.\n");
|
||||
fflush(fout);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
result = strtok(input_line, " ");
|
||||
|
@ -1530,7 +1530,7 @@ readline_repeat:
|
|||
else
|
||||
{
|
||||
fprintf_flush(fout, "\n");
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1584,7 +1584,7 @@ readline_repeat:
|
|||
{
|
||||
fprintf(fout, "? for help, q to quit.\n");
|
||||
fflush(fout);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
result = strtok(input_line, " ");
|
||||
|
@ -1596,7 +1596,7 @@ readline_repeat:
|
|||
else
|
||||
{
|
||||
fprintf_flush(fout, "\n");
|
||||
return(RIGCTL_PARSE_END);
|
||||
return (RIGCTL_PARSE_END);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1679,7 +1679,8 @@ readline_repeat:
|
|||
|
||||
if (my_rig->state.comm_state == 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: %p rig not open...trying to reopen\n", __func__, &my_rig->state.comm_state);
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: %p rig not open...trying to reopen\n", __func__,
|
||||
&my_rig->state.comm_state);
|
||||
rig_open(my_rig);
|
||||
}
|
||||
|
||||
|
@ -1705,7 +1706,7 @@ readline_repeat:
|
|||
|
||||
if (sync_cb) { sync_cb(0); } /* unlock if necessary */
|
||||
|
||||
return(retcode);
|
||||
return (retcode);
|
||||
}
|
||||
|
||||
if (retcode != RIG_OK)
|
||||
|
@ -1761,7 +1762,7 @@ readline_repeat:
|
|||
|
||||
if (sync_cb) { sync_cb(0); } /* unlock if necessary */
|
||||
|
||||
return(retcode);
|
||||
return (retcode);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1945,7 +1946,7 @@ int set_conf(RIG *my_rig, char *conf_parms)
|
|||
|
||||
if (!q)
|
||||
{
|
||||
return(-RIG_EINVAL);
|
||||
return (-RIG_EINVAL);
|
||||
}
|
||||
|
||||
*q++ = '\0';
|
||||
|
@ -1960,13 +1961,13 @@ int set_conf(RIG *my_rig, char *conf_parms)
|
|||
|
||||
if (ret != RIG_OK)
|
||||
{
|
||||
return(ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
p = n;
|
||||
}
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -4622,7 +4623,7 @@ static int hasbinary(char *s, int len)
|
|||
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
if (!isascii(s[i])) { return(1); }
|
||||
if (!isascii(s[i])) { return (1); }
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -4888,7 +4889,7 @@ declare_proto_rig(halt)
|
|||
/* a bit rough, TODO: clean daemon shutdown */
|
||||
exit(0);
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -4900,7 +4901,7 @@ declare_proto_rig(pause)
|
|||
CHKSCN1ARG(sscanf(arg1, "%u", &seconds));
|
||||
sleep(seconds);
|
||||
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
char rig_passwd[256];
|
||||
|
@ -4930,7 +4931,7 @@ declare_proto_rig(set_password)
|
|||
strncpy(rig_passwd, passwd, sizeof(passwd) - 1);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: set_password %s\n", __func__, rig_passwd);
|
||||
fprintf(fout, "set_password %s\n", rig_passwd);
|
||||
return(RIG_OK);
|
||||
return (RIG_OK);
|
||||
}
|
||||
|
||||
/* '0x8d' */
|
||||
|
|
|
@ -888,7 +888,7 @@ static int handle_ts2000(void *arg)
|
|||
if (strcmp(arg, "SA;") == 0)
|
||||
{
|
||||
// should we silently fail with RIG_OK instead? TBD
|
||||
return(-RIG_ENIMPL);
|
||||
return (-RIG_ENIMPL);
|
||||
}
|
||||
|
||||
if (strlen(arg) > 3 && ((char *)arg)[2] == '1')
|
||||
|
@ -901,7 +901,7 @@ static int handle_ts2000(void *arg)
|
|||
}
|
||||
else
|
||||
{
|
||||
return(-RIG_ENAVAIL);
|
||||
return (-RIG_ENAVAIL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -567,11 +567,13 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
multicast_port = atoi(optarg);
|
||||
|
||||
if (multicast_port == 0)
|
||||
{
|
||||
fprintf(stderr, "Invalid multicast port: %s\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -773,8 +775,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
saved_result = result;
|
||||
|
||||
enum multicast_item_e items = RIG_MULTICAST_POLL | RIG_MULTICAST_TRANSCEIVE | RIG_MULTICAST_SPECTRUM;
|
||||
retcode = network_multicast_publisher_start(my_rig, multicast_addr, multicast_port, items);
|
||||
enum multicast_item_e items = RIG_MULTICAST_POLL | RIG_MULTICAST_TRANSCEIVE |
|
||||
RIG_MULTICAST_SPECTRUM;
|
||||
retcode = network_multicast_publisher_start(my_rig, multicast_addr,
|
||||
multicast_port, items);
|
||||
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
|
@ -1134,6 +1138,7 @@ void *handle_socket(void *arg)
|
|||
do
|
||||
{
|
||||
mutex_rigctld(1);
|
||||
|
||||
if (!rig_opened)
|
||||
{
|
||||
retcode = rig_open(my_rig);
|
||||
|
@ -1141,6 +1146,7 @@ void *handle_socket(void *arg)
|
|||
rig_debug(RIG_DEBUG_ERR, "%s: rig_open reopened retcode=%d\n", __func__,
|
||||
retcode);
|
||||
}
|
||||
|
||||
mutex_rigctld(0);
|
||||
|
||||
if (rig_opened) // only do this if rig is open
|
||||
|
@ -1176,12 +1182,15 @@ void *handle_socket(void *arg)
|
|||
hl_usleep(1000 * 1000);
|
||||
|
||||
mutex_rigctld(1);
|
||||
if (!rig_opened) {
|
||||
|
||||
if (!rig_opened)
|
||||
{
|
||||
retcode = rig_open(my_rig);
|
||||
rig_opened = retcode == RIG_OK ? 1 : 0;
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: rig_open retcode=%d, opened=%d\n", __func__,
|
||||
retcode, rig_opened);
|
||||
}
|
||||
|
||||
mutex_rigctld(0);
|
||||
}
|
||||
while (!ctrl_c && !rig_opened && retry-- > 0 && retcode != RIG_OK);
|
||||
|
|
|
@ -631,7 +631,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
time_t gentime;
|
||||
int set_or_get;
|
||||
int i,nbytes,nbytes_total=0;
|
||||
int i, nbytes, nbytes_total = 0;
|
||||
char *pbuf, prntbuf[4096];
|
||||
|
||||
rig_load_all_backends();
|
||||
|
@ -709,7 +709,8 @@ int main(int argc, char *argv[])
|
|||
bitmap_func |= func;
|
||||
nbytes = strlen("<TD></TD>") + strlen(s) + 1;
|
||||
nbytes_total += nbytes;
|
||||
pbuf += snprintf(pbuf, sizeof(pbuf)-nbytes_total, "<TD>%s</TD>", s);
|
||||
pbuf += snprintf(pbuf, sizeof(pbuf) - nbytes_total, "<TD>%s</TD>", s);
|
||||
|
||||
if (strlen(pbuf) > sizeof(pbuf) + nbytes)
|
||||
{
|
||||
printf("Buffer overflow in %s\n", __func__);
|
||||
|
@ -751,7 +752,8 @@ int main(int argc, char *argv[])
|
|||
bitmap_level |= level;
|
||||
nbytes = strlen("<TD></TD>") + strlen(s) + 1;
|
||||
nbytes_total += nbytes;
|
||||
pbuf += snprintf(pbuf, sizeof(pbuf)-nbytes_total, "<TD>%s</TD>", s);
|
||||
pbuf += snprintf(pbuf, sizeof(pbuf) - nbytes_total, "<TD>%s</TD>", s);
|
||||
|
||||
if (strlen(pbuf) > sizeof(pbuf) + nbytes)
|
||||
{
|
||||
printf("Buffer overflow in %s\n", __func__);
|
||||
|
@ -793,7 +795,8 @@ int main(int argc, char *argv[])
|
|||
bitmap_parm |= parm;
|
||||
nbytes = strlen("<TD></TD>") + strlen(s) + 1;
|
||||
nbytes_total += nbytes;
|
||||
pbuf += snprintf(pbuf, sizeof(pbuf)-nbytes_total, "<TD>%s</TD>", s);
|
||||
pbuf += snprintf(pbuf, sizeof(pbuf) - nbytes_total, "<TD>%s</TD>", s);
|
||||
|
||||
if (strlen(pbuf) > sizeof(pbuf) + nbytes)
|
||||
{
|
||||
printf("Buffer overflow in %s\n", __func__);
|
||||
|
|
|
@ -36,6 +36,7 @@ static int test1()
|
|||
|
||||
if (retcode == RIG_OK) { printf("Test#1d OK\n"); }
|
||||
else {printf("Test#1d Failed\n"); return 1;}
|
||||
|
||||
#endif
|
||||
|
||||
retcode = rig_cookie(NULL, RIG_COOKIE_RELEASE, cookie2, sizeof(cookie2));
|
||||
|
@ -88,16 +89,17 @@ static int test3_invalid_input()
|
|||
{
|
||||
int retcode;
|
||||
char cookie[HAMLIB_COOKIE_SIZE];
|
||||
int n=0;
|
||||
int n = 0;
|
||||
|
||||
/* Make sure any value smaller then HAMLIB_COOKIE_SIZE is rejected */
|
||||
for (unsigned int i = 0; i < HAMLIB_COOKIE_SIZE; i++)
|
||||
{
|
||||
retcode = rig_cookie(NULL, RIG_COOKIE_GET, cookie, i);
|
||||
|
||||
if (retcode != -RIG_EINVAL) { n++;printf("Test#3a failed at %d bytes\n", i); }
|
||||
if (retcode != -RIG_EINVAL) { n++; printf("Test#3a failed at %d bytes\n", i); }
|
||||
}
|
||||
if (n==0) printf("Test#3a OK\n");
|
||||
|
||||
if (n == 0) { printf("Test#3a OK\n"); }
|
||||
|
||||
/* Make sure a NULL cookie is ignored */
|
||||
retcode = rig_cookie(NULL, RIG_COOKIE_GET, NULL, sizeof(cookie));
|
||||
|
|
|
@ -10,7 +10,9 @@ int main()
|
|||
RIG *rig;
|
||||
rig_set_debug_level(RIG_DEBUG_ERR);
|
||||
rig = rig_init(1);
|
||||
if (rig == NULL) return 1;
|
||||
|
||||
if (rig == NULL) { return 1; }
|
||||
|
||||
printf("Offsets are OK (i.e. have not changed)\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue