| 28 | |
| 29 | |
| 30 | int main(int argc, char *argv[]) |
| 31 | { |
| 32 | char buf[BUFSIZE]; |
| 33 | char *pbuf; |
| 34 | int n; |
| 35 | int fd = openPort(argv[1]); |
| 36 | |
| 37 | while (1) |
| 38 | { |
| 39 | if (getmyline(fd, buf)) |
| 40 | { |
| 41 | printf("Cmd:%s\n", buf); |
| 42 | } |
| 43 | else { continue; } |
| 44 | |
| 45 | if (strcmp(buf, "RM5;") == 0) |
| 46 | { |
| 47 | printf("%s\n", buf); |
| 48 | hl_usleep(50 * 1000); |
| 49 | pbuf = "RM5100000;"; |
| 50 | n = write(fd, pbuf, strlen(pbuf)); |
| 51 | printf("n=%d\n", n); |
| 52 | |
| 53 | if (n <= 0) { perror("RM5"); } |
| 54 | } |
| 55 | |
| 56 | if (strcmp(buf, "AN0;") == 0) |
| 57 | { |
| 58 | printf("%s\n", buf); |
| 59 | hl_usleep(50 * 1000); |
| 60 | pbuf = "AN030;"; |
| 61 | n = write(fd, pbuf, strlen(pbuf)); |
| 62 | printf("n=%d\n", n); |
| 63 | |
| 64 | if (n <= 0) { perror("AN"); } |
| 65 | } |
| 66 | else if (strcmp(buf, "IF;") == 0) |
| 67 | { |
| 68 | printf("%s\n", buf); |
| 69 | hl_usleep(50 * 1000); |
| 70 | pbuf = "IF059014200000+000000700000;"; |
| 71 | n = write(fd, pbuf, strlen(pbuf)); |
| 72 | printf("n=%d\n", n); |
| 73 | |
| 74 | if (n <= 0) { perror("IF"); } |
| 75 | } |
| 76 | else if (strcmp(buf, "ID;") == 0) |
| 77 | { |
| 78 | printf("%s\n", buf); |
| 79 | hl_usleep(50 * 1000); |
| 80 | int id = NC_RIGID_FTDX3000; |
| 81 | SNPRINTF(buf, sizeof(buf), "ID%03d;", id); |
| 82 | n = write(fd, buf, strlen(buf)); |
| 83 | printf("n=%d\n", n); |
| 84 | |
| 85 | if (n <= 0) { perror("ID"); } |
| 86 | } |
| 87 | else if (strcmp(buf, "EX032;") == 0) |