8 void dowrite(char *s, int len)
17 int waitchar(int timeout)
23 return poll(&pfd, 1, timeout) == 1;
26 void expect(char *s, int len)
30 for (i=0; i < len; i++)
32 if (waitchar(100) == 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");
40 fprintf(stderr, "Expect failed: expected %d, got %d (pos %d)\n", s[i], c, i);
44 void expect_no_chars()
48 while (waitchar(10) == 1)
51 if (read(0, &c, 1) == 0)
52 fprintf(stderr, "enc Short read...\n");
54 fprintf(stderr, "Warning: expected no chars, got %d\n", c);
57 fprintf(stderr, "Expect no chars failed: got %d chars\n", cs);
62 void main(int argc, char **argv)
64 unsigned char buf[259];
70 fprintf(stderr, "Usage: %s [filename]\n", argv[0]);
73 rfd = open(argv[1], O_RDONLY);
80 dowrite("\x1B" "A\x00\x00\x00...", 8);
81 fprintf(stderr, "Address sent\n");
83 while ((sz = read(rfd, buf+3, 128)) > 0)
89 fprintf(stderr, "Data sent\n");