Functions



IOWarriorCount


Returns the number of interfaces connected to this system.
int IOWarriorCountInterfaces (void);
function result
The number of IOWarrior interfaces.

IOWarriorFirstInterfaceOfType


Returns the first IOWarrior interface of type inInterfaceType.

IOWarriorHIDDeviceInterface** IOWarriorFirstInterfaceOfType (
    int inInterfaceType
);
Discussion

Use this function to get the first discovered interface of a certain type. See the Constants definitions for a list of supported IOWarrior interface types. The result of this function can be used as paramter for IOWarriorWriteToInterface or IOWarriorReadFromInterface. Returns NULL if no interface matching inInterfaceType could be found.

Parameter Descriptions
inInterfaceType
The type of the interface to be returned.
function result
Returns an interface object if found, NULL otherwise.

IOWarriorInit


Initializes the IOWarrior library. Call this before calling any other functions.
int IOWarriorInit (void);
function result
Returns 0 if successfull, otherwise return value is different from 0.

IOWarriorInterfaceListNodeAtIndex


Returns the list node element at index inIndex.
IOWarriorListNode* IOWarriorInterfaceListNodeAtIndex (
    int inIndex
);
Discussion

Use this function to obtain more information (serial number, device type) about an interface of an IOWarrior device.

Parameter Descriptions
inIndex
The index of the desired list node. First list node has index 0.
function result
A pointer to a structure of type IOWarriorListNode. NULL if index is out of bounds.

IOWarriorIsPresent


Use this function to too see of an IOWarrior device is present.
int IOWarriorIsPresent (void);
function result
Returns 1 if at least one IOWarrior is connected to this system. Returns 0 if no IOWarrior device could be discovered.

IOWarriorReadFromInterface


Reads data from a specific interface.
int IOWarriorReadFromInterface (
    IOWarriorHIDDeviceInterface** inInterface,
    int inReportID,
    int inSize,
    void* outData
);
Discussion

Use this function to read a certain amount of data associated with a certain reportID to a specific interface.

Parameter Descriptions
inInterface
The interface the data should be read from. Pass the ioWarriorHIDInterface member of an IOWarriorListNode struct. This function will not get you the data sent in interrupt mode from interface 1. Instead you will receive a copy of the last HID report sent in interrupt mode. Use IOWarriorSetInterruptCallback to receive data received in interrupt mode.
inReportID
The report ID of the request. See the IO Warrior Datasheet for the appropriate values.
inSize
The size of the data to be read.
inData
A pointer to a buffer thats at least inSize bytes long. Read data will be stored here.
function result
Returns 0 if read operation was successful, returns an error code different from 0 otherwise.

IOWarriorReadInterface0


Reads 4 byte (32 bit) from interface 0 of the first IOWarrior 40 device connected to this system using a GetOutputReport request.
int IOWarriorReadInterface0 (
    void *outData
);
Parameter Descriptions
outData
A pointer to a buffer where the data should be stored. Buffer has to be at least 4 bytes long
function result
Returns 0 if reading operation was successfull. Returns a value different from 0 otherwise.

IOWarriorReadInterface1


Reads a 7 byte output report from interface 1 of the first IOWarrior 40 device connected to this system. This function won't work for interfaces 1 of an IOWarrior 40 on Mac OS X 10.2.x.

int IOWarriorReadInterface1 (
    int inReportID,
    void *outData
);
Discussion

Use this function to obtain data from the IOWarrior when in special mode. See the IOWarrior datasheet for details.

Parameter Descriptions
inReportID
The report ID of the request. See the IO Warrior Datasheet for the appropriate values.
outData
A pointer to a buffer where the data should be stored. Buffer has to be at least 7 bytes long
function result
Returns 0 if reading operation was successfull. Returns a value different from 0 otherwise.

IOWarriorSetDeviceCallback


Sets the function to be called when IOWarrior devices ar added or removed.
void IOWarriorSetDeviceCallback (
    IOWarriorDeviceCallbackFunctionPtr inCallbackPtr,
    void* inRefCon
);
Discussion

Use this function to install a custom callback function. You function will be called whenever IOWarrior devices are added or removed from the system. You should invalidate any references to IOWarriorListNode structures you might have saved when your callback functions gets called. Be sure to call IOWarriorCountInterfaces at least once after you callback function was invoked before calling any other functions from the IOWarrior Library.


IOWarriorSetInterruptCallback


Sets the function to be called when a report data is received on inInterface.
int IOWarriorSetInterruptCallback (
    IOWarriorHIDDeviceInterface** inInterface,
    void* inBuffer,
    UInt32 inBufferSize,
    IOHIDReportCallbackFunction inCallbackPtr,
    void* inRefCon
);
Discussion

Use this function to install a custom callback routine that gets invoked when data is received on interface inInterface. This function will only work when your application was compiled on Mac OS 10.3 or later and is running on Mac OS 10.3 or later. For earlier systems the implementation of the function is hidden from the compiler using preprocessor commands, because the system does not implement the required API calls.

Parameter Descriptions
inInterface
The interface where your data arrives
inBuffer
A buffer provided by the caller.
inBufferSize
The size of inBuffer.
inCallbackPtr
A pointer to your callback function. See IOHIDLib.h for more info.
inRefCon
A reference value passed to your callback on invocation.

IOWarriorWriteInterface0


Writes a 4 byte buffer (32 bit) to interface 0 of the first IOWarrior 40 devices using a SetOutputReport request.
int IOWarriorWriteInterface0 (
    void *inData
);
Discussion

The first byte of the passed buffer becomes mapped to the pins of port 0, the second byte to the pins of port 1 and so on.

Parameter Descriptions
inData
A pointer to the data being written. Should be at least 4 bytes long.
function result
Returns 0 if writing operation was successfull. Returns a value different from 0 otherwise.

IOWarriorWriteInterface1


Writes a 7 byte output report to interface 1 of the first IOWarrior 40 device connected to this system.
int IOWarriorWriteInterface1 (
    int inReportID,
    void *inData
);
Discussion

Use the function to control IOWarrior special modes (like IIC and LCD mode) of the IOWarrior. See the IOWarrior datasheet for details.

Parameter Descriptions
inReportID
The report ID of the request. See the IO Warrior Datasheet for the appropriate values.
inData
A pointer to the data being written. Should be at least 7 bytes long.
function result
Returns 0 if writing operation was successfull. Returns a value different from 0 otherwise.

IOWarriorWriteToInterface


Writes data to a specific interface.
int IOWarriorWriteToInterface (
    IOWarriorHIDDeviceInterface** inInterface,
    int inSize,
    void* inData
);
Discussion

Use this function to write to a certain amount of data associated with a certain reportID to a specific interface.

Parameter Descriptions
inInterface
The interface the data should be written to. Pass the ioWarriorHIDInterface member of an IOWarriorListNode struct obtained earlier.
inSize
The size of the data to be written.
inData
A pointer to the data to be written. First byte is report id.
function result
Returns 0 if write operation was successful, returns an error code different from 0 otherwise.

(Last Updated 5/24/2019)