1 |
|
---|
2 | /*
|
---|
3 | io_serial.h
|
---|
4 | Serial port input/output definitions
|
---|
5 |
|
---|
6 | This file is part of the Unix driver for Towitoko smartcard readers
|
---|
7 | Copyright (C) 2000 Carlos Prados <cprados@yahoo.com>
|
---|
8 |
|
---|
9 | This version is modified by doz21 to work in a special manner ;)
|
---|
10 |
|
---|
11 | This library is free software; you can redistribute it and/or
|
---|
12 | modify it under the terms of the GNU Lesser General Public
|
---|
13 | License as published by the Free Software Foundation; either
|
---|
14 | version 2 of the License, or (at your option) any later version.
|
---|
15 |
|
---|
16 | This library is distributed in the hope that it will be useful,
|
---|
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | Lesser General Public License for more details.
|
---|
20 |
|
---|
21 | You should have received a copy of the GNU Lesser General Public
|
---|
22 | License along with this library; if not, write to the Free Software
|
---|
23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef _IO_SERIAL_
|
---|
27 | # define _IO_SERIAL_
|
---|
28 |
|
---|
29 | # include "defines.h"
|
---|
30 |
|
---|
31 | # define IO_Serial_DTR_Set(io) IO_Serial_DTR_RTS(io, 1, 1)
|
---|
32 | # define IO_Serial_DTR_Clr(io) IO_Serial_DTR_RTS(io, 1, 0)
|
---|
33 | # define IO_Serial_RTS_Set(io) IO_Serial_DTR_RTS(io, 0, 1)
|
---|
34 | # define IO_Serial_RTS_Clr(io) IO_Serial_DTR_RTS(io, 0, 0)
|
---|
35 |
|
---|
36 | /*
|
---|
37 | * Exported constants definition
|
---|
38 | */
|
---|
39 |
|
---|
40 | /* Type of parity of the serial device */
|
---|
41 | # define IO_SERIAL_PARITY_ODD 1
|
---|
42 | # define IO_SERIAL_PARITY_EVEN 2
|
---|
43 | # define IO_SERIAL_PARITY_NONE 3
|
---|
44 |
|
---|
45 | /* Values for the modem lines */
|
---|
46 | # define IO_SERIAL_HIGH 1
|
---|
47 | # define IO_SERIAL_LOW 0
|
---|
48 |
|
---|
49 | /* Maximum size of PnP Com ID */
|
---|
50 | # define IO_SERIAL_PNPID_SIZE 256
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * Exported datatypes definition
|
---|
54 | */
|
---|
55 |
|
---|
56 | /* Settings than can be modified to the serial device */
|
---|
57 | typedef struct {
|
---|
58 | unsigned long input_bitrate;
|
---|
59 | unsigned long output_bitrate;
|
---|
60 | unsigned bits;
|
---|
61 | unsigned stopbits;
|
---|
62 | int parity;
|
---|
63 | int dtr;
|
---|
64 | int rts;
|
---|
65 | } IO_Serial_Properties;
|
---|
66 |
|
---|
67 | typedef struct {
|
---|
68 | int F;
|
---|
69 | float D;
|
---|
70 | int fs;
|
---|
71 | int N;
|
---|
72 | int T;
|
---|
73 | int inv;
|
---|
74 | } SR_Config;
|
---|
75 |
|
---|
76 | /* IO_Serial exported datatype */
|
---|
77 | typedef struct {
|
---|
78 | int fd; /* Handle of the serial device */
|
---|
79 | IO_Serial_Properties *props;
|
---|
80 | BYTE PnP_id[IO_SERIAL_PNPID_SIZE]; /* PnP Id of the serial device */
|
---|
81 | unsigned PnP_id_size; /* Length of PnP Id */
|
---|
82 | char device[128]; /* Device path */
|
---|
83 | int reader_type; /* Reader type */
|
---|
84 | unsigned long frequency; /* Frequency (Hz) */
|
---|
85 | int wr;
|
---|
86 | SR_Config *SmartReaderConf;
|
---|
87 | } IO_Serial;
|
---|
88 |
|
---|
89 | /*
|
---|
90 | * Exported functions declaration
|
---|
91 | */
|
---|
92 |
|
---|
93 | /* IO_Serial creation and deletion */
|
---|
94 | //extern void IO_Serial_Reopen (IO_Serial * io);
|
---|
95 | extern void IO_Serial_Flush(IO_Serial * io);
|
---|
96 | extern IO_Serial *IO_Serial_New(void);
|
---|
97 | extern void IO_Serial_Delete(IO_Serial * io);
|
---|
98 |
|
---|
99 | /* Initialization and closing */
|
---|
100 | extern bool IO_Serial_Init(IO_Serial * io, char *device, unsigned long frequency, unsigned short reader_type, bool pnp);
|
---|
101 | extern bool IO_Serial_Close(IO_Serial * io);
|
---|
102 |
|
---|
103 | /* Transmission properties */
|
---|
104 | extern bool IO_Serial_SetProperties(IO_Serial * io, IO_Serial_Properties * props, SR_Config *sr_config);
|
---|
105 | extern bool IO_Serial_GetProperties(IO_Serial * io, IO_Serial_Properties * props, SR_Config *sr_config);
|
---|
106 | extern bool IO_Serial_DTR_RTS(IO_Serial * io, int, int);
|
---|
107 |
|
---|
108 | # if defined(TUXBOX) && defined(PPC)
|
---|
109 | extern void IO_Serial_Ioctl_Lock(IO_Serial *, int);
|
---|
110 | # else
|
---|
111 | # define IO_Serial_Ioctl_Lock(a, b) {}
|
---|
112 | # endif
|
---|
113 |
|
---|
114 | /* Input and output */
|
---|
115 | extern bool IO_Serial_Read(IO_Serial * io, unsigned timeout, unsigned size, BYTE * data);
|
---|
116 | extern bool IO_Serial_Write(IO_Serial * io, unsigned delay, unsigned size, BYTE * data);
|
---|
117 |
|
---|
118 | /* Serial port atributes */
|
---|
119 | extern void IO_Serial_GetPnPId(IO_Serial * io, BYTE * pnp_id, unsigned *length);
|
---|
120 |
|
---|
121 | #endif /* IO_SERIAL */
|
---|