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 | #define IO_Serial_DTR_Set(reader) {int32_t _dtr = 1; IO_Serial_DTR_RTS(reader, &_dtr, NULL);}
|
---|
29 | #define IO_Serial_DTR_Clr(reader) {int32_t _dtr = 0; IO_Serial_DTR_RTS(reader, &_dtr, NULL);}
|
---|
30 | #define IO_Serial_RTS_Set(reader) {int32_t _rts = 1; IO_Serial_DTR_RTS(reader, NULL, &_rts);}
|
---|
31 | #define IO_Serial_RTS_Clr(reader) {int32_t _rts = 0; IO_Serial_DTR_RTS(reader, NULL, &_rts);}
|
---|
32 |
|
---|
33 | //Type of parity of the serial device
|
---|
34 | //Chosen to Smartreader definition
|
---|
35 | //Since for io_serial it doesnt matter which values we choose
|
---|
36 | #if defined(__CYGWIN__)
|
---|
37 | #undef PARITY_NONE
|
---|
38 | #undef PARITY_ODD
|
---|
39 | #undef PARITY_EVEN
|
---|
40 | #undef PARITY_MARK
|
---|
41 | #undef PARITY_SPACE
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #define PARITY_NONE 0
|
---|
45 | #define PARITY_ODD 1
|
---|
46 | #define PARITY_EVEN 2
|
---|
47 | #define PARITY_MARK 3
|
---|
48 | #define PARITY_SPACE 4
|
---|
49 | /* Values for the modem lines */
|
---|
50 | #define IO_SERIAL_HIGH 1
|
---|
51 | #define IO_SERIAL_LOW 0
|
---|
52 |
|
---|
53 | /* Maximum size of PnP Com ID */
|
---|
54 | #define IO_SERIAL_PNPID_SIZE 256
|
---|
55 |
|
---|
56 | /*
|
---|
57 | * Exported functions declaration
|
---|
58 | */
|
---|
59 |
|
---|
60 | /* IO_Serial creation and deletion */
|
---|
61 | void IO_Serial_Flush(struct s_reader *reader);
|
---|
62 |
|
---|
63 | /* Initialization and closing */
|
---|
64 | bool IO_Serial_InitPnP(struct s_reader *reader);
|
---|
65 | int32_t IO_Serial_Close(struct s_reader *reader);
|
---|
66 |
|
---|
67 | /* Transmission properties */
|
---|
68 | bool IO_Serial_DTR_RTS_dbox2(struct s_reader *reader, int32_t *dtr, int32_t *rts);
|
---|
69 | bool IO_Serial_DTR_RTS(struct s_reader *reader, int32_t *dtr, int32_t *rts);
|
---|
70 | void IO_Serial_Ioctl_Lock(struct s_reader *reader, int32_t);
|
---|
71 |
|
---|
72 | bool IO_Serial_SetBitrate(struct s_reader *reader, uint32_t bitrate, struct termios *tio);
|
---|
73 | bool IO_Serial_SetParams(struct s_reader *reader, uint32_t bitrate, uint32_t bits, int32_t parity, uint32_t stopbits, int32_t *dtr, int32_t *rts);
|
---|
74 | bool IO_Serial_SetProperties(struct s_reader *reader, struct termios newtio);
|
---|
75 | int32_t IO_Serial_SetParity(struct s_reader *reader, unsigned char parity);
|
---|
76 |
|
---|
77 | /* Input and output */
|
---|
78 | bool IO_Serial_Read(struct s_reader *reader, uint32_t delay, uint32_t timeout, uint32_t size, unsigned char *data);
|
---|
79 | bool IO_Serial_Write(struct s_reader *reader, uint32_t delay, uint32_t timeout, uint32_t size, const unsigned char *data);
|
---|
80 | void IO_Serial_Sendbreak(struct s_reader *reader, int32_t duration);
|
---|
81 | bool IO_Serial_WaitToRead(struct s_reader *reader, uint32_t delay_us, uint32_t timeout_us);
|
---|
82 |
|
---|
83 | int32_t IO_Serial_Receive(struct s_reader *reader, unsigned char *buffer, uint32_t size, uint32_t delay, uint32_t timeout);
|
---|
84 | int32_t IO_Serial_Transmit(struct s_reader *reader, unsigned char *buffer, uint32_t size, uint32_t expectedlen, uint32_t delay, uint32_t timeout);
|
---|
85 | int32_t IO_Serial_GetStatus(struct s_reader *reader, int32_t *status);
|
---|
86 | int32_t IO_Serial_SetBaudrate(struct s_reader *reader, uint32_t baudrate);
|
---|
87 |
|
---|
88 | #endif /* IO_SERIAL */
|
---|