[go: up one dir, main page]

File: libaltos.h

package info (click to toggle)
altos 1.9-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 67,272 kB
  • sloc: ansic: 90,607; java: 39,048; makefile: 6,591; sh: 3,008; xml: 1,972; pascal: 1,597
file content (123 lines) | stat: -rw-r--r-- 2,849 bytes parent folder | download | duplicates (3)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * Copyright © 2010 Keith Packard <keithp@keithp.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 */

#ifndef _LIBALTOS_H_
#define _LIBALTOS_H_

#include <stdlib.h>

#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# ifndef BUILD_STATIC
#  ifdef BUILD_DLL
#   define PUBLIC __declspec(dllexport)
#  else
#   define PUBLIC __declspec(dllimport)
#  endif
# endif /* BUILD_STATIC */
#endif

#ifndef PUBLIC
# define PUBLIC
#endif

struct altos_device {
	//%immutable;
	int				vendor;
	int				product;
	int				serial;
	char				name[256];
	char				path[256];
	//%mutable;
};

struct altos_bt_device {
	//%immutable;
	char				name[256];
	char				addr[20];
	//%mutable;
};

struct altos_error {
	int				code;
	char				string[1024];
};

#define LIBALTOS_SUCCESS	0
#define LIBALTOS_ERROR		-1
#define LIBALTOS_TIMEOUT	-2

/* Returns 0 for success, < 0 on error */
PUBLIC int
altos_init(void);

PUBLIC void
altos_fini(void);

PUBLIC void
altos_get_last_error(struct altos_error *error);

PUBLIC struct altos_list *
altos_list_start(void);

PUBLIC struct altos_list *
altos_ftdi_list_start(void);

/* Returns 1 for success, zero on end of list */
PUBLIC int
altos_list_next(struct altos_list *list, struct altos_device *device);

PUBLIC void
altos_list_finish(struct altos_list *list);

PUBLIC struct altos_file *
altos_open(struct altos_device *device);

PUBLIC void
altos_close(struct altos_file *file);

PUBLIC void
altos_free(struct altos_file *file);

/* Returns < 0 for error */
PUBLIC int
altos_putchar(struct altos_file *file, char c);

/* Returns < 0 for error */
PUBLIC int
altos_flush(struct altos_file *file);

/* Returns < 0 for error or timeout. timeout of 0 == wait forever */
PUBLIC int
altos_getchar(struct altos_file *file, int timeout);

PUBLIC struct altos_bt_list *
altos_bt_list_start(int inquiry_time);

PUBLIC int
altos_bt_list_next(struct altos_bt_list *list, struct altos_bt_device *device);

PUBLIC void
altos_bt_list_finish(struct altos_bt_list *list);

PUBLIC void
altos_bt_fill_in(char *name, char *addr, struct altos_bt_device *device);

PUBLIC struct altos_file *
altos_bt_open(struct altos_bt_device *device);

#endif /* _LIBALTOS_H_ */