libusb 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -2
- data/Gemfile +0 -8
- data/History.md +5 -0
- data/README.md +6 -6
- data/Rakefile +9 -9
- data/ext/extconf.rb +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/AUTHORS +10 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/COPYING +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/ChangeLog +17 -9
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/INSTALL +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Makefile.am +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Makefile.in +153 -178
- data/ext/libusb-1.0.18/NEWS +2 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/PORTING +13 -13
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/README +9 -11
- data/ext/libusb-1.0.18/TODO +2 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Xcode/common.xcconfig +3 -3
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Xcode/config.h +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Xcode/debug.xcconfig +2 -2
- data/ext/{libusbx-1.0.17/Xcode/libusbx.xcconfig → libusb-1.0.18/Xcode/libusb.xcconfig} +2 -2
- data/ext/libusb-1.0.18/Xcode/libusb.xcodeproj/project.pbxproj +1 -0
- data/ext/{libusbx-1.0.17/Xcode/libusbx_debug.xcconfig → libusb-1.0.18/Xcode/libusb_debug.xcconfig} +3 -3
- data/ext/{libusbx-1.0.17/Xcode/libusbx_release.xcconfig → libusb-1.0.18/Xcode/libusb_release.xcconfig} +3 -3
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/Xcode/release.xcconfig +2 -2
- data/ext/{libusbx-1.0.17/m4/libtool.m4 → libusb-1.0.18/aclocal.m4} +1731 -27
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/README +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/config.h +1 -10
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/jni/Android.mk +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/jni/Application.mk +6 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/jni/examples.mk +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/jni/libusb.mk +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/android/jni/tests.mk +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/compile +3 -7
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/config.guess +19 -24
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/config.h.in +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/config.sub +30 -47
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/configure +118 -172
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/configure.ac +24 -2
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/depcomp +186 -268
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/doc/Makefile.am +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/doc/Makefile.in +36 -73
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/doc/doxygen.cfg.in +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/Makefile.am +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/Makefile.in +68 -132
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/dpfp.c +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/dpfp_threaded.c +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/ezusb.c +57 -26
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/ezusb.h +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/fxload.c +3 -3
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/getopt/getopt.c +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/getopt/getopt.h +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/getopt/getopt1.c +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/hotplugtest.c +9 -2
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/listdevs.c +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/sam3u_benchmark.c +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/examples/xusb.c +20 -4
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/install-sh +7 -7
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb-1.0.pc.in +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/Makefile.am +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/Makefile.in +94 -134
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/core.c +95 -74
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/descriptor.c +2 -2
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/hotplug.c +3 -3
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/hotplug.h +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/io.c +127 -116
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/libusb-1.0.def +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/libusb-1.0.rc +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/libusb.h +42 -39
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/libusbi.h +20 -11
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/darwin_usb.c +20 -16
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/darwin_usb.h +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/linux_netlink.c +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/linux_udev.c +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/linux_usbfs.c +15 -12
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/linux_usbfs.h +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/netbsd_usb.c +2 -4
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/openbsd_usb.c +5 -2
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/poll_posix.c +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/poll_posix.h +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/poll_windows.c +2 -2
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/poll_windows.h +0 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/threads_posix.c +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/threads_posix.h +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/threads_windows.c +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/threads_windows.h +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/wince_usb.c +1 -2
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/wince_usb.h +2 -2
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/windows_common.h +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/windows_usb.c +53 -33
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/os/windows_usb.h +6 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/strerror.c +2 -2
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/sync.c +6 -6
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/libusb/version.h +1 -1
- data/ext/libusb-1.0.18/libusb/version_nano.h +1 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/ltmain.sh +3 -3
- data/ext/libusb-1.0.18/missing +331 -0
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/tests/Makefile.am +1 -1
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/tests/Makefile.in +69 -127
- data/ext/{libusbx-1.0.17/tests/libusbx_testlib.h → libusb-1.0.18/tests/libusb_testlib.h} +15 -15
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/tests/stress.c +16 -16
- data/ext/{libusbx-1.0.17 → libusb-1.0.18}/tests/testlib.c +21 -20
- data/lib/libusb/version_gem.rb +1 -1
- data/libusb.gemspec +1 -6
- metadata +117 -135
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ext/libusbx-1.0.17/NEWS +0 -2
- data/ext/libusbx-1.0.17/TODO +0 -2
- data/ext/libusbx-1.0.17/Xcode/libusbx.xcodeproj/project.pbxproj +0 -864
- data/ext/libusbx-1.0.17/aclocal.m4 +0 -1112
- data/ext/libusbx-1.0.17/libusb/version_nano.h +0 -1
- data/ext/libusbx-1.0.17/m4/ltoptions.m4 +0 -384
- data/ext/libusbx-1.0.17/m4/ltsugar.m4 +0 -123
- data/ext/libusbx-1.0.17/m4/ltversion.m4 +0 -23
- data/ext/libusbx-1.0.17/m4/lt~obsolete.m4 +0 -98
- data/ext/libusbx-1.0.17/missing +0 -215
- metadata.gz.sig +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
*
|
2
|
+
* libusb example program to manipulate U.are.U 4000B fingerprint scanner.
|
3
3
|
* Copyright © 2007 Daniel Drake <dsd@gentoo.org>
|
4
4
|
*
|
5
5
|
* Basic image capture program only, does not consider the powerup quirks or
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
*
|
2
|
+
* libusb example program to manipulate U.are.U 4000B fingerprint scanner.
|
3
3
|
* Copyright © 2007 Daniel Drake <dsd@gentoo.org>
|
4
4
|
*
|
5
5
|
* Basic image capture program only, does not consider the powerup quirks or
|
@@ -181,7 +181,7 @@ static bool ezusb_cpucs(libusb_device_handle *device, uint32_t addr, bool doRun)
|
|
181
181
|
RW_INTERNAL, addr & 0xFFFF, addr >> 16,
|
182
182
|
&data, 1, 1000);
|
183
183
|
if ((status != 1) &&
|
184
|
-
/* We may get an I/O error from
|
184
|
+
/* We may get an I/O error from libusb as the device disappears */
|
185
185
|
((!doRun) || (status != LIBUSB_ERROR_IO)))
|
186
186
|
{
|
187
187
|
const char *mesg = "can't modify CPUCS";
|
@@ -208,7 +208,7 @@ static bool ezusb_fx3_jump(libusb_device_handle *device, uint32_t addr)
|
|
208
208
|
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
|
209
209
|
RW_INTERNAL, addr & 0xFFFF, addr >> 16,
|
210
210
|
NULL, 0, 1000);
|
211
|
-
/* We may get an I/O error from
|
211
|
+
/* We may get an I/O error from libusb as the device disappears */
|
212
212
|
if ((status != 0) && (status != LIBUSB_ERROR_IO))
|
213
213
|
{
|
214
214
|
const char *mesg = "failed to send jump command";
|
@@ -436,7 +436,11 @@ static int parse_iic(FILE *image, void *context,
|
|
436
436
|
uint8_t block_header[4];
|
437
437
|
int rc;
|
438
438
|
bool external = false;
|
439
|
-
long file_size, initial_pos
|
439
|
+
long file_size, initial_pos;
|
440
|
+
|
441
|
+
initial_pos = ftell(image);
|
442
|
+
if (initial_pos < 0)
|
443
|
+
return -1;
|
440
444
|
|
441
445
|
fseek(image, 0L, SEEK_END);
|
442
446
|
file_size = ftell(image);
|
@@ -453,7 +457,7 @@ static int parse_iic(FILE *image, void *context,
|
|
453
457
|
data_addr = (block_header[2] << 8) + block_header[3];
|
454
458
|
if (data_len > sizeof(data)) {
|
455
459
|
/* If this is ever reported as an error, switch to using malloc/realloc */
|
456
|
-
logerror("IIC data block too small - please report this error to
|
460
|
+
logerror("IIC data block too small - please report this error to libusb.info\n");
|
457
461
|
return -1;
|
458
462
|
}
|
459
463
|
read_len = fread(data, 1, data_len, image);
|
@@ -563,6 +567,7 @@ static int fx3_load_ram(libusb_device_handle *device, const char *path)
|
|
563
567
|
uint32_t* dImageBuf;
|
564
568
|
unsigned char *bBuf, hBuf[4], blBuf[4], rBuf[4096];
|
565
569
|
FILE *image;
|
570
|
+
int ret = 0;
|
566
571
|
|
567
572
|
image = fopen(path, "rb");
|
568
573
|
if (image == NULL) {
|
@@ -574,13 +579,15 @@ static int fx3_load_ram(libusb_device_handle *device, const char *path)
|
|
574
579
|
// Read header
|
575
580
|
if (fread(hBuf, sizeof(char), sizeof(hBuf), image) != sizeof(hBuf)) {
|
576
581
|
logerror("could not read image header");
|
577
|
-
|
582
|
+
ret = -3;
|
583
|
+
goto exit;
|
578
584
|
}
|
579
585
|
|
580
586
|
// check "CY" signature byte and format
|
581
587
|
if ((hBuf[0] != 'C') || (hBuf[1] != 'Y')) {
|
582
588
|
logerror("image doesn't have a CYpress signature\n");
|
583
|
-
|
589
|
+
ret = -3;
|
590
|
+
goto exit;
|
584
591
|
}
|
585
592
|
|
586
593
|
// Check bImageType
|
@@ -591,20 +598,24 @@ static int fx3_load_ram(libusb_device_handle *device, const char *path)
|
|
591
598
|
break;
|
592
599
|
case 0xB1:
|
593
600
|
logerror("security binary image is not currently supported\n");
|
594
|
-
|
601
|
+
ret = -3;
|
602
|
+
goto exit;
|
595
603
|
case 0xB2:
|
596
604
|
logerror("VID:PID image is not currently supported\n");
|
597
|
-
|
605
|
+
ret = -3;
|
606
|
+
goto exit;
|
598
607
|
default:
|
599
608
|
logerror("invalid image type 0x%02X\n", hBuf[3]);
|
600
|
-
|
609
|
+
ret = -3;
|
610
|
+
goto exit;
|
601
611
|
}
|
602
612
|
|
603
613
|
// Read the bootloader version
|
604
614
|
if (verbose) {
|
605
615
|
if ((ezusb_read(device, "read bootloader version", RW_INTERNAL, 0xFFFF0020, blBuf, 4) < 0)) {
|
606
616
|
logerror("Could not read bootloader version\n");
|
607
|
-
|
617
|
+
ret = -8;
|
618
|
+
goto exit;
|
608
619
|
}
|
609
620
|
logerror("FX3 bootloader version: 0x%02X%02X%02X%02X\n", blBuf[3], blBuf[2], blBuf[1], blBuf[0]);
|
610
621
|
}
|
@@ -616,7 +627,8 @@ static int fx3_load_ram(libusb_device_handle *device, const char *path)
|
|
616
627
|
if ((fread(&dLength, sizeof(uint32_t), 1, image) != 1) || // read dLength
|
617
628
|
(fread(&dAddress, sizeof(uint32_t), 1, image) != 1)) { // read dAddress
|
618
629
|
logerror("could not read image");
|
619
|
-
|
630
|
+
ret = -3;
|
631
|
+
goto exit;
|
620
632
|
}
|
621
633
|
if (dLength == 0)
|
622
634
|
break; // done
|
@@ -624,14 +636,16 @@ static int fx3_load_ram(libusb_device_handle *device, const char *path)
|
|
624
636
|
dImageBuf = calloc(dLength, sizeof(uint32_t));
|
625
637
|
if (dImageBuf == NULL) {
|
626
638
|
logerror("could not allocate buffer for image chunk\n");
|
627
|
-
|
639
|
+
ret = -4;
|
640
|
+
goto exit;
|
628
641
|
}
|
629
642
|
|
630
643
|
// read sections
|
631
644
|
if (fread(dImageBuf, sizeof(uint32_t), dLength, image) != dLength) {
|
632
645
|
logerror("could not read image");
|
633
646
|
free(dImageBuf);
|
634
|
-
|
647
|
+
ret = -3;
|
648
|
+
goto exit;
|
635
649
|
}
|
636
650
|
for (i = 0; i < dLength; i++)
|
637
651
|
dCheckSum += dImageBuf[i];
|
@@ -646,14 +660,16 @@ static int fx3_load_ram(libusb_device_handle *device, const char *path)
|
|
646
660
|
(ezusb_read(device, "read firmware", RW_INTERNAL, dAddress, rBuf, dLen) < 0)) {
|
647
661
|
logerror("R/W error\n");
|
648
662
|
free(dImageBuf);
|
649
|
-
|
663
|
+
ret = -5;
|
664
|
+
goto exit;
|
650
665
|
}
|
651
666
|
// Verify data: rBuf with bBuf
|
652
667
|
for (i = 0; i < dLen; i++) {
|
653
668
|
if (rBuf[i] != bBuf[i]) {
|
654
669
|
logerror("verify error");
|
655
670
|
free(dImageBuf);
|
656
|
-
|
671
|
+
ret = -6;
|
672
|
+
goto exit;
|
657
673
|
}
|
658
674
|
}
|
659
675
|
|
@@ -668,19 +684,22 @@ static int fx3_load_ram(libusb_device_handle *device, const char *path)
|
|
668
684
|
if ((fread(&dExpectedCheckSum, sizeof(uint32_t), 1, image) != 1) ||
|
669
685
|
(dCheckSum != dExpectedCheckSum)) {
|
670
686
|
logerror("checksum error\n");
|
671
|
-
|
687
|
+
ret = -7;
|
688
|
+
goto exit;
|
672
689
|
}
|
673
690
|
|
674
691
|
// transfer execution to Program Entry
|
675
692
|
if (!ezusb_fx3_jump(device, dAddress)) {
|
676
|
-
|
693
|
+
ret = -6;
|
677
694
|
}
|
678
695
|
|
679
|
-
|
696
|
+
exit:
|
697
|
+
fclose(image);
|
698
|
+
return ret;
|
680
699
|
}
|
681
700
|
|
682
701
|
/*
|
683
|
-
* Load a firmware file into target RAM. device is the open
|
702
|
+
* Load a firmware file into target RAM. device is the open libusb
|
684
703
|
* device, and the path is the name of the source file. Open the file,
|
685
704
|
* parse the bytes, and write them in one or two phases.
|
686
705
|
*
|
@@ -701,6 +720,7 @@ int ezusb_load_ram(libusb_device_handle *device, const char *path, int fx_type,
|
|
701
720
|
struct ram_poke_context ctx;
|
702
721
|
int status;
|
703
722
|
uint8_t iic_header[8] = { 0 };
|
723
|
+
int ret = 0;
|
704
724
|
|
705
725
|
if (fx_type == FX_TYPE_FX3)
|
706
726
|
return fx3_load_ram(device, path);
|
@@ -718,7 +738,8 @@ int ezusb_load_ram(libusb_device_handle *device, const char *path, int fx_type,
|
|
718
738
|
|| ((fx_type == FX_TYPE_AN21) && (iic_header[0] != 0xB2))
|
719
739
|
|| ((fx_type == FX_TYPE_FX1) && (iic_header[0] != 0xB6)) ) {
|
720
740
|
logerror("IIC image does not contain executable code - cannot load to RAM.\n");
|
721
|
-
|
741
|
+
ret = -1;
|
742
|
+
goto exit;
|
722
743
|
}
|
723
744
|
}
|
724
745
|
|
@@ -744,7 +765,10 @@ int ezusb_load_ram(libusb_device_handle *device, const char *path, int fx_type,
|
|
744
765
|
|
745
766
|
/* if required, halt the CPU while we overwrite its code/data */
|
746
767
|
if (cpucs_addr && !ezusb_cpucs(device, cpucs_addr, false))
|
747
|
-
|
768
|
+
{
|
769
|
+
ret = -1;
|
770
|
+
goto exit;
|
771
|
+
}
|
748
772
|
|
749
773
|
/* 2nd stage, first part? loader was already uploaded */
|
750
774
|
} else {
|
@@ -761,7 +785,8 @@ int ezusb_load_ram(libusb_device_handle *device, const char *path, int fx_type,
|
|
761
785
|
status = parse[img_type](image, &ctx, is_external, ram_poke);
|
762
786
|
if (status < 0) {
|
763
787
|
logerror("unable to upload %s\n", path);
|
764
|
-
|
788
|
+
ret = status;
|
789
|
+
goto exit;
|
765
790
|
}
|
766
791
|
|
767
792
|
/* second part of 2nd stage: rescan */
|
@@ -771,7 +796,10 @@ int ezusb_load_ram(libusb_device_handle *device, const char *path, int fx_type,
|
|
771
796
|
|
772
797
|
/* if needed, halt the CPU while we overwrite the 1st stage loader */
|
773
798
|
if (cpucs_addr && !ezusb_cpucs(device, cpucs_addr, false))
|
774
|
-
|
799
|
+
{
|
800
|
+
ret = -1;
|
801
|
+
goto exit;
|
802
|
+
}
|
775
803
|
|
776
804
|
/* at least write the interrupt vectors (at 0x0000) for reset! */
|
777
805
|
rewind(image);
|
@@ -780,7 +808,8 @@ int ezusb_load_ram(libusb_device_handle *device, const char *path, int fx_type,
|
|
780
808
|
status = parse_ihex(image, &ctx, is_external, ram_poke);
|
781
809
|
if (status < 0) {
|
782
810
|
logerror("unable to completely upload %s\n", path);
|
783
|
-
|
811
|
+
ret = status;
|
812
|
+
goto exit;
|
784
813
|
}
|
785
814
|
}
|
786
815
|
|
@@ -790,7 +819,9 @@ int ezusb_load_ram(libusb_device_handle *device, const char *path, int fx_type,
|
|
790
819
|
|
791
820
|
/* if required, reset the CPU so it runs what we just uploaded */
|
792
821
|
if (cpucs_addr && !ezusb_cpucs(device, cpucs_addr, true))
|
793
|
-
|
822
|
+
ret = -1;
|
794
823
|
|
795
|
-
|
824
|
+
exit:
|
825
|
+
fclose(image);
|
826
|
+
return ret;
|
796
827
|
}
|
File without changes
|
@@ -40,7 +40,7 @@ static bool dosyslog = false;
|
|
40
40
|
#endif
|
41
41
|
|
42
42
|
#ifndef FXLOAD_VERSION
|
43
|
-
#define FXLOAD_VERSION (__DATE__ " (
|
43
|
+
#define FXLOAD_VERSION (__DATE__ " (libusb)")
|
44
44
|
#endif
|
45
45
|
|
46
46
|
#ifndef ARRAYSIZE
|
@@ -69,7 +69,7 @@ static int print_usage(int error_code) {
|
|
69
69
|
fprintf(stderr, " -i <path> -- Firmware to upload\n");
|
70
70
|
fprintf(stderr, " -t <type> -- Target type: an21, fx, fx2, fx2lp, fx3\n");
|
71
71
|
fprintf(stderr, " -d <vid:pid> -- Target device, as an USB VID:PID\n");
|
72
|
-
fprintf(stderr, " -p <bus,addr> -- Target device, as a
|
72
|
+
fprintf(stderr, " -p <bus,addr> -- Target device, as a libusb bus number and device address path\n");
|
73
73
|
fprintf(stderr, " -v -- Increase verbosity\n");
|
74
74
|
fprintf(stderr, " -q -- Decrease verbosity (silent mode)\n");
|
75
75
|
fprintf(stderr, " -V -- Print program version\n");
|
@@ -165,7 +165,7 @@ int main(int argc, char*argv[])
|
|
165
165
|
}
|
166
166
|
}
|
167
167
|
|
168
|
-
/* open the device using
|
168
|
+
/* open the device using libusb */
|
169
169
|
status = libusb_init(NULL);
|
170
170
|
if (status < 0) {
|
171
171
|
logerror("libusb_init() failed: %s\n", libusb_error_name(status));
|
File without changes
|
File without changes
|
File without changes
|
@@ -65,7 +65,12 @@ int main(int argc, char *argv[])
|
|
65
65
|
product_id = (argc > 2) ? strtol (argv[2], NULL, 0) : 0x5005;
|
66
66
|
class_id = (argc > 3) ? strtol (argv[3], NULL, 0) : LIBUSB_HOTPLUG_MATCH_ANY;
|
67
67
|
|
68
|
-
libusb_init (NULL);
|
68
|
+
rc = libusb_init (NULL);
|
69
|
+
if (rc < 0)
|
70
|
+
{
|
71
|
+
printf("failed to initialise libusb: %s\n", libusb_error_name(rc));
|
72
|
+
return EXIT_FAILURE;
|
73
|
+
}
|
69
74
|
|
70
75
|
if (!libusb_has_capability (LIBUSB_CAP_HAS_HOTPLUG)) {
|
71
76
|
printf ("Hotplug capabilites are not supported on this platform\n");
|
@@ -90,7 +95,9 @@ int main(int argc, char *argv[])
|
|
90
95
|
}
|
91
96
|
|
92
97
|
while (done < 2) {
|
93
|
-
libusb_handle_events (NULL);
|
98
|
+
rc = libusb_handle_events (NULL);
|
99
|
+
if (rc < 0)
|
100
|
+
printf("libusb_handle_events() failed: %s\n", libusb_error_name(rc));
|
94
101
|
}
|
95
102
|
|
96
103
|
libusb_exit (NULL);
|
File without changes
|
@@ -43,13 +43,14 @@
|
|
43
43
|
#define false (!true)
|
44
44
|
#endif
|
45
45
|
|
46
|
-
// Future versions of
|
46
|
+
// Future versions of libusb will use usb_interface instead of interface
|
47
47
|
// in libusb_config_descriptor => catter for that
|
48
48
|
#define usb_interface interface
|
49
49
|
|
50
50
|
// Global variables
|
51
51
|
static bool binary_dump = false;
|
52
52
|
static bool extra_info = false;
|
53
|
+
static bool force_device_request = false; // For WCID descriptor queries
|
53
54
|
static const char* binary_name = NULL;
|
54
55
|
|
55
56
|
static int perr(char const *format, ...)
|
@@ -415,6 +416,7 @@ static void get_sense(libusb_device_handle *handle, uint8_t endpoint_in, uint8_t
|
|
415
416
|
uint8_t sense[18];
|
416
417
|
uint32_t expected_tag;
|
417
418
|
int size;
|
419
|
+
int rc;
|
418
420
|
|
419
421
|
// Request Sense
|
420
422
|
printf("Request Sense:\n");
|
@@ -424,7 +426,12 @@ static void get_sense(libusb_device_handle *handle, uint8_t endpoint_in, uint8_t
|
|
424
426
|
cdb[4] = REQUEST_SENSE_LENGTH;
|
425
427
|
|
426
428
|
send_mass_storage_command(handle, endpoint_out, 0, cdb, LIBUSB_ENDPOINT_IN, REQUEST_SENSE_LENGTH, &expected_tag);
|
427
|
-
libusb_bulk_transfer(handle, endpoint_in, (unsigned char*)&sense, REQUEST_SENSE_LENGTH, &size, 1000);
|
429
|
+
rc = libusb_bulk_transfer(handle, endpoint_in, (unsigned char*)&sense, REQUEST_SENSE_LENGTH, &size, 1000);
|
430
|
+
if (rc < 0)
|
431
|
+
{
|
432
|
+
printf("libusb_bulk_transfer failed: %s\n", libusb_error_name(rc));
|
433
|
+
return;
|
434
|
+
}
|
428
435
|
printf(" received %d bytes\n", size);
|
429
436
|
|
430
437
|
if ((sense[0] != 0x70) && (sense[0] != 0x71)) {
|
@@ -707,6 +714,11 @@ static void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uin
|
|
707
714
|
};
|
708
715
|
|
709
716
|
if (iface_number < 0) return;
|
717
|
+
// WinUSB has a limitation that forces wIndex to the interface number when issuing
|
718
|
+
// an Interface Request. To work around that, we can force a Device Request for
|
719
|
+
// the Extended Properties, assuming the device answers both equally.
|
720
|
+
if (force_device_request)
|
721
|
+
os_fd[1].recipient = LIBUSB_RECIPIENT_DEVICE;
|
710
722
|
|
711
723
|
for (i=0; i<2; i++) {
|
712
724
|
printf("\nReading %s OS Feature Descriptor (wIndex = 0x%04d):\n", os_fd[i].desc, os_fd[i].index);
|
@@ -985,6 +997,9 @@ int main(int argc, char** argv)
|
|
985
997
|
case 'i':
|
986
998
|
extra_info = true;
|
987
999
|
break;
|
1000
|
+
case 'w':
|
1001
|
+
force_device_request = true;
|
1002
|
+
break;
|
988
1003
|
case 'b':
|
989
1004
|
if ((j+1 >= argc) || (argv[j+1][0] == '-') || (argv[j+1][0] == '/')) {
|
990
1005
|
printf(" Option -b requires a file name\n");
|
@@ -1057,7 +1072,7 @@ int main(int argc, char** argv)
|
|
1057
1072
|
}
|
1058
1073
|
|
1059
1074
|
if ((show_help) || (argc == 1) || (argc > 7)) {
|
1060
|
-
printf("usage: %s [-h] [-d] [-i] [-k] [-b file] [-l lang] [-j] [-x] [-s] [-p] [vid:pid]\n", argv[0]);
|
1075
|
+
printf("usage: %s [-h] [-d] [-i] [-k] [-b file] [-l lang] [-j] [-x] [-s] [-p] [-w] [vid:pid]\n", argv[0]);
|
1061
1076
|
printf(" -h : display usage\n");
|
1062
1077
|
printf(" -d : enable debug output\n");
|
1063
1078
|
printf(" -i : print topology and speed info\n");
|
@@ -1068,12 +1083,13 @@ int main(int argc, char** argv)
|
|
1068
1083
|
printf(" -s : test Microsoft Sidewinder Precision Pro (HID)\n");
|
1069
1084
|
printf(" -x : test Microsoft XBox Controller Type S\n");
|
1070
1085
|
printf(" -l lang : language to report errors in (ISO 639-1)\n");
|
1086
|
+
printf(" -w : force the use of device requests when querying WCID descriptors\n");
|
1071
1087
|
printf("If only the vid:pid is provided, xusb attempts to run the most appropriate test\n");
|
1072
1088
|
return 0;
|
1073
1089
|
}
|
1074
1090
|
|
1075
1091
|
version = libusb_get_version();
|
1076
|
-
printf("Using
|
1092
|
+
printf("Using libusb v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano);
|
1077
1093
|
r = libusb_init(NULL);
|
1078
1094
|
if (r < 0)
|
1079
1095
|
return r;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/bin/sh
|
2
2
|
# install - install a program, script, or datafile
|
3
3
|
|
4
|
-
scriptversion=2011-
|
4
|
+
scriptversion=2011-01-19.21; # UTC
|
5
5
|
|
6
6
|
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
7
7
|
# later released in X11R6 (xc/config/util/install.sh) with the
|
@@ -35,7 +35,7 @@ scriptversion=2011-11-20.07; # UTC
|
|
35
35
|
# FSF changes to this file are in the public domain.
|
36
36
|
#
|
37
37
|
# Calling this script install-sh is preferred over install.sh, to prevent
|
38
|
-
#
|
38
|
+
# `make' implicit rules from creating a file called install from it
|
39
39
|
# when there is no Makefile.
|
40
40
|
#
|
41
41
|
# This script is compatible with the BSD install script, but was written
|
@@ -156,7 +156,7 @@ while test $# -ne 0; do
|
|
156
156
|
-s) stripcmd=$stripprog;;
|
157
157
|
|
158
158
|
-t) dst_arg=$2
|
159
|
-
# Protect names problematic for
|
159
|
+
# Protect names problematic for `test' and other utilities.
|
160
160
|
case $dst_arg in
|
161
161
|
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
162
162
|
esac
|
@@ -190,7 +190,7 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
|
190
190
|
fi
|
191
191
|
shift # arg
|
192
192
|
dst_arg=$arg
|
193
|
-
# Protect names problematic for
|
193
|
+
# Protect names problematic for `test' and other utilities.
|
194
194
|
case $dst_arg in
|
195
195
|
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
196
196
|
esac
|
@@ -202,7 +202,7 @@ if test $# -eq 0; then
|
|
202
202
|
echo "$0: no input file specified." >&2
|
203
203
|
exit 1
|
204
204
|
fi
|
205
|
-
# It's OK to call
|
205
|
+
# It's OK to call `install-sh -d' without argument.
|
206
206
|
# This can happen when creating conditional directories.
|
207
207
|
exit 0
|
208
208
|
fi
|
@@ -240,7 +240,7 @@ fi
|
|
240
240
|
|
241
241
|
for src
|
242
242
|
do
|
243
|
-
# Protect names problematic for
|
243
|
+
# Protect names problematic for `test' and other utilities.
|
244
244
|
case $src in
|
245
245
|
-* | [=\(\)!]) src=./$src;;
|
246
246
|
esac
|
@@ -354,7 +354,7 @@ do
|
|
354
354
|
if test -z "$dir_arg" || {
|
355
355
|
# Check for POSIX incompatibilities with -m.
|
356
356
|
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
357
|
-
# other-
|
357
|
+
# other-writeable bit of parent directory when it shouldn't.
|
358
358
|
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
359
359
|
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
360
360
|
case $ls_ld_tmpdir in
|