Home > other >  Take less than a USB device information pyusb module
Take less than a USB device information pyusb module

Time:09-25

Want to use the usb to read and write functions of Python, it is found that take less than a usb information,

The code is as follows:
The import usb

Dev=usb. Core. The find (idVendor=0 x04bb, idProduct=0 x0c55)
Print dev
>> None (but clearly have insert the number of USB)

PS: according to some online, have been using Inf Wizard. Exe on the USB device driver installation,

Everyone a great god see have encountered similar problems?

CodePudding user response:

Can with lsusb first look at the list to the device

CodePudding user response:

The passing of the tread pit, anyway I am no longer with pyusb playing under the Windows, I'm drift,
My solution:
1, under the Windows: using pywinusb library, but apparently only support HID devices
2 in the Linux (only in ubuntu and raspberry PI wheezy) tested, using pyusb, (remember to use the root),
One of the USB part for your reference: http://git.oschina.net/jakey.chen/SlaveDebugTool

CodePudding user response:

reference 1/f, sprawling response:
lsusb first to make sure is it possible to list to equipment


Also not line, no equipment list

CodePudding user response:

refer to the second floor u011062542 response:
to tread the pit passing, anyway I am no longer with pyusb playing under the Windows, I'm drift,
My solution:
1, under the Windows: using pywinusb library, but apparently only support HID devices
2 in the Linux (only in ubuntu and raspberry PI wheezy) tested, using pyusb, (remember to use the root),
The USB part for reference: http://git.oschina.net/jakey.chen/SlaveDebugTool


This,,, not very embarrassing for PYTHON?? .

CodePudding user response:

Use Pyserial this, has been updated

CodePudding user response:

This is my copy pyusb code, see not useful to you
The import usb. The core
The import usb. Util
The import sys

Dev=usb. Core. The find (idVendor=0 x5345, idProduct=0 x1234)

CFG=dev. Get_active_configuration ()
Intf=CFG/(0, 0)
Ep=usb. Util. Find_descriptor (
Intf,
# match the first OUT the endpoint
Custom_match=\
Lambda e: \
Usb. Util. Endpoint_direction (e.b EndpointAddress)==\
Usb. Util. ENDPOINT_OUT
)
Print 'The length of The data (write USB) is:', ep. Write (' WANTFORGETTXT)
Ep_read=usb. Util. Find_descriptor (
Intf,
# match the first endpoint IN
Custom_match=\
Lambda e: \
Usb. Util. Endpoint_direction (e.b EndpointAddress)==\
Usb. Util. ENDPOINT_IN
)
Data_len=ep_read. Read (4)
Print 'Get the USB data:', data_len
Len=(data_len [3] <24) + (data_len [2] <16) + (data_len [1] <8) + data_len [0]
Print 'data len is:', len
Dev. Reset ()

CodePudding user response:

refer to 6th floor python_lele response:
this is my copy of pyusb code, see not useful to you
The import usb. The core
The import usb. Util
The import sys

Dev=usb. Core. The find (idVendor=0 x5345, idProduct=0 x1234)

CFG=dev. Get_active_configuration ()
Intf=CFG/(0, 0)
Ep=usb. Util. Find_descriptor (
Intf,
# match the first OUT the endpoint
Custom_match=\
Lambda e: \
Usb. Util. Endpoint_direction (e.b EndpointAddress)==\
Usb. Util. ENDPOINT_OUT
)
Print 'The length of The data (write USB) is:', ep. Write (' WANTFORGETTXT)
Ep_read=usb. Util. Find_descriptor (
Intf,
# match the first endpoint IN
Custom_match=\
Lambda e: \
Usb. Util. Endpoint_direction (e.b EndpointAddress)==\
Usb. Util. ENDPOINT_IN
)
Data_len=ep_read. Read (4)
Print 'Get the USB data:', data_len
Len=(data_len [3] <24) + (data_len [2] <16) + (data_len [1] <8) + data_len [0]
Print 'data len is:', len
Dev. Reset ()


Hello, thank you for your reply,
'this code is also not line,
Dev=usb. Core. The find (idVendor=0 x5345, idProduct=0 x1234)
Using the above interface returns a NULL,
Usb. Core. The.findall but could not find any equipment

CodePudding user response:

reference 5 floor python_lele reply:
use Pyserial this, has been in the update


This is not used to develop a serial port application? I use the rs232 program development,,,

CodePudding user response:

Top one again ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

CodePudding user response:

Ubuntu installation first libusb
Apt to get the install libusb - dev
Apt to get the install libusb - 1.0-0 - dev
To install: PIP install pyusb
The test code:
The import usb. The core
Usb. Core. Show_devices ()
Successful output:

Another test results:
The import usb
Dev=usb. Core. The find (idVendor=0 x05fe, idProduct=0 x1010)
Print dev
v

CodePudding user response:

Under the Windows need to filter the install I will small white to express the aim not at first, then use and
> The import usb. The core
> Usb. Core. Show_devices ()

Can print added drive, but other the.findall that was empty

CodePudding user response:

11 references b8 response:
under the Windows need to filter the install I will small white to express the aim not at first, then use and
> nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related