Functions



IOWarriorCount


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

IOWarriorFirstInterfaceOfType


Returns the first IOWarrior interface of type inInterfaceType.

Parameters

NameDescription
inInterfaceTypeThe type of the interface to be returned.
Result: Returns an interface object if found, NULL otherwise.
IOWarriorHIDDeviceInterface** IOWarriorFirstInterfaceOfType (
    int inInterfaceType
);

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.


IOWarriorInit


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

IOWarriorInterfaceListNodeAtIndex


Returns the list node element at index inIndex.

Parameters

NameDescription
inIndexThe index of the desired list node. First list node has index 0.
Result: A pointer to a structure of type IOWarriorListNode. NULL if index is out of bounds.
IOWarriorListNode* IOWarriorInterfaceListNodeAtIndex (
    int inIndex
);

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


IOWarriorIsPresent


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

IOWarriorReadFromInterface


Reads data from a specific interface.

Parameters

NameDescription
inInterfaceThe 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.
inReportIDThe report ID of the request. See the IO Warrior Datasheet for the appropriate values.
inSizeThe size of the data to be read.
inDataA pointer to a buffer thats at least inSize bytes long. Read data will be stored here.
Result: Returns 0 if read operation was successful, returns an error code different from 0 otherwise.
int IOWarriorReadFromInterface (
    IOWarriorHIDDeviceInterface** inInterface,
    int inReportID,
    int inSize,
    void* outData
);

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


IOWarriorReadInterface0


Reads 4 byte (32 bit) from interface 0 of the first IOWarrior 40 device connected to this system using a GetOutputReport request.

Parameters

NameDescription
outDataA pointer to a buffer where the data should be stored. Buffer has to be at least 4 bytes long
Result: Returns 0 if reading operation was successfull. Returns a value different from 0 otherwise.
int IOWarriorReadInterface0 (
    void *outData
);

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.

Parameters

NameDescription
inReportIDThe report ID of the request. See the IO Warrior Datasheet for the appropriate values.
outDataA pointer to a buffer where the data should be stored. Buffer has to be at least 7 bytes long
Result: Returns 0 if reading operation was successfull. Returns a value different from 0 otherwise.
int IOWarriorReadInterface1 (
    int inReportID,
    void *outData
);

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


IOWarriorSetDeviceCallback


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

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.

Parameters

NameDescription
inInterfaceThe interface where your data arrives
inBufferA buffer provided by the caller.
inBufferSizeThe size of inBuffer.
inCallbackPtrA pointer to your callback function. See IOHIDLib.h for more info.
inRefConA reference value passed to your callback on invocation.
int IOWarriorSetInterruptCallback (
    IOWarriorHIDDeviceInterface** inInterface,
    void* inBuffer,
    UInt32 inBufferSize,
    IOHIDReportCallbackFunction inCallbackPtr,
    void* inRefCon
);

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.


IOWarriorWriteInterface0


Writes a 4 byte buffer (32 bit) to interface 0 of the first IOWarrior 40 devices using a SetOutputReport request.

Parameters

NameDescription
inDataA pointer to the data being written. Should be at least 4 bytes long.
Result: Returns 0 if writing operation was successfull. Returns a value different from 0 otherwise.
int IOWarriorWriteInterface0 (
    void *inData
);

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.


IOWarriorWriteInterface1


Writes a 7 byte output report to interface 1 of the first IOWarrior 40 device connected to this system.

Parameters

NameDescription
inReportIDThe report ID of the request. See the IO Warrior Datasheet for the appropriate values.
inDataA pointer to the data being written. Should be at least 7 bytes long.
Result: Returns 0 if writing operation was successfull. Returns a value different from 0 otherwise.
int IOWarriorWriteInterface1 (
    int inReportID,
    void *inData
);

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


IOWarriorWriteToInterface


Writes data to a specific interface.

Parameters

NameDescription
inInterfaceThe interface the data should be written to. Pass the ioWarriorHIDInterface member of an IOWarriorListNode struct obtained earlier.
inSizeThe size of the data to be written.
inDataA pointer to the data to be written. First byte is report id.
Result: Returns 0 if write operation was successful, returns an error code different from 0 otherwise.
int IOWarriorWriteToInterface (
    IOWarriorHIDDeviceInterface** inInterface,
    int inSize,
    void* inData
);

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

(Last Updated 2/4/2004)