USB Human Interface Devices

classic Classic list List threaded Threaded
165 messages Options
1234567 ... 9
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Johann Glaser
Hi!

Just a quick reply while at work, I'll reply to all EMails in the evening.

First of all: Thanks for finding the bug with the index variable I vs. J. I'll fix that in the evening.

Secondly: You are correct, the "EZ-USB" is a specific chip family by Cypress, e.g., AN2131, without Flash/ROM but with SRAM for the firmware. I built a few devices with that chip, therefore I also implemented the Pascal "driver" to download the firmware into the "naked" device. There are also many (old) devices on the marked which use that chip, e.g., the Keil uLink (1st generation).

To understand how USB actually works (endpoints, in and out transfers, control/bulk/interrupt/isochronous transfers, ...), I have learned a lot from the Technical Reference Manual (TRM) of the EZ-USB. Just search for it, there are plenty of sources. Chapter 1 is the interesting one. If you directly search at the Cypress page, they will redirect you to the successor product FX2, but its chapter 1 is nearly identical to that of EZ-USB.

The EZ-USB firmware download is performed with control transfers to EP0. So you can find examples for control transfers in ezusb.pas.

You can find example code for bulk and interrupt endpoints e.g., in https://github.com/hansiglaser/pas-gpib/blob/master/usb/usbtmc.pas.

I can provide more examples in the evening.

Bye
  Hansi

> Gesendet: Freitag, 09. August 2019 um 12:09 Uhr
> Von: "James Richters" <[hidden email]>
> An: "'FPC-Pascal users discussions'" <[hidden email]>
> Betreff: Re: [fpc-pascal] USB Human Interface Devices
>
> Maybe I am going down the wrong path trying to get test_arduino_with_bmp280.pas to work with my device...  I think I am confusing easyusb with easyhid which is what is used to communicate with the device in the python code I am trying to use.  It looks like easyusb is to send firmware to a specific usb device that has no rom in it... and that's not exactly what I'm trying to do...
>
> I'm trying to figure out how to open the device and read data and write data to this device.  Is there an example of how to do that with pas-libusb?
>
> Sorry I am so confused by all this.  I feel like I'm almost to where I will understand things again but I'm just missing something.
>
> James
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Zaaphod
Hi Hansi,
Thanks for the explanation.

Here's the python code I’m trying to port over to FPC:
https://github.com/wolfmanjm/kivy-smoothie-host/blob/master/modules/hb04.py

it uses functions like hid.open, hid.close, hid.read, hid.write, and hid.send_feature_report   I'm trying to figure out how to somehow get similar functions to those in FPC.   Some example of how to perform those kinds of functions would be extremely helpful!

Thank you for your help with this

James


-----Original Message-----
From: fpc-pascal <[hidden email]> On Behalf Of Johann Glaser
Sent: Friday, August 9, 2019 7:17 AM
To: [hidden email]
Subject: Re: [fpc-pascal] USB Human Interface Devices

Hi!

Just a quick reply while at work, I'll reply to all EMails in the evening.

First of all: Thanks for finding the bug with the index variable I vs. J. I'll fix that in the evening.

Secondly: You are correct, the "EZ-USB" is a specific chip family by Cypress, e.g., AN2131, without Flash/ROM but with SRAM for the firmware. I built a few devices with that chip, therefore I also implemented the Pascal "driver" to download the firmware into the "naked" device. There are also many (old) devices on the marked which use that chip, e.g., the Keil uLink (1st generation).

To understand how USB actually works (endpoints, in and out transfers, control/bulk/interrupt/isochronous transfers, ...), I have learned a lot from the Technical Reference Manual (TRM) of the EZ-USB. Just search for it, there are plenty of sources. Chapter 1 is the interesting one. If you directly search at the Cypress page, they will redirect you to the successor product FX2, but its chapter 1 is nearly identical to that of EZ-USB.

The EZ-USB firmware download is performed with control transfers to EP0. So you can find examples for control transfers in ezusb.pas.

You can find example code for bulk and interrupt endpoints e.g., in https://github.com/hansiglaser/pas-gpib/blob/master/usb/usbtmc.pas.

I can provide more examples in the evening.

Bye
  Hansi

> Gesendet: Freitag, 09. August 2019 um 12:09 Uhr
> Von: "James Richters" <[hidden email]>
> An: "'FPC-Pascal users discussions'" <[hidden email]>
> Betreff: Re: [fpc-pascal] USB Human Interface Devices
>
> Maybe I am going down the wrong path trying to get test_arduino_with_bmp280.pas to work with my device...  I think I am confusing easyusb with easyhid which is what is used to communicate with the device in the python code I am trying to use.  It looks like easyusb is to send firmware to a specific usb device that has no rom in it... and that's not exactly what I'm trying to do...
>
> I'm trying to figure out how to open the device and read data and write data to this device.  Is there an example of how to do that with pas-libusb?
>
> Sorry I am so confused by all this.  I feel like I'm almost to where I will understand things again but I'm just missing something.
>
> James
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  [hidden email] https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Johann Glaser
Hi!

Am Freitag, den 09.08.2019, 08:08 -0400 schrieb James Richters:

> Hi Hansi,
> Thanks for the explanation.
>
> Here's the python code I’m trying to port over to FPC:
> https://github.com/wolfmanjm/kivy-smoothie-host/blob/master/modules/hb04.py
>
> it uses functions like hid.open, hid.close, hid.read, hid.write, and
> hid.send_feature_report   I'm trying to figure out how to somehow get
> similar functions to those in FPC.   Some example of how to perform
> those kinds of functions would be extremely helpful!
These hid.open, hid.close, ... functions are all methods of the object
"hid", which was previously assigned to from devices[0] (line 68),
which itself was returned from en.find(), where en is an object of
Enumeration() from the package easyhid.

To communicate with USB HID devices, please peek into the outdated
branch “master” of pas-libust (for legacy libusb-0.1) and open file
src/usb.pas. This is the old analogous to the new libusboop.pas.

It has the class TUSBPseudoHIDInterface which implements basic
communication with USB HID devices.

I've used that for a project with a barcode scanner. Please find
attached the two files snapi.pas (implementing the "standard" SNAPI for
barcode scanners, which is based on USB HID), and
barcodescannersymbolms4407.pas (implementing a few more specific
methods for a Symbol MS4407 barcode scanner). The latter file uses
several units of my project, therefore it will not compile on your
host. It is just to see how to use the SNAPI devices. I release these
files with the same license as libusboop.pas.

Please excuse that these files are still based on the outdated pas-
libusb for the old libusb-0.1. Therefore they would need translation
for the newer libusb-1.0 stuff. Unfortunately I've never head time to
transition the project. Actually you could copy the class
TUSBPseudoHIDInterface (plus the types THIDReport and TIntrReportFunc)
from usb.pas to libusboop.pas and change everything necessary.

At least one difference is that all names change from TUSB* to
TLibUsb*. I'm sure there are more, but I don't know by heart.

Please also excuse that I can’t recall why its just “PseudoHID” and not
a fully-fledged HID. Probably I didn’t implement all HID functions, or
the SNAPI HID interface just isn't registered with descriptor type $21.

This brings me to the second topic, where you got the message
  Unknown descriptor type $21 with length 9
from test2controlsync. That's a HID descriptor (see LIBUSB_DT_HID). It
is just not decoded in test2controlsync.

And finally, the third point regarding the bug with PortPath index.
I've fixed that now and pushed to Github. Thanks for pointing this out!

Thanks
  Hansi

