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

Function rotorez_thread

simulators/simeasycomm.c:106–162  ·  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 (sscanf(buf, "AZ%g EL%g", &az, &el) == 2)
128 {
129 //n = write(fd, buf, strlen(buf));
130 printf("n=%d fd=%d\n", n, fd);
131 }
132 else if (strcmp(buf,"AZ")==0)
133 {
134 sprintf(buf,"AZ%.1f\n", az);
135 n = write(fd, buf, strlen(buf));
136 }
137 else if (strcmp(buf,"EL")==0)
138 {
139 sprintf(buf,"EL%.1f\n", el);
140 n = write(fd, buf, strlen(buf));
141 }
142 else
143 {
144 printf("Unknown cmd=%s\n", buf);
145 }
146
147#if 0
148
149 switch (buf[0])
150 {
151 case '?': printf("Query %c\n", buf[1]); break;
152
153 case '*': printf("Set %c\n", buf[1]); break;
154
155 default: printf("Unknown cmd=%02x\n", buf[4]);
156 }
157
158#endif
159 }
160
161 pthread_exit(NULL);
162}

Callers

nothing calls this directly

Calls 3

hl_usleepFunction · 0.85
pthread_exitFunction · 0.85
_getmylineFunction · 0.70

Tested by

no test coverage detected