From: <sk...@us...> - 2010-09-23 11:53:50
|
Revision: 2390 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2390&view=rev Author: skitt Date: 2010-09-23 11:53:44 +0000 (Thu, 23 Sep 2010) Log Message: ----------- Add an inputattach mode for the Sahara Touch-iT213 and options --always and --noinit; patch taken from https://bugs.launchpad.net/ubuntu/+source/inputattach/+bug/338746 Modified Paths: -------------- trunk/utils/inputattach.c Modified: trunk/utils/inputattach.c =================================================================== --- trunk/utils/inputattach.c 2010-09-23 11:47:58 UTC (rev 2389) +++ trunk/utils/inputattach.c 2010-09-23 11:53:44 UTC (rev 2390) @@ -7,6 +7,8 @@ * * Twiddler support Copyright (c) 2001 Arndt Schoenewald * Sponsored by Quelltext AG (http://www.quelltext-ag.de), Dortmund, Germany + * + * Sahara Touchit-213 mode added by Claudio Nieder 2008-05-01. */ /* @@ -33,25 +35,18 @@ * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic */ +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> #include <linux/serio.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <sys/time.h> - +#include "serio-ids.h" #include <stdio.h> #include <stdlib.h> +#include <string.h> +#include <sys/ioctl.h> +#include <termios.h> #include <unistd.h> -#include <fcntl.h> -#include <termios.h> -#include <string.h> -#include <errno.h> -#include <assert.h> -#include <ctype.h> -#include "serio-ids.h" - static int readchar(int fd, unsigned char *c, int timeout) { struct timeval tv; @@ -121,7 +116,7 @@ return 0; } -static int spaceball_waitchar(int fd, unsigned char c, unsigned char *d, +static int spaceball_waitchar(int fd, unsigned char c, char *d, int timeout) { unsigned char b = 0; @@ -240,7 +235,7 @@ { int i; unsigned char c; - unsigned char *response = "\r\n0600520058C272"; + unsigned char *response = (unsigned char *)"\r\n0600520058C272"; if (write(fd, " E5E5", 5) != 5) /* Enable command */ return -1; @@ -362,6 +357,52 @@ return 0; } +static int t213_init(int fd, unsigned long *id, unsigned long *extra) +{ + char cmd[]={0x0a,1,'A'}; + int count=10; + int state=0; + unsigned char data; + + /* + * In case the controller is in "ELO-mode" send a few times + * the check active packet to force it into the documented + * touchkit mode. + */ + while (count>0) { + if (write(fd, &cmd, 3) != 3) + return -1; + while (!readchar(fd, &data, 100)) { + switch (state) { + case 0: + if (data==0x0a) { + state=1; + } + break; + case 1: + if (data==1) { + state=2; + } else if (data!=0x0a) { + state=0; + } + break; + case 2: + if (data=='A') { + return 0; + } else if (data==0x0a) { + state=1; + } else { + state=0; + } + break; + } + + } + count--; + } + return -1; +} + static int dump_init(int fd, unsigned long *id, unsigned long *extra) { unsigned char c, o = 0; @@ -480,6 +521,9 @@ { "--mtouch", "-mtouch", "MicroTouch (3M) touchscreen", B9600, CS8 | CRTSCTS, SERIO_MICROTOUCH, 0x00, 0x00, 0, NULL }, +{ "--touchit213", "-t213", "Sahara Touch-iT213 Tablet PC", + B9600, CS8, + SERIO_TOUCHIT213, 0x00, 0x00, 0, t213_init }, { "--touchright", "-tr", "Touchright serial touchscreen", B9600, CS8 | CRTSCTS, SERIO_TOUCHRIGHT, 0x00, 0x00, 0, NULL }, @@ -503,7 +547,7 @@ struct input_types *type; puts(""); - puts("Usage: inputattach [--daemon] <mode> <device>"); + puts("Usage: inputattach [--daemon] [--always] [--noinit] <mode> <device>"); puts(""); puts("Modes:"); @@ -525,8 +569,10 @@ unsigned long id, extra; int fd; int i; - char c; + unsigned char c; int retval; + int ignore_init_res = 0; + int no_init = 0; for (i = 1; i < argc; i++) { if (!strcasecmp(argv[i], "--help")) { @@ -534,6 +580,10 @@ return EXIT_SUCCESS; } else if (!strcasecmp(argv[i], "--daemon")) { daemon_mode = 1; + } else if (!strcasecmp(argv[i], "--always")) { + ignore_init_res = 1; + } else if (!strcasecmp(argv[i], "--noinit")) { + no_init = 1; } else if (need_device) { device = argv[i]; need_device = 0; @@ -586,9 +636,15 @@ id = type->id; extra = type->extra; - if (type->init && type->init(fd, &id, &extra)) { - fprintf(stderr, "inputattach: device initialization failed\n"); - return EXIT_FAILURE; + if (type->init && !no_init) { + if (type->init(fd, &id, &extra)) { + if (ignore_init_res) { + fprintf(stderr, "inputattach: ignored device initialization failure\n"); + } else { + fprintf(stderr, "inputattach: device initialization failed\n"); + return EXIT_FAILURE; + } + } } ldisc = N_MOUSE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2010-11-04 12:17:01
|
Revision: 2399 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2399&view=rev Author: skitt Date: 2010-11-04 12:16:54 +0000 (Thu, 04 Nov 2010) Log Message: ----------- this is a driver for Zhen Hua PCM-4CH RC transmitter (commonly used in cheap Ready To Fly RC helicopters) which using "Zhen Hua 5-byte protocol" for using them as a four axis joystick via serial port. Transmitter connected to serial port (19200 8N1) sending periodically 5 bytes where first byte is for synchronization and next four bytes are values of axis. Signed-off-by: Martin Kebert <gk...@gm...> Signed-off-by: Stephen Kitt <st...@sk...> Modified Paths: -------------- trunk/utils/inputattach.c Modified: trunk/utils/inputattach.c =================================================================== --- trunk/utils/inputattach.c 2010-11-04 06:15:52 UTC (rev 2398) +++ trunk/utils/inputattach.c 2010-11-04 12:16:54 UTC (rev 2399) @@ -403,6 +403,44 @@ return -1; } +static int zhenhua_init(int fd, unsigned long *id, unsigned long *extra) +{ + /* Zhen Hua 5 byte protocol: first (synchronization) byte allways + * contain 0xF7, next four bytes are axis of controller with values + * between 50-200. + * Incoming data (each byte) have reversed bits (lowest bit is + * highest bit) - something like little-endian but on bit level. + * Synchronization byte without reversing bits have (raw) value: + * 0xEF + * + * Initialization is almost same as twiddler_init */ + + unsigned char c[10]; + int count; + + for (count=0 ; count < 5 ; count++) { + if(readchar(fd, c+0, 500)) return -1; + if(c[0] == 0xef) break; + } + + if (count == 5) { + /* Could not find header byte in data stream */ + return -1; + } + + /* Read remaining 4 bytes plus the full next data packet */ + for (count = 1; count < 10; count++) { + if (readchar(fd, c+count, 500)) return -1; + } + + /* check if next sync byte exists */ + if (c[5] != 0xef) + return -1; + + return 0; + +} + static int dump_init(int fd, unsigned long *id, unsigned long *extra) { unsigned char c, o = 0; @@ -539,6 +577,9 @@ { "--ps2mult", "-ps2m", "PS/2 serial multiplexer", B57600, CS8, SERIO_PS2MULT, 0x00, 0x00, 1, NULL }, +{ "--zhen-hua", "-zhen", "Zhen Hua 5-byte protocol", + B19200, CS8, + SERIO_ZHENHUA, 0x00, 0x00, 0, zhenhua_init }, { "--dump", "-dump", "Just enable device", B2400, CS8, 0, 0x00, 0x00, 0, dump_init }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2011-03-06 14:27:59
|
Revision: 2402 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2402&view=rev Author: skitt Date: 2011-03-06 14:27:53 +0000 (Sun, 06 Mar 2011) Log Message: ----------- Support the wacom_w8001 driver. Thanks to Alexander Clouter <al...@di...> for collating the various patches! Modified Paths: -------------- trunk/utils/inputattach.c Modified: trunk/utils/inputattach.c =================================================================== --- trunk/utils/inputattach.c 2010-12-28 22:17:35 UTC (rev 2401) +++ trunk/utils/inputattach.c 2011-03-06 14:27:53 UTC (rev 2402) @@ -583,6 +583,9 @@ { "--dump", "-dump", "Just enable device", B2400, CS8, 0, 0x00, 0x00, 0, dump_init }, +{ "--w8001", "-w8001", "Wacom W8001", + B38400, CS8, + SERIO_W8001, 0x00, 0x00, 0, NULL }, { NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, NULL } }; @@ -591,7 +594,7 @@ struct input_types *type; puts(""); - puts("Usage: inputattach [--daemon] [--always] [--noinit] <mode> <device>"); + puts("Usage: inputattach [--daemon] [--baud <baud>] [--always] [--noinit] <mode> <device>"); puts(""); puts("Modes:"); @@ -615,6 +618,7 @@ int i; unsigned char c; int retval; + int baud = -1; int ignore_init_res = 0; int no_init = 0; @@ -631,6 +635,15 @@ } else if (need_device) { device = argv[i]; need_device = 0; + } else if (!strcasecmp(argv[i], "--baud")) { + if (argc <= i + 1) { + show_help(); + fprintf(stderr, + "inputattach: require baud rate\n"); + return EXIT_FAILURE; + } + + baud = atoi(argv[++i]); } else { if (type && type->name) { fprintf(stderr, @@ -671,6 +684,19 @@ return 1; } + switch(baud) { + case -1: break; + case 2400: type->speed = B2400; break; + case 4800: type->speed = B4800; break; + case 9600: type->speed = B9600; break; + case 19200: type->speed = B19200; break; + case 38400: type->speed = B38400; break; + default: + fprintf(stderr, "inputattach: invalid baud rate '%d'\n", + baud); + return EXIT_FAILURE; + } + setline(fd, type->flags, type->speed); if (type->flush) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2011-08-09 05:43:15
|
Revision: 2429 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2429&view=rev Author: skitt Date: 2011-08-09 05:43:09 +0000 (Tue, 09 Aug 2011) Log Message: ----------- Avoid resetting the line discipline if another instance of inputattach is already running. Modified Paths: -------------- trunk/utils/inputattach.c Modified: trunk/utils/inputattach.c =================================================================== --- trunk/utils/inputattach.c 2011-06-25 13:19:12 UTC (rev 2428) +++ trunk/utils/inputattach.c 2011-08-09 05:43:09 UTC (rev 2429) @@ -626,6 +626,7 @@ int baud = -1; int ignore_init_res = 0; int no_init = 0; + int one_read = 0; for (i = 1; i < argc; i++) { if (!strcasecmp(argv[i], "--help")) { @@ -746,11 +747,17 @@ if (i == -1) { if (RETRY_ERROR(errno)) continue; + } else { + one_read = 1; } } while (!i); ldisc = 0; - ioctl(fd, TIOCSETD, &ldisc); + if (one_read) { + // If we've never managed to read, avoid resetting the line + // discipline - another inputattach is probably running + ioctl(fd, TIOCSETD, &ldisc); + } close(fd); return retval; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |