2012/2/10 Lance R. Vick <la...@lrvick.net>:
> Hello all.
>
> So I have some working c code for a temperature Temper1v1.1 usb temperature
> sensor I recently bought: http://pastie.org/3354037
>
> But I want to port this to using pure python via pyusb.
>
> Based on the working c code I came up with the following:
>

I don't know why your c code is working, because you didn't claim the
interfaces.

> ------------
>
> import usb.core
>
> dev = usb.core.find(idVendor=0x0c45,idProduct=0x7401)
>
> if dev.is_kernel_driver_active(0):
>     dev.detach_kernel_driver(0)
>     dev.detach_kernel_driver(1)
>
> dev.set_configuration()
>
> request = ''.join([chr(x) for x in
> [0x01,0x80,0x33,0x01,0x00,0x00,0x00,0x00]])
>
> dev.ctrl_transfer(0x21,9,0x200,0x1,request,8)
>
> ret = dev.read(0x82,8,0)
>
> print(ret)
>
> ------------
>
> However, this fails with the following Traceback
>
> ------------
>
>
> Traceback (most recent call last):
>   File
> "/home/lrvick/.virtualenvs/temper1/lib/python3.2/site-packages/usb/core.py",
> line 177, in get_endpoint_type
>     return self._ep_type_map[key]
> KeyError: (130, 0, 0)
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "temper1.py", line 15, in <module>
>     ret = dev.read(0x82,8,0)
>   File
> "/home/lrvick/.virtualenvs/temper1/lib/python3.2/site-packages/usb/core.py",
> line 629, in read
>     fn = fn_map[self._ctx.get_endpoint_type(self, endpoint, intf)]
>   File
> "/home/lrvick/.virtualenvs/temper1/lib/python3.2/site-packages/usb/core.py",
> line 180, in get_endpoint_type
>     etype = util.endpoint_type(e.bmAttributes)
> AttributeError: 'NoneType' object has no attribute 'bmAttributes'
>
> ------------
>
>
> Clearly I am doing something wrong but I have no idea what to try next.  Any
> ideas?
>

There is only one thing that I can imagine: endpoint 0x82 belongs to
interface 1, not interface 0. Furthermore, can you can that the
interface numbers are 0 and 1? It is often the case, but not a rule.

-- 
Best Regards,
Wander Lairson Costa

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to