Go Down

Topic: Using USB Keyboard (Read 20292 times) previous topic - next topic

Techniker

I need to use a keyboard for the application I'm developing. The keyboard is used to be connected to the USB-Host. Later it will be replaced by a laser scanner.
So I plugged the keyboard in, got the PnP-Event:
Code: [Select]
[  139.540000] usb 1-1.1: new low-speed USB device number 4 using ehci-platform
[  139.670000] usb 1-1.1: New USB device found, idVendor=0a81, idProduct=0103
[  139.680000] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  139.680000] usb 1-1.1: Product: USB Keyboard
[  139.680000] usb 1-1.1: Manufacturer: CHESEN

tried to hook the input events, but there is only /dev/input/event0 available. Shouldn't the USB device be listed there? I am not very familiar with linux. So I would be happy if someone would explain how to map the keyboard to linino so it can be used.
My second question would be whats the best way to forward the input events to my sketch? I can't use the serial terminal because it conflicts with my TFT...

sonnyyu

#1
Dec 30, 2013, 06:37 pm Last Edit: Dec 30, 2013, 06:47 pm by sonnyyu Reason: 1
THe USB HID and HID RAW  support at trunk is broken.

HID RAW might needed for Laser Scanner, Magnetic Stripe Reader...

Gernby

Do you have an LCD connected to the serial pins on the Yun?  If so, doesn't that interfere with the bridge between the Arduino and Linino? 

I am trying to get an LCD working with my Yun, and think the best way to do it will be to connect it to the USB host on the Linino, then use the Bridge to communicate between the LCD and Arduino sketch.  I would think you should be able to do the same thing with the keyboard.

Techniker


Do you have an LCD connected to the serial pins on the Yun?  If so, doesn't that interfere with the bridge between the Arduino and Linino? 

It does indeed. But the problem with the USB HID is another. It seems that OpenWRT doesn't support low speed USB devices. I'll try to connect a PS/2 keyboard next, using the PS2Keyboard lib. I hope that a future patch for LININO will fix the USB problem.

I am trying to get an LCD working with my Yun, and think the best way to do it will be to connect it to the USB host on the Linino, then use the Bridge to communicate between the LCD and Arduino sketch.  I would think you should be able to do the same thing with the keyboard.


I had the same problem with my TFT. You can't use Pin 0 and 1:
http://forum.arduino.cc/index.php?topic=206923.0

federicofissore


THe USB HID and HID RAW  support at trunk is broken.

HID RAW might needed for Laser Scanner, Magnetic Stripe Reader...


sonnyyu, do you have a link to share or it's your direct experience?

sonnyyu



THe USB HID and HID RAW  support at trunk is broken.

HID RAW might needed for Laser Scanner, Magnetic Stripe Reader...


sonnyyu, do you have a link to share or it's your direct experience?


I compile new module of kmod-hid-generic and recompile kmod-hid with HID RAW  support.
Here are the links.

https://drive.google.com/file/d/0B49lSur2AThlQ1NnX1hzWFV6UEE/edit?usp=sharing
https://drive.google.com/file/d/0B49lSur2AThleW04WHNqRDc2S0E/edit?usp=sharing

