Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8437 > unrolled thread

reading from HID keyboard

Started byben@bbarker.co.uk
First post2013-02-22 09:15 -0800
Last post2013-02-22 16:21 -0800
Articles 4 — 2 participants

Back to article view | Back to comp.lang.php


Contents

  reading from HID keyboard ben@bbarker.co.uk - 2013-02-22 09:15 -0800
    Re: reading from HID keyboard Anders Wegge Keller <wegge@wegge.dk> - 2013-02-22 21:45 +0100
      Re: reading from HID keyboard ben@bbarker.co.uk - 2013-02-22 14:29 -0800
        Re: reading from HID keyboard ben@bbarker.co.uk - 2013-02-22 16:21 -0800

#8437 — reading from HID keyboard

Fromben@bbarker.co.uk
Date2013-02-22 09:15 -0800
Subjectreading from HID keyboard
Message-ID<d4ab77b3-5958-4c09-be1b-0b9cab2c4bb0@googlegroups.com>
Hi,
I have a device that appears to my machine as a HID keyboard (though actually it is an RFID reader) 

I can read from it locally in php by using fopen("php://stdin",r)

The problem is if I shell into this machine via ssh, then stdin comes from the remote keyboard, not from the local HID device, and the above does not return any data.

I can read from /dev/input/by-id/<my device>

But this returns a very large number of bytes that it is not immediately obvious how to decode

Can anyone suggest a way forward here? 

[toc] | [next] | [standalone]


#8443

FromAnders Wegge Keller <wegge@wegge.dk>
Date2013-02-22 21:45 +0100
Message-ID<87a9qwoz6h.fsf@huddi.jernurt.dk>
In reply to#8437
ben@bbarker.co.uk writes:

> Hi,
> I have a device that appears to my machine as a HID keyboard (though actually it is an RFID reader) 
> 
> I can read from it locally in php by using fopen("php://stdin",r)
> 
> The problem is if I shell into this machine via ssh, then stdin comes from the remote keyboard, not from the local HID device, and the above does not return any data.
> 
> I can read from /dev/input/by-id/<my device>
> 
> But this returns a very large number of bytes that it is not immediately obvious how to decode
> 
> Can anyone suggest a way forward here? 

 It's hard to say without further information, but hazarding a guess,
you are reading raw keyboard scan codes in the latter case. If I was
in your situation, I'd look at the documentation for the device in
question, and take it from there. If your documentation is lacking,
try to look at the table of PS2 scan codes, and see if they match up
with your input.

http://www.computer-engineering.org/ps2keyboard/scancodes2.html

-- 
/Wegge

Leder efter redundant peering af dk.*,linux.debian.*

[toc] | [prev] | [next] | [standalone]


#8446

Fromben@bbarker.co.uk
Date2013-02-22 14:29 -0800
Message-ID<fc21a58b-66aa-4d1b-9862-d9da4a2641b6@googlegroups.com>
In reply to#8443
> 
> 
> 
> > Hi,
> 
> > I have a device that appears to my machine as a HID keyboard (though actually it is an RFID reader) 
> 
> > 
> 
> > I can read from it locally in php by using fopen("php://stdin",r)
> 
> > 
> 
> > The problem is if I shell into this machine via ssh, then stdin comes from the remote keyboard, not from the local HID device, and the above does not return any data.
> 
> > 
> 
> > I can read from /dev/input/by-id/<my device>
> 
> > 
> 
> > But this returns a very large number of bytes that it is not immediately obvious how to decode
> 
> > 
> 
> > Can anyone suggest a way forward here? 
> 
> 
> 
>  It's hard to say without further information, but hazarding a guess,
> 
> you are reading raw keyboard scan codes in the latter case. If I was
> 
> in your situation, I'd look at the documentation for the device in
> 
> question, and take it from there. If your documentation is lacking,
> 
> try to look at the table of PS2 scan codes, and see if they match up
> 
> with your input.
> 
> 
> 
> http://www.computer-engineering.org/ps2keyboard/scancodes2.html
> 
> 
> 
> -- 
> 
> /Wegge
> 
> 
> 
> Leder efter redundant peering af dk.*,linux.debian.*

Ah - a useful little program fro the repositories call "evtest" has helped sort things out. 

It seems that the data consists of a series of bytes, and for every key press/ character generated there are 8 bytes produced

Event: time 1361571412.662329, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70027
Event: time 1361571412.662343, type 1 (EV_KEY), code 11 (KEY_0), value 1

Interspersed with 

Event: time 1361571412.688401, -------------- SYN_REPORT ------------

It should be fairly easy to decode now :-)


[toc] | [prev] | [next] | [standalone]


#8447

Fromben@bbarker.co.uk
Date2013-02-22 16:21 -0800
Message-ID<f80d9976-db5d-4732-ab42-2a2df0192959@googlegroups.com>
In reply to#8446
On Friday, 22 February 2013 22:29:01 UTC, b...@bbarker.co.uk  wrote:
> > 
> 
> > 
> 
> > 
> 
> > > Hi,
> 
> > 
> 
> > > I have a device that appears to my machine as a HID keyboard (though actually it is an RFID reader) 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > I can read from it locally in php by using fopen("php://stdin",r)
> 
> > 
> 
> > > 
> 
> > 
> 
> > > The problem is if I shell into this machine via ssh, then stdin comes from the remote keyboard, not from the local HID device, and the above does not return any data.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > I can read from /dev/input/by-id/<my device>
> 
> > 
> 
> > > 
> 
> > 
> 
> > > But this returns a very large number of bytes that it is not immediately obvious how to decode
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Can anyone suggest a way forward here? 
> 
> > 
> 
> > 
> 
> > 
> 
> >  It's hard to say without further information, but hazarding a guess,
> 
> > 
> 
> > you are reading raw keyboard scan codes in the latter case. If I was
> 
> > 
> 
> > in your situation, I'd look at the documentation for the device in
> 
> > 
> 
> > question, and take it from there. If your documentation is lacking,
> 
> > 
> 
> > try to look at the table of PS2 scan codes, and see if they match up
> 
> > 
> 
> > with your input.
> 
> > 
> 
> > 
> 
> > 
> 
> > http://www.computer-engineering.org/ps2keyboard/scancodes2.html
> 
> > 
> 
> > 
> 
> > 
> 
> > -- 
> 
> > 
> 
> > /Wegge
> 
> > 
> 
> > 
> 
> > 
> 
> > Leder efter redundant peering af dk.*,linux.debian.*
> 
> 
> 
> Ah - a useful little program fro the repositories call "evtest" has helped sort things out. 
> 
> 
> 
> It seems that the data consists of a series of bytes, and for every key press/ character generated there are 8 bytes produced
> 
> 
> 
> Event: time 1361571412.662329, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70027
> 
> Event: time 1361571412.662343, type 1 (EV_KEY), code 11 (KEY_0), value 1
> 
> 
> 
> Interspersed with 
> 
> 
> 
> Event: time 1361571412.688401, -------------- SYN_REPORT ------------
> 
> 
> 
> It should be fairly easy to decode now :-)

This was also of much use:
http://stackoverflow.com/questions/5060710/format-of-dev-input-event

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web