Reading USB in Python

Поделиться
HTML-код
  • Опубликовано: 20 янв 2025

Комментарии • 72

  • @MrEengstrom77
    @MrEengstrom77 4 года назад +9

    Love the "Life" background. :-)

  • @tube63017
    @tube63017 4 года назад +11

    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

  • @namratamulwani4737
    @namratamulwani4737 4 года назад +2

    Can you please make a video on connecting and reading data from USB barcode scanner

  • @svalaboj
    @svalaboj 4 года назад +3

    Alex, great and simple and clear video, I am also looking python usb stuff on windows 10, your help is welcome

  • @AlirezaAbbasi-kv6uf
    @AlirezaAbbasi-kv6uf 23 дня назад

    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?

  • @josejaviermoya-angelergarc6968
    @josejaviermoya-angelergarc6968 4 года назад +3

    Great video, it has helped me a lot on my latest project

  • @therocker1639
    @therocker1639 4 года назад

    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

    • @therocker1639
      @therocker1639 4 года назад

      @@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

  • @deplorablesecuritydevices
    @deplorablesecuritydevices 5 месяцев назад

    Great video! Thank you!

  • @mitschcrafter6766
    @mitschcrafter6766 4 года назад +1

    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.

    • @mitschcrafter6766
      @mitschcrafter6766 4 года назад

      @@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.

    • @ammarshahzad9627
      @ammarshahzad9627 2 года назад

      did it work? I want to do something similar

  • @DontMansion
    @DontMansion 2 года назад

    How can I send signal to turn on/off electromagnet through USB using PyUSB?

  • @rverm1000
    @rverm1000 2 года назад

    how do you start the program your using to get usb info. is that ubuntu,linux? cant find usb.core library

  • @swarajsamal6864
    @swarajsamal6864 4 года назад +1

    Nice.. it's really helpful.

  • @dofuru
    @dofuru 3 года назад

    >lsusb
    'lsusb' is not recognized as an internal or external command,
    operable program or batch file.

  • @subramonianmohan1241
    @subramonianmohan1241 3 года назад

    Good. Keep it up. Thank you

  • @shobharani828
    @shobharani828 4 года назад

    what module is used to access adb and to add adddevicechangeevent listener in python?

  • @muhammadumerfarooq9671
    @muhammadumerfarooq9671 2 года назад

    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?

  • @martonhorvath1887
    @martonhorvath1887 5 месяцев назад

    Is it works with hid devices also?

  • @therealgamingcroc
    @therealgamingcroc 4 года назад

    What is the yellow and blue background?

  • @sacredinclinations
    @sacredinclinations 3 года назад

    thanks great video I have subscribed.

  • @juanpablotravi2210
    @juanpablotravi2210 4 года назад

    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?

  • @Stylaboxxx
    @Stylaboxxx 5 лет назад +4

    hey nice video. Could you release a video for writing usb, too?

  • @josejaviermoya-angelergarc6968
    @josejaviermoya-angelergarc6968 4 года назад +1

    I get the following error: [Errno 13] Access denied (insufficient permissions) What can I do to fix it?

    • @josejaviermoya-angelergarc6968
      @josejaviermoya-angelergarc6968 4 года назад +1

      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

    • @sauravshroff427
      @sauravshroff427 4 года назад

      @@josejaviermoya-angelergarc6968 yo thanks a ton u saved me a ton of time :)

    • @nobytes2
      @nobytes2 4 года назад

      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.

  • @waleedaiad3411
    @waleedaiad3411 2 года назад

    How can i use hc-12 with arduino using python language?

  • @donato685
    @donato685 3 года назад +1

    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
      @parthchopra315 3 года назад

      Any update regarding it bro? I'm doing same project with windows and measuring instrument. Help

    • @donato685
      @donato685 3 года назад

      @@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

    • @parthchopra315
      @parthchopra315 3 года назад +1

      @@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

    • @donato685
      @donato685 3 года назад

      @@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)

  • @prasadvaidya9563
    @prasadvaidya9563 4 года назад

    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????

    • @NawtieBoy96
      @NawtieBoy96 3 года назад

      did you find the solution :) ?

  • @АлександрБурдин-щ3в

    Thanks for video. What's about getting information from pci in python?

  • @louismaurin7234
    @louismaurin7234 5 лет назад +1

    how can I do that on windows ?

  • @Baba-so6fh
    @Baba-so6fh 4 года назад +1

    Any idea how this can be done on Windows?

    • @adampindelski2359
      @adampindelski2359 3 года назад

      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

  • @baxiry.
    @baxiry. 5 лет назад

    very useful. thank you very much

  • @omarramirez2511
    @omarramirez2511 4 года назад

    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

    • @omarramirez2511
      @omarramirez2511 4 года назад

      @@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

    • @omarramirez2511
      @omarramirez2511 4 года назад

      @@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.

  • @sandrorippstein2539
    @sandrorippstein2539 4 года назад +2

    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)

  • @simasonline5215
    @simasonline5215 3 года назад

    hello,. can it be used for windows users?
    and can it scan for available ports on a laptop?

  • @patelchiragkumar5732
    @patelchiragkumar5732 4 года назад

    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??

  • @mind_calming68
    @mind_calming68 4 года назад

    can we control mobile device connecting USB cable with python?

    • @adampindelski2359
      @adampindelski2359 3 года назад

      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.

  • @ameralahmad3563
    @ameralahmad3563 3 года назад

    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

    • @exeqd
      @exeqd 2 года назад

      @Aahmad Aa can you tell me how you get the vendorID and the productID on Windows?

  • @kallan2255
    @kallan2255 4 года назад +6

    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.

    • @steve24822
      @steve24822 4 года назад

      I wasn't sure whether I should be dancing or listening.

    • @kallan2255
      @kallan2255 4 года назад +3

      ​@@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!

  • @irunnal2898
    @irunnal2898 4 года назад +1

    background voice is very high:)

  • @thomasblackwell9507
    @thomasblackwell9507 2 года назад

    Is it a black helicopter?

  • @muhammadkashif4000
    @muhammadkashif4000 3 года назад

    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.

  • @fardeenpettiwala1138
    @fardeenpettiwala1138 4 года назад

    how to do this in windows

    • @fardeenpettiwala1138
      @fardeenpettiwala1138 4 года назад

      @@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

    • @nicklespale22
      @nicklespale22 4 года назад

      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

  • @renegadezed
    @renegadezed 3 года назад

    just a heads up, lsusb is a command for linux.. it is not python. otherwise great video

  • @nirbhay_raghav
    @nirbhay_raghav 4 года назад

    You can actualy explain rather than just brushing what you already know.

  • @LiBlock
    @LiBlock 2 года назад

    I need to detect someone's IDs. help

  • @vtrandal
    @vtrandal 4 года назад

    Come on. Sudo rhymes with doodoo. Origin? To do something with superuser privilege: su + do = sudo.

  • @doug3458
    @doug3458 3 года назад +2

    Gave up after 3 mins, background music was driving me mad!

  • @Doodmeister0
    @Doodmeister0 5 месяцев назад

    Shut the damn music off

  • @matveyleshchinskiy9346
    @matveyleshchinskiy9346 4 года назад

    Great video, it has helped me a lot on my latest project