Yet another batch of state pointers

pull/1584/head
George Baltz N3GB 2024-07-11 12:44:30 -04:00
rodzic 7bf63ecbf0
commit 16707507c6
5 zmienionych plików z 29 dodań i 26 usunięć

Wyświetl plik

@ -71,6 +71,7 @@ static int print_ext(RIG *rig, const struct confparams *cfp, rig_ptr_t ptr)
int dumpcaps(RIG *rig, FILE *fout) int dumpcaps(RIG *rig, FILE *fout)
{ {
const struct rig_caps *caps; const struct rig_caps *caps;
struct rig_state *rs;
int status, i; int status, i;
int can_esplit, can_echannel; int can_esplit, can_echannel;
char freqbuf[20]; char freqbuf[20];
@ -89,6 +90,7 @@ int dumpcaps(RIG *rig, FILE *fout)
} }
caps = rig->caps; caps = rig->caps;
rs = STATE(rig);
fprintf(fout, "Caps dump for model: %u\n", caps->rig_model); fprintf(fout, "Caps dump for model: %u\n", caps->rig_model);
fprintf(fout, "Model name:\t%s\n", caps->model_name); fprintf(fout, "Model name:\t%s\n", caps->model_name);
@ -439,10 +441,9 @@ int dumpcaps(RIG *rig, FILE *fout)
fprintf(fout, "Extra parameters:\n"); fprintf(fout, "Extra parameters:\n");
rig_ext_parm_foreach(rig, print_ext, fout); rig_ext_parm_foreach(rig, print_ext, fout);
if (rs->mode_list != 0)
if (rig->state.mode_list != 0)
{ {
rig_sprintf_mode(prntbuf, sizeof(prntbuf), rig->state.mode_list); rig_sprintf_mode(prntbuf, sizeof(prntbuf), rs->mode_list);
} }
else else
{ {
@ -453,9 +454,9 @@ int dumpcaps(RIG *rig, FILE *fout)
fprintf(fout, "Mode list: %s\n", prntbuf); fprintf(fout, "Mode list: %s\n", prntbuf);
if (rig->state.vfo_list != 0) if (rs->vfo_list != 0)
{ {
rig_sprintf_vfo(prntbuf, sizeof(prntbuf), rig->state.vfo_list); rig_sprintf_vfo(prntbuf, sizeof(prntbuf), rs->vfo_list);
} }
else else
{ {
@ -922,7 +923,7 @@ int dumpcaps(RIG *rig, FILE *fout)
can_echannel = caps->set_mem can_echannel = caps->set_mem
&& ((caps->set_vfo && ((caps->set_vfo
&& ((rig->state.vfo_list & RIG_VFO_MEM) == RIG_VFO_MEM)) && ((rs->vfo_list & RIG_VFO_MEM) == RIG_VFO_MEM))
|| (caps->vfo_op || (caps->vfo_op
&& rig_has_vfo_op(rig, RIG_OP_TO_VFO | RIG_OP_FROM_VFO))); && rig_has_vfo_op(rig, RIG_OP_TO_VFO | RIG_OP_FROM_VFO)));

Wyświetl plik

@ -141,9 +141,9 @@ int dumpcaps_rot(ROT *rot, FILE *fout)
"Post write delay:\t%dms\n", "Post write delay:\t%dms\n",
caps->post_write_delay); caps->post_write_delay);
if (rot->state.has_status != 0) if (ROTSTATE(rot)->has_status != 0)
{ {
rot_sprintf_status(prntbuf, sizeof(prntbuf), rot->state.has_status); rot_sprintf_status(prntbuf, sizeof(prntbuf), ROTSTATE(rot)->has_status);
} }
else else
{ {

Wyświetl plik

@ -281,6 +281,7 @@ int main(int argc, char *argv[])
int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */ int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
int i; int i;
extern int is_rigctld; extern int is_rigctld;
struct rig_state *rs;
is_rigctld = 1; is_rigctld = 1;
@ -689,12 +690,13 @@ int main(int argc, char *argv[])
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1); strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
} }
my_rig->state.twiddle_timeout = twiddle_timeout; rs = STATE(my_rig);
my_rig->state.twiddle_rit = twiddle_rit; rs->twiddle_timeout = twiddle_timeout;
my_rig->state.uplink = uplink; rs->twiddle_rit = twiddle_rit;
rs->uplink = uplink;
rig_debug(RIG_DEBUG_TRACE, "%s: twiddle=%d, uplink=%d, twiddle_rit=%d\n", rig_debug(RIG_DEBUG_TRACE, "%s: twiddle=%d, uplink=%d, twiddle_rit=%d\n",
__func__, __func__,
my_rig->state.twiddle_timeout, my_rig->state.uplink, my_rig->state.twiddle_rit); rs->twiddle_timeout, rs->uplink, rs->twiddle_rit);
/* /*
* ex: RIG_PTT_PARALLEL and /dev/parport0 * ex: RIG_PTT_PARALLEL and /dev/parport0
@ -702,29 +704,29 @@ int main(int argc, char *argv[])
if (ptt_type != RIG_PTT_NONE) if (ptt_type != RIG_PTT_NONE)
{ {
PTTPORT(my_rig)->type.ptt = ptt_type; PTTPORT(my_rig)->type.ptt = ptt_type;
my_rig->state.pttport_deprecated.type.ptt = ptt_type; rs->pttport_deprecated.type.ptt = ptt_type;
// This causes segfault since backend rig_caps are const // This causes segfault since backend rig_caps are const
// rigctld will use the rig->state version of this for clients // rigctld will use the STATE(rig) version of this for clients
//my_rig->caps->ptt_type = ptt_type; //my_rig->caps->ptt_type = ptt_type;
} }
if (dcd_type != RIG_DCD_NONE) if (dcd_type != RIG_DCD_NONE)
{ {
DCDPORT(my_rig)->type.dcd = dcd_type; DCDPORT(my_rig)->type.dcd = dcd_type;
my_rig->state.dcdport_deprecated.type.dcd = dcd_type; rs->dcdport_deprecated.type.dcd = dcd_type;
} }
if (ptt_file) if (ptt_file)
{ {
strncpy(PTTPORT(my_rig)->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, strncpy(rs->pttport_deprecated.pathname, ptt_file,
HAMLIB_FILPATHLEN - 1); HAMLIB_FILPATHLEN - 1);
} }
if (dcd_file) if (dcd_file)
{ {
strncpy(DCDPORT(my_rig)->pathname, dcd_file, HAMLIB_FILPATHLEN - 1); strncpy(DCDPORT(my_rig)->pathname, dcd_file, HAMLIB_FILPATHLEN - 1);
strncpy(my_rig->state.dcdport_deprecated.pathname, dcd_file, strncpy(rs->dcdport_deprecated.pathname, dcd_file,
HAMLIB_FILPATHLEN - 1); HAMLIB_FILPATHLEN - 1);
} }
@ -732,7 +734,7 @@ int main(int argc, char *argv[])
if (serial_rate != 0) if (serial_rate != 0)
{ {
RIGPORT(my_rig)->parm.serial.rate = serial_rate; RIGPORT(my_rig)->parm.serial.rate = serial_rate;
my_rig->state.rigport_deprecated.parm.serial.rate = serial_rate; rs->rigport_deprecated.parm.serial.rate = serial_rate;
} }
if (civaddr) if (civaddr)
@ -1229,7 +1231,7 @@ void *handle_socket(void *arg)
mutex_rigctld(1); mutex_rigctld(1);
rig_get_powerstat(my_rig, &rig_powerstat); rig_get_powerstat(my_rig, &rig_powerstat);
mutex_rigctld(0); mutex_rigctld(0);
my_rig->state.powerstat = rig_powerstat; STATE(my_rig)->powerstat = rig_powerstat;
} }
do do

Wyświetl plik

@ -365,24 +365,24 @@ int main(int argc, char *argv[])
step = atof(argv[optind]) * 1e6; step = atof(argv[optind]) * 1e6;
} }
fprintf(stderr, "Setting rotator to azimuth %.1f°\n", rot->state.min_az); fprintf(stderr, "Setting rotator to azimuth %.1f°\n", ROTSTATE(rot)->min_az);
rot_set_position(rot, rot->state.min_az, 0); rot_set_position(rot, ROTSTATE(rot)->min_az, 0);
fprintf(stderr, "Wait for rotator to move...\n"); fprintf(stderr, "Wait for rotator to move...\n");
rot_get_position(rot, &azimuth, &elevation); rot_get_position(rot, &azimuth, &elevation);
while (fabs(azimuth - rot->state.min_az) > 1.) while (fabs(azimuth - ROTSTATE(rot)->min_az) > 1.)
{ {
rot_get_position(rot, &azimuth, &elevation); rot_get_position(rot, &azimuth, &elevation);
hl_usleep(step); hl_usleep(step);
} }
fprintf(stderr, "Now initiating full 360° rotation...\n"); fprintf(stderr, "Now initiating full 360° rotation...\n");
rot_set_position(rot, rot->state.max_az, 0); rot_set_position(rot, ROTSTATE(rot)->max_az, 0);
/* TODO: check CW or CCW */ /* TODO: check CW or CCW */
/* disable AGC? */ /* disable AGC? */
while (fabs(rot->state.max_az - azimuth) > 1.) while (fabs(ROTSTATE(rot)->max_az - azimuth) > 1.)
{ {
value_t strength; value_t strength;

Wyświetl plik

@ -34,8 +34,8 @@ int main(int argc, const char *argv[])
// disabled until we change this to the other multicast capability // disabled until we change this to the other multicast capability
#if 0 #if 0
multicast_init(rig, "224.0.0.1", 4532); multicast_init(rig, "224.0.0.1", 4532);
printf("threadid=%lld\n", (long long)rig->state.multicast->threadid); printf("threadid=%lld\n", (long long)STATE(rig)->multicast->threadid);
pthread_join(rig->state.multicast->threadid, NULL); pthread_join(STATE(rig)->multicast->threadid, NULL);
pthread_exit(NULL); pthread_exit(NULL);
#endif #endif
return 0; return 0;