> -----Original Message-----
> From: fpc-pascal <[hidden email]> On Behalf
> Of Johann Glaser
> Sent: Friday, August 9, 2019 7:17 AM
> To: [hidden email]
> Subject: Re: [fpc-pascal] USB Human Interface Devices
>
> Hi!
>
> Just a quick reply while at work, I'll reply to all EMails in the
> evening.
>
> First of all: Thanks for finding the bug with the index variable I
> vs. J. I'll fix that in the evening.
>
> Secondly: You are correct, the "EZ-USB" is a specific chip family by
> Cypress, e.g., AN2131, without Flash/ROM but with SRAM for the
> firmware. I built a few devices with that chip, therefore I also
> implemented the Pascal "driver" to download the firmware into the
> "naked" device. There are also many (old) devices on the marked which
> use that chip, e.g., the Keil uLink (1st generation).
>
> To understand how USB actually works (endpoints, in and out
> transfers, control/bulk/interrupt/isochronous transfers, ...), I have
> learned a lot from the Technical Reference Manual (TRM) of the EZ-
> USB. Just search for it, there are plenty of sources. Chapter 1 is
> the interesting one. If you directly search at the Cypress page, they
> will redirect you to the successor product FX2, but its chapter 1 is
> nearly identical to that of EZ-USB.
>
> The EZ-USB firmware download is performed with control transfers to
> EP0. So you can find examples for control transfers in ezusb.pas.
>
> You can find example code for bulk and interrupt endpoints e.g., in
> https://github.com/hansiglaser/pas-gpib/blob/master/usb/usbtmc.pas.
>
> I can provide more examples in the evening.
>
> Bye
>   Hansi
>
> > Gesendet: Freitag, 09. August 2019 um 12:09 Uhr
> > Von: "James Richters" <[hidden email]>
> > An: "'FPC-Pascal users discussions'" <
> > [hidden email]>
> > Betreff: Re: [fpc-pascal] USB Human Interface Devices
> >
> > Maybe I am going down the wrong path trying to get
> > test_arduino_with_bmp280.pas to work with my device...  I think I
> > am confusing easyusb with easyhid which is what is used to
> > communicate with the device in the python code I am trying to
> > use.  It looks like easyusb is to send firmware to a specific usb
> > device that has no rom in it... and that's not exactly what I'm
> > trying to do...
> >
> > I'm trying to figure out how to open the device and read data and
> > write data to this device.  Is there an example of how to do that
> > with pas-libusb?
> >
> > Sorry I am so confused by all this.  I feel like I'm almost to
> > where I will understand things again but I'm just missing
> > something.
> >
> > James
> > _______________________________________________
> > fpc-pascal maillist  -  [hidden email]
> > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> >
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

