Format the 'adat/' directory.

Apply formatting to Adat.
pull/1/head
Nate Bargmann 2017-08-10 20:41:48 -05:00
rodzic d489b8bcb5
commit 7056aa7f69
4 zmienionych plików z 2197 dodań i 2193 usunięć

Wyświetl plik

@ -23,7 +23,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
# include "config.h"
#endif
// ---------------------------------------------------------------------------
@ -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;

Wyświetl plik

@ -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)
@ -389,7 +388,7 @@ typedef struct _adat_priv_data
// ---------------------------------------------------------------------------
typedef unsigned long long adat_cmd_id_t; // Bit mask for commands. Each command
// is represented by 1 bit.
// is represented by 1 bit.
// adat_cmd_def : ADAT COMMAND DEFINITION.
// Basic idea: Each command can be made of several strings to be sent
@ -398,20 +397,18 @@ 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
int (*pfCmdFn)( RIG *pRig ); // Fn to be called to execute this cmd
int (*pfCmdFn)(RIG *pRig); // Fn to be called to execute this cmd
int nNrCmdStrs; // Oh my, C as a language ... I'd love to
// switch to Common Lisp ... What a hack here ...
@ -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 ];
@ -493,102 +483,102 @@ typedef struct _adat_vfo_list
// Helper functions
size_t trimwhitespace( char *, size_t, const char * );
int adat_print_cmd( adat_cmd_def_ptr );
size_t trimwhitespace(char *, size_t, const char *);
int adat_print_cmd(adat_cmd_def_ptr);
int adat_parse_freq( char *, adat_freq_parse_mode_t, int *, freq_t * );
int adat_parse_freq(char *, adat_freq_parse_mode_t, int *, freq_t *);
int adat_parse_mode( char *, rmode_t *, char * );
int adat_mode_rnr2anr( rmode_t, int * );
int adat_mode_anr2rnr( int, rmode_t * );
int adat_parse_mode(char *, rmode_t *, char *);
int adat_mode_rnr2anr(rmode_t, int *);
int adat_mode_anr2rnr(int, rmode_t *);
int adat_parse_vfo( char *, vfo_t *, int * );
int adat_vfo_rnr2anr( vfo_t, int * );
int adat_vfo_anr2rnr( int, vfo_t * );
int adat_parse_vfo(char *, vfo_t *, int *);
int adat_vfo_rnr2anr(vfo_t, int *);
int adat_vfo_anr2rnr(int, vfo_t *);
int adat_parse_ptt( char *, int * );
int adat_ptt_rnr2anr( ptt_t, int * );
int adat_ptt_anr2rnr( int, ptt_t * );
int adat_parse_ptt(char *, int *);
int adat_ptt_rnr2anr(ptt_t, int *);
int adat_ptt_anr2rnr(int, ptt_t *);
int adat_send( RIG *, char * );
int adat_receive( RIG *, char * );
int adat_send(RIG *, char *);
int adat_receive(RIG *, char *);
int adat_priv_set_cmd( RIG *, char *, int );
int adat_priv_set_result( RIG *, char * );
int adat_priv_clear_result( RIG * );
int adat_priv_set_cmd(RIG *, char *, int);
int adat_priv_set_result(RIG *, char *);
int adat_priv_clear_result(RIG *);
int adat_get_single_cmd_result( RIG * );
int adat_get_single_cmd_result(RIG *);
int adat_cmd_recover_from_error( RIG *, int );
int adat_cmd_recover_from_error(RIG *, int);
int adat_transaction( RIG *, adat_cmd_list_ptr );
int adat_transaction(RIG *, adat_cmd_list_ptr);
adat_priv_data_ptr adat_new_priv_data( RIG * );
void adat_del_priv_data( adat_priv_data_t ** );
adat_priv_data_ptr adat_new_priv_data(RIG *);
void adat_del_priv_data(adat_priv_data_t **);
// Command implementation
int adat_cmd_fn_get_serial_nr( RIG * );
int adat_cmd_fn_get_fw_version( RIG * );
int adat_cmd_fn_get_hw_version( RIG * );
int adat_cmd_fn_get_gui_fw_version( RIG * );
int adat_cmd_fn_get_id_code( RIG * );
int adat_cmd_fn_get_options( RIG * );
int adat_cmd_fn_get_serial_nr(RIG *);
int adat_cmd_fn_get_fw_version(RIG *);
int adat_cmd_fn_get_hw_version(RIG *);
int adat_cmd_fn_get_gui_fw_version(RIG *);
int adat_cmd_fn_get_id_code(RIG *);
int adat_cmd_fn_get_options(RIG *);
int adat_cmd_fn_set_callsign( RIG * );
int adat_cmd_fn_get_callsign( RIG * );
int adat_cmd_fn_set_callsign(RIG *);
int adat_cmd_fn_get_callsign(RIG *);
int adat_cmd_fn_set_freq( RIG * );
int adat_cmd_fn_get_freq( RIG * );
int adat_cmd_fn_set_freq(RIG *);
int adat_cmd_fn_get_freq(RIG *);
int adat_cmd_fn_get_mode( RIG * );
int adat_cmd_fn_set_mode( RIG * );
int adat_cmd_fn_get_mode(RIG *);
int adat_cmd_fn_set_mode(RIG *);
int adat_cmd_fn_get_vfo( RIG * );
int adat_cmd_fn_set_vfo( RIG * );
int adat_cmd_fn_get_vfo(RIG *);
int adat_cmd_fn_set_vfo(RIG *);
int adat_cmd_fn_get_ptt( RIG * );
int adat_cmd_fn_set_ptt( RIG * );
int adat_cmd_fn_get_ptt(RIG *);
int adat_cmd_fn_set_ptt(RIG *);
// ---------------------------------------------------------------------------
// ADAT FUNCTION DECLARATIONS
// ---------------------------------------------------------------------------
int adat_init( RIG * );
int adat_cleanup( RIG * );
int adat_reset( RIG *, reset_t );
int adat_open( RIG * );
int adat_close( RIG * );
int adat_init(RIG *);
int adat_cleanup(RIG *);
int adat_reset(RIG *, reset_t);
int adat_open(RIG *);
int adat_close(RIG *);
int adat_set_conf( RIG *, token_t, const char *val );
int adat_get_conf( RIG *, token_t, char *val );
int adat_set_conf(RIG *, token_t, const char *val);
int adat_get_conf(RIG *, token_t, char *val);
int adat_set_freq( RIG *, vfo_t, freq_t );
int adat_get_freq( RIG *, vfo_t, freq_t * );
int adat_set_freq(RIG *, vfo_t, freq_t);
int adat_get_freq(RIG *, vfo_t, freq_t *);
int adat_set_vfo( RIG *, vfo_t );
int adat_get_vfo( RIG *, vfo_t * );
int adat_set_vfo(RIG *, vfo_t);
int adat_get_vfo(RIG *, vfo_t *);
int adat_set_ptt( RIG *, vfo_t, ptt_t );
int adat_get_ptt( RIG *, vfo_t, ptt_t * );
int adat_set_ptt(RIG *, vfo_t, ptt_t);
int adat_get_ptt(RIG *, vfo_t, ptt_t *);
int adat_set_mode( RIG *, vfo_t, rmode_t, pbwidth_t );
int adat_get_mode( RIG *, vfo_t, rmode_t *, pbwidth_t * );
int adat_set_mode(RIG *, vfo_t, rmode_t, pbwidth_t);
int adat_get_mode(RIG *, vfo_t, rmode_t *, pbwidth_t *);
int adat_set_func( RIG *, vfo_t, setting_t func, int );
int adat_get_func( RIG *, vfo_t, setting_t func, int * );
int adat_set_func(RIG *, vfo_t, setting_t func, int);
int adat_get_func(RIG *, vfo_t, setting_t func, int *);
int adat_set_level( RIG *, vfo_t, setting_t level, value_t );
int adat_get_level( RIG *, vfo_t, setting_t level, value_t * );
int adat_set_level(RIG *, vfo_t, setting_t level, value_t);
int adat_get_level(RIG *, vfo_t, setting_t level, value_t *);
int adat_handle_event( RIG * );
int adat_handle_event(RIG *);
const char * adat_get_info( RIG * );
const char *adat_get_info(RIG *);
int adat_mW2power( RIG *, float *, unsigned int, freq_t, rmode_t );
int adat_power2mW( RIG *, unsigned int *, float, freq_t, rmode_t );
int adat_mW2power(RIG *, float *, unsigned int, freq_t, rmode_t);
int adat_power2mW(RIG *, unsigned int *, float, freq_t, rmode_t);
int adat_get_powerstat( RIG *, powerstat_t * );
int adat_get_powerstat(RIG *, powerstat_t *);
extern const struct rig_caps adt_200a_caps;

