summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am10
-rw-r--r--examples/dpfp.c7
-rw-r--r--examples/dpfp_threaded.c9
-rw-r--r--examples/lsusb.c1
-rw-r--r--examples/lsusb.dsp4
-rw-r--r--examples/lsusb_2005.vcproj8
-rw-r--r--examples/lsusb_2008.vcproj8
-rw-r--r--examples/lsusb_sources15
-rw-r--r--examples/xusb.c27
-rw-r--r--examples/xusb.dsp4
-rw-r--r--examples/xusb_2005.vcproj8
-rw-r--r--examples/xusb_2008.vcproj8
-rw-r--r--examples/xusb_sources15
13 files changed, 62 insertions, 62 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
index fe6cae4..8ffc9c5 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,6 +1,12 @@
INCLUDES = -I$(top_srcdir)
-noinst_PROGRAMS = xusb lsusb
-#dpfp dpfp_threaded
+
+if POSIX_THREADS
+DPFP_SRC = dpfp dpfp_threaded
+else
+DPFP_SRC = dpfp
+endif
+
+noinst_PROGRAMS = xusb lsusb $(DPFP_SRC)
lsusb_SOURCES = lsusb.c
lsusb_LDADD = ../libusb/libusb-1.0.la -lusb-1.0
diff --git a/examples/dpfp.c b/examples/dpfp.c
index bd9702a..e218246 100644
--- a/examples/dpfp.c
+++ b/examples/dpfp.c
@@ -416,7 +416,9 @@ static void sighandler(int signum)
int main(void)
{
+#ifndef __MINGW32__
struct sigaction sigact;
+#endif
int r = 1;
r = libusb_init(NULL);
@@ -456,12 +458,17 @@ int main(void)
if (r < 0)
goto out_deinit;
+#ifndef __MINGW32__
sigact.sa_handler = sighandler;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigaction(SIGINT, &sigact, NULL);
sigaction(SIGTERM, &sigact, NULL);
sigaction(SIGQUIT, &sigact, NULL);
+#else
+ signal(SIGINT, sighandler);
+ signal(SIGTERM, sighandler);
+#endif
while (!do_exit) {
r = libusb_handle_events(NULL);
diff --git a/examples/dpfp_threaded.c b/examples/dpfp_threaded.c
index 59540e3..6ae59ef 100644
--- a/examples/dpfp_threaded.c
+++ b/examples/dpfp_threaded.c
@@ -92,6 +92,7 @@ static void *poll_thread_main(void *arg)
printf("poll thread shutting down\n");
pthread_exit(NULL);
+ return NULL;
}
static int find_dpfp_device(void)
@@ -443,7 +444,9 @@ static void sighandler(int signum)
int main(void)
{
+#ifndef __MINGW32__
struct sigaction sigact;
+#endif
int r = 1;
r = libusb_init(NULL);
@@ -474,13 +477,17 @@ int main(void)
goto out_deinit;
/* async from here onwards */
-
+#ifndef __MINGW32__
sigact.sa_handler = sighandler;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigaction(SIGINT, &sigact, NULL);
sigaction(SIGTERM, &sigact, NULL);
sigaction(SIGQUIT, &sigact, NULL);
+#else
+ signal(SIGINT, sighandler);
+ signal(SIGTERM, sighandler);
+#endif
r = pthread_create(&poll_thread, NULL, poll_thread_main, NULL);
if (r)
diff --git a/examples/lsusb.c b/examples/lsusb.c
index f08b7cc..eb3855a 100644
--- a/examples/lsusb.c
+++ b/examples/lsusb.c
@@ -18,7 +18,6 @@
*/
#include <stdio.h>
-#include <sys/types.h>
#include <libusb/libusb.h>
#include <libusb/os/driver_install.h>
diff --git a/examples/lsusb.dsp b/examples/lsusb.dsp
index 96841be..b598ffa 100644
--- a/examples/lsusb.dsp
+++ b/examples/lsusb.dsp
@@ -50,7 +50,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 pthreadVC2.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "lsusb - Win32 Debug"
@@ -74,7 +74,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo /n "../Win32/Debug/dll/core.sbr" "../Win32/Debug/dll/descriptor.sbr" "../Win32/Debug/dll/io.sbr" "../Win32/Debug/dll/sync.sbr" "../Win32/Debug/dll/windows_compat.sbr" "../Win32/Debug/dll/windows_usb.sbr"
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 pthreadVC2d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /debug /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /debug /machine:I386
# SUBTRACT LINK32 /pdb:none
!ENDIF
diff --git a/examples/lsusb_2005.vcproj b/examples/lsusb_2005.vcproj
index 0b46e40..453b2a2 100644
--- a/examples/lsusb_2005.vcproj
+++ b/examples/lsusb_2005.vcproj
@@ -64,7 +64,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2.lib ole32.lib advapi32.lib"
+ AdditionalDependencies="setupapi.lib ole32.lib advapi32.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
@@ -140,7 +140,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2.lib ole32.lib advapi32.lib"
+ AdditionalDependencies="setupapi.lib ole32.lib advapi32.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
@@ -221,7 +221,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2_x64.lib"
+ AdditionalDependencies="setupapi.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
@@ -298,7 +298,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2_x64.lib"
+ AdditionalDependencies="setupapi.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
diff --git a/examples/lsusb_2008.vcproj b/examples/lsusb_2008.vcproj
index fa0991f..168cf3f 100644
--- a/examples/lsusb_2008.vcproj
+++ b/examples/lsusb_2008.vcproj
@@ -65,7 +65,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2_x64.lib difxapi.lib driver_resources.res"
+ AdditionalDependencies="setupapi.lib difxapi.lib driver_resources.res"
LinkIncremental="2"
AdditionalLibraryDirectories="..\msvc;$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib\driver-resources"
GenerateDebugInformation="true"
@@ -142,7 +142,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2_x64.lib difxapi.lib driver_resources.res"
+ AdditionalDependencies="setupapi.lib difxapi.lib driver_resources.res"
LinkIncremental="2"
AdditionalLibraryDirectories="..\msvc;$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib\driver-resources"
GenerateDebugInformation="true"
@@ -219,7 +219,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2_x64.lib difxapi.lib driver_resources.res"
+ AdditionalDependencies="setupapi.lib difxapi.lib driver_resources.res"
LinkIncremental="1"
AdditionalLibraryDirectories="..\msvc;$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib\driver-resources"
GenerateDebugInformation="true"
@@ -299,7 +299,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2_x64.lib difxapi.lib driver_resources.res"
+ AdditionalDependencies="setupapi.lib difxapi.lib driver_resources.res"
LinkIncremental="1"
AdditionalLibraryDirectories="..\msvc;$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib\driver-resources"
GenerateDebugInformation="true"
diff --git a/examples/lsusb_sources b/examples/lsusb_sources
index fcb4c4d..82ea935 100644
--- a/examples/lsusb_sources
+++ b/examples/lsusb_sources
@@ -11,26 +11,13 @@ MSC_WARNING_LEVEL=/W3
-!IF "$(_BUILDARCH)"=="AMD64"
-
-PTHREAD_LIB=pthreadVC2_x64.lib
-
-!ELSE
-
-PTHREAD_LIB=pthreadVC2.lib
-
-!ENDIF
-
-
-
USE_MSVCRT=1
UMTYPE=console
INCLUDES=..\..\msvc;..\..;$(DDK_INC_PATH)
-UMLIBS=..\..\msvc\$(PTHREAD_LIB) \
- ..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
+UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
SOURCES=..\lsusb.c
diff --git a/examples/xusb.c b/examples/xusb.c
index 15dc126..5000059 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -1,6 +1,8 @@
/*
- * xusb: libusb-winusb specific test program, (c) 2009 Pete Batard
- * based on lsusb, copyright (C) 2007 Daniel Drake <dsd@gentoo.org>
+ * xusb: libusb-winusb specific test program
+ * Copyright (c) 2009-2010 Pete Batard <pbatard@gmail.com>
+ * Based on lsusb, copyright (c) 2007 Daniel Drake <dsd@gentoo.org>
+ * With contributions to Mass Storage test by Alan Stern.
*
* This test program tries to access an USB device through WinUSB.
* To access your device, modify this source and add your VID/PID.
@@ -20,13 +22,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifdef _MSC_VER
-#include <config_msvc.h>
-#else
#include <config.h>
-#endif
#include <stdio.h>
-#include <sys/types.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
@@ -35,7 +32,6 @@
#include <libusb/libusb.h>
#ifdef OS_WINDOWS
-#include <windows.h>
#define msleep(msecs) Sleep(msecs)
#else
#include <unistd.h>
@@ -497,6 +493,17 @@ int test_hid(libusb_device_handle *handle, uint8_t endpoint_in)
return -1;
}
+ printf("\nReading Feature Report...\n");
+ r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE,
+ HID_GET_REPORT, (HID_REPORT_TYPE_FEATURE<<8)|0, 0, input_report, (uint16_t)size, 5000);
+ if (r >= 0) {
+ display_buffer_hex(input_report, size);
+ } else if (r == LIBUSB_ERROR_NOT_FOUND) {
+ printf(" No Feature Report available for this device\n");
+ } else {
+ printf(" Error: %s\n", libusb_strerror(r));
+ }
+
printf("\nReading Input Report...\n");
r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE,
HID_GET_REPORT, (HID_REPORT_TYPE_INPUT<<8)|0x00, 0, input_report, (uint16_t)size, 5000);
@@ -508,7 +515,7 @@ int test_hid(libusb_device_handle *handle, uint8_t endpoint_in)
printf(" Timeout! Please make sure you act on the device within the 5 seconds allocated...\n");
break;
default:
- printf(" Error: %d\n", r);
+ printf(" Error: %s\n", libusb_strerror(r));
break;
}
}
@@ -614,10 +621,10 @@ int test_device(uint16_t vid, uint16_t pid)
}
#endif
+ printf("\nReading string descriptors:\n");
r = libusb_get_string_descriptor(handle, 0, 0, string, 128);
if (r > 0) {
nb_strings = string[0];
- printf("\nReading string descriptors:\n");
for (i=1; i<nb_strings; i++) {
if (libusb_get_string_descriptor_ascii(handle, (uint8_t)i, string, 128) >= 0) {
printf(" String (%d/%d): \"%s\"\n", i, nb_strings-1, string);
diff --git a/examples/xusb.dsp b/examples/xusb.dsp
index 15081c6..b47b8c0 100644
--- a/examples/xusb.dsp
+++ b/examples/xusb.dsp
@@ -50,7 +50,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 pthreadVC2.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "xusb - Win32 Debug"
@@ -74,7 +74,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo /n "../Win32/Debug/dll/core.sbr" "../Win32/Debug/dll/descriptor.sbr" "../Win32/Debug/dll/io.sbr" "../Win32/Debug/dll/sync.sbr" "../Win32/Debug/dll/windows_compat.sbr" "../Win32/Debug/dll/windows_usb.sbr"
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 pthreadVC2d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /debug /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /debug /machine:I386
!ENDIF
diff --git a/examples/xusb_2005.vcproj b/examples/xusb_2005.vcproj
index 0554e05..19e771a 100644
--- a/examples/xusb_2005.vcproj
+++ b/examples/xusb_2005.vcproj
@@ -64,7 +64,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2.lib ole32.lib advapi32.lib"
+ AdditionalDependencies="setupapi.lib ole32.lib advapi32.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
@@ -140,7 +140,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2.lib ole32.lib advapi32.lib"
+ AdditionalDependencies="setupapi.lib ole32.lib advapi32.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
@@ -221,7 +221,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2_x64.lib"
+ AdditionalDependencies="setupapi.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
@@ -298,7 +298,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2_x64.lib"
+ AdditionalDependencies="setupapi.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
diff --git a/examples/xusb_2008.vcproj b/examples/xusb_2008.vcproj
index 4cd9b13..224249a 100644
--- a/examples/xusb_2008.vcproj
+++ b/examples/xusb_2008.vcproj
@@ -65,7 +65,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2.lib"
+ AdditionalDependencies="setupapi.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
@@ -142,7 +142,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2_x64.lib"
+ AdditionalDependencies="setupapi.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
@@ -219,7 +219,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2.lib"
+ AdditionalDependencies="setupapi.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
@@ -299,7 +299,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="setupapi.lib pthreadVC2_x64.lib"
+ AdditionalDependencies="setupapi.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="..\msvc"
GenerateDebugInformation="true"
diff --git a/examples/xusb_sources b/examples/xusb_sources
index 609f369..f69b9e0 100644
--- a/examples/xusb_sources
+++ b/examples/xusb_sources
@@ -11,26 +11,13 @@ MSC_WARNING_LEVEL=/W3
-!IF "$(_BUILDARCH)"=="AMD64"
-
-PTHREAD_LIB=pthreadVC2_x64.lib
-
-!ELSE
-
-PTHREAD_LIB=pthreadVC2.lib
-
-!ENDIF
-
-
-
USE_MSVCRT=1
UMTYPE=console
INCLUDES=..\..\msvc;..\..;$(DDK_INC_PATH)
-UMLIBS=..\..\msvc\$(PTHREAD_LIB) \
- ..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
+UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
SOURCES=..\xusb.c