barcodescannersymbolms4407.pas (5K) Download Attachment
snapi.pas (18K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Zaaphod
Hi Hansi,

Thanks for the sample programs and information.   I'm going to try to do as you suggest and try to translate to the new libusb-1.0.. I'm not sure I'll understand it enough but it seems like it's heading in the right directions so would be worth a try.

James

-----Original Message-----
From: fpc-pascal <[hidden email]> On Behalf Of Johann Glaser
Sent: Friday, August 9, 2019 7:33 PM
To: [hidden email]
Subject: Re: [fpc-pascal] USB Human Interface Devices

Hi!

Am Freitag, den 09.08.2019, 08:08 -0400 schrieb James Richters:

> Hi Hansi,
> Thanks for the explanation.
>
> Here's the python code I’m trying to port over to FPC:
> https://github.com/wolfmanjm/kivy-smoothie-host/blob/master/modules/hb
> 04.py
>
> it uses functions like hid.open, hid.close, hid.read, hid.write, and
> hid.send_feature_report   I'm trying to figure out how to somehow get
> similar functions to those in FPC.   Some example of how to perform
> those kinds of functions would be extremely helpful!

These hid.open, hid.close, ... functions are all methods of the object "hid", which was previously assigned to from devices[0] (line 68), which itself was returned from en.find(), where en is an object of
Enumeration() from the package easyhid.

To communicate with USB HID devices, please peek into the outdated branch “master” of pas-libust (for legacy libusb-0.1) and open file src/usb.pas. This is the old analogous to the new libusboop.pas.

It has the class TUSBPseudoHIDInterface which implements basic communication with USB HID devices.

I've used that for a project with a barcode scanner. Please find attached the two files snapi.pas (implementing the "standard" SNAPI for barcode scanners, which is based on USB HID), and barcodescannersymbolms4407.pas (implementing a few more specific methods for a Symbol MS4407 barcode scanner). The latter file uses several units of my project, therefore it will not compile on your host. It is just to see how to use the SNAPI devices. I release these files with the same license as libusboop.pas.

Please excuse that these files are still based on the outdated pas- libusb for the old libusb-0.1. Therefore they would need translation for the newer libusb-1.0 stuff. Unfortunately I've never head time to transition the project. Actually you could copy the class TUSBPseudoHIDInterface (plus the types THIDReport and TIntrReportFunc) from usb.pas to libusboop.pas and change everything necessary.

At least one difference is that all names change from TUSB* to TLibUsb*. I'm sure there are more, but I don't know by heart.

Please also excuse that I can’t recall why its just “PseudoHID” and not a fully-fledged HID. Probably I didn’t implement all HID functions, or the SNAPI HID interface just isn't registered with descriptor type $21.

This brings me to the second topic, where you got the message
  Unknown descriptor type $21 with length 9 from test2controlsync. That's a HID descriptor (see LIBUSB_DT_HID). It is just not decoded in test2controlsync.

And finally, the third point regarding the bug with PortPath index.
I've fixed that now and pushed to Github. Thanks for pointing this out!

Thanks
  Hansi

> -----Original Message-----
> From: fpc-pascal <[hidden email]> On Behalf
> Of Johann Glaser
> Sent: Friday, August 9, 2019 7:17 AM
> To: [hidden email]
> Subject: Re: [fpc-pascal] USB Human Interface Devices
>
> Hi!
>
> Just a quick reply while at work, I'll reply to all EMails in the
> evening.
>
> First of all: Thanks for finding the bug with the index variable I vs.
> J. I'll fix that in the evening.
>
> Secondly: You are correct, the "EZ-USB" is a specific chip family by
> Cypress, e.g., AN2131, without Flash/ROM but with SRAM for the
> firmware. I built a few devices with that chip, therefore I also
> implemented the Pascal "driver" to download the firmware into the
> "naked" device. There are also many (old) devices on the marked which
> use that chip, e.g., the Keil uLink (1st generation).
>
> To understand how USB actually works (endpoints, in and out transfers,
> control/bulk/interrupt/isochronous transfers, ...), I have learned a
> lot from the Technical Reference Manual (TRM) of the EZ- USB. Just
> search for it, there are plenty of sources. Chapter 1 is the
> interesting one. If you directly search at the Cypress page, they will
> redirect you to the successor product FX2, but its chapter 1 is nearly
> identical to that of EZ-USB.
>
> The EZ-USB firmware download is performed with control transfers to
> EP0. So you can find examples for control transfers in ezusb.pas.
>
> You can find example code for bulk and interrupt endpoints e.g., in
> https://github.com/hansiglaser/pas-gpib/blob/master/usb/usbtmc.pas.
>
> I can provide more examples in the evening.
>
> Bye
>   Hansi
>
> > Gesendet: Freitag, 09. August 2019 um 12:09 Uhr
> > Von: "James Richters" <[hidden email]>
> > An: "'FPC-Pascal users discussions'" <
> > [hidden email]>
> > Betreff: Re: [fpc-pascal] USB Human Interface Devices
> >
> > Maybe I am going down the wrong path trying to get
> > test_arduino_with_bmp280.pas to work with my device...  I think I am
> > confusing easyusb with easyhid which is what is used to communicate
> > with the device in the python code I am trying to use.  It looks
> > like easyusb is to send firmware to a specific usb device that has
> > no rom in it... and that's not exactly what I'm trying to do...
> >
> > I'm trying to figure out how to open the device and read data and
> > write data to this device.  Is there an example of how to do that
> > with pas-libusb?
> >
> > Sorry I am so confused by all this.  I feel like I'm almost to where
> > I will understand things again but I'm just missing something.
> >
> > James
> > _______________________________________________
> > fpc-pascal maillist  -  [hidden email]
> > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> >
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Zaaphod
In reply to this post by Johann Glaser
I'm making an attempt to copy TUSBPseudoHIDInterface into libusboop.pas.  I've made the recomended name changes and then tried to compile it.  Some things I found like the names changing from things like

PUSBInterfaceDescriptop to Plibusb_interface_descriptor

are pretty obvious, but just taking a guess on other things like:

 changing:
      if (EP.bmAttributes and USB_ENDPOINT_TYPE_MASK = USB_ENDPOINT_TYPE_INTERRUPT) and
         (EP.bEndpointAddress and USB_ENDPOINT_DIR_MASK <> 0) then

To:
      if (EP^.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK = LIBUSB_TRANSFER_TYPE_INTERRUPT) and
         (EP^.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0) then

Based on looking at something similar in libusbutil... but I'm not sure it's right at all.... I'm not sure if USB_ENDPOINT_TYPE_MASK was really changed to LIBUSB_TRANSFER_TYPE_MASK or if something else happened.  But at least it compiles...
but now I've hit a few items that I just don't know what to do with.    I can't find anything similar to get a reference from:

libusboop.pas(1198,28) Error: Identifier not found "USB_TYPE_CLASS"
libusboop.pas(1199,5) Error: Identifier not found "USB_REQ_HID_SET_REPORT"
libusboop.pas(1216,27) Error: Identifier not found "USB_TYPE_CLASS"
libusboop.pas(1217,5) Error: Identifier not found "USB_REQ_HID_GET_REPORT"
libusboop.pas(1227,23) Error: Identifier not found "HID_REPORT_TYPE_OUTPUT"

I've tried things that seem to be in line with other changes, like changing USB_Type_Class to LIBUSB_TYPE_CLASS or spelling out REQUEST instead of REQ which also seems to be done in other places, but still the identifiers are not found... the problem is I have no idea where these identifiers were/are defined.

I made a fork in github and a branch called "test"  here:
https://github.com/Zaaphod/pas-libusb/tree/Test

Any advice is greatly appreciated

James



> Actually you could copy the class TUSBPseudoHIDInterface (plus the types THIDReport and TIntrReportFunc) from usb.pas to libusboop.pas and change everything necessary.

> At least one difference is that all names change from TUSB* to TLibUsb*. I'm sure there are more, but I don't know by heart.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Johann Glaser
Hi!

Am Samstag, den 10.08.2019, 17:50 -0400 schrieb James Richters:
> I'm making an attempt to copy TUSBPseudoHIDInterface into
> libusboop.pas.  I've made the recomended name changes and then tried
> to compile it.  Some things I found like the names changing from
> things like
>
> PUSBInterfaceDescriptop to Plibusb_interface_descriptor

OK, there are two things. Names directly from libusb-1.0 (as used in
libusb.pas) should be identical to the original C code, i.e.,
Plibusb_interface_descriptor as you've written.

The second thing are the classes in the OOP wrapper in libusboop.pas.
Please use CamelCase for them, e.g., TLibusbPseudoHIDInterface.

> are pretty obvious, but just taking a guess on other things like:
>
>  changing:
>       if (EP.bmAttributes and USB_ENDPOINT_TYPE_MASK =
> USB_ENDPOINT_TYPE_INTERRUPT) and
>          (EP.bEndpointAddress and USB_ENDPOINT_DIR_MASK <> 0) then
>
> To:
>       if (EP^.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK =
> LIBUSB_TRANSFER_TYPE_INTERRUPT) and
>          (EP^.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0)
> then

Yes, very good, thanks!

Whether EP is a pointer (--> EP^.bmAttributes) or a record
(EP.bmAttributs) just depends on the usage in the code. As I see in
usb.pas in line 846, in TUSBPseudoHIDInterface.Create, it is actually
the record, so you should stay without the '^'.

> Based on looking at something similar in libusbutil... but I'm not
> sure it's right at all.... I'm not sure if USB_ENDPOINT_TYPE_MASK was
> really changed to LIBUSB_TRANSFER_TYPE_MASK or if something else
> happened.  But at least it compiles...

You translated it correctly.

> but now I've hit a few items that I just don't know what to do
> with.    I can't find anything similar to get a reference from:
>
> libusboop.pas(1198,28) Error: Identifier not found "USB_TYPE_CLASS"

Use LIBUSB_REQUEST_TYPE_CLASS.

> libusboop.pas(1199,5) Error: Identifier not found
> "USB_REQ_HID_SET_REPORT"
> libusboop.pas(1216,27) Error: Identifier not found "USB_TYPE_CLASS"
> libusboop.pas(1217,5) Error: Identifier not found
> "USB_REQ_HID_GET_REPORT"
> libusboop.pas(1227,23) Error: Identifier not found
> "HID_REPORT_TYPE_OUTPUT"

Please copy the constants USB_REQ_HID_* and HID_REPORT_* from
libusb.pas (branch master) lines 248-257 to the interface section of
libusboop.pas (branch libusb-1.0) directly above the class declaration
of TLibusbPseudoHIDInterface. Then please rename USB_REQ_HID_* to
LIBUSB_REQUEST_HID_* and HID_REPORT_* to LIBUSB_HID_REPORT_*.

> I've tried things that seem to be in line with other changes, like
> changing USB_Type_Class to LIBUSB_TYPE_CLASS or spelling out REQUEST
> instead of REQ which also seems to be done in other places, but still
> the identifiers are not found... the problem is I have no idea where
> these identifiers were/are defined.
>
> I made a fork in github and a branch called "test"  here:
> https://github.com/Zaaphod/pas-libusb/tree/Test

Great approach, thanks, then we can use pull requests.

Thanks
  Hansi

> > Actually you could copy the class TUSBPseudoHIDInterface (plus the
> > types THIDReport and TIntrReportFunc) from usb.pas to libusboop.pas
> > and change everything necessary.
> > At least one difference is that all names change from TUSB* to
> > TLibUsb*. I'm sure there are more, but I don't know by heart.
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Zaaphod
Thank you for the help.  I made most of the changes you recommend and I was able to get it to compile,  the only one I had trouble with was
If I take out the ^ from:
       if (EP^.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK =
 LIBUSB_TRANSFER_TYPE_INTERRUPT) and
          (EP^.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0) then

So it looks like this:
       if (EP.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK =
 LIBUSB_TRANSFER_TYPE_INTERRUPT) and
          (EP.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0) then

I get a compiler error:
libusboop.pas(1168,14) Error: Illegal qualifier
libusboop.pas(1168,14) Fatal: Syntax error, ")" expected but "identifier BMATTRIBUTES" found
libusboop.pas(0) Fatal: Compilation aborted

With the ^ in it compiles anyway... I don't know how to adjust the format to not have the ^

I have not tried to do anything with TLibUsbPseudoHIDInterface yet, I was just trying to get libusboop.pas to compile, and be able to still run the previous examples.

I've updated my repository at https://github.com/Zaaphod/pas-libusb/tree/Test

Let me know if I should do something different with the ^ above, or if you see anything else I missed.

James

-----Original Message-----
From: fpc-pascal <[hidden email]> On Behalf Of Johann Glaser
Sent: Sunday, August 11, 2019 4:16 PM
To: [hidden email]
Subject: Re: [fpc-pascal] USB Human Interface Devices

Hi!

Am Samstag, den 10.08.2019, 17:50 -0400 schrieb James Richters:
> I'm making an attempt to copy TUSBPseudoHIDInterface into
> libusboop.pas.  I've made the recomended name changes and then tried
> to compile it.  Some things I found like the names changing from
> things like
>
> PUSBInterfaceDescriptop to Plibusb_interface_descriptor

OK, there are two things. Names directly from libusb-1.0 (as used in
libusb.pas) should be identical to the original C code, i.e., Plibusb_interface_descriptor as you've written.

The second thing are the classes in the OOP wrapper in libusboop.pas.
Please use CamelCase for them, e.g., TLibusbPseudoHIDInterface.

> are pretty obvious, but just taking a guess on other things like:
>
>  changing:
>       if (EP.bmAttributes and USB_ENDPOINT_TYPE_MASK =
> USB_ENDPOINT_TYPE_INTERRUPT) and
>          (EP.bEndpointAddress and USB_ENDPOINT_DIR_MASK <> 0) then
>
> To:
>       if (EP^.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK =
> LIBUSB_TRANSFER_TYPE_INTERRUPT) and
>          (EP^.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0) then

Yes, very good, thanks!

Whether EP is a pointer (--> EP^.bmAttributes) or a record
(EP.bmAttributs) just depends on the usage in the code. As I see in usb.pas in line 846, in TUSBPseudoHIDInterface.Create, it is actually the record, so you should stay without the '^'.

> Based on looking at something similar in libusbutil... but I'm not
> sure it's right at all.... I'm not sure if USB_ENDPOINT_TYPE_MASK was
> really changed to LIBUSB_TRANSFER_TYPE_MASK or if something else
> happened.  But at least it compiles...

You translated it correctly.

> but now I've hit a few items that I just don't know what to do
> with.    I can't find anything similar to get a reference from:
>
> libusboop.pas(1198,28) Error: Identifier not found "USB_TYPE_CLASS"

Use LIBUSB_REQUEST_TYPE_CLASS.

> libusboop.pas(1199,5) Error: Identifier not found
> "USB_REQ_HID_SET_REPORT"
> libusboop.pas(1216,27) Error: Identifier not found "USB_TYPE_CLASS"
> libusboop.pas(1217,5) Error: Identifier not found
> "USB_REQ_HID_GET_REPORT"
> libusboop.pas(1227,23) Error: Identifier not found
> "HID_REPORT_TYPE_OUTPUT"

Please copy the constants USB_REQ_HID_* and HID_REPORT_* from libusb.pas (branch master) lines 248-257 to the interface section of libusboop.pas (branch libusb-1.0) directly above the class declaration of TLibusbPseudoHIDInterface. Then please rename USB_REQ_HID_* to
LIBUSB_REQUEST_HID_* and HID_REPORT_* to LIBUSB_HID_REPORT_*.

> I've tried things that seem to be in line with other changes, like
> changing USB_Type_Class to LIBUSB_TYPE_CLASS or spelling out REQUEST
> instead of REQ which also seems to be done in other places, but still
> the identifiers are not found... the problem is I have no idea where
> these identifiers were/are defined.
>
> I made a fork in github and a branch called "test"  here:
> https://github.com/Zaaphod/pas-libusb/tree/Test

Great approach, thanks, then we can use pull requests.

Thanks
  Hansi

> > Actually you could copy the class TUSBPseudoHIDInterface (plus the
> > types THIDReport and TIntrReportFunc) from usb.pas to libusboop.pas
> > and change everything necessary.
> > At least one difference is that all names change from TUSB* to
> > TLibUsb*. I'm sure there are more, but I don't know by heart.
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email] https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Johann Glaser
Hi!

