OpenWrt Forum Archive

Topic: WR703N - HID device access

The content of this topic has been archived on 16 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'm trying to develop an indoor air quality monitor/logger using a WR703N and a HID air quality monitor. The device is recognised by the system:

-----------------------------------------------------
ATTITUDE ADJUSTMENT (12.09, r36088)
-----------------------------------------------------
  * 1/4 oz Vodka      Pour all ingredients into mixing
  * 1/4 oz Gin        tin with ice, strain into glass.
  * 1/4 oz Amaretto
  * 1/4 oz Triple sec
  * 1/4 oz Peach schnapps
  * 1/4 oz Sour mix
  * 1 splash Cranberry juice
-----------------------------------------------------
root@OpenWrt:~# dmesg | grep hid
[   31.570000] generic-usb 0003:03EB:2013.0001: hiddev0: USB HID v1.11 Device [AppliedSensor iAQ Stick] on usb-ehci-platform-1/input0
[   31.580000] usbcore: registered new interface driver usbhid
[   31.590000] usbhid: USB HID core driver
root@OpenWrt:~#

What I've read suggests that I could use a Lua script to read HID reports from the device.  I have no experience in developing such scripts and would appreciate any guidance/advice to at least get started.  Are there alternative ways to read reports from HID devices?

Does the file "/dev/usb/hiddev0" contain HID reports or information on how to access them? I've tried opening it but to no avail.

I would install triggerhappy

Look in /etc/triggerhappy for guidande in the conf file
From there You can trigger actions depending on hid input

(Last edited by rullbandspelare on 11 May 2013, 16:04)

I've installed triggerhappy and can list supported eventcodes with "thd --listevents". However using an alternative command to list eventcodes I get the following:

root@OpenWrt:~# thd --dump /dev/input/event*
Error opening '/dev/input/event*': No such file or directory

According to http://h-wrt.com/en/doc/kb:

We also check if a corresponding device has been created:
root@OpenWrt:/# ls /dev/input/*
/dev/input/event0 /dev/input/event1

which suggests to me that the device has not been created.

I've checked the file system with WinSCP to confirm that "/dev/input" does not exist.

I don't understand why the directory in question is missing and how critical it is.

I'd appreciate comments/advice.

I'm not sure how what you are doing is supposed to work, but your "ls" statement shows two devices in the /dev/input directory--event0 and event1.  What happens if you do "thd --dump /dev/input/event0" or "thd --dump /dev/input/event1"?

Perhaps you could provide a little explanation of what should be happening.

lizby wrote:

What happens if you do "thd --dump /dev/input/event0" or "thd --dump /dev/input/event1"?

This is what happens:

root@OpenWrt:~# thd --dump /dev/input/event0
Error opening '/dev/input/event0': No such file or directory

The "ls" output I quoted in my previous post was taken verbatim from the link http://h-wrt.com/en/doc/kb which was provided by robthebrew in a previous post.

Using the same "ls" command on my system I get (as expected):

ls: /dev/input/*: No such file or directory

The reading I've done implies that there should be a "/dev/input" directory once the device has connected successfully.  I'm wondering why I don't seem to have such a directory despite other indications that the device has connected and is recognised - for example: 

root@OpenWrt:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 03eb:2013 Atmel Corp.

and

root@OpenWrt:~# lsusb -d 03eb:2013 -v
Bus 001 Device 002: ID 03eb:2013 Atmel Corp.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        32
  idVendor           0x03eb Atmel Corp.
  idProduct          0x2013
  bcdDevice           10.00
  iManufacturer           1 AppliedSensor
  iProduct                2 iAQ Stick
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      53
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval              10
Device Status:     0x0000
  (Bus Powered)

If You dont get any input device in /dev, then im not sure that OpenWRT supports the HID device.
Have You installed all the usb hid Components with opkg? kmod-usb-hid?
Take a look at http://h-wrt.com/en/doc/kb
Try with at USB mouse and see if "thd --dump /dev/input/event*" works.
If it does , then try to see what device is created in /dev when You connect Your HID device.

sometimes a USB hub is required!!!

(Last edited by rullbandspelare on 12 May 2013, 23:55)

rullbandspelare wrote:


Try with at USB mouse and see if "thd --dump /dev/input/event*" works.

I connected a USB trackball and the USB air quality monitor via a USB 2.0 high speed hub (480 Mbps) and now have a "/dev/input" directory:

root@OpenWrt:~# ls /dev/input/*
/dev/input/event0

I've confirmed that trackball button press events are being captured:

root@OpenWrt:~# thd --dump /dev/input/event0
EV_KEY  BTN_RIGHT       1       /dev/input/event0
# BTN_RIGHT     1       command
EV_KEY  BTN_RIGHT       0       /dev/input/event0
# BTN_RIGHT     0       command
EV_KEY  BTN_LEFT        1       /dev/input/event0
# BTN_LEFT      1       command
EV_KEY  BTN_LEFT        0       /dev/input/event0
# BTN_LEFT      0       command
EV_KEY  BTN_MIDDLE      1       /dev/input/event0
# BTN_MIDDLE    1       command
EV_KEY  BTN_MIDDLE      0       /dev/input/event0
# BTN_MIDDLE    0       command


rullbandspelare wrote:

.....then try to see what device is created in /dev when You connect Your HID device.

When I connect the air quality device the file "hiddev0" is created in "/dev/usb".

I've tried:

root@OpenWrt:~# thd --dump /dev/usb/hiddev0
Device /dev/usb/hiddev0 not suitable.

I'm at loss of what to try next - any advice?

kmod-hid-generic must be selected for buttons on USB devices to work in trunk. I was able to use the buttons on my USB sound card this way.

The discussion might have continued from here.