Machine Interface Utility:VER1.0
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
||||
|
||||
USAGE: benchmark [list]
|
||||
[pid=] [vid=] [ep=] [intf=] [altf=]
|
||||
[read|write|loop] [notestselect]
|
||||
[verify|verifydetail]
|
||||
[retry=] [timeout=] [refresh=] [priority=]
|
||||
[mode=] [buffersize=] [buffercount=] [packetsize=]
|
||||
|
||||
Commands:
|
||||
list : Display a list of connected devices before starting.
|
||||
Select the device to use for the test from the list.
|
||||
read : Read from the device.
|
||||
write : Write to the device.
|
||||
loop : [Default] Read and write to the device at the same time.
|
||||
|
||||
notestselect : Skips submitting the control transfers to get/set the
|
||||
test type. This makes the application compatible
|
||||
with non-benchmark firmwared. Use at your own risk!
|
||||
|
||||
verify : Verify received data for loop and read tests. Report
|
||||
basic information on data validation errors.
|
||||
verifydetail : Same as verify except reports detail information for
|
||||
each byte that fails validation.
|
||||
|
||||
Switches:
|
||||
vid : Vendor id of device. (hex) (Default=0x0666)
|
||||
pid : Product id of device. (hex) (Default=0x0001)
|
||||
retry : Number of times to retry a transfer that timeout.
|
||||
(Default = 0)
|
||||
timeout : Transfer timeout value. (milliseconds) (Default=5000)
|
||||
The timeout value used for read/write operations. If a
|
||||
transfer times out more than {retry} times, the test
|
||||
fails and the operation is aborted.
|
||||
mode : Sync|Async (Default=Sync)
|
||||
Sync uses the libusb-win32 sync transfer functions.
|
||||
Async uses the libusb-win32 asynchronous api.
|
||||
buffersize : Transfer test size in bytes. (Default=4096)
|
||||
Increasing this value will generally yield higher
|
||||
transfer rates.
|
||||
buffercount: (Async mode only) Number of outstanding transfers on
|
||||
an endpoint (Default=1, Max=10). Increasing this value
|
||||
will generally yield higher transfer rates.
|
||||
refresh : The display refresh interval. (in milliseconds)
|
||||
(Default=1000) This also effect the running status.
|
||||
priority : AboveNormal|BelowNormal|Highest|Lowest|Normal
|
||||
(Default=Normal) The thread priority level to use
|
||||
for the test.
|
||||
ep : The loopback endpoint to use. For example ep=0x01, would
|
||||
read from 0x81 and write to 0x01. (default is to use the
|
||||
(first read/write endpoint(s) in the interface)
|
||||
intf : The interface id the read/write endpoints reside in.
|
||||
intf : The alt interface id the read/write endpoints reside in.
|
||||
packetsize : For isochronous use only. Sets the iso packet size.
|
||||
If not specified, the endpoints maximum packet size
|
||||
is used.
|
||||
WARNING:
|
||||
This program should only be used with USB devices which implement
|
||||
one more more "Benchmark" interface(s). Using this application
|
||||
with a USB device it was not designed for can result in permanent
|
||||
damage to the device.
|
||||
|
||||
Examples:
|
||||
|
||||
benchmark vid=0x0666 pid=0x0001
|
||||
benchmark vid=0x4D2 pid=0x162E
|
||||
benchmark vid=0x4D2 pid=0x162E buffersize=65536
|
||||
benchmark read vid=0x4D2 pid=0x162E
|
||||
benchmark vid=0x4D2 pid=0x162E buffercount=3 buffersize=0x2000
|
||||
File diff suppressed because it is too large
Load Diff
+56
@@ -0,0 +1,56 @@
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define _WIN32_IE 0x0400
|
||||
#endif
|
||||
|
||||
#define RC_VERSION 1,1,0,0
|
||||
#define RC_VERSION_STR "1.1.0.0"
|
||||
|
||||
#ifndef _BENCHMARK_VER_ONLY
|
||||
|
||||
#include <windows.h>
|
||||
#include <winver.h>
|
||||
|
||||
#define RC_FILE_TYPE VFT_APP
|
||||
#define RC_FILE_SUB_TYPE VFT2_UNKNOWN
|
||||
#define RC_PRODUCT_STR "Benchmark Application"
|
||||
#define RC_FILE_NAME_STR "Benchmark.exe"
|
||||
|
||||
#define RT_MANIFEST 24
|
||||
#define ID_MANIFEST 1
|
||||
#define ID_HELP_TEXT 10020
|
||||
#define ID_DOS_TEXT 300
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION RC_VERSION
|
||||
PRODUCTVERSION RC_VERSION
|
||||
FILEFLAGSMASK 0x3FL
|
||||
FILEFLAGS 0x0L
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE RC_FILE_TYPE
|
||||
FILESUBTYPE RC_FILE_SUB_TYPE
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Travis Robinson"
|
||||
VALUE "FileDescription", RC_PRODUCT_STR
|
||||
VALUE "FileVersion", RC_VERSION_STR
|
||||
VALUE "InternalName", RC_FILE_NAME_STR
|
||||
VALUE "LegalCopyright", "Copyright (C) 2010 Travis Robinson"
|
||||
VALUE "OriginalFilename",RC_FILE_NAME_STR
|
||||
VALUE "ProductName", RC_PRODUCT_STR
|
||||
VALUE "ProductVersion", RC_VERSION_STR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
ID_HELP_TEXT ID_DOS_TEXT "BenchmarkHelp.txt"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,240 @@
|
||||
#include <usb.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Enables this example to work with a device running the
|
||||
// libusb-win32 PIC Benchmark Firmware.
|
||||
#define BENCHMARK_DEVICE
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// TEST SETUP (User configurable)
|
||||
|
||||
// Issues a Set configuration request
|
||||
#define TEST_SET_CONFIGURATION
|
||||
|
||||
// Issues a claim interface request
|
||||
#define TEST_CLAIM_INTERFACE
|
||||
|
||||
// Use the libusb-win32 async transfer functions. see
|
||||
// transfer_bulk_async() below.
|
||||
#define TEST_ASYNC
|
||||
|
||||
// Attempts one bulk read.
|
||||
#define TEST_BULK_READ
|
||||
|
||||
// Attempts one bulk write.
|
||||
// #define TEST_BULK_WRITE
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// DEVICE SETUP (User configurable)
|
||||
|
||||
// Device vendor and product id.
|
||||
#define MY_VID 0x0666
|
||||
#define MY_PID 0x0001
|
||||
|
||||
// Device configuration and interface id.
|
||||
#define MY_CONFIG 1
|
||||
#define MY_INTF 0
|
||||
|
||||
// Device endpoint(s)
|
||||
#define EP_IN 0x81
|
||||
#define EP_OUT 0x01
|
||||
|
||||
// Device of bytes to transfer.
|
||||
#define BUF_SIZE 64
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
usb_dev_handle *open_dev(void);
|
||||
|
||||
static int transfer_bulk_async(usb_dev_handle *dev,
|
||||
int ep,
|
||||
char *bytes,
|
||||
int size,
|
||||
int timeout);
|
||||
|
||||
usb_dev_handle *open_dev(void)
|
||||
{
|
||||
struct usb_bus *bus;
|
||||
struct usb_device *dev;
|
||||
|
||||
for (bus = usb_get_busses(); bus; bus = bus->next)
|
||||
{
|
||||
for (dev = bus->devices; dev; dev = dev->next)
|
||||
{
|
||||
if (dev->descriptor.idVendor == MY_VID
|
||||
&& dev->descriptor.idProduct == MY_PID)
|
||||
{
|
||||
return usb_open(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
usb_dev_handle *dev = NULL; /* the device handle */
|
||||
char tmp[BUF_SIZE];
|
||||
int ret;
|
||||
void* async_read_context = NULL;
|
||||
void* async_write_context = NULL;
|
||||
|
||||
usb_init(); /* initialize the library */
|
||||
usb_find_busses(); /* find all busses */
|
||||
usb_find_devices(); /* find all connected devices */
|
||||
|
||||
|
||||
if (!(dev = open_dev()))
|
||||
{
|
||||
printf("error opening device: \n%s\n", usb_strerror());
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("success: device %04X:%04X opened\n", MY_VID, MY_PID);
|
||||
}
|
||||
|
||||
#ifdef TEST_SET_CONFIGURATION
|
||||
if (usb_set_configuration(dev, MY_CONFIG) < 0)
|
||||
{
|
||||
printf("error setting config #%d: %s\n", MY_CONFIG, usb_strerror());
|
||||
usb_close(dev);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("success: set configuration #%d\n", MY_CONFIG);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TEST_CLAIM_INTERFACE
|
||||
if (usb_claim_interface(dev, 0) < 0)
|
||||
{
|
||||
printf("error claiming interface #%d:\n%s\n", MY_INTF, usb_strerror());
|
||||
usb_close(dev);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("success: claim_interface #%d\n", MY_INTF);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TEST_BULK_WRITE
|
||||
|
||||
#ifdef BENCHMARK_DEVICE
|
||||
ret = usb_control_msg(dev, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
|
||||
14, /* set/get test */
|
||||
2, /* test type */
|
||||
MY_INTF, /* interface id */
|
||||
tmp, 1, 1000);
|
||||
#endif
|
||||
|
||||
#ifdef TEST_ASYNC
|
||||
// Running an async write test
|
||||
ret = transfer_bulk_async(dev, EP_OUT, tmp, sizeof(tmp), 5000);
|
||||
#else
|
||||
// Running a sync write test
|
||||
ret = usb_bulk_write(dev, EP_OUT, tmp, sizeof(tmp), 5000);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("error writing:\n%s\n", usb_strerror());
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("success: bulk write %d bytes\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TEST_BULK_READ
|
||||
|
||||
#ifdef BENCHMARK_DEVICE
|
||||
ret = usb_control_msg(dev, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
|
||||
14, /* set/get test */
|
||||
1, /* test type */
|
||||
MY_INTF, /* interface id */
|
||||
tmp, 1, 1000);
|
||||
#endif
|
||||
|
||||
#ifdef TEST_ASYNC
|
||||
// Running an async read test
|
||||
ret = transfer_bulk_async(dev, EP_IN, tmp, sizeof(tmp), 5000);
|
||||
#else
|
||||
// Running a sync read test
|
||||
ret = usb_bulk_read(dev, EP_IN, tmp, sizeof(tmp), 5000);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("error reading:\n%s\n", usb_strerror());
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("success: bulk read %d bytes\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TEST_CLAIM_INTERFACE
|
||||
usb_release_interface(dev, 0);
|
||||
#endif
|
||||
|
||||
if (dev)
|
||||
{
|
||||
usb_close(dev);
|
||||
}
|
||||
printf("Done.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read/Write using async transfer functions.
|
||||
*
|
||||
* NOTE: This function waits for the transfer to complete essentially making
|
||||
* it a sync transfer function so it only serves as an example of how one might
|
||||
* implement async transfers into thier own code.
|
||||
*/
|
||||
static int transfer_bulk_async(usb_dev_handle *dev,
|
||||
int ep,
|
||||
char *bytes,
|
||||
int size,
|
||||
int timeout)
|
||||
{
|
||||
// Each async transfer requires it's own context. A transfer
|
||||
// context can be re-used. When no longer needed they must be
|
||||
// freed with usb_free_async().
|
||||
//
|
||||
void* async_context = NULL;
|
||||
int ret;
|
||||
|
||||
// Setup the async transfer. This only needs to be done once
|
||||
// for multiple submit/reaps. (more below)
|
||||
//
|
||||
ret = usb_bulk_setup_async(dev, &async_context, ep);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("error usb_bulk_setup_async:\n%s\n", usb_strerror());
|
||||
goto Done;
|
||||
}
|
||||
|
||||
// Submit this transfer. This function returns immediately and the
|
||||
// transfer is on it's way to the device.
|
||||
//
|
||||
ret = usb_submit_async(async_context, bytes, size);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("error usb_submit_async:\n%s\n", usb_strerror());
|
||||
usb_free_async(&async_context);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
// Wait for the transfer to complete. If it doesn't complete in the
|
||||
// specified time it is cancelled. see also usb_reap_async_nocancel().
|
||||
//
|
||||
ret = usb_reap_async(async_context, timeout);
|
||||
|
||||
// Free the context.
|
||||
usb_free_async(&async_context);
|
||||
|
||||
Done:
|
||||
return ret;
|
||||
}
|
||||
Vendored
+82
@@ -0,0 +1,82 @@
|
||||
; This examples demonstrates how libusb's drivers
|
||||
; can be installed automatically along with your application using an installer.
|
||||
;
|
||||
; Requirements: Inno Setup (http://www.jrsoftware.org/isdl.php)
|
||||
;
|
||||
; To use this script, do the following:
|
||||
; - generate a setup package using inf-wizard and save the generated files to
|
||||
; "this folder\driver"
|
||||
; - in this script replace <your_inf_file.inf> with the name of your .inf file
|
||||
; - customize other settings (strings)
|
||||
; - open this script with Inno Setup
|
||||
; - compile and run
|
||||
|
||||
[Setup]
|
||||
AppName = TestDrivers
|
||||
AppVerName = TestDrivers 0.1.10.2
|
||||
AppPublisher = TestDrivers
|
||||
AppPublisherURL = http://test.url.com/
|
||||
AppVersion = 0.1.10.1
|
||||
DefaultDirName = {pf}\TestApp
|
||||
DefaultGroupName = TestDrivers
|
||||
Compression = lzma
|
||||
SolidCompression = yes
|
||||
; Win2000 or higher
|
||||
MinVersion = 5,5
|
||||
|
||||
; This installation requires admin priveledges. This is needed to install
|
||||
; drivers on windows vista and later.
|
||||
PrivilegesRequired = admin
|
||||
|
||||
; "ArchitecturesInstallIn64BitMode=x64 ia64" requests that the install
|
||||
; be done in "64-bit mode" on x64 & Itanium, meaning it should use the
|
||||
; native 64-bit Program Files directory and the 64-bit view of the
|
||||
; registry. On all other architectures it will install in "32-bit mode".
|
||||
ArchitecturesInstallIn64BitMode=x64 ia64
|
||||
|
||||
; Inno pascal functions for determining the processor type.
|
||||
; you can use these to use (in an inno "check" parameter for example) to
|
||||
; customize the installation depending on the architecture.
|
||||
[Code]
|
||||
function IsX64: Boolean;
|
||||
begin
|
||||
Result := Is64BitInstallMode and (ProcessorArchitecture = paX64);
|
||||
end;
|
||||
|
||||
function IsI64: Boolean;
|
||||
begin
|
||||
Result := Is64BitInstallMode and (ProcessorArchitecture = paIA64);
|
||||
end;
|
||||
|
||||
function IsX86: Boolean;
|
||||
begin
|
||||
Result := not IsX64 and not IsI64;
|
||||
end;
|
||||
|
||||
function Is64: Boolean;
|
||||
begin
|
||||
Result := IsX64 or IsI64;
|
||||
end;
|
||||
|
||||
[Files]
|
||||
; copy your libusb-win32 setup package to the App folder
|
||||
Source: "driver\*"; Excludes: "*.exe"; Flags: recursesubdirs; DestDir: "{app}\driver"
|
||||
|
||||
; also copy the native (32bit or 64 bit) libusb0.dll to the
|
||||
; system folder so that rundll32.exe will find it
|
||||
Source: "driver\x86\libusb0_x86.dll"; DestName: "libusb0.dll"; DestDir: "{sys}"; Flags: uninsneveruninstall replacesameversion restartreplace promptifolder; Check: IsX86;
|
||||
Source: "driver\amd64\libusb0.dll"; DestDir: "{sys}"; Flags: uninsneveruninstall replacesameversion restartreplace promptifolder; Check: IsX64;
|
||||
Source: "driver\ia64\libusb0.dll"; DestDir: {sys}; Flags: uninsneveruninstall replacesameversion restartreplace promptifolder; Check: IsI64;
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\Uninstall TestDrivers"; Filename: "{uninstallexe}"
|
||||
|
||||
[Run]
|
||||
|
||||
; touch the HID .inf file to break its digital signature
|
||||
; this is only required if the device is a mouse or a keyboard !!
|
||||
;Filename: "rundll32"; Parameters: "libusb0.dll,usb_touch_inf_file_np_rundll {win}\inf\input.inf"
|
||||
|
||||
; invoke libusb's DLL to install the .inf file
|
||||
Filename: "rundll32"; Parameters: "libusb0.dll,usb_install_driver_np_rundll {app}\driver\<your_inf_file.inf>"; StatusMsg: "Installing driver (this may take a few seconds) ..."
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/* libusb-win32, Generic Windows USB Library
|
||||
* Copyright (c) 2002-2006 Stephan Meyer <ste_meyer@web.de>
|
||||
* Copyright (c) 2010 Travis Robinson <libusbdotnet@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define RC_FILE_TYPE VFT_APP
|
||||
#define RC_FILE_SUB_TYPE VFT2_UNKNOWN
|
||||
#define RC_PRODUCT_STR "libusb-win32 - Test Program"
|
||||
#define RC_FILE_NAME_STR "testbulk.exe"
|
||||
|
||||
#include "libusb-win32_version.rc"
|
||||
Reference in New Issue
Block a user