#include <linux/serio.h>#include <sys/types.h>#include <sys/ioctl.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <fcntl.h>#include <termios.h>
Go to the source code of this file.
| Defines | |
| #define | ION_LDISC N_MOUSE | 
| #define | ION_SERIO_TYPE SERIO_STOWAWAY | 
| #define | ION_SERIO_FLAGS CS8 | 
| #define | ION_SERIO_SPEED B115200 | 
| Functions | |
| static void | setline (int fd, int flags, int speed) | 
| int | main (int argc, char **argv) | 
| #define ION_LDISC N_MOUSE | 
Copyright (C) 2008 iRex Technologies B.V. All rights reserved.
Based on inputattach.c by Vojtech Pavlik
Definition at line 57 of file kbdattach.c.
Referenced by main().
| #define ION_SERIO_FLAGS CS8 | 
Definition at line 59 of file kbdattach.c.
Referenced by main().
| #define ION_SERIO_SPEED B115200 | 
Definition at line 60 of file kbdattach.c.
Referenced by main().
| #define ION_SERIO_TYPE SERIO_STOWAWAY | 
Definition at line 58 of file kbdattach.c.
Referenced by main().
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) | 
Definition at line 79 of file kbdattach.c.
References fd, ION_LDISC, ION_SERIO_FLAGS, ION_SERIO_SPEED, ION_SERIO_TYPE, and setline().
00080 { 00081 unsigned long devt; 00082 int ldisc; 00083 int fd; 00084 00085 // open device 00086 if ((fd = open(argv[1], O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) { 00087 fprintf(stderr, "kbdattach: can't open device\n"); 00088 return 1; 00089 } 00090 00091 // set speed and flags 00092 setline(fd, ION_SERIO_FLAGS, ION_SERIO_SPEED); 00093 00094 // flush input junk 00095 // while (!readchar(fd, &c, 100)); 00096 // do device init if required 00097 00098 // set line discipline 00099 ldisc = ION_LDISC; 00100 if(ioctl(fd, TIOCSETD, &ldisc)) { 00101 fprintf(stderr, "kbdattach: can't set line discipline\n"); 00102 return 1; 00103 } 00104 00105 // set device type 00106 devt = ION_SERIO_TYPE; 00107 if(ioctl(fd, SPIOCSTYPE, &devt)) { 00108 fprintf(stderr, "kbdattach: can't set device type\n"); 00109 return 1; 00110 } 00111 00112 daemon(0,0); 00113 00114 read(fd, NULL, 0); 00115 00116 // reset line discipline 00117 ldisc = 0; 00118 ioctl(fd, TIOCSETD, &ldisc); 00119 close(fd); 00120 00121 return 0; 00122 }

| static void setline | ( | int | fd, | |
| int | flags, | |||
| int | speed | |||
| ) |  [static] | 
Definition at line 145 of file kbdattach.c.
Referenced by main().
00146 { 00147 struct termios t; 00148 00149 tcgetattr(fd, &t); 00150 00151 t.c_cflag = flags | CREAD | HUPCL | CLOCAL; 00152 t.c_iflag = IGNBRK | IGNPAR; 00153 t.c_oflag = 0; 00154 t.c_lflag = 0; 00155 t.c_cc[VMIN ] = 1; 00156 t.c_cc[VTIME] = 0; 00157 00158 cfsetispeed(&t, speed); 00159 cfsetospeed(&t, speed); 00160 00161 tcsetattr(fd, TCSANOW, &t); 00162 }

 1.6.2-20100208
 1.6.2-20100208