[go: up one dir, main page]

File: cjnitest.c

package info (click to toggle)
altos 1.9.22-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,712 kB
  • sloc: ansic: 120,853; java: 42,921; makefile: 8,573; sh: 4,995; xml: 2,154; pascal: 2,008
file content (78 lines) | stat: -rw-r--r-- 1,634 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <stdio.h>
#include "libaltos.h"
#include <string.h>

#define HAS_BLUETOOTH 	1
#define HAS_USB		1

static void
altos_puts(struct altos_file *file, char *string)
{
	char	c;

	while ((c = *string++))
		altos_putchar(file, c);
}

int
main (int argc, char **argv)
{
	struct altos_device	device;
	struct altos_list	*list;
	struct altos_bt_device	bt_device;
	struct altos_bt_list	*bt_list;

	altos_init();
#if HAS_USB
	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);
#endif
#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;
}