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

Function main

simulators/simft818.c:27–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26
27int main(int argc, char *argv[])
28{
29 char buf[BUFSIZE];
30 char resp[256];
31 char *pbuf;
32 int n;
33 int fd = openPort(argv[1]);
34
35 while (1)
36 {
37 buf[0] = 0;
38
39 if (getmyline(fd, buf))
40 {
41 printf("Cmd:%s\n", buf);
42 }
43
44 //else { return 0; }
45
46 if (strcmp(buf, "RM5;") == 0)
47 {
48 printf("%s\n", buf);
49 hl_usleep(50 * 1000);
50 pbuf = "RM5100000;";
51 n = write(fd, pbuf, strlen(pbuf));
52 printf("n=%d\n", n);
53
54 if (n <= 0) { perror("RM5"); }
55 }
56
57 if (strcmp(buf, "AN0;") == 0)
58 {
59 printf("%s\n", buf);
60 hl_usleep(50 * 1000);
61 pbuf = "AN030;";
62 n = write(fd, pbuf, strlen(pbuf));
63 printf("n=%d\n", n);
64
65 if (n <= 0) { perror("AN"); }
66 }
67 else if (strcmp(buf, "FA;") == 0)
68 {
69 //SNPRINTF(resp, sizeof(resp), "FA%010.0f;", freqA);
70 SNPRINTF(resp, sizeof(resp), "FA%08.0f;", freqA);
71 freqA += 10;
72 n = write(fd, resp, strlen(resp));
73 }
74 else if (strncmp(buf, "FA", 2) == 0)
75 {
76 sscanf(buf, "FA%f", &freqA);
77 }
78 else if (strcmp(buf, "FB;") == 0)
79 {
80 //SNPRINTF(resp, sizeof(resp), "FB%0010.0f;", freqB);
81 SNPRINTF(resp, sizeof(resp), "FB%08.0f;", freqB);
82 n = write(fd, resp, strlen(resp));
83 }
84 else if (strncmp(buf, "FB", 2) == 0)

Callers

nothing calls this directly

Calls 3

openPortFunction · 0.85
getmylineFunction · 0.85
hl_usleepFunction · 0.85

Tested by

no test coverage detected