[pyar] portando un dispositivo HID de windows a linux con pyusb 1.0a

Marcos Wolff wmarcos en gmail.com
Vie Dic 17 08:15:08 ART 2010


Con esa línea me devuelve esto:

  File "prueba.py", line 27, in <module>
    print dev.read(0x81, 5, timeout=1e99)
  File "/home/administrador/pyusb-1.0.0-a0/usb/core.py", line 624, in read
    self.__get_timeout(timeout)
  File "/home/administrador/pyusb-1.0.0-a0/usb/_debug.py", line 53, in
do_trace
    return f(*args, **named_args)
  File "/home/administrador/pyusb-1.0.0-a0/usb/backend/libusb10.py", line
501, in intr_read
    timeout)
  File "/home/administrador/pyusb-1.0.0-a0/usb/backend/libusb10.py", line
581, in __read
    timeout))
ctypes.ArgumentError: argument 6: <type 'exceptions.TypeError'>: wrong type

pero con esta print dev.read(0x81, 5, timeout=2000) funcionó perfecto !!!


$ sudo python prueba.py
array('B', [155, 53, 16, 3, 0])

GRACIAS MANU !! :D :D


2010/12/16 Manuel Naranjo <naranjo.manuel en gmail.com>

>  Buenas,
>
>  #configuration
> import usb.core
> dev = usb.core.find(idVendor=1240,idProduct=32)
> if dev is None:
>     raise ValueError('Device not found')
> interface = dev.get_interface_altsetting()
> if dev.is_kernel_driver_active(interface.bInterfaceNumber) is True:
>         dev.detach_kernel_driver(interface.bInterfaceNumber)
> dev.set_configuration()
> dev.reset()
>
>  #communication code
> msg = [0x02,0x03,0x00]
> print dev.write(1, msg)
> print dev.read(0x81, 5)
>
> No le estas pasandole un timeout. El valor por defecto es 1000, pero capaz
> q' no sea suficiente, proba de pasarle un número gigante a ver si empieza a
> andar
> print dev.read(0x81, 5, timeout=1e99)
>
> Saludos,
> Manu
>
> _______________________________________________
> pyar mailing list pyar en python.org.ar
> http://listas.python.org.ar/listinfo/pyar
>
> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20101217/1c570302/attachment.html>


More information about the pyar mailing list