Am Sonntag, den 11.08.2019, 19:13 -0400 schrieb James Richters:

> Thank you for the help.  I made most of the changes you recommend and
> I was able to get it to compile,  the only one I had trouble with was
> If I take out the ^ from:
>        if (EP^.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK =
>  LIBUSB_TRANSFER_TYPE_INTERRUPT) and
>           (EP^.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0)
> then
>
> So it looks like this:
>        if (EP.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK =
>  LIBUSB_TRANSFER_TYPE_INTERRUPT) and
>           (EP.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0)
> then
>
> I get a compiler error:
> libusboop.pas(1168,14) Error: Illegal qualifier
> libusboop.pas(1168,14) Fatal: Syntax error, ")" expected but
> "identifier BMATTRIBUTES" found
> libusboop.pas(0) Fatal: Compilation aborted
>
> With the ^ in it compiles anyway... I don't know how to adjust the
> format to not have the ^
>
> I have not tried to do anything with TLibUsbPseudoHIDInterface yet, I
> was just trying to get libusboop.pas to compile, and be able to still
> run the previous examples.
>
> I've updated my repository at
> https://github.com/Zaaphod/pas-libusb/tree/Test
>
> Let me know if I should do something different with the ^ above, or
> if you see anything else I missed.

Ah, I see. You declared EP as Plibusb_endpoint_descriptor (i.e., the
pointer to an endpoint descriptor record), while in the original code
it is a USBEndpointDescriptor (i.e., the record itself).

Your version is more memory efficient but uses "ugly pointer-
arithmetic" by taking the address of an array element. However, just
keep it as you implemented it.

While reviewing your changes, I found a few small things.

