source: trunk/csctapi/io_serial.h

Last change on this file was 8960, checked in by Gorgone Impertinence, 7 years ago

revert 8951 & 8952
sorry for this !

  • Property svn:eol-style set to LF
File size: 3.7 KB
Line 
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 */
61void IO_Serial_Flush(struct s_reader *reader);
62
63/* Initialization and closing */
64bool IO_Serial_InitPnP(struct s_reader *reader);
65int32_t IO_Serial_Close(struct s_reader *reader);
66
67/* Transmission properties */
68bool IO_Serial_DTR_RTS_dbox2(struct s_reader *reader, int32_t *dtr, int32_t *rts);
69bool IO_Serial_DTR_RTS(struct s_reader *reader, int32_t *dtr, int32_t *rts);
70void IO_Serial_Ioctl_Lock(struct s_reader *reader, int32_t);
71
72bool IO_Serial_SetBitrate(struct s_reader *reader, uint32_t bitrate, struct termios *tio);
73bool 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);
74bool IO_Serial_SetProperties(struct s_reader *reader, struct termios newtio);
75int32_t IO_Serial_SetParity(struct s_reader *reader, unsigned char parity);
76
77/* Input and output */
78bool IO_Serial_Read(struct s_reader *reader, uint32_t delay, uint32_t timeout, uint32_t size, unsigned char *data);
79bool IO_Serial_Write(struct s_reader *reader, uint32_t delay, uint32_t timeout, uint32_t size, const unsigned char *data);
80void IO_Serial_Sendbreak(struct s_reader *reader, int32_t duration);
81bool IO_Serial_WaitToRead(struct s_reader *reader, uint32_t delay_us, uint32_t timeout_us);
82
83int32_t IO_Serial_Receive(struct s_reader *reader, unsigned char *buffer, uint32_t size, uint32_t delay, uint32_t timeout);
84int32_t IO_Serial_Transmit(struct s_reader *reader, unsigned char *buffer, uint32_t size, uint32_t expectedlen, uint32_t delay, uint32_t timeout);
85int32_t IO_Serial_GetStatus(struct s_reader *reader, int32_t *status);
86int32_t IO_Serial_SetBaudrate(struct s_reader *reader, uint32_t baudrate);
87
88#endif /* IO_SERIAL */
Note: See TracBrowser for help on using the repository browser.