Amptek DppApi CE DPP Beta Developer Resource

  • Copyright 2009 Amptek Inc.


Download details: Windows Mobile Developer Power Toys

Windows Mobile Developer Power Toys

Brief Description Developer Power Toys for the Windows Mobile platform

The Windows Mobile Developer Power Toys help you develop and test your Windows Mobile applications. N.B. These Power Toys are NOT supported..

The Power Toys include:

  • NOTE: Windows Mobile Developer Power Toys can be download from Microsoft(R) free of charge.

  • Emulator ActiveSync Connection Tool - Allows Activesync to connect to your Emulator session from Visual Studio .NET 2003.

  • ActiveSync Remote Display - Display Pocket PC applications on your desktop or laptop without needing any device side configuration.

  • CECopy - Command line tool for copying files to the device currently connected to desktop ActiveSync.

  • Convert PPC DAT to SP XML - Command line tool for generating Smartphone CABWizSP XML docs from existing Pocket PC CAB files.

  • Hopper - User input stress simulator.

  • JShell - UI version of the Platform Builder Target Control Window.

  • PPC Command Shell - Command shell for the Pocket PC 2003 device. Works on Windows Mobile 5. Set Command Processor OutputTo Setting to 0.

  • RAPI Debug - Displays detailed information about currently running processes.

  • RAPI Start - Command line tool to remotely start an application on your Pocket PC from your desktop.

  • TypeIt - Send characters/strings to the Smartphone 2003 Emulator via ActiveSync.

System Requirements

  • Supported Operating Systems: Windows 2000 Service Pack 3; Windows Server 2003; Windows XP

Not all tools are supported on all listed platforms.

Instructions There are two packages to download. The Emulator Activesync Connection Tool comes as one package. The remaining tools come in a second package.

Emulator Activesync Connection Tool

  1. Start Visual Studio .NET 2003.

  2. Click "Connect Emulator with ActiveSync" on the Tools menu.

  3. From the "Connect Emulator with ActiveSync" dialog, select an Emulator image from
    the dropdown list.

  4. Ensure the selected emulator is not running yet.

  5. Click the Connect button. The emulator will be started and an ActiveSync
    connection will be established with it.

  6. Once the connection is ready, it is OK to close the tool by clicking Exit
    from the menu.


Remote Tools

Remote Tools are included with the Windows Mobile Version 5.0 SDK

With remote tools you can use a development workstation to remotely perform a variety of programming tasks on a Microsoft® Windows® CE–based target device.

After you establish a connection between the remote tool and the target device over Platform Manager, you can accomplish such tasks as the following:

  • Downloading a file to the target device

  • Monitoring the status of processes and threads on the target device

  • Measuring the performance of the target device

You can run one instance of each remote tool at a time. You cannot run Remote Call Profiler and Remote Kernel Tracker simultaneously. However, many remote tools can display multiple windows.

The toolbar buttons and some menu items in the window for the remote tool become active after you connect to a target device.

OS designs created with Microsoft Platform Builder 3.0 or later support all remote tools except Remote Call Profiler. OS designs created with Platform Builder 4.0 or later support Remote Call Profiler.

The following table shows the remote tools that are available in Platform Builder and Microsoft eMbedded Visual C++® 4.0 Service Pack 4.

Remote tool | Description
Remote Call Profiler | Provides profiling and analysis tools within a graphical user interface (GUI) that enable you to identify algorithmic bottlenecks in your applications.
Remote File Viewer | Displays a hierarchical view of the file system on a target device.
Remote Heap Walker | Displays information about heap identifiers and flags for processes that are running on a target device.
Remote Kernel Tracker | Provides a visual representation of OS and application events occurring on a target device.
Remote Performance Monitor | Measures the performance of a target device.
Remote Process Viewer | Displays a list of processes and threads running on a target device.
Remote Registry Editor | Displays the registry for a target device and enables you to manage the registry.
Remote Spy | Displays a list of windows opened on a target device and messages generated by those windows.
Remote System Information | Displays system settings and properties for a target device.
Remote Zoom-in | Displays an image from the screen of a target device.

NOTE: The tools may be not be integrated into VS2005. You may have to manually find the tools.

The tools may be in “C:\Program Files\CE Remote Tools\5.01\bin” or a similar directory. Check your SDK install for details.


Command Processor Registry Settings

The command processor registry stores information necessary to configure the behavior of the command processor.

The HKEY_LOCAL_MACHINE\Drivers\Console registry key is required to configure the command processor.
You can use this registry key to redirect the command processor output to COM1 serial port.
The following table shows the named values for the Console settings.

Value : type | Description
OutputTo : REG_DWORD | No default setting. This value controls whether the command processor output is redirected to the serial port. Setting this value to -1 will redirect the output to a debug port. Setting this value to 0 to specifies no redirection. Setting this value to a number greater than 0 and less than 10 will redirect to a serial port.
COMSpeed : REG_DWORD | Defaults to 19600 bps, and specifies the serial port speed.


DppApi CE Driver Model

  • The windrvr6.dll is loaded at startup by wdreg.exe.

  • The wdapi1000.dll has driver helper functions..

  • The usb_diag application can be used to diagnose driver problems.

  • DppUsbCe.dll provides usb interface functions for CE USB communications.

  • Applications and the CE DppApi communicate with the DppUsbCe.dll (See the USB sample code).

  • The CE DppApi is provided for rapid application development (See the Test_CE_DPP sample code).


Installing the Drivers

Installing the Drivers and CE DppApi (Recommended)

  • Attach the host device.

  • Goto the DppApiCE\Install_DppApi directory.

  • Run setup.exe.

  • Follow the CE Application Manager Instructions.

  • Shortcuts to installed applications.

  • The DppApi Development directory is "\Program files\DppApi".

UnInstalling the Drivers (With Recommended Install ONLY.)

  • Goto the Remove Programs Dialog.

  • Click "Amptek DppApi".

  • Follow the CE Application Manager Instructions.

Manually Installing the Drivers

On Windows Mobile the operating system's security scheme prevents the loading of unsigned drivers at boot time, therefore the WinDriver kernel module has to be reloaded after boot. The wdreg.exe utility resides in the Windows StartUp directory on the target, to reload WinDriver on the target Windows Mobile platform every time the OS is started. The DPP device is not recognized until after the first call to open the driver or the first DppApi Open USB call.

Installing WinDriver CE when Developing Applications for Windows CE Computers

  • Copy the windrvr6.dll, wdapi1000.dll and the DppUsbCE.dll to your target Windows CE platform Windows directory.

  • Copy WDReg.exe to the Windows StartUp directory on the target platform.

  • Copy Test_CE_DPP.exe, usb_diag.exe, and DppApi.dll to your target platform development directory.

  • The DPP device is not recognized until after the first call to open the driver or the first DppApi Open USB call.

Program Shortcuts

Remove Programs


DppUsbCE Host Driver API

The DppUsbCE Host Driver API emulates the APA USB driver functions.

See for Details:

  • APA USB Reference

  • DppUSB.cpp Source

  • DppUSB.h Source

  • usbdrvd.h Source

  • guid.h Source

USB Functions Supported:

  • USBDRVD_CloseDevice

  • USBDRVD_GetDevCount

  • USBDRVD_GetDriverVersion

  • USBDRVD_GetStringDescriptor

  • USBDRVD_OpenDevice

  • USBDRVD_PipeClose

  • USBDRVD_PipeOpen

  • USBDRVD_PipeReadTimeout

  • USBDRVD_PipeReset

  • USBDRVD_PipeWriteTimeout

  • USBDRVD_VendorOrClassRequestOut

Vendor Requests Supported:

  • 0x7F

  • 0x80

  • 0x81

  • 0x82

  • 0x83

  • 0x84

  • 0x85

  • 0x86

  • 0x87

  • 0x88

  • 0x89

  • 0x8A

  • 0x8B

  • 0x8C

  • 0x8D

  • 0x8E

  • 0x8F

  • 0x90

  • 0x91

  • 0x92

  • 0x93

  • 0x94

  • 0x95

  • 0x96

  • 0x97

  • 0x98

  • 0x99

  • 0x9A

  • 0x9B

  • 0x9C

  • 0x9D

  • 0x9E

  • 0x9F

Other Legacy Support:

  • GUID_CLASS

  • USB_Major

  • USB_Minor

  • USBDRVD_API

  • PipeHandle_config

  • PipeHandle_configOut

  • PipeHandle_dataA

  • PipeHandle_dataB

  • PipeHandle_Scope

  • PipeHandle_statusA

  • PipeHandle_statusB

  • USB_Device_Handle


usb_diag.exe Utility

  • Provides CE side USB diagnostics.

  • The Amptek DPP Vendor ID is 0bd7, and the Product ID is a021.

  • Read/Write data from pipes.

  • Identify the device by VID and PID

  • DPP Device Attached

  • DP5 end-points

  • Exiting usb_diag

Identify the device by VID and PID

DPP Device Attached

DP5 end-points

Exiting usb_diag


DP5 Pipes

Enter device vendor id (hex) (=0xbd7):

Enter device product id (hex) (=0xa021):

Please make sure the device is attached:

DeviceAttach: received and accepted attach for vendor id 0xbd7, product id 0xa021, interface 0,device handle 0x00022280

Main Menu (active Dev/Prod/Interface/Alt. Setting: 0xbd7/0xa021/

0/0)

----------

1. Display device configurations

2. Change interface alternate setting

3. Reset Pipe

4. Read/Write from pipes

6. Refresh

99. Exit

Enter option: 1

This device has 1 configurations:

0. configuration value 1 (has1 interfaces)

The configuration indexed 0 has 1 interface(s):

interface no. 0 has 1 alternate settings:

alternate: 0, endpoints: 4, class: 0xff, subclass: 0x0, protocol: 0x0

end-point address: 0x01, attributes: 0x2, max packet 64, Interval: 0

end-point address: 0x81, attributes: 0x2, max packet 64, Interval: 0

end-point address: 0x82, attributes: 0x2, max packet 64, Interval: 0

end-point address: 0x83, attributes: 0x2, max packet 64, Interval: 0

Main Menu (active Dev/Prod/Interface/Alt. Setting: 0xbd7/0xa021/0/0)

----------

1. Display device configurations

2. Change interface alternate setting

3. Reset Pipe

4. Read/Write from pipes

6. Refresh

99. Exit

Enter option: 99


PX4 Pipes

Enter device vendor id (hex) (=0xbd7):

Enter device product id (hex) (=0xa021):

Please make sure the device is attached:

DeviceAttach: received and accepted attach for vendor id 0xbd7, product id 0xa021, interface 0,device handle 0x00022280

Main Menu (active Dev/Prod/Interface/Alt. Setting: 0xbd7/0xa021/

0/0)

----------

1. Display device configurations

2. Change interface alternate setting

3. Reset Pipe

4. Read/Write from pipes

6. Refresh

99. Exit

Enter option: 1

This device has 1 configurations:

0. configuration value 1 (has1 interfaces)

The configuration indexed 0 has 1 interface(s):

interface no. 0 has 1 alternate settings:

alternate: 0, endpoints: 7, class: 0xff, subclass: 0x0, protocol: 0x0

end-point address: 0x01, attributes: 0x2, max packet 64, Interval: 0

end-point address: 0x81, attributes: 0x2, max packet 64, Interval: 0

end-point address: 0x82, attributes: 0x2, max packet 64, Interval: 0

end-point address: 0x83, attributes: 0x2, max packet 64, Interval: 0

end-point address: 0x84, attributes: 0x2, max packet 64, Interval: 0

end-point address: 0x85, attributes: 0x2, max packet 64, Interval: 0

end-point address: 0x86, attributes: 0x2, max packet 64, Interval: 0

Main Menu (active Dev/Prod/Interface/Alt. Setting: 0xbd7/0xa021/0/0)

----------

1. Display device configurations

2. Change interface alternate setting

3. Reset Pipe

4. Read/Write from pipes

6. Refresh

99. Exit

Enter option: 99


WDReg.exe Driver Installation Utility

On Windows Mobile the operating system's security scheme prevents the loading of unsigned drivers at boot time, therefore the WinDriver kernel module has to be reloaded after boot. The wdreg.exe utility resides in the Windows StartUp directory on the target, to reload WinDriver on the target Windows Mobile platform every time the OS is started. The DPP device is not recognized until after the first call to open the driver or the first DppApi Open USB call.

Installing WinDriver CE when Developing Applications for Windows CE Computers

  • Copy the windrvr6.dll, wdapi1000.dll and the DppUsbCE.dll to your target Windows CE platform Windows directory.

  • Copy WDReg.exe to the Windows StartUp directory on the target platform.

  • Copy Test_CE_DPP.exe, usb_diag.exe, and DppApi.dll to your target platform development directory.

  • The DPP device is not recognized until after the first call to open the driver or the first DppApi Open USB call.


guid.h

//

// $History: guid.h $

//

//*****************  Version 1  *****************

//User: Amptek       Date: 5/28/04    Time: 3:23p

//Updated in $/USB_DRV/sys

//

//***********************************************

#pragma once

#ifndef GUID_INC

#define GUID_INC

#ifndef DEFINE_GUID

#include <objbase.h>

#endif

#include <initguid.h>

// {8B021AA5-A319-45c1-932C-90AA82E6478D}";

static const GUID GUID_CLASS =

{ 0x8B021AA5, 0xA319, 0x45c1, { 0x93, 0x2C, 0x90, 0xAA, 0x82, 0xE6, 0x47, 0x8D } };

//DEFINE_GUID(GUID_CLASS, 0x8B021AA5, 0xA319, 0x45c1, 0x93, 0x2C, 0x90, 0xAA, 0x82, 0xE6, 0x47, 0x8D);

#endif // end, #ifndef GUID_INC


USB.cpp

#include "stdafx.h"

#include ".\ADMCA\DPP\USB\DppUSB.h"

#include <math.h>

#include <wchar.h>

#include <ctype.h>

#ifdef _DEBUG

#define USB_DEBUG_MODE 1

#else

#define USB_DEBUG_MODE 0

#endif

CDppUSB::CDppUSB(void)

{

      USB_Device_Handle = INVALID_HANDLE_VALUE;

    PipeHandle_config = INVALID_HANDLE_VALUE;

      PipeHandle_configOut = INVALID_HANDLE_VALUE;

    PipeHandle_statusA = INVALID_HANDLE_VALUE;

    PipeHandle_dataA = INVALID_HANDLE_VALUE;

    PipeHandle_statusB = INVALID_HANDLE_VALUE;

    PipeHandle_dataB = INVALID_HANDLE_VALUE;

      PipeHandle_Scope = INVALID_HANDLE_VALUE;

    NumUSBDevices = 0;

      CurrentDevice = 1;

      DriverOpen = false;

      PipesOpen = false;

      isSendingPacket = false;

      usb_busy = false;

      isDPP5 = false;

      cstrDppUsbDeviceType = "";

      HaveDeviceStatus = false;

}

CDppUSB::~CDppUSB(void)

{

    CloseUSB();

}

// Monitor Conditions

// ------------------

// Driver Not Connected or Closed (!DriverOpen)

      // Connect to driver (in OpenUSB)

      // Scan for devices (in OpenUSB)

      // Open Device if devices > 0 (in OpenUSB)

// DriverOpen (DriverOpen)

      // Check for device status:

            // Device Not Open ((DriverOpen && !PipesOpen) && (NumUSBDevices > 0))

                  // open pipes, check success, return number of devices

            // Device Open, PipesOpen ((DriverOpen && PipesOpen) && (NumUSBDevices > 0))

                  // return number of devices

            // Device Removed ((DriverOpen && PipesOpen) && (NumUSBDevices == 0))

                  // close pipes, rescan for devices, return number of devices

            // No Devices ((DriverOpen && !PipesOpen) && (NumUSBDevices == 0))

                  // return number of devices

int CDppUSB::MonitorUSBDevices() {

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);     // check for devices once, to start

      usb_busy = false;

      if (DriverOpen == false) {          // cannot detect devices if the driver is not open

            NumUSBDevices = OpenUSB();                            // open the driver and try to detect any devices

      } else if ((DriverOpen && !PipesOpen) && (NumUSBDevices > 0)) {  // Device Not Open

            // open pipes, check success, return number of devices

            NumUSBDevices = OpenUSBPipes();                 // open the pipes

      } else if ((DriverOpen && PipesOpen) && (NumUSBDevices > 0)) {   // Device Open, PipesOpen

            // return number of devices from initial check

      } else if ((DriverOpen && PipesOpen) && (NumUSBDevices == 0)) {  // Device Removed

            // close pipes, rescan for devices, return number of devices from initial check

            CloseUSBPipes();

      } else if ((DriverOpen && !PipesOpen) && (NumUSBDevices == 0)) { // No Devices

            // return number of devices from initial check

      }

    return NumUSBDevices;

}

// convert a 4 byte long word to a double

// lwStart - starting index of longword

// buffer - byte buffer

double CDppUSB::LongWordToDouble(int lwStart, UCHAR buffer[]) {

      double dblVal;

      int j;

      double ByteMask;

      dblVal = 0;

      for(j=0;j<4;j++) {            // build 4 bytes (lwStart-lwStart+3) into double

            ByteMask = pow(2.0,(8.0 * (double)j));

            dblVal = dblVal + (buffer[(lwStart + j)] * ByteMask);

      }

      return dblVal;

}

// returns true if successful, false otherwise

// the results are stored in dppusbSerialNumber, dppusbDeviceType

bool CDppUSB::GetUSBDeviceInfo() {

      UCHAR Status[USB_BUFFER_SIZE];

      dppusbDeviceType =  0;

    dppusbSerialNumber = 0;

      while(usb_busy);

      usb_busy = true;

      int iNumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      isDPP5 = false;                                                               // DPP5 20070927    intialize DPP5 indicator

      if (NumUSBDevices <= 0)  { return false; }            // no devices

      GetDPPStatus(true,Status);          //get the device type and serial number

      dppusbFPGA = UCHARVersionToDouble(Status[8]);                     // DPP5 20070907 // FPGA version (8 bits)

      dppusbFirmware = UCHARVersionToDouble(Status[13]);                // DPP5 20070907 // embedded code version

      if (dppusbFirmware >= 5.0) {                                            // DPP5 20070907 // device is DPP5 if firmware >= 5.0

            isDPP5 = true;

      } else {

            isDPP5 = false;

      }

      dppusbDeviceType = ((((Status[23] & 0x80) >> 7) + 1) + ((int)isDPP5 * 2));    // device indicator from status

      dppusbSerialNumber = (ULONG)LongWordToDouble(14, Status);                           // SerialNumber bytes 0-3

      cstrDppUsbDeviceType = GetDeviceNameFromVal(dppusbDeviceType);

      //AfxMessageBox(cstrDppUsbDeviceType);    //CETest

      return true;

}

CString CDppUSB::GetDeviceNameFromVal(int DeviceTypeVal) {

    CString cstrDeviceType;

      switch(DeviceTypeVal) {

            case 1:

            cstrDeviceType = "DP4";

                  break;

            case 2:

            cstrDeviceType = "PX4";

                  break;

            case 3:

            cstrDeviceType = "DP4EMUL";

                  break;

            case 4:

            cstrDeviceType = "DP5";

                  break;

            default:           // unknown

            cstrDeviceType = "";

                  break;

      }

    return cstrDeviceType;

}

// calculate major.minor version from UCHAR, convert/save to double

double CDppUSB::UCHARVersionToDouble(UCHAR Version) {

      double dblVersion;

      CString strTemp;

      strTemp.Format(_T("%d.%02d"),((Version & 240) / 16),(Version & 15));

      //AfxMessageBox(strTemp);     //CETest

      //dblVersion = atof(strTemp);

      dblVersion = wcstod(strTemp,NULL);

      return dblVersion;

}

// monitors usb for attached devices

int CDppUSB::USBTimer() {

    return MonitorUSBDevices();

}

UINT CDppUSB::OpenUSBPipes() {

    UINT Device;

    UINT Flags;

      // DPP5 20070912 Device Test ---------------------

      UCHAR Status[USB_BUFFER_SIZE];

      UCHAR Firmware;

      // DPP5 20070912 ---------------------------------

      if (!DriverOpen) return 0;          // cannot open pipes or count devices if driver not open

      CloseUSBPipes();                    // close the pipes if open

    NumUSBDevices = 0;

      while(usb_busy);

      usb_busy = true;

    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

    if (NumUSBDevices >= 1) {

        Device = CurrentDevice;                                     //  default to first device

        Flags = FILE_FLAG_OVERLAPPED;

            while(usb_busy);

            usb_busy = true;

        PipeHandle_config = USBDRVD_PipeOpen(Device, 0, Flags, &GUID_CLASS);    //  Pipe 0

        PipeHandle_statusA = USBDRVD_PipeOpen(Device, 1, Flags, &GUID_CLASS);   //  Pipe 1

        PipeHandle_dataA = USBDRVD_PipeOpen(Device, 2, Flags, &GUID_CLASS);     //  Pipe 2

            usb_busy = false;

            // DPP5 20070912/20071126 Read and test status for DPP5 device type

            HaveDeviceStatus = false;

            GetDPP_PipeOpen_Status(true,Status); //get devicetype and sernum,no ready check

            if (HaveDeviceStatus) {

                  Firmware = Status[13]; // embedded code version

                  if (Firmware >= 80) {

                        isDPP5 = true;

                  } else {

                        isDPP5 = false;

                  }

            } else {

                  isDPP5 = false;         // try the device as a DP4/PX4

            }

            while(usb_busy);

            usb_busy = true;

            if (isDPP5) PipeHandle_configOut = USBDRVD_PipeOpen(Device, 3, Flags, &GUID_CLASS);   // DPP5 20070907 //  Pipe 3

            if (! isDPP5) PipeHandle_statusB = USBDRVD_PipeOpen(Device, 3, Flags, &GUID_CLASS);   // DPP5 20070907 no DPP5 statusB pipe

        if (! isDPP5) PipeHandle_dataB = USBDRVD_PipeOpen(Device, 4, Flags, &GUID_CLASS);     // DPP5 20070907 no DPP5 dataB pipe

        if (! isDPP5) PipeHandle_configOut = USBDRVD_PipeOpen(Device, 5, Flags, &GUID_CLASS); // DPP5 20070907 configOut pipe will be pipe 3 for DPP5

        if (! isDPP5) PipeHandle_Scope = USBDRVD_PipeOpen(Device, 6, Flags, &GUID_CLASS);     // DPP5 20070907 Scope pipe disabled until implemented

            usb_busy = false;

            PipesOpen = true;

    }

    return NumUSBDevices;

}

UINT CDppUSB::OpenUSB() {

    UINT Device;

    UINT Flags;

    NumUSBDevices = 0;

    if (DriverOpen == false) {

        Device = CurrentDevice;                                     //  default to first device

        Flags = FILE_FLAG_OVERLAPPED;

            while(usb_busy);

            usb_busy = true;

            USB_Device_Handle = USBDRVD_OpenDevice(Device, 0, &GUID_CLASS);

            usb_busy = false;

            // check if the driver is open

            if ((USB_Device_Handle != INVALID_HANDLE_VALUE) && (USB_Device_Handle != NULL)){

                  DriverOpen = true;

                  while(usb_busy);

                  usb_busy = true;

                  NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

                  usb_busy = false;

                  if (PipesOpen) {              // must reopen pipes for the current device

                        CloseUSBPipes();

                  }

                  if (NumUSBDevices > 0) {      // if a device is present open the device

                        OpenUSBPipes();

                  }

            } else {          // driver error, attempt to close driver

                  NumUSBDevices = 0;

                  CloseUSB();

            }

      } else {

            while(usb_busy);

            usb_busy = true;

        NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

            usb_busy = false;

    }

    return NumUSBDevices;

}

UINT CDppUSB::OpenUSBEx(UINT Device) {

      //CurrentDevice = Device;           // jungo only open default device

      OpenUSB();

    return NumUSBDevices;

}

void CDppUSB::CloseUSBPipes() {

    if (PipesOpen) {

            while(usb_busy);

            usb_busy = true;

        USBDRVD_PipeClose (PipeHandle_config);

        if (PipeHandle_configOut != INVALID_HANDLE_VALUE) USBDRVD_PipeClose (PipeHandle_configOut);                   // DPP5 200709011 disable configOut pipe close if not valid

        USBDRVD_PipeClose (PipeHandle_statusA);

        USBDRVD_PipeClose (PipeHandle_dataA);

        if ((! isDPP5) && (PipeHandle_statusB != INVALID_HANDLE_VALUE)) USBDRVD_PipeClose (PipeHandle_statusB); // DPP5 20070911 no DPP5 statusB pipe

        if ((! isDPP5) && (PipeHandle_dataB != INVALID_HANDLE_VALUE)) USBDRVD_PipeClose (PipeHandle_dataB);           // DPP5 20070907 no DPP5 dataB pipe

        if ((! isDPP5) && (PipeHandle_Scope != INVALID_HANDLE_VALUE)) USBDRVD_PipeClose (PipeHandle_Scope);           // DPP5 20070907 DPP5 Scope pipe disabled until implemented

            usb_busy = false;

        PipeHandle_config = INVALID_HANDLE_VALUE;

        PipeHandle_configOut = INVALID_HANDLE_VALUE;

        PipeHandle_statusA = INVALID_HANDLE_VALUE;

        PipeHandle_dataA = INVALID_HANDLE_VALUE;

        PipeHandle_statusB = INVALID_HANDLE_VALUE;

        PipeHandle_dataB = INVALID_HANDLE_VALUE;

        PipeHandle_Scope = INVALID_HANDLE_VALUE;

            PipesOpen = false;

    }

    NumUSBDevices = 0;

}

void CDppUSB::CloseUSB() {

    if (DriverOpen) {

            CloseUSBPipes();

            while(usb_busy);

            usb_busy = true;

            USBDRVD_CloseDevice (USB_Device_Handle);

            usb_busy = false;

        USB_Device_Handle = INVALID_HANDLE_VALUE;

            DriverOpen = false;

    }

    NumUSBDevices = 0;

}

//-----------------------------------------------------------------------------------

//82H Enable MCA/MCS

//83H Disable MCA/MCS

//-----------------------------------------------------------------------------------

UINT CDppUSB::PauseMCAUSB(BOOLEAN boolPauseMCA) {

    ULONG ret;

    UCHAR buffer[64];

    //UCHAR buffer[USB_BUFFER_SIZE];

      if (! USBDeviceReady()) { return 0; }

    ClearBufferArray(buffer);

      while(usb_busy);

      usb_busy = true;

    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

    if (NumUSBDevices > 0) {          //  only send if USB DP4 detected

        if (boolPauseMCA) {

            //  Req type=2 (Vendor), Dest=3 (other), Request=0x83 (disable MCA), Val=0, Index=0, Len=0

                  while(usb_busy);

                  usb_busy = true;

            ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x83, 0, 0, buffer, 0);

                  usb_busy = false;

        } else {

            //  Req type=2 (Vendor), Dest=3 (other), Request=0x82 (enable MCA), Val=0, Index=0, Len=0

                  while(usb_busy);

                  usb_busy = true;

            ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x82, 0, 0, buffer, 0);

                  usb_busy = false;

        }

    }

    return NumUSBDevices;

}

void CDppUSB::SendUSBPacket(UCHAR buffer[]) {

    UINT Count;

      DWORD nBytes;

    DWORD Timeout;

    ULONG ret;

      int retries;

      int CurTry;

      if (! USBDeviceReady()) { return; }

      CString cstrBufMsg;

      while(usb_busy);

      usb_busy = true;

    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

    if (NumUSBDevices > 0) {    //  only send config packet if USB DP4 detected

        Count = 64;             //  64-byte USB packet

        Timeout = 100;         //  .1 second timeout

            retries = 5;                  //  5 chances to send config

            CurTry = 0;                   //  holds the current number of tries

            do

            {

                  ret = 0;

                  nBytes = 0;

                  while(usb_busy);

                  usb_busy = true;

                  ret = USBDRVD_PipeWriteTimeout(PipeHandle_config, buffer, Count, &nBytes, Timeout);

                  usb_busy = false;

                  CurTry++;

            }

            while(((nBytes != Count) || (ret == FALSE)) && (CurTry < retries));

    }

}

//-----------------------------------------------------------------------------------

//80H Clear buffer A

//81H Clear buffer B (doesn't do anything on DP5)

//-----------------------------------------------------------------------------------

void CDppUSB::ClearBuffer(BOOLEAN isBufferA) {

    ULONG ret;

    UCHAR buffer[64];

      if (! USBDeviceReady()) { return; }

    ClearBufferArray(buffer);

    if (isBufferA) {

        //  Req type=2 (Vendor), Dest=3 (other), Request=0x80 (clear buffer A), Val=0, Index=0, Len=0

            while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x80, 0, 0, buffer, 0);

            usb_busy = false;

      } else {

        //  Req type=2 (Vendor), Dest=3 (other), Request=0x81 (clear buffer B), Val=0, Index=0, Len=0

            while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x81, 0, 0, buffer, 0);

            usb_busy = false;

   }

      //CString cstrRetVal;

      //cstrRetVal.Format("ClearBuffer ret: %d", ret);

      //::MessageBox(NULL,cstrRetVal,"USBDRVD_VendorOrClassRequestOut",MB_ICONINFORMATION);

}

BOOLEAN CDppUSB::USBDeviceReady() {

      if (!DriverOpen) return FALSE;

      if (!PipesOpen) return FALSE;

      while(usb_busy);

      usb_busy = true;

    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

            return TRUE;

      } else {

            return FALSE;

      }

}

// returns 0 if fails, return same codes as ReadFile()

ULONG CDppUSB::GetDPPConfig(UCHAR ConfigIn[], bool isScopeData) {

    UINT Count;

      DWORD nBytes;

    DWORD Timeout;

    ULONG ret;

      int retries;

      int CurTry;

            //CString cstrCETest; //CETest

            //cstrCETest.Format(_T("%d"),PipeHandle_configOut); //CETest

            //AfxMessageBox(cstrCETest); //CETest

      if (isScopeData && (! isDPP5)) { return 0; }

      if ((PipeHandle_configOut == INVALID_HANDLE_VALUE)) {

            return 0;

      }     // DPP5 20070907 disabled until DPP5 cfg read fully implemented

      if (! USBDeviceReady()) { return 0; }

    Count = 64;                     //  status packet=64 bytes

      if (isScopeData) { Count = 512; }

    Timeout = 100;                  //  .1 second timeout

      retries = 5;                  //  5 chances to send config

      CurTry = 0;                   //  holds the current number of tries

      do

      {

            ret = 0;

            nBytes = 0;

            while(usb_busy);

            usb_busy = true;

            //!!!!! update count for count

            ret = USBDRVD_PipeReadTimeout(PipeHandle_configOut, ConfigIn, (Count + COUNT_OFFSET), &nBytes, Timeout);

            usb_busy = false;

            CurTry++;

      }

      while(((nBytes != Count) || (ret == FALSE)) && (CurTry < retries));

      return nBytes;

}

void CDppUSB::GetDPPStatus(BOOLEAN isBufferA, UCHAR Status[]) {

    UINT Count;

      DWORD nBytes;

    DWORD Timeout;

    ULONG ret;

      int retries;

      int CurTry;

      if (! USBDeviceReady()) { return; }

    Count = 64;                     //  status packet=64 bytes

    Timeout = 100;                  //  .1 second timeout

      retries = 5;                  //  5 chances to send config

      CurTry = 0;                   //  holds the current number of tries

      do

      {

            ret = 0;

            nBytes = 0;

            if (isBufferA) {

                  while(usb_busy);

                  usb_busy = true;

                  ret = USBDRVD_PipeReadTimeout(PipeHandle_statusA, Status, (Count + COUNT_OFFSET), &nBytes, Timeout);

                  usb_busy = false;

            } else if (! isDPP5) {  // DPP5 20070907 DPP5 devices do not have a BufferB

                  while(usb_busy);

                  usb_busy = true;

                  ret = USBDRVD_PipeReadTimeout(PipeHandle_statusB, Status, (Count + COUNT_OFFSET), &nBytes, Timeout);

                  usb_busy = false;

            }

            CurTry++;

      }

      while(((nBytes != Count) || (ret == FALSE)) && (CurTry < retries));

      // test for device status needed to open pipes

      HaveDeviceStatus = (isBufferA && (nBytes == Count) && (ret != FALSE) && (CurTry < retries));

}

void CDppUSB::GetDPP_PipeOpen_Status(BOOLEAN isBufferA, UCHAR Status[])

{

    UINT Count;

      DWORD nBytes;

    DWORD Timeout;

    ULONG ret;

      int retries;

      int CurTry;

      //if (! USBDeviceReady()) { return; } // ALL PIPES ARE NOT OPEN CANNOT CHECK AT THIS POINT

    Count = 64;                     //  status packet=64 bytes

    Timeout = 100;                  //  .1 second timeout

      retries = 5;                  //  5 chances to send config

      CurTry = 0;                   //  holds the current number of tries

      do

      {

            ret = 0;

            nBytes = 0;

            if (isBufferA) {

                  while(usb_busy);

                  usb_busy = true;

                  ret = USBDRVD_PipeReadTimeout(PipeHandle_statusA, Status, (Count + COUNT_OFFSET), &nBytes, Timeout);

                  usb_busy = false;

            } else if (! isDPP5) {  // DPP5 20070907 DPP5 devices do not have a BufferB

                  while(usb_busy);

                  usb_busy = true;

                  ret = USBDRVD_PipeReadTimeout(PipeHandle_statusB, Status, (Count + COUNT_OFFSET), &nBytes, Timeout);

                  usb_busy = false;

            }

            CurTry++;

      }

      while(((nBytes != Count) || (ret == FALSE)) && (CurTry < retries));

      // test for device status needed to open pipes

      HaveDeviceStatus = (isBufferA && (nBytes == Count) && (ret != FALSE) && (CurTry < retries));

}

// reads data and returns actual number of bytes read

DWORD CDppUSB::GetDPPData(BOOLEAN isBufferA, UCHAR buffer[], UINT ExpectedCount) {

    UINT Count;

      DWORD nBytes;

    DWORD Timeout;

    ULONG ret;

      int retries;

      int CurTry;

      if (! USBDeviceReady()) { return 0; }

    Count = ExpectedCount;          //  status packet=64 bytes

    Timeout = 100;                        //  .1 second timeout

      retries = 5;                        //  5 chances to send config

      CurTry = 0;                         //  holds the current number of tries

      do

      {

            ret = 0;

            nBytes = 0;

            if (isBufferA) {

                  while(usb_busy);

                  usb_busy = true;

                  ret = USBDRVD_PipeReadTimeout(PipeHandle_dataA, buffer, (Count + COUNT_OFFSET), &nBytes, Timeout);

                  usb_busy = false;

            } else {

                  if (isDPP5) { return 0; }     // DPP5 20070907 DPP5 devices do not have a BufferB

                  if ((PipeHandle_dataB == INVALID_HANDLE_VALUE)) { return 0; }     // DPP5 20070907 exit on bad bufferB pipe

                  while(usb_busy);

                  usb_busy = true;

                  ret = USBDRVD_PipeReadTimeout(PipeHandle_dataB, buffer, (Count + COUNT_OFFSET), &nBytes, Timeout);

                  usb_busy = false;

            }

            CurTry++;

      }

      while(((nBytes != Count) || (ret == FALSE)) && (CurTry < retries));

    return nBytes;

}

// loads buffer with config data and sends as usb packet

void CDppUSB::SendDPPConfigUSB(UCHAR Config[], UINT Preset) {

    int i;

    UCHAR buffer[USB_BUFFER_SIZE];

    UCHAR buffer2[USB_CFG_IN_SIZE];

      for(i=0; i<=10; i++) {  // assign config bytes 0-10 to buffer

            buffer[i] = Config[i+2];

      }

      buffer[11] = (BYTE)(Preset % 256);              // !!! preset is set in config cmdbtn fn

    buffer[12] = (BYTE)((Preset / 256) % 256);

    buffer[13] = (BYTE)((Preset / 65536) % 256);

      for(i=14; i<=29; i++) {       // assign config bytes 14-29 to buffer

            buffer[i] = Config[i-1];

      }

      //CString cstrMCS;

      //cstrMCS.Format("%d",buffer[29] & 0x0F);

      //AfxMessageBox(cstrMCS);

    buffer[30] = 0;                       // these bytes are not assigned

    buffer[31] = 0;

      for(i=32; i<=63; i++) {       // assign config bytes 32-63 to buffer

            buffer[i] = Config[i];

      }

      SendUSBPacket(buffer);

      //CString strBufferData;

      //strBufferData = DisplayBufferArray(buffer);

      //SaveStringDataToFile(strBufferData);

      GetDPPConfig(buffer2,false);

      bool isSame;

      isSame = CompareBufferArrays(buffer,buffer2);

      if (!isSame) {

            SendUSBPacket(buffer);

            GetDPPConfig(buffer2,false);

            isSame = CompareBufferArrays(buffer,buffer2);

      }

}

void CDppUSB::SaveStringDataToFile(CString strData)

{

   FILE  *out;

   CString strFilename;

   CString strError;

   strFilename = "CfgHex.txt";

   if ( (out = _tfopen(strFilename,_T("w"))) == (FILE *) NULL)

      strError.Format(_T("Couldn't open %s for writing.\n"), strFilename);

   else

   {

      fprintf(out,"%s\n",strData);

   }

   fclose(out);

}

bool CDppUSB::CompareBufferArrays(UCHAR buffer[], UCHAR buffer2[])

{

    int i;

      int arrsize;

      bool isSame;

      isSame = true;

      arrsize = (sizeof buffer) / (sizeof buffer[0]);

      for(i=0;i<arrsize;i++) {

            if (buffer[i] != buffer2[i]) isSame = false;

      }

      return isSame;

}

void CDppUSB::ClearBufferArray(UCHAR buffer[]) {

    int i;

      int arrsize;

      arrsize = (sizeof buffer) / (sizeof buffer[0]);

      for(i=0;i<arrsize;i++) {

            buffer[i] = 0;

      }

}

// monitors usb for attached devices

CString CDppUSB::GetUSBTimerStatText() {

      CString cstrText;

    if (NumUSBDevices < 0) {        //  no devices but pipes are open?

        cstrText = "USB closed";

    } else {

        cstrText.Format(_T("%s%d%s"), "USB (", NumUSBDevices, " detected)");

    }

      return cstrText;

}

CString CDppUSB::DisplayBufferArray(UCHAR buffer[]) {

    int i;

      CString cstrVal("");

      CString cstrMsg("");

      for(i=0;i<64;i++) {

            //cstrVal.Format("%.2X ",buffer[i]);      // on same line separated w/spaces

            cstrVal.Format(_T("%.2X\r\n"),buffer[i]); //with dos newlines

            cstrMsg += cstrVal;

      }

      cstrMsg += "\r\n";

      return cstrMsg;

}

//-----------------------------------------------------------------------------------

//84H Arm digital scope

//-----------------------------------------------------------------------------------

void CDppUSB::ArmTrigger()

{

    ULONG ret;

    UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

   if (NumUSBDevices > 0) {

        // Req type=2 (Vendor), Dest=3 (other), Request=0x84 (arm scope trigger), Val=0, Index=0, Len=0

            while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x84, 0, 0, buffer, 0);

            usb_busy = false;

    }

}

//-----------------------------------------------------------------------------------

//85H Autoset input offset (fine steps) (DPP5 not implemented yet)

//-----------------------------------------------------------------------------------

void CDppUSB::InputOffsetFineStep()

{

    ULONG ret;

    UCHAR buffer[64];

      //if (isDPP5) return;         // DPP5 20070910 disable InputOffsetFineStep for DPP5

      while(usb_busy);

      usb_busy = true;

    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

   if (NumUSBDevices > 0) {

        // Req type=2 (Vendor), Dest=3 (other), Request=0x85 (InputOffsetFineStep), Val=0, Index=0, Len=0

            while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x85, 0, 0, buffer, 0);

            usb_busy = false;

    }

}

//-----------------------------------------------------------------------------------

//86H Autoset input offset (coarse steps) (DPP5 not implemented yet)

//-----------------------------------------------------------------------------------

void CDppUSB::InputOffsetCoarseStep()

{

    ULONG ret;

    UCHAR buffer[64];

      //if (isDPP5) return;         // DPP5 20070910 disable InputOffsetCoarseStep for DPP5

      while(usb_busy);

      usb_busy = true;

    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

   if (NumUSBDevices > 0) {

        // Req type=2 (Vendor), Dest=3 (other), Request=0x86 (InputOffsetCoarseStep), Val=0, Index=0, Len=0

            while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x86, 0, 0, buffer, 0);

            usb_busy = false;

    }

}

//-----------------------------------------------------------------------------------

//87H Autoset fast threshold (DPP5 not implemented yet)

//-----------------------------------------------------------------------------------

void CDppUSB::DPPCalcFastThresh()

{

    ULONG ret;

    UCHAR buffer[64];

      //if (isDPP5) return;         // DPP5 20070910 disable DPPCalcFastThresh for DPP5

      while(usb_busy);

      usb_busy = true;

    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

   if (NumUSBDevices > 0) {

        // Req type=2 (Vendor), Dest=3 (other), Request=0x87 (DPPCalcFastThresh), Val=0, Index=0, Len=0

            while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x87, 0, 0, buffer, 0);

            usb_busy = false;

    }

}

DWORD CDppUSB::GetScopeData(UCHAR Scope[])

{

    UINT Count;

      DWORD nBytes;

    DWORD Timeout;

    ULONG ret;

      int retries;

      int CurTry;

      if (isDPP5) { return 0; }     // DPP5 20071210 disabled dpp5 scope uses PipeHandle_configOut pipe

      if ((PipeHandle_Scope == INVALID_HANDLE_VALUE)) { return 0; }     // DPP5 20070907 exit on bad scope pipe

      if (! USBDeviceReady()) { return 0; }

    Count = 512;                    //  scope packet=512 bytes

    Timeout = 100;                  //  .1 second timeout

      retries = 5;                  //  5 chances to send config

      CurTry = 0;                   //  holds the current number of tries

      do

      {

            ret = 0;

            nBytes = 0;

            if (usb_busy) return 0;

            while(usb_busy);

            usb_busy = true;

            ret = USBDRVD_PipeReadTimeout(PipeHandle_Scope, Scope, (Count + COUNT_OFFSET), &nBytes, Timeout);

            usb_busy = false;

            CurTry++;

      }

      while(((nBytes != Count) || (ret == FALSE)) && (CurTry < retries));

      return nBytes;

}

double CDppUSB::GetDriverVersion()

{

    UINT ret;

      ULONG USB_Major;

      ULONG USB_Minor;

      double dblVersion;

      CString strVersion;

      if (! USBDeviceReady()) { return 0; }

      if (usb_busy) return 0;

      while(usb_busy);

      usb_busy = true;

      ret = USBDRVD_GetDriverVersion(USB_Device_Handle, &USB_Major, &USB_Minor);

      usb_busy = false;

      //Driver Version

      strVersion.Format(_T("%d.%03d"),USB_Major,USB_Minor);

      //dblVersion = atof(strVersion);

      dblVersion = wcstod(strVersion,NULL);

      return dblVersion;

}

