ahi.device For High-level AccessFour primary steps are required to open ahi.device:
CreateMsgPort(). Reply messages from
the device must be directed to a message port.
AHIRequest using
CreateIORequest(). CreateIORequest() will initialize the I/O
request to point to your reply port.
ahi.device unit AHI_DEFAULT_UNIT or any other unit the
user has specified with, for example, a UNIT tooltype. Call
OpenDevice(), passing the I/O request.
Each OpenDevice() must eventually be matched by a call to
CloseDevice(). When the last close is performed, the device will
deallocate all resources.
All I/O requests must be completed before CloseDevice(). Abort any
pending requests with AbortIO().
Example:
struct MsgPort *AHImp = NULL;
struct AHIRequest *AHIio = NULL;
BYTE AHIDevice = -1;
UBYTE unit = AHI_DEFAULT_UNIT;
/* Check if user wants another unit here... */
if(AHImp = CreateMsgPort())
{
if(AHIio = (struct AHIRequest *)
CreateIORequest(AHImp, sizeof(struct AHIRequest)))
{
AHIio->ahir_Version = 4;
if(!(AHIDevice = OpenDevice(AHINAME, unit,
(struct IORequest *) AHIio, NULL)))
{
/* Send commands to the device here... */
if(! CheckIO((struct IORequest *) AHIio))
{
AbortIO((struct IORequest *) AHIio);
}
WaitIO((struct IORequest *) AHIio);
CloseDevice((struct IORequest *) AHIio);
AHIDevice = -1;
}
DeleteIORequest((struct IORequest *) AHIio);
AHIio = NULL;
}
DeleteMsgPort(AHImp);
AHImp = NULL;
}
Go to the first, previous, next, last section, table of contents.