#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(dead_code)]
use std::os::raw;
pub const FALSE: u32 = 0;
pub const TRUE: u32 = 1;
pub const IOWKIT_VENDOR_ID: u32 = 1984;
pub const IOWKIT_VID: u32 = 1984;
pub const IOWKIT_PRODUCT_ID_IOW40: u32 = 5376;
pub const IOWKIT_PID_IOW40: u32 = 5376;
pub const IOWKIT_PRODUCT_ID_IOW24: u32 = 5377;
pub const IOWKIT_PID_IOW24: u32 = 5377;
pub const IOWKIT_PRODUCT_ID_IOW24_SENSI: u32 = 5514;
pub const IOWKIT_PID_IOW24_SENSI: u32 = 5514;
pub const IOWKIT_PRODUCT_ID_IOWPV1: u32 = 5393;
pub const IOWKIT_PID_IOWPV1: u32 = 5393;
pub const IOWKIT_PRODUCT_ID_IOWPV2: u32 = 5394;
pub const IOWKIT_PID_IOWPV2: u32 = 5394;
pub const IOWKIT_PRODUCT_ID_IOW56: u32 = 5379;
pub const IOWKIT_PID_IOW56: u32 = 5379;
pub const IOWKIT_PRODUCT_ID_IOW56_ALPHA: u32 = 5515;
pub const IOWKIT_PID_IOW56_ALPHA: u32 = 5515;
pub const IOWKIT_PRODUCT_ID_IOW28: u32 = 5380;
pub const IOWKIT_PID_IOW28: u32 = 5380;
pub const IOWKIT_PRODUCT_ID_IOW28L: u32 = 5381;
pub const IOWKIT_PID_IOW28L: u32 = 5381;
pub const IOWKIT_PRODUCT_ID_IOW100: u32 = 5382;
pub const IOWKIT_PID_IOW100: u32 = 5382;
pub const IOWKIT_PRODUCT_ID_TW: u32 = 5631;
pub const IOWKIT_PID_TW: u32 = 5631;
pub const IOWKIT_MAX_PIPES: u32 = 4;
pub const IOW_PIPE_IO_PINS: u32 = 0;
pub const IOW_PIPE_SPECIAL_MODE: u32 = 1;
pub const IOW_PIPE_I2C_MODE: u32 = 2;
pub const IOW_PIPE_ADC_MODE: u32 = 3;
pub const IOWKIT_MAX_DEVICES: u32 = 16;
pub const IOW_OPEN_SIMPLE: u32 = 1;
pub const IOW_OPEN_COMPLEX: u32 = 2;
pub const IOW_NON_LEGACY_REVISION: u32 = 4112;
pub type ULONG = raw::c_ulong;
pub type LONG = raw::c_long;
pub type USHORT = raw::c_ushort;
pub type WORD = raw::c_ushort;
pub type UCHAR = raw::c_uchar;
pub type BYTE = raw::c_uchar;
pub type PCHAR = *mut raw::c_char;
pub type PWCHAR = *mut raw::c_ushort;
pub type BOOL = raw::c_int;
pub type BOOLEAN = raw::c_uchar;
pub type DWORD = raw::c_ulong;
pub type PDWORD = *mut DWORD;
pub type PVOID = *mut raw::c_void;
pub type HANDLE = DWORD;
pub type PULONG = *mut ULONG;
pub type PCSTR = *const raw::c_char;
pub type PWCSTR = *const raw::c_ushort;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _IOWKIT_REPORT {
pub ReportID: UCHAR,
pub __bindgen_anon_1: _IOWKIT_REPORT__bindgen_ty_1,
}
#[repr(C, packed)]
#[derive(Copy, Clone)]
pub union _IOWKIT_REPORT__bindgen_ty_1 {
pub Value: DWORD,
pub Bytes: [BYTE; 4usize],
}
pub type IOWKIT_REPORT = _IOWKIT_REPORT;
pub type PIOWKIT_REPORT = *mut _IOWKIT_REPORT;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _IOWKIT40_IO_REPORT {
pub ReportID: UCHAR,
pub __bindgen_anon_1: _IOWKIT40_IO_REPORT__bindgen_ty_1,
}
#[repr(C, packed)]
#[derive(Copy, Clone)]
pub union _IOWKIT40_IO_REPORT__bindgen_ty_1 {
pub Value: DWORD,
pub Bytes: [BYTE; 4usize],
}
pub type IOWKIT40_IO_REPORT = _IOWKIT40_IO_REPORT;
pub type PIOWKIT40_IO_REPORT = *mut _IOWKIT40_IO_REPORT;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _IOWKIT24_IO_REPORT {
pub ReportID: UCHAR,
pub __bindgen_anon_1: _IOWKIT24_IO_REPORT__bindgen_ty_1,
}
#[repr(C, packed)]
#[derive(Copy, Clone)]
pub union _IOWKIT24_IO_REPORT__bindgen_ty_1 {
pub Value: WORD,
pub Bytes: [BYTE; 2usize],
}
pub type IOWKIT24_IO_REPORT = _IOWKIT24_IO_REPORT;
pub type PIOWKIT24_IO_REPORT = *mut _IOWKIT24_IO_REPORT;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _IOWKIT_SPECIAL_REPORT {
pub ReportID: UCHAR,
pub Bytes: [UCHAR; 7usize],
}
pub type IOWKIT_SPECIAL_REPORT = _IOWKIT_SPECIAL_REPORT;
pub type PIOWKIT_SPECIAL_REPORT = *mut _IOWKIT_SPECIAL_REPORT;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _IOWKIT56_IO_REPORT {
pub ReportID: UCHAR,
pub Bytes: [UCHAR; 7usize],
}
pub type IOWKIT56_IO_REPORT = _IOWKIT56_IO_REPORT;
pub type PIOWKIT56_IO_REPORT = *mut _IOWKIT56_IO_REPORT;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _IOWKIT56_SPECIAL_REPORT {
pub ReportID: UCHAR,
pub Bytes: [UCHAR; 63usize],
}
pub type IOWKIT56_SPECIAL_REPORT = _IOWKIT56_SPECIAL_REPORT;
pub type PIOWKIT56_SPECIAL_REPORT = *mut _IOWKIT56_SPECIAL_REPORT;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _IOWKIT28_IO_REPORT {
pub ReportID: UCHAR,
pub Bytes: [UCHAR; 4usize],
}
pub type IOWKIT28_IO_REPORT = _IOWKIT28_IO_REPORT;
pub type PIOWKIT28_IO_REPORT = *mut _IOWKIT28_IO_REPORT;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _IOWKIT28_SPECIAL_REPORT {
pub ReportID: UCHAR,
pub Bytes: [UCHAR; 63usize],
}
pub type IOWKIT28_SPECIAL_REPORT = _IOWKIT28_SPECIAL_REPORT;
pub type PIOWKIT28_SPECIAL_REPORT = *mut _IOWKIT28_SPECIAL_REPORT;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _IOWKIT100_IO_REPORT {
pub ReportID: UCHAR,
pub Bytes: [UCHAR; 12usize],
}
pub type IOWKIT100_IO_REPORT = _IOWKIT100_IO_REPORT;
pub type PIOWKIT100_IO_REPORT = *mut _IOWKIT100_IO_REPORT;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _IOWKIT100_SPECIAL_REPORT {
pub ReportID: UCHAR,
pub Bytes: [UCHAR; 63usize],
}
pub type IOWKIT100_SPECIAL_REPORT = _IOWKIT100_SPECIAL_REPORT;
pub type PIOWKIT100_SPECIAL_REPORT = *mut _IOWKIT100_SPECIAL_REPORT;
pub type IOWKIT_HANDLE = PVOID;
extern crate libloading;
#[derive(Debug)]
pub struct Iowkit {
__library: ::libloading::Library,
pub IowKitOpenDevice: Result<unsafe extern "C" fn() -> IOWKIT_HANDLE, ::libloading::Error>,
pub IowKitCloseDevice:
Result<unsafe extern "C" fn(devHandle: IOWKIT_HANDLE), ::libloading::Error>,
pub IowKitWrite: Result<
unsafe extern "C" fn(
devHandle: IOWKIT_HANDLE,
numPipe: ULONG,
buffer: PCHAR,
length: ULONG,
) -> ULONG,
::libloading::Error,
>,
pub IowKitRead: Result<
unsafe extern "C" fn(
devHandle: IOWKIT_HANDLE,
numPipe: ULONG,
buffer: PCHAR,
length: ULONG,
) -> ULONG,
::libloading::Error,
>,
pub IowKitReadNonBlocking: Result<
unsafe extern "C" fn(
devHandle: IOWKIT_HANDLE,
numPipe: ULONG,
buffer: PCHAR,
length: ULONG,
) -> ULONG,
::libloading::Error,
>,
pub IowKitReadImmediate: Result<
unsafe extern "C" fn(devHandle: IOWKIT_HANDLE, value: PDWORD) -> BOOL,
::libloading::Error,
>,
pub IowKitGetNumDevs: Result<unsafe extern "C" fn() -> ULONG, ::libloading::Error>,
pub IowKitGetDeviceHandle:
Result<unsafe extern "C" fn(numDevice: ULONG) -> IOWKIT_HANDLE, ::libloading::Error>,
pub IowKitSetLegacyOpenMode:
Result<unsafe extern "C" fn(legacyOpenMode: ULONG) -> BOOL, ::libloading::Error>,
pub IowKitGetProductId:
Result<unsafe extern "C" fn(devHandle: IOWKIT_HANDLE) -> ULONG, ::libloading::Error>,
pub IowKitGetRevision:
Result<unsafe extern "C" fn(devHandle: IOWKIT_HANDLE) -> ULONG, ::libloading::Error>,
pub IowKitGetThreadHandle:
Result<unsafe extern "C" fn(devHandle: IOWKIT_HANDLE) -> HANDLE, ::libloading::Error>,
pub IowKitGetSerialNumber: Result<
unsafe extern "C" fn(devHandle: IOWKIT_HANDLE, serialNumber: PWCHAR) -> BOOL,
::libloading::Error,
>,
pub IowKitSetTimeout: Result<
unsafe extern "C" fn(devHandle: IOWKIT_HANDLE, timeout: ULONG) -> BOOL,
::libloading::Error,
>,
pub IowKitSetWriteTimeout: Result<
unsafe extern "C" fn(devHandle: IOWKIT_HANDLE, timeout: ULONG) -> BOOL,
::libloading::Error,
>,
pub IowKitCancelIo: Result<
unsafe extern "C" fn(devHandle: IOWKIT_HANDLE, numPipe: ULONG) -> BOOL,
::libloading::Error,
>,
pub IowKitVersion: Result<unsafe extern "C" fn() -> PCSTR, ::libloading::Error>,
}
impl Iowkit {
pub unsafe fn new<P>(path: P) -> Result<Self, ::libloading::Error>
where
P: AsRef<::std::ffi::OsStr>,
{
let library = ::libloading::Library::new(path)?;
Self::from_library(library)
}
pub unsafe fn from_library<L>(library: L) -> Result<Self, ::libloading::Error>
where
L: Into<::libloading::Library>,
{
let __library = library.into();
let IowKitOpenDevice = __library.get(b"IowKitOpenDevice\0").map(|sym| *sym);
let IowKitCloseDevice = __library.get(b"IowKitCloseDevice\0").map(|sym| *sym);
let IowKitWrite = __library.get(b"IowKitWrite\0").map(|sym| *sym);
let IowKitRead = __library.get(b"IowKitRead\0").map(|sym| *sym);
let IowKitReadNonBlocking = __library.get(b"IowKitReadNonBlocking\0").map(|sym| *sym);
let IowKitReadImmediate = __library.get(b"IowKitReadImmediate\0").map(|sym| *sym);
let IowKitGetNumDevs = __library.get(b"IowKitGetNumDevs\0").map(|sym| *sym);
let IowKitGetDeviceHandle = __library.get(b"IowKitGetDeviceHandle\0").map(|sym| *sym);
let IowKitSetLegacyOpenMode = __library.get(b"IowKitSetLegacyOpenMode\0").map(|sym| *sym);
let IowKitGetProductId = __library.get(b"IowKitGetProductId\0").map(|sym| *sym);
let IowKitGetRevision = __library.get(b"IowKitGetRevision\0").map(|sym| *sym);
let IowKitGetThreadHandle = __library.get(b"IowKitGetThreadHandle\0").map(|sym| *sym);
let IowKitGetSerialNumber = __library.get(b"IowKitGetSerialNumber\0").map(|sym| *sym);
let IowKitSetTimeout = __library.get(b"IowKitSetTimeout\0").map(|sym| *sym);
let IowKitSetWriteTimeout = __library.get(b"IowKitSetWriteTimeout\0").map(|sym| *sym);
let IowKitCancelIo = __library.get(b"IowKitCancelIo\0").map(|sym| *sym);
let IowKitVersion = __library.get(b"IowKitVersion\0").map(|sym| *sym);
Ok(Iowkit {
__library,
IowKitOpenDevice,
IowKitCloseDevice,
IowKitWrite,
IowKitRead,
IowKitReadNonBlocking,
IowKitReadImmediate,
IowKitGetNumDevs,
IowKitGetDeviceHandle,
IowKitSetLegacyOpenMode,
IowKitGetProductId,
IowKitGetRevision,
IowKitGetThreadHandle,
IowKitGetSerialNumber,
IowKitSetTimeout,
IowKitSetWriteTimeout,
IowKitCancelIo,
IowKitVersion,
})
}
pub unsafe fn IowKitOpenDevice(&self) -> IOWKIT_HANDLE {
(self
.IowKitOpenDevice
.as_ref()
.expect("Expected function, got error."))()
}
pub unsafe fn IowKitCloseDevice(&self, devHandle: IOWKIT_HANDLE) -> () {
(self
.IowKitCloseDevice
.as_ref()
.expect("Expected function, got error."))(devHandle)
}
pub unsafe fn IowKitWrite(
&self,
devHandle: IOWKIT_HANDLE,
numPipe: ULONG,
buffer: PCHAR,
length: ULONG,
) -> ULONG {
(self
.IowKitWrite
.as_ref()
.expect("Expected function, got error."))(devHandle, numPipe, buffer, length)
}
pub unsafe fn IowKitRead(
&self,
devHandle: IOWKIT_HANDLE,
numPipe: ULONG,
buffer: PCHAR,
length: ULONG,
) -> ULONG {
(self
.IowKitRead
.as_ref()
.expect("Expected function, got error."))(devHandle, numPipe, buffer, length)
}
pub unsafe fn IowKitReadNonBlocking(
&self,
devHandle: IOWKIT_HANDLE,
numPipe: ULONG,
buffer: PCHAR,
length: ULONG,
) -> ULONG {
(self
.IowKitReadNonBlocking
.as_ref()
.expect("Expected function, got error."))(devHandle, numPipe, buffer, length)
}
pub unsafe fn IowKitReadImmediate(&self, devHandle: IOWKIT_HANDLE, value: PDWORD) -> BOOL {
(self
.IowKitReadImmediate
.as_ref()
.expect("Expected function, got error."))(devHandle, value)
}
pub unsafe fn IowKitGetNumDevs(&self) -> ULONG {
(self
.IowKitGetNumDevs
.as_ref()
.expect("Expected function, got error."))()
}
pub unsafe fn IowKitGetDeviceHandle(&self, numDevice: ULONG) -> IOWKIT_HANDLE {
(self
.IowKitGetDeviceHandle
.as_ref()
.expect("Expected function, got error."))(numDevice)
}
pub unsafe fn IowKitSetLegacyOpenMode(&self, legacyOpenMode: ULONG) -> BOOL {
(self
.IowKitSetLegacyOpenMode
.as_ref()
.expect("Expected function, got error."))(legacyOpenMode)
}
pub unsafe fn IowKitGetProductId(&self, devHandle: IOWKIT_HANDLE) -> ULONG {
(self
.IowKitGetProductId
.as_ref()
.expect("Expected function, got error."))(devHandle)
}
pub unsafe fn IowKitGetRevision(&self, devHandle: IOWKIT_HANDLE) -> ULONG {
(self
.IowKitGetRevision
.as_ref()
.expect("Expected function, got error."))(devHandle)
}
pub unsafe fn IowKitGetThreadHandle(&self, devHandle: IOWKIT_HANDLE) -> HANDLE {
(self
.IowKitGetThreadHandle
.as_ref()
.expect("Expected function, got error."))(devHandle)
}
pub unsafe fn IowKitGetSerialNumber(
&self,
devHandle: IOWKIT_HANDLE,
serialNumber: PWCHAR,
) -> BOOL {
(self
.IowKitGetSerialNumber
.as_ref()
.expect("Expected function, got error."))(devHandle, serialNumber)
}
pub unsafe fn IowKitSetTimeout(&self, devHandle: IOWKIT_HANDLE, timeout: ULONG) -> BOOL {
(self
.IowKitSetTimeout
.as_ref()
.expect("Expected function, got error."))(devHandle, timeout)
}
pub unsafe fn IowKitSetWriteTimeout(&self, devHandle: IOWKIT_HANDLE, timeout: ULONG) -> BOOL {
(self
.IowKitSetWriteTimeout
.as_ref()
.expect("Expected function, got error."))(devHandle, timeout)
}
pub unsafe fn IowKitCancelIo(&self, devHandle: IOWKIT_HANDLE, numPipe: ULONG) -> BOOL {
(self
.IowKitCancelIo
.as_ref()
.expect("Expected function, got error."))(devHandle, numPipe)
}
pub unsafe fn IowKitVersion(&self) -> PCSTR {
(self
.IowKitVersion
.as_ref()
.expect("Expected function, got error."))()
}
}