deps.labjack: fiddle with Windows support a little

I will probably spend more time on this than I plan to, though I am not
really writing this to run on Windows. At this point, Windows
compilation works but when the driver attempts to read the HID
descriptor, the response is only 45 bytes instead of the expected 75
(which is what it gets when run on Linux). I was under the impression
that this response was just raw data from the device itself, but it's
clearly handled differently on the different platforms, so I think it
will be somewhat interesting to dig into what is different between the
two and why. It's possible I may actually learn something along the
way, unfortunately.
This commit is contained in:
torque 2024-07-02 21:37:41 -07:00
parent c32390f7c1
commit 10c40d7d50
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk
4 changed files with 21 additions and 0 deletions

View File

@ -17,6 +17,10 @@ pub fn build(b: *std.Build) !void {
.link_libc = true,
});
if (optimize == .Debug) {
liblabjackusb.defineCMacro("LJ_DEBUG", "1");
}
liblabjackusb.addCSourceFile(.{ .file = b.path("liblabjackusb/labjackusb.c") });
liblabjackusb.installHeader(b.path("liblabjackusb/labjackusb.h"), "labjackusb.h");

View File

@ -505,6 +505,7 @@ static HANDLE LJUSB_OpenSpecificDevice(libusb_device *dev, const struct libusb_d
return NULL;
}
#if defined(_WIN32)
// Test if the kernel driver has the U12.
if (desc->idProduct == U12_PRODUCT_ID && libusb_kernel_driver_active(devh, 0)) {
#if LJ_DEBUG
@ -521,6 +522,7 @@ static HANDLE LJUSB_OpenSpecificDevice(libusb_device *dev, const struct libusb_d
return NULL;
}
}
#endif // _WIN32
r = libusb_claim_interface(devh, 0);
if (r < 0) {

View File

@ -17,6 +17,10 @@ pub fn build(b: *std.Build) !void {
.link_libc = true,
});
if (optimize == .Debug) {
libljacklm.defineCMacro("LJ_DEBUG", "1");
}
if (target.result.os.tag == .windows) {
libljacklm.defineCMacro("LJACKLM_USE_WINDOWS_MUTEX_SHIM", "1");
}

View File

@ -7220,6 +7220,17 @@ long GetU12Information( HANDLE hDevice,
temp = (unsigned long)LJUSB_GetDeviceDescriptorReleaseNumber(hDevice) * 65536; //upper two bytes of serial #
result = LJUSB_GetHIDReportDescriptor(hDevice, repDesc, 75);
#if defined(LJ_DEBUG)
fprintf(stderr, "U12 HID ReportDescriptor (hex, %lu B): ", result);
for (int idx = 0; idx < result; idx++) {
fprintf(stderr, "%02hhX", repDesc[idx]);
}
fprintf(stderr, "\n");
#endif // LJ_DEBUG
if(result < 75)
{
//Failed getting descriptor. First capability would of been input, so