File: skyeye_uart.h

package info (click to toggle)
skyeye 1.2.5-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,236 kB
  • ctags: 19,345
  • sloc: ansic: 90,379; sh: 5,188; python: 707; cpp: 417; makefile: 322; exp: 38
file content (93 lines) | stat: -rw-r--r-- 3,562 bytes parent folder | download | duplicates (4)
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
/*
	skyeye_uart.h - skyeye uart device support functions
	Copyright (C) 2003 - 2007 Skyeye Develop Group
	for help please send mail to <skyeye-developer@lists.gro.clinux.org>

	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 __SKYEYE_UART_H_
#define __SKYEYE_UART_H_

#include <sys/time.h>

#include "skyeye_device.h"
#include "skyeye_config.h"

/* uart simulation type */
#define UART_SIM_STDIO		0	/* use stdin and stdout as fd */
#define UART_SIM_PIPE		1	/* use file (pipe file) or device(/dev/ttyS1) as fd */
#define UART_SIM_NET		2	/* use tcp port as fd */

struct uart_device {
	int mod;

	char desc_in[MAX_STR_NAME];	/* description of device, such as path etc. */
	char desc_out[MAX_STR_NAME];	/* description of device, such as path etc. */

	/* private data. */
	void *priv;

	int (*uart_open)(struct uart_device *uart_dev);
	int (*uart_close)(struct uart_device *uart_dev);
	int (*uart_read)(struct uart_device *uart_dev, void *buf, size_t count, struct timeval *timeout);
	int (*uart_write)(struct uart_device *uart_dev, void *buf, size_t count);

	char converter[MAX_STR_NAME];
	void *converter_priv; /* converter private data. */
};

void skyeye_uart_cleanup();
int skyeye_uart_setup(struct uart_option *uart_opt);


/* converter */
void skyeye_uart_converter_setup(void);
void skyeye_uart_converter_dcc_setup(struct uart_device *uart_dev);


/* modules */
int uart_stdio_open(struct uart_device *uart_dev);
int uart_stdio_close(struct uart_device *uart_dev);
int uart_stdio_read(struct uart_device *uart_dev, void *buf, size_t count, struct timeval *timeout);
int uart_stdio_write(struct uart_device *uart_dev, void *buf, size_t count);

int uart_pipe_open(struct uart_device *uart_dev);
int uart_pipe_close(struct uart_device *uart_dev);
int uart_pipe_read(struct uart_device *uart_dev, void *buf, size_t count, struct timeval *timeout);
int uart_pipe_write(struct uart_device *uart_dev, void *buf, size_t count);

int uart_net_open(struct uart_device *uart_dev);
int uart_net_close(struct uart_device *uart_dev);
int uart_net_read(struct uart_device *uart_dev, void *buf, size_t count, struct timeval *timeout);
int uart_net_write(struct uart_device *uart_dev, void *buf, size_t count);


/* helper functions */

/* skyeye_uart_read(), skyeye_uart_write():
 * devIndex:
 * 	>= 0	---	the index of device
 * 	< 0	---	all devices, skyeye_uart_write() return the maximum bytes of the actions
 * retDevIndex:
 * 	if you don't pass NULL to it, skyeye_uart_read() replace the value of it be the index of device that got something.
 * wroteBytes:
 * 	if you don't pass NULL to it, skyeye_uart_write() replace the value of it be the bytes of each action of devices.
 */
int skyeye_uart_read(int devIndex, void *buf, size_t count, struct timeval *timeout, int *retDevIndex);
int skyeye_uart_write(int devIndex, void *buf, size_t count, int *wroteBytes[MAX_UART_DEVICE_NUM]);

#endif	/* __SKYEYE_UART_H_ */