Changeset 60794 in vbox for trunk/src/VBox/ValidationKit/tests/usb
- Timestamp:
- May 2, 2016 4:13:57 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/usb/usbgadget.py
r60571 r60794 62 62 ## @{ 63 63 g_kiGadgetAccessUsbIp = 1; 64 ## @} 65 66 ## @name USB gadget config types. 67 ## @{ 68 g_kiGadgetCfgTypeBool = 1; 69 g_kiGadgetCfgTypeString = 2; 70 g_kiGadgetCfgTypeUInt8 = 3; 71 g_kiGadgetCfgTypeUInt16 = 4; 72 g_kiGadgetCfgTypeUInt32 = 5; 73 g_kiGadgetCfgTypeUInt64 = 6; 74 g_kiGadgetCfgTypeInt8 = 7; 75 g_kiGadgetCfgTypeInt16 = 8; 76 g_kiGadgetCfgTypeInt32 = 9; 77 g_kiGadgetCfgTypeInt64 = 10; 64 78 ## @} 65 79 … … 176 190 for i in range(cb): # pylint: disable=W0612 177 191 abArray.append(0); 192 return abArray; 193 194 def strToByteArry(sStr): 195 """Encodes the string as a little endian byte (B) array including the terminator.""" 196 abArray = array.array('B'); 197 sUtf8 = sStr.encode('utf_8'); 198 for i in range(0, len(sUtf8)): 199 abArray.append(ord(sUtf8[i])) 200 abArray.append(0); 201 return abArray; 202 203 def cfgListToByteArray(lst): 204 """Encodes the given config list as a little endian byte (B) array.""" 205 abArray = array.array('B'); 206 if lst is not None: 207 for t3Item in lst: 208 # Encode they key size 209 abArray.extend(u32ToByteArray(len(t3Item[0]) + 1)); # Include terminator 210 abArray.extend(u32ToByteArray(t3Item[1])) # Config type 211 abArray.extend(u32ToByteArray(len(t3Item[2]) + 1)); # Value size including temrinator. 212 abArray.extend(u32ToByteArray(0)); # Reserved field. 213 214 abArray.extend(strToByteArry(t3Item[0])); 215 abArray.extend(strToByteArry(t3Item[2])); 216 178 217 return abArray; 179 218 … … 750 789 # 751 790 752 def taskGadgetCreate(self, iGadgetType, iGadgetAccess ):791 def taskGadgetCreate(self, iGadgetType, iGadgetAccess, lstCfg = None): 753 792 """Creates a new gadget on UTS""" 754 fRc = self.sendMsg("GDGTCRT", (iGadgetType, iGadgetAccess, 0, 0)); 793 cCfgItems = 0; 794 if lstCfg is not None: 795 cCfgItems = len(lstCfg); 796 fRc = self.sendMsg("GDGTCRT", (iGadgetType, iGadgetAccess, cCfgItems, 0, cfgListToByteArray(lstCfg))); 755 797 if fRc is True: 756 798 fRc = self.recvAckLogged("GDGTCRT"); … … 839 881 # 840 882 841 def asyncGadgetCreate(self, iGadgetType, iGadgetAccess, cMsTimeout = 30000, fIgnoreErrors = False):883 def asyncGadgetCreate(self, iGadgetType, iGadgetAccess, lstCfg = None, cMsTimeout = 30000, fIgnoreErrors = False): 842 884 """ 843 885 Initiates a gadget create task. … … 848 890 """ 849 891 return self.startTask(cMsTimeout, fIgnoreErrors, "GadgetCreate", self.taskGadgetCreate, \ 850 (iGadgetType, iGadgetAccess ));851 852 def syncGadgetCreate(self, iGadgetType, iGadgetAccess, cMsTimeout = 30000, fIgnoreErrors = False):892 (iGadgetType, iGadgetAccess, lstCfg)); 893 894 def syncGadgetCreate(self, iGadgetType, iGadgetAccess, lstCfg = None, cMsTimeout = 30000, fIgnoreErrors = False): 853 895 """Synchronous version.""" 854 return self.asyncToSync(self.asyncGadgetCreate, iGadgetType, iGadgetAccess, cMsTimeout, fIgnoreErrors);896 return self.asyncToSync(self.asyncGadgetCreate, iGadgetType, iGadgetAccess, lstCfg, cMsTimeout, fIgnoreErrors); 855 897 856 898 def asyncGadgetDestroy(self, iGadgetId, cMsTimeout = 30000, fIgnoreErrors = False): … … 1327 1369 return self.oUtsSession.syncGadgetConnect(self.idGadget); 1328 1370 1329 def impersonate(self, sImpersonation ):1371 def impersonate(self, sImpersonation, fSuperSpeed = False): 1330 1372 """ 1331 1373 Impersonate a given device. … … 1338 1380 fRc = False; 1339 1381 if sImpersonation == g_ksGadgetImpersonationTest: 1340 fDone = self.oUtsSession.syncGadgetCreate(g_kiGadgetTypeTest, g_kiGadgetAccessUsbIp); 1382 lstCfg = []; 1383 if fSuperSpeed is True: 1384 lstCfg.append( ('Gadget/SuperSpeed', g_kiGadgetCfgTypeBool, 'true') ); 1385 fDone = self.oUtsSession.syncGadgetCreate(g_kiGadgetTypeTest, g_kiGadgetAccessUsbIp, lstCfg); 1341 1386 if fDone is True and self.oUtsSession.isSuccess(): 1342 1387 # Get the gadget ID.
Note:
See TracChangeset
for help on using the changeset viewer.