MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / ars_set_position_sync

Function ars_set_position_sync

rotators/ars/ars.c:451–569  ·  view source on GitHub ↗

* ars_set_position_sync() is synchronous. * See handle_set_position_async() for asynchronous thread handler, * with wait loop in background */

Source from the content-addressed store, hash-verified

449 * with wait loop in background
450 */
451int
452ars_set_position_sync(ROT *rot, azimuth_t az, elevation_t el)
453{
454 azimuth_t curr_az, prev_az;
455 elevation_t curr_el, prev_el;
456 int retval;
457 int az_move, el_move;
458 struct timeval last_pos_az_tv, last_pos_el_tv;
459
460 rig_debug(RIG_DEBUG_TRACE, "%s called: %.1f %.1f\n", __func__, az, el);
461
462 ars_stop(rot);
463
464 retval = ars_get_position(rot, &curr_az, &curr_el);
465
466 if (retval != RIG_OK)
467 {
468 return retval;
469 }
470
471 /* watchdog init */
472 prev_az = curr_az;
473 prev_el = curr_el;
474 gettimeofday(&last_pos_az_tv, NULL);
475 last_pos_el_tv = last_pos_az_tv;
476
477 while (!angle_in_range(curr_az, az, AZ_RANGE) ||
478 (ars_has_el(rot) && !angle_in_range(curr_el, el, EL_RANGE))
479 )
480 {
481
482 if (curr_az < (az - AZ_RANGE))
483 {
484 az_move = ROT_MOVE_RIGHT;
485 }
486 else if (curr_az > (az + AZ_RANGE))
487 {
488 az_move = ROT_MOVE_LEFT;
489 }
490 else
491 {
492 az_move = 0;
493 }
494
495 if (ars_has_el(rot))
496 {
497 if (curr_el < (el - EL_RANGE))
498 {
499 el_move = ROT_MOVE_UP;
500 }
501 else if (curr_el > (el + EL_RANGE))
502 {
503 el_move = ROT_MOVE_DOWN;
504 }
505 else
506 {
507 el_move = 0;
508 }

Callers 1

handle_set_positionFunction · 0.85

Calls 9

rig_debugFunction · 0.85
ars_stopFunction · 0.85
ars_get_positionFunction · 0.85
gettimeofdayFunction · 0.85
angle_in_rangeFunction · 0.85
ars_has_elFunction · 0.85
ars_moveFunction · 0.85
hl_usleepFunction · 0.85
rig_check_cache_timeoutFunction · 0.85

Tested by

no test coverage detected