Mercurial > ~darius > hgwebdir.cgi > pyinst
diff usb488.py @ 8:381ed6f3d2d7
Save handle after using it, makes the code look nicer.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Sat, 16 May 2009 23:32:33 +0930 |
parents | 813e183cfd49 |
children | a6b746654ae2 |
line wrap: on
line diff
--- a/usb488.py Sat May 16 23:31:26 2009 +0930 +++ b/usb488.py Sat May 16 23:32:33 2009 +0930 @@ -69,8 +69,7 @@ # 2 bTagInverse 1 0xfd Inverse of previous field # 3 Reserved 1 0x00 # 4 TransferSize 4 0x64 -# 5 .. 0x00 -# 6 .. 0x00 +# 5 .. 0x00# 6 .. 0x00 # 7 .. 0x00 # 8 bmTransferAttr 1 0x00 # 9 Term char 1 0x00 @@ -135,10 +134,12 @@ raise "Could not find a suitable USB device" # Open the device and claim the USB interface that supports the spec - self.handle = dev.open() - self.handle.setConfiguration(dev.configurations[confidx].value) - self.handle.claimInterface(altif.interfaceNumber) - self.handle.setAltInterface(altif.alternateSetting) + handle = dev.open() + handle.setConfiguration(dev.configurations[confidx].value) + handle.claimInterface(altif.interfaceNumber) + handle.setAltInterface(altif.alternateSetting) + self.dev = dev + self.handle = handle # Get some info for humans self.vendname = self.handle.getString(dev.iManufacturer, 1024)