[8] | 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 "defines.h"
|
---|
| 29 |
|
---|
| 30 | #define IO_Serial_DTR_Set(io) IO_Serial_DTR_RTS(io, 1, 1)
|
---|
| 31 | #define IO_Serial_DTR_Clr(io) IO_Serial_DTR_RTS(io, 1, 0)
|
---|
| 32 | #define IO_Serial_RTS_Set(io) IO_Serial_DTR_RTS(io, 0, 1)
|
---|
| 33 | #define IO_Serial_RTS_Clr(io) IO_Serial_DTR_RTS(io, 0, 0)
|
---|
| 34 | /*
|
---|
| 35 | * Exported constants definition
|
---|
| 36 | */
|
---|
| 37 |
|
---|
| 38 | /* Type of parity of the serial device */
|
---|
| 39 | #define IO_SERIAL_PARITY_ODD 1
|
---|
| 40 | #define IO_SERIAL_PARITY_EVEN 2
|
---|
| 41 | #define IO_SERIAL_PARITY_NONE 3
|
---|
| 42 |
|
---|
| 43 | /* Values for the modem lines */
|
---|
| 44 | #define IO_SERIAL_HIGH 1
|
---|
| 45 | #define IO_SERIAL_LOW 0
|
---|
| 46 |
|
---|
| 47 | /* Maximum size of PnP Com ID */
|
---|
| 48 | #define IO_SERIAL_PNPID_SIZE 256
|
---|
| 49 |
|
---|
| 50 | /*
|
---|
| 51 | * Exported datatypes definition
|
---|
| 52 | */
|
---|
| 53 |
|
---|
[567] | 54 | /* IO_Serial exported datatype */
|
---|
[8] | 55 | typedef struct
|
---|
| 56 | {
|
---|
[567] | 57 | int fd; /* Handle of the serial device */
|
---|
| 58 | /* Settings that can be modified */
|
---|
[8] | 59 | unsigned long input_bitrate;
|
---|
| 60 | unsigned long output_bitrate;
|
---|
| 61 | unsigned bits;
|
---|
| 62 | unsigned stopbits;
|
---|
| 63 | int parity;
|
---|
| 64 | int dtr;
|
---|
| 65 | int rts;
|
---|
[567] | 66 | /* end settings that can be modified */
|
---|
[8] | 67 | unsigned com; /* Com port number (1..4) */
|
---|
| 68 | BYTE PnP_id[IO_SERIAL_PNPID_SIZE]; /* PnP Id of the serial device */
|
---|
| 69 | unsigned PnP_id_size; /* Length of PnP Id */
|
---|
| 70 | bool usbserial; /* Is serial USB device */
|
---|
| 71 | int wr;
|
---|
[71] | 72 | int reader_type;
|
---|
[566] | 73 | int mhz; /* mhz specified in config = actual reader clock speed */
|
---|
[615] | 74 | int cardmhz; /* mhz specified in config = standard (non overclocked) clock speed of card*/
|
---|
[8] | 75 | }
|
---|
| 76 | IO_Serial;
|
---|
| 77 |
|
---|
| 78 | /*
|
---|
| 79 | * Exported functions declaration
|
---|
| 80 | */
|
---|
| 81 |
|
---|
| 82 | /* IO_Serial creation and deletion */
|
---|
| 83 | //extern void IO_Serial_Reopen (IO_Serial * io);
|
---|
| 84 | extern void IO_Serial_Flush (IO_Serial * io);
|
---|
[615] | 85 | extern IO_Serial *IO_Serial_New (int reader_type, int mhz, int cardmhz);
|
---|
[8] | 86 | extern void IO_Serial_Delete (IO_Serial * io);
|
---|
| 87 |
|
---|
| 88 | /* Initialization and closing */
|
---|
[1126] | 89 | extern bool IO_Serial_Init (IO_Serial * io, unsigned com, bool usbserial);
|
---|
[8] | 90 | extern bool IO_Serial_Close (IO_Serial * io);
|
---|
| 91 |
|
---|
| 92 | /* Transmission properties */
|
---|
[567] | 93 | extern bool IO_Serial_SetProperties (IO_Serial * io);
|
---|
| 94 | extern bool IO_Serial_GetProperties (IO_Serial * io);
|
---|
[8] | 95 | extern bool IO_Serial_DTR_RTS(IO_Serial * io, int, int);
|
---|
| 96 | #if defined(TUXBOX) && defined(PPC)
|
---|
| 97 | extern void IO_Serial_Ioctl_Lock(IO_Serial *, int);
|
---|
| 98 | #else
|
---|
| 99 | #define IO_Serial_Ioctl_Lock(a, b) {}
|
---|
| 100 | #endif
|
---|
| 101 |
|
---|
| 102 | /* Input and output */
|
---|
| 103 | extern bool IO_Serial_Read (IO_Serial * io, unsigned timeout, unsigned size, BYTE * data);
|
---|
| 104 | extern bool IO_Serial_Write (IO_Serial * io, unsigned delay, unsigned size, BYTE * data);
|
---|
| 105 |
|
---|
| 106 | /* Serial port atributes */
|
---|
| 107 | extern unsigned IO_Serial_GetCom (IO_Serial * io);
|
---|
| 108 | extern void IO_Serial_GetPnPId (IO_Serial * io, BYTE * pnp_id, unsigned *length);
|
---|
| 109 |
|
---|
| 110 | #endif /* IO_SERIAL */
|
---|