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
20 changes: 20 additions & 0 deletions USBDevice/Linux/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

import os

def check_enum(pid):
command = f'lsusb | grep -i {pid}'
if(os.system(command) == 0):
print("USB is properly enumerated")
return True
else:
print("USB enumeration failed!")
return False

if __name__ == "__main__":
pid = input("Enter USB PID to check enumeration: ")
if check_enum(pid):
print("[PASS] USB Device Enumeration in {} is successful".format(pid))
else:
print("[FAIL] USB Device Enumeration in {} has failed".format(pid))
84 changes: 84 additions & 0 deletions USBDevice/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
```
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
SPDX-License-Identifier: BSD-3-Clause-Clear
```

# USB Device Mode Validation

## Overview

This test verifies enumeration of DUT (Device-Under-Test) connected via USB to Host PC.

---

## Setup

- Connect DUT to Host PC via USB.
- Only applicable for USB port(s) on DUT that support Peripheral/Device Mode functionality.

---

## Usage

### Prerequisites

1. Install Python3 on Host PC.

2. The script requires user to input USB PID (Product ID) against which the test checks successful USB enumeration on Host PC. Following is the list of supported PIDs:
```
A4A1 NCM
4EE7 ADB
900E DIAG
901C DIAG + UAC2
901D DIAG + ADB
9015 MASS_STORAGE + ADB
9024 RNDIS + ADB
902A RNDIS + MASS_STORAGE
902B RNDIS + ADB + MASS_STORAGE
902C RNDIS + DIAG
902D RNDIS + DIAG + ADB
902F RNDIS + DIAG + MASS_STORAGE
908C NCM + ADB
90CA DIAG + UAC2 + ADB
90CB DIAG + UVC + ADB
90CC DIAG + UAC2 + UVC + ADB
90DF DIAG + UVC
90E0 DIAG + UAC2 + UVC
9135 DIAG + QDSS + ADB
9136 DIAG + QDSS
F000 MASS_STORAGE
F00E RNDIS
```

### Windows

1. **Connect DUT to Windows PC via USB**


2. **Execute run.py under USBDevice/Windows directory**
Use `python3` to execute run.py script on the Windows host by giving PID (Product ID) as user argument to test USB enumeration of target device.


### Example

```py
python3 run.py <USB PID>
```

### Linux

1. **Connect DUT to Linux PC via USB**


2. **Execute run.py under USBDevice/Linux directory**
Use `python3` to execute run.py script on the Linux host by giving PID (Product ID) as user argument to test USB enumeration of target device.

---


## License

```
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
SPDX-License-Identifier: BSD-3-Clause-Clear
```
54 changes: 54 additions & 0 deletions USBDevice/Windows/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

import time
import subprocess

def check_enum(pid):
# Run 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("USB is not properly enumerated:{}".format(out))
print('Retry after 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("USB is not properly enumerated. Please check for yellow bang on USB driver in the Device Manager:{}".format(out))
return False
elif out.find("Driver is running") != -1:
print("USB is properly enumerated")
return True
else:
print("USB enumeration failed!")
print(out)
return False
elif out.find("Driver is running") != -1:
print("USB is properly enumerated")
return True
else:
print("USB enumeration failed!")
print(out)
print('Retry after 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("USB is not properly enumerated. Please check for yellow bang on USB driver in the Device Manager:{}".format(out))
return False
elif out.find("Driver is running") != -1:
print("USB is properly enumerated")
return True
else:
print("USB enumeration failed!")
print(out)
return False

if __name__ == "__main__":
pid = input("Enter USB PID to check enumeration: ")
if check_enum(pid):
print("[PASS] USB Device Enumeration in {} is successful".format(pid))
else:
print("[FAIL] USB Device Enumeration in {} has failed".format(pid))
Loading