?> python setup.py install
file: http://darcs.erazor-zone.de/python/ezusb/ezusb.py
""" EZUSB Object copyright Alexander Krause <alexander.krause@erazor-zone.de> date 2006.06.06 version 0.0.1 """ import usb from ihex import ihex class DeviceNotFound(Exception): def __init__(self,value): self.value=value def __str__(self): return repr(self.value) class EZUSB: "EZUSB device class, to manage EZUSB via libusb" def __init__(self,vendorid,productid): self.device=self.findDevice(vendorid,productid) self.vendorid=vendorid self.productid=productid def findDevice(self,vendorid,productid): "get the first device on any bus with the given vendorid and productid." for bus in usb.busses(): for device in bus.devices: if (device.idVendor==vendorid) and (device.idProduct==productid): return device raise DeviceNotFound,'no device found' def writeRAM(self,addr,buffer): "write values directly into ram at address addr via endpoint-zero calls." self.device.open().controlMsg(0x40,0xa0,buffer,addr,0x00,1000) def reset(self,state=3): if state==3: self.writeRAM(0x7f92,[state&0x01]) else: self.writeRAM(0x7f92,[1]) self.writeRAM(0x7f92,[0]) def downloadFW(self,filename): self.reset(1) newFW=ihex(filename) for mrecord in newFW.mrecords: self.writeRAM(mrecord.address,mrecord.data) self.reset(0)