Merge pull request #1522 from GeoBaltz/rp6

Convert all port references to pointers
pull/1523/head
Michael Black 2024-03-01 11:45:44 -06:00 zatwierdzone przez GitHub
commit cef2525d0f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
31 zmienionych plików z 145 dodań i 141 usunięć

Wyświetl plik

@ -132,7 +132,7 @@ int gr_init(RIG *rig)
rig->state.priv = (void*)priv;
rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__ );
rig->state.rigport.type.rig = RIG_PORT_NONE;
RIGORT(rig)->type.rig = RIG_PORT_NONE;
memset(priv->parms, 0, RIG_SETTING_MAX*sizeof(value_t));

Wyświetl plik

@ -2490,6 +2490,7 @@ typedef hamlib_port_t port_t;
#define AMPPORT(a) (&a->state.ampport)
#define ROTPORT(r) (&r->state.rotport)
#define ROTPORT2(r) (&r->state.rotport2)
#define STATE(r) (&r->state)
/* Then when the rigport address is stored as a pointer somewhere else(say,
* in the rig structure itself), the definition could be changed to
* #define RIGPORT(r) r->somewhereelse
@ -2504,6 +2505,7 @@ typedef hamlib_port_t port_t;
#define HAMLIB_AMPPORT(a) ((hamlib_port_t *)amp_data_pointer(a, RIG_PTRX_AMPPORT))
#define HAMLIB_ROTPORT(r) ((hamlib_port_t *)rot_data_pointer(r, RIG_PTRX_ROTPORT))
#define HAMLIB_ROTPORT2(r) ((hamlib_port_t *)rot_data_pointer(r, RIG_PTRX_ROTPORT2))
#define HAMLIB_STATE(r) ((struct rig_state *)rig_data_pointer(r, RIG_PTRX_STATE))
#endif
typedef enum {
@ -2515,6 +2517,7 @@ typedef enum {
RIG_PTRX_AMPPORT,
RIG_PTRX_ROTPORT,
RIG_PTRX_ROTPORT2,
RIG_PTRX_STATE,
// New entries go directly above this line====================
RIG_PTRX_MAXIMUM
} rig_ptrx_t;

Wyświetl plik

@ -2005,7 +2005,9 @@ vfo_t HAMLIB_API vfo_fixup2a(RIG *rig, vfo_t vfo, split_t split,
// We need to add some exceptions to this like the ID-5100
vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split)
{
vfo_t currvfo = rig->state.current_vfo;
struct rig_state *rs = STATE(rig);
vfo_t currvfo = rs->current_vfo;
rig_debug(RIG_DEBUG_TRACE, "%s:(from %s:%d) vfo=%s, vfo_curr=%s, split=%d\n",
__func__, funcname, linenum,
rig_strvfo(vfo), rig_strvfo(currvfo), split);
@ -2013,8 +2015,6 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split)
if (rig->caps->rig_model == RIG_MODEL_ID5100
|| rig->caps->rig_model == RIG_MODEL_IC9700)
{
struct rig_state *rs = &rig->state;
// dualwatch on ID5100 is TX=Main, RX=Sub
if (rig->caps->rig_model == RIG_MODEL_ID5100 && rs->dual_watch)
{
@ -2032,7 +2032,7 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split)
vfo = RIG_VFO_MAIN_A;
// only have Main/Sub when in satmode
if (rig->state.cache.satmode) { vfo = RIG_VFO_MAIN; }
if (CACHE(rig)->satmode) { vfo = RIG_VFO_MAIN; }
}
else if (vfo == RIG_VFO_B && (currvfo == RIG_VFO_MAIN
|| currvfo == RIG_VFO_MAIN_A))
@ -2061,7 +2061,7 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split)
if (vfo == RIG_VFO_OTHER)
{
switch (rig->state.current_vfo)
switch (rs->current_vfo)
{
case RIG_VFO_A:
return RIG_VFO_B;
@ -2085,7 +2085,7 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split)
if (vfo == RIG_VFO_RX)
{
vfo = rig->state.rx_vfo;
vfo = rs->rx_vfo;
}
else if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN)
{
@ -2098,7 +2098,7 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split)
int satmode = CACHE(rig)->satmode;
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): split=%d, vfo==%s tx_vfo=%s\n", __func__,
__LINE__, split, rig_strvfo(vfo), rig_strvfo(rig->state.tx_vfo));
__LINE__, split, rig_strvfo(vfo), rig_strvfo(rs->tx_vfo));
if (VFO_HAS_MAIN_SUB_ONLY && !split && !satmode && vfo != RIG_VFO_B) { vfo = RIG_VFO_MAIN; }

Wyświetl plik

@ -606,7 +606,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
* populate the rig->state
* TODO: read the Preferences here!
*/
rs = &rig->state;
rs = STATE(rig);
#if defined(HAVE_PTHREAD)
pthread_mutex_init(&rs->mutex_set_transaction, NULL);
#endif
@ -623,10 +623,13 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
rs->rig_model = caps->rig_model;
rs->priv = NULL;
rs->async_data_enabled = 0;
rs->depth = 1;
rs->comm_state = 0;
rs->comm_status = RIG_COMM_STATUS_CONNECTING;
rs->tuner_control_pathname = DEFAULT_TUNER_CONTROL_PATHNAME;
rp->fd = -1;
pttp->fd = -1;
rs->comm_state = 0;
rig->state.depth = 1;
#if 0 // extra debug if needed
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %p rs->comm_state==0?=%d\n", __func__,
__LINE__, &rs->comm_state,
@ -636,9 +639,6 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
#if defined(HAVE_PTHREAD)
rp->asyncio = 0;
#endif
rig->state.comm_status = RIG_COMM_STATUS_CONNECTING;
rs->tuner_control_pathname = DEFAULT_TUNER_CONTROL_PATHNAME;
switch (caps->port_type)
{
@ -946,7 +946,7 @@ int HAMLIB_API rig_open(RIG *rig)
}
caps = rig->caps;
rs = &rig->state;
rs = STATE(rig);
rp->rig = rig;
rs->rigport_deprecated.rig = rig;
@ -1642,7 +1642,7 @@ int HAMLIB_API rig_close(RIG *rig)
caps = rig->caps;
rs = &rig->state;
rs = STATE(rig);
if (!rs->comm_state)
{
@ -3039,7 +3039,7 @@ pbwidth_t HAMLIB_API rig_passband_normal(RIG *rig, rmode_t mode)
ENTERFUNC;
rs = &rig->state;
rs = STATE(rig);
// return CW for CWR and RTTY for RTTYR
if (mode == RIG_MODE_CWR) { mode = RIG_MODE_CW; }
@ -3091,7 +3091,7 @@ pbwidth_t HAMLIB_API rig_passband_narrow(RIG *rig, rmode_t mode)
ENTERFUNC;
rs = &rig->state;
rs = STATE(rig);
for (i = 0; i < HAMLIB_FLTLSTSIZ - 1 && rs->filters[i].modes; i++)
{
@ -3144,7 +3144,7 @@ pbwidth_t HAMLIB_API rig_passband_wide(RIG *rig, rmode_t mode)
ENTERFUNC;
rs = &rig->state;
rs = STATE(rig);
for (i = 0; i < HAMLIB_FLTLSTSIZ - 1 && rs->filters[i].modes; i++)
{
@ -3428,7 +3428,7 @@ int HAMLIB_API rig_get_vfo(RIG *rig, vfo_t *vfo)
int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
const struct rig_caps *caps;
struct rig_state *rs = &rig->state;
struct rig_state *rs = STATE(rig);
hamlib_port_t *rp = RIGPORT(rig);
hamlib_port_t *pttp = PTTPORT(rig);
struct rig_cache *cachep = CACHE(rig);
@ -3756,7 +3756,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
const struct rig_caps *caps;
struct rig_state *rs = &rig->state;
struct rig_state *rs = STATE(rig);
hamlib_port_t *rp = RIGPORT(rig);
hamlib_port_t *pttp = PTTPORT(rig);
struct rig_cache *cachep = CACHE(rig);
@ -4563,7 +4563,7 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo), tx_freq);
caps = rig->caps;
rs = &rig->state;
rs = STATE(rig);
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo;
@ -4753,7 +4753,7 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
}
caps = rig->caps;
rs = &rig->state;
rs = STATE(rig);
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo;
@ -4930,7 +4930,7 @@ int HAMLIB_API rig_set_split_mode(RIG *rig,
ENTERFUNC;
caps = rig->caps;
rs = &rig->state;
rs = STATE(rig);
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo;
@ -5167,7 +5167,7 @@ int HAMLIB_API rig_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
}
caps = rig->caps;
rs = &rig->state;
rs = STATE(rig);
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo;
@ -5327,7 +5327,7 @@ int HAMLIB_API rig_set_split_freq_mode(RIG *rig,
ENTERFUNC;
caps = rig->caps;
rs = &rig->state;
rs = STATE(rig);
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo;
@ -5474,7 +5474,7 @@ int HAMLIB_API rig_get_split_freq_mode(RIG *rig,
}
caps = rig->caps;
rs = &rig->state;
rs = STATE(rig);
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo;
@ -5557,7 +5557,7 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
rig_strvfo(rx_vfo), split, rig_strvfo(tx_vfo), cachep->split);
caps = rig->caps;
rs = &rig->state;
rs = STATE(rig);
if (caps->set_split_vfo == NULL)
{
@ -5813,7 +5813,7 @@ int HAMLIB_API rig_get_split_vfo(RIG *rig,
}
caps = rig->caps;
rs = &rig->state;
rs = STATE(rig);
if (MUTEX_CHECK(&morse_mutex))
{
@ -6656,7 +6656,7 @@ shortfreq_t HAMLIB_API rig_get_resolution(RIG *rig, rmode_t mode)
ENTERFUNC;
rs = &rig->state;
rs = STATE(rig);
for (i = 0; i < HAMLIB_TSLSTSIZ && rs->tuning_steps[i].ts; i++)
{
@ -8249,7 +8249,7 @@ void rig_lock(RIG *rig, int lock)
#if defined(HAVE_PTHREAD)
static int async_data_handler_start(RIG *rig)
{
struct rig_state *rs = &rig->state;
struct rig_state *rs = STATE(rig);
async_data_handler_priv_data *async_data_handler_priv;
ENTERFUNC;
@ -8293,7 +8293,7 @@ static int async_data_handler_start(RIG *rig)
#if defined(HAVE_PTHREAD)
static int morse_data_handler_start(RIG *rig)
{
struct rig_state *rs = &rig->state;
struct rig_state *rs = STATE(rig);
morse_data_handler_priv_data *morse_data_handler_priv;
ENTERFUNC;
@ -8334,7 +8334,7 @@ static int morse_data_handler_start(RIG *rig)
#if defined(HAVE_PTHREAD)
static int async_data_handler_stop(RIG *rig)
{
struct rig_state *rs = &rig->state;
struct rig_state *rs = STATE(rig);
async_data_handler_priv_data *async_data_handler_priv;
ENTERFUNC;
@ -8375,7 +8375,7 @@ static int async_data_handler_stop(RIG *rig)
#if defined(HAVE_PTHREAD)
static int morse_data_handler_stop(RIG *rig)
{
struct rig_state *rs = &rig->state;
struct rig_state *rs = STATE(rig);
morse_data_handler_priv_data *morse_data_handler_priv;
ENTERFUNC;
@ -8390,7 +8390,7 @@ static int morse_data_handler_stop(RIG *rig)
hl_usleep(100 * 1000);
//HAMLIB_TRACE;
while (peek(rig->state.fifo_morse) >= 0)
while (peek(rs->fifo_morse) >= 0)
{
HAMLIB_TRACE;
rig_debug(RIG_DEBUG_TRACE, "%s: waiting for fifo queue to flush\n", __func__);
@ -8435,7 +8435,7 @@ void *async_data_handler(void *arg)
arg;
RIG *rig = args->rig;
unsigned char frame[MAX_FRAME_LENGTH];
struct rig_state *rs = &rig->state;
struct rig_state *rs = STATE(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting async data handler thread\n",
__func__);
@ -8521,18 +8521,19 @@ void *morse_data_handler(void *arg)
struct morse_data_handler_args_s *args =
(struct morse_data_handler_args_s *) arg;
RIG *rig = args->rig;
const struct rig_state *rs = &rig->state;
const struct rig_state *rs = STATE(rig);
int result;
rig_debug(RIG_DEBUG_VERBOSE, "%s: Starting morse data handler thread\n",
__func__);
if (rig->state.fifo_morse == NULL)
if (STATE(rig)->fifo_morse == NULL)
{
rig->state.fifo_morse = calloc(1, sizeof(FIFO_RIG));
// Can't use rs-> 'cuz it's const
STATE(rig)->fifo_morse = calloc(1, sizeof(FIFO_RIG));
}
initFIFO(rig->state.fifo_morse);
initFIFO(rs->fifo_morse);
char *c;
int qsize = rig->caps->morse_qsize; // if backend overrides qsize
@ -8548,14 +8549,14 @@ void *morse_data_handler(void *arg)
for (n = 0; n < qsize; n++)
{
int d = peek(rig->state.fifo_morse);
int d = peek(rs->fifo_morse);
if (d < 0)
{
break;
}
d = pop(rig->state.fifo_morse);
d = pop(rs->fifo_morse);
c[n] = (char) d;
}
@ -8623,7 +8624,7 @@ void *morse_data_handler(void *arg)
if (result == -RIG_EINVAL)
{
// severe error -- so flush it and stop
resetFIFO(rig->state.fifo_morse);
resetFIFO(rs->fifo_morse);
nloops = 0;
}
@ -8634,7 +8635,7 @@ void *morse_data_handler(void *arg)
nloops--;
}
while (result != RIG_OK && rig->state.fifo_morse->flush == 0 && --nloops > 0);
while (result != RIG_OK && STATE(rig)->fifo_morse->flush == 0 && --nloops > 0);
MUTEX_UNLOCK(morse_mutex);
@ -8645,13 +8646,13 @@ void *morse_data_handler(void *arg)
}
}
rig->state.fifo_morse->flush = 0; // reset flush flag
rs->fifo_morse->flush = 0; // reset flush flag
hl_usleep(100 * 1000);
}
free(rig->state.fifo_morse);
free(STATE(rig)->fifo_morse);
free(c);
rig->state.fifo_morse = NULL;
STATE(rig)->fifo_morse = NULL;
pthread_exit(NULL);
return NULL;
}
@ -8830,7 +8831,7 @@ HAMLIB_EXPORT(int) rig_is_model(RIG *rig, rig_model_t model)
#if defined(HAVE_PTHREAD)
int morse_data_handler_set_keyspd(RIG *rig, int keyspd)
{
struct rig_state *rs = &rig->state;
struct rig_state *rs = STATE(rig);
morse_data_handler_priv_data *morse_data_handler_priv =
(morse_data_handler_priv_data *) rs->morse_data_handler_priv_data;
morse_data_handler_priv->keyspd = keyspd;
@ -8870,6 +8871,9 @@ HAMLIB_EXPORT(void *) rig_data_pointer(RIG *rig, rig_ptrx_t idx)
case RIG_PTRX_CACHE:
return CACHE(rig);
case RIG_PTRX_STATE:
return STATE(rig);
default:
rig_debug(RIG_DEBUG_ERR, "%s: Invalid data index=%d\n", __func__, idx);
return NULL;

Wyświetl plik

@ -328,7 +328,7 @@ int main(int argc, char *argv[])
if (amp_file)
{
strncpy(my_amp->state.ampport.pathname, amp_file, HAMLIB_FILPATHLEN - 1);
strncpy(AMPPORT(my_amp)->pathname, amp_file, HAMLIB_FILPATHLEN - 1);
strncpy(my_amp->state.ampport_deprecated.pathname, amp_file,
HAMLIB_FILPATHLEN - 1);
}
@ -336,7 +336,7 @@ int main(int argc, char *argv[])
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_amp->state.ampport.parm.serial.rate = serial_rate;
AMPPORT(my_amp)->parm.serial.rate = serial_rate;
my_amp->state.ampport_deprecated.parm.serial.rate = serial_rate;
}

Wyświetl plik

@ -1990,7 +1990,7 @@ declare_proto_amp(get_powerstat)
declare_proto_amp(send_cmd)
{
int retval;
struct amp_state *rs;
hamlib_port_t *ampp = AMPPORT(amp);
int backend_num, cmd_len;
#define BUFSZ 128
unsigned char bufcmd[BUFSZ];
@ -2038,11 +2038,9 @@ declare_proto_amp(send_cmd)
eom_buf[2] = send_cmd_term;
}
rs = &amp->state;
rig_flush(ampp);
rig_flush(&rs->ampport);
retval = write_block(&rs->ampport, bufcmd, cmd_len);
retval = write_block(ampp, bufcmd, cmd_len);
if (retval != RIG_OK)
{
@ -2060,7 +2058,7 @@ declare_proto_amp(send_cmd)
* assumes CR or LF is end of line char
* for all ascii protocols
*/
retval = read_string(&rs->ampport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1);
retval = read_string(ampp, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1);
if (retval < 0)
{

Wyświetl plik

@ -353,13 +353,13 @@ int main(int argc, char *argv[])
if (amp_file)
{
strncpy(my_amp->state.ampport.pathname, amp_file, HAMLIB_FILPATHLEN - 1);
strncpy(AMPPORT(my_amp)->pathname, amp_file, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_amp->state.ampport.parm.serial.rate = serial_rate;
AMPPORT(my_amp)->parm.serial.rate = serial_rate;
}
/*

Wyświetl plik

@ -77,9 +77,9 @@ int main(int argc, char *argv[])
/* Set up serial port, baud rate */
rig_file = argv[2]; // your serial device
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
my_rig->state.rigport.parm.serial.rate = baud; // your baud rate
RIGPORT(my_rig)->parm.serial.rate = baud; // your baud rate
/* Open my rig */
retcode = rig_open(my_rig);

Wyświetl plik

@ -44,7 +44,7 @@ int main(int argc, const char *argv[])
/* Set up serial port, baud rate */
rig_file = "127.0.0.1:4532"; // your serial device
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
/* Open my rig */
retcode = rig_open(my_rig);

Wyświetl plik

@ -12,7 +12,7 @@ int callback(const struct rig_caps *caps, rig_ptr_t rigp)
}
const char *port = "/dev/pts/3";
strcpy(rig->state.rigport.pathname, port);
strcpy(RIGPORT(rig)->pathname, port);
printf("%20s:", caps->model_name);
fflush(stdout);

Wyświetl plik

@ -57,7 +57,7 @@ int main(int argc, const char *argv[])
exit(1); /* whoops! something went wrong (mem alloc?) */
}
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
if (rig_open(my_rig))
{

Wyświetl plik

@ -67,12 +67,12 @@ int main(int argc, const char *argv[])
my_rig->caps->version,
rig_strstatus(my_rig->caps->status));
printf("Serial speed: %d baud\n", my_rig->state.rigport.parm.serial.rate);
printf("Serial speed: %d baud\n", RIGPORT(my_rig)->parm.serial.rate);
#if 0 // if we want to bench serial or network I/O use this time
rig_set_cache_timeout_ms(my_rig, HAMLIB_CACHE_ALL, 0);
#endif
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
retcode = rig_open(my_rig);

Wyświetl plik

@ -592,7 +592,7 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
/*
@ -600,7 +600,7 @@ int main(int argc, char *argv[])
*/
if (ptt_type != RIG_PTT_NONE)
{
my_rig->state.pttport.type.ptt = ptt_type;
PTTPORT(my_rig)->type.ptt = ptt_type;
}
if (dcd_type != RIG_DCD_NONE)
@ -610,7 +610,7 @@ int main(int argc, char *argv[])
if (ptt_file)
{
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(PTTPORT(my_rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
}
if (dcd_file)
@ -621,7 +621,7 @@ int main(int argc, char *argv[])
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(my_rig)->parm.serial.rate = serial_rate;
my_rig->state.rigport_deprecated.parm.serial.rate = serial_rate;
}

Wyświetl plik

@ -2576,7 +2576,7 @@ declare_proto_rig(set_ptt)
if (rig->caps->ptt_type != RIG_PTT_RIG_MICDATA)
{
rig_debug(RIG_DEBUG_ERR, "%s: pttport.type.ptt=%d\n", __func__,
rig->state.pttport.type.ptt);
PTTPORT(rig)->type.ptt);
ptt = RIG_PTT_ON;
}
@ -4654,7 +4654,7 @@ declare_proto_rig(dump_state)
{
fprintf(fout, "vfo_ops=0x%x\n", rig->caps->vfo_ops);
fprintf(fout, "ptt_type=0x%x\n",
rig->state.pttport.type.ptt);
PTTPORT(rig)->type.ptt);
fprintf(fout, "targetable_vfo=0x%x\n", rig->caps->targetable_vfo);
fprintf(fout, "has_set_vfo=%d\n", rig->caps->set_vfo != NULL);
fprintf(fout, "has_get_vfo=%d\n", rig->caps->get_vfo != NULL);
@ -5005,7 +5005,7 @@ extern int flrig_cat_string(RIG *rig, const char *arg);
declare_proto_rig(send_cmd)
{
int retval;
struct rig_state *rs = &rig->state;
hamlib_port_t *rp = RIGPORT(rig);
int backend_num, cmd_len;
#define BUFSZ 512
char bufcmd[BUFSZ * 5]; // allow for 5 chars for binary
@ -5015,7 +5015,7 @@ declare_proto_rig(send_cmd)
int rxbytes = BUFSZ;
int simulate = rig->caps->rig_model == RIG_MODEL_DUMMY ||
rig->caps->rig_model == RIG_MODEL_NONE ||
rs->rigport.rig == RIG_PORT_NONE;
rp->rig == RIG_PORT_NONE;
ENTERFUNC2;
@ -5120,7 +5120,7 @@ declare_proto_rig(send_cmd)
}
rig_debug(RIG_DEBUG_TRACE, "%s: rigport=%d, bufcmd=%s, cmd_len=%d\n", __func__,
rs->rigport.fd, hasbinary(bufcmd, cmd_len) ? "BINARY" : bufcmd, cmd_len);
rp->fd, hasbinary(bufcmd, cmd_len) ? "BINARY" : bufcmd, cmd_len);
set_transaction_active(rig);
@ -5131,17 +5131,17 @@ declare_proto_rig(send_cmd)
}
else
{
rig_flush(&rs->rigport);
rig_flush(rp);
// we don't want the 'w' command to wait too long
int save_retry = rs->rigport.retry;
rs->rigport.retry = 0;
retval = write_block(&rs->rigport, (unsigned char *) bufcmd, cmd_len);
rs->rigport.retry = save_retry;
int save_retry = rp->retry;
rp->retry = 0;
retval = write_block(rp, (unsigned char *) bufcmd, cmd_len);
rp->retry = save_retry;
if (retval != RIG_OK)
{
rig_flush_force(&rs->rigport, 1);
rig_flush_force(rp, 1);
set_transaction_inactive(rig);
RETURNFUNC2(retval);
}
@ -5193,7 +5193,7 @@ declare_proto_rig(send_cmd)
else
{
/* Assumes CR or LF is end of line char for all ASCII protocols. */
retval = read_string(&rs->rigport, buf, rxbytes, eom_buf,
retval = read_string(rp, buf, rxbytes, eom_buf,
strlen(eom_buf), 0, 1);
if (retval < 0)
@ -5245,7 +5245,7 @@ declare_proto_rig(send_cmd)
strncat(hexbuf, hex, hexbufbytes - 1);
}
rig_flush_force(&rs->rigport, 1);
rig_flush_force(rp, 1);
set_transaction_inactive(rig);
rig_debug(RIG_DEBUG_TRACE, "%s: binary=%s, retval=%d\n", __func__, hexbuf,
@ -5262,7 +5262,7 @@ declare_proto_rig(send_cmd)
}
while (retval > 0 && rxbytes == BUFSZ);
rig_flush_force(&rs->rigport, 1);
rig_flush_force(rp, 1);
set_transaction_inactive(rig);
// we use fwrite in case of any nulls in binary return
@ -5786,7 +5786,7 @@ declare_proto_rig(cm108_get_bit)
if (n != 1) { return -RIG_EINVAL; }
int retval = rig_cm108_get_bit(&rig->state.pttport, gpio, &bit);
int retval = rig_cm108_get_bit(PTTPORT(rig), gpio, &bit);
if (retval != RIG_OK)
{
@ -5826,7 +5826,7 @@ declare_proto_rig(cm108_set_bit)
if (n != 1) { return -RIG_EINVAL; }
rig_debug(RIG_DEBUG_TRACE, "%s: set gpio=%d, bit=%d\n", __func__, gpio, bit);
int retval = rig_cm108_set_bit(&rig->state.pttport, gpio, bit);
int retval = rig_cm108_set_bit(PTTPORT(rig), gpio, bit);
if (retval != RIG_OK)
{

Wyświetl plik

@ -512,7 +512,7 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
if (!rig_file2)
@ -528,7 +528,7 @@ int main(int argc, char *argv[])
*/
if (ptt_type != RIG_PTT_NONE)
{
my_rig->state.pttport.type.ptt = ptt_type;
PTTPORT(my_rig)->type.ptt = ptt_type;
}
if (dcd_type != RIG_DCD_NONE)
@ -538,7 +538,7 @@ int main(int argc, char *argv[])
if (ptt_file)
{
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(PTTPORT(my_rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
}
if (dcd_file)
@ -549,7 +549,7 @@ int main(int argc, char *argv[])
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(my_rig)->parm.serial.rate = serial_rate;
}
if (serial_rate2 != 0)

Wyświetl plik

@ -691,7 +691,7 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
my_rig->state.twiddle_timeout = twiddle_timeout;
@ -706,7 +706,7 @@ int main(int argc, char *argv[])
*/
if (ptt_type != RIG_PTT_NONE)
{
my_rig->state.pttport.type.ptt = ptt_type;
PTTPORT(my_rig)->type.ptt = ptt_type;
my_rig->state.pttport_deprecated.type.ptt = ptt_type;
// This causes segfault since backend rig_caps are const
// rigctld will use the rig->state version of this for clients
@ -721,7 +721,7 @@ int main(int argc, char *argv[])
if (ptt_file)
{
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(PTTPORT(my_rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(my_rig->state.pttport_deprecated.pathname, ptt_file,
HAMLIB_FILPATHLEN - 1);
}
@ -736,7 +736,7 @@ int main(int argc, char *argv[])
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(my_rig)->parm.serial.rate = serial_rate;
my_rig->state.rigport_deprecated.parm.serial.rate = serial_rate;
}

Wyświetl plik

@ -540,11 +540,11 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
fprintf(stderr, "rig to send frequency to: %s\n", rig_file2);
strncpy(my_rig_sync->state.rigport.pathname, rig_file2, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig_sync)->pathname, rig_file2, HAMLIB_FILPATHLEN - 1);
#if 0
@ -553,7 +553,7 @@ int main(int argc, char *argv[])
*/
if (ptt_type != RIG_PTT_NONE)
{
my_rig->state.pttport.type.ptt = ptt_type;
PTTPORT(my_rig)->type.ptt = ptt_type;
}
if (dcd_type != RIG_DCD_NONE)
@ -563,7 +563,7 @@ int main(int argc, char *argv[])
if (ptt_file)
{
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(PTTPORT(my_rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
}
if (dcd_file)
@ -576,12 +576,12 @@ int main(int argc, char *argv[])
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(my_rig)->parm.serial.rate = serial_rate;
}
if (serial_rate2 != 0)
{
my_rig_sync->state.rigport.parm.serial.rate = serial_rate2;
RIGPORT(my_rig_sync)->parm.serial.rate = serial_rate2;
}

Wyświetl plik

@ -686,7 +686,7 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
my_rig->state.twiddle_timeout = twiddle_timeout;
@ -701,7 +701,7 @@ int main(int argc, char *argv[])
*/
if (ptt_type != RIG_PTT_NONE)
{
my_rig->state.pttport.type.ptt = ptt_type;
PTTPORT(my_rig)->type.ptt = ptt_type;
my_rig->state.pttport_deprecated.type.ptt = ptt_type;
// This causes segfault since backend rig_caps are const
// rigctld will use the rig->state version of this for clients
@ -716,7 +716,7 @@ int main(int argc, char *argv[])
if (ptt_file)
{
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(PTTPORT(my_rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(my_rig->state.pttport_deprecated.pathname, ptt_file,
HAMLIB_FILPATHLEN - 1);
}
@ -731,7 +731,7 @@ int main(int argc, char *argv[])
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(my_rig)->parm.serial.rate = serial_rate;
my_rig->state.rigport_deprecated.parm.serial.rate = serial_rate;
}
@ -1309,7 +1309,7 @@ void *handle_socket(void *arg)
if (cmd[0] != 0)
{
memset(reply, 0, sizeof(reply));
rig_flush(&my_rig->state.rigport);
rig_flush(RIGPORT(my_rig));
retcode = rig_send_raw(my_rig, cmd, nbytes, reply, sizeof(reply),
term);

Wyświetl plik

@ -82,7 +82,7 @@ int main(int argc, const char *argv[])
exit(1); /* whoops! something went wrong (mem alloc?) */
}
strncpy(my_rig->state.rigport.pathname, argv[2], HAMLIB_FILPATHLEN - 1);
rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), argv[2]);
retcode = rig_open(my_rig);

Wyświetl plik

@ -283,13 +283,13 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(rig)->parm.serial.rate = serial_rate;
}
if (civaddr)

Wyświetl plik

@ -265,13 +265,13 @@ int main(int argc, char *argv[])
if (rig_file)
{
strncpy(rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(rig)->parm.serial.rate = serial_rate;
}
if (civaddr)
@ -329,13 +329,13 @@ int main(int argc, char *argv[])
if (rot_file)
{
strncpy(rot->state.rotport.pathname, rot_file, HAMLIB_FILPATHLEN - 1);
strncpy(ROTPORT(rot)->pathname, rot_file, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
if (rot_serial_rate != 0)
{
rot->state.rotport.parm.serial.rate = rot_serial_rate;
ROTPORT(rot)->parm.serial.rate = rot_serial_rate;
}
retcode = rot_open(rot);

Wyświetl plik

@ -257,23 +257,23 @@ int main(int argc, char *argv[])
if (ptt_type != RIG_PTT_NONE)
{
rig->state.pttport.type.ptt = ptt_type;
PTTPORT(rig)->type.ptt = ptt_type;
}
if (ptt_file)
{
strncpy(rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(PTTPORT(rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
}
if (rig_file)
{
strncpy(rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
rig->state.rigport.parm.serial.rate = serial_rate;
RIGPORT(rig)->parm.serial.rate = serial_rate;
}
if (civaddr)
@ -283,7 +283,7 @@ int main(int argc, char *argv[])
if (!rig_has_get_level(rig, RIG_LEVEL_SWR)
|| rig->state.pttport.type.ptt == RIG_PTT_NONE)
|| PTTPORT(rig)->type.ptt == RIG_PTT_NONE)
{
fprintf(stderr,

Wyświetl plik

@ -25,11 +25,11 @@ int main(int argc, const char *argv[])
}
#ifdef _WIN32
strncpy(rig->state.rigport.pathname, "COM37", HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(rig)->pathname, "COM37", HAMLIB_FILPATHLEN - 1);
#else
strncpy(rig->state.rigport.pathname, "/dev/ttyUSB0", HAMLIB_FILPATHLEN - 1);
strncpy(RIGPORT(rig)->pathname, "/dev/ttyUSB0", HAMLIB_FILPATHLEN - 1);
#endif
rig->state.rigport.parm.serial.rate = 38400;
RIGPORT(rig)->parm.serial.rate = 38400;
rig_open(rig);
// disabled until we change this to the other multicast capability
#if 0

Wyświetl plik

@ -368,26 +368,26 @@ int main(int argc, char *argv[])
token = strtok(NULL, ",");
}
hamlib_port_t *rotp = ROTPORT(my_rot);
hamlib_port_t *rotp2 = ROTPORT2(my_rot);
if (rot_file)
{
strncpy(my_rot->state.rotport.pathname, rot_file, HAMLIB_FILPATHLEN - 1);
strncpy(rotp->pathname, rot_file, HAMLIB_FILPATHLEN - 1);
}
if (rot_file2)
{
strncpy(my_rot->state.rotport2.pathname, rot_file2, HAMLIB_FILPATHLEN - 1);
strncpy(rotp2->pathname, rot_file2, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
my_rot->state.rotport2.parm.serial.rate =
my_rot->state.rotport.parm.serial.rate;
my_rot->state.rotport2.parm.serial.data_bits =
my_rot->state.rotport.parm.serial.data_bits;
rotp2->parm.serial.rate = rotp->parm.serial.rate;
rotp2->parm.serial.data_bits = rotp->parm.serial.data_bits;
if (serial_rate != 0)
{
my_rot->state.rotport.parm.serial.rate = serial_rate;
my_rot->state.rotport2.parm.serial.rate = serial_rate;
rotp->parm.serial.rate = serial_rate;
rotp2->parm.serial.rate = serial_rate;
}
/*

Wyświetl plik

@ -2507,7 +2507,7 @@ declare_proto_rot(dump_state)
declare_proto_rot(send_cmd)
{
int retval;
struct rot_state *rs;
hamlib_port_t *rotp = ROTPORT(rot);
int backend_num, cmd_len;
#define BUFSZ 128
unsigned char bufcmd[BUFSZ];
@ -2555,11 +2555,9 @@ declare_proto_rot(send_cmd)
eom_buf[2] = send_cmd_term;
}
rs = &rot->state;
rig_flush(rotp);
rig_flush(&rs->rotport);
retval = write_block(&rs->rotport, bufcmd, cmd_len);
retval = write_block(rotp, bufcmd, cmd_len);
if (retval != RIG_OK)
{
@ -2577,7 +2575,7 @@ declare_proto_rot(send_cmd)
* assumes CR or LF is end of line char
* for all ascii protocols
*/
retval = read_string(&rs->rotport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1);
retval = read_string(rotp, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1);
if (retval < 0)
{

Wyświetl plik

@ -376,18 +376,18 @@ int main(int argc, char *argv[])
if (rot_file)
{
strncpy(my_rot->state.rotport.pathname, rot_file, HAMLIB_FILPATHLEN - 1);
strncpy(ROTPORT(my_rot)->pathname, rot_file, HAMLIB_FILPATHLEN - 1);
}
if (rot_file2)
{
strncpy(my_rot->state.rotport2.pathname, rot_file2, HAMLIB_FILPATHLEN - 1);
strncpy(ROTPORT2(my_rot)->pathname, rot_file2, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
if (serial_rate != 0)
{
my_rot->state.rotport.parm.serial.rate = serial_rate;
ROTPORT(my_rot)->parm.serial.rate = serial_rate;
}
/*

Wyświetl plik

@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <hamlib/rig.h>
#define PATH "/dev/pts/4"
int
main()
@ -15,7 +16,7 @@ main()
int retcode;
my_rig = rig_init(2048);
strcpy(my_rig->state.rigport.pathname, "/dev/pts/4");
rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), PATH);
retcode = rig_open(my_rig);

Wyświetl plik

@ -46,7 +46,7 @@ int main(int argc, char *argv[])
/* Set up serial port, baud rate */
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), rig_file);
/* Open my rig */
retcode = rig_open(my_rig);

Wyświetl plik

@ -68,7 +68,7 @@ int main(int argc, const char *argv[])
exit(1); /* whoops! something went wrong (mem alloc?) */
}
//strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
//strncpy(RIGPORT(my_rig)->pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
retcode = rig_open(my_rig);

Wyświetl plik

@ -30,7 +30,7 @@ int callback(struct rig_caps *caps, rig_ptr_t rigp)
}
const char *port = "/dev/pts/3";
strcpy(rig->state.rigport.pathname, port);
rig_set_conf(rig, rig_token_lookup(rig, "rig_pathname"), port);
printf("%20s:", caps->model_name);
fflush(stdout);

Wyświetl plik

@ -52,7 +52,7 @@ int main(int argc, const char *argv[])
exit(1); /* whoops! something went wrong (mem alloc?) */
}
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), SERIAL_PORT);
if (rig_open(my_rig))
{