Forum > General

FPC-HID-USB ReadFile ok on Windows, not working on Linux

(1/3) > >>

BobT:
I am working on a Lazarus USB HID application ,which will eventually be a port of an existing Delphi 7 PIC bootloader application to be built in Linux (MX Linux 19.2 currently) for crossplatform use.

As a first step I am looking at the FPC-USB-HID demo application. I can build this ok and by adjusting the Vendor and product ID's my device checks out in both Linux and W7 builds. Manufacturer and Product description strings are read OK, but I'm running into problems when I try to use the HidReadWrite function to send a single byte command to my target device bootload firmware and read the response data. Building from the same source files and configuration on the same hardware, on Windows HidReadWrite works as expected, with the correct data being returned in Ctrl.LocalData. On Linux the read phase hangs for a few seconds, and eventually LocalData is populated with a few 1's rather than the expected values. (Using OnData gives a timeout error). Debugging of the target device shows it is receiving and responding to the Linux system command as normal, and Wireshark shows exactly the same expected data in the payload of the returned packet on both o/s.

Any suggestions gratefully received.

DonAlfredo:
Does the device have the correct permission on Linux ?
https://github.com/LongDirtyAnimAlf/FPC-USB-HID/blob/master/udev_rules/10-usbhid.rules

MarkMLl:
I think the critical question here is 32- or 64-bit, and for that matter the kernel version and platform.

I can't help with FPC-USB-HID specifically, but I've got a vague recollection of looking at HID handling at some point using direct kernel access and finding that there were data structures etc. where alignment was absolutely critical. Hence the importance of being absolutely clear about your system, in case it's something that FPC-USB-HID hasn't been explicitly tested against.

MarkMLl

DonAlfredo:
FPC-USB-HID is used (by me) on a daily base on RPi. So, it is tested. But not on ARM64.
However. Its not trivial stuff. So you might be correct.

MarkMLl:
I'm having to scrape my memory here. I was probably tinkering on Debian x86_64, and eventually I concluded that the data structures were sufficiently tricky that the only safe way to do it was to use libraries supplied as one of the extension kernel projects i.e. compiled using the standard kernel tools.

I think that what I was doing was investigating whether an older program that controlled a Logitech gaming mouse (i.e. to customise buttons etc.) could be generalised.

But getting access properly defined in the udev rules is obviously critically important, particularly if a GUI program is involved.

MarkMLl

Navigation

[0] Message Index

[#] Next page

Go to full version