[fpc-pascal] USB Human Interface Devices

James Richters james at productionautomation.net
Sat Aug 17 15:00:49 CEST 2019


I’m trying to figure out why I get an access violation when I try to open my device with pas-libusb but it works with libusbxhid  they both are using libusb-1.0.dll

 

I put a bunch of hacks into pas-libusb to try to figure it out… just a lot of writeln’s so I can try to track down exactly what’s happening.  Because if I try to trace through the program I get “Program received signal SIGSEGV  Segmentation fault” before I get to the problem

 

I put this in a branch here:

 

https://github.com/Zaaphod/pas-libusb/tree/Hack/src

 

I’m using testopendevic_vidpid2.pas to test it with.  

 

Here’s my output:

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

H1

I

4

Cousldn't connect to device: Access violation

 

 

 

Here’s as far as I could get….

(**

* Find endpoint according to MatchFunc

*

* @param MatchFunc  method to compare a given endpoint descriptor with a

*                   criterion

*

* @returns endpoint or Nil

*)

Function TLibUsbInterface.FindEndpoint(MatchFunc : TLibUsbEndpointMatchMethod) : Plibusb_endpoint_descriptor;

Var IEP : Integer;

    ED  : Plibusb_endpoint_descriptor;

Begin

   writeln('H',FInterface^.bNumEndpoints);

  For IEP := 0 to FInterface^.bNumEndpoints-1 do

    Begin

    Writeln('I');

      ED:= @(FInterface^.endpoint^[IEP]);

      if MatchFunc(ED) then

        Begin

           Writeln('J');

           Exit(ED);

        End

      else

       Writeln('K');

    End;

  Result := Nil;

End;

MatchFunc(ED) is where the access violation occurs, but I can’t trace any further because I can’t find the function MatchFunc()   I just don’t understand where the actual function is.

 

Maybe I made an error in the way I’m trying to open the device?   It can’t be any problem with the device itself or using libusb-1.0.dll because that is all working with libusbxhid.. in fact I have all inputs from my device mapped out.. Still don’t have the LCD working…. I can just use libusbxhid, but this is bugging me and I wanted to try to figure out what’s going on.

 

 

James

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20190817/569fee49/attachment.html>


More information about the fpc-pascal mailing list