Recent

Author Topic: USB HID access on Linux  (Read 17071 times)

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1404
Re: USB HID access on Linux
« Reply #15 on: January 31, 2017, 05:12:41 pm »
Will dive into it. Please stay tuned.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1404
Re: USB HID access on Linux
« Reply #16 on: January 31, 2017, 09:38:00 pm »
I think your mouse is not detected as a real hiddev on Linux.
I guess it shows up as a hidraw device.

Therefor, I have updated the GitRepo to show hidraw.
Please test as previous. I hope that you will succeed this time.

mark

  • New Member
  • *
  • Posts: 11
Re: USB HID access on Linux
« Reply #17 on: January 31, 2017, 10:56:26 pm »
ok, thanks, i will test and let you know. because i also thought it would be a good idea to use something else, i also test with a different hid device.
But that also did not work. It appears that the rule is not executed. But because of being new it is hard to debug/test.
So i first try your update.

mark

  • New Member
  • *
  • Posts: 11
Re: USB HID access on Linux
« Reply #18 on: January 31, 2017, 11:03:56 pm »
Hello DonAlfredo

Now it works  :) :) :)
And the thing : i only had to change the pid/vid in the code. What did you change that fixed it?
Well i can check that of course. I appreciate the help. Now i can continue.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1404
Re: USB HID access on Linux
« Reply #19 on: February 01, 2017, 08:15:55 am »
In usbcontroller.pas, there is
Code: Pascal  [Select][+][-]
  1. {$DEFINE hidraw}
  2. {.$DEFINE hiddev}
These defines allow you to choose !
As you can see, hidraw is defined in your use-case.

mark

  • New Member
  • *
  • Posts: 11
Re: USB HID access on Linux
« Reply #20 on: February 01, 2017, 10:43:49 am »
thanks.
In the mean time I tried a different HID device, made all the changes, but i seem to have the old problem : nothing listed again. It appears that using usb on PI with lazarus is not a walk in the park. This time i tried an usb programmer :
Bus 001 Device 010: ID 03eb:2104 Atmel Corp. AVR ISP mkII

and here is the lsb -vvv
Bus 001 Device 010: ID 03eb:2104 Atmel Corp. AVR ISP mkII
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        16
  idVendor           0x03eb Atmel Corp.
  idProduct          0x2104 AVR ISP mkII
  bcdDevice            2.00
  iManufacturer           1 ATMEL
  iProduct                2 AVRISP mkII
  iSerial                 3 0000A0005627
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              10
Device Status:     0x0001
  Self Powered

the new rules :
pi@raspberrypi:~ $ cat /etc/udev/rules.d/20-usb-rules-by-mark.rules
SUBSYSTEM=="usbmisc", ATTRS{idVendor}=="03eb" ,ATTRS{idProduct}=="2104", MODE="0666"
SUBSYSTEM=="usb",ATTRS{idVendor}=="03eb", ATTRS{idVendor}=="2104", MODE="0666"

KERNEL=="hidraw", SUBSYSTEM=="hidraw", ATTRS{idVendor}="03eb" , MODE="0666"

and i changed the code :
  Vendor                        = $03eb;
  Product                       = $2104;

when it did not work, i also tried with :
{.$DEFINE hidraw}
{$DEFINE hiddev}

But nothing. I was under assumption that all HID devices are the same with respect to jvHidcontroller. Under windows Delphi i use the Tjvhidcontroller for some years and it lists all HID devices. I hope you have some idea since this is a great component when using a PI.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1404
Re: USB HID access on Linux
« Reply #21 on: February 01, 2017, 10:50:36 am »
Look at this:
Code: Pascal  [Select][+][-]
  1. bInterfaceClass       255 Vendor Specific Class

For HID, it should be:
Code: Pascal  [Select][+][-]
  1. bInterfaceClass         3 Human Interface Device

So, its no HID, and will not be detected by this component !

However, for FPC on Linux, you can also use libusb !
That will work with any USB device AFAIK.

mark

  • New Member
  • *
  • Posts: 11
Re: USB HID access on Linux
« Reply #22 on: February 01, 2017, 10:54:03 am »
Aha, you are right. I tested with the wrong device.  I will dig up a home made hid device and test again. Thanks for your help.

mark

  • New Member
  • *
  • Posts: 11
Re: USB HID access on Linux
« Reply #23 on: February 01, 2017, 11:19:25 am »
I retested with a proper HID device and your latest code works perfect  :)
thanks again!

Punkertjenv

  • Newbie
  • Posts: 1
Re: USB HID access on Linux
« Reply #24 on: November 24, 2017, 04:16:28 pm »
Hi DonAlfredo,

I want to thank you for you contribution.
The basics seem to work very well.
However I have a device were it would be feasible from to get/set the hid feature reports.
I altered the code and added a function to do so, but It does not seem te be working.
I'v created a record based on an array of cuint32 that I pass to the fpioctl function, but i don't notice any change in the record.
Did you ever get any luck getting/setting features?

Kind Regards,

N!

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1404
Re: USB HID access on Linux
« Reply #25 on: November 24, 2017, 04:40:54 pm »
To be honest, I only used feature reports on Windows.
And have never tested this on Linux.

If time permits, I will dig into this to get it working on Linux too !

 

TinyPortal © 2005-2018