Good Day,
Here we are using USB 3.0 loopback hardware in our manufacturing test environment. 4ea Passmark are connected to the downstream port of our product.
During current testing, we are using Python subprocess to test the USB 3.0 loopback for each Passmark loopback, so basically they are running loopback one by one.
In order to reduce the total test time, we try to modify the code to use threading to run the loopback on different loopback hardware simultaneously.
Here is our partial python code to call the different loopback hardware to run the USB3Console.exe, but looks like the result is quite unstable, sometimes the return code will indicate the loopback hardware can't be find. I would like to confirm if USB3Console.exe is friendly to multi-threading application?
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def Passmark_Attach_1():
def run_usb_test(device, usb2_result_array, usb3_result_array):
def Passmark_USB_Test(m):
if __name__ == "__main__":
Here we are using USB 3.0 loopback hardware in our manufacturing test environment. 4ea Passmark are connected to the downstream port of our product.
During current testing, we are using Python subprocess to test the USB 3.0 loopback for each Passmark loopback, so basically they are running loopback one by one.
In order to reduce the total test time, we try to modify the code to use threading to run the loopback on different loopback hardware simultaneously.
Here is our partial python code to call the different loopback hardware to run the USB3Console.exe, but looks like the result is quite unstable, sometimes the return code will indicate the loopback hardware can't be find. I would like to confirm if USB3Console.exe is friendly to multi-threading application?
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def Passmark_Attach_1():
p = subprocess.Popen(r"M:\\Result\\FunctionalTestScrip tGE\\USB3Console.exe -f", stdout = subprocess.PIPE)
output = p.communicate()
returncode = p.wait()
data = output[0].decode("utf-8").splitlines()
time.sleep(2)
serial_number_array_1 = []
for i in data:
output = p.communicate()
returncode = p.wait()
data = output[0].decode("utf-8").splitlines()
time.sleep(2)
serial_number_array_1 = []
for i in data:
find_device_data = i.split("=")
serial_number_array_1.append(find_device_data[1])
p.kill()
return serial_number_array_1
return serial_number_array_1
def run_usb_test(device, usb2_result_array, usb3_result_array):
p_usb2 = subprocess.Popen(r"M:\\Result\\FunctionalTestScrip tBB\\USB3Console.exe -d {} -s USB2 -t 2 -l 1".format(device), stdout=subprocess.PIPE)
returncode_usb2 = p_usb2.wait()
if returncode_usb2 == 0:
returncode_usb2 = p_usb2.wait()
if returncode_usb2 == 0:
usb2_result_array.append("Pass")
else:
usb2_result_array.append("Fail")
p_usb3 = subprocess.Popen(r"M:\\Result\\FunctionalTestScrip tBB\\USB3Console.exe -d {} -s USB3 -t 2 -l 1".format(device), stdout=subprocess.PIPE)
returncode_usb3 = p_usb3.wait()
returncode_usb3 = p_usb3.wait()
if returncode_usb3 == 0:
usb3_result_array.append("Pass")
else:
usb3_result_array.append("Fail")
def Passmark_USB_Test(m):
usb3_result_array = []
usb2_result_array = []
result = {}
if len(m) < 1:
usb2_result_array = []
result = {}
if len(m) < 1:
result.update({'USB 2 Result': 'Fail', 'USB 3 Result': 'Fail'})
else:
threads = []
for i in m:
for i in m:
thread_usb = threading.Thread(target=run_usb_test, args=(i, usb2_result_array, usb3_result_array))
threads.append(thread_usb)
thread_usb.start()
threads.append(thread_usb)
thread_usb.start()
for thread in threads:
thread.join()
if len(usb3_result_array) != len(m) and len(usb2_result_array)!=len(m):
result.update({'USB 2 Result': 'Fail', 'USB 3 Result': 'Fail'})
else:
if "Fail" in usb3_result_array:
result.update({'USB 3 Result': 'Fail'})
else:
result.update({'USB 3 Result': 'Pass'})
if "Fail" in usb2_result_array:
result.update({'USB 2 Result': 'Fail'})
else:
result.update({'USB 2 Result': 'Pass'})
return result
if __name__ == "__main__":
while(True):
usb_result = None
time.sleep(2)
passmark_serial_1 = Passmark_Attach_1()
print(passmark_serial_1)
usb_result = Passmark_USB_Test(passmark_serial_1)
print(usb_result)
time.sleep(2)
passmark_serial_1 = Passmark_Attach_1()
print(passmark_serial_1)
usb_result = Passmark_USB_Test(passmark_serial_1)
print(usb_result)
Comment