93d1f3763cf13cae66c35686bf11c6e2d48f31e6
[fw/altos] / ao-tools / libaltos / cjnitest.c
1 #include <stdio.h>
2 #include "libaltos.h"
3
4 static void
5 altos_puts(struct altos_file *file, char *string)
6 {
7         char    c;
8
9         while ((c = *string++))
10                 altos_putchar(file, c);
11 }
12
13 main ()
14 {
15         struct altos_device     device;
16         struct altos_list       *list;
17
18         altos_init();
19         list = altos_list_start();
20         while (altos_list_next(list, &device)) {
21                 struct altos_file       *file;
22                 int                     c;
23
24                 printf ("%04x:%04x %-20s %4d %s\n", device.vendor, device.product,
25                         device.name, device.serial, device.path);
26
27                 file = altos_open(&device);
28                 if (!file) {
29                         printf("altos_open failed\n");
30                         continue;
31                 }
32                 altos_puts(file,"v\nc s\n");
33                 while ((c = altos_getchar(file, 100)) >= 0) {
34                         putchar (c);
35                 }
36                 if (c != LIBALTOS_TIMEOUT)
37                         printf ("getchar returns %d\n", c);
38                 altos_close(file);
39         }
40         altos_list_finish(list);
41         altos_fini();
42 }