-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrotator.c
64 lines (54 loc) · 1.44 KB
/
rotator.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* @file
* Rotator controller for Hamlib.
*/
#include <assert.h>
#include <hamlib/rotator.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "main.h"
#include "rotator.h"
static ROT *rot;
/**
* Initialize and open rotator interface. This function exits on error.
*/
void rotator_open() {
rig_set_debug(RIG_DEBUG_WARN);
assert(config.rot_model != 0);
rot = rot_init(config.rot_model);
if (rot == NULL) {
fprintf(stderr, "Unknown rotator model!\n");
exit(EXIT_FAILURE);
}
if (config.rot_file != NULL) {
strlcpy(rot->state.rotport.pathname, config.rot_file, FILPATHLEN);
}
if (rot_open(rot) != RIG_OK) {
fprintf(stderr, "Could not open rotator!\n");
exit(EXIT_FAILURE);
}
}
/**
* Get the current position of the rotator interface. On failure, the output
* variables are set to zero and thus become invalid.
* @return True if successful, false otherwise.
*/
bool rotator_get_position(float *azimuth, float *elevation) {
return rot_get_position(rot, azimuth, elevation) == RIG_OK;
}
/**
* Set the current position of the rotator interface.
* @return True if successful, false otherwise.
*/
bool rotator_set_position(float azimuth, float elevation) {
return rot_set_position(rot, azimuth, elevation) == RIG_OK;
}
/**
* Close and destroy rotator interface.
*/
void rotator_close() {
rot_close(rot);
rot_cleanup(rot);
}