kopia lustrzana https://github.com/Hamlib/Hamlib
rodzic
d489b8bcb5
commit
7056aa7f69
63
adat/adat.c
63
adat/adat.c
|
@ -42,7 +42,7 @@
|
|||
// HAMLIB INCLUDES
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include <hamlib/rig.h>
|
||||
#include "token.h"
|
||||
#include "serial.h"
|
||||
#include "misc.h"
|
||||
|
@ -577,7 +577,9 @@ size_t trimwhitespace(char *out, size_t len, const char *str)
|
|||
}
|
||||
|
||||
// Trim leading space
|
||||
while (isspace((int)*str)) str++;
|
||||
while (isspace((int)*str)) {
|
||||
str++;
|
||||
}
|
||||
|
||||
if (*str == 0) { // All spaces?
|
||||
out = NULL;
|
||||
|
@ -696,8 +698,8 @@ int adat_parse_freq(char *pcStr,
|
|||
pcEnd = pcStr;
|
||||
}
|
||||
|
||||
if ((_nVFO != 0) || // VFO = 0 -> Current VFO not active.
|
||||
(nMode == ADAT_FREQ_PARSE_MODE_WITHOUT_VFO)) {
|
||||
if ((_nVFO != 0) // VFO = 0 -> Current VFO not active.
|
||||
|| (nMode == ADAT_FREQ_PARSE_MODE_WITHOUT_VFO)) {
|
||||
char acValueBuf[ ADAT_BUFSZ + 1 ];
|
||||
char acUnitBuf[ ADAT_BUFSZ + 1 ];
|
||||
int nI = 0;
|
||||
|
@ -708,8 +710,8 @@ int adat_parse_freq(char *pcStr,
|
|||
|
||||
// Get Freq Value from response string
|
||||
|
||||
while ((isalpha((int)*pcEnd) == 0) ||
|
||||
(*pcEnd == '.')) {
|
||||
while ((isalpha((int)*pcEnd) == 0)
|
||||
|| (*pcEnd == '.')) {
|
||||
acValueBuf[ nI++ ] = *pcEnd;
|
||||
pcEnd += sizeof(char);
|
||||
}
|
||||
|
@ -1277,8 +1279,9 @@ int adat_priv_set_cmd(RIG *pRig, char *pcCmd, int nCmdKind)
|
|||
} else {
|
||||
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
|
||||
|
||||
if (pPriv->pcCmd != NULL)
|
||||
if (pPriv->pcCmd != NULL) {
|
||||
free(pPriv->pcCmd);
|
||||
}
|
||||
|
||||
pPriv->pcCmd = strdup(pcCmd);
|
||||
pPriv->nCmdKind = nCmdKind;
|
||||
|
@ -1317,8 +1320,9 @@ int adat_priv_set_result(RIG *pRig, char *pcResult)
|
|||
} else {
|
||||
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
|
||||
|
||||
if (pPriv->pcResult != NULL)
|
||||
if (pPriv->pcResult != NULL) {
|
||||
free(pPriv->pcResult);
|
||||
}
|
||||
|
||||
pPriv->pcResult = strdup(pcResult);
|
||||
|
||||
|
@ -1360,8 +1364,9 @@ int adat_priv_clear_result(RIG *pRig)
|
|||
} else {
|
||||
adat_priv_data_ptr pPriv = (adat_priv_data_ptr) pRig->state.priv;
|
||||
|
||||
if (pPriv->pcResult != NULL)
|
||||
if (pPriv->pcResult != NULL) {
|
||||
free(pPriv->pcResult);
|
||||
}
|
||||
|
||||
pPriv->pcResult = NULL;
|
||||
}
|
||||
|
@ -1402,8 +1407,9 @@ int adat_get_single_cmd_result(RIG *pRig)
|
|||
|
||||
nRC = adat_send(pRig, pPriv->pcCmd);
|
||||
|
||||
if ((nRC == RIG_OK) &&
|
||||
(pPriv->nCmdKind == ADAT_CMD_KIND_WITH_RESULT)) {
|
||||
if ((nRC == RIG_OK)
|
||||
&& (pPriv->nCmdKind == ADAT_CMD_KIND_WITH_RESULT)) {
|
||||
|
||||
char acBuf[ ADAT_RESPSZ + 1 ];
|
||||
char acBuf2[ ADAT_RESPSZ + 1 ];
|
||||
int nBufLength = 0;
|
||||
|
@ -1425,8 +1431,9 @@ int adat_get_single_cmd_result(RIG *pRig)
|
|||
if ((nRC == RIG_OK) && (pcPos != NULL)) {
|
||||
int nLength = 0;
|
||||
|
||||
if (*pcPos == '\0') // Adjust for 00 byte at beginning ...
|
||||
if (*pcPos == '\0') { // Adjust for 00 byte at beginning ...
|
||||
pcPos++; // No, please don't ask me why this
|
||||
}
|
||||
|
||||
// happens ... ;-)
|
||||
|
||||
|
@ -1441,8 +1448,9 @@ int adat_get_single_cmd_result(RIG *pRig)
|
|||
if (nLength > 0) {
|
||||
char *pcPos2 = strchr(pcPos, (char) 0x0d);
|
||||
|
||||
if (pcPos2 != NULL)
|
||||
if (pcPos2 != NULL) {
|
||||
*pcPos2 = '\0'; // Truncate \0d\0a
|
||||
}
|
||||
|
||||
pcPos = strchr(pcPos, ' ');
|
||||
|
||||
|
@ -1523,9 +1531,10 @@ int adat_cmd_recover_from_error(RIG *pRig, int nError)
|
|||
|
||||
// Recover from communication error
|
||||
|
||||
if ((nError == RIG_ETIMEOUT) ||
|
||||
(nError == RIG_EPROTO) ||
|
||||
(nError == RIG_EIO)) {
|
||||
if ((nError == RIG_ETIMEOUT)
|
||||
|| (nError == RIG_EPROTO)
|
||||
|| (nError == RIG_EIO)) {
|
||||
|
||||
rig_close(pRig);
|
||||
sleep(ADAT_SLEEP_AFTER_RIG_CLOSE);
|
||||
|
||||
|
@ -2415,9 +2424,10 @@ int adat_transaction(RIG *pRig,
|
|||
"*** ADAT: %d pacCmdStrs[%d] = %s\n",
|
||||
gFnLevel, nJ, pCmd->pacCmdStrs[ nJ ]);
|
||||
|
||||
while ((nJ < pCmd->nNrCmdStrs) &&
|
||||
(nRC == RIG_OK) &&
|
||||
(pCmd->pacCmdStrs[ nJ ] != NULL)) {
|
||||
while ((nJ < pCmd->nNrCmdStrs)
|
||||
&& (nRC == RIG_OK)
|
||||
&& (pCmd->pacCmdStrs[ nJ ] != NULL)) {
|
||||
|
||||
nRC = adat_send(pRig, pCmd->pacCmdStrs[ nJ ]);
|
||||
|
||||
if (nRC == RIG_OK) {
|
||||
|
@ -2428,8 +2438,10 @@ int adat_transaction(RIG *pRig,
|
|||
|
||||
nRC = adat_receive(pRig, acBuf);
|
||||
|
||||
while ((nRC == RIG_OK) &&
|
||||
(strncmp(acBuf, ADAT_BOM, strlen(ADAT_BOM)) != 0)) {
|
||||
while ((nRC == RIG_OK)
|
||||
&& (strncmp(acBuf, ADAT_BOM,
|
||||
strlen(ADAT_BOM)) != 0)) {
|
||||
|
||||
nRC = adat_receive(pRig, acBuf);
|
||||
}
|
||||
|
||||
|
@ -2963,8 +2975,9 @@ int adat_set_mode(RIG *pRig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
nRC = adat_vfo_rnr2anr(vfo, &(pPriv->nCurrentVFO));
|
||||
|
||||
if (width != RIG_PASSBAND_NOCHANGE) {
|
||||
if (width == RIG_PASSBAND_NORMAL)
|
||||
if (width == RIG_PASSBAND_NORMAL) {
|
||||
width = rig_passband_normal(pRig, mode);
|
||||
}
|
||||
|
||||
pPriv->nWidth = width;
|
||||
}
|
||||
|
@ -3504,11 +3517,13 @@ DECLARE_PROBERIG_BACKEND(adat)
|
|||
"*** ADAT: %d %s (%s:%d): ENTRY.\n",
|
||||
gFnLevel, __func__, __FILE__, __LINE__);
|
||||
|
||||
if (!port)
|
||||
if (!port) {
|
||||
return RIG_MODEL_NONE;
|
||||
}
|
||||
|
||||
if (port->type.rig != RIG_PORT_SERIAL)
|
||||
if (port->type.rig != RIG_PORT_SERIAL) {
|
||||
return RIG_MODEL_NONE;
|
||||
}
|
||||
|
||||
port->write_delay = port->post_write_delay = 10;
|
||||
port->parm.serial.stop_bits = 0;
|
||||
|
|
32
adat/adat.h
32
adat/adat.h
|
@ -34,7 +34,7 @@
|
|||
// HAMLIB INCLUDES
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include <hamlib/rig.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// GLOBAL DEFINITIONS
|
||||
|
@ -329,8 +329,7 @@
|
|||
// ADAT PRIVATE DATA
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
typedef struct _adat_priv_data
|
||||
{
|
||||
typedef struct _adat_priv_data {
|
||||
int nOpCode;
|
||||
|
||||
char *pcProductName; // Future use (USB direct I/O)
|
||||
|
@ -398,16 +397,14 @@ typedef unsigned long long adat_cmd_id_t; // Bit mask for commands. Each command
|
|||
// executed by adat_transaction(). The last value as returned by the
|
||||
// commands will be set as overall command result.
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
ADAT_CMD_KIND_WITH_RESULT = 0, // After sending a command to the ADAT,
|
||||
// a result has to be read.
|
||||
ADAT_CMD_KIND_WITHOUT_RESULT = 1
|
||||
|
||||
} adat_cmd_kind_t;
|
||||
|
||||
typedef struct _adat_cmd_def_t
|
||||
{
|
||||
typedef struct _adat_cmd_def_t {
|
||||
adat_cmd_id_t nCmdId; // Bit indicating this cmd
|
||||
adat_cmd_kind_t nCmdKind; // Defines if result expected
|
||||
|
||||
|
@ -420,16 +417,14 @@ typedef struct _adat_cmd_def_t
|
|||
} adat_cmd_def_t,
|
||||
* adat_cmd_def_ptr;
|
||||
|
||||
typedef struct _adat_cmd_table_t
|
||||
{
|
||||
typedef struct _adat_cmd_table_t {
|
||||
int nNrCmds;
|
||||
adat_cmd_def_ptr adat_cmds[];
|
||||
|
||||
} adat_cmd_table_t,
|
||||
* adat_cmd_table_ptr;
|
||||
|
||||
typedef struct _adat_cmd_list_t
|
||||
{
|
||||
typedef struct _adat_cmd_list_t {
|
||||
int nNrCmds;
|
||||
adat_cmd_def_ptr adat_cmds[];
|
||||
|
||||
|
@ -440,8 +435,7 @@ typedef struct _adat_cmd_list_t
|
|||
// OTHER ADAT DATA TYPES
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
ADAT_FREQ_PARSE_MODE_WITH_VFO = 0,
|
||||
ADAT_FREQ_PARSE_MODE_WITHOUT_VFO = 1
|
||||
|
||||
|
@ -449,8 +443,7 @@ typedef enum
|
|||
|
||||
// ADAT MODE DEFINITION
|
||||
|
||||
typedef struct _adat_mode_def
|
||||
{
|
||||
typedef struct _adat_mode_def {
|
||||
char *pcADATModeStr;
|
||||
rmode_t nRIGMode;
|
||||
int nADATMode;
|
||||
|
@ -458,8 +451,7 @@ typedef struct _adat_mode_def
|
|||
} adat_mode_def_t,
|
||||
* adat_mode_def_ptr;
|
||||
|
||||
typedef struct _adat_mode_list
|
||||
{
|
||||
typedef struct _adat_mode_list {
|
||||
int nNrModes;
|
||||
|
||||
adat_mode_def_t adat_modes[ ADAT_NR_MODES ];
|
||||
|
@ -469,8 +461,7 @@ typedef struct _adat_mode_list
|
|||
|
||||
// ADAT VFO DEFINITION
|
||||
|
||||
typedef struct _adat_vfo_def
|
||||
{
|
||||
typedef struct _adat_vfo_def {
|
||||
char *pcADATVFOStr;
|
||||
vfo_t nRIGVFONr;
|
||||
int nADATVFONr;
|
||||
|
@ -478,8 +469,7 @@ typedef struct _adat_vfo_def
|
|||
} adat_vfo_def_t,
|
||||
* adat_vfo_def_ptr;
|
||||
|
||||
typedef struct _adat_vfo_list
|
||||
{
|
||||
typedef struct _adat_vfo_list {
|
||||
int nNrVFOs;
|
||||
|
||||
adat_vfo_def_t adat_vfos[ ADAT_NR_VFOS ];
|
||||
|
|
|
@ -53,8 +53,7 @@
|
|||
// ADT-200A HAMLIB CAPS / DESCRIPTION
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const struct rig_caps adt_200a_caps =
|
||||
{
|
||||
const struct rig_caps adt_200a_caps = {
|
||||
.rig_model = RIG_MODEL_ADT_200A,
|
||||
.model_name = "ADT-200A",
|
||||
.mfg_name = "ADAT www.adat.ch",
|
||||
|
|
Ładowanie…
Reference in New Issue