Tony Liu | 22 Feb 01:21 2013
Picon

Device writing timeout problem

Hi all,

I'm new to PyUSB, and now i'm working on communicating with a costumed chip. 
The chip use two endpoint and one is use for in and another for out, and the manufacturer told me just to send raw date to it with different value of command.

When I try this:

buf = struct.pack("b",2)

buf1 = struct.pack("b",0)

print(buf+buf1+buf1)

device.write(0x81,buf+buf1+buf1,0,100)


I got the error of 

Traceback (most recent call last):

  File "/Users/tonyliu/Documents/Aptana Studio 3 Workspace/Final-Year-Project/Test/USB_Test.py", line 81, in <module>

    device.write(0x81,buf+buf1+buf1,0,100)

  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/core.py", line 626, in write

    self.__get_timeout(timeout)

  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/backend/libusb1.py", line 532, in bulk_write

    timeout)

  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/backend/libusb1.py", line 631, in __write

    _check(retval)

  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/backend/libusb1.py", line 403, in _check

    raise USBError(_str_error[ret], ret, _libusb_errno[ret])

usb.core.USBError: [Errno 60] Operation timed out

Exception AttributeError: "'NoneType' object has no attribute 'libusb_exit'" in <bound method _Initializer.__del__ of <usb.backend.libusb1._Initializer object at 0x101134ad0>> ignored


Is this means I do not send data correctly or other?


Thanks a lot.


Tony

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
pyusb-users mailing list
pyusb-users@...
https://lists.sourceforge.net/lists/listinfo/pyusb-users
Wander Lairson Costa | 22 Feb 01:28 2013
Picon

Re: Device writing timeout problem

2013/2/21 Tony Liu <tonynothing@...>:
> Hi all,
>
> I'm new to PyUSB, and now i'm working on communicating with a costumed chip.
> The chip use two endpoint and one is use for in and another for out, and the
> manufacturer told me just to send raw date to it with different value of
> command.
>
> When I try this:
>
> buf = struct.pack("b",2)
>
> buf1 = struct.pack("b",0)
>
> print(buf+buf1+buf1)
>
> device.write(0x81,buf+buf1+buf1,0,100)
>
>
> I got the error of
>
> Traceback (most recent call last):
>
>   File "/Users/tonyliu/Documents/Aptana Studio 3
> Workspace/Final-Year-Project/Test/USB_Test.py", line 81, in <module>
>
>     device.write(0x81,buf+buf1+buf1,0,100)
>
>   File
> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/core.py",
> line 626, in write
>
>     self.__get_timeout(timeout)
>
>   File
> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/backend/libusb1.py",
> line 532, in bulk_write
>
>     timeout)
>
>   File
> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/backend/libusb1.py",
> line 631, in __write
>
>     _check(retval)
>
>   File
> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/backend/libusb1.py",
> line 403, in _check
>
>     raise USBError(_str_error[ret], ret, _libusb_errno[ret])
>
> usb.core.USBError: [Errno 60] Operation timed out
>
> Exception AttributeError: "'NoneType' object has no attribute 'libusb_exit'"
> in <bound method _Initializer.__del__ of <usb.backend.libusb1._Initializer
> object at 0x101134ad0>> ignored
>
>
> Is this means I do not send data correctly or other?
>
>

In general, you should at least call set_configuration() before trying
to talk to a device. Have you done that?

--

-- 
Best Regards,
Wander Lairson Costa

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
Tony Liu | 22 Feb 01:56 2013
Picon

Re: Device writing timeout problem

Yes I put it after the find() function.
Do I need add other configuration functions?

Cheers,

Tony

On 22 Feb 2013, at 00:29, Wander Lairson Costa
<wander.lairson@...> wrote:

