build: link windows-native driver when targeting windows
This is completely experimental, but since the API is the same, it's a drop-in replacement. The Windows driver is not apparently open source, so I am vendoring the static libraries provided. In theory, this will obviate the need to replace the HID driver on Windows and will thus require no initial setup, but I cannot currently test it beyond making sure it compiles.
This commit is contained in:
parent
e4393c2e5a
commit
f1480bca45
20
build.zig
20
build.zig
@ -17,11 +17,21 @@ pub fn build(b: *std.Build) void {
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const ljacklm_dep = b.dependency(
|
||||
"ljacklm",
|
||||
.{ .target = target, .optimize = optimize, .use_udev = use_udev },
|
||||
);
|
||||
exe.linkLibrary(ljacklm_dep.artifact("ljacklm"));
|
||||
if (target.result.os.tag == .windows) {
|
||||
if (target.result.cpu.arch == .x86)
|
||||
exe.addObjectFile(b.path("deps/labjack/windows/ljackuw32.lib"))
|
||||
else if (target.result.cpu.arch == .x86_64)
|
||||
exe.addObjectFile(b.path("deps/labjack/windows/ljackuw64.lib"))
|
||||
else
|
||||
@panic("Unsupported CPU arch for Windows build (must be x86 or x86_64).");
|
||||
} else {
|
||||
const ljacklm_dep = b.dependency(
|
||||
"ljacklm",
|
||||
.{ .target = target, .optimize = optimize, .use_udev = use_udev },
|
||||
);
|
||||
exe.linkLibrary(ljacklm_dep.artifact("ljacklm"));
|
||||
}
|
||||
|
||||
exe.root_module.addImport(
|
||||
"udev_rules",
|
||||
b.addModule("udev_rules", .{
|
||||
|
1667
deps/labjack/windows/ljackuw.h
vendored
Normal file
1667
deps/labjack/windows/ljackuw.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
deps/labjack/windows/ljackuw32.lib
vendored
Normal file
BIN
deps/labjack/windows/ljackuw32.lib
vendored
Normal file
Binary file not shown.
BIN
deps/labjack/windows/ljackuw64.lib
vendored
Normal file
BIN
deps/labjack/windows/ljackuw64.lib
vendored
Normal file
Binary file not shown.
@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn getDriverVersion() f32 {
|
||||
return c_api.GetDriverVersion();
|
||||
@ -289,6 +290,11 @@ pub const PackedOutput = packed struct(u4) {
|
||||
}
|
||||
};
|
||||
|
||||
const Call: std.builtin.CallingConvention = if (builtin.os.tag == .windows and builtin.cpu.arch == .x86)
|
||||
.Stdcall
|
||||
else
|
||||
.C;
|
||||
|
||||
pub const c_api = struct {
|
||||
pub const vendor_id: u16 = 0x0CD5;
|
||||
pub const u12_product_id: u16 = 0x0001;
|
||||
@ -300,9 +306,9 @@ pub const c_api = struct {
|
||||
idnum: *c_long,
|
||||
serialnum: *c_long,
|
||||
caldata: *[20]c_long,
|
||||
) c_long;
|
||||
) callconv(Call) c_long;
|
||||
|
||||
pub extern fn CloseAll(local_id: c_long) c_long;
|
||||
pub extern fn CloseAll(local_id: c_long) callconv(Call) c_long;
|
||||
|
||||
pub extern fn GetU12Information(
|
||||
handle: *anyopaque,
|
||||
@ -312,7 +318,7 @@ pub const c_api = struct {
|
||||
cal_data: *[20]c_long,
|
||||
fcdd_max_size: *c_long,
|
||||
hvc_max_size: *c_long,
|
||||
) c_long;
|
||||
) callconv(Call) c_long;
|
||||
|
||||
pub extern fn EAnalogIn(
|
||||
idnum: *c_long,
|
||||
@ -321,14 +327,14 @@ pub const c_api = struct {
|
||||
gain: c_long,
|
||||
overVoltage: *c_long,
|
||||
voltage: *f32,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn EAnalogOut(
|
||||
idnum: *c_long,
|
||||
demo: c_long,
|
||||
analogOut0: f32,
|
||||
analogOut1: f32,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn ECount(
|
||||
idnum: *c_long,
|
||||
@ -336,7 +342,7 @@ pub const c_api = struct {
|
||||
resetCounter: c_long,
|
||||
count: *f64,
|
||||
ms: *f64,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn EDigitalIn(
|
||||
idnum: *c_long,
|
||||
@ -344,7 +350,7 @@ pub const c_api = struct {
|
||||
channel: c_long,
|
||||
readD: c_long,
|
||||
state: *c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn EDigitalOut(
|
||||
idnum: *c_long,
|
||||
@ -352,7 +358,7 @@ pub const c_api = struct {
|
||||
channel: c_long,
|
||||
writeD: c_long,
|
||||
state: c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn AsynchConfig(
|
||||
idnum: *c_long,
|
||||
@ -367,7 +373,7 @@ pub const c_api = struct {
|
||||
halfA: c_long,
|
||||
halfB: c_long,
|
||||
halfC: c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn Asynch(
|
||||
idnum: *c_long,
|
||||
@ -380,7 +386,7 @@ pub const c_api = struct {
|
||||
numWrite: c_long,
|
||||
numRead: c_long,
|
||||
data: [*]c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn AISample(
|
||||
idnum: *c_long,
|
||||
@ -394,7 +400,7 @@ pub const c_api = struct {
|
||||
disableCal: c_long,
|
||||
overVoltage: *c_long,
|
||||
voltages: *[4]f32,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn AIBurst(
|
||||
idnum: *c_long,
|
||||
@ -415,7 +421,7 @@ pub const c_api = struct {
|
||||
stateIOout: *[4096]c_long,
|
||||
overVoltage: *c_long,
|
||||
transferMode: c_long, // 0=auto,1=normal,2=turbo
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn AIStreamStart(
|
||||
idnum: *c_long,
|
||||
@ -430,7 +436,7 @@ pub const c_api = struct {
|
||||
disableCal: c_long,
|
||||
reserved1: c_long, // always 0
|
||||
readCount: c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn AIStreamRead(
|
||||
localID: c_long,
|
||||
@ -441,11 +447,11 @@ pub const c_api = struct {
|
||||
reserved: ?*c_long, // unused
|
||||
ljScanBacklog: *c_long,
|
||||
overVoltage: *c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn AIStreamClear(
|
||||
localID: c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn AOUpdate(
|
||||
idnum: *c_long,
|
||||
@ -459,21 +465,21 @@ pub const c_api = struct {
|
||||
count: [*c]c_ulong,
|
||||
analogOut0: f32,
|
||||
analogOut1: f32,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn BitsToVolts(
|
||||
chnum: c_long,
|
||||
chgain: c_long,
|
||||
bits: c_long,
|
||||
volts: [*c]f32,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn VoltsToBits(
|
||||
chnum: c_long,
|
||||
chgain: c_long,
|
||||
volts: f32,
|
||||
bits: [*c]c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn Counter(
|
||||
idnum: *c_long,
|
||||
@ -483,7 +489,7 @@ pub const c_api = struct {
|
||||
resetCounter: c_long,
|
||||
enableSTB: c_long,
|
||||
count: [*c]c_ulong,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn DigitalIO(
|
||||
idnum: *c_long,
|
||||
@ -494,12 +500,12 @@ pub const c_api = struct {
|
||||
stateIO: *c_long, // 4 bits
|
||||
updateDigital: c_long,
|
||||
outputD: *c_long, // 16 bits
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn GetDriverVersion() f32;
|
||||
pub extern fn StaticErrorString(errorcode: c_long) [*:0]const u8;
|
||||
pub extern fn GetErrorString(errorcode: c_long, errorString: *[50]u8) void;
|
||||
pub extern fn GetFirmwareVersion(idnum: *c_long) f32;
|
||||
pub extern fn GetDriverVersion() callconv(Call) f32;
|
||||
pub extern fn StaticErrorString(errorcode: c_long) callconv(Call) [*:0]const u8;
|
||||
pub extern fn GetErrorString(errorcode: c_long, errorString: *[50]u8) callconv(Call) void;
|
||||
pub extern fn GetFirmwareVersion(idnum: *c_long) callconv(Call) f32;
|
||||
|
||||
pub extern fn ListAll(
|
||||
productIDList: *[127]c_long,
|
||||
@ -510,12 +516,12 @@ pub const c_api = struct {
|
||||
numberFound: *c_long,
|
||||
fcddMaxSize: *c_long,
|
||||
hvcMaxSize: *c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn LocalID(
|
||||
idnum: *c_long,
|
||||
localID: c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn PulseOut(
|
||||
idnum: *c_long,
|
||||
@ -527,7 +533,7 @@ pub const c_api = struct {
|
||||
timeC1: c_long,
|
||||
timeB2: c_long,
|
||||
timeC2: c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn PulseOutStart(
|
||||
idnum: *c_long,
|
||||
@ -539,24 +545,24 @@ pub const c_api = struct {
|
||||
timeC1: c_long,
|
||||
timeB2: c_long,
|
||||
timeC2: c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn PulseOutFinish(
|
||||
idnum: *c_long,
|
||||
demo: c_long,
|
||||
timeoutMS: c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn PulseOutCalc(
|
||||
frequency: *f32,
|
||||
timeB: *c_long,
|
||||
timeC: *c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn ReEnum(idnum: *c_long) LabjackCError;
|
||||
pub extern fn Reset(idnum: *c_long) LabjackCError;
|
||||
pub extern fn ResetLJ(idnum: *c_long) LabjackCError;
|
||||
pub extern fn CloseLabJack(localID: c_long) LabjackCError;
|
||||
pub extern fn ReEnum(idnum: *c_long) callconv(Call) LabjackCError;
|
||||
pub extern fn Reset(idnum: *c_long) callconv(Call) LabjackCError;
|
||||
pub extern fn ResetLJ(idnum: *c_long) callconv(Call) LabjackCError;
|
||||
pub extern fn CloseLabJack(localID: c_long) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn SHT1X(
|
||||
idnum: *c_long,
|
||||
@ -567,7 +573,7 @@ pub const c_api = struct {
|
||||
tempC: *f32,
|
||||
tempF: *f32,
|
||||
rh: *f32,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn SHTComm(
|
||||
idnum: *c_long,
|
||||
@ -579,7 +585,7 @@ pub const c_api = struct {
|
||||
numRead: c_long,
|
||||
datatx: [*]u8, // numWrite length
|
||||
datarx: [*]u8, // numRead length
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn SHTCRC(
|
||||
statusReg: c_long,
|
||||
@ -587,7 +593,7 @@ pub const c_api = struct {
|
||||
numRead: c_long,
|
||||
datatx: *[4]u8,
|
||||
datarx: *[4]u8,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn Synch(
|
||||
idnum: *c_long,
|
||||
@ -601,7 +607,7 @@ pub const c_api = struct {
|
||||
configD: c_long,
|
||||
numWriteRead: c_long,
|
||||
data: *[18]c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn Watchdog(
|
||||
idnum: *c_long,
|
||||
@ -615,7 +621,7 @@ pub const c_api = struct {
|
||||
stateD0: c_long,
|
||||
stateD1: c_long,
|
||||
stateD8: c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn ReadMem(
|
||||
idnum: *c_long,
|
||||
@ -624,7 +630,7 @@ pub const c_api = struct {
|
||||
data2: *c_long,
|
||||
data1: *c_long,
|
||||
data0: *c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub extern fn WriteMem(
|
||||
idnum: *c_long,
|
||||
@ -634,7 +640,7 @@ pub const c_api = struct {
|
||||
data2: c_long,
|
||||
data1: c_long,
|
||||
data0: c_long,
|
||||
) LabjackCError;
|
||||
) callconv(Call) LabjackCError;
|
||||
|
||||
pub const LabjackCError = packed struct(c_ulong) {
|
||||
code: LabjackErrorCode,
|
||||
|
Loading…
x
Reference in New Issue
Block a user