Technical information

CHAPTER 3
The PC Interface Driver
Passing Messages 49
Installing a Message Handler 3
Before you can receive messages, you must install a message handler. The PC Interface
driver calls the message handler when the driver receives a message with a command
value greater than or equal to recCmdBase and less than recCmdBase + recCmdCount
in the MsgRecElem data structure. The driver passes the message’s 16-bit command and
the two 32-bit parameters to your message handler.
The message handler examines the command and parameters and determines whether
there is any data to be received. If there is, the handler passes back a pointer to a
MsgPBlk. The PC Interface driver then receives the data and puts it into the buffer
pointed to by msgBuffer. The driver then updates msgActCount with the number of
bytes of data received and sets msgResult to 0 (no error), –1 (MsgOverrun), –2
(MsgUnderrun), or –3 (MsgTimeout). The driver then calls your completion routine, if
there is one.
A message handler is described by a MsgRecElem record. The recProc field points to
the handler procedure; the values of recBaseCmd and recCmdCount are the values
allocated by rsRegisterMessage.
IMPORTANT
Before your program terminates, you must remove your message
handler so that the PC Interface driver will not call it after you are gone.
See the section “Removing a Message Handler” on page 51.
On the Mac OS 3
The MsgRecElem data structure for programs on the Mac OS has the following format
MsgRecElem RECORD 0
recQLink DS.l 1 ; Next queue element
recQType DS.w 1 ; Queue flags
recFlags DS.w 1 ; Not used...Yet...Set to zero
recProc DS.l 1 ; Pointer to the receive procedure
recCmdBase DS.w 1 ; First command received by this
procedure
recCmdCount DS.w 1 ; Number of commands allocated for
this procedure
recUserData DS.l 1 ; For caller’s use (could be A5...)
MsgRecElemSize Equ *
ENDR
To install a message handler on the Mac OS, build a MsgRecElem record and pass a
pointer to it in a control call to the PC Interface driver.