| 41 | int rigtime = 1230; |
| 42 | |
| 43 | int |
| 44 | frameGet(int fd, unsigned char *buf) |
| 45 | { |
| 46 | int i = 0, n; |
| 47 | memset(buf, 0, BUFSIZE); |
| 48 | unsigned char c; |
| 49 | |
| 50 | while (read(fd, &c, 1) > 0) |
| 51 | { |
| 52 | buf[i++] = c; |
| 53 | //printf("i=%d, c=0x%02x\n",i,c); |
| 54 | |
| 55 | if (c == 0xfd) |
| 56 | { |
| 57 | char mytime[256]; |
| 58 | date_strget(mytime, sizeof(mytime), 1); |
| 59 | printf("%s:", mytime); dumphex(buf, i); |
| 60 | // echo |
| 61 | n = write(fd, buf, i); |
| 62 | |
| 63 | if (n != i) { printf("%s: error on write: %s\n", __func__, strerror(errno)); } |
| 64 | |
| 65 | return i; |
| 66 | } |
| 67 | |
| 68 | if (i > 2 && c == 0xfe) |
| 69 | { |
| 70 | printf("Turning power on due to 0xfe string\n"); |
| 71 | powerstat = 1; |
| 72 | int j; |
| 73 | |
| 74 | for (j = i; j < 175; ++j) |
| 75 | { |
| 76 | if (read(fd, &c, 1) < 0) { break; } |
| 77 | } |
| 78 | |
| 79 | i = 0; |
| 80 | continue; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | printf("Error %s\n", strerror(errno)); |
| 85 | |
| 86 | return 0; |
| 87 | } |
| 88 | |
| 89 | void frameParse(int fd, unsigned char *frame, int len) |
| 90 | { |
no test coverage detected