7 * A Linux/Unix toolset and driver for Nokia mobile phones.
9 * Copyright (C) 1999, 2000 Hugh Blemings & Pavel JanÃk ml.
10 * Copyright (C) 2000-2001 Marcel Holtmann <marcel@holtmann.org>
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Revision 1.1.1.1 2001/11/25 21:59:08 short
28 * :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
30 * Revision 1.2 2001/02/21 19:57:03 chris
31 * More fiddling with the directory layout
33 * Revision 1.1 2001/02/16 14:29:51 chris
34 * Restructure of common/. Fixed a problem in fbus-phonet.c
35 * Lots of dprintfs for Marcin
36 * Any size xpm can now be loaded (eg for 7110 startup logos)
37 * nk7110 code detects 7110/6210 and alters startup logo size to suit
38 * Moved Marcin's extended phonebook code into gnokii.c
40 * Revision 1.2 2001/02/12 15:13:46 chris
41 * Fixed my bug in xgnokii_contacts.c and added <string.h> to tekram.c
43 * Revision 1.1 2001/02/09 18:12:53 chris
44 * Marcel's tekram support
50 #include <sys/ioctl.h>
55 #include "devices/unixserial.h"
57 #include "winserial.h"
60 #include "devices/tekram.h"
65 int tekram_open(__const char *__file) {
67 return (serial_open(__file, O_RDWR | O_NOCTTY | O_NONBLOCK));
70 void tekram_close(int __fd) {
72 serial_setdtrrts(__fd, 0, 0);
77 void tekram_reset(int __fd) {
79 serial_setdtrrts(__fd, 0, 0);
83 serial_setdtrrts(__fd, 1, 0);
87 serial_setdtrrts(__fd, 1, 1);
92 serial_changespeed(__fd, 9600);
95 void tekram_changespeed(int __fd, int __speed) {
97 unsigned char speedbyte;
103 case 9600: speedbyte = TEKRAM_PW | TEKRAM_B9600; break;
104 case 19200: speedbyte = TEKRAM_PW | TEKRAM_B19200; break;
105 case 38400: speedbyte = TEKRAM_PW | TEKRAM_B38400; break;
106 case 57600: speedbyte = TEKRAM_PW | TEKRAM_B57600; break;
107 case 115200: speedbyte = TEKRAM_PW | TEKRAM_B115200; break;
114 serial_setdtrrts(__fd, 1, 0);
118 serial_write(__fd, &speedbyte, 1);
122 serial_setdtrrts(__fd, 1, 1);
125 serial_changespeed(__fd, __speed);
128 size_t tekram_read(int __fd, __ptr_t __buf, size_t __nbytes) {
130 return (serial_read(__fd, __buf, __nbytes));
133 size_t tekram_write(int __fd, __const __ptr_t __buf, size_t __n) {
135 return (serial_write(__fd, __buf, __n));
138 int tekram_select(int fd, struct timeval *timeout) {
143 FD_SET(fd, &readfds);
145 return (select(fd + 1, &readfds, NULL, NULL, timeout));