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

Function rotorez_thread

simulators/simrotorez.c:106–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106static void *rotorez_thread(void *arg)
107{
108 int n = 0;
109 char buf[BUFSIZE];
110 int fd = *(int *)arg;
111 float az = 123;
112 float el = 45;
113
114 while (1)
115 {
116 int bytes;
117 bytes = _getmyline(fd, buf);
118
119 if (bytes == 0)
120 {
121 hl_usleep(100 * 1000);
122 continue;
123 }
124
125 printf("line[%d]=%s\n", fd, buf);
126
127 if (strncmp(buf, "BI1", 3) == 0)
128 {
129 if (fd == thread_args[0])
130 {
131 sprintf(buf, "%3.1f;", az);
132 printf("az=%f\n", az);
133 }
134 else
135 {
136 sprintf(buf, "%3.1f;", el);
137 printf("el=%f\n", el);
138 }
139
140 n = write(fd, buf, strlen(buf));
141 printf("n=%d fd=%d\n", n, fd);
142 }
143 else if (strncmp(buf, "AP1", 3) == 0)
144 {
145 if (fd == thread_args[0])
146 {
147 sscanf(buf, "AP1%f", &az);
148 }
149 else
150 {
151 sscanf(buf, "AP1%f", &el);
152 }
153 }
154 else
155 {
156 printf("Unknown cmd=%s\n", buf);
157 }
158
159#if 0
160
161 switch (buf[0])
162 {
163 case '?': printf("Query %c\n", buf[1]); break;

Callers

nothing calls this directly

Calls 3

hl_usleepFunction · 0.85
pthread_exitFunction · 0.85
_getmylineFunction · 0.70

Tested by

no test coverage detected