Ver Mensaje Individual
  #12 (permalink)  
Antiguo 28/12/2013, 18:13
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: Como saber que esta llegando por el puerto usb

razpeitia gracias por responder, hice lo que me indicas pero ya obtengo este error

Código BASH:
Ver original
  1. # python prueba3.py
  2. Traceback (most recent call last):
  3.   File "prueba3.py", line 10, in <module>
  4.     raise ValueError('Device not found')
  5. ValueError: Device not found


El codigo que quiero probar es el de la pagina http://pyusb.sourceforge.net/docs/1.0/tutorial.html
Código Python:
Ver original
  1. #coding: utf-8
  2. import usb.core
  3. import usb.util
  4.  
  5. # find our device
  6. dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)
  7.  
  8. # was it found?
  9. if dev is None:
  10.     raise ValueError('Device not found')
  11.  
  12. # set the active configuration. With no arguments, the first
  13. # configuration will be the active one
  14. dev.set_configuration()
  15.  
  16. # get an endpoint instance
  17. cfg = dev.get_active_configuration()
  18. interface_number = cfg[(0,0)].bInterfaceNumber
  19. alternate_settting = usb.control.get_interface(interface_number)
  20. intf = usb.util.find_descriptor(
  21.     cfg, bInterfaceNumber = interface_number,
  22.     bAlternateSetting = alternate_setting
  23. )
  24.  
  25. ep = usb.util.find_descriptor(
  26.     intf,
  27.     # match the first OUT endpoint
  28.     custom_match = \
  29.     lambda e: \
  30.         usb.util.endpoint_direction(e.bEndpointAddress) == \
  31.         usb.util.ENDPOINT_OUT
  32. )
  33.  
  34. assert ep is not None
  35.  
  36. # write the data
  37. ep.write('test')