* [PATCH 2/2] driver for Zhen Hua PCM-4CH RC transmitter v2
@ 2008-02-13 15:51 Kmarty
[not found] ` <20080213105906.ZZRA012@mailhub.coreip.homeip.net>
0 siblings, 1 reply; 2+ messages in thread
From: Kmarty @ 2008-02-13 15:51 UTC (permalink / raw)
To: dtor; +Cc: linux-input
[-- Attachment #1: Type: text/plain, Size: 72 bytes --]
(again, now as attachments)
Patch for inputattach from joystick-utils.
[-- Attachment #2: inputattach.c.diffstat --]
[-- Type: application/octet-stream, Size: 111 bytes --]
inputattach.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: inputattach.c.diff --]
[-- Type: text/x-patch; name=inputattach.c.diff, Size: 2094 bytes --]
--- inputattach.c.orig 2008-02-06 10:35:22.000000000 +0100
+++ inputattach.c 2008-02-13 15:49:48.000000000 +0100
@@ -1,5 +1,4 @@
/*
- * $Id: inputattach.c 2352 2006-02-08 12:19:31Z vojtech $
*
* Copyright (c) 1999-2000 Vojtech Pavlik
*
@@ -315,6 +314,42 @@
return 0;
}
+int zhenhua_init(int fd, long *id, long *extra)
+{
+ /* Zhen Hua 5 byte protokol: prvni (synchronizacni) byte obsahuje vzdy 0xF7,
+ * nasledujici ctyri pak jednotlive osy ovladace v intervalu 50-200.
+ * Pozor, nacitana data (jednotlive bajty) jsou bitove prevracene (nejnizsi
+ * bit je nejvyssim bitem) - neco jako little-endian na bitove urovni.
+ * Synchronizacni byte ma tedy bez prevraceni hodnotu 0xEF
+ *
+ * Inicializace je temer shodna s twiddlerem */
+
+ 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;
+
+}
+
int dump_init(int fd, long *id, long *extra)
{
unsigned char c, o = 0;
@@ -376,6 +411,7 @@
{ "--elo4002", "-elo6b", B9600, CS8 | CRTSCTS, SERIO_ELO, 1, 0, 0, NULL },
{ "--elo271-140", "-elo4b", B9600, CS8 | CRTSCTS, SERIO_ELO, 2, 0, 0, NULL },
{ "--elo261-280", "-elo3b", B9600, CS8 | CRTSCTS, SERIO_ELO, 3, 0, 0, NULL },
+{ "--zhen-hua", "-zhen", B19200, CS8, SERIO_ZHENHUA, 0, 0, 0, zhenhua_init },
{ "--dump", "-dump", B2400, CS8, 0, 0, 0, 0, dump_init },
{ "", "", 0, 0 }
@@ -416,6 +452,7 @@
puts(" --ps2serkbd -ps2ser PS/2 via serial keyboard");
puts(" --twiddler -twid Handykey Twiddler chording keyboard");
puts(" --twiddler-joy -twidjoy Handykey Twiddler used as a joystick");
+ puts(" --zhen-hua -zhen Zhen Hua 5-byte protocol");
puts("");
return 1;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] driver for Zhen Hua PCM-4CH RC transmitter v2
[not found] ` <20080213105906.ZZRA012@mailhub.coreip.homeip.net>
@ 2008-02-13 16:52 ` Kmarty
0 siblings, 0 replies; 2+ messages in thread
From: Kmarty @ 2008-02-13 16:52 UTC (permalink / raw)
To: dtor; +Cc: linux-input
[-- Attachment #1: Type: text/plain, Size: 808 bytes --]
2008/2/13, Dmitry Torokhov:
> Hi,
>
> On Wed, Feb 13, 2008 at 04:51:50PM +0100, Kmarty wrote:
> >
> > +int zhenhua_init(int fd, long *id, long *extra)
> > +{
> > + /* Zhen Hua 5 byte protokol: prvni (synchronizacni) byte obsahuje vzdy 0xF7,
> > + * nasledujici ctyri pak jednotlive osy ovladace v intervalu 50-200.
> > + * Pozor, nacitana data (jednotlive bajty) jsou bitove prevracene (nejnizsi
> > + * bit je nejvyssim bitem) - neco jako little-endian na bitove urovni.
> > + * Synchronizacni byte ma tedy bez prevraceni hodnotu 0xEF
> > + *
> > + * Inicializace je temer shodna s twiddlerem */
> > +
>
> Could you please change this comment to english since this way most
> people can read it? Other than that it all looks good, thanks.
>
> --
> Dmitry
>
Ok, translated.
[-- Attachment #2: inputattach.c.diffstat --]
[-- Type: application/octet-stream, Size: 113 bytes --]
inputattach.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: inputattach.c.diff --]
[-- Type: text/x-patch; name=inputattach.c.diff, Size: 2105 bytes --]
--- inputattach.c.orig 2008-02-06 10:35:22.000000000 +0100
+++ inputattach.c 2008-02-13 17:48:29.000000000 +0100
@@ -1,5 +1,4 @@
/*
- * $Id: inputattach.c 2352 2006-02-08 12:19:31Z vojtech $
*
* Copyright (c) 1999-2000 Vojtech Pavlik
*
@@ -315,6 +314,44 @@
return 0;
}
+int zhenhua_init(int fd, long *id, 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;
+
+}
+
int dump_init(int fd, long *id, long *extra)
{
unsigned char c, o = 0;
@@ -376,6 +413,7 @@
{ "--elo4002", "-elo6b", B9600, CS8 | CRTSCTS, SERIO_ELO, 1, 0, 0, NULL },
{ "--elo271-140", "-elo4b", B9600, CS8 | CRTSCTS, SERIO_ELO, 2, 0, 0, NULL },
{ "--elo261-280", "-elo3b", B9600, CS8 | CRTSCTS, SERIO_ELO, 3, 0, 0, NULL },
+{ "--zhen-hua", "-zhen", B19200, CS8, SERIO_ZHENHUA, 0, 0, 0, zhenhua_init },
{ "--dump", "-dump", B2400, CS8, 0, 0, 0, 0, dump_init },
{ "", "", 0, 0 }
@@ -416,6 +454,7 @@
puts(" --ps2serkbd -ps2ser PS/2 via serial keyboard");
puts(" --twiddler -twid Handykey Twiddler chording keyboard");
puts(" --twiddler-joy -twidjoy Handykey Twiddler used as a joystick");
+ puts(" --zhen-hua -zhen Zhen Hua 5-byte protocol");
puts("");
return 1;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-13 16:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-13 15:51 [PATCH 2/2] driver for Zhen Hua PCM-4CH RC transmitter v2 Kmarty
[not found] ` <20080213105906.ZZRA012@mailhub.coreip.homeip.net>
2008-02-13 16:52 ` Kmarty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).