kopia lustrzana https://github.com/Hamlib/Hamlib
only trigger set_pos thread handler on demand
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2923 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.11
rodzic
b32720c6fb
commit
f8de70f0b3
26
ars/ars.c
26
ars/ars.c
|
@ -192,11 +192,6 @@ ars_open(ROT *rot)
|
|||
pthread_attr_t attr;
|
||||
int retcode;
|
||||
|
||||
/* make handle_set_position() quiet at startup */
|
||||
retcode = ars_get_position(rot, &priv->target_az, &priv->target_el);
|
||||
if (retcode != RIG_OK)
|
||||
return retcode;
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
|
||||
|
@ -236,6 +231,10 @@ ars_stop(ROT *rot)
|
|||
rig_debug(RIG_DEBUG_TRACE, "%s called, brake was %s\n", __func__,
|
||||
priv->brake_off ? "OFF" : "ON");
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
priv->set_pos_active = 0;
|
||||
#endif
|
||||
|
||||
par_lock (pport);
|
||||
|
||||
priv->brake_off = 0;
|
||||
|
@ -392,29 +391,19 @@ static void *handle_set_position(void *arg)
|
|||
{
|
||||
ROT *rot = (ROT*) arg;
|
||||
struct ars_priv_data *priv = (struct ars_priv_data *)rot->state.priv;
|
||||
azimuth_t curr_az;
|
||||
elevation_t curr_el;
|
||||
int retcode;
|
||||
|
||||
while (1) {
|
||||
|
||||
retcode = ars_get_position(rot, &curr_az, &curr_el);
|
||||
if (retcode != RIG_OK) {
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: ars_get_position() failed: %s\n",
|
||||
__func__, rigerror(retcode));
|
||||
usleep(1000*1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (angle_in_range(curr_az, priv->target_az, AZ_RANGE) &&
|
||||
(!ars_has_el(rot) || angle_in_range(curr_el, priv->target_el, EL_RANGE)))
|
||||
if (!priv->set_pos_active)
|
||||
{
|
||||
/* polling period */
|
||||
/* TODO: replace polling period by cond var */
|
||||
usleep(100*1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
retcode = ars_set_position_sync(rot, priv->target_az, priv->target_el);
|
||||
priv->set_pos_active = 0;
|
||||
if (retcode != RIG_OK) {
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: ars_set_position_sync() failed: %s\n",
|
||||
__func__, rigerror(retcode));
|
||||
|
@ -529,6 +518,7 @@ ars_set_position(ROT *rot, azimuth_t az, elevation_t el)
|
|||
/* will be picked by handle_set_position() next polling tick */
|
||||
priv->target_az = az;
|
||||
priv->target_el = el;
|
||||
priv->set_pos_active = 1;
|
||||
|
||||
return RIG_OK;
|
||||
#else
|
||||
|
|
|
@ -32,6 +32,7 @@ struct ars_priv_data {
|
|||
unsigned char pp_data;
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_t thread;
|
||||
int set_pos_active;
|
||||
azimuth_t target_az;
|
||||
elevation_t target_el;
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue