SECTION 2
Supporting DOS Applications
PEN*KEY
R
6200/6300 Hand-Held Computer Programmer’s Reference Guide 2-19
To write to the device, use any appropriate output function that can be directed
to the device (for example, in C you can use
fprintf()
).
You should install a critical error handler that processes errors from the printer.
The printer driver returns only device not ready" errors to DOS for the sake of
compatibility with the standard PRINT program supplied with DOS. You can
retrieve the extended error if you bypass DOS and call the driver directly from
the error handler. See the example listing of CRITICAL.C and errors returned
in
Appendix B, Common PEN*KEY 6000 Series Information
.
IOCTL calls (DOS Function AH = 44h, AL = 02h) are supported by the device
driver (see the DOS technical reference manual). Calls require the handle
number of the printer device in register BX, a data item with this structure
pointed to by DS:DX, and the number of bytes to be read in register CX.
struct ioargs {
far *unsigned char ioctl_cmd;
far *unsigned char ioctl_buf;
};
These commands may be pointed to by the
ioctl_command
field to be executed by
the driver:
ONLINE = 2
STATUS = 3
GET DEVICE FEATURES = 4
SELFTEST = 5
RESET
= 6
GET CURRENT CONFIGURATION =7
XTENDED ERROR = 255
Data is returned to the buffer pointed to by the ioctl_buf, for the number of bytes
specified in register CX when the IOCTL call is made. The first byte of the
returned data represents any error encountered during the call. If the call was
successful, this byte is zero. If the call was unsuccessful, this byte represents the
extended error. The format for the rest of the data is described in the
documentation for the printer.
Notes
The printer driver must be opened and closed for each report transaction with
the printer if you want to take advantage of the lineĆloss detection features of the
NPCP protocol. Applications should do an (
ioctl 3
) status call to the printer
after the last line of a report or a series of reports are sent to the printer to
ensure that all lines were printed successfully by the printer.
The printer driver is multiĆtasking. For the application to take full advantage of
this feature, it must enable timeĆslicing through the appropriate call to INT 15h.
(See the 4000API documentation.)
If timeĆslicing is not activated, the last line buffered by the driver is not sent to
the printer until the device is closed or an IOCTL status call is made to the
printer. Perform an IOCTL status call before all closes to ensure the driver print
buffer is sent to the printer successfully, because DOS closes to character devices
do not perform output flushes as part of the close operation. The driver flushes
the buffer upon a close, but no error is returned if the flush is unsuccessful.
The printer driver intercepts INT 17h (Printer BIOS Services) and translates the
requested functions to provide PL/N support. The BIOS interface for INT 17h is
not 100 percent PC compatible, it is meant to be compatible with PL/N. The
support provided by the BIOS interface for standard applications is unknown.
2. DOS
Applications