Code: [Select]
opkg update
opkg install kmod-input-core
opkg install  kmod-input-evdev
rm /tmp/opkg-lists/*; opkg install kmod-hid_3.8.3-1_ar71xx.ipk
opkg install kmod-hid-generic_3.8.3-1_ar71xx.ipk
opkg update
opkg install kmod-usb-hid


Code: [Select]
insmod  hid-generic
echo "hid-generic" >>/etc/modules.d/62-hid-generic
cat /dev/input/event1  | hexdump


Code: [Select]
0000000 52c8 f605 0002 118a 0004 0004 0007 0004
0000010 52c8 f605 0002 118a 0001 001e 0000 0001
0000020 52c8 f605 0002 118a 0000 0000 0000 0000
0000030 52c8 f605 0003 e636 0004 0004 0007 0004
0000040 52c8 f605 0003 e636 0001 001e 0000 0000
0000050 52c8 f605 0003 e636 0000 0000 0000 0000
0000060 52c8 f606 000c 140f 0004 0004 0007 0005
0000070 52c8 f606 000c 140f 0001 0030 0000 0001
0000080 52c8 f606 000c 140f 0000 0000 0000 0000
0000090 52c8 f606 000d 8b0e 0004 0004 0007 0005
00000a0 52c8 f606 000d 8b0e 0001 0030 0000 0000
00000b0 52c8 f606 000d 8b0e 0000 0000 0000 0000
00000c0 52c8 f608 000e 468b 0004 0004 0007 0006
00000d0 52c8 f608 000e 468b 0001 002e 0000 0001
00000e0 52c8 f608 000e 468b 0000 0000 0000 0000
00000f0 52c8 f609 0000 b9ca 0004 0004 0007 0006
0000100 52c8 f609 0000 b9ca 0001 002e 0000 0000
0000110 52c8 f609 0000 b9ca 0000 0000 0000 0000


Above is keyboard input "abc"

federicofissore

I googled around but I couldn't find neither openwrt forum topics or anything else related. Do you have some links to share?

sonnyyu

I couldn't find neither at openwrt, I did hardway use up stream OS of Openwrt , at Debian I setup working case.
lsmod
Code: [Select]
hid_generic            12540  0
usbhid                 47346  0
hid                   105826  2 hid_generic,usbhid


Now I know I need hid_generic, then read through openwrt source and linino source code. fix the bug and recompile.




thomas-c

Thank you sonnyyu.  I was working towards compiling this and this was the info I had come across:
https://dev.openwrt.org/ticket/12631  (to add hid-generic - see patchwork url at the end)
https://dev.openwrt.org/ticket/11145  (to add hid raw)
http://h-wrt.com/en/doc/kb  (general usb keyboard info for openwrt)

Not sure if this is the correct way, but I was modifying these files:
~/linino/trunk/package/kernel/modules/001-depends.mk  (to add +kmod-hid-generic)
~/linino/trunk/package/kernel/modules/input.mk  (to add CONFIG_HIDRAW=y)

Thanks again.

snooops

Hi thomas-c is it possible for you to supply your new kernel/firmware here?

sonnyyu

I am second one need new kernel/firmware source as well.

thomas-c

Thanks again sonnyyu for providing the kmod-hid-generic and kmod-hid module install packages above.  My USB keyboard (/dev/input/eventX) and HID RAW (/dev/hidrawX) devices are now visible for use.

Sorry, I only have access to the same public precompiled binaries/firmware that are located at download.linino.org where our Yun's web panel OPKG-Configuration (/etc/opkg.conf) is configured to point to.

Tunell

Anybody have any code to access the USB HID on the Yun for a keyboard?
Not sure how to expose the keystrokes to my sketch.

snooops

Im compiling right now a new kernel with usb hid for /dev/input/eventx support. After its finished i post here the results.

snooops

Update:
im running to an error during compile i dont know how to fix, maybe someone can help:
Code: [Select]
/home/dennis/storage/kernelbuilder/linino/trunk/scripts/download.pl "/home/dennis/storage/kernelbuilder/linino/trunk/dl" "cpu-mcu-bridge-1.1.0.tar.bz2" "afa194cf16a3d2b1ca5180f630054ed2" "http://downloads.arduino.cc/"
--2014-01-21 14:43:48--  http://downloads.arduino.cc/cpu-mcu-bridge-1.1.0.tar.bz2
Resolving downloads.arduino.cc (downloads.arduino.cc)... 64.90.32.4, 2607:f298:4:143:acce:55:0:1
Connecting to downloads.arduino.cc (downloads.arduino.cc)|64.90.32.4|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10843 (11K) [application/x-tar]
Saving to: `STDOUT'

100%[=======================================================================================================>] 10,843      --.-K/s   in 0s      

2014-01-21 14:43:49 (69.3 MB/s) - written to stdout [10843/10843]

MD5 sum of the downloaded file does not match (file: 0b877889de3c28601a599f7222ebb1c3, requested: afa194cf16a3d2b1ca5180f630054ed2) - deleting download.

Go Up