Client API

C:\Windows\System32\AIO167.dll provides this API; it can alternately be moved to the same dir as the executable.

Headers are provided for C/C++ and Delphi (Object Pascal). C/C++ also requires a library file; one is provided for Microsoft Visual C/C++. Because the names match, it's possible to start with an ACCES32-based sample, and just remove VCACCES.lib and add VCAIO167.lib.

GetNumCards()

function GetNumCards: LongWord; cdecl; external 'AIO167.dll'; __declspec(dllimport) unsigned long GetNumCards(void);

GetNumCards() returns the number of cards installed using AIO167. The first card always has a card number of 0, the next (if any) is 1, etc. Thus if GetNumCards() returns 3, then the cards are numbered 0, 1, and 2.

QueryCardID()

function QueryCardID(CardNum: LongWord; pID: PLongWord): LongWord; cdecl; external 'AIO167.dll'; __declspec(dllimport) unsigned long QueryCardID(unsigned long CardNum, unsigned long *pDeviceID);

QueryCardID() fetches the virtual device ID of a card. The 104-AIO16E's virtual device ID is 0x1ECE8, and the 104-QUAD-8's is 0x12230. It returns a Windows error code, which will be ERROR_SUCCESS on success.

QueryCardBase()

function QueryCardBase(CardNum: LongWord; pBase: PLongWord): LongWord; cdecl; external 'AIO167.dll'; __declspec(dllimport) unsigned long QueryCardBase(unsigned long CardNum, unsigned long *pBase);

QueryCardBase() fetches the base address of a card. This can be used for non-Rel port I/O. It returns a Windows error code, which will be ERROR_SUCCESS on success.

WaitForIRQ()

function WaitForIRQ(CardNum: LongWord): LongWord; cdecl; external 'AIO167.dll'; __declspec(dllimport) unsigned long WaitForIRQ(unsigned long CardNum);

WaitForIRQ() performs a wait, which will return when the card generates an IRQ. In normal use, spawn a worker thread which calls this function. It returns a Windows error code, which will be ERROR_SUCCESS on success.

An IOCTL with no .DLL wrapper can be called to cancel a pending wait. Contact the factory for details.

WaitForIRQData()

function WaitForIRQData(CardNum: LongWord; DataBytes: LongInt; pData: Pointer): LongWord; cdecl; external 'AIO167.dll'; __declspec(dllimport) unsigned long WaitForIRQData(unsigned long CardNum, signed long DataBytes, void *pData);

WaitForIRQData() performs a wait like WaitForIRQ(); if the wait completes successfully, it fills in the data buffer with words read from the card. For the 104-AIO16E, this should usually be half the FIFO, 512 words (equal to 1024 bytes).

Port I/O Functions

InPortB, InPort, InPortL, OutPortB, OutPort, and OutPortL function like their ACCES32 counterparts.

RelInPortB, RelInPort, RelInPortL, RelOutPortB, RelOutPort, and RelOutPortL, are similar, but use a relative offset instead of an absolute address.

For example, if card number 0 has a base address of 0x300, RelOutPortB(0, 6, 0xF0) is equivalent to OutPortB(0x306, 0xF0).

FunctionUse
RelInPortBRead a byte from a relative offset
RelInPortRead a word (2 bytes) from a relative offset
RelInPortLRead a double-word (4 bytes) from a relative offset
RelOutPortBWrite a byte to a relative offset
RelOutPortWrite a word (2 bytes) to a relative offset
RelOutPortLWrite a double-word (4 bytes) to a relative offset

InPortBRead a byte from an absolute address
InPortRead a word (2 bytes) from an absolute address
InPortLRead a double-word (4 bytes) from an absolute address
OutPortBWrite a byte to an absolute address
OutPortWrite a word (2 bytes) to an absolute address
OutPortLWrite a double-word (4 bytes) to an absolute address