comparison 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
comparison
equal deleted inserted replaced
7:813e183cfd49 8:381ed6f3d2d7
67 # 0 MsgID 1 0x02 REQUEST_DEV_DEP_MSG_IN 67 # 0 MsgID 1 0x02 REQUEST_DEV_DEP_MSG_IN
68 # 1 bTag 1 0x02 Varies with each transfer 68 # 1 bTag 1 0x02 Varies with each transfer
69 # 2 bTagInverse 1 0xfd Inverse of previous field 69 # 2 bTagInverse 1 0xfd Inverse of previous field
70 # 3 Reserved 1 0x00 70 # 3 Reserved 1 0x00
71 # 4 TransferSize 4 0x64 71 # 4 TransferSize 4 0x64
72 # 5 .. 0x00 72 # 5 .. 0x00# 6 .. 0x00
73 # 6 .. 0x00
74 # 7 .. 0x00 73 # 7 .. 0x00
75 # 8 bmTransferAttr 1 0x00 74 # 8 bmTransferAttr 1 0x00
76 # 9 Term char 1 0x00 75 # 9 Term char 1 0x00
77 # 10 Reserved 1 0x00 76 # 10 Reserved 1 0x00
78 # 11 Reserved 1 0x00 77 # 11 Reserved 1 0x00
133 break 132 break
134 if not found: 133 if not found:
135 raise "Could not find a suitable USB device" 134 raise "Could not find a suitable USB device"
136 135
137 # Open the device and claim the USB interface that supports the spec 136 # Open the device and claim the USB interface that supports the spec
138 self.handle = dev.open() 137 handle = dev.open()
139 self.handle.setConfiguration(dev.configurations[confidx].value) 138 handle.setConfiguration(dev.configurations[confidx].value)
140 self.handle.claimInterface(altif.interfaceNumber) 139 handle.claimInterface(altif.interfaceNumber)
141 self.handle.setAltInterface(altif.alternateSetting) 140 handle.setAltInterface(altif.alternateSetting)
141 self.dev = dev
142 self.handle = handle
142 143
143 # Get some info for humans 144 # Get some info for humans
144 self.vendname = self.handle.getString(dev.iManufacturer, 1024) 145 self.vendname = self.handle.getString(dev.iManufacturer, 1024)
145 self.prodname = self.handle.getString(dev.iProduct, 1024) 146 self.prodname = self.handle.getString(dev.iProduct, 1024)
146 self.serial = self.handle.getString(dev.iSerialNumber, 1024) 147 self.serial = self.handle.getString(dev.iSerialNumber, 1024)