GDSX Manual

DEVICE^HANDLER Example, Design
Extended General Device Support (GDSX) Manual134303
5-13
The DEVICE^HANDLER Procedure
The terminal buffer is needed because the application subroutine SCAN^BUF converts
the data in the receiving buffer (rcv^buf), changing each byte so that a hexadecimal 6 in
the leftmost four bits becomes a hexadecimal 4, and a hexadecimal 7 in the leftmost four
bits becomes a hexadecimal 5. (Code for the SCAN^BUF subprocedure is shown in
Appendix B.) This conversion effectively capitalizes any lowercase alphabetic
characters.
The converted data is put into the terminal buffer. The terminal buffer is not allocated
until necessary; during the previous ^AWAITIO it was not needed. In general, memory
should not be allocated from the pools until it is needed, so that it is available for other
tasks.
The type of request is tested with a CASE statement. If the request is a WRITEREAD
(and it is not the case that a backup process has just taken over, as discussed later in this
section), the SCAN^BUF subroutine is called, and then ^WRITEREAD is called,
followed by ^AWAITIO. A flag, my^dcb.wt^rd^pend, is set before the ^WRITEREAD
and reset after the completion of the operation. If the task is stopped, this flag is tested
to see whether there is an outstanding ^WRITEREAD to be canceled (this is discussed
RD -> ! READ
BEGIN
CALL ^READX(TERM^FILE^NUM,TERM^BUF,RQSTR^RD^CT);
IF <> THEN CALL DEBUG;
CALL ^AWAITIOX(TERM^FILE^NUM,@TERM^BUF,TERM^CT^RD);
CALL ^FILEINFO(TERM^FILE^NUM,FERR);
IF (FERR = 0) THEN
CALL ^REPLYX(TERM^BUF,TERM^CT^RD)
ELSE
CALL ^REPLYX(,,,,FERR);
END;
CTRL -> ! CONTROL
BEGIN
CALL ^CONTROL(TERM^FILE^NUM,RCV^BUF[1],RCV^BUF[2]);
IF <> THEN CALL DEBUG;
CALL ^AWAITIOX(TERM^FILE^NUM);
CALL ^FILEINFO(TERM^FILE^NUM,FERR);
CALL ^REPLYX(,,,,FERR);;
END;
SET^MD -> ! SETMODE
BEGIN
CALL ^SETMODENOWAIT(TERM^FILE^NUM,RCV^BUF[1],
RCV^BUF[2],RCV^BUF[3]);
IF <> THEN CALL DEBUG;
CALL ^AWAITIOX(TERM^FILE^NUM);
CALL ^FILEINFO(TERM^FILE^NUM,FERR);
CALL ^REPLYX(,,,,FERR);
END;
END; !CASE
CALL PUTEXTPOOL(10,@TERM^BUF);
CALL PUTEXTPOOL(10,@RCV^BUF);
END; !WHILE
END; !PROC
Example 5-4. Request Processing (page 2 of 2)