PrinterSupportChapter —5
202 700Series Color MobileComputer User’s Manual
NPCP Printer Communications
All NPCP printer communications should be based on the f ollowing flow:
1Use CreateFile(); toopen the printer driver.
2Use IOCTL_NPCP_BIND to bind a session with the printer;
IOCTL_NPCP_ERRORto check for errors on the bind to ensure suc-
cess; and IOCTL_NPCP_CANCEL to cancel any outstanding print
jobs.
3Use IOCTL_NPCP_FLUSH to poll the printer to free up printe r buff-
er resources. Use IOCTL_NPCP_FLUSH to poll the printer ’s status. If
an error is reported by the IOCTL, then use IOCTL_NPCP_ERROR
to get theerror and determine the correct recovery procedure.
4Use WriteFile();to write your data to the printer. Check for errors and
that all data were written. Use IOCTL_NPCP_ERROR to get the ex-
tendederror. If the error is critical in nature, use
IOCTL_NPCP_CLOSE, followed by CloseFi le(), to end the commu-
nications session. Start a new session, beginning with step 1 to ensure
proper printing.For noncritical errors display theerror and retry the
operation.
5After all data is sent to the printer, ensure that the printer continues to
print the report properly by polling the printe r’s status. Use
IOCTL_NPCP_FLUSHto poll the printer’s status. If an error is re-
ported by theIOCTL, then use IOCTL_NPCP_ERRORto get the
error and determinethe correct recovery procedure.
Sample Code
See sample code in the “\700C Dev Tools\InstallableDriv ers\Port
Drivers\Npcp\NPCPPrint\”directory for more details on printing, printer
communications and error code handling.