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