[fpc-pascal] USB Human Interface Devices

James Richters james at productionautomation.net
Tue Aug 20 00:48:00 CEST 2019


I'm trying to get this to work with libusboop.pas but I'm getting a compiler error I don't really know how to fix:

157  Constructor TSNAPIDevice.Create(idVendor, idProduct: LongInt; AConfig, AInterface, AAltInterface: LongInt);
158  Var Intf : Plibusb_interface_descriptor;
159  Begin
160    inherited Create(idVendor,idProduct,AConfig);
161    { create USB interface }
162    Intf := TLibUsbDevice.FindInterface(AInterface,AAltInterface,FDevice); { better: search for iInterface = "SNAPI Command Interface" }
163    FSNAPICommandInterface := TLIBUSBPseudoHIDInterface.Create(Self,Intf);
164    FSNAPICommandInterface.OnIntrReport := @IntrReport;
165  End;

First compilation of i:\programming\pas-libusb_test_dll\src\examples\snapi.pas
snapi.pas(160,28) Error: Incompatible type for arg no. 1: Got "LongInt", expected "TLibUsbContext"
snapi.pas(162,72) Error: Wrong number of parameters specified for call to "FindInterface"
libusboop.pas(911,24) Error: Found declaration: FindInterface(TLibUsbInterfaceMatchMethod):^libusb_interface_descriptor;
libusboop.pas(943,24) Error: Found declaration: FindInterface(TLibUsbInterfaceMatchClass;Boolean=`TRUE`):^libusb_interface_descriptor;
libusboop.pas(958,24) Error: Found declaration: FindInterface(TLibUsbInterfaceMatchFunc;Pointer):^libusb_interface_descriptor;
libusboop.pas(981,24) Error: Found declaration: FindInterface(Byte;Byte):^libusb_interface_descriptor;
libusboop.pas(991,24) Error: Found declaration: FindInterface:^libusb_interface_descriptor;
snapi.pas(432) Fatal: There were 7 errors compiling module, stopping
snapi.pas(0) Fatal: Compilation aborted

I've put my attempt on my repository in the TEST branch here: https://github.com/Zaaphod/pas-libusb/blob/Test/src/examples/snapi.pas

I don't really understand how this inherited stuff and constructors and all that works.. but I figure if I get snapi.pas to compile correctly with libusboop.pas then I will have an example of how to create the TLIBUSBPseudoHIDInterface for my device... but maybe I need to do it completely differently than this?    Sorry I'm so confused.

James



More information about the fpc-pascal mailing list