//read a 64-character logical name from the PX4 EEPROM.

//return the name via a USB Get_Descriptor request.

//The PX4 name is USB String Descriptor 3.

//3 is the string number, ask for 65 bytes to get 64

CString CDppUSB::GetPX4DeviceText()

{

    CHAR buffer[USB_BUFFER_SIZE];

    UINT ret;

      CString strText;

      if (! USBDeviceReady()) { return (_T("")); }

      if (usb_busy) return (_T(""));

      while(usb_busy);

      usb_busy = true;

      ret = USBDRVD_GetStringDescriptor(USB_Device_Handle, 0x0409, 3, 65, buffer);

      usb_busy = false;

      buffer[64] = '\0';

      strText = buffer;

      strText.Trim();

      return strText;

}

//sends a 64-character logical name to the PX4. It will save it in EEPROM,

//and return the name via a USB 'Get_Descriptor request. The PX4 name is USB String Descriptor #3.

//Writing is a series of Vendor Requests, each of which writes 2 characters.

// The 'Request' is 0x7F, the 'value' LSB is one character and the MSB is the subsequent one,

// the 'index' is the string offset, i.e. 0, 2, 4...62. An index of 62 triggers

// the firmware to copy the string into the EEPROM.

void CDppUSB::SendPX4DeviceText(CString strText)

{

      UCHAR Setting = 0x00;   // no setting used

    UINT ret;

      USHORT ChOut;

      char ch1;

      char ch2;

      CString strTextOut;

      CString strSpaces(' ',65);

      strTextOut = strText + strSpaces;   //

      if (! USBDeviceReady()) { return ; }

      if (usb_busy) return ;

    for(USHORT i=0; i<32 ; i++) { // 32 Requests to send 64 bytes

        ch1 = (char)strTextOut[i * 2];

            ch2 = (char)strTextOut[(i * 2) + 1];

            ChOut = (ch2 << 8) + ch1;

        // Req type=2 (Vendor), Dest=3 (Other), Request=&H7F (Write PX4 Name), Val=char1+char2, Index=string byte position, Len=0

            while(usb_busy);

            usb_busy = true;

            ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x7F, ChOut, (USHORT)(i * 2), &Setting, 0);

            usb_busy = false;

    }

      return ;

}

void CDppUSB::SendDP5DeviceText(CString strText) {

      BYTE Buffer[512];

      int idxCnt;

      long lStrLen;

      UINT ret;

      if (! USBDeviceReady()) { return ; }

      if (usb_busy) return ;

      lStrLen = strText.GetLength();

      for(idxCnt=0; idxCnt<512 ; idxCnt++) {

        if (idxCnt < lStrLen) {

                  Buffer[idxCnt] = (BYTE)strText[idxCnt];

        } else {

            Buffer[idxCnt] = 0;

        }

      }

      for(idxCnt=0; idxCnt<16 ; idxCnt++) {

        //Req type=2 (Vendor), Dest=3 (Other), Request=&H7F (Write PX4 Name), Val=0, Index=0..15, Len=32

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x7F, 0, idxCnt, &Buffer[idxCnt * 32], 32);

    }

}

CString CDppUSB::GetDP5DeviceText()

{

    UCHAR buffer[1024];

      CString strText;

    UINT Count;

      DWORD nBytes;

    DWORD Timeout;

    ULONG ret;

      int retries;

      int CurTry;

      for(int idxCnt=0; idxCnt<1024 ; idxCnt++) {

            buffer[idxCnt] = '\0';

      }

      if (! USBDeviceReady()) { return (_T("")); }

      if (usb_busy) return (_T(""));

      //if ((PipeHandle_config == INVALID_HANDLE_VALUE)) { return (""); }     // exit on bad cfg pipe

          ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x98, 1, 0, buffer, 0);

      Sleep(2);

    Count = 512;                                                                          //  dp5 text packet=512 bytes

    Timeout = 100;                                                                              //  .1 second timeout

      retries = 5;                                                                              //  5 chances to send config

      CurTry = 0;                                                                               //  holds the current number of tries

      do

      {

                //Req type=2 (Vendor), Dest=3 (other), Request=&H98, Val=1 (Request text block via Pipe 3), Index=0, Len=0

            ret = 0;

            nBytes = 0;

          if (usb_busy) return (_T(""));

            while(usb_busy);

            usb_busy = true;

            ret = USBDRVD_PipeReadTimeout(PipeHandle_configOut, buffer, (Count + COUNT_OFFSET), &nBytes, Timeout);

            usb_busy = false;

            CurTry++;

            //Sleep(5);

      }

      while(((nBytes != Count) || (ret == FALSE)) && (CurTry < retries));

      usb_busy = false;

      //buffer[512] = '\0';

      strText = buffer;

      strText.Trim();

      return strText;

}

//USBDRVD_API ULONG _stdcall USBDRVD_VendorOrClassRequestOut(HANDLE hDevice,

 //                                                UCHAR Type,                           // 1=class, 2 = vendor

 //                                                UCHAR Destination,                    // 0=device, 1=interface,

 //                                                                                      // 2=endpoint, 3=other

 //                                               // see the USB Specification for an explanation of the following

 //                                                UCHAR Request,                        // request

 //                                                USHORT Value,                         // value

 //                                                USHORT Index,                         // index

 //                                                PUCHAR pData,                         // data buffer

 //                                                ULONG Length);                        // length of data

//-----------------------------------------------------------------------------------

//Dpp Vendor Request + 16-bit value

//-----------------------------------------------------------------------------------

void CDppUSB::SendGenericDppVendorRequest(UCHAR Request, USHORT Value)

{

    ULONG ret;

    UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

   if (NumUSBDevices > 0) {

            while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, Request, Value, 0, buffer, 0);

            usb_busy = false;

    }

}

//-----------------------------------------------------------------------------------

//88H Clear PA0/IO0

//-----------------------------------------------------------------------------------

void CDppUSB::ClearPA0IO0()

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

      while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x88, 0, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//89H Set PA0/IO0

//-----------------------------------------------------------------------------------

void CDppUSB::SetPA0IO0()

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

      while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x89, 0, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//8AH Clear PA1/IO1

//-----------------------------------------------------------------------------------

void CDppUSB::ClearPA1IO1()

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

      while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x8A, 0, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//8BH Set PA1/IO1

//-----------------------------------------------------------------------------------

void CDppUSB::SetPA1IO1()

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

      while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x8B, 0, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//8CH Clear PA2/IO2

//-----------------------------------------------------------------------------------

void CDppUSB::ClearPA2IO2()

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

      while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x8C, 0, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//8DH Set PA2/IO2

//-----------------------------------------------------------------------------------

void CDppUSB::SetPA2IO2()

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

      while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x8D, 0, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//8EH Clear PA3/IO3

//-----------------------------------------------------------------------------------

void CDppUSB::ClearPA3IO3()

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

      while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x8E, 0, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//8FH Set PA3/IO3

//-----------------------------------------------------------------------------------

void CDppUSB::SetPA3IO3()

{

    ULONG ret;

    UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

            while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x8F, 0, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//90H + 16-bit value    Set Diode cal

//-----------------------------------------------------------------------------------

void CDppUSB::SendDiodeCal(USHORT DCalValue)

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

      while(usb_busy);

            usb_busy = true;

            ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x90, DCalValue, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//91H + 16-bit value    Set TEC current limit (not used on DP5)

//-----------------------------------------------------------------------------------

void CDppUSB::SetTECCurrentLimit(USHORT CurrentLimit)

{

    ULONG ret;

    UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

   if (NumUSBDevices > 0) {

            while(usb_busy);

            usb_busy = true;

        ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x91, CurrentLimit, 0, buffer, 0);

            usb_busy = false;

    }

}

//===================================================================================

//These are new for the DP5:

//-----------------------------------------------------------------------------------

//92H + 16-bit value    Set DP5 boot options*

//-----------------------------------------------------------------------------------

//*Boot options:

//LSB of 16-bit value field:

//D7  0 = PX4 mode (use PX4 power supply configuration bytes, report 'PX4' in status)

//          1 = DP5 mode (use nonvolatile settings for HV, temp, etc; report 'DP4' in status)

//D6  0 = boot in unconfigured state

//          1 = use nonvolatile configuration, report 'power button config' in status

//D5  0 = 57,600 baud for RS232

//          1 = 115,200 baud

//D4  0 = 20MHz FPGA clock

//          1 = 80MHz FPGA clock

//D3  0 = positive HV PC5 required

//          1 = negative HV PC5 required

//D2  0 = ADC non-inverting [DP5 mode only; use 'invert' bit in PX4 mode]

//          1 = ADC inverting [" "]

//D1  0 =

//          1 =

//D0  0 =

//          1 =

//The MSB of the boot options is undefined so far.

void CDppUSB::SetDP5BootOptions(USHORT BootOptions)

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

            while(usb_busy);

            usb_busy = true;

            ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x92, BootOptions, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//93H + 16-bit value    Set PC5 HV

//-----------------------------------------------------------------------------------

void CDppUSB::SetPC5HV(USHORT HV)

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

            while(usb_busy);

            usb_busy = true;

            ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x93, HV, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//94H + 16-bit value    Set PC5 TEC temperature

//-----------------------------------------------------------------------------------

void CDppUSB::SetPC5TECTemp(USHORT Temperature)

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

            while(usb_busy);

            usb_busy = true;

            ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x94, Temperature, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//95H + 16-bit value    Set DP5 input offset

//-----------------------------------------------------------------------------------

void CDppUSB::SetDP5InputOffset(USHORT InputOffset)

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

            while(usb_busy);

            usb_busy = true;

            ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x95, InputOffset, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//96H + 16-bit value    Set DP5 microcontroller ADC/Temperature calibration (TBD)

//-----------------------------------------------------------------------------------

void CDppUSB::SetDP5MicroAdcTempCal(USHORT MicroAdcTempCal)

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

            while(usb_busy);

            usb_busy = true;

            ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x96, MicroAdcTempCal, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//97H + 16-bit value    Set DP5 spectrum offset

//-----------------------------------------------------------------------------------

void CDppUSB::SetDP5SpectrumOffset(USHORT SpectrumOffset)

{

      ULONG ret;

      UCHAR buffer[64];

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

            while(usb_busy);

            usb_busy = true;

            ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x97, SpectrumOffset, 0, buffer, 0);

            usb_busy = false;

      }

}

//-----------------------------------------------------------------------------------

//98H Request Digital Scope Data    20071210

//-----------------------------------------------------------------------------------

void CDppUSB::RequestDigitalScopeData()

{

      ULONG ret;

      UCHAR buffer[64];

      if (! isDPP5) return;         // Request Digital Scope Data needed for DP5 USB scope only

      while(usb_busy);

      usb_busy = true;

      NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

      usb_busy = false;

      if (NumUSBDevices > 0) {

            while(usb_busy);

            usb_busy = true;

            ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x98, 0, 0, buffer, 0);

            usb_busy = false;

      }

}

////-----------------------------------------------------------------------------------

////99H + 16-bit value  TBD

////-----------------------------------------------------------------------------------

//void CDppUSB::Set TBD(USHORT TBDOptions)

//{

//    ULONG ret;

//    UCHAR buffer[64];

//    while(usb_busy);

//    usb_busy = true;

//    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

//    usb_busy = false;

//    if (NumUSBDevices > 0) {

//          while(usb_busy);

//          usb_busy = true;

//          ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x99, TBDOptions, 0, buffer, 0);

//          usb_busy = false;

//    }

//}

////-----------------------------------------------------------------------------------

////9AH + 16-bit value  TBD

////-----------------------------------------------------------------------------------

//void CDppUSB::Set TBD(USHORT TBDOptions)

//{

//    ULONG ret;

//    UCHAR buffer[64];

//    while(usb_busy);

//    usb_busy = true;

//    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

//    usb_busy = false;

//    if (NumUSBDevices > 0) {

//          while(usb_busy);

//          usb_busy = true;

//          ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x9A, TBDOptions, 0, buffer, 0);

//          usb_busy = false;

//    }

//}

////-----------------------------------------------------------------------------------

////9BH + 16-bit value  TBD

////-----------------------------------------------------------------------------------

//void CDppUSB::Set TBD(USHORT TBDOptions)

//{

//    ULONG ret;

//    UCHAR buffer[64];

//    while(usb_busy);

//    usb_busy = true;

//    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

//    usb_busy = false;

//    if (NumUSBDevices > 0) {

//          while(usb_busy);

//          usb_busy = true;

//          ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x9B, TBDOptions, 0, buffer, 0);

//          usb_busy = false;

//    }

//}

////-----------------------------------------------------------------------------------

////9CH + 16-bit value  TBD

////-----------------------------------------------------------------------------------

//void CDppUSB::Set TBD(USHORT TBDOptions)

//{

//    ULONG ret;

//    UCHAR buffer[64];

//    while(usb_busy);

//    usb_busy = true;

//    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

//    usb_busy = false;

//    if (NumUSBDevices > 0) {

//          while(usb_busy);

//          usb_busy = true;

//          ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x9C, TBDOptions, 0, buffer, 0);

//          usb_busy = false;

//    }

//}

////-----------------------------------------------------------------------------------

////9DH + 16-bit value  TBD

////-----------------------------------------------------------------------------------

//void CDppUSB::Set TBD(USHORT TBDOptions)

//{

//    ULONG ret;

//    UCHAR buffer[64];

//    while(usb_busy);

//    usb_busy = true;

//    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

//    usb_busy = false;

//    if (NumUSBDevices > 0) {

//          while(usb_busy);

//          usb_busy = true;

//          ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x9D, TBDOptions, 0, buffer, 0);

//          usb_busy = false;

//    }

//}

////-----------------------------------------------------------------------------------

////9EH + 16-bit value  TBD

////-----------------------------------------------------------------------------------

//void CDppUSB::Set TBD(USHORT TBDOptions)

//{

//    ULONG ret;

//    UCHAR buffer[64];

//    while(usb_busy);

//    usb_busy = true;

//    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

//    usb_busy = false;

//    if (NumUSBDevices > 0) {

//          while(usb_busy);

//          usb_busy = true;

//          ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x9E, TBDOptions, 0, buffer, 0);

//          usb_busy = false;

//    }

//}

////-----------------------------------------------------------------------------------

////9FH + 16-bit value  Save current configuration to flash memory (may or may not be necessary)

