GRL-USB-PD-C2 API  0.8.0
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-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.
      The Ethernet port on the controller computer needs to be configured correctly for the C2 to recognize the controller computer and vice versa.
      To make sure the network connection is set up correctly, open the Network Connections panel from the control panel.
      networkconnection.jpg

      Open the Ethernet panel for the Ethernet port that will connect to the C2, select “Internet Protocol Version 4 (TCP/IPv4)” and click on the “Properties” button below and to the right.
      EthernetProperties.jpg

      Set up the TCP/IPv4 properties as shown below:
      EthernetSettings.jpg

      Select a static IP address (“Use the following IP address:”) which should be 192.168.255.n where n is any number between 2 and 255. The subnet mask should be 255.255.255.0 and the default gateway should be 192.168.255.1. The rest of the items should remain unchanged.
      Click the “OK” button on the Internet Protocol Properties and close the Ethernet Properties. Make sure the C2 is powered on and completely booted up (front panel display shows firmware version number) and then connect the Ethernet cable from the C2 to the computer’s Ethernet port that was just set up. The network connections panel should now look as shown below:
      connectioncmplete.jpg

      The GRL-USB-PD-C2 controller is now setup and ready for use.
      Before running any tests, it is recommended that you verify that the controller computer and the C2 are communicating 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:

    1. Python 2.7.13 or Visual Studio 2017
    2. GRL-USB-PD-C2 Application
    3. Python PIP

      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 instructions to install the software.

      If you want to use C# for creating the test cases install Visual Studio 2017 from https://visualstudio.microsoft.com/downloads/
      Download the appropriate Visual Studio and follow the onscreen instructions to install the software.

      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/
      Follow the onscreen instructions to install the GRL-USB-PD-C2 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 [File] menu, select [New]-[Project…], click [Windows Forms App] or [Console App].
      visualStudioNewProject.jpg

    3. Add reference to GrlPdApiLib.dll and GrlPdLib.dll in 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 Python 2.7.x version of Python from https://www.python.org/downloads/release/python-2713/
    2. Add following Python installation paths to 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.