Wyświetl plik

@ -23,7 +23,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
# include "config.h"
#endif
// ---------------------------------------------------------------------------
@ -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",
@ -134,35 +133,35 @@ const struct rig_caps adt_200a_caps =
.filters =
{
{ RIG_MODE_CW|RIG_MODE_CWR, Hz(50) },
{ RIG_MODE_CW|RIG_MODE_CWR, Hz(75) },
{ RIG_MODE_CW|RIG_MODE_CWR, Hz(100) },
{ RIG_MODE_CW|RIG_MODE_CWR, Hz(150) },
{ RIG_MODE_CW|RIG_MODE_CWR, Hz(200) },
{ RIG_MODE_CW|RIG_MODE_CWR, Hz(300) },
{ RIG_MODE_CW|RIG_MODE_CWR, Hz(750) },
{ RIG_MODE_CW|RIG_MODE_CWR, Hz(1000) },
{ RIG_MODE_CW|RIG_MODE_CWR, Hz(1200) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(300) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(500) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(750) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(1000) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(1200) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(1500) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(1800) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(2000) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(2200) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(2400) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(2700) },
{ RIG_MODE_LSB|RIG_MODE_USB, Hz(3500) },
{ RIG_MODE_AM|RIG_MODE_SAL|RIG_MODE_SAH, Hz(3000) },
{ RIG_MODE_AM|RIG_MODE_SAL|RIG_MODE_SAH, Hz(3500) },
{ RIG_MODE_AM|RIG_MODE_SAL|RIG_MODE_SAH, Hz(4000) },
{ RIG_MODE_AM|RIG_MODE_SAL|RIG_MODE_SAH, Hz(4500) },
{ RIG_MODE_AM|RIG_MODE_SAL|RIG_MODE_SAH, Hz(5000) },
{ RIG_MODE_AM|RIG_MODE_SAL|RIG_MODE_SAH, Hz(6000) },
{ RIG_MODE_AM|RIG_MODE_SAL|RIG_MODE_SAH, Hz(7000) },
{ RIG_MODE_AM|RIG_MODE_SAL|RIG_MODE_SAH, Hz(8000) },
{ RIG_MODE_CW | RIG_MODE_CWR, Hz(50) },
{ RIG_MODE_CW | RIG_MODE_CWR, Hz(75) },
{ RIG_MODE_CW | RIG_MODE_CWR, Hz(100) },
{ RIG_MODE_CW | RIG_MODE_CWR, Hz(150) },
{ RIG_MODE_CW | RIG_MODE_CWR, Hz(200) },
{ RIG_MODE_CW | RIG_MODE_CWR, Hz(300) },
{ RIG_MODE_CW | RIG_MODE_CWR, Hz(750) },
{ RIG_MODE_CW | RIG_MODE_CWR, Hz(1000) },
{ RIG_MODE_CW | RIG_MODE_CWR, Hz(1200) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(300) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(500) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(750) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(1000) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(1200) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(1500) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(1800) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(2000) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(2200) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(2400) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(2700) },
{ RIG_MODE_LSB | RIG_MODE_USB, Hz(3500) },
{ RIG_MODE_AM | RIG_MODE_SAL | RIG_MODE_SAH, Hz(3000) },
{ RIG_MODE_AM | RIG_MODE_SAL | RIG_MODE_SAH, Hz(3500) },
{ RIG_MODE_AM | RIG_MODE_SAL | RIG_MODE_SAH, Hz(4000) },
{ RIG_MODE_AM | RIG_MODE_SAL | RIG_MODE_SAH, Hz(4500) },
{ RIG_MODE_AM | RIG_MODE_SAL | RIG_MODE_SAH, Hz(5000) },
{ RIG_MODE_AM | RIG_MODE_SAL | RIG_MODE_SAH, Hz(6000) },
{ RIG_MODE_AM | RIG_MODE_SAL | RIG_MODE_SAH, Hz(7000) },
{ RIG_MODE_AM | RIG_MODE_SAL | RIG_MODE_SAH, Hz(8000) },
{ RIG_MODE_FM, Hz(6000) },
{ RIG_MODE_FM, Hz(7000) },
{ RIG_MODE_FM, Hz(8000) },