-2

pyusb doesnt find any usb devices.I tried several devices and copied/pasted the VID and PID. Has anyone an idea,what I am doing wrong? I get always an error message: NameError: name '_04F2' is not defined

import usb.core
import usb.util

dev = usb.core.find(idVendor=_04F2, idProduct=_B449)
  if dev is None:
    raise ValueError('Device is not found')
theozh
  • 22,244
  • 5
  • 28
  • 72
subwafer
  • 1
  • 1
  • what is `_04F2`? – MoRe Jul 22 '22 at 11:19
  • 1
    maybe it should be string `"_04F2"` and `"_B449"` evetually it may need hex value `0x04F2` and `0xB449`. For Python your `_04F2` and `_B449` are names of variables, not values. – furas Jul 22 '22 at 12:37

1 Answers1

0

For Python your _04F2 and _B449 mean names of variables, not values, so you could do

_04F2 = "Hello World"
print(_04F2)

for _B449 in range(10):
    print(_B449)

Probably you needs string "_04F2" and "_B449"

dev = usb.core.find(idVendor="_04F2", idProduct="_B449")

evetually hex value 0x04F2 and 0xB449.

dev = usb.core.find(idVendor=0x04F2, idProduct=0xB449)
furas
  • 134,197
  • 12
  • 106
  • 148