> 2013/2/21 Tony Liu <tonynothing@...>:
>> Hi all,
>>
>> I'm new to PyUSB, and now i'm working on communicating with a costumed chip.
>> The chip use two endpoint and one is use for in and another for out, and the
>> manufacturer told me just to send raw date to it with different value of
>> command.
>>
>> When I try this:
>>
>> buf = struct.pack("b",2)
>>
>> buf1 = struct.pack("b",0)
>>
>> print(buf+buf1+buf1)
>>
>> device.write(0x81,buf+buf1+buf1,0,100)
>>
>>
>> I got the error of
>>
>> Traceback (most recent call last):
>>
>>  File "/Users/tonyliu/Documents/Aptana Studio 3
>> Workspace/Final-Year-Project/Test/USB_Test.py", line 81, in <module>
>>
>>    device.write(0x81,buf+buf1+buf1,0,100)
>>
>>  File
>> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/core.py",
>> line 626, in write
>>
>>    self.__get_timeout(timeout)
>>
>>  File
>> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/backend/libusb1.py",
>> line 532, in bulk_write
>>
>>    timeout)
>>
>>  File
>> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/backend/libusb1.py",
>> line 631, in __write
>>
>>    _check(retval)
>>
>>  File
>> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/usb/backend/libusb1.py",
>> line 403, in _check
>>
>>    raise USBError(_str_error[ret], ret, _libusb_errno[ret])
>>
>> usb.core.USBError: [Errno 60] Operation timed out
>>
>> Exception AttributeError: "'NoneType' object has no attribute 'libusb_exit'"
>> in <bound method _Initializer.__del__ of <usb.backend.libusb1._Initializer
>> object at 0x101134ad0>> ignored
>>
>>
>> Is this means I do not send data correctly or other?
>
> In general, you should at least call set_configuration() before trying
> to talk to a device. Have you done that?
>
> --
> Best Regards,
> Wander Lairson Costa
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> pyusb-users mailing list
> pyusb-users@...
> https://lists.sourceforge.net/lists/listinfo/pyusb-users

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
Wander Lairson Costa | 22 Feb 02:05 2013
Picon

Re: Device writing timeout problem

2013/2/21 Tony Liu <tonynothing@...>:
> Yes I put it after the find() function.
> Do I need add other configuration functions?
>

I mean, the set_configuration method from Device class. Please, refer
to the tutorial if you are in doubt.

--

-- 
Best Regards,
Wander Lairson Costa

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
Tony Liu | 22 Feb 15:25 2013
Picon

Re: Device writing timeout problem

Hi,

I look back to the tutorial and I write the programme to get the endpoint instances, one is in and another is out.

ep_in = usb.util.find_descriptor(

    intf,

    custom_match = \

    lambda e: \

        usb.util.endpoint_direction(e.bEndpointAddress) == \

        usb.util.ENDPOINT_IN

)

ep_out = usb.util.find_descriptor(

    intf,

    # match the first OUT endpoint

    custom_match = \

    lambda e: \

        usb.util.endpoint_direction(e.bEndpointAddress) == \

        usb.util.ENDPOINT_OUT

)

And when I try this:

 print(ep_out.read(64))

it does work and get some data from usb device. But when I try to write something into the device, like this:

 buf = struct.pack("b",7)

 ep_in.write(buf)

it still got the timeout problem.


Cheers,

Tony



On 22 February 2013 01:05, Wander Lairson Costa <wander.lairson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
2013/2/21 Tony Liu <tonynothing <at> gmail.com>:
> Yes I put it after the find() function.
> Do I need add other configuration functions?
>

I mean, the set_configuration method from Device class. Please, refer
to the tutorial if you are in doubt.

--
Best Regards,
Wander Lairson Costa

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
pyusb-users mailing list
pyusb-users-5NWGOfrQmnd4wTydcyPnfg@public.gmane.orgceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users



--

Tony

Yinhua LIU

Electronic & Computer Engineering

University of Nottingham

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
pyusb-users mailing list
pyusb-users@...
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Gmane