Chapter 5 — Printer Support
116 CN2B Mobile Computer User’s Manual
4 Use WriteFile(); to write your data to the printer. Check for errors and
that all data were written. Use IOCTL_NPCP_ERROR to get the
extended error. If the error is critical in nature, use
IOCTL_NPCP_CLOSE, followed by CloseFile(), to end the communi-
cations session. Start a new session, beginning with step 1 to ensure
proper printing. For noncritical errors display the error and retry the
operation.
5 After all data is sent to the printer, ensure that the printer continues to
print the report properly by polling the printer’s status. 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 the
error and determine the correct recovery procedure.
Sample Code
See sample code in the “\CN2B Dev Tools\Installable Drivers\Port Driv-
ers\Npcp\NPCPPrint\” directory for more details on printing, printer com-
munications and error code handling.
NPCP Error Codes
Call the IOCTL_NPCP_ERROR I/O control function to receive PL/N
compatible error codes. Applications must decide how to act upon the data
returned.
// Definition of NPCP communications Errors and Printer Errors
#define PNRDY (BYTE)102 // link not ready error
#define RXTMO (BYTE)104 // link no receive error
#define TXTMO (BYTE)106 // link no transmit error
#define BADADR (BYTE)111 // frame address error
#define GAPERR (BYTE)112 // link gap error (timeout) in receive data
#define LSRPE (BYTE)113 // frame parity error on length field
#define IFTS (BYTE)120 // session layer - invalid frame this state
#define NS_NE_VR (BYTE)121 // session layer sequence error
#define NR_NE_VS (BYTE)122 // session layer sequence error
#define MAC_CRCERR (BYTE)124 // MAC CRC error
#define RLENERR (BYTE)123 // MAC too much data received
#define FRMERR (BYTE)200 // Frame Reject
#define FRMERR_IF (BYTE)201 // Frame Reject - Invalid Frame
#define FRMERR_NR (BYTE)202 // Frame Reject - NR Mismatch
#define FRMERR_NS (BYTE)203 // Frame Reject - NS Mismatch
#define NDMERR (BYTE)204 // Normal Disconnect mode error
#define BINDERR (BYTE)210 // bind error
#define IPLDUR (BYTE)221 // invalid presentation layer response
#define HEADJAM (BYTE)222 // printer head jam
#define PAPEROUT (BYTE)223 // printer paper out
#define LOWVOLTS (BYTE)224 // printer low voltage
#define HIVOLTS (BYTE)225 // printer over voltage
#define LOWBAT (BYTE)226 // printer low battery
#define COVEROFF (BYTE)227 // printer cover off error
#define HEADFAULT (BYTE)228 // printer head short or driver short error
#define PFFAULT (BYTE)229 // paper feed motor fault.
#define FRAME_NOT_ACKED 0x8000 // frame was not received by printer and need to
be resent.
Comentários a estes Manuais