Hello, Great video. Simple, short and gets the learning across clear. I am trying to learn python usb stuff on windows 10 and need your help with following 1. how to get the vid and pid of a plugged in usb wired mouse ? 2. Also get usb.core.NoBackendError: No backend available error, cannot figure out what is causing it. Any help here would be great. thank you Ashutosh
hello i have an issue where this code works for me in linux on my usb device (my mouse) but when i try to do this in windows I can't get any data whatsoever every time it goes to time out can you help me out? can i send you my code somewhere?
Hi I executed the code at 5:49 on my Windows 10 computer and it ran without errors, however I hadn't passed the parameter of "I" to is_kernel_driver_active meaning I actually disconnected the drivers from every single interface on my computer. This means I can no longer connect to WiFi even through a wired connection, I can't play audio and I can't use external peripherals like keyboard or mouse. I'm utterly stuck with this, I know you use Linux but does anyone know how I can fix this problem? Thank
Excuse me! i have a question. does this apply to reading HDMI input as well? because i want to make a litte thing that lets me get video feedback from nothing more then a HDMI cable, running from my computer to my gaming console. In a small window, that is emulating the behavior of a TV. i want to be able to record footage without having to pay 300 dollars for a capture card that i will only ever use once. so i thing this would be pretty handy.
@@alexlugo5967 ive tried finding something but i couldnt find anything. its sad to say that this ends here then... or you have something that could bring me in the right direction.
Hi, do you have video on how to read USB data from windows environment? Linux i believe does not have many security layers and easily provide access to usb, but can you please create a video on how to read data in windows using python?
Never mind, If you ever have the same problem try to log in as root, this video explains how to allow a user runing raspbian to use the root user: ruclips.net/video/v0vrkMP27PA/видео.html
Excellent and clear video. I'm going to develope communication between linux running workstation (in my case Raspberry4 running Xubuntu) and laboratory measuring instrument with usb interface. Where can I find further knowledge to fulfill my goal? Thanks in advance
@@parthchopra315 I had some rough results: i was able to connect to the instrument (was a flewmeter) following these steps: 1) swtiching usb connection to serial (in Linux is a very simple operation); 2) you need serial communication rules to send commands to the instrument and reading data from it. The protocol should be described in device manual. If not clear, ask me more
@@donato685 like u programmed it on something? I don't have any manual or so and it's my internship project to retrieve data from instrument and save it in server with timestamp
@@parthchopra315 start point is communication protocol. How does the instrument receive instructions and sends Data? How long is the string? How many characters? Check the web for this device manual or, in alternative, which chipset provides communication. The core is the communication pattern (protocol)
I’m setting the timeout to 2 while creating the serial object. When I’m reading from serial port I’m checking wether data is present in input buffer by : if(obj.inWaiting>0) : If the data packets are interrupted it hangs in there.... I have given timeout value as 2 still it’s waiting indefinitely... why it’s not considering timeout value????
pyusb is compatible with windows so the code should work and the package also provides tools to scan the ports and find the devices you are looking for so no need to even look in the system manually although if you prefer to do it with a system tool I would look at devices panel
Hello Alex. I tried to apply your example to an usb digitalPerosn fingerprint reader. The program finds the device, but whe I try to do dev.read it gives me some errors. I don`t know if you can help me. I use python 3.8 (can`y find the 3.5 version). import time import usb.core import usb.util VID = 0x05ba PID = 0x000a dev=usb.core.find(idVendor=VID, idProduct=PID) if not dev: print ("Could not find the device :(") exit(1) print ("Dispositivo digitalPerson encontrado") ep=dev[0].interfaces()[0].endpoints()[0] i=dev[0].interfaces()[0].bInterfaceNumber dev.reset() dev.set_configuration() eaddr=ep.bEndpointAddress r=dev.read(eaddr,1024) print(len(r)) The error is: (base) [root@web-apto finger_print]# python3 read.py Dispositivo digitalPerson encontrado Traceback (most recent call last): File "read.py", line 24, in r=dev.read(eaddr,1024) File "/root/anaconda3/lib/python3.8/site-packages/usb/core.py", line 1017, in read ret = fn( File "/root/anaconda3/lib/python3.8/site-packages/usb/backend/libusb1.py", line 864, in intr_read return self.__read(self.lib.libusb_interrupt_transfer, File "/root/anaconda3/lib/python3.8/site-packages/usb/backend/libusb1.py", line 954, in __read _check(retval) File "/root/anaconda3/lib/python3.8/site-packages/usb/backend/libusb1.py", line 602, in _check raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBTimeoutError: [Errno 110] Operation timed out omarr@cable.net.co
@@alexlugo5967 Thanks for your fast answer. Even if I put my finger immediately when I get the Device Found message, I get the same error. The device never turns a blue light on. Wich does with the fprintd command
@@alexlugo5967 Thank a lot. It seems that the scanner (digitalpersona) needs a command to put it in a read mode before the dev.read command is send. I am going to check the manual, if I find one. Happy new year.
Thank you for this video! I had some troubles and now I get a "tuple index out of range" at line 4. endpoints() seem to have no index. When I print dev it looks correct. Does somebody have an Idea why? Thank you (sorry I'm not very familiar with high level languages)
Hey, I have windows10 OS and I am running the below python code in it to read the USB device. I am able to connect the device but in last when I am reading it gives no data. Here is my code, import usb.core import usb.util def main(): device = usb.core.find(idVendor=0x046D, idProduct=0xC077) device.reset()
# use the first/default configuration device.set_configuration() # first endpoint endpoint = device[0][(0,0)][0] # read a data packet data = None while True: try: data = device.read(endpoint.bEndpointAddress,endpoint.wMaxPacketSize,1000) print (len(data)) except usb.core.USBError as e: data = None if e.args == ('Operation timed out',): continue if __name__ == '__main__': main() It always goes in except statement. Could you please let me know that whether its OS problem or code??
Sky is the limit but a lot of work is required since you need to communicate under some protocol. Technically you can send whatever you want so even replicating adb functionality or jailbreaking is possible.
@@alexlugo5967 If you're poking around in the video description as well it might be good to put some show notes in there as well. Such as: 0:38 lsusb linux.die.net/man/8/lsusb 2:33 pip install pyusb github.com/pyusb/pyusb As well as a link to a gist of the source code at the end. Just makes it easier for people to find what they need without having to scrub through the video again. Thanks for the video though, all just constructive criticism!
You can find the VendorID & ProductID by locating your usb in Device Manager (unfortunately specific device are rarely immediately distinguishable). >Open "Run" (either type Run in search, or hit the Windows-button+R) and type "devmgmt.msc" for device manager >Right-click the device and hit "properties" >Under the "details" tab, scroll down from 'device description' until you find 'hardware ids' There you'll see USB\VID_XXXX&PID_XXXX
Love the "Life" background. :-)
Hello,
Great video. Simple, short and gets the learning across clear.
I am trying to learn python usb stuff on windows 10 and need your help with following
1. how to get the vid and pid of a plugged in usb wired mouse ?
2. Also get usb.core.NoBackendError: No backend available error, cannot figure out what is causing it. Any help here would be great.
thank you
Ashutosh
Can you please make a video on connecting and reading data from USB barcode scanner
Alex, great and simple and clear video, I am also looking python usb stuff on windows 10, your help is welcome
hello
i have an issue where this code works for me in linux on my usb device (my mouse) but when i try to do this in windows I can't get any data whatsoever every time it goes to time out
can you help me out? can i send you my code somewhere?
Great video, it has helped me a lot on my latest project
Hi
I executed the code at 5:49 on my Windows 10 computer and it ran without errors, however I hadn't passed the parameter of "I" to is_kernel_driver_active meaning I actually disconnected the drivers from every single interface on my computer. This means I can no longer connect to WiFi even through a wired connection, I can't play audio and I can't use external peripherals like keyboard or mouse.
I'm utterly stuck with this, I know you use Linux but does anyone know how I can fix this problem?
Thank
@@alexlugo5967 yeah I tried all of that. Tbh in the end I just reinstalled Windows because I couldn't find a way to fix it
Great video! Thank you!
Excuse me! i have a question. does this apply to reading HDMI input as well? because i want to make a litte thing that lets me get video feedback from nothing more then a HDMI cable, running from my computer to my gaming console. In a small window, that is emulating the behavior of a TV. i want to be able to record footage without having to pay 300 dollars for a capture card that i will only ever use once. so i thing this would be pretty handy.
@@alexlugo5967 ive tried finding something but i couldnt find anything. its sad to say that this ends here then... or you have something that could bring me in the right direction.
did it work? I want to do something similar
How can I send signal to turn on/off electromagnet through USB using PyUSB?
how do you start the program your using to get usb info. is that ubuntu,linux? cant find usb.core library
Nice.. it's really helpful.
>lsusb
'lsusb' is not recognized as an internal or external command,
operable program or batch file.
Good. Keep it up. Thank you
what module is used to access adb and to add adddevicechangeevent listener in python?
Hi, do you have video on how to read USB data from windows environment? Linux i believe does not have many security layers and easily provide access to usb, but can you please create a video on how to read data in windows using python?
Is it works with hid devices also?
What is the yellow and blue background?
thanks great video I have subscribed.
Hi. That's a great job my friend! Thanks in advice.
I have a problem with pyusb I think.. "No backend available" in find module.
Can U help me?
hey nice video. Could you release a video for writing usb, too?
I get the following error: [Errno 13] Access denied (insufficient permissions) What can I do to fix it?
Never mind, If you ever have the same problem try to log in as root, this video explains how to allow a user runing raspbian to use the root user: ruclips.net/video/v0vrkMP27PA/видео.html
@@josejaviermoya-angelergarc6968 yo thanks a ton u saved me a ton of time :)
Logging as root is a viable option to test the script, but the actual fix is to add a udev rule to your user account.
How can i use hc-12 with arduino using python language?
Excellent and clear video. I'm going to develope communication between linux running workstation (in my case Raspberry4 running Xubuntu) and laboratory measuring instrument with usb interface. Where can I find further knowledge to fulfill my goal? Thanks in advance
Any update regarding it bro? I'm doing same project with windows and measuring instrument. Help
@@parthchopra315 I had some rough results: i was able to connect to the instrument (was a flewmeter) following these steps: 1) swtiching usb connection to serial (in Linux is a very simple operation); 2) you need serial communication rules to send commands to the instrument and reading data from it. The protocol should be described in device manual. If not clear, ask me more
@@donato685 like u programmed it on something? I don't have any manual or so and it's my internship project to retrieve data from instrument and save it in server with timestamp
@@parthchopra315 start point is communication protocol. How does the instrument receive instructions and sends Data? How long is the string? How many characters? Check the web for this device manual or, in alternative, which chipset provides communication. The core is the communication pattern (protocol)
I’m setting the timeout to 2 while creating the serial object. When I’m reading from serial port I’m checking wether data is present in input buffer by :
if(obj.inWaiting>0) :
If the data packets are interrupted it hangs in there.... I have given timeout value as 2 still it’s waiting indefinitely... why it’s not considering timeout value????
did you find the solution :) ?
Thanks for video. What's about getting information from pci in python?
how can I do that on windows ?
Any idea how this can be done on Windows?
pyusb is compatible with windows so the code should work and the package also provides tools to scan the ports and find the devices you are looking for so no need to even look in the system manually although if you prefer to do it with a system tool I would look at devices panel
very useful. thank you very much
Hello Alex. I tried to apply your example to an usb digitalPerosn fingerprint reader. The program finds the device, but whe I try to do dev.read it gives me some errors. I don`t know if you can help me. I use python 3.8 (can`y find the 3.5 version).
import time
import usb.core
import usb.util
VID = 0x05ba
PID = 0x000a
dev=usb.core.find(idVendor=VID, idProduct=PID)
if not dev:
print ("Could not find the device :(")
exit(1)
print ("Dispositivo digitalPerson encontrado")
ep=dev[0].interfaces()[0].endpoints()[0]
i=dev[0].interfaces()[0].bInterfaceNumber
dev.reset()
dev.set_configuration()
eaddr=ep.bEndpointAddress
r=dev.read(eaddr,1024)
print(len(r))
The error is:
(base) [root@web-apto finger_print]# python3 read.py
Dispositivo digitalPerson encontrado
Traceback (most recent call last):
File "read.py", line 24, in
r=dev.read(eaddr,1024)
File "/root/anaconda3/lib/python3.8/site-packages/usb/core.py", line 1017, in read
ret = fn(
File "/root/anaconda3/lib/python3.8/site-packages/usb/backend/libusb1.py", line 864, in intr_read
return self.__read(self.lib.libusb_interrupt_transfer,
File "/root/anaconda3/lib/python3.8/site-packages/usb/backend/libusb1.py", line 954, in __read
_check(retval)
File "/root/anaconda3/lib/python3.8/site-packages/usb/backend/libusb1.py", line 602, in _check
raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out
omarr@cable.net.co
@@alexlugo5967 Thanks for your fast answer. Even if I put my finger immediately when I get the Device Found message, I get the same error.
The device never turns a blue light on. Wich does with the fprintd command
@@alexlugo5967 Thank a lot.
It seems that the scanner (digitalpersona) needs a command to put it in a read mode before the dev.read command is send. I am going to check the manual, if I find one.
Happy new year.
Thank you for this video!
I had some troubles and now I get a "tuple index out of range" at line 4. endpoints() seem to have no index. When I print dev it looks correct.
Does somebody have an Idea why?
Thank you (sorry I'm not very familiar with high level languages)
same
hello,. can it be used for windows users?
and can it scan for available ports on a laptop?
1 yes 2 probably also yes (look at pyusb docs)
Hey, I have windows10 OS and I am running the below python code in it to read the USB device. I am able to connect the device but in last when I am reading it gives no data.
Here is my code,
import usb.core
import usb.util
def main():
device = usb.core.find(idVendor=0x046D, idProduct=0xC077)
device.reset()
# use the first/default configuration
device.set_configuration()
# first endpoint
endpoint = device[0][(0,0)][0]
# read a data packet
data = None
while True:
try:
data = device.read(endpoint.bEndpointAddress,endpoint.wMaxPacketSize,1000)
print (len(data))
except usb.core.USBError as e:
data = None
if e.args == ('Operation timed out',):
continue
if __name__ == '__main__':
main()
It always goes in except statement. Could you please let me know that whether its OS problem or code??
can we control mobile device connecting USB cable with python?
Sky is the limit but a lot of work is required since you need to communicate under some protocol. Technically you can send whatever you want so even replicating adb functionality or jailbreaking is possible.
I used your code on the windows system, it works very well, I just deleted the kernel driver (if) statement, I get joystick raw data, thanks
@Aahmad Aa can you tell me how you get the vendorID and the productID on Windows?
Thank you for this video. I would strongly implore you not to play music over voice though. It's very difficult for those with hearing difficulties.
I wasn't sure whether I should be dancing or listening.
@@alexlugo5967 If you're poking around in the video description as well it might be good to put some show notes in there as well.
Such as:
0:38 lsusb linux.die.net/man/8/lsusb
2:33 pip install pyusb github.com/pyusb/pyusb
As well as a link to a gist of the source code at the end.
Just makes it easier for people to find what they need without having to scrub through the video again.
Thanks for the video though, all just constructive criticism!
background voice is very high:)
Is it a black helicopter?
I had to make a module in python for USB flash encryption using AES-256 algorithm.
Kindly tell me where do I find relevant information about it.
how to do this in windows
@@alexlugo5967 Basically what i want to do is i want to make an application using tkinker to check if my phone is connected any help would be useful
You can find the VendorID & ProductID by locating your usb in Device Manager (unfortunately specific device are rarely immediately distinguishable).
>Open "Run" (either type Run in search, or hit the Windows-button+R) and type "devmgmt.msc" for device manager
>Right-click the device and hit "properties"
>Under the "details" tab, scroll down from 'device description' until you find 'hardware ids'
There you'll see USB\VID_XXXX&PID_XXXX
just a heads up, lsusb is a command for linux.. it is not python. otherwise great video
You can actualy explain rather than just brushing what you already know.
I need to detect someone's IDs. help
Come on. Sudo rhymes with doodoo. Origin? To do something with superuser privilege: su + do = sudo.
Gave up after 3 mins, background music was driving me mad!
Shut the damn music off
Great video, it has helped me a lot on my latest project