8 void dowrite(char *s, int len)
17 int waitchar(int timeout)
23 return poll(&pfd, 1, timeout) == 1;
26 int expect(char *s, int len)
30 for (i=0; i < len; i++)
32 if (waitchar(1000) == 0)
34 fprintf(stderr, "Timeout reached in expect (expected %c)\n", s[i]);
37 while (read(0, &c, 1) == 0)
38 fprintf(stderr, "Short read...\n");
41 fprintf(stderr, "Expect failed: expected %d, got %d (pos %d)\n", s[i], c, i);
48 void expect_no_chars()
52 while (waitchar(100) == 1)
55 if (read(0, &c, 1) == 0)
56 fprintf(stderr, "enc Short read...\n");
58 fprintf(stderr, "Warning: expected no chars, got %d\n", c);
61 fprintf(stderr, "Expect no chars failed: got %d chars\n", cs);
64 void main(int argc, char **argv)
66 unsigned char buf[259];
73 fprintf(stderr, "Usage: %s [filename]\n", argv[0]);
76 rfd = open(argv[1], O_RDONLY);
83 dowrite("\x1B" "A\x00\x00\x00", 5);
84 fprintf(stderr, "Address sent\n");
87 while ((sz = read(rfd, buf+3, 255)) > 0)
96 fprintf(stderr, "Data sent (%d)\n", tc);
101 printf("Failure to ack... retrying\n");
103 rv = expect("...", 3);