1 | /*
|
---|
2 | io_serial.h
|
---|
3 | Serial port input/output definitions
|
---|
4 |
|
---|
5 | This file is part of the Unix driver for Towitoko smartcard readers
|
---|
6 | Copyright (C) 2000 Carlos Prados <cprados@yahoo.com>
|
---|
7 |
|
---|
8 | This version is modified by doz21 to work in a special manner ;)
|
---|
9 |
|
---|
10 | This library is free software; you can redistribute it and/or
|
---|
11 | modify it under the terms of the GNU Lesser General Public
|
---|
12 | License as published by the Free Software Foundation; either
|
---|
13 | version 2 of the License, or (at your option) any later version.
|
---|
14 |
|
---|
15 | This library is distributed in the hope that it will be useful,
|
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
18 | Lesser General Public License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU Lesser General Public
|
---|
21 | License along with this library; if not, write to the Free Software
|
---|
22 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef _IO_SERIAL_
|
---|
26 | #define _IO_SERIAL_
|
---|
27 |
|
---|
28 | #include <termios.h>
|
---|
29 |
|
---|
30 | #define IO_Serial_DTR_Set(reader) IO_Serial_DTR_RTS(reader, 1, 1)
|
---|
31 | #define IO_Serial_DTR_Clr(reader) IO_Serial_DTR_RTS(reader, 1, 0)
|
---|
32 | #define IO_Serial_RTS_Set(reader) IO_Serial_DTR_RTS(reader, 0, 1)
|
---|
33 | #define IO_Serial_RTS_Clr(reader) IO_Serial_DTR_RTS(reader, 0, 0)
|
---|
34 |
|
---|
35 | //Type of parity of the serial device
|
---|
36 | //Chosen to Smartreader definition
|
---|
37 | //Since for io_serial it doesnt matter which values we choose
|
---|
38 | #ifdef OS_CYGWIN32
|
---|
39 | #undef PARITY_NONE
|
---|
40 | #undef PARITY_ODD
|
---|
41 | #undef PARITY_EVEN
|
---|
42 | #undef PARITY_MARK
|
---|
43 | #undef PARITY_SPACE
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | #define PARITY_NONE 0
|
---|
47 | #define PARITY_ODD 1
|
---|
48 | #define PARITY_EVEN 2
|
---|
49 | #define PARITY_MARK 3
|
---|
50 | #define PARITY_SPACE 4
|
---|
51 | /* Values for the modem lines */
|
---|
52 | #define IO_SERIAL_HIGH 1
|
---|
53 | #define IO_SERIAL_LOW 0
|
---|
54 |
|
---|
55 | /* Maximum size of PnP Com ID */
|
---|
56 | #define IO_SERIAL_PNPID_SIZE 256
|
---|
57 |
|
---|
58 | /*
|
---|
59 | * Exported functions declaration
|
---|
60 | */
|
---|
61 |
|
---|
62 | /* IO_Serial creation and deletion */
|
---|
63 | void IO_Serial_Flush (struct s_reader * reader);
|
---|
64 |
|
---|
65 | /* Initialization and closing */
|
---|
66 | bool IO_Serial_InitPnP (struct s_reader * reader);
|
---|
67 | bool IO_Serial_Close (struct s_reader * reader);
|
---|
68 |
|
---|
69 | /* Transmission properties */
|
---|
70 | bool IO_Serial_DTR_RTS(struct s_reader * reader, int, int);
|
---|
71 | #if defined(TUXBOX) && defined(PPC)
|
---|
72 | void IO_Serial_Ioctl_Lock(struct s_reader * reader, int);
|
---|
73 | #else
|
---|
74 | #define IO_Serial_Ioctl_Lock(a,b) {} //FIXME ugly !!
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | bool IO_Serial_SetBitrate (struct s_reader * reader, unsigned long bitrate, struct termios * tio);
|
---|
78 | bool IO_Serial_SetParams (struct s_reader * reader, unsigned long bitrate, unsigned bits, int parity, unsigned stopbits, int dtr, int rts);
|
---|
79 | bool IO_Serial_SetProperties (struct s_reader * reader, struct termios newtio);
|
---|
80 | int IO_Serial_SetParity (struct s_reader * reader, BYTE parity);
|
---|
81 |
|
---|
82 | /* Input and output */
|
---|
83 | bool IO_Serial_Read (struct s_reader * reader, unsigned timeout, unsigned size, BYTE * data);
|
---|
84 | bool IO_Serial_Write (struct s_reader * reader, unsigned delay, unsigned size, BYTE * data);
|
---|
85 |
|
---|
86 | #endif /* IO_SERIAL */
|
---|