Could you please keep the indenting and coding style as the existing
code? This is especially for the constant and type declarations around
TLibUsbPseudoHIDInterface (IIRC the keywords Type and Const should
start at character 1, therefore you also should un-indent the 6+3
constants and the P/THIDReport record (except its final "End;" by 2
spaces.

Secondly, in your improved TLibUsbInterface.FindEndpoint, please revert
the capitalization and indenting changes (i.e., capital "Function",
"For", ..., and "do" and "then" in the same line, ... IMHO the only
changed lines in comparison to the original code should be the extra
variable EP, its assignment without range checks, and its use in
MatchFunc and Exit.

And thirdly, you introduced a class type TLibUsbInterruptInEndpoint,
which is IMHO unused. If its so, please remove it. I like to avoid
clutter. :-)

Apart form these cosmetic things, thank you very much for your effort!
I'm looking forward hearing from you your success when accessing a HID
device (or call for help :-) ).

Thanks
  Hansi

> -----Original Message-----
> From: fpc-pascal <[hidden email]> On Behalf
> Of Johann Glaser
> Sent: Sunday, August 11, 2019 4:16 PM
> To: [hidden email]
> Subject: Re: [fpc-pascal] USB Human Interface Devices
>
> Hi!
>
> Am Samstag, den 10.08.2019, 17:50 -0400 schrieb James Richters:
> > I'm making an attempt to copy TUSBPseudoHIDInterface into
> > libusboop.pas.  I've made the recomended name changes and then
> > tried
> > to compile it.  Some things I found like the names changing from
> > things like
> >
> > PUSBInterfaceDescriptop to Plibusb_interface_descriptor
>
> OK, there are two things. Names directly from libusb-1.0 (as used in
> libusb.pas) should be identical to the original C code, i.e.,
> Plibusb_interface_descriptor as you've written.
>
> The second thing are the classes in the OOP wrapper in libusboop.pas.
> Please use CamelCase for them, e.g., TLibusbPseudoHIDInterface.
>
> > are pretty obvious, but just taking a guess on other things like:
> >
> >  changing:
> >       if (EP.bmAttributes and USB_ENDPOINT_TYPE_MASK =
> > USB_ENDPOINT_TYPE_INTERRUPT) and
> >          (EP.bEndpointAddress and USB_ENDPOINT_DIR_MASK <> 0) then
> >
> > To:
> >       if (EP^.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK =
> > LIBUSB_TRANSFER_TYPE_INTERRUPT) and
> >          (EP^.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0)
> > then
>
> Yes, very good, thanks!
>
> Whether EP is a pointer (--> EP^.bmAttributes) or a record
> (EP.bmAttributs) just depends on the usage in the code. As I see in
> usb.pas in line 846, in TUSBPseudoHIDInterface.Create, it is actually
> the record, so you should stay without the '^'.
>
> > Based on looking at something similar in libusbutil... but I'm not
> > sure it's right at all.... I'm not sure if USB_ENDPOINT_TYPE_MASK
> > was
> > really changed to LIBUSB_TRANSFER_TYPE_MASK or if something else
> > happened.  But at least it compiles...
>
> You translated it correctly.
>
> > but now I've hit a few items that I just don't know what to do
> > with.    I can't find anything similar to get a reference from:
> >
> > libusboop.pas(1198,28) Error: Identifier not found "USB_TYPE_CLASS"
>
> Use LIBUSB_REQUEST_TYPE_CLASS.
>
> > libusboop.pas(1199,5) Error: Identifier not found
> > "USB_REQ_HID_SET_REPORT"
> > libusboop.pas(1216,27) Error: Identifier not found "USB_TYPE_CLASS"
> > libusboop.pas(1217,5) Error: Identifier not found
> > "USB_REQ_HID_GET_REPORT"
> > libusboop.pas(1227,23) Error: Identifier not found
> > "HID_REPORT_TYPE_OUTPUT"
>
> Please copy the constants USB_REQ_HID_* and HID_REPORT_* from
> libusb.pas (branch master) lines 248-257 to the interface section of
> libusboop.pas (branch libusb-1.0) directly above the class
> declaration of TLibusbPseudoHIDInterface. Then please rename
> USB_REQ_HID_* to
> LIBUSB_REQUEST_HID_* and HID_REPORT_* to LIBUSB_HID_REPORT_*.
>
> > I've tried things that seem to be in line with other changes, like
> > changing USB_Type_Class to LIBUSB_TYPE_CLASS or spelling out
> > REQUEST
> > instead of REQ which also seems to be done in other places, but
> > still
> > the identifiers are not found... the problem is I have no idea
> > where
> > these identifiers were/are defined.
> >
> > I made a fork in github and a branch called "test"  here:
> > https://github.com/Zaaphod/pas-libusb/tree/Test
>
> Great approach, thanks, then we can use pull requests.
>
> Thanks
>   Hansi
>
> > > Actually you could copy the class TUSBPseudoHIDInterface (plus
> > > the
> > > types THIDReport and TIntrReportFunc) from usb.pas to
> > > libusboop.pas
> > > and change everything necessary.
> > > At least one difference is that all names change from TUSB* to
> > > TLibUsb*. I'm sure there are more, but I don't know by heart.
> >
> > _______________________________________________
> > fpc-pascal maillist  -  [hidden email]
> > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Zaaphod

>>Ah, I see. You declared EP as Plibusb_endpoint_descriptor (i.e., the pointer to an endpoint descriptor record), while in the original code it is a USBEndpointDescriptor (i.e., the record itself).
>>Your version is more memory efficient but uses "ugly pointer- arithmetic" by taking the address of an array element. However, just keep it as you implemented it.

Well that wasn’t my idea,  I was trying to get it to compile and I saw the existing function:
// helper function for method below, this can't be a local function
Function MyEndpointMatch(EP:Plibusb_endpoint_descriptor;Data:Pointer):Boolean;
Var bEndpointAddress : Byte;
Begin
  bEndpointAddress := (PtrUInt(Data) shr 0) and $FF;
  Result := (EP^.bEndpointAddress = bEndpointAddress);
End;

        It compiled and had the pointer, so I stuck a pointer in the one I was having a problem with and it compiled.... it was just a guess at how to get it to compile honestly. I figured that the other code had it so maybe something to do with the way things are defined now require it to be a pointer.. without the pointer it gives errors.

>>While reviewing your changes, I found a few small things.
>>Could you please keep the indenting and coding style as the existing code? This is especially for the constant and type declarations around TLibUsbPseudoHIDInterface (IIRC the >>keywords Type and Const should start at character 1, therefore you also should un-indent the 6+3 constants and the P/THIDReport record (except its final "End;" by 2 spaces.

        Yes, I will keep the indenting and coding style the same, No problem, I adjusted this as you requested.  I'll go through later and see if there are any other things I missed.. most of what I've done is cutting and pasting, but I'll keep it consistent.

>>Secondly, in your improved TLibUsbInterface.FindEndpoint, please revert the capitalization and indenting changes (i.e., capital "Function", "For", ..., and "do" and "then" in the same line, ... IMHO the only changed lines in comparison to the original code should be the extra variable EP, its assignment without range checks, and its use in MatchFunc and Exit.
        That was code the Jean sent me to get it to work under windows, but I wend an retrieved the original function and re-did the modifications to match the formatting.  It compiles fine without turning off range check, but I think there was some reason why Jean had to put them in there.. I'll leave it out for now unless we figure out why they were needed.

>>And thirdly, you introduced a class type TLibUsbInterruptInEndpoint, which is IMHO unused. If its so, please remove it. I like to avoid clutter. :-)
        I guess you are talking about line 128:   TLibUsbInterruptInEndpoint   = class; ?
              When I copied over { TUSBPseudoHIDInterface } and then renamed everything I needed it to be able to compile
        Line 211:    FIntrEndpoint : TLibUsbInterruptInEndpoint;  
              Without it I was getting libusboop.pas(212,21) Error: Identifier not found "TLibUsbInterruptInEndpoint"
              So I went back to usb.pas and copied that line over to prevent this error... perhaps I have it in the wrong place??

>>Apart form these cosmetic things, thank you very much for your effort!
    No problem,  please let me know if I missed anything,  I'm happy to make it conform to the coding standards.  I’m a little confused by the capitalization, for example sometimes it's LibUsb,  sometimes it's Libusb.. I'm trying to figure out when the U is capitated and when it is not.... maybe it should always be one way or the other?  Please continue to correct me on anything you see.

>>I'm looking forward hearing from you your success when accessing a HID device (or call for help :-) ).

        Well..... since you asked... I'm having a real challenge trying to figure out how I can use all this to access my device... I'm just not familiar with this kind of programming... constructors, destructors, and all this inherited stuff, it's not what I am used to, I never have anything like that.. I know how to program in Turbo Pascal for DOS pretty much and normal in-line console style programming, but very little of anything past that, so a lot of this just goes over my head.  
        On top of that, I really don't understand USB communications at all, I have written programs with all kinds of features, programs that send e-mails, communicate over ethernet and serial connections, Modbus, etc... but this USB stuff is just not making any sense to me... and it seems like the python code I have as an example is so simple... you open the device, send and receive some stuff and close it...  but I don't really know python either, so I really don't understand everything going on there...
      I still don't really see how to open and close the device or how to send or receive anything from it...  I'm struggling to see how the somewhat simple looking functions in HB04.py can be implemented....

I'm trying to use one of the examples to just open and close the device, but I am not successful with that,    Here is what I am trying to do:

I ran Test1library.pas and got the following:

Running "i:\programming\pas-libusb_test_dll\src\examples\test1library.exe "
Using libusb(x) v1.0.22.11312
Found 14 devices:
  Bus   1 Device   0: ID 8086:A36D,  port:   0, Speed: Unknown
  Bus   1 Device   5: ID 8087:0AAA,  port:  14, port path from HCD: 0, Speed: 12 Mbit/s (USB FullSpeed)
  Bus   1 Device  33: ID 0424:2734,  port:   1, port path from HCD: 0->1, Speed: 480 Mbit/s (USB HighSpeed)
  Bus   1 Device   7: ID 1B1C:0C15,  port:   2, port path from HCD: 0->9, Speed: 12 Mbit/s (USB FullSpeed)
  Bus   1 Device  16: ID 10CE:EB93,  port:   4, port path from HCD: 0, Speed: 12 Mbit/s (USB FullSpeed)
  Bus   1 Device   3: ID 05E3:0610,  port:   9, port path from HCD: 0, Speed: 480 Mbit/s (USB HighSpeed)
  Bus   1 Device  18: ID 04E8:61F5,  port:  19, port path from HCD: 0, Speed: unknown (4)
  Bus   1 Device   4: ID 1B1C:0C10,  port:  10, port path from HCD: 0, Speed: 12 Mbit/s (USB FullSpeed)
  Bus   1 Device  25: ID 0424:274C,  port:   5, port path from HCD: 0->1->1, Speed: 480 Mbit/s (USB HighSpeed)
  Bus   1 Device  34: ID 047D:1020,  port:   3, port path from HCD: 0->1->1, Speed: 1.5 Mbit/s (USB LowSpeed)
  Bus   1 Device  26: ID 1B1C:1B4F,  port:   4, port path from HCD: 0->1->1, Speed: 12 Mbit/s (USB FullSpeed)
  Bus   1 Device  12: ID 1A40:0101,  port:   1, port path from HCD: 0, Speed: 480 Mbit/s (USB HighSpeed)
  Bus   1 Device  14: ID 0C45:7403,  port:   2, port path from HCD: 0->1, Speed: 12 Mbit/s (USB FullSpeed)
  Bus   1 Device  30: ID 10C4:EA60,  port:   5, port path from HCD: 0, Speed: 12 Mbit/s (USB FullSpeed)

The one I want to try to use is this one:
  Bus   1 Device  16: ID 10CE:EB93,  port:   4, port path from HCD: 0, Speed: 12 Mbit/s (USB FullSpeed)
I assume that $10CE and $EB93 are the Vid and Pid??  

I tried plugging those into the following test program:

program test_open_WHB04B;

{$mode objfpc}{$H+}

uses
    Classes,SysUtils,MyDevice,LibUsbOop,LibUsbUtil;

procedure WHB04B_Device;
const
     WHB04B_VID= $10CE;
     WHB04B_PID= $EB93;
var
   Context   : TLibUsbContext;
   TheDevice : TMyDevice;
function CreateMatch: TLibUsbDeviceMatchVidPid;
   begin
      Result:= TLibUsbDeviceMatchVidPid.Create( Context, WHB04B_VID, WHB04B_PID);
   end;
begin
     Context := TLibUsbContext.Create;
     try
        TheDevice := TMyDevice.Create( Context, CreateMatch, '', CreateMatch);
     except
       on E : Exception do
         Begin
           WriteLn('Couldn''t connect to device: ',E.Message);
           Halt(1);
         End;
     End;
     WriteLn('Successfully connected to USB device ',IntToHex(WHB04B_VID,4),':',IntToHex(WHB04B_PID,4));
     WriteLn('Version:        ',TheDevice.GetVersion);
     WriteLn('Version String: ',TheDevice.GetVersionString);
     WriteLn('Status:         ',TheDevice.GetStatus);

     while true
     do
       Write( TheDevice.ReadString);

     TheDevice.Free;
     Context.Free;
end;

begin
     WHB04B_Device;
End.


When I run it I get:
Running "i:\programming\pas-libusb_test_dll\src\examples\test_open_whb04b.exe "
Couldn't connect to device: Access violation

When I try any of the other devices in the list I get:
Running "i:\programming\pas-libusb_test_dll\src\examples\test_open.exe "
Couldn't connect to device: Open: LIBUSB_ERROR_NO_DEVICE

What am I missing here?  Why can't I get this to work?

Any help is greatly appreciated!

James




_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Johann Glaser
Hi James!

Am Montag, den 12.08.2019, 20:20 -0400 schrieb James Richters:

> > > Ah, I see. You declared EP as Plibusb_endpoint_descriptor (i.e.,
> > > the pointer to an endpoint descriptor record), while in the
> > > original code it is a USBEndpointDescriptor (i.e., the record
> > > itself).
> > > Your version is more memory efficient but uses "ugly pointer-
> > > arithmetic" by taking the address of an array element. However,
> > > just keep it as you implemented it.
>
> Well that wasn’t my idea,  I was trying to get it to compile and I
> saw the existing function:
> // helper function for method below, this can't be a local function
> Function
> MyEndpointMatch(EP:Plibusb_endpoint_descriptor;Data:Pointer):Boolean;
> Var bEndpointAddress : Byte;
> Begin
>   bEndpointAddress := (PtrUInt(Data) shr 0) and $FF;
>   Result := (EP^.bEndpointAddress = bEndpointAddress);
> End;
>
> It compiled and had the pointer, so I stuck a pointer in the
> one I was having a problem with and it compiled.... it was just a
> guess at how to get it to compile honestly. I figured that the other
> code had it so maybe something to do with the way things are defined
> now require it to be a pointer.. without the pointer it gives errors.

Yes, yes, no worries! That was no criticism, just a (hopefully)
objective description of what I saw in the code. :-)

> > > While reviewing your changes, I found a few small things.
> > > Could you please keep the indenting and coding style as the
> > > existing code? This is especially for the constant and type
> > > declarations around TLibUsbPseudoHIDInterface (IIRC the
> > > >>keywords Type and Const should start at character 1, therefore
> > > you also should un-indent the 6+3 constants and the P/THIDReport
> > > record (except its final "End;" by 2 spaces.
>
> Yes, I will keep the indenting and coding style the same, No
> problem, I adjusted this as you requested.  I'll go through later and
> see if there are any other things I missed.. most of what I've done
> is cutting and pasting, but I'll keep it consistent.

Great, thanks! And there is no hurry.

> > > Secondly, in your improved TLibUsbInterface.FindEndpoint, please
> > > revert the capitalization and indenting changes (i.e., capital
> > > "Function", "For", ..., and "do" and "then" in the same line, ...
> > > IMHO the only changed lines in comparison to the original code
> > > should be the extra variable EP, its assignment without range
> > > checks, and its use in MatchFunc and Exit.
> That was code the Jean sent me to get it to work under windows, but I
> wend an retrieved the original function and re-did the modifications
> to match the formatting.  It compiles fine without turning off range
> check, but I think there was some reason why Jean had to put them in
> there.. I'll leave it out for now unless we figure out why they were
> needed.

You can just keep in the range checking. I think I should have done
this from the beginning, but never used range checking, therefore never
thought of it.

> > > And thirdly, you introduced a class type
> > > TLibUsbInterruptInEndpoint, which is IMHO unused. If its so,
> > > please remove it. I like to avoid clutter. :-)
> I guess you are talking about line
> 128:   TLibUsbInterruptInEndpoint   = class; ?
>               When I copied over { TUSBPseudoHIDInterface } and then
> renamed everything I needed it to be able to compile
> Line 211:    FIntrEndpoint : TLibUsbInterruptInEndpoint;
>               Without it I was getting libusboop.pas(212,21) Error:
> Identifier not found "TLibUsbInterruptInEndpoint"
>               So I went back to usb.pas and copied that line over to
> prevent this error... perhaps I have it in the wrong place??

Let me have a closer look. :-)

Ah, sorry, it was my fault. I should have looked at the complete file,
not just the diff. :-)

Please keep the forward declaration in.

> > > Apart form these cosmetic things, thank you very much for your
> > > effort!
>     No problem,  please let me know if I missed anything,  I'm
> happy to make it conform to the coding standards.  I’m a little
> confused by the capitalization, for example sometimes it's
> LibUsb,  sometimes it's Libusb.. I'm trying to figure out when the U
> is capitated and when it is not.... maybe it should always be one way
> or the other?  Please continue to correct me on anything you see.

That's probably my own lazyness. However, at least in libusboop.pas,
all declarations use LibUsb (capital 'U') everywhere. And in libusb.pas
its "libusb" (all small letters) except the unit name itself.

> > > I'm looking forward hearing from you your success when accessing
> > > a HID device (or call for help :-) ).
>
> Well..... since you asked... I'm having a real challenge trying
> to figure out how I can use all this to access my device... I'm just
> not familiar with this kind of programming... constructors,
> destructors, and all this inherited stuff, it's not what I am used
> to, I never have anything like that.. I know how to program in Turbo
> Pascal for DOS pretty much and normal in-line console style
> programming, but very little of anything past that, so a lot of this
> just goes over my head.
> On top of that, I really don't understand USB communications at
> all, I have written programs with all kinds of features, programs
> that send e-mails, communicate over ethernet and serial connections,
> Modbus, etc... but this USB stuff is just not making any sense to
> me... and it seems like the python code I have as an example is so
> simple... you open the device, send and receive some stuff and close
> it...  but I don't really know python either, so I really don't
> understand everything going on there...

Regarding USB, I've recommended some EMails ago to read the first
chapter of the AN2131 EZ-USB TRM. That really got me into USB.

>       I still don't really see how to open and close the device or
> how to send or receive anything from it...  I'm struggling to see how
> the somewhat simple looking functions in HB04.py can be
> implemented....

It seems that libusb-1.0 as well as pas-libusb (incl. the OOP wrapper)
are much nearer to the hardware than the Python stuff.

> I'm trying to use one of the examples to just open and close the
> device, but I am not successful with that,    Here is what I am
> trying to do:
>
> I ran Test1library.pas and got the following:
>
> Running "i:\programming\pas-libusb_test_dll\src\examples\test1library.exe "
> Using libusb(x) v1.0.22.11312
> Found 14 devices:
>   Bus   1 Device   0: ID 8086:A36D,  port:   0, Speed: Unknown
>   Bus   1 Device   5: ID 8087:0AAA,  port:  14, port path from HCD: 0, Speed: 12 Mbit/s (USB FullSpeed)
>   Bus   1 Device  33: ID 0424:2734,  port:   1, port path from HCD: 0->1, Speed: 480 Mbit/s (USB HighSpeed)
>   Bus   1 Device   7: ID 1B1C:0C15,  port:   2, port path from HCD: 0->9, Speed: 12 Mbit/s (USB FullSpeed)
>   Bus   1 Device  16: ID 10CE:EB93,  port:   4, port path from HCD: 0, Speed: 12 Mbit/s (USB FullSpeed)
>   Bus   1 Device   3: ID 05E3:0610,  port:   9, port path from HCD: 0, Speed: 480 Mbit/s (USB HighSpeed)
>   Bus   1 Device  18: ID 04E8:61F5,  port:  19, port path from HCD: 0, Speed: unknown (4)
>   Bus   1 Device   4: ID 1B1C:0C10,  port:  10, port path from HCD: 0, Speed: 12 Mbit/s (USB FullSpeed)
>   Bus   1 Device  25: ID 0424:274C,  port:   5, port path from HCD: 0->1->1, Speed: 480 Mbit/s (USB HighSpeed)
>   Bus   1 Device  34: ID 047D:1020,  port:   3, port path from HCD: 0->1->1, Speed: 1.5 Mbit/s (USB LowSpeed)
>   Bus   1 Device  26: ID 1B1C:1B4F,  port:   4, port path from HCD: 0->1->1, Speed: 12 Mbit/s (USB FullSpeed)
>   Bus   1 Device  12: ID 1A40:0101,  port:   1, port path from HCD: 0, Speed: 480 Mbit/s (USB HighSpeed)
>   Bus   1 Device  14: ID 0C45:7403,  port:   2, port path from HCD: 0->1, Speed: 12 Mbit/s (USB FullSpeed)
>   Bus   1 Device  30: ID 10C4:EA60,  port:   5, port path from HCD: 0, Speed: 12 Mbit/s (USB FullSpeed)
>
> The one I want to try to use is this one:
>   Bus   1 Device  16: ID 10CE:EB93,  port:   4, port path from HCD: 0, Speed: 12 Mbit/s (USB FullSpeed)
> I assume that $10CE and $EB93 are the Vid and Pid??

Exactly!

> I tried plugging those into the following test program:
>
> program test_open_WHB04B;
>
> {$mode objfpc}{$H+}
>
> uses
>     Classes,SysUtils,MyDevice,LibUsbOop,LibUsbUtil;
>
> procedure WHB04B_Device;
> const
>      WHB04B_VID= $10CE;
>      WHB04B_PID= $EB93;
> var
>    Context   : TLibUsbContext;
>    TheDevice : TMyDevice;

IMHO you should _not_ use "MyDevice", because thats just a lousy demo
of a hypothetical device with a built-in EZ-USB chip (you remember,
without ROM or Flash). It downloads the firmware and then talks to that
demo firmware.

> function CreateMatch: TLibUsbDeviceMatchVidPid;
>    begin
>       Result:= TLibUsbDeviceMatchVidPid.Create( Context, WHB04B_VID,
> WHB04B_PID);
>    end;
> begin
>      Context := TLibUsbContext.Create;
>      try
>         TheDevice := TMyDevice.Create( Context, CreateMatch, '',
> CreateMatch);
>      except
>        on E : Exception do
>          Begin
>            WriteLn('Couldn''t connect to device: ',E.Message);
>            Halt(1);
>          End;
>      End;
>      WriteLn('Successfully connected to USB device
> ',IntToHex(WHB04B_VID,4),':',IntToHex(WHB04B_PID,4));
>      WriteLn('Version:        ',TheDevice.GetVersion);
>      WriteLn('Version String: ',TheDevice.GetVersionString);
>      WriteLn('Status:         ',TheDevice.GetStatus);
>
>      while true
>      do
>        Write( TheDevice.ReadString);
>
>      TheDevice.Free;
>      Context.Free;
> end;
>
> begin
>      WHB04B_Device;
> End.
>
>
> When I run it I get:
> Running "i:\programming\pas-
> libusb_test_dll\src\examples\test_open_whb04b.exe "
> Couldn't connect to device: Access violation

Would be interesting where this is coming from. It seems, Windows
doesn't allow you to open that device. It could be, that Windows wants
some "driver" (AFAIK just a .ini file). Or it could be that Windows saw
that this is a USB HID device and now some Windows default HID driver
is hogging that device.

Unfortunately I don't know anything of Windows, so I can't help here.

> When I try any of the other devices in the list I get:
> Running "i:\programming\pas-
> libusb_test_dll\src\examples\test_open.exe "
> Couldn't connect to device: Open: LIBUSB_ERROR_NO_DEVICE
>
> What am I missing here?  Why can't I get this to work?

Please consult my EMail from last Saturday with the attached snapi.pas.

You can basically use the TSNAPIDevice and remove everything you don't
need. :-)

The important thing is the constructor, where the PseudoHID interface
is allocated.

And then you can use the PseudoHID interface methods like SetReport,
... to communicate with the device.

In the hb04.py code I also see some "normal" read() and write() calls.
AFAIK these are not covered by the standard HID. So we would have to
find out what that Python easyhid is doing and then use the appropriate
pas-libusb functions.

Bye
  Hansi


_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Zaaphod
I wonder if HID devices will work at all on Windows the same as they do on Linux.   I have not been able to get the HID part of the python code to work on windows yet either because the instructions given to install the packages needed only apply to Linux...   I also wonder if fundamental differences in operating systems is why FPC doesn't already have built in support for HID devices... maybe it's just not possible to make it cross platform.

I did a little searching... I came across this:
https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/introduction-to-hid-concepts

it seems maybe you are right and even though I did not install a driver into windows for this device, maybe windows just detected it was an HID device and attached it, and what I really need to do is access it through windows, not directly.. I had to do this with parallel ports.. I can't just read and write directly to the parallel port like I used to be able to with DOS,  I have to go through windows somehow.. I am using http://www.highrez.co.uk/Downloads/InpOut32/ to work with parallel ports with Windows.  I think it's a DLL written in C, so I had to write a unit to get it to work with FPC... but it does work reliably even though windows shows the ports in device manager.  Microsoft seems to be completely against users accessing hardware directly as we used to be able to with DOS.

I wonder if the only way to get FPC to work with HID devices on Windows is to do something similar with the windows HID API, and go through windows the only way windows will allow me to access these devices.  I've been searching trying to find information on this.. I came across the project at:

https://github.com/signal11/hidapi

it states in the readme:

HIDAPI has four back-ends:
        * Windows (using hid.dll)
        * Linux/hidraw (using the Kernel's hidraw driver)
        * Linux/libusb (using libusb-1.0)
        * FreeBSD (using libusb-1.0)
        * Mac (using IOHidManager)

This seems to indicate the libusb-1.0 is what you use for Linux and FreeBSD, but not for windows, because if it worked for Windows or Mac, then why bother doing it differently for them.  Of course this project is for C, not pascal....

So then I was looking for a Pascal way to use hid.dll, and came across this:
https://github.com/prof7bit/HIDAPI.pas/blob/master/hidapi.pas  that looked promising because it has functions like Open(), Close(), Write(), Read(), SendFeatureReport() etc... but.... that isn't working under windows... uggggggg.  

It seems that using this HID device with FPC under windows is going to be anything but easy... ugggg   maybe I can solve it with hardware.. I can get a raspberry pi, teach my self python, hack the python code to interface with the HID device on the Rpi and communicate with my windows 10 FPC program over an ethernet port or something stupid like that and hope it's fast enough... boy is sure seems stupid to use another complete computer to interface this once device to windows... I guess I'll keep trying to come up with a solution.

Anyone have any thoughts on all this?

James


_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: *** SPAM *** Re: USB Human Interface Devices

Jean SUZINEAU
Le 14/08/2019 à 01:41, James Richters a écrit :
> Anyone have any thoughts on all this?

I'm busy for now, but I'll have a look as soon as possible.

Did you try to change your driver with Zadig (https://zadig.akeo.ie/)
for your device 10CE:EB93 ?

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

José Mejuto
In reply to this post by Zaaphod
El 14/08/2019 a las 1:41, James Richters escribió:

> I wonder if HID devices will work at all on Windows the same as they do on Linux.   I have not been able to get the HID part of the python code to work on windows yet either because the instructions given to install the packages needed

Hello,

HID devices works in the same way, you need a device driver for the
hardware that exposes a HID interface and you can manage that HID
interface using native hid.dll or use an abstraction layer like libusb-1.0.

https://github.com/JoshyFun/VUSBRelayPascal

My code to manage HID USB relays uses hid.dll (32 & 64 bits) or
libusb-1.0 (32 bits only tested) on Windows, and libusb-1.0 or
libusb-0.1 in Linux.

Of course, functions on hid.dll and libusb are no the same, they work in
different way, but the libusb-1.0 works the same way in both platforms.

Implementation of hid.dll, libusb, etc, in my code only have relevant
functions used in USB relays, so they can not used as a complete
implementation.

In the other hand, the hardware you are trying to manage is 10CE:EB93 ?
If the answer is yes, that device is *not* HID compatible so you can not
use hid.dll for native access, you must use WinUSB API set, or the
libusb-1.0 abstraction layer.

--

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: *** SPAM *** Re: USB Human Interface Devices

Zaaphod
In reply to this post by Jean SUZINEAU
> Did you try to change your driver with Zadig (https://zadig.akeo.ie/) for your device 10CE:EB93 ?

No, I didn't try that..   but I'm trying it now....
I downloaded Zadig, and used the pulldown and selected devices until I got the one with the USB ID  I want.
It filled in as follows:
"USB Input Device"
Driver: HidUSB (v10.0.17763.1)
USB ID: 10CE EB93
WCID has a red X in it
       
I am not sure what to do from here.   It looks like it has a driver for HidUSB and maybe that's what I want because the project at https://github.com/prof7bit/HIDAPI.pas has the same functions as the ones I am looking to duplicate... but then I don't know, maybe I am mixing up terminology

Anyway, before I go changing drivers.. is there some way to un-do this change?  I don't see HidUSB in the list of drivers that Zadig can install, so if it turns out hat I really wanted HidUSB driver and I changed it to LibUsb then is there a way to put it back?

James
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Zaaphod
In reply to this post by José Mejuto
>My code to manage HID USB relays uses hid.dll (32 & 64 bits) or
>libusb-1.0 (32 bits only tested) on Windows, and libusb-1.0 or
>libusb-0.1 in Linux.

I'll have a look at your project.. maybe it will give me some clues.
Can you tell me how to get hid.dll?  I  find it all very confusing, can I just download the dll somewhere or do I have to get this huge confusing package and built it myself?  The sample code that is able to access my device with python on Linux uses hid.dll  I would like to at least be able to try the hid.dll... if I can get hid.dll somewhere.

>Of course, functions on hid.dll and libusb are no the same, they work in different way, but the libusb-1.0 works the same way in both platforms.
The hid.dll way seems to have the functions I am trying to duplicate.

>Implementation of hid.dll, libusb, etc, in my code only have relevant functions used in USB relays, so they can not used as a complete implementation.
Maybe it will at least be able to get me started with some basic access.. at this point I would be happy to make it just open and close the device without an error.

>In the other hand, the hardware you are trying to manage is 10CE:EB93 ?
Yes, I got a listing of all devices, then I plugged in the new one, and that is the ID that was not there before.

>If the answer is yes, that device is *not* HID compatible so you can not use hid.dll for native access, you must use WinUSB API set, or the
>libusb-1.0 abstraction layer.
I'm curious how you can tell that by looking at the number of it?


_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

José Mejuto
El 14/08/2019 a las 16:29, James Richters escribió:

> I'll have a look at your project.. maybe it will give me some clues.
> Can you tell me how to get hid.dll?  I  find it all very confusing, can I just download the dll somewhere or do I have to get this huge confusing package and built it myself?  The sample code that is able to access my device with python on Linux uses hid.dll  I would like to at least be able to try the hid.dll... if I can get hid.dll somewhere.

Hello,

hid.dll is the windows system HID interface, the API provided by Windows.

>> In the other hand, the hardware you are trying to manage is 10CE:EB93 ?
> Yes, I got a listing of all devices, then I plugged in the new one, and that is the ID that was not there before.
>> If the answer is yes, that device is *not* HID compatible so you can not use hid.dll for native access, you must use WinUSB API set, or the
>> libusb-1.0 abstraction layer.
> I'm curious how you can tell that by looking at the number of it?

No, I just look for the product and try to find its drivers, no one name
the HID interface. Do you see the device in windows device manager under
the HID section "Human Interface Devices (HID)" ?


--

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Zaaphod
Yes, in device manager I see it listed as "HID-compliant vendor-defined device"  also Zadig identifies it as "USB Input Device" and it shows Driver: HidUsb (v10.1.17763.1)

Is there a way to use the windows system HID interface with FPC already in place as there is for other windows APIs?

James

-----Original Message-----
From: fpc-pascal <[hidden email]> On Behalf Of José Mejuto
Sent: Thursday, August 15, 2019 8:34 AM
To: [hidden email]
Subject: Re: [fpc-pascal] USB Human Interface Devices

El 14/08/2019 a las 16:29, James Richters escribió:

> I'll have a look at your project.. maybe it will give me some clues.
> Can you tell me how to get hid.dll?  I  find it all very confusing, can I just download the dll somewhere or do I have to get this huge confusing package and built it myself?  The sample code that is able to access my device with python on Linux uses hid.dll  I would like to at least be able to try the hid.dll... if I can get hid.dll somewhere.

Hello,

hid.dll is the windows system HID interface, the API provided by Windows.

>> In the other hand, the hardware you are trying to manage is 10CE:EB93 ?
> Yes, I got a listing of all devices, then I plugged in the new one, and that is the ID that was not there before.
>> If the answer is yes, that device is *not* HID compatible so you can
>> not use hid.dll for native access, you must use WinUSB API set, or
>> the
>> libusb-1.0 abstraction layer.
> I'm curious how you can tell that by looking at the number of it?

No, I just look for the product and try to find its drivers, no one name the HID interface. Do you see the device in windows device manager under the HID section "Human Interface Devices (HID)" ?


--

_______________________________________________
fpc-pascal maillist  -  [hidden email] https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

José Mejuto
El 15/08/2019 a las 15:11, James Richters escribió:
> Yes, in device manager I see it listed as "HID-compliant vendor-defined device"  also Zadig identifies it as "USB Input Device" and it shows Driver: HidUsb (v10.1.17763.1)
>
> Is there a way to use the windows system HID interface with FPC already in place as there is for other windows APIs?
>

Hello,

You can find a HID interface for windows at:

https://libstock.mikroe.com/projects/view/528/usb-hid-dll-for-delphi-and-perhaps-other-languages

In the "Basic" package.

Anyway, if possible, the use of libusb-1.0 is recommended as it will
give you crossplatform support.

You can check my project to see how devices are enumerated, based in the
libusb-1.0 function calls.

--

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Stefan V. Pantazi
In reply to this post by Zaaphod
Hi James,

I remember going through many similar difficulties with HID. A few years
ago I was trying to connect to much simpler devices than yours (game
controllers, weather station base, graphic tablet, etc). USB programming
is confusing and many abstraction layers have been created aiming at
simplifying it. Unfortunately this introduces dependencies. I remember
trying to port hidapi headers to Pascal and tried to use the hidraw
backend (in linux) with mixed results. Also tried the libhid
cross-platform library. In the end I went with libusb 1.0 for which a
Pascal header already existed
(https://forum.lazarus.freepascal.org/index.php?topic=11435.0) and used
it to implement on top of it a subset of the HID API calls that suited
my needs and kept things simple. I just posted an example on github:
https://github.com/svpantazi/libusbxhid
Hope it helps.

In theory you could use the Windows HID API but, as others have
suggested, the solution would not be cross platform, or, to put it
another way, Windows HID API would become your dependency. My suggestion
is also to go the libusb 1.0 route and use a Pascal HID library that
depends only on libusb 1.0. Your device appears to be HID-compliant so
no additional drivers should be needed for it. As far as I know, the
Zadig generic driver is necessary only for non-HID devices. I remember
using it for a rtl-sdr USB device on Windows.

Hope you find your solution. Good luck.

On 8/15/19 9:11 AM, James Richters wrote:

> Yes, in device manager I see it listed as "HID-compliant vendor-defined device"  also Zadig identifies it as "USB Input Device" and it shows Driver: HidUsb (v10.1.17763.1)
>
> Is there a way to use the windows system HID interface with FPC already in place as there is for other windows APIs?
>
> James
>
> -----Original Message-----
> From: fpc-pascal <[hidden email]> On Behalf Of José Mejuto
> Sent: Thursday, August 15, 2019 8:34 AM
> To: [hidden email]
> Subject: Re: [fpc-pascal] USB Human Interface Devices
>
> El 14/08/2019 a las 16:29, James Richters escribió:
>
>> I'll have a look at your project.. maybe it will give me some clues.
>> Can you tell me how to get hid.dll?  I  find it all very confusing, can I just download the dll somewhere or do I have to get this huge confusing package and built it myself?  The sample code that is able to access my device with python on Linux uses hid.dll  I would like to at least be able to try the hid.dll... if I can get hid.dll somewhere.
>
> Hello,
>
> hid.dll is the windows system HID interface, the API provided by Windows.
>
>>> In the other hand, the hardware you are trying to manage is 10CE:EB93 ?
>> Yes, I got a listing of all devices, then I plugged in the new one, and that is the ID that was not there before.
>>> If the answer is yes, that device is *not* HID compatible so you can
>>> not use hid.dll for native access, you must use WinUSB API set, or
>>> the
>>> libusb-1.0 abstraction layer.
>> I'm curious how you can tell that by looking at the number of it?
>
> No, I just look for the product and try to find its drivers, no one name the HID interface. Do you see the device in windows device manager under the HID section "Human Interface Devices (HID)" ?
>
>

--
_______________________________________________________
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: USB Human Interface Devices

Zaaphod
Thanks for posting the examples and the information. I'll have a look... I am thinking maybe I should buy some of those USB relays  or something simpler just to get SOMETHNG to work so I can figure out what's supposed to even be happening.    

James

-----Original Message-----
From: fpc-pascal <[hidden email]> On Behalf Of Stefan V. Pantazi
Sent: Thursday, August 15, 2019 5:31 PM
To: [hidden email]
Subject: Re: [fpc-pascal] USB Human Interface Devices

Hi James,

I remember going through many similar difficulties with HID. A few years ago I was trying to connect to much simpler devices than yours (game controllers, weather station base, graphic tablet, etc). USB programming is confusing and many abstraction layers have been created aiming at simplifying it. Unfortunately this introduces dependencies. I remember trying to port hidapi headers to Pascal and tried to use the hidraw backend (in linux) with mixed results. Also tried the libhid cross-platform library. In the end I went with libusb 1.0 for which a Pascal header already existed
(https://forum.lazarus.freepascal.org/index.php?topic=11435.0) and used it to implement on top of it a subset of the HID API calls that suited my needs and kept things simple. I just posted an example on github:
https://github.com/svpantazi/libusbxhid
Hope it helps.

In theory you could use the Windows HID API but, as others have suggested, the solution would not be cross platform, or, to put it another way, Windows HID API would become your dependency. My suggestion is also to go the libusb 1.0 route and use a Pascal HID library that depends only on libusb 1.0. Your device appears to be HID-compliant so no additional drivers should be needed for it. As far as I know, the Zadig generic driver is necessary only for non-HID devices. I remember using it for a rtl-sdr USB device on Windows.

Hope you find your solution. Good luck.

On 8/15/19 9:11 AM, James Richters wrote:

> Yes, in device manager I see it listed as "HID-compliant
> vendor-defined device"  also Zadig identifies it as "USB Input Device"
> and it shows Driver: HidUsb (v10.1.17763.1)
>
> Is there a way to use the windows system HID interface with FPC already in place as there is for other windows APIs?
>
> James
>
> -----Original Message-----
> From: fpc-pascal <[hidden email]> On Behalf
> Of José Mejuto
> Sent: Thursday, August 15, 2019 8:34 AM
> To: [hidden email]
> Subject: Re: [fpc-pascal] USB Human Interface Devices
>
> El 14/08/2019 a las 16:29, James Richters escribió:
>
>> I'll have a look at your project.. maybe it will give me some clues.
>> Can you tell me how to get hid.dll?  I  find it all very confusing, can I just download the dll somewhere or do I have to get this huge confusing package and built it myself?  The sample code that is able to access my device with python on Linux uses hid.dll  I would like to at least be able to try the hid.dll... if I can get hid.dll somewhere.
>
> Hello,
>
> hid.dll is the windows system HID interface, the API provided by Windows.
>
>>> In the other hand, the hardware you are trying to manage is 10CE:EB93 ?
>> Yes, I got a listing of all devices, then I plugged in the new one, and that is the ID that was not there before.
>>> If the answer is yes, that device is *not* HID compatible so you can
>>> not use hid.dll for native access, you must use WinUSB API set, or
>>> the
>>> libusb-1.0 abstraction layer.
>> I'm curious how you can tell that by looking at the number of it?
>
> No, I just look for the product and try to find its drivers, no one name the HID interface. Do you see the device in windows device manager under the HID section "Human Interface Devices (HID)" ?
>
>

--
_______________________________________________________
_______________________________________________
fpc-pascal maillist  -  [hidden email] https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
1234567 ... 9