////-----------------------------------------------------------------------------------

//void CDppUSB::Set SaveCfgToFlash(USHORT ConfigOptions)

//{

//    ULONG ret;

//    UCHAR buffer[64];

//    while(usb_busy);

//    usb_busy = true;

//    NumUSBDevices = USBDRVD_GetDevCount(&GUID_CLASS);

//    usb_busy = false;

//    if (NumUSBDevices > 0) {

//          while(usb_busy);

//          usb_busy = true;

//          ret = USBDRVD_VendorOrClassRequestOut(USB_Device_Handle, 2, 3, 0x9F, ConfigOptions, 0, buffer, 0);

//          usb_busy = false;

//    }

//}

////===================================================================================


USB.h

#pragma once

#if !defined(DPPUSB_H)

#define DPPUSB_H

#include "stdafx.h"

#include ".\ADMCA\DPP\USB\guid.h"   //in \sys directory

#include ".\ADMCA\Dpp\Cfg\DPPConst.h"

#include ".\ADMCA\DPP\USB\usbdrvd.h" //in \dll directory

//===============================================================

// DPP USB Communications Class

//---------------------------------------------------------------

// Purpose : Interfaces the DPP control functions to the APA USB API

//   Notes :

// Imports :

//---------------------------------------------------------------

//Revision History

//---------------------------------------------------------------

// 20040528 : Initial Version

// Copyright (c)2004, 2007 Amptek, All Rights Reserved

//===============================================================

class CDppUSB

{

private:

      // USB PIPE handles

      HANDLE PipeHandle_config;

      HANDLE PipeHandle_configOut;

      HANDLE PipeHandle_statusA;

      HANDLE PipeHandle_dataA;

      HANDLE PipeHandle_statusB;

      HANDLE PipeHandle_dataB;

      HANDLE PipeHandle_Scope;

      HANDLE USB_Device_Handle;

      UINT NumUSBDevices;

public:

      long Dropouts;                      // from dpp demo packet dropout test

      bool HaveDeviceStatus;

      bool DriverOpen;        // connection to driver open

      bool PipesOpen;               // pipes are open

      bool usb_busy;

      CDppUSB(void);

      ~CDppUSB(void);

      int MonitorUSBDevices();

      UINT OpenUSBPipes();

      UINT OpenUSB();

      void CloseUSBPipes();

      void CloseUSB();

      UINT PauseMCAUSB(BOOLEAN boolPauseMCA);

      void SendUSBPacket(UCHAR buffer[]);

      void ClearBuffer(BOOLEAN isBufferA);

      BOOLEAN USBDeviceReady();

      //ULONG GetDPPConfig(UCHAR Config[]);

      ULONG GetDPPConfig(UCHAR ConfigIn[], bool isScopeData);     //DP5 Scope Data uses config in pipe 20071211

      void GetDPPStatus(BOOLEAN isBufferA, UCHAR Status[]);

      void GetDPP_PipeOpen_Status(BOOLEAN isBufferA, UCHAR Status[]);

      DWORD GetDPPData(BOOLEAN isBufferA, UCHAR buffer[], UINT ExpectedCount);

      void SendDPPConfigUSB(UCHAR Config[], UINT Preset);

      void CDppUSB::SaveStringDataToFile(CString strData);

      bool CompareBufferArrays(UCHAR buffer[], UCHAR buffer2[]);

      void ClearBufferArray(UCHAR buffer[]);

      int USBTimer();

      CString GetUSBTimerStatText();

      CString DisplayBufferArray(UCHAR buffer[]);

public:

      double dppusbFirmware;                                      // DPP5 20070926 dpp firmware version

      double dppusbFPGA;                                                // DPP5 20070926 dpp fpga version

      bool isDPP5;                                                      // DPP5 20070926 DPP5 indicator

      double UCHARVersionToDouble(UCHAR Version);           // DPP5 20070926 converts version code to double

      long dppusbSerialNumber;

      int dppusbDeviceType;

      CString cstrDppUsbDeviceType;

      bool GetUSBDeviceInfo();

      UINT OpenUSBEx(UINT Device);

      int CurrentDevice;                                                // current USB device

      bool isSendingPacket;

      void InputOffsetFineStep();

      void InputOffsetCoarseStep();

      void DPPCalcFastThresh();

      void ArmTrigger();

      void ClearPA0IO0();

      void SetPA0IO0();

      void ClearPA1IO1();

      void SetPA1IO1();

      void ClearPA2IO2();

      void SetPA2IO2();

      void ClearPA3IO3();

      void SetPA3IO3();

      void SendDiodeCal(USHORT DCalValue);

      DWORD GetScopeData(UCHAR Scope[]);

      //void ResetUSBPipe(HANDLE ResetPipeHandle);

      double LongWordToDouble(int lwStart, UCHAR buffer[]);

      double GetDriverVersion();

      CString GetPX4DeviceText();

      void SendPX4DeviceText(CString strText);

      CString GetDP5DeviceText();

      void SendDP5DeviceText(CString strText);

      void SendGenericDppVendorRequest(UCHAR Request, USHORT Value);

      // DPP5 20070928 new dp5 vendor request functions

      void SetTECCurrentLimit(USHORT CurrentLimit);

      void SetDP5BootOptions(USHORT BootOptions);

      void SetPC5HV(USHORT HV);

      void SetPC5TECTemp(USHORT Temperature);

      void SetDP5InputOffset(USHORT InputOffset);

      void SetDP5MicroAdcTempCal(USHORT MicroAdcTempCal);

      void SetDP5SpectrumOffset(USHORT SpectrumOffset);

      void RequestDigitalScopeData();

      CString GetDeviceNameFromVal(int DeviceTypeVal);

      //void SetDeviceTypeFromStringDescriptor(CString cstrStringDescriptor);

};

#endif // !defined(DPPUSB_H)


usbdrvd.h

//

// $History: usbdrvd.h $

//

//*****************  Version 1  *****************

//User: JungoCE       Date: 6/04/09    Time: 9:41a

//Created in $/USB_DRV/DLL

#ifndef _USBDRVD_H_

#define _USBDRVD_H_

#define USBDRVD_EXPORTS

#ifdef USBDRVD_EXPORTS

#define USBDRVD_API __declspec(dllexport)

#else

#define USBDRVD_API __declspec(dllimport)

#endif

////////////////////////////////////////////////////////////////////////////////

/////////////////  Device Functions  ///////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

#ifdef __cplusplus

extern "C"{

#endif

//Returns number of USBDRVD devices attached

USBDRVD_API UINT _stdcall USBDRVD_GetDevCount(const GUID *pUSB_GUID);

USBDRVD_API HANDLE _stdcall USBDRVD_OpenDevice(UINT DevNum, DWORD dwFlagsAndAttributes, const GUID * pUSB_GUID);

USBDRVD_API void _stdcall USBDRVD_CloseDevice(HANDLE hDevice);

USBDRVD_API UINT _stdcall USBDRVD_GetStringDescriptor(HANDLE hDevice, USHORT LangID, ULONG Index, ULONG Length, PCHAR pString);

USBDRVD_API UINT _stdcall USBDRVD_GetDriverVersion(HANDLE hDevice, ULONG *pMajor, ULONG *pMinor);

USBDRVD_API ULONG _stdcall USBDRVD_VendorOrClassRequestOut(HANDLE hDevice,

                                                 UCHAR Type,                           // 1=class, 2 = vendor

                                                 UCHAR Destination,                    // 0=device, 1=interface,

                                                                                // 2=endpoint, 3=other

                                                // see the USB Specification for an explanation of the following

                                                 UCHAR Request,                        // request

                                                 USHORT Value,                         // value

                                                 USHORT Index,                         // index

                                                 PUCHAR pData,                         // data buffer

                                                 ULONG Length);                        // length of data

//Opens Pipe on device DevNum returning handle for pipe operations

USBDRVD_API HANDLE _stdcall USBDRVD_PipeOpen(UINT DevNum, UINT Pipe, DWORD dwFlagsAndAttributes, const GUID *pUSB_GUID);

//Given hPipe from prior USBDRVD_OpenPipe(), closes the pipe

USBDRVD_API void _stdcall USBDRVD_PipeClose(HANDLE hPipe);

//Writefile() wrapper with timeout

USBDRVD_API BOOL _stdcall USBDRVD_PipeWriteTimeout(HANDLE hPipe, LPVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, DWORD dwTimeout);

//ReadFile() wrapper with timeout

USBDRVD_API BOOL _stdcall USBDRVD_PipeReadTimeout(HANDLE hPipe, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, DWORD dwTimeout);

//Resets hPipe after a stall condition. (not normally needed, but provided)

USBDRVD_API BOOL _stdcall USBDRVD_PipeReset(HANDLE hPipe);

#ifdef __cplusplus

}

#endif

#endif


DppApi Help

DP4/PX4/DP5 Digital Pulse Processor API Help for Window Mobile 5 (ARMV4I)

The DP4/PX4/DP5 Digital Pulse Processor API is an Application Programming Interface Library for the Amptek DP4,PX4 and DP5 Digital Pulse Processors.

