GRL-USB-PD-C2 API  0.8.5
GRL-USB-PD-C2 / GRL-USB-PD-F1 API Documentation
Getting Started

Introduction

image001.png

The GRL USB Type-C Power Delivery Tester and Analyzer (GRL-USB-PD-C2) and GRL USB Type-C Power Delivery Performance Analyzer (GRL-USB-PD-F1) are GRL's powerful USB Power Delivery (USB-PD) testers. GRL-USB-PD-C2 is approved by USB-IF for USB PD compliance testing. This document explains how to use GRL-USB-PD-C2/F1 API's to create test cases to meet more customized test requirements.

Prerequisites

Following are the prerequisites for using the software:

  • This document assumes that users of API have knowledge on USB Power Delivery Specification
  • Knowledge of C# or Python to use the API
  • Visual Studio or any other IDE's
  • Laptop or PC with Windows 10 with minimum of 8GB of RAM
  • GRL-USB-PD-C2 or GRL-USB-PD-F1 Hardware
  • GRL-USB-PD-C2 or GRL-USB-PD-F1 software installed on the PC / Laptop
  • UUT (Unit under test)

Architecture

Custom test cases can be written in either C# or Python as independent standalone application. These test cases call the API's defined in GrlPdApiLib.dll and all the support functions and helper classes are defined in GrlPdLib.dll. The C2 Tester can emulate as provider, consumer and DRP devices.

Architecture.jpg

Hardware Setup

Following diagram illustrates the required hardware connection for using the API's along with the GRL-USB-PD-C2/F1:

HardwareSetup.png


The GRL-USB-PD-C2 Software is loaded on a Windows 10 computer. Below is a procedure for connecting the hardware and computer.

  1. Connect the GRL-USB-PD-C2/F1 Power Interface using the 24V, 280W Power Brick included with the controller.
  2. Connect the GRL-USB-PD-C2/F1 Controller using a physical Ethernet connection between the computer and the controller.
  3. The Ethernet port on the control computer needs to be configured correctly for the GRL-USB-PD-C2/F1 controller to recognize the control computer and vice versa.
  4. To make sure the network connection is set up correctly, goto Network Connections from the Control Panel on the computer.
    networkconnection.jpg
  5. Open the Ethernet properties settings for the Ethernet port that will connect to the GRL-USB-PD-C2/F1 controller, select “Internet Protocol Version 4 (TCP/IPv4)” and click on the “Properties” button below and to the right.
    EthernetProperties.jpg
  6. Set up the TCP/IPv4 properties as shown below and select “Use the following IP address:” to configure static IP address as 192.168.255.n where n is any number between 2 and 255. The subnet mask should be set as 255.255.255.0 and the default gateway as 192.168.255.1. The rest of the items will remain unchanged.
    EthernetSettings.jpg
  7. Once configured click the “OK” button and close the TCP/IPv4 Properties pop-up. Make sure the GRL-USB-PD-C2/F1 Controller is powered on and completely booted up (front panel display showing firmware version number) and then connect the Ethernet cable from the GRL-USB-PD-C2/F1 controller to the computer’s Ethernet port that was just set up. The Network Connections window should now appear as in the below image
    connectioncmplete.jpg
    <
  8. The GRL-USB-PD-C2/F1 Controller is now set up and ready for use.
  9. Before running any tests, it is recommended that you verify both the control computer and the GRL-USB-PD-C2/F1 Controller are communicating properly by using ping 192.168.255.1 from command line. <>

Software Setup

You can create custom test cases using Python or C#. To create API programming you need the following software:

  • Python 2.7.13 or Visual Studio 2017
  • GRL-USB-PD-C2 or GRL-USB-PD-F1 Application
  • Python PIP


  1. If you want to use Python to create the custom test cases, install Python 2.7.13 from https://www.python.org/downloads/release/python-2713/
    Download the Python 2.7.13 installer and follow the on screen instructions to install the software
  2. If you want to use C# to create the custom test cases install Visual Studio 2017 from https://visualstudio.microsoft.com/downloads/
    Download the appropriate Visual Studio installer version and follow the onscreen instructions to install the software.
  3. All API libraries and helper functions are installed along with the GRL-USB-PD-C2/F1 software. Download the GRL-USB-PD-C2/F1 software from https://graniteriverlabs.com/download-center/ and follow the onscreen instructions to install the software.

Development Environment Setup

Creating custom test cases in C#

To develop the application in C#, follow the below instructions:

  1. Open Visual Studio 2017 or higher.
  2. Create a console application in Visual Studio wizard from the [File] menu, select [New]-[Project…], and click on Windows Forms App (.NET Framework)" or "Console App (.NET Framework)".
    visualStudioNewProject.jpg

  3. Add references to GrlPdApiLib.dll and GrlPdLib.dll under the project "Reference".
    addReference.jpg

  4. You are now set for C# application development; refer to the sample code documentation for further details.

Creating custom test cases in Python

To develop the application in Python, follow the below instructions:

  1. Download and install version 2.7.x of Python from https://www.python.org/downloads/release/python-2713/
  2. Add following Python installation paths to the system PATH variable C:\Python27; C:\Python27\Scripts ; C:\Python27\Lib.
  3. Download get-pip.py from https://pip.pypa.io/en/stable/installing/ and copy to C:\Python27.
  4. Open command prompt and navigate to C:\Python27. Type python get-pip.py to install PIP.
    pipinstall.jpg

  5. Install pythonnet via PIP by using the "pip install pythonnet" command in command prompt.
    pythonnetinstall.jpg

  6. You are now set for Python application development; refer to the sample code documentation for further details.