2010/7/16 John Harrison <johnharrison...@gmail.com>:
> I appreciate your end goal and understand how hard that could be. In any
> case, this now may be going beyond the scope of what this list is for. If so
> just tell me and I'll stop. But I did get somewhere. I can now write to the
> device but I can't read from it yet.
>
> I found in the manual to the device:
>
> Command       | Description          | bRequest | Direction |
> StringMessage | Send string messages | 0x80     | In/Out    |
>                 to the device
>
> RawData       | Return raw data      | 0x81     | In        |
>                 from the device
>
> So I tried
> print dev.ctrl_transfer(0x40,0x80,0,0, MyCommand)
>
> The command did return the length of the command and the command was
> executed by the device. WOO HOO!
>
> But I can't seem to figure out how to get the response. For one thing, the
> command I sent also sent a response...somewhere. I also tried:
>
> print dev.ctrl_transfer(0x40,0x81,0,0, len(MyCommand))
>
> to get a response and that returns an error in line 653 of ctrl_transfer in
> core.pyc: "TypeError: 'int' object is not iterable"

Try this:

print dev.ctrl_transfer(0xC0,0x81,0,0, len(MyCommand))

>
> BTW your code to calculate bmRequestType also returned 0x40.
>
> -John
>
>
>
>
> On Fri, Jul 16, 2010 at 11:08 AM, Wander Lairson <wander.lair...@gmail.com>
> wrote:
>>
>> 2010/7/16 John Harrison <johnharrison...@gmail.com>:
>> > Perhaps I am not reading the right parts of the documentation but I
>> > can't
>> > figure out how to write to my device even given your hints about my
>> > device
>> > not having endpoints. Frankly I don't even know what an endpoint is. I
>> > was
>> > hoping not to have to know. :-) I just need to send some simple strings
>> > to
>> > my device and get back some floats.
>>
>> Getting PyUSB users talking to USB devices without USB knowledge is my
>> ultimate goal, but it is harder to do than it sounds. I have some
>> ideas for common
>> cases which I intend to implement in the future.
>>
>> I don't know much of your device, but I guess you have to use
>> ctrl_transfer to send and receive to/from it.
>> The point is that control transfers are the most complicated type of
>> transfer in the USB standard,
>> because it is a structured transfer. Here is an example from my test
>> firmware:
>>
>> import usb.core
>> import usb.util
>>
>> dev = usb.core.find(idVendor=0xfffe)
>>
>> msg = 'test'
>>
>> bmRequestType = usb.util.build_request_type(usb.util.CTRL_OUT,
>>
>> usb.util.CTRL_TYPE_VENDOR,
>>
>> usb.util.CTRL_RECIPIENT_DEVICE)
>>
>> dev.ctrl_transfer(bmRequestType, CTRL_LOOPBACK_WRITE, 0, 0, msg)
>>
>> CTRL_LOOPBACK_WRITE is a private request that I implemented in the
>> firmware. If I am right about your device, you will need to know from
>> some kind of datesheet what requests your device implement.
>>
>> >
>> > Also how can I issue my own GET_STRING request to get a description of a
>> > serial number, for example?
>>
>> Actually, PyUSB will implement a get_string function in the near
>> future, it is just not implemented right now (but 0.4 version does).
>> You may implement it using ctrl_transfer method, as GET_STRING is
>> nothing else than a kind of standard control request, but I think this
>> is not related to your issue.
>>
>> >
>> > On Fri, Jul 16, 2010 at 8:43 AM, Wander Lairson
>> > <wander.lair...@gmail.com>
>> > wrote:
>> >>
>> >> 2010/7/16 John Harrison <johnharrison...@gmail.com>:
>> >> > Running testlibusb-win.exe I see:
>> >> >
>> >> > DLL version:    1.2.0.0
>> >> > Driver version:    1.2.0.0
>> >> >
>> >> > bus/device  idVendor/idProduct
>> >> > bus-0/\\.\libusb0-0002--0x09db-0x00f9     09DB/00F9
>> >> > - Manufacturer : Measurement Computing
>> >> > - Product      : USB-2001-TC
>> >> > - Serial Number: 014F0F9C
>> >> >   wTotalLength:         18
>> >> >   bNumInterfaces:       1
>> >> >   bConfigurationValue:  1
>> >> >   iConfiguration:       0
>> >> >   bmAttributes:         80h
>> >> >   MaxPower:             250
>> >> >     bInterfaceNumber:   0
>> >> >     bAlternateSetting:  0
>> >> >     bNumEndpoints:      0
>> >> >     bInterfaceClass:    255
>> >> >     bInterfaceSubClass: 255
>> >> >     bInterfaceProtocol: 0
>> >> >     iInterface:         0
>> >> >
>> >> > The product and Manufacturer match the device I am trying to
>> >> > communicate
>> >> > with. BTW these values seem different with pyUSB. For example
>> >> >
>> >> > dev = usb.core.find(idVendor=0x09db, idProduct=0x00f9)
>> >> > dev.iSerialNumber
>> >> >
>> >> > returns the value 3.
>> >>
>> >> I guess testlibusb-win issues a GET_STRING request over the value 3 to
>> >> get a description of the serial number. Therefore it is ok.
>> >> Now backing to your original problem, your device doesn't have any
>> >> endpoints, this is because find_descriptor returned None and the
>> >> assertion failed. Maybe your device only talks through endpoint 0 (a
>> >> control endpoint that is kind of built-in).
>> >>
>> >> >
>> >> > -John
>> >> >
>> >> > On Thu, Jul 15, 2010 at 6:02 PM, Xiaofan Chen <xiaof...@gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> On Fri, Jul 16, 2010 at 2:12 AM, Wander Lairson
>> >> >> <wander.lair...@gmail.com> wrote:
>> >> >> > 2010/7/15 John Harrison <johnharrison...@gmail.com>:
>> >> >> >> libusb-win32-bin-1.2.0.0\bin\x86>testlibusb.exe
>> >> >> >> Dev #0: 0000 - 0000
>> >> >> >>   Dev #2: Measurement Computing - USB-2001-TC
>> >> >> >>
>> >> >> >> Dev #2 is the correct name for my device.
>> >> >> >
>> >> >> > Oh, sorry, I mentioned the wrong test app. I don't remember its
>> >> >> > name
>> >> >> > and I don't have an Windows machine right now, but I mean the test
>> >> >> > application with graphical interface, which dumps all device
>> >> >> > descriptors...
>> >> >>
>> >> >> testlibusb-win.exe
>> >> >>
>> >> >> To John:
>> >> >>
>> >> >> +++++++++++++
>> >> >> http://sourceforge.net/apps/trac/libusb-win32/wiki
>> >> >> Please describe your problems and your system as precise as possible
>> >> >> (OS, service packs, version of libusb-win32, type of device, output
>> >> >> of
>> >> >> "testlibusb-win.exe", etc.). This will make solving problems a lot
>> >> >> easier.
>> >> >> +++++++++++++
>> >> >>
>> >> >> BTW, if you have not done so, please update to libusb-win32 1.2.0.0.
>> >> >>
>> >> >> --
>> >> >> Xiaofan http://sourceforge.net/projects/libusb-win32/
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> ------------------------------------------------------------------------------
>> >> >> This SF.net email is sponsored by Sprint
>> >> >> What will you do first with EVO, the first 4G phone?
>> >> >> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>> >> >> _______________________________________________
>> >> >> pyusb-users mailing list
>> >> >> pyusb-users@lists.sourceforge.net
>> >> >> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > ------------------------------------------------------------------------------
>> >> > This SF.net email is sponsored by Sprint
>> >> > What will you do first with EVO, the first 4G phone?
>> >> > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>> >> > _______________________________________________
>> >> > pyusb-users mailing list
>> >> > pyusb-users@lists.sourceforge.net
>> >> > https://lists.sourceforge.net/lists/listinfo/pyusb-users
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Best Regards,
>> >> Wander Lairson Costa
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >> This SF.net email is sponsored by Sprint
>> >> What will you do first with EVO, the first 4G phone?
>> >> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>> >> _______________________________________________
>> >> pyusb-users mailing list
>> >> pyusb-users@lists.sourceforge.net
>> >> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>> >
>> >
>> >
>> > --
>> > John
>> > http://alumni.media.mit.edu/~harrison/
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > This SF.net email is sponsored by Sprint
>> > What will you do first with EVO, the first 4G phone?
>> > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>> > _______________________________________________
>> > pyusb-users mailing list
>> > pyusb-users@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/pyusb-users
>> >
>> >
>>
>>
>>
>> --
>> Best Regards,
>> Wander Lairson Costa
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by Sprint
>> What will you do first with EVO, the first 4G phone?
>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>> _______________________________________________
>> pyusb-users mailing list
>> pyusb-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>
>



-- 
Best Regards,
Wander Lairson Costa

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to