DPPAPI Function Groups

  • _ DppApi Introduction
  • Configuration Helper Functions
  • Configuration Transfer Functions
  • Data Acquisition Functions
  • DP5 Text Functions
  • DPP Tune Functions
  • DPP USB Additional Functions
  • DppApi Constructor Functions
  • DppApi Setup Notes
  • PX4 Text Functions
  • Status Indicator Functions
  • USB Manager Functions

    • DPPAPI Reference Sections

    Functions

    Structures

    Modules

    Help file built: 07/17/09

    Functions

  • ClearDppData
  • CloseDppApi
  • CloseUSBDevice
  • CreateMCAFileDPPSettings
  • DisplayStatusBuffer
  • Get80MHzMode
  • GetCoarseGainSpinFromText
  • GetCoarseGainTextFromSpin
  • GetConfigFromBuffer
  • GetConfigFromDpp
  • GetConfigFromFile
  • GetConfigString
  • GetDP5Text
  • GetDppData
  • GetOutputOffsetSpinFromText
  • GetOutputOffsetTextFromSpin
  • GetPresetTimeStringFromVal
  • GetPresetTimeValFromString
  • GetPX4Text
  • GetSlowThreshSpinFromChannel
  • GetSlowThreshSpinFromPercent
  • GetSlowThreshStringsFromSpin
  • GetStatusBuffer
  • GetStatusString
  • GetStatusStringFromBuffer
  • GetStatusStruct
  • GetStatusStructFromBuffer
  • GetTempConfigSettings
  • GetTempConfigString
  • GetTimeToPeakDecimationFromSpin
  • GetTimeToPeakSpinFromValues
  • GetUSBDppDeviceInfo
  • MonitorUSBDppDevices
  • OpenDppApi
  • OpenUSBDevice
  • OpenUSBDeviceEx
  • PauseDppData
  • ProcessDppData
  • ProcessStatusBuffer
  • SaveConfigToFile
  • SendConfigToBuffer
  • SendConfigToDpp
  • SendDppVendorRequest
  • SetDP5Text
  • SetFPGAClockDefault
  • SetPX4Text
  • SetTempConfigSettings
  • TuneFastThreshold
  • TuneInputOffset
  • TuneInputOffsetInit

    • Modules

  • _ DppApi Introduction
  • Configuration Helper Functions
  • Configuration Transfer Functions
  • Data Acquisition Functions
  • DP5 Text Functions
  • DPP Tune Functions
  • DPP USB Additional Functions
  • DppApi Constructor Functions
  • DppApi Setup Notes
  • PX4 Text Functions
  • Status Indicator Functions
  • USB Manager Functions

    • Structures

  • DPP_BOOT_STATUS
  • DPP_CONFIG_SETTINGS
  • DPP_STATUS

    • _ DppApi Introduction

     Filename: DppApi.h

    Description

    Interface to the DPP Application functions.

    The DP4/PX4/DP5 Digital Pulse Processor API (DppApi) is the Application Programming Interface Library for Amptek DP4, PX4 and DP5 Digital Pulse Processors (DPPs).

    Copyright (c)2005, 2007, 2009 Amptek, All Rights Reserved

    Developer Notes

    Application programs invoke DppApi functions to establish communication with DPP, control its operation, and retrieve data. DppApi is distributed in two forms, as an object link library (.LIB) or Dynamic Link Library (.DLL). The application executable programs (.EXE) are created by linking the application code with one of these libraries statically or dynamically (see Microsoft documentation about program linking). The applications can be developed in C, Visual Basic or many other languages.

    CE Configuration files and spectra are UNICODE. XP Configuration files and spectra are ASCII. Windows NotePad can be used to convert ASCII files to/from UNICODE.

    Version: v20050729_1423

    _ DppApi Introduction

  • DPP_BOOT_STATUS
  • DPP_CONFIG_SETTINGS
  • DPP_STATUS

    • Configuration Helper Functions

     Filename: DppApi.h

    Description

    help in the display, control and conversion of DPP configuration data.

    All of the configuration settings have underlying support classes. Configuration Helper Functions tap some of the functionality of the underlying classes. The goal is to reduce the amount of support coding necessary to a minimum.

    Copyright (c)2005, 2007 Amptek, All Rights Reserved

    Configuration Helper Functions

  • GetCoarseGainSpinFromText
  • GetCoarseGainTextFromSpin
  • GetOutputOffsetSpinFromText
  • GetOutputOffsetTextFromSpin
  • GetPresetTimeStringFromVal
  • GetPresetTimeValFromString
  • GetSlowThreshSpinFromChannel
  • GetSlowThreshSpinFromPercent
  • GetSlowThreshStringsFromSpin
  • GetTimeToPeakDecimationFromSpin
  • GetTimeToPeakSpinFromValues

    • Configuration Transfer Functions

     Filename: DppApi.h

    Description

    Configuration Transfer Functions provide device configuration services.

    Configuration Transfer Functions sets and transfers configurations to and from the current DPP, the DppApi and selected Amptek DPP configuration files.

    Copyright (c)2005, 2007 Amptek, All Rights Reserved

    Developer Notes

    The DppApi and the current DPP must be configured before data acquisition operations can begin.

    Configuration Transfer Functions

  • Get80MHzMode
  • GetConfigFromBuffer
  • GetConfigFromDpp
  • GetConfigFromFile
  • GetConfigString
  • GetTempConfigSettings
  • GetTempConfigString
  • SaveConfigToFile
  • SendConfigToBuffer
  • SendConfigToDpp
  • SetFPGAClockDefault
  • SetTempConfigSettings

    • Data Acquisition Functions

     Filename: DppApi.h

    Description

    Control data acquisition.

    Spectrum information is read as a block of data and is converted into histogram ready display values.

    Copyright (c)2005, 2007 Amptek, All Rights Reserved

    Data Acquisition Functions

  • ClearDppData
  • GetDppData
  • PauseDppData
  • ProcessDppData

    • DP5 Text Functions

     Filename: DppApi.h

    Description

    Sets and reads text stored in the DP5.

    DP5 Text Functions works for DP5 only.

    Copyright (c)2005, 2009 Amptek, All Rights Reserved

    DP5 Text Functions

  • GetDP5Text
  • SetDP5Text

    • DPP Tune Functions

     Filename: DppApi.h

    Description

    Tunes the fast threshold (DP4/PX4/DP5) and input offset (PX4/DP5 only).

    PX4 with FPGA/Firmware greater than Version 3.13 or DP4 with FPGA/Firmware greater than Version 4.00 required.

    Developer Notes

    The source must be removed to auto tune the fast threshold. Status flags are provided to indicate a tuning function successful completion. (See DPP_STATUS.)

    Copyright (c)2005-2009 Amptek, All Rights Reserved

    DPP Tune Functions

  • TuneFastThreshold
  • TuneInputOffset
  • TuneInputOffsetInit

    • DPP USB Additional Functions

     Filename: DppApi.h

    Description

    Send Dpp USB Vendor Request (DP4/PX4/DP5).

    Developer Notes

    Additonal functions are available through Dpp USB Vendor Requests. This is an advanced function and is not supported. See DP4/PX4/DP5 user manuals for Vendor Request function details.

    Copyright (c)2005-2009 Amptek, All Rights Reserved

    DPP USB Additional Functions

  • SendDppVendorRequest

    • DppApi Constructor Functions

     Filename: DppApi.h

    Description

    Opens the DPP Application functions.

    DppApi Constructor Functions create, initialize and close the DppApi. Opening the DppApi with OpenDppApi creates and initializes an instance of the DppApi. The DppApi instance manages and stores DPP data, configurations, and controls communication.

    Copyright (c)2005, 2007 Amptek, All Rights Reserved

    Developer Notes

    All other DppApi functions need the DppApi to be opened before being called. When all DppApi operations are completed and before the application is closed, the DppApi must be closed with CloseDppApi.

    DppApi Constructor Functions

  • CloseDppApi
  • OpenDppApi

    • DppApi Setup Notes

     Filename: DppApi.h

    Description

    Additional setup notes.

    Application programs invoke DppApi functions to establish DPP communications, control DPP operations, and retrieve spectrum data. The DppApi is distributed with an import library (.LIB), and a dynamic link library (.DLL) and a type library (.TLB).

    Applications can be developed with the DppApi in C, Visual Basic and many other programming languages.

    The C language representation of DppApi functions are defined in the DppApi.h header file. These files are provided with the DppApi libraries. The USB drivers provided with your Amptek DPP must be installed and the usbdrvd.dll must be accessible to the DppApi in order to function properly.

    Copyright (c)2005, 2007 Amptek, All Rights Reserved

    DppApi Setup Notes

    PX4 Text Functions

     Filename: DppApi.h

    Description

    Sets and reads text stored in the PX4.

    PX4 Text Functions works for PX4 with FPGA/Firmware Version 3.13 and above.

    Copyright (c)2005, 2007 Amptek, All Rights Reserved

    PX4 Text Functions

  • GetPX4Text
  • SetPX4Text

    • Status Indicator Functions

     Filename: DppApi.h

    Description

    Status Indicator Functions monitor and display DPP device information.

    Status information is read as a block of data and is converted into display values. Status information includes device identification, spectrum accumulation status, monitors, and boot status.

    Copyright (c)2005, 2007 Amptek, All Rights Reserved

    Status Indicator Functions

  • CreateMCAFileDPPSettings
  • DisplayStatusBuffer
  • GetStatusBuffer
  • GetStatusString
  • GetStatusStringFromBuffer
  • GetStatusStruct
  • GetStatusStructFromBuffer
  • ProcessStatusBuffer

    • USB Manager Functions

     Filename: DppApi.h

    Description

    USB Manager Functions provide USB device control.

    USB Manager Functions provide USB device control. All USB communications to the DPP require that the USB device be open for the corresponding DPP. When a USB device is opened with OpenUSBDevice communications are opened to the DPP. All USB functions are handled within the DppApi.

    Copyright (c)2005, 2007 Amptek, All Rights Reserved

    Developer Notes

    Once all USB operations are completed and before the DppApi is closed the USB device should be closed with CloseUSBDevice. The number of USB device connections can be monitored with MonitorUSBDppDevices. If a device has been disconnected, MonitorUSBDppDevices will indicate the number of devices has decreased and appropriate action can be taken.

    USB Manager Functions

  • CloseUSBDevice
  • GetUSBDppDeviceInfo
  • MonitorUSBDppDevices
  • OpenUSBDevice
  • OpenUSBDeviceEx

    • ClearDppData

     void __stdcall ClearDppData(void * objptr, BOOLEAN isBufferA)

    Clears the USB DPP spectrum data.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    isBufferA
    Spectrum data buffer selector.

    CloseDppApi

     void __stdcall CloseDppApi(void * objptr)

    Closes the current instance of the DppApi.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    CloseUSBDevice

     void __stdcall CloseUSBDevice(void * objptr)

    Closes the USB current device for communications.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    CreateMCAFileDPPSettings

     void __stdcall CreateMCAFileDPPSettings(void * objptr, LPWSTR pszSettings, LONG cSize)

    Creates a MCA acquisition file string that includes all configuration and status settings.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    pszSettings
    DPP devices settings.

    cSize
    Character buffer size.

    Developer Notes

    This function formats the additional information for MCA spectrum file storage. This settings string is appended to the end of the DPP MCA spectrum file after the spectrum data section. This information is used by the Amptek acquisition software.

    DisplayStatusBuffer

     void __stdcall DisplayStatusBuffer(void * objptr, UCHAR Status[], LPWSTR pszStatus, LONG cSize)

    Processes raw status data, stores the status data in the DppApi, and returns a status display string.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    Status[]
    Status buffer.

    pszStatus
    Status character string.

    cSize
    Character buffer size.

    Developer Notes

    The raw status data is read from the DPP by calling GetStatusBuffer. DisplayStatusBuffer is used to update the DppApi to the current DPP status and request status display information.

    Get80MHzMode

     long __stdcall Get80MHzMode(void * objptr)

    Gets FPGA 80MHz Clock Mode for DP5 only, returns true if is a DP5 and in 80MHz Mode.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    Developer Notes

    The FPGA 80MHz Clock Mode indicator is set when a DPP status command is issued and a DPP device is attached or when SetFPGAClockDefault sets this value. The DP5 FPGA 80MHz Clock Mode must be set to correctly interpret DP5 configuration file settings.

    GetCoarseGainSpinFromText

     void __stdcall GetCoarseGainSpinFromText(void * objptr, byte * Spin, LPWSTR pszCoarseGain)

    Creates an up-down spin control value from a coarse gain display string.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    Spin
    Up-down spin control setting.

    pszCoarseGain
    Coarse gain value string.

    GetCoarseGainTextFromSpin

     void __stdcall GetCoarseGainTextFromSpin(void * objptr, byte Spin, LPWSTR pszCoarseGain, LONG cSize)

    Creates a coarse gain display string from a selected up-down spin control value.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    Spin
    Up-down spin control setting.

    pszCoarseGain
    Coarse gain value string.

    cSize
    Character buffer size.

    GetConfigFromBuffer

     void __stdcall GetConfigFromBuffer(void * objptr)

    Loads the stored configuration read from the DPP (stored in a byte block) into the DppApi.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi. configuration buffer read from the dpp stored in a byte block the current device type (default is 1=DP4)

    GetConfigFromDpp

     void __stdcall GetConfigFromDpp(void * objptr)

    Loads the stored configuration from the DPP USB into the DppApi.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    GetConfigFromFile

     void __stdcall GetConfigFromFile(void * objptr, LPWSTR pszFilename, LONG cSize, byte DPPDeviceType)

    Loads a configuration from a DPP configuration file into the DppApi.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    pszFilename
    Dpp configuration filename.

    cSize
    Character buffer size.

    DPPDeviceType
    DPP Device Type

    Developer Notes

    DPP Device Type (1=DP4,2=PX4,3=DP5(DP4 Emulation),4=DP5(Px4 Emulation)) If no device type or an invalid device type is selected, DPPDeviceType defaults to PX4.

    GetConfigString

     void __stdcall GetConfigString(void * objptr, LPWSTR pszConfig, LONG cSize)

    Creates display formatted copy of the current DppApi configuration.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    pszConfig
    Configuration display string.

    cSize
    Character buffer size.

    GetDP5Text

     void __stdcall GetDP5Text(void * objptr, LPWSTR pszDP5Text, LONG cSize)

    Gets the DP5 stored text.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    pszDP5Text
    DP5 text string.

    cSize
    Character buffer size.

    GetDppData

     int __stdcall GetDppData(void * objptr, long DataBuffer[])

    Get the USB DPP spectrum data.

    Defined in: DppApi.h

    Return Value

    Returns the number of spectrum channels.

    Parameters

    objptr
    Pointer to the DppApi.

    DataBuffer[]
    Holds the DPP spectrum data.

    GetOutputOffsetSpinFromText

     void __stdcall GetOutputOffsetSpinFromText(void * objptr, byte * Spin, LPWSTR pszOffset)

    Creates an up-down spin control value from an output offset display string.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    Spin
    Up-down spin control setting.

    pszOffset
    Output offset value string.

    GetOutputOffsetTextFromSpin

     void __stdcall GetOutputOffsetTextFromSpin(void * objptr, byte Spin, LPWSTR pszOffset, LONG cSize)

    Creates an output offset display string from a selected up-down spin control value.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    Spin
    Up-down spin control setting.

    pszOffset
    Output offset value string.

    cSize
    Character buffer size.

    GetPresetTimeStringFromVal

     void __stdcall GetPresetTimeStringFromVal(void * objptr, long lPresetTime, LPWSTR pszPresetTime, LONG cSize)

    Creates a preset time display string from a preset time value.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    lPresetTime
    Preset time in tenths of a second.

    pszPresetTime
    Preset time display string.

    cSize
    Character buffer size.

    GetPresetTimeValFromString

     void __stdcall GetPresetTimeValFromString(void * objptr, long * lPresetTime, LPWSTR pszPresetTime)

    Calculates a preset time value from a preset time display string.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    lPresetTime
    Preset time in tenths of a second.

    pszPresetTime
    Preset time display string.

    GetPX4Text

     void __stdcall GetPX4Text(void * objptr, LPWSTR pszPX4Text, LONG cSize)

    Gets the PX4 stored text.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    pszPX4Text
    PX4 text string.

    cSize
    Character buffer size.

    GetSlowThreshSpinFromChannel

     void __stdcall GetSlowThreshSpinFromChannel(void * objptr, double dblChannel, byte * Spin)

    Calculates the up-down spin control value for a given slow threshold channel value.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    dblChannel
    Slow threshold spectrum channel.

    Spin
    Up-down spin control setting.

    GetSlowThreshSpinFromPercent

     void __stdcall GetSlowThreshSpinFromPercent(void * objptr, double dblPercent, byte * Spin)

    Calculates the up-down spin control value for a given slow threshold percent value.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    dblPercent
    Slow threshold percent of full energy scale.

    Spin
    Up-down spin control setting.

    GetSlowThreshStringsFromSpin

     void __stdcall GetSlowThreshStringsFromSpin(void * objptr, byte Spin, LPWSTR pszPercent, LONG cSizePer, LPWSTR pszChannels, LONG cSizeChan)

    Creates slow threshold percent and channel display strings from an up-down spin control value.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    Spin
    Up-down spin control setting.

    pszPercent
    Slow threshold percent display string.

    cSizePer
    Size of the percent character buffer.

    pszChannels
    Slow threshold channel position display string.

    cSizeChan
    Size of the channel character buffer.

    GetStatusBuffer

     void __stdcall GetStatusBuffer(void * objptr, BOOLEAN isBufferA, UCHAR Status[])

    Requests the current DPP device and spectrum status raw data.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    isBufferA
    Spectrum data buffer selector.

    Status[]
    Status buffer.

    Developer Notes

    A spectrum buffer (A or B) is selected to determine which group of Spectrum Accumulation Status information to return.

    GetStatusString

     void __stdcall GetStatusString(void * objptr, BOOLEAN isBufferA, LPWSTR pszStatus, LONG cSize)

    Gets a copy of the current status and stores the data in a string.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    isBufferA
    Spectrum data buffer selector.

    pszStatus
    Status character string.

    cSize
    Character buffer size.

    Developer Notes

    A spectrum buffer (A or B) is selected to determine which group of Spectrum Accumulation Status information to return.

    GetStatusStringFromBuffer

     void __stdcall GetStatusStringFromBuffer(void * objptr, BOOLEAN isBufferA, LPWSTR pszStatus, LONG cSize, UCHAR Status[])

    Gets a copy of the current status and stores the data in a string.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    isBufferA
    Spectrum data buffer selector.

    pszStatus
    Status character string.

    cSize
    Character buffer size.

    Status[]
    Status buffer.

    Developer Notes

    A spectrum buffer (A or B) is selected to determine which group of Spectrum Accumulation Status information to return.

    GetStatusStruct

     void __stdcall GetStatusStruct(void * objptr, BOOLEAN isBufferA, DPP_STATUS * StatusStruct)

    Returns the current DPP device and spectrum status data in a status structure.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    isBufferA
    Spectrum data buffer selector.

    StatusStruct
    Status structure.

    Developer Notes

    A spectrum buffer (A or B) is selected to determine which group of Spectrum Accumulation Status information to return.

    GetStatusStructFromBuffer

     void __stdcall GetStatusStructFromBuffer(void * objptr, BOOLEAN isBufferA, DPP_STATUS * StatusStruct, UCHAR Status[])

    Returns the current DPP device and spectrum status data in a status structure.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    isBufferA
    Spectrum data buffer selector.

    StatusStruct
    Status structure.

    Status[]
    Status buffer.

    Developer Notes

    A spectrum buffer (A or B) is selected to determine which group of Spectrum Accumulation Status information to return.

    GetTempConfigSettings

     void __stdcall GetTempConfigSettings(void * objptr, DPP_CONFIG_SETTINGS * CfgSet, BOOLEAN CurrentUpdate)

    Copies selected configuration to a DPP_CONFIG_SETTINGS structure.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    CfgSet
    Configuration settings.

    CurrentUpdate
    Current settings update.

    Developer Notes

    If UpdateCurrent is selected, the configuration is copied from the current DppApi configuration settings. If UpdateCurrent is not selected, the last temporary configuration storage is used.

    GetTempConfigString

     void __stdcall GetTempConfigString(void * objptr, LPWSTR pszConfig, LONG cSize)

    Creates a display formatted copy of the temporary DppApi configuration.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    pszConfig
    Configuration display string.

    cSize
    Character buffer size.

    GetTimeToPeakDecimationFromSpin

     void __stdcall GetTimeToPeakDecimationFromSpin(void * objptr, byte * TimeToPeak, byte * Decimation, byte Spin)

    Calculates the time-to-peak and decimation values from an up-down spin control value.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    TimeToPeak
    Time-to-peak value.

    Decimation
    Decimation value.

    Spin
    Up-down spin control setting.

    GetTimeToPeakSpinFromValues

     void __stdcall GetTimeToPeakSpinFromValues(void * objptr, byte TimeToPeak, byte Decimation, byte * Spin)

    Converts a time-to-peak value to an up-down spin control setting.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    TimeToPeak
    Time-to-peak value.

    Decimation
    Decimation value.

    Spin
    Up-down spin control setting.

    Developer Notes

    When a time-to-peak value is known it may be necessary to remotely set an up-down spin control. GetTimeToPeakSpinFromValues uses a time-to-peak value a known decimation value to calculate the correct control setting.

    GetUSBDppDeviceInfo

     int __stdcall GetUSBDppDeviceInfo(void * objptr, long Device, long * lSerialNumber)

    Get device information (serial number and type) for the selected usb device.

    Defined in: DppApi.h

    Return Value

    Returns the type Amptek USB device detected.

    Amptek DPP USB devices

    DPPNONE = 0x0 // none

    DPPDP4 = 0x1 // DP4

    DPPPX4 = 0x2 // PX4

    DPPDP4EMUL = 0x3 // DP5 with DP4 Emulation

    DPPPX4EMUL = 0x4 // DP5 with PX4 Emulation (Same as DPPDP5)

    DPPDP5 = 0x4 // DP5 with PX4 Emulation

    Parameters

    objptr
    Pointer to the DppApi.

    Device
    selected USB DPP device

    lSerialNumber
    serial number of device

    MonitorUSBDppDevices

     int __stdcall MonitorUSBDppDevices(void * objptr)

    Monitors the USB current device to determine if connected and communicating.

    Defined in: DppApi.h

    Return Value

    Returns the number of Amptek USB devices detected.

    Parameters

    objptr
    Pointer to the DppApi.

    OpenDppApi

     void * __stdcall OpenDppApi(void)

    Creates and initializes an instance of the DppApi.

    Defined in: DppApi.h

    Return Value

    Returns an object pointer handle to the DppApi.

    OpenUSBDevice

     int __stdcall OpenUSBDevice(void * objptr)

    Opens the USB current device for communications.

    Defined in: DppApi.h

    Return Value

    Returns the number of Amptek USB devices detected.

    Parameters

    objptr
    Pointer to the DppApi.

    OpenUSBDeviceEx

     int __stdcall OpenUSBDeviceEx(void * objptr, long Device)

    Opens the USB selected device for communications.

    Defined in: DppApi.h

    Return Value

    Returns the number of Amptek USB devices detected.

    Parameters

    objptr
    Pointer to the DppApi.

    Device
    selected USB DPP device

    PauseDppData

     void __stdcall PauseDppData(void * objptr, BOOLEAN boolPauseData)

    Pauses the USB DPP spectrum data.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    boolPauseData
    Pause the spectrum data.

    ProcessDppData

     int __stdcall ProcessDppData(void * objptr, long DataBuffer[], UCHAR RawData[], UINT ByteCount)

    Process the USB DPP spectrum data.

    Defined in: DppApi.h

    Return Value

    Returns the number of spectrum channels.

    Parameters

    objptr
    Pointer to the DppApi.

    DataBuffer[]
    Holds the DPP spectrum data.

    RawData[]
    Holds pre-processed spectra data.

    ByteCount
    Holds pre-processed spectra data byte count.

    ProcessStatusBuffer

     void __stdcall ProcessStatusBuffer(void * objptr, UCHAR Status[])

    Processes raw status data and stores the status data in the DppApi.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    Status[]
    Status buffer.

    Developer Notes

    The raw status data is read from the DPP by calling GetStatusBuffer. ProcessStatusBuffer is used to update the DppApi to the current DPP status without requesting status display information.

    SaveConfigToFile

     void __stdcall SaveConfigToFile(void * objptr, LPWSTR pszFilename, LONG cSize)

    Sends the current configuration from the DppApi to a DPP configuration file.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    pszFilename
    Dpp configuration filename.

    cSize
    Character buffer size.

    SendConfigToBuffer

     void __stdcall SendConfigToBuffer(void * objptr)

    Sends the current configuration from the DppApi to a configuration buffer.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi. dppapi configuration stored in a byte block preset setting

    SendConfigToDpp

     void __stdcall SendConfigToDpp(void * objptr)

    Sends the current configuration from the DppApi to the DPP USB.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    SendDppVendorRequest

     void __stdcall SendDppVendorRequest(void * objptr, int Request, int Value)

    Sends a generic DPP Vendor Request to the default usb device.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    Request
    Vendor request.

    Value
    Vendor request value.

    Developer Notes

    The function SendDppVendorRequest is determined by the Request parameter. See DP4/PX4/DP5 user manuals for Vendor Request function details.

    Boot Option Vendor Requests:

    BootOptSetBootFlags = 0x92 //Set DP5 boot options

    BootOptSetPC5HV = 0x93 //Set PC5 HV

    BootOptPC5TECTemp = 0x94 //Set PC5 TEC temperature

    BootOptDP5InputOffset = 0x95 //Set DP5 input offset

    BootOptSetDP5uCtrADC = 0x96 //Set DP5 microcontroller ADC/Temperature calibration (RESERVED)

    BootOptSetDP5SpectrumOffset = 0x97 //Set DP5 spectrum offset

    SetDP5Text

     void __stdcall SetDP5Text(void * objptr, LPWSTR pszDP5Text)

    Sets the DP5 stored text.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    pszDP5Text
    DP5 text string.

    SetFPGAClockDefault

     void __stdcall SetFPGAClockDefault(void * objptr, BOOLEAN b80MHzMode, byte DPPDeviceType)

    Sets FPGA 80MHz Clock Mode indicator for DP5 only

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    b80MHzMode
    80MHz Mode indicator.

    DPPDeviceType
    DPP Device Type.

    Developer Notes

    The DP5 FPGA 80MHz Clock Mode indicator must be set to correctly interpret DP5 configuration file settings. The FPGA 80MHz Clock indicator is set when a DPP status command is issued and a DPP device is attached or when SetFPGAClockDefault sets this value. SetFPGAClockDefault is needed when editing DP5 configuration files without a DP5 device.

    SetPX4Text

     void __stdcall SetPX4Text(void * objptr, LPWSTR pszPX4Text)

    Sets the PX4 stored text.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    pszPX4Text
    PX4 text string.

    SetTempConfigSettings

     void __stdcall SetTempConfigSettings(void * objptr, DPP_CONFIG_SETTINGS * CfgSet, BOOLEAN CurrentUpdate)

    Copies the selected settings from a DPP_CONFIG_SETTINGS data structure.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    CfgSet
    Configuration settings.

    CurrentUpdate
    Current settings update.

    Developer Notes

    If UpdateCurrent is selected, the temporary configuration is also copied to the current DppApi configuration settings. Current DppApi configuration settings can be used to configure the DPP or be saved to a configuration file for storage.

    TuneFastThreshold

     void __stdcall TuneFastThreshold(void * objptr)

    Tunes the fast threshold.

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    Developer Notes

    The source must be removed before tuning the fast threshold.

    The status flag SetFastThreshDone is set (=TRUE) if the fast threshold tuning was successful. If the fast threshold tuning was successful, the configuration must be read back using GetConfigFromDpp to update the DppApi copy of the configuration.

    TuneInputOffset

     void __stdcall TuneInputOffset(void * objptr)

    Tunes the input offset. (PX4/DP5 only.)

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    Developer Notes

    Input Offset MUST be properly set before running TuneInputOffset. The initial input offset setting is based on the current input polarity and polezero configuration settings. The TuneInputOffsetInit function checks these values and sets the initial input offset value.

    The status flag SetInputOffsetDone is set (=TRUE) if the input offset tuning was successful. If the input offset tuning was successful, the configuration must be read back using GetConfigFromDpp to update the DppApi copy of the configuration.

    (See the DppApi Reference and the PX4/DP5 Hardware Description for details.)

    Possible input offset tune start settings:

    SET TO -2.048V (= 0000) IF THE Input Polarity is NEGATIVE(-) and PoleZero > 0

    SET TO -0.100V (= 1948) IF THE Input Polarity is NEGATIVE(-) and PoleZero = 0

    SET TO +0.100V (= 2148) IF THE Input Polarity is POSITIVE(+) and PoleZero = 0

    SET TO +2.042V (= 4090) IF THE Input Polarity is POSITIVE(+) and PoleZero > 0

    TuneInputOffsetInit

     void __stdcall TuneInputOffsetInit(void * objptr)

    Sets initial values for PX4 input offset tuning. (PX4 only.)

    Defined in: DppApi.h

    Parameters

    objptr
    Pointer to the DppApi.

    DPP_BOOT_STATUS structure

    struct {
    USHORT BootFlags;
    USHORT HVDACSet;
    USHORT TECDACSet;
    USHORT InputOffsetTuning;
    USHORT uCTempCal;
    USHORT SpectrumOffset;
} DPP_BOOT_STATUS;
    DPP Boot Options Status Storage Type

    Defined in: DppApi.h

    Members

    BootFlags
    Boot flags (MSB currently unused)
    HVDACSet
    HV DAC setting (not used in PX4 mode)
    TECDACSet
    TEC DAC setting (not used in PX4 mode)
    InputOffsetTuning
    Input offset DAC setting (not used in PX4 mode)
    uCTempCal
    uC temp cal
    SpectrumOffset
    Spectrum offset

    DPP_CONFIG_SETTINGS structure

    struct {
    byte AcqMode;
    byte MCSTimebase;
    byte MCAChannels;
    byte BufferSelect;
    byte TTLGate;
    byte SlowThreshold;
    long PresetTime;
    long PresetCount;
    long SCA[8];
    byte TimeToPeak;
    byte Decimation;
    byte FlatTop;
    byte PUREnable;
    byte FastThreshold;
    byte RTDSlow;
    byte RTDOn;
    byte RTDFast;
    byte BLR;
    byte BaselineOn;
    byte CoarseGain;
    long FineGain;
    long PoleZero;
    long InputOffset;
    byte InputPolarity;
    byte DetReset;
    long TEC;
    byte HVEnabled;
    long HV;
    byte PreampPower;
    byte AnalogOut;
    byte OutputOffset;
    byte AuxOut;
    byte AudibleCounter;
} DPP_CONFIG_SETTINGS;
    DPP Configuration Settings Storage Type

    Defined in: DppApi.h

    Members

    AcqMode
    acquisition mode 0=MCA,1=MCS
    MCSTimebase
    MCS timebase value (0-15) see CAcqMode
    MCAChannels
    number of channels 4=256,3=512,2=1024,1=2048,0=4096,5=8192
    BufferSelect
    Holds Buffer Sel A&B,Buffer Sel Hardware,see DPPBufferSelect
    TTLGate
    gate input settings, determines events included/excluded from spectrum, see DPPGate
    SlowThreshold
    Slow ch threshold, Events w/amp lower not added to spectrum
    PresetTime
    var holds preset time, used in usb
    PresetCount
    preset count in selected channels, ch are set in SCA8
    SCA[8]
    SCA values, LL, UL, and Enable are stored together
    TimeToPeak
    TimeToPeak register setting
    Decimation
    decimation setting for pulse shaping
    FlatTop
    flatop register setting
    PUREnable
    pile-up rejection enabled
    FastThreshold
    Fast Ch Threshold, events w/fch amp below this are rejected
    RTDSlow
    Risetime Discrimination slow threshold
    RTDOn
    Turns RTD on, and sets the amplitude and timing thresholds
    RTDFast
    RTD Time Threshold,Events w/HWHM wider than this are rejected
    BLR
    Baseline Restoration, see udBLR.Value notes for values
    BaselineOn
    use autobaseline during detector reset
    CoarseGain
    stores current coarse gain value
    FineGain
    stores current fine gain value
    PoleZero
    pole zero adjust value
    InputOffset
    input offset
    InputPolarity
    use InvertEnable during detector reset
    DetReset
    detector reset lockout period
    TEC
    TEC temperature setting (displayed in Kelvin)
    HVEnabled
    high voltage setting enable
    HV
    high voltage setting value
    PreampPower
    preamp power select value (5v or 8.5v)
    AnalogOut
    dac enabled and DAC output type,(stobed peak,shaped pulse,dec inp,fast ch)
    OutputOffset
    Output DAC offset, -64…+63,(signed)(D7-D1) (-500mV to +492mV)
    AuxOut
    Aux output type
    AudibleCounter
    audio volume setting

    DPP_STATUS structure

    struct {
    double FPGA;
    double Firmware;
    double SerialNumber;
    byte StatDevInd;
    byte BootStatus;
    byte PwrBtnConfig;
    byte SwConfigRcvd;
    byte SetFastThreshDone;
    byte SetSlowThreshDone;
    byte SetInputOffsetDone;
    double BoardTemp;
    double HVMonitor;
    double TECMonitor;
    double FastCount;
    double SlowCount;
    double AccumulationTime;
    byte StatMcaEnabled;
    byte MCSDone;
    byte PresetCountExpired;
} DPP_STATUS;
    DPP Status Storage Type

    Defined in: DppApi.h

    Members

    FPGA
    FPGA
    Firmware
    firmware revision
    SerialNumber
    unit serial number
    StatDevInd
    device indicator from status block (0=dp4,1=px4)
    BootStatus
    boot status byte (PwrBtnConfig,SwConfigRcvd,McaEnabled)
    PwrBtnConfig
    dpp has loaded config from power button
    SwConfigRcvd
    software has sent valid config to unit since startup
    SetFastThreshDone
    DPP tune fast thresh has successfully done
    SetSlowThreshDone
    DPP tune slow thresh has successfully done (NOT USED)
    SetInputOffsetDone
    DPP tune input offset has successfully done
    BoardTemp
    board temperature monitor value
    HVMonitor
    high voltage monitor value
    TECMonitor
    TEC temperature monitor value (displayed in Kelvin)
    FastCount
    fast channel count
    SlowCount
    slow channel count
    AccumulationTime
    real time duration of present data acquisition interval
    StatMcaEnabled
    mca enabled status, high during acq, preset time resets flag
    MCSDone
    MCS done flag 1=finished, 0=not finished
    PresetCountExpired
    indicates presets counts have been reached


