| 43 | |
| 44 | |
| 45 | int main(int argc, char *argv[]) |
| 46 | { |
| 47 | int fd = openPort(argv[1]); |
| 48 | int fd2 = openPort(argv[2]); |
| 49 | pthread_t threads[2]; |
| 50 | thread_args[0] = fd; |
| 51 | thread_args[1] = fd2; |
| 52 | pthread_create(&threads[0], NULL, rotorez_thread, (void *)&thread_args[0]); |
| 53 | pthread_create(&threads[1], NULL, rotorez_thread, (void *)&thread_args[1]); |
| 54 | pthread_exit(NULL); |
| 55 | return 0; |
| 56 | /* |
| 57 | again: |
| 58 | int flag = 0; |
| 59 | |
| 60 | while (1) |
| 61 | { |
| 62 | int bytes; |
| 63 | if (!flag) bytes = _getmyline(fd, buf); |
| 64 | else bytes = _getmyline(fd2, buf); |
| 65 | flag = !flag; |
| 66 | |
| 67 | if (bytes == 0) |
| 68 | { |
| 69 | //close(fd); |
| 70 | printf("again\n"); |
| 71 | goto again; |
| 72 | } |
| 73 | printf("line=%s\n", buf); |
| 74 | |
| 75 | if (strncmp(buf,"BI1",3) == 0) |
| 76 | { |
| 77 | sprintf(buf,"%3.1f;", az); |
| 78 | n = write(flag?fd:fd2, buf, strlen(buf)); |
| 79 | printf("n=%d\n", n); |
| 80 | } |
| 81 | else if (strncmp(buf,"AP1",3) == 0) |
| 82 | { |
| 83 | sscanf(buf,"AP1%f", &az); |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | printf("Unknown cmd=%s\n", buf); |
| 88 | } |
| 89 | |
| 90 | #if 0 |
| 91 | switch (buf[0]) |
| 92 | { |
| 93 | case '?': printf("Query %c\n", buf[1]); break; |
| 94 | |
| 95 | case '*': printf("Set %c\n", buf[1]); break; |
| 96 | |
| 97 | default: printf("Unknown cmd=%02x\n", buf[4]); |
| 98 | } |
| 99 | #endif |
| 100 | } |
| 101 | |
| 102 | return 0; |
nothing calls this directly
no test coverage detected