Keep in mind that I am new to this USB and hardware hacking stuff.
Alright I am writing this little python application to pull the firmware from a
device using the Cypress EzUSB Fx2 chip. Snazzy little thing.
To do that you generally use fxload to load the Cypress developer kit-supplied
Vend_ax.hex code. It loads into ram, resets the cpu, and then you can get
access to some vendor commands to read and write to the eeprom.
The reason I am doing this is because I need to have a way to verify the
firmware on any random device on of this type. This is due to some sticky
certification issues that I won't bother you with. I like python so this seems
the way to go.
Once you get the vend stuff loaded then you use control messages to send a
request and your given a hunk of code.
So.. it's the syntax of the controlmsg function that I have a question about. I
have everything working right now and the script is working and all that, I
just want to make sure that this behavior is 'correct'. Because once I say this
is 'finished' it'll be very difficult to change the script.
So a truncated version of the script looks like this:
buses = usb.busses()
for bus in buses:
for device in bus.devices:
if device.idVendor == vend_id and device.idProduct == prod_id:
mooCow = device
mooCowHandler = moocow.open()
results = mooCowHandler.controlMsg(0xc0, 0xa2, data, address, 0xBEEF, 10000)
Ok.. so it works and it makes me very happy with good feelings and all that.
But my question is this:
According to the documentation I would expect that the output from the command
would be put into 'data' and the 'results' would be a return value for number
of bytes written.
| controlMsg(...)
| controlMsg(requestType, request, buffer, value=0, index=0, timeout=100)
-> bytesWritten|buffer
|
| Performs a control request to the default control pipe on a device.
| Arguments:
| requestType: specifies the direction of data flow, the type
| of request, and the recipient.
| request: specifies the request.
| buffer: if the transfer is a write transfer, buffer is a
sequence
| with the transfer data, otherwise, buffer is the number
of
| bytes to read.
| value: specific information to pass to the device. (default: 0)
| index: specific information to pass to the device. (default: 0)
| timeout: operation timeout in miliseconds. (default: 100)
| Returns the number of bytes written.
However with my code it does something quite differently.
The 'results' end up being a tuple of returned values! Not the number of bytes.
And the 'data' needs to be a number that tells it how many bytes I want
returned from the command!
This is quite a bit different then what I expect after reading the docs and
thus is why I am worried.
When I try to make the 'data' be a tuple or a list of objects or whatnot then
It'll end up being unmodified when I run the script, but the results ends up
being the number of items I put in the data list. I am confused.
So I want to make sure that this is the correct behavior for this function.
(for it to return a tuple of the results) I am not a stickler for
'correctitude' or anything like that, but I want to make sure that this
behavior isn't a 'bug' that is going to get 'fixed' and break my script in the
distant future.
I am using python-usb package version 0.4.1-4 provided by Debian
Testing/Unstable.
Thank you!!
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Pyusb-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyusb-users