Test_CE_DPP - CE DppApi C++ Demonstration Project

CE Configuration files and spectra are UNICODE.
XP Configuration files and spectra are ASCII.
Windows NotePad can be used to convert ASCII files to/from UNICODE.
This example provides a cut/paste solution for rapid application development. Below is a list of demonstrated concepts used in Visual C++ CE DppApi development.

  • Test_CE_DPP - CE DppApi C++ Demonstration Project:

    • Minimum code required for spectrum acquisition.

    • Snapshot data acquisition.

    • Plots in linear (and has code to plot in log) scale.

    • Start/Stop acquisition loop.

    • Find connected USB DPP devices.

    • Selects default USB DPP device from a list of connected devices.

    • Acquires spectrum data.

    • Reads/displays DPP status.

    • Reads/Saves Unicode DPP configuration.

    • Sends/Receives DPP configurations through USB.

    • Test_CE_DPP C++ Example

    • Acquisition Menu

    • Setup Menu

    • Display Dialog Showing a Configuration

    • Open Dialog Showing Default Amptek Configuration Files

    • SaveAs Dialog Showing the Default Configuration Save Filename

    • Display Dialog Showing a DPP Status Message

    • CE DppApi Program Files Directory

  • Demonstrates DppApi control of Amptek USB DPP devices.

  • Visual C++ 8.0 source code.

