Re: [pyusb-users] ctrl_transfer failed...

2014-05-21 Thread Wander Lairson Costa
2014-05-21 3:00 GMT-03:00 Slavko Kocjancic esla...@gmail.com:
 On 05/21/2014 03:36 AM, Wander Lairson Costa wrote:
 2014-05-20 13:26 GMT-03:00 Slavko Kocjancic esla...@gmail.com:
 Hello...

 I'm new to python (and pyusb).
 I try to port some VUSB device to work with python, but get at trouble
 in beggining. I can't send bytes...
 here is my example (stripped from manual...)

 import usb.core
 import usb.util

 from array import *
 dev = usb.core.find(idVendor=0x16c0, idProduct=0x05df)
 if dev is None:
   raise ValueError('Device not found')
 dev.set_configuration()

 msg = 'test'
 print dev.ctrl_transfer(32+128, 9, 0, 0, msg)

 I guess the first argument should be just 32.

 Well I want write. And bit 7 of first argument tells if this is write or
 read.
 and msg (at least by manual) behave as buffer for tx, and integer for
 size in receive mode.


Yes, with this bit set, the request is an IN transfer, and the `msg`
parameter is (wrongly) interpreted as the length of the transfer.

--
Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free.
http://p.sf.net/sfu/SauceLabs
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] ctrl_transfer failed...

2014-05-21 Thread Slavko Kocjancic
On 05/21/2014 05:27 PM, Wander Lairson Costa wrote:
 2014-05-21 3:00 GMT-03:00 Slavko Kocjancic esla...@gmail.com:
 On 05/21/2014 03:36 AM, Wander Lairson Costa wrote:
 2014-05-20 13:26 GMT-03:00 Slavko Kocjancic esla...@gmail.com:
 Hello...

 I'm new to python (and pyusb).
 I try to port some VUSB device to work with python, but get at trouble
 in beggining. I can't send bytes...
 here is my example (stripped from manual...)

 import usb.core
 import usb.util

 from array import *
 dev = usb.core.find(idVendor=0x16c0, idProduct=0x05df)
 if dev is None:
raise ValueError('Device not found')
 dev.set_configuration()

 msg = 'test'
 print dev.ctrl_transfer(32+128, 9, 0, 0, msg)

 I guess the first argument should be just 32.
 Well I want write. And bit 7 of first argument tells if this is write or
 read.
 and msg (at least by manual) behave as buffer for tx, and integer for
 size in receive mode.

 Yes, with this bit set, the request is an IN transfer, and the `msg`
 parameter is (wrongly) interpreted as the length of the transfer.

I realized that when I wan't to read from device. I'm interpreted this 
bit just opposite. But have other problem with win driver and take a lot 
of time to discover what are wrong. At least it works now.


--
Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free.
http://p.sf.net/sfu/SauceLabs
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] ctrl_transfer failed...

2014-05-21 Thread Wander Lairson Costa
2014-05-21 14:08 GMT-03:00 Slavko Kocjancic esla...@gmail.com:
 On 05/21/2014 05:27 PM, Wander Lairson Costa wrote:
 2014-05-21 3:00 GMT-03:00 Slavko Kocjancic esla...@gmail.com:
 On 05/21/2014 03:36 AM, Wander Lairson Costa wrote:
 2014-05-20 13:26 GMT-03:00 Slavko Kocjancic esla...@gmail.com:
 Hello...

 I'm new to python (and pyusb).
 I try to port some VUSB device to work with python, but get at trouble
 in beggining. I can't send bytes...
 here is my example (stripped from manual...)

 import usb.core
 import usb.util

 from array import *
 dev = usb.core.find(idVendor=0x16c0, idProduct=0x05df)
 if dev is None:
raise ValueError('Device not found')
 dev.set_configuration()

 msg = 'test'
 print dev.ctrl_transfer(32+128, 9, 0, 0, msg)

 I guess the first argument should be just 32.
 Well I want write. And bit 7 of first argument tells if this is write or
 read.
 and msg (at least by manual) behave as buffer for tx, and integer for
 size in receive mode.

 Yes, with this bit set, the request is an IN transfer, and the `msg`
 parameter is (wrongly) interpreted as the length of the transfer.

 I realized that when I wan't to read from device. I'm interpreted this
 bit just opposite. But have other problem with win driver and take a lot
 of time to discover what are wrong. At least it works now.



You can use the util.build_request_type function to avoid bit mistakes.



-- 
Best Regards,
Wander Lairson Costa

--
Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free.
http://p.sf.net/sfu/SauceLabs
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] ctrl_transfer failed...

2014-05-20 Thread Wander Lairson Costa
2014-05-20 13:26 GMT-03:00 Slavko Kocjancic esla...@gmail.com:
 Hello...

 I'm new to python (and pyusb).
 I try to port some VUSB device to work with python, but get at trouble
 in beggining. I can't send bytes...
 here is my example (stripped from manual...)

 import usb.core
 import usb.util

 from array import *
 dev = usb.core.find(idVendor=0x16c0, idProduct=0x05df)
 if dev is None:
  raise ValueError('Device not found')
 dev.set_configuration()

 msg = 'test'
 print dev.ctrl_transfer(32+128, 9, 0, 0, msg)


I guess the first argument should be just 32.

 and there is error report

 Traceback (most recent call last):
File pyusbtest.py, line 13, in module
  print dev.ctrl_transfer(32+128, 9, 0, 0, msg)
File /usr/local/lib/python2.7/dist-packages/usb/core.py, line 711,
 in ctrl_transfer
  self.__get_timeout(timeout)
File /usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py,
 line 823, in ctrl_transfer
  buff = _interop.as_array((0,) * data_or_wLength)
 TypeError: can't multiply sequence by non-int of type 'str'

 how to proceed? (python2.7 on ubuntu)
 slavko.






-- 
Best Regards,
Wander Lairson Costa

--
Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free.
http://p.sf.net/sfu/SauceLabs
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users