diff options
author | Bdale Garbee <bdale@gag.com> | 2013-05-16 00:36:23 -0600 |
---|---|---|
committer | Bdale Garbee <bdale@gag.com> | 2013-05-16 00:36:23 -0600 |
commit | 02d111b1b53ef01fc6e9ab6c4bc60b8af1be0067 (patch) | |
tree | 8356f4a019969ee99a45e264c87d38555cf316cc /libaltos/cjnitest.c | |
parent | 7a2e1f05adad990a6b161865267abf07ffec7a7e (diff) | |
parent | 7699a55aed3a9a7daeb4c6a5a9a280f43edf455f (diff) |
Merge branch 'branch-1.2' into debian
Diffstat (limited to 'libaltos/cjnitest.c')
-rw-r--r-- | libaltos/cjnitest.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/libaltos/cjnitest.c b/libaltos/cjnitest.c new file mode 100644 index 00000000..f0fe78f7 --- /dev/null +++ b/libaltos/cjnitest.c @@ -0,0 +1,71 @@ +#include <stdio.h> +#include "libaltos.h" + +static void +altos_puts(struct altos_file *file, char *string) +{ + char c; + + while ((c = *string++)) + altos_putchar(file, c); +} + +main () +{ + struct altos_device device; + struct altos_list *list; + struct altos_bt_device bt_device; + struct altos_bt_list *bt_list; + + altos_init(); + list = altos_list_start(); + while (altos_list_next(list, &device)) { + struct altos_file *file; + int c; + + printf ("%04x:%04x %-20s %4d %s\n", device.vendor, device.product, + device.name, device.serial, device.path); + + file = altos_open(&device); + if (!file) { + printf("altos_open failed\n"); + continue; + } + altos_puts(file,"v\nc s\n"); + altos_flush(file); + while ((c = altos_getchar(file, 100)) >= 0) { + putchar (c); + } + if (c != LIBALTOS_TIMEOUT) + printf ("getchar returns %d\n", c); + altos_close(file); + } + altos_list_finish(list); +#if HAS_BLUETOOTH + bt_list = altos_bt_list_start(8); + while (altos_bt_list_next(bt_list, &bt_device)) { + printf ("%s %s\n", bt_device.name, bt_device.addr); + if (strncmp(bt_device.name, "TeleBT", 6) == 0) { + struct altos_file *file; + + int c; + file = altos_bt_open(&bt_device); + if (!file) { + printf("altos_bt_open failed\n"); + continue; + } + altos_puts(file,"v\nc s\n"); + altos_flush(file); + while ((c = altos_getchar(file, 100)) >= 0) { + putchar(c); + } + if (c != LIBALTOS_TIMEOUT) + printf("getchar returns %d\n", c); + altos_close(file); + } + } + altos_bt_list_finish(bt_list); +#endif + altos_fini(); + return 0; +} |