FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » reading from HID keyboard
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
reading from HID keyboard [message #180503] Fri, 22 February 2013 12:15 Go to next message
Ben Barker is currently offline  Ben Barker
Messages: 5
Registered: October 2011
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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?
Re: reading from HID keyboard [message #180509 is a reply to message #180503] Fri, 22 February 2013 15:45 Go to previous messageGo to next message
Anders Wegge Keller is currently offline  Anders Wegge Keller
Messages: 30
Registered: May 2012
Karma: 0
Member
add to buddy list
ignore all messages by this user
ben(at)bbarker(dot)co(dot)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.*
Re: reading from HID keyboard [message #180512 is a reply to message #180509] Fri, 22 February 2013 17:29 Go to previous messageGo to next message
Ben Barker is currently offline  Ben Barker
Messages: 5
Registered: October 2011
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
>
>
>
>> 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 :-)
Re: reading from HID keyboard [message #180513 is a reply to message #180512] Fri, 22 February 2013 19:21 Go to previous message
Ben Barker is currently offline  Ben Barker
Messages: 5
Registered: October 2011
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: utf8_encode(utf8_decode(string)) doesn't return same string
Next Topic: Re: Where to Find Pipe Information?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Dec 12 18:51:16 EST 2017

Total time taken to generate the page: 0.00684 seconds