[fpc-pascal] USB Human Interface Devices

Johann Glaser Johann.Glaser at gmx.at
Mon Aug 19 21:09:47 CEST 2019


Hi!

Am Sonntag, den 18.08.2019, 10:43 -0400 schrieb James Richters:
> I just pushed it.

Sorry for the delayed reply.

After comparing the exception stack trace you've sent (see below) and
your code, the access violation happens at
https://github.com/Zaaphod/pas-libusb/blob/Hack/src/libusboop.pas#L1330
. The code dereferences the parameter AEndpoint.

Most probably it is however Nil, because the preceding
FInterface.FindEndpoint(EP_IN) in
https://github.com/Zaaphod/pas-libusb/blob/Hack/src/examples/mydevice.pas#L143
didn't find that endpoint.

As I've written, TMyDevice is NOT a generic device! It is specific for
EZ-USB chips. You really should create your own class descending from
TLibUsbDevice (instead of TLibUsbDeviceWithFirmware).

In your constructor, you have to get a reference to the HID interface
of your device, e.g., by
  TLibUsbPseudoHIDInterface.Create(...)
analogous to
https://github.com/Zaaphod/pas-libusb/blob/Hack/src/examples/mydevice.pas#L141
.

This internally also gets references to the necessary endpoints,
therefore you most probably don't need manual FInterface.FindEndpoint()
(like TMyDevice).

Please see snapi.pas, which I've sent you on 2019-08-10. This does
exactly that. I've sent this file specifically that you use it instead
of mydevice.pas.

Bye
  Hansi


> > Could you please "git push" the source code to Github so that the
> > line numbers match the output? At least in line 1330 of
> > libusboop.pas there is no Create. Please ensure that the
> > version on Github is the very same version where you executed the
> > program and got the line numbers.
>
> Thanks
>   Hansi
>
> > Running "i:\programming\pas-
> > libusb_test_dll\src\examples\testopendevic_vidpid2.exe "
> > start
> > 1
> > 2
> > a05472131
> > a10CEEB93
> > b
> > c
> > FALSE  8086  10CE  A36D  EB93
> > FALSE  8087  10CE  0AAA  EB93
> > FALSE  0424  10CE  2734  EB93
> > FALSE  1D50  10CE  6015  EB93
> > FALSE  1B1C  10CE  0C15  EB93
> > TRUE  10CE  10CE  EB93  EB93
> > FALSE  05E3  10CE  0610  EB93
> > FALSE  04E8  10CE  61F5  EB93
> > FALSE  1B1C  10CE  0C10  EB93
> > FALSE  0424  10CE  274C  EB93
> > FALSE  047D  10CE  1020  EB93
> > FALSE  1B1C  10CE  1B4F  EB93
> > FALSE  1A40  10CE  0101  EB93
> > FALSE  0C45  10CE  7403  EB93
> > FALSE  10C4  10CE  EA60  EB93
> > d
> > e
> > N
> > P
> > L
> > H1
> > I
> > I2
> > Q
> > R
> > K
> > M
> > O1
> > An unhandled exception occurred at $000000010002D0BB:
> > EAccessViolation: Access violation
> >   $000000010002D0BB  CREATE,  line 1330 of libusboop.pas
> >   $000000010002B3AB
> >   $0000000100001942  main,  line 75 of ../../pas-
> > libusb_test_dll/src/examples/testopendevic_vidpid2.pas
> >   $0000000100001AF6  main,  line 96 of ../../pas-
> > libusb_test_dll/src/examples/testopendevic_vidpid2.pas
> >   $0000000100010040
> >   $00000001000017F0
> >   $00007FFB66D07E94
> >   $00007FFB675FA251
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list