X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETMAXUSB.py;h=f16da04d98d49edc9fdd325f5699ffb9dac50600;hp=8f05d43d7ec6c60ea90e0e0f727d0ccb0b1dc199;hb=ee53514febab9c7a9d341e60ba0f9b9a1dc161d7;hpb=2f6dc7ff6da98e249560706dd14a8cda9ad23e51 diff --git a/client/GoodFETMAXUSB.py b/client/GoodFETMAXUSB.py index 8f05d43..f16da04 100644 --- a/client/GoodFETMAXUSB.py +++ b/client/GoodFETMAXUSB.py @@ -90,7 +90,7 @@ GD_STRING =0x03 # Get device descriptor: String GD_HID =0x21 # Get descriptor: HID GD_REPORT =0x22 # Get descriptor: Report -# SETUP packet offsets +# SETUP packet header offsets bmRequestType =0 bRequest =1 wValueL =2 @@ -203,6 +203,16 @@ bmHXFRDNIRQ =0x80 class GoodFETMAXUSB(GoodFET): MAXUSBAPP=0x40; + + def setup2str(self,SUD): + """Converts the header of a setup packet to a string.""" + return "bmRequestType=0x%02x, bRequest=0x%02x, wValue=0x%04x, wIndex=0x%04x, wLength=0x%04x" % ( + ord(SUD[0]), ord(SUD[1]), + ord(SUD[2])+(ord(SUD[3])<<8), + ord(SUD[4])+(ord(SUD[5])<<8), + ord(SUD[6])+(ord(SUD[7])<<8) + ); + def MAXUSBsetup(self): """Move the FET into the MAXUSB application.""" self.writecmd(self.MAXUSBAPP,0x10,0,self.data); #MAXUSB/SETUP @@ -318,9 +328,11 @@ class GoodFETMAXUSB(GoodFET): #Very innefficient, move this to C if performance is needed. for j in range(0,pktsize): self.xfrdata=self.xfrdata+[self.rreg(rRCVFIFO)]; + xfrsize=self.xfrdata[0]; self.wreg(rHIRQ,bmRCVDAVIRQ); #Clear IRQ xfrlen=xfrlen+pktsize; #Add byte count to total transfer length. + print "%i / %i" % (xfrlen,xfrsize) #Packet is complete if: # 1. The device sent a short packet,