On Dec 22, 2008, at 3:23 AM, Bill Maas wrote:
>
> On Mon, 2008-12-22 at 10:11 +0800, David Schulz wrote:
>> On Wed, Dec 17, 2008 at 08:25:19PM -0500, Jed Clear wrote:
>>> On Tue Dec 16 22:49 , David Schulz sent:
>>>> I recently purchased 2 net4801 that now run OpenBSD 4.4 Release.
>>>> I attached a USB Keyboard to the USB Port.
>>>>
>>>> In my dmesg, the USB Keyboard gets attached to /dev/wskbd1
>>>>
>>>> I want to automatically run a Program at boot that logs and
>>>> processes Keyboard
>>>> Input. How can i get to the Keyboard Input made on a USB Keyboard
>>>> that i
>>>> attached to my Soekris USB Port? Means: How can i capture
>>>> whatever is entered
>>>> on the USB Keyboard, so i can use it in my program?
>>>>
>>>> Here is a hypothetical Perl Program that takes Input and writes
>>>> it to a file.
>>>> I am aware that noone will see the print Statements when there is
>>>> no screen,
>>>> they are just for examples sake when i run this from a ssh session:
>>>>
>>>>
>>>> #!/usr/bin/perl
>>>>
>>>> use strict;
>>>> use warnings;
>>>>
>>>> open(my $fh, '>', '/var/log/reader.log') or die $!;
>>>>
>>>> while ('TRUE') {
>>>> print "Enter ID :";
>>>> chomp(my $id = <STDIN>);
>>>> print $fh " You entered $id\n";
>>>> if ($id eq 'exit') {
>>>> print "Exiting\n";
>>>> close($fh);
>>>> exit;
>>>> }
>>>> }
>>>>
>>>>
>>>> The above will not work for me, because when the Machine is running
>>>> unattended, there is noone who logged in, the Program wouldn't
>>>> know where to
>>>> take the input from. I need to somehow make my Program read
>>>> directly
>>>> from the Keyboard Device Entry, and take its Input from there.
>>>
>>> You're on the right track. You need to be reading from that
>>> keyboard, not
>>> standard in. My Perl is very rusty, but you need to either remap
>>> STDIN to
>>> /dev/wskbd1, or just open the keyboard device as a file and read
>>> from that file
>>> handle. I'd probably go with the latter. Either way I think you
>>> need Perl's
>>> "open" function. If you don't have a Camel or Llama handy, google
>>> for perldocs.
>>>
>>> The other problem is how to run it unattended. Unix gives you
>>> many ways to do
>>> this, including: cron, boot RC scripts, /etc/inittab, and /dev/
>>> ttys. The latter
>>> has traditionally dealt with terminals. I'm more familiar with
>>> FreeBSD and
>>> SunOS, so YMMV with OpenBSD as to the exact file used for those.
>>>
>>>> Can anyone
>>>> help me out, it would be great. I hope i have been concise but
>>>> clear with my
>>>> Problem.
>>>
>>> Works for me. A lot better than one frequently gets on other
>>> forums.
>>>
>>> -Jed
>>> _______________________________________________
>>> Soekris-tech mailing list
>>> [email protected]
>>> http://lists.soekris.com/mailman/listinfo/soekris-tech
>>>
>>> !DSPAM:4949a729675011436264198!
>>>
>>>
>>
>> Hi,
>>
>> there are a couple ways to start the program unattended, my main
>> problem is
>> still the 'binding' to the keyboard device. In my example Code i am
>> trying to
>> basically open the /dev/wskbd1 as a file and read from it, but i
>> only get
>> garbled characters. The reason would be that the Keyboard doesnt
>> send a
>> literal A when i hit the letter 'A', but instead some ascii code
>> that has to
>> be translated by the Operating System before it is output on my
>> screen.
>>
>> If anyone can share his ideas on how to read from a USB Keyboard
>> that is
>> attached to the Soekris-4801 USB Port, please share.
>>
>> Thanks and best regards,
>> David
>
> Hi David,
>
> I'm not a Perl programmer, but shouldn't the links below at least give
> you something to start with?
>
> (terminal handling / raw input mode)
> http://docstore.mik.ua/orelly/perl/cookbook/ch15_07.htm
>
> (input char mapping)
> http://perldoc.perl.org/functions/chr.html
>
> Hope that these are not telling you things you already knew. In any
> case, "keymap" would be the first thing I'd look for here.
>
> Bill
FWIW i used the following to accomplish what you wanted.
It was designed for a very narrow purpose and may not do what you want
exactly, it did work great for me for its purpose (which is possibly
obvious from the code) on OpenBSD :)
http://adam.gs/c/ukbd.txt
-Adam
_______________________________________________
Soekris-tech mailing list
[email protected]
http://lists.soekris.com/mailman/listinfo/soekris-tech