Test_CE_DPP C++ Example

Acquisition Menu

Setup Menu

Display Dialog Showing a Configuration

Open Dialog Showing Default Amptek Configuration Files

SaveAs Dialog Showing the Default Configuration Save Filename

Display Dialog Showing a DPP Status Message

CE DppApi Program Files Directory


Configuration Editor

CfgEdit - Configuration Editor

  • Edits Amptek DPP Configurations.

  • Communicates to USB DPP devices.

  • Sends/Receives DPP configurations through USB.

  • Reads/Writes/Edits DPP configuration files.

  • Visual Basic 5 source code.

  • Includes Edit Configuration Dialog.

Edit Configuration Dialog


DP5 Boot Options Manager

DP5BootManager – DP5 Boot Options Manager

  • Communicates to USB DP5 DPPs

  • Reads/Writes/Edits USB DP5 Boot Options

  • Reads USB DP5 Configuration and Status

  • Visual Basic 5 source code.

  • Includes DP5 Boot Flag Dialog.

DP5 Boot Flag Dialog


SavePlot - Save 10 Second Preset Spectrum Plot

  • Saves 10 Second Data Spectrum.

  • Reads DPP configuration and status.

  • Sets 10 second preset.

  • Acquires spectrum data for 10 seconds.

  • Saves spectrum data to Amptek MCA spectrum file.

  • Visual Basic 5 source code.


vbDppApi - DPPAPI Demonstration Project

  • Finds connected USB DPP devices.

  • Select a USB DPP device from a list of connected devices.

    • Select DPP from connected device list.

  • Acquires spectrum data.

  • Reads/displays DPP status.

  • Reads/displays DPP configuration.

  • Sends/Receives DPP configurations through USB.

  • Edits DPP configurations.

  • Visual Basic 5 source code.

  • vbDppApi Acquiring Data.

  • vbDppApi Edit/Display Configuration.

  • vbDppApi Selecting a DPP.

vbDppApi Acquiring Data

vbDppApi Edit/Display Configuration

vbDppApi Selecting a DPP


Slide 1

Click here to start

Table of contents

Slide 1
Slide 2
Slide 3
Slide 4
Slide 5
Slide 6
Slide 7
Slide 8
Slide 9
Slide 10
Slide 11
Slide 12
Slide 13
Slide 14
Slide 15
Slide 16
Slide 17
Slide 18
Slide 19
Slide 20
Slide 21
Slide 22
Slide 23
Slide 24
Slide 25
Slide 26
Slide 27
Slide 28
Slide 29
Slide 30
Slide 31
Slide 32
Slide 33
Slide 34
Slide 35
Slide 36
Slide 37
Slide 38
Slide 39
Slide 40
Slide 41
Slide 42
Slide 43
Slide 44
Slide 45
Slide 46
Slide 47
Slide 48
Slide 49
Slide 50
Slide 51
Slide 52
Slide 53
Slide 54
Slide 55
Slide 56
Slide 57
Slide 58
Slide 59
Slide 60
Slide 61
Slide 62
Slide 63
Slide 64
Slide 65
Slide 66
Slide 67
Slide 68
Slide 69
Slide 70
Slide 71
Slide 72
Slide 73
Slide 74
Slide 75
Slide 76
Slide 77
Slide 78
Slide 79
Slide 80


C:\Program Files\CE Remote Tools\5.01\bin


USBDRVD_CloseDevice
USBDRVD_GetDevCount
USBDRVD_GetDriverVersion
USBDRVD_GetStringDescriptor
USBDRVD_OpenDevice
USBDRVD_PipeClose
USBDRVD_PipeOpen
USBDRVD_PipeReadTimeout
USBDRVD_PipeReset
USBDRVD_PipeWriteTimeout
USBDRVD_VendorOrClassRequestOut


1>------ Build started: Project: DppApi, Configuration: Debug Windows Mobile 5.0 Pocket PC SDK (ARMV4I) ------
1>Compiling...
1>DppShaping.cpp
1>Build log was saved at "file://c:\WinDriver\samples\DPPAPI\Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\Debug\BuildLog.htm"
1>DppApi - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========


========================================================================
    MICROSOFT FOUNDATION CLASS LIBRARY : DppApi Project Overview
========================================================================

AppWizard has created this DppApi DLL for you.  This DLL not only
demonstrates the basics of using the Microsoft Foundation classes but
is also a starting point for writing your DLL.

This file contains a summary of what you will find in each of the files that
make up your DppApi DLL.

DppApi.vcproj
    This is the main project file for VC++ projects generated using an Application Wizard.
    It contains information about the version of Visual C++ that generated the file, and
    information about the platforms, configurations, and project features selected with the
    Application Wizard.

DppApi.h
    This is the main header file for the DLL.  It declares the
    CDppApiApp class.

DppApi.cpp
    This is the main DLL source file.  It contains the class CDppApiApp.
    It also contains the OLE entry points required of inproc servers.

DppApi.idl
    This file contains the Object Description Language source code for the
    type library of your DLL.

DppApippc.rc
    This is a listing of all of the Microsoft Windows resources that the
    project uses when compiling for the Pocket PC platform, or a platform
    that supports the same user interface model.  It includes the icons,
    bitmaps, and cursors that are stored in the RES subdirectory. When the
    .rc file is persisted, the defines in the data section are persisted
    as the hexadecimal version of the numeric value they are defined to
    rather than the friendly name of the define.

res\DppApi.rc2
    This file contains resources that are not edited by Microsoft
    Visual C++.  You should place all resources not editable by
    the resource editor in this file.

DppApi.def
    This file contains information about the DLL that must be
    provided to run with Microsoft Windows.  It defines parameters
    such as the name and description of the DLL.  It also exports
    functions from the DLL.

/////////////////////////////////////////////////////////////////////////////
Other standard files:

StdAfx.h, StdAfx.cpp
    These files are used to build a precompiled header (PCH) file
    named DppApi.pch and a precompiled types file named StdAfx.obj.

resourceppc.h
    This is the standard header file, which defines new resource IDs.
    Microsoft Visual C++ reads and updates this file.

/////////////////////////////////////////////////////////////////////////////
Other notes:

AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.

/////////////////////////////////////////////////////////////////////////////


DPPAPI DLL Files List - 2009-07-15

DppApi.dll - DPPAPI Dynamic Link Library
DppApi.tlb - DPPAPI Type Library
DppApi.lib - DPPAPI Import Library
DppApi.exp - DPPAPI Export Library
DppApi.res - DPPAPI Compiled Resource File


DP4/PX4/DP5 Digital Pulse Processor API Reference

Amptek, Inc.
14 De Angelo Dr.
Bedford MA 01730
781-275-2242			www.amptek.com

Directory Contents:
-------------------
\DPPAPI\dll           - DppApi dynamic link library and related files
\DPPAPI\doc           - DppApi reference documentation
\DPPAPI\USB           - USB driver installation files and information
\DPPAPI\vb            - Visual Basic samples
\DPPAPI\vc            - Visual C++ samples
\DPPAPI\DP5 Utilities - DP5 Boot Manager and UpLoad Utilities
..\ADMCA\DET_CFG      - Amptek detector configuration sample files

Getting Started...
------------------
The Amptek DppApi was developed to provide rapid low-cost development of
acquisition software for Amptek DP4,PX4 and DP5 Digital Pulse Processors (DPPs).

The DppApi Reference Manual is located at:
\DPPAPI\doc\DPPAPI_Reference.pdf

The DppApi Reference Manual contains an overview of the DppApi and its functions.

------------------------------------------------------
DPPAPI - DP4/PX4 Digital Pulse Processor API Reference
Copyright (C) 2006,2009 Amptek, Inc.


DPPAPI Static Library Files List - 2005-08-02

DppApi.tlb - DPPAPI Type Library
DppApi.lib - DPPAPI Static Library
DppApi.res - DPPAPI Compiled Resource File


This directory contains USB drivers and minimum information necessary for DPPAPI software development.
It is recommended to use the drivers distributed with your DP4/PX4.
Additional USB driver related information and samples are included with the USB drivers provided with your Amptek product.


================================================================================
    MICROSOFT FOUNDATION CLASS LIBRARY : Test_CE_DPP Project Overview
===============================================================================

The application wizard has created this Test_CE_DPP application for
you.  This application not only demonstrates the basics of using the Microsoft
Foundation Classes but is also a starting point for writing your application.

This file contains a summary of what you will find in each of the files that
make up your Test_CE_DPP application.

Test_CE_DPP.vcproj
    This is the main project file for VC++ projects generated using an application wizard.
    It contains information about the version of Visual C++ that generated the file, and
    information about the platforms, configurations, and project features selected with the
    application wizard.

Test_CE_DPP.h
    This is the main header file for the application.  It includes other
    project specific headers and declares the CTest_CE_DPPApp application class.

Test_CE_DPP.cpp
    This is the main application source file that contains the application
    class CTest_CE_DPPApp.

Test_CE_DPPppc.rc
    This is the project's main resource file listing of all of the Microsoft Windows
    resources that the project uses when compiling for the Pocket PC platform, or a
    platform that supports the same user interface model.  It includes the icons,
    bitmaps, and cursors that are stored in the RES subdirectory.  This file can be
    directly edited in Microsoft Visual C++. Your project resources are in
    1033. When the .rc file is persisted, the defines in the data section
    are persisted as the hexadecimal version of the numeric value they are defined to
    rather than the friendly name of the define.

res\Test_CE_DPPppc.rc2
    This file contains resources that are not edited by Microsoft
    Visual C++. You should place all resources not editable by
    the resource editor in this file.

res\Test_CE_DPP.ico
    This is an icon file, which is used as the application's icon.  This
    icon is included by the main resource file.

/////////////////////////////////////////////////////////////////////////////

The application wizard creates one dialog class:

Test_CE_DPPDlg.h, Test_CE_DPPDlg.cpp - the dialog
    These files contain your CTest_CE_DPPDlg class.  This class defines
    the behavior of your application's main dialog.  The dialog's template is
    in the main resource file, which can be edited in Microsoft Visual C++.

/////////////////////////////////////////////////////////////////////////////

Other standard files:

StdAfx.h, StdAfx.cpp
    These files are used to build a precompiled header (PCH) file
    named Test_CE_DPP.pch and a precompiled types file named StdAfx.obj.

Resourceppc.h
    This is the standard header file, which defines new resource IDs.
    Microsoft Visual C++ reads and updates this file.

/////////////////////////////////////////////////////////////////////////////

Other notes:

The application wizard uses "TODO:" to indicate parts of the source code you
should add to or customize.

If your application uses MFC in a shared DLL, and your application is in a
language other than the operating system's current language, you will need
to copy the corresponding localized resources MFC80XXX.DLL to your application
directory ("XXX" stands for the language abbreviation.  For example,
MFC80DEU.DLL contains resources translated to German.)  If you don't do this,
some of the UI elements of your application will remain in the language of the
operating system.

/////////////////////////////////////////////////////////////////////////////


1>------ Deploy started: Project: DPP_CE, Configuration: DPP_CE DLL Debug Windows Mobile 5.0 Pocket PC SDK (ARMV4I) ------
1>c:\WinDriver\samples\DPP_CE\Windows_Mobile_5_ARMV4I\msdev_2005\Debug\DppUsbCE.dll
1>Registering file...
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========


Building
--------

To rebuild the cab files run the following command

"C:\Program Files\Windows CE Tools\wce420\POCKET PC 2003\Tools\Cabwiz.exe" "C:\WinDriver\WM5 DPP Setup\DppApi.inf"

Then copy the CAB files created to the Install_DppApi directory.

File List
---------

Everything in the Install_DppApi directory is required to install your application.


========================================================================
       WIN32 APPLICATION : PocketPCInstall
========================================================================

AppWizard has created this PocketPCInstall application for you.

This file contains a summary of what you will find in each of the files that
make up your PocketPCInstall application.

PocketPCInstall.cpp
    This is the main application source file.

PocketPCInstall.dsp
    This file (the project file) contains information at the project level and
    is used to build a single project or subproject. Other users can share the
    project (.dsp) file, but they should export the makefiles locally.

/////////////////////////////////////////////////////////////////////////////
Other standard files:

StdAfx.h, StdAfx.cpp
    These files are used to build a precompiled header (PCH) file
    named PocketPCInstall.pch and a precompiled types file named StdAfx.obj.

/////////////////////////////////////////////////////////////////////////////
Other notes:

AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.

/////////////////////////////////////////////////////////////////////////////