Re: [pyusb-users] Need Help Please

2020-11-16 Thread Xiaofan Chen
On Mon, Nov 16, 2020 at 4:08 PM Nicolas Pinault via pyusb-users
 wrote:
>
> On Windows, for HID devices, I use a dedicated HID library : 
> https://github.com/rene-aguirre/pywinusb
>
I second this if it is just for Windows platform.

For cross platform applications, I will recommend python bindings of HIDAPI.
https://github.com/trezor/cython-hidapi

FAQ in libusb wiki.
https://github.com/libusb/libusb/wiki/FAQ#Does_libusb_support_USB_HID_devices

-- 
Xiaofan


___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Need Help Please

2020-11-16 Thread Nicolas Pinault via pyusb-users
Hi,
 
 On Windows, for HID devices, I use a dedicated HID library : 
https://github.com/rene-aguirre/pywinusb
 
 Nicolas
 
 
 Le 13/11/2020 à 07:50, John Beamish a écrit :
 
 
Hi 

 
 
I am trying to use a USB port to talk to a 18F46K20 pic controller. The 
project, which is in the early stages, will communicate simple commands to the 
controller,  to get temperature and humidity data from a sensor attached to the 
controller.
 
I want to use Python to manipulate the results in graphic form.
 
I have read some articles about using PyUSB for interacting with the USB port 
so I thought I would do some preliminary tests to trial it before I get into 
the more complex parts.
 
I copied a small program to test it 
(https://github.com/pyusb/pyusb/blob/master/docs/tutorial.rst)
 
 
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x04B3, idProduct=0x310C)
if dev is None:
raise ValueError('Device not found')
print (dev.idProduct,dev.idVendor) 
dev.set_configuration()
 
 
The device is an USB optical mouse. Info from USB Device Viewer is at the end 
of this email.
 
Line 6 outputs 12556 1203 ( which is in decimal).
 
Line 7 produces the following
 
Exception has occurred: USBError
 [Errno 40] Operation not supported or unimplemented on this platform
   File "C:\Users\John Beamish\test\usbtest.py", line 7, in 
     dev.set_configuration()
 
 
I loaded pyusb 1.1.0 with pip install pyusb and libusb1 1.8 with pip install 
libusb1
 
I am running Python 3.9 0n Windows 10 Home Version 2004.
 

 
 
I know I have/ or am doing something wrong but if anyone is able to advise me I 
would really appreciate this.
 

 
 
This was supposed to be the easy bit!!!
 
Regards
 

 
 
John Beamish
 

 
 
       ---===>Device Information<===---
 English product name: "USB Optical Mouse"
 
 ConnectionStatus:                  
 Current Config Value:              0x01  -> Device Bus Speed: Low
 Device Address:                    0x27
 Open Pipes:                           1
 
           ===>Device Descriptor<===
 bLength:                           0x12
 bDescriptorType:                   0x01
 bcdUSB:                          0x0200
 bDeviceClass:                      0x00  -> This is an Interface Class Defined 
Device

 bDeviceSubClass:                   0x00
 bDeviceProtocol:                   0x00
 bMaxPacketSize0:                   0x08 = (8) Bytes
 idVendor:                        0x04B3 = IBM Corporation
 idProduct:                       0x310C
 
 

 
 

 
 

 
 
 
 
 

___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


 
 ___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Need Help Please

2020-11-13 Thread Jonas Malaco via pyusb-users
On Fri, Nov 13, 2020 at 3:51 AM John Beamish  wrote:
> ...
>
> I know I have/ or am doing something wrong but if anyone is able to advise me 
> I would really appreciate this.
>
> This was supposed to be the easy bit!!!
> Regards

Unfortunately you complicated things for yourself by picking a Human
Interface Device (HID) for your proof-of-concept.

On Windows libusb (which is what PyUSB is using) wraps the HID driver,
and this results in some limitations to what APIs are available.
Additionally, in many OSes, including Windows, access to mice and
keyboards is restricted for security reasons.  You will have better
luck with other devices.

That said, you should also keep in mind the "lightweight reset issue"
when calling `set_configuration`; the FAQ goes into more detail about
this, linking to the relevant libusb documentation.[1]

Hope this helps,
Jonas

[1] 
https://github.com/pyusb/pyusb/blob/master/docs/faq.rst#how-not-to-call-set_configuration-on-a-device-already-configured-with-the-selected-configuration


___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users