Background and instructions for typekey, etc.
Correspondence between the maintainer and author of typekeys, a program supplied by serial-text.
Blueprint information
- Status:
- Not started
- Approver:
- Loye Young
- Priority:
- Undefined
- Drafter:
- Loye Young
- Direction:
- Needs approval
- Assignee:
- None
- Definition:
- Approved
- Series goal:
- None
- Implementation:
- Unknown
- Milestone target:
- None
- Started by
- Completed by
Whiteboard
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td align=right>
<font size=-1><b>
Loye Young
<loye.young [at some email domain] like iycc.net>
</b></td>
</tr>
</table>
<hr>
<font size=+2>
<b>Re: serial barcode reader in linux</
<font size=-1>8 messages</font>
<hr>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td>
<font size=-1><b>
Jiri Bohac
<jbohac [at some email domain] like suse >
</b></font>
</td>
<td align=right>
<font size=-1><b>
Mon, Jun 4, 2007 at 12:42 PM
</b></font>
<tr>
<td colspan=2>
<font size=-1>
<div>
To:
loye.young [at some email domain] like iycc.net
</div>
</font>
<tr>
<td colspan=2>
<table width=100% cellpadding=12 cellspacing=0 border=0>
<tr>
<td>
<font size=-1>Hi,<br />
<br />
> This is a very interesting and apparently elegant approach. I<br />
> apologize for my technical ignorance, however. I don't<br />
> understand how to make typekeys work.<br />
><br />
> 1. How is this program to be compiled? As a kernel module? A<br />
> device driver?<br />
<br />
It is a standard userspace program. Modern 2.6 kernels allow<br />
userspace programs to inject iput events into the kernel using<br />
the uinput device (/dev/input/
<br />
You just compile it with<br />
<br />
gcc -o typekeys typekeys.c<br />
<br />
This produces a typekeys executable.<br />
<br />
> 2. You say:<br />
><br />
> * Translates data from stdin to uinput key press / key release<br />
> * sequences and feeds them to /dev/input/
><br />
> How does the data get to stdin in the first place? What's<br />
> reading the serial port?<br />
><br />
> 3. What is the ttySA device and how does it get created?<br />
> There's not one on my (Debian/Ubuntu) systems. Is it the SUSE<br />
> name for ttyS0?<br />
<br />
oops, that was a typo. It was meant to be ttyS0.<br />
I've seen in one of your posts (don't remember where), that wwhen<br />
you do "cat /dev/ttyS0", you can see the data coming from the<br />
barcode reader.<br />
<br />
So this program can read the data the same way cat does.<br />
You can redirect the stdin, or cat the data into it.<br />
<br />
cat /dev/ttyS0 | typekeys typekeys.conf<br />
or<br />
typekeys typekeys.conf < /dev/ttyS0<br />
<br />
You need to have the serial port set up properly (using stty).<br />
But once you can get the correct data using cat, typekeys should<br />
work.<br />
<br />
<br />
> 4. Do I need to put it in the rcS script so that it will<br />
> invoke on bootup?<br />
<br />
yes, you need to somehow ensure this program will run. My<br />
suggestion would be putting it in /etc/inittab<br />
But as you probably (?) can not redirect IO in inittab, I would<br />
first make a script (e.g. /usr/local/
with something like:<br />
#!/bin/bash<br />
stty /dev/ttyS0 whatever parameters you need<br />
/usr/local/
<br />
And then run this from the inittab (e.g. below the stty lines):<br />
tk:2345:
<br />
Or put it somewhere in rcS, you just need to make sure it does<br />
not get killed when the parent process terminates (you may use<br />
something like nohup for that)<br />
<br />
> 5. Once typekeys is invoked, does the barcode data show up in<br />
> all applications, including applications running under X, just<br />
> like the keyboard?<br />
<br />
exactly.<br />
<font color=#888888><br />
j.<br />
</font></font>
</table>
</table>
<hr>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td>
<font size=-1><b>
Loye Young
<loye.young [at some email domain] like iycc.net>
</b></font>
</td>
<td align=right>
<font size=-1><b>
Mon, Jun 4, 2007 at 4:19 PM
</b></font>
<tr>
<td colspan=2>
<font size=-1>
<div>
To:
Jiri Bohac <jbohac [at some email domain] like suse >, Vojtech Pavlik <vpavlik [at some email domain] like suse >
</div>
</font>
<tr>
<td colspan=2>
<table width=100% cellpadding=12 cellspacing=0 border=0>
<tr>
<td>
<font size=-1>Biggest issue I see is how to make sure the device gets handled correctly by udev, because ttyS0 might change from reboot to reboot. <br><br>Vojtech Pavlik (<a href="mailto:
xtkbd.c, sunkbd.c, lkkdbd.c, hilkbd.c, and atkbd.c.) Your code looks like a simplified version of those. The uinput solution in this case seems like a circumvention of the udev approach to device management. It seems to me that a driver in the input/keyboards branch of the kernel tree would be the right solution.
<br><br>I note that you both have [at some email domain]<a href="http://
<br><br>Loye Young<br><br><br>-- <br>Loye Young<br>Isaac & Young Computer Company<br>Laredo, Texas<br>(956) 857-1172<br><a href="mailto:
jbohac [at some email domain] like suse </a>></i></b> wrote:<blockquote style="
Hi, <br><br>I saw your posts in many places, trying to find a way to connect<br>your serial barcode reader to linux and make it transparently<
<br>thing sooner or later, so I made a small program called<
</a><br><br>You can then use like this:<br>
<br><br>
</font>
</table>
</table>
<hr>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td>
<font size=-1><b>
Mail Delivery System
<MAILER-DAEMON [at some email domain] like suse >
</b></font>
</td>
<td align=right>
<font size=-1><b>
Mon, Jun 4, 2007 at 4:20 PM
</b></font>
<tr>
<td colspan=2>
<font size=-1>
<div>
To:
loye.young [at some email domain] like iycc.net
</div>
</font>
<tr>
<td colspan=2>
<table width=100% cellpadding=12 cellspacing=0 border=0>
<tr>
<td>
<font size=-1>This is the Postfix program at host <a href="http://
<br />
I'm sorry to have to inform you that your message could not be<br />
be delivered to one or more recipients. It's attached below.<br />
<br />
For further assistance, please send mail to <postmaster&
<br />
If you do so, please include this problem report. You can<br />
delete your own text from the attached returned message.<br />
<br />
The Postfix program<br />
<br />
<<a href="mailto:
/
550-Mailbox unknown. Either there is no mailbox associated with this<br />
550-name or you do not have authorization to see it. 550 5.1.1 User unknown<br />
(in reply to RCPT TO command)<br />
<br>Final-
Action: failed<br />
Status: 5.0.0<br />
Diagnostic-Code: X-Postfix; host<br />
/
550-Mailbox unknown. Either there is no mailbox associated with this<br />
550-name or you do not have authorization to see it. 550 5.1.1 User unknown<br />
(in reply to RCPT TO command)<br />
<br><br>---------- Forwarded message -------
xtkbd.c, sunkbd.c, lkkdbd.c, hilkbd.c, and atkbd.c.) Your code looks like a simplified version of those. The uinput solution in this case seems like a circumvention of the udev approach to device management. It seems to me that a driver in the input/keyboards branch of the kernel tree would be the right solution.
<br><br>I note that you both have [at some email domain]<a href="http://
<br><br>Loye Young<br><br><br>-- <br>Loye Young<br>Isaac & Young Computer Company<br>Laredo, Texas<br>(956) 857-1172<br><a href="mailto:
<br><br><div><span class="
Hi,<br><br>> This is a very interesting and apparently elegant approach. I<br>> apologize for my technical ignorance, however. I don't<br>> understand how to make typekeys work.<br>
<br>> device driver?<br><br>It is a standard userspace program. Modern 2.6 kernels allow<br>userspace programs to inject iput events into the kernel using<br>the uinput device (/dev/input/
<br><br>gcc -o typekeys typekeys.
<br>><br>> How does the data get to stdin in the first place? What's<br>> reading the serial port?<br>
<br>> name for ttyS0?<br><br>oops, that was a typo. It was meant to be ttyS0.<br>I've seen in one of your posts (don't remember where), that wwhen<br>you do "cat /dev/ttyS0", you can see the data coming from the
<br>barcode reader.<br><br>So this program can read the data the same way cat does.<br>You can redirect the stdin, or cat the data into it.<br><br>cat /dev/ttyS0 | typekeys typekeys.
<br><br>You need to have the serial port set up properly (using stty).<br>But once you can get the correct data using cat, typekeys should<
<br>> invoke on bootup?<br><br>yes, you need to somehow ensure this program will run. My<br>suggestion would be putting it in /etc/inittab<br>But as you probably (?) can not redirect IO in inittab, I would<br>first make a script (
e.g. /usr/local/
<br>tk:
<br>> all applications, including applications running under X, just<br>> like the keyboard?
jbohac [at some email domain] like suse </a>></i></b> wrote:<blockquote style="
Hi, <br><br>I saw your posts in many places, trying to find a way to connect<br>your serial barcode reader to linux and make it transparently<
<br>thing sooner or later, so I made a small program called<
</a><br><br>You can then use like this:<br>
<br><br>
<br></font>
</table>
</table>
<hr>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td>
<font size=-1><b>
Loye Young
<loye.young [at some email domain] like iycc.net>
</b></font>
</td>
<td align=right>
<font size=-1><b>
Mon, Jun 4, 2007 at 4:22 PM
</b></font>
<tr>
<td colspan=2>
<font size=-1>
<div>
To:
Vojtech Pavlik <vojtech [at some email domain] like suse >
</div>
<div>
Cc:
Jiri Bohac <jbohac [at some email domain] like suse >
</div>
</font>
<tr>
<td colspan=2>
<table width=100% cellpadding=12 cellspacing=0 border=0>
<tr>
<td>
<font size=-1><div style='padding:5 0'><font size=1 color=#
</table>
</table>
<hr>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td>
<font size=-1><b>
Jiri Bohac
<jbohac [at some email domain] like suse >
</b></font>
</td>
<td align=right>
<font size=-1><b>
Mon, Jun 4, 2007 at 5:06 PM
</b></font>
<tr>
<td colspan=2>
<font size=-1>
<div>
To:
Loye Young <loye.young [at some email domain] like iycc.net>
</div>
<div>
Cc:
Jiri Bohac <jbohac [at some email domain] like suse >, Vojtech Pavlik <vpavlik [at some email domain] like suse >
</div>
</font>
<tr>
<td colspan=2>
<table width=100% cellpadding=12 cellspacing=0 border=0>
<tr>
<td>
<font size=-1>Hi,<br />
<font color=#550055><br />
> Biggest issue I see is how to make sure the device gets handled correctly by<br />
> udev, because ttyS0 might change from reboot to reboot.<br />
<br />
</font>Probably not for standard machines with a single serial<br />
contoller. This might be an issue with e.g. multiple PCI serial<br />
controllers, but on standard setups, ttyS0 should stay ttyS0<br />
AFAIK.<br />
<font color=#550055><br />
> Vojtech Pavlik (<a href="mailto:
> keyboards and they are incorporated in the kernel now. (See the kernel<br />
> keyboard input source tree, ./linux/
> xtkbd.c, sunkbd.c, lkkdbd.c, hilkbd.c, and atkbd.c.) Your code looks like a<br />
> simplified version of those. The uinput solution in this case seems like a<br />
> circumvention of the udev approach to device management.<br />
<br />
</font>Well, yes, the code is a quick hack and could be useful right<br />
now. I don't think it circumvents anything. It just takes the easy<br />
approach and uses the uinput interface which is already present<br />
in the kernel.<br />
<br />
Personally, I don't see real benefints of having simple drivers<br />
like this in the kernel - it just works in userspace, it's easier<br />
to tweak and improve. It can be rewritten/extended in any<br />
language (perl?).<br />
<br />
I'll talk to people at work who work on input drivers whether<br />
they would like something like this as a kernel driver.<br />
<font color=#550055><br />
j.<br />
<br />
--<br />
Jiri Bohac <<a href="mailto:
</font>SUSE Labs, SUSE CZ<br />
<br />
</font>
</table>
</table>
<hr>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td>
<font size=-1><b>
Loye Young
<loye.young [at some email domain] like iycc.net>
</b></font>
</td>
<td align=right>
<font size=-1><b>
Mon, Jun 4, 2007 at 7:41 PM
</b></font>
<tr>
<td colspan=2>
<font size=-1>
<div>
To:
Jiri Bohac <jbohac [at some email domain] like suse >
</div>
</font>
<tr>
<td colspan=2>
<table width=100% cellpadding=12 cellspacing=0 border=0>
<tr>
<td>
<font size=-1><font color=#
<br>"
<br><br></font>I need to do some reading up on uinput and its interrelation to udev. If I'm not mistaken, Greg K-H and your colleagues [at some email domain]<a href="http://
<br><font color=#
<br><br>Let me know what you and the input guys come up with. I've got a running list of folks who are wanting to know how to make this work. I've been searching for a solution for well over two years now.<br><br>
(Oh, and pardon my Texas syntax. The Bushes aren't the only Texans who mangle English.)<br><font color=#
</table>
</table>
<hr>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td>
<font size=-1><b>
Jiri Bohac
<jbohac [at some email domain] like suse >
</b></font>
</td>
<td align=right>
<font size=-1><b>
Tue, Jun 5, 2007 at 4:01 AM
</b></font>
<tr>
<td colspan=2>
<font size=-1>
<div>
To:
Loye Young <loye.young [at some email domain] like iycc.net>
</div>
</font>
<tr>
<td colspan=2>
<table width=100% cellpadding=12 cellspacing=0 border=0>
<tr>
<td>
<font size=-1>Hi,<br />
<font color=#550055>> "uses the uinput interface which is already present in the kernel."<br />
> "Personally, I don't see real benefints of having simple drivers<br />
> like this in the kernel - it just works in userspace, it's easier<br />
> to tweak and improve. It can be rewritten/extended in any<br />
> language (perl?)."<br />
><br />
> I need to do some reading up on uinput and its interrelation to udev. If I'm<br />
> not mistaken, Greg K-H and your colleagues [at some email domain]<a href="http://
> input system around udev to do what you suggest: pull drivers out of the<br />
> kernel and put them into userspace. Although I understand the concept, I<br />
> don't understand the code enough to know exactly how they work.<br />
<br />
</font>I don't think you don't quite understand what udev does.<br />
Besically, udev is there to populate /dev with device files.<br />
That's its primary purpose and that's what it does form 90% of<br />
devices: it merely creates the device files in /dev on<br />
boot/hotplug. It gets /dev very close to the state it was<br />
before, when all the device files were created there statically<br />
by the distribution.<br />
<br />
In some cases, it does a little magic. Like ensuring persistent<br />
network device names, so no matter what network cards you take<br />
out or add into your computer, the ones that stay will keep their<br />
names. Similar thing can be done for disks. Need for this emerged<br />
as the kernel started to probe devices asynchronously, so that<br />
the order in which they are discovered and drivers loaded may<br />
change from boot to boot. Udev is there to handle the result as<br />
consistently as possible.<br />
<br />
But udev is by no means a device driver for anything. Really it<br />
just creates appropriate device files in /dev and assigns network<br />
interface names. Not much else. So don't be afraid of it.<br />
<font color=#550055><br />
> "I'll talk to people at work who work on input drivers whether<br />
> they would like something like this as a kernel driver."<br />
<br />
</font>I just talked to our new input expert (Vojtech is not doing that<br />
so much anymore), and said he would have done it exactly the way<br />
I have. I.e. a userspace program feeding the keypresses into<br />
/dev/input/uinput. There are many different serial devices and it<br />
is much easier adapting a userspace program for a particular<br />
device than having to adapt it in the kernel and having to<br />
recompile it just because of that.<br />
<br />
The reason some serial keyboard drivers are in the kernel already<br />
is that the drivers existed before uinput existed, so it was the<br />
only way to do that. They could easily be taken out of the kernel<br />
and replaced by a userspace program, but it would just make life<br />
mor difficult for people who set their keyboards up already using<br />
the kernel driver.<br />
<font color=#550055><br />
> Whatever the solution, it should be distributed as part of the stock<br />
> GNU/Linux stack, IMHO.<br />
<br />
</font>Well, that's just a matter of packaging it for whatever<br />
distribution you use and pushing it into the distribution.<br />
I might do that for SUSE one day, but hey, it's so trivial it<br />
might not be even worth doing it ;-)<br />
It's good enough for barcode/rfid readers, but maybe not for a<br />
all serial keyboards out there. It would probably be needed to<br />
allow some conditional statements in the config file or something<br />
like that. Not all devices have context-less output - one byte of<br />
output may mean different things depending on the bytes following<br />
or preceeding. My program can not handle that. So maybe one day<br />
someone will write something more generic and more usefult, worth<br />
pushing to all the distributions out there.<br />
<font color=#550055><br />
> (Oh, and pardon my Texas syntax. The Bushes aren't the only Texans who<br />
> mangle English.)<br />
<br />
</font>Hmm, not only do the Bushes mangle English, but they also cause<br />
havoc Prague's traffic ;-) We happen to have G. W. B. visiting<br />
_today_ and half of the city is closed because of that ;-)))<br />
<font color=#888888><br />
<br />
<br />
--<br />
</font><div style='padding:5 0'><font size=1 color=#
</table>
</table>
<hr>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td>
<font size=-1><b>
Jiri Bohac
<jbohac [at some email domain] like suse >
</b></font>
</td>
<td align=right>
<font size=-1><b>
Wed, Aug 8, 2007 at 9:12 AM
</b></font>
<tr>
<td colspan=2>
<font size=-1>
<div>
To:
Loye Young <loye.young [at some email domain] like iycc.net>
</div>
</font>
<tr>
<td colspan=2>
<table width=100% cellpadding=12 cellspacing=0 border=0>
<tr>
<td>
<font size=-1>Hi Loye,<br />
<br />
> Although I am no longer in need of the scanner, it seems that there is a lot<br />
> of interest in the subject. In order to hand over the reins, I have<br />
> registered a project in Launchpad (<a href="http://
> called "serial-
><br />
> With your permission, I would like to post the correspondence between you and<br />
> I, along with your code. Please advise what license you would like the<br />
> package to have. If you would like to take over maintenance of the project, I<br />
> would be toe-tapping happy about that, because I am not the right person for<br />
> the job. However, if you are unable to take over, I will oversee the project<br />
> until it gets on its feet independently.<br />
<br />
Sure, you can do anything with the code and you can post the<br />
correspondence anywhere.<br />
<br />
The code (and the config file are available from:<br />
<a href="http://
and<br />
<a href="http://
<br />
As you've seen already, it's really simple. The license is "GPL2<br />
or newer". Althought it can be useful as is, it is leiterallily a<br />
couple of lines of code (except the key table copied from<br />
somewhere else), so anyone who will want to extend it may well<br />
prefer to start from scratch.<br />
<br />
<br />
Regards,<br />
<div style='padding:5 0'><font size=1 color=#
</table>
</table>
<hr>