Initial commit - from Precise source
[freerdp-ubuntu-pcb-backport.git] / channels / rdpdr / serial / serial_tty.h
1 /**
2  * FreeRDP: A Remote Desktop Protocol client.
3  * Serial Port Device Service Virtual Channel
4  *
5  * Copyright 2011 O.S. Systems Software Ltda.
6  * Copyright 2011 Eduardo Fiss Beloni <beloni@ossystems.com.br>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #ifndef __SERIAL_TTY_H
22 #define __SERIAL_TTY_H
23
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <dirent.h>
27
28 typedef struct _SERIAL_TTY SERIAL_TTY;
29 struct _SERIAL_TTY
30 {
31         uint32 id;
32         int fd;
33
34         int dtr;
35         int rts;
36         uint32 control;
37         uint32 xonoff;
38         uint32 onlimit;
39         uint32 offlimit;
40         uint32 baud_rate;
41         uint32 queue_in_size;
42         uint32 queue_out_size;
43         uint32 wait_mask;
44         uint32 read_interval_timeout;
45         uint32 read_total_timeout_multiplier;
46         uint32 read_total_timeout_constant;
47         uint32 write_total_timeout_multiplier;
48         uint32 write_total_timeout_constant;
49         uint8 stop_bits;
50         uint8 parity;
51         uint8 word_length;
52         uint8 chars[6];
53         struct termios* ptermios;
54         struct termios* pold_termios;
55         int event_txempty;
56         int event_cts;
57         int event_dsr;
58         int event_rlsd;
59         int event_pending;
60 };
61
62
63 SERIAL_TTY* serial_tty_new(const char* path, uint32 id);
64 void serial_tty_free(SERIAL_TTY* tty);
65
66 boolean serial_tty_read(SERIAL_TTY* tty, uint8* buffer, uint32* Length);
67 boolean serial_tty_write(SERIAL_TTY* tty, uint8* buffer, uint32 Length);
68 uint32 serial_tty_control(SERIAL_TTY* tty, uint32 IoControlCode, STREAM* input, STREAM* output, uint32* abort_io);
69
70 boolean serial_tty_get_event(SERIAL_TTY* tty, uint32* result);
71
72 #endif /* __SERIAL_TTY_H */