Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions usb_test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# USB Device mode Validation

## Overview

This folder contains script related to basic USB functionalities.

1) usb_enum_win.py -> To check the enumeration of DUT in Windows host
2) usb_enum_linux.py -> To check the enumeration of DUT in Linux host

## Prerequisites

For Windows
1) Python 3
2) pip install subprocess
3) Devcon

For Linux
1) Python3

## Usage

To run the script: python "filename"

The script will prompt you to enter the PID. Enter the PID according to the variant of the meta.

PID for ADV variant -> 9135
PID for STD variant -> D002
14 changes: 14 additions & 0 deletions usb_test/usb_enum_linux.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os

def check_device_status(pid):
command = f'lsusb | grep -i {pid}'
if(os.system(command) == 0):
print("DUT is properly enumerated")
return True
else:
print("DUT is not found")
return False

if __name__ == "__main__":
pid = input("Enter the PID of the device: ")
check_device_status(pid)
48 changes: 48 additions & 0 deletions usb_test/usb_enum_win.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import time
import subprocess

def check_device_status(pid):
# Run the devcon status command with the given PID
command = f'devcon status *{pid}*'
result = subprocess.run(command, capture_output=True, universal_newlines=True, stdin=subprocess.DEVNULL,shell=True)
out, err = result.stdout, result.stderr
if out.find("The device has the following problem") != -1:
print("DUT Not properly enumerated. Might be some yellow bang on PCs Device Manager or still taking time to enumerate:{}".format(out))
print('Checking for 2nd time after waiting for 10 sec')
time.sleep(10)
result = subprocess.run(command, capture_output=True, universal_newlines=True, stdin=subprocess.DEVNULL,shell=True)
out, err = result.stdout, result.stderr
if out.find("The device has the following problem") != -1:
print("DUT Not properly enumerated. Surely be some yellow bang on PCs Device Manager:{}".format(out))
return False
elif out.find("Driver is running") != -1:
print("DUT is properly enumerated")
return True
else:
print("DUT is not found")
print(out)
return False
elif out.find("Driver is running") != -1:
print("DUT is properly enumerated")
return True
else:
print("DUT is not found")
print(out)
print('Checking for 2nd time after waiting for 10 secs')
time.sleep(10)
result = subprocess.run(command, capture_output=True, universal_newlines=True, stdin=subprocess.DEVNULL,shell=True)
out, err = result.stdout, result.stderr
if out.find("The device has the following problem") != -1:
print("DUT Not properly enumerated. Surely be some yellow bang on PCs Device Manager:{}".format(out))
return False
elif out.find("Driver is running") != -1:
print("DUT is properly enumerated")
return True
else:
print("DUT is not found")
print(out)
return False

if __name__ == "__main__":
pid = input("Enter the PID of the device: ")
check_device_status(pid)
Loading