Commit Graph

721 Commits

Author SHA1 Message Date
Klaus Reimer
db56a99069 New linux binaries 2013-07-13 21:06:26 +02:00
Klaus Reimer
4bd5b6a76d Fix unit tests 2013-07-13 21:04:34 +02:00
Klaus Reimer
08f724de7a Implement support for BOS descriptors 2013-07-13 21:02:23 +02:00
Klaus Reimer
e234b9a75f Add unit test for Interface and catch uninitialized usage of it. 2013-07-13 20:01:18 +02:00
Klaus Reimer
60d8c7c904 Add unit test for InterfaceDescriptor and catch uninitialized usage of
it.
2013-07-13 19:56:53 +02:00
Klaus Reimer
c0efcdf706 Add unit test for DeviceDescriptor and catch uninitialized usage of it. 2013-07-13 19:50:28 +02:00
Klaus Reimer
6f11a8b365 Ignore crash logs 2013-07-13 19:34:16 +02:00
Klaus Reimer
b0ea43c88b Add unit test for EndpointDescriptor and catch uninitialized usage of it 2013-07-13 19:27:26 +02:00
Klaus Reimer
0d2a6d3d49 Add unit test for ConfigDescriptor and catch uninitialized usage of it 2013-07-13 18:20:24 +02:00
Klaus Reimer
7ad0eef2bc Add unit test for SuperSpeed Endpoint Companion Descriptor 2013-07-13 17:27:46 +02:00
Klaus Reimer
ed6178e93c Implement a bunch of new libusb constants and wrapper functions and add
support for SuperSpeed Endpoint Companion Descriptors.
2013-07-13 17:14:22 +02:00
Klaus Reimer
ac18b6a3d0 Add LPM attribute constant. 2013-07-13 10:34:39 +02:00
Klaus Reimer
63a145e494 Add constants for supported speed bit fields 2013-07-13 10:33:09 +02:00
Klaus Reimer
15c1cf252e Fix handle leak warnings 2013-07-13 10:20:19 +02:00
Luca Longinotti
b12535ac22 Mac OS X: update support for 32 and 64 bit versions. Xcode-gcc didn't like one of the warnings, so it was removed (not critical). 2013-07-12 11:19:28 +02:00
Klaus Reimer
0fa54ff8d8 Disable udev support. Not portable enough yet 2013-07-09 18:30:15 +02:00
Klaus Reimer
4a47d32920 Upgrade to libusbx-1.0.16-rc3. Only Linux binaries have been updated. 2013-07-09 18:23:10 +02:00
Klaus Reimer
baa5f63099 Add -Wno-extra-portability flag. 2013-07-09 17:49:07 +02:00
Luca Longinotti
2fce3707fc Make libusbx-1.0.15 the only default stable provider for all systems.
Add libusbx-1.0.16-rc3 as an option to test the new upcoming release.
With 1.0.16 libusb and libusbx are merging back together, so the separation doesn't make sense anymore.
The 1.0.16 RCs might give better results on MacOS X, lots of work has gone in the Darwin backend.
Defaults to stable, but just set LIBUSB="beta" in build/common.sh to switch to 1.0.16 RCs.
2013-07-08 17:05:35 +02:00
Luca Longinotti
33b580b5f6 Commit fixes for Mac OS X build. 2013-07-08 12:19:59 +02:00
Luca Longinotti
e97db92e7f Add Win64 rebuild, completing the series. 2013-06-24 11:48:38 +02:00
Luca Longinotti
6aaf3e98f1 Add ARMv7HF build. 2013-06-23 22:25:04 -04:00
Luca Longinotti
d09592e9dc Update build. 2013-06-24 03:48:19 +02:00
Luca Longinotti
a783e6d2d0 Update configure.ac and build to support older automake. 2013-06-24 03:47:24 +02:00
Luca Longinotti
b7ff0b6cba Fix autogen.sh failure on Linux systems. 2013-06-24 02:53:48 +02:00
Luca Longinotti
d9f4ac089c Windows 32bit native build. 2013-06-24 02:12:24 +02:00
Luca Longinotti
8c4d2dddac Add recompiles for win32 and win64. win64 should work, win32 I'm unsure if there will still be problems with having used the MinGW cross-compiler or not. 2013-06-21 15:24:53 +02:00
Luca Longinotti
5c36619972 Add updated linux-32 port. 2013-06-20 23:48:46 +02:00
Luca Longinotti
2034fd81f3 Add up-to-date linux-64 build. 2013-06-20 23:26:32 +02:00
Luca Longinotti
09d582157f Implement equals/hashCode for ControlSetup by comparing the two buffers fully (only thing you can do!).
Change equals/hashCode for IsoPacketDescriptor and related Transfer to use only their pointers to native memory.
This is because two Transfers may be the same on all accounts, but they still are not the same Transfer that's happening.
Also it interfered with removal of Transfers from a list in the callback: Java couldn't clearly distinguish them and started accessing members of some that were already freed, resulting in exceptions.
Furhter, implement toString for IsoPacketDescriptor, Transfer and ControlSetup.
2013-06-18 11:02:25 +02:00
Luca Longinotti
f92a84c979 Read the flags before calling the Java method, as it might free the underlying memory. 2013-06-18 10:51:06 +02:00
Luca Longinotti
faa739dcbd Fix typo. Update libs with new fix. 2013-06-18 10:07:21 +02:00
Luca Longinotti
451b081d3f Commit updated libs. 2013-06-17 09:00:48 +02:00
Luca Longinotti
c0ea9ba0f6 How we interact with libusb from Java is quite inconsistent, and it mainly stems from the fact Java has no
unsigned integers, which is what libusb uses everywhere.
As it was before, there are parts of the library that return bytes & shorts, like the Descriptors (mostly to
be compatible with javax.usb), and others that take and return int, even where an 8 or 16-bit quantity would
be expected by libusb. I suspect this was done to avoid casting and try to side-step the sign-extension
problem with Java as much as possible, but in the end it leads to an API that's inconsistent, that doesn't
express the ranges it can use well (it's an int but in reality only 16 bits for libusb and so on). It also
fails at basic operations in ways you'd not expect because of the above inconsistencies:
if (deviceDescriptor.bDeviceClass() == LibUsb.CLASS_VENDOR_SPEC) { do something; }
will never work, since the constant is an int and the returned short from bDeviceClass() will be cast up to an
int too, but CLASS_VENDOR_SPEC is 0xFF (MSB=1), it will be sign-extended and the comparison will fail always.
There are two solutions I can see here:
A) consistently use int/long everywhere, both input and output. Everything becomes simpler to write, with less
casts, BUT javax.usb compatibility is gone for the Descriptors and it becomes even unclearer what those values
effectively mean and what range they support.
B) restrict the API to use the proper integer sizes as the C API, ie. 8-bit quantities (char, uint8_t, int8_t)
are represented by jbyte, 16-bit by jshort, and all the constants get properly sized too. With this approach
the sizes and ranges are much clearer, comparisons like the above work out-of-the-box, javax.usb compatibility
is maintained for the Descriptors. The downside is more casting and the occasional need to mask off returned
values to kill the sign-extension when you want to use those values as integers (like when printing stuff in
decimal notation).
I chose to try out the approach from B) for now, this commit implements it as explained above.
It requires minimal changes to the javax.usb implementation, just two casts to byte in AbstractDevice.java.
2013-06-17 00:17:48 +02:00
Luca Longinotti
a50fd0ecb5 Also make timeout read a long. 2013-06-16 18:07:47 +02:00
Luca Longinotti
b239bfdedd Make timeouts long: they are unsigned ints in C, and only a Java long can properly represent the full range.
It would be counter-intuitive to have to set negative timeouts in Java to get longer timeouts in C...
Also reorder getVersion() and getStringDescriptorAscii() to their proper places, so they are in the same order
as they appear in the libusbx documentation.
2013-06-16 17:20:19 +02:00
Luca Longinotti
58a2494e4c Use C99-style for-loops, much more readable. 2013-06-14 18:14:53 +02:00
Luca Longinotti
3d939da41f Bump version for testing. 2013-06-14 17:04:15 +02:00
Luca Longinotti
eb5b993eb2 Add updated libraries for Windows and Linux x86_64. 2013-06-13 14:31:21 +02:00
Luca Longinotti
ccdc2f6022 Don't increase refcount on the device returned by getParent() or getDevice().
It's better to be like libusbx itself here and not change the behavior.
But I've added a note to explain to never unref such a device.
2013-06-13 14:26:36 +02:00
Luca Longinotti
266ab299cc Wcast-qual was useuful to discover those errors in extra(): the returned ByteBuffer is fully writable, but the backing memory isn't really intended to be written to (and you never should modify the descriptors in memory).
So fixed by getting a read-only ByteBuffer and passing that back to Java instead.
2013-06-13 13:43:27 +02:00
Luca Longinotti
0f6031ab88 Revert TransferTest to original, since null is now supported again. 2013-06-13 13:40:06 +02:00
Luca Longinotti
95ee591d46 Remove memcpy wrap stuff to support old, broken systems... memcpy is never used here, only libusb uses it and there they don't support it in any particular way, so I don't believe there should be a workaround for this that forces memcpy to be slower on all x86_64 linux systems.
Enable silent building and C99 support.
Enable lots of warnings and don't enable Werror, as there are warnings in libusb.h.
Fix all warnings. Add const to exceptions.
Make it possible to pass null to setDevHandle and setBuffer in Transfer now.
2013-06-13 12:59:42 +02:00
Luca Longinotti
b3e261f050 Fix tests: use direct int buffers where needed, it's Implicit and not Explicit, the class 5 is known.
Setting devHandle or buffer to NULL in Transfer is not supported (doesn't make sense at all...).
2013-06-12 23:18:39 +02:00
Luca Longinotti
8967434994 Fix descriptor dumps. Forgot to shift the masked values, other minor changes. 2013-06-12 23:09:58 +02:00
Luca Longinotti
5b58cb0302 Issue expected exception when default context refcount is zero or smaller.
Make sure that returning a new reference always leads to a new Java object being created, else
freeing/unref'ing that one would lead to the reset of the original object too.
Furthermore, ensure that getDevice also increments the reference count, since if you then free it,
which is usual and not forbidden (libusbx docs just tell you are not obligated to unref it), the
reference count would be wrong and lead to a segfault. This way it would lead at most to keeping a
device around, instead of segfaulting. Still, always free your references!!!
2013-06-12 22:22:58 +02:00
Luca Longinotti
a4d3ab69da Destroying the default context twice, even if it is refcounted, results in a segfault.
Fix submitted to libusbx as pull request #116.
Also fix this inside the Java wrapper, by adding our own refcount (similar to what was in original usb4java,
but allowing multiple calls with the default context), and making the access to said variable thread-safe.
Once libusbx fixes this, the above code can be removed.
2013-06-12 21:39:02 +02:00
Luca Longinotti
0ba3d8869f Fixed test to also use the pointer instead of the Context hashCode. 2013-06-12 18:45:31 +02:00
Luca Longinotti
ea680a9be7 Add linux and windows 64bit updated builds for more testing (linux works at a basic level). 2013-06-12 14:45:08 +02:00
Luca Longinotti
032b7487d4 Add a few capability constants that were missing, from libusbx-1.0.15. 2013-06-12 14:44:24 +02:00