The text of a manual · part 12 of 38
PEN*KEY 6100 Computer Programmer's Reference Guide: Section 3: Supporting Windows Applications, pages 96 to 102
Pages 96 to 102 of 328, from PEN*KEY 6100 Computer Programmer's Reference Guide
The original document is the PDF (1.2 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
Filed in the catalog under the Intermec 6110
Page 96
Supporting Windows Applications
SECTION 3
Special Paper Handling
3. Windows Applications
The PrtService API supports two paperĆhandling options, PRT_FORWARD and PRT_REVERSE, that should be used with care. They are provided to allow reĆ ports to be after they have been printed and inspected. Windows mainĆ tains an internal value that where the current page is relative to the top of form and end of form. If you use these options, Windows can get confused. The printer also knows where it is on the page (every 11 inches is a new page, which may not match the actual paper if the topĆofĆform button is used incorrectĆ ly). Windows always produces a form feed at the end of a page to advance the paper to the top of the next page. These options are typically used around the printers topĆofĆform marker, which confuses things even more. Different sizes of paper behave differently and may jam the printer. 1. Generate your entire page (may be only half of the page) and call EndĆ Page(...). This flushes everything printed to the printer and performs a form feed. This places the print position up at the top of the next page. 2. Call StartPage(...) to reset the Windows device context so that you can do more output. 3. Use PRT_FORWARD to advance the paper far enough so that the user can determine whether the page is correct. Use a small number of lines, if you can, especially if you are using multipart forms. If possible, do not advance at all. This may be possible if you have not printed on the bottom inch of the page or if the information is not critical. Ask the user to determine whether the page is correct. 4. Use PRT_REVERSE to rewind the paper back into the printer the same number of lines used in step 3 (assuming the paper is advanced in step 3). This moves the print position to the top of the form. 5. Use PRT_REVERSE to rewind the paper back into the printer to get to the spot at which to print your validation information. Rewind past the topĆofĆ form marker so that the EndPage(...) in step 7 moves the print position to the top of the next page. If not rewinded far enough, EndPage(...) causes it to skip an entire page. To print on the last line of the page, a value of 2 works, assuming TextOut(...) starts at 0 for the Y value. 6. Use EndPage(...) to flush everything printed to the printer and performs a form feed. The print position moves to the top of the next page and, if right, Windows is reset so that the next StartPage(...) gets things going again. Print something on the page regardless of whether the user said the page was correct. This validates the page only if the valid message is on the page. Errors can occur while the system attempts to print the void message which may not appear on the paper. If the absence of a void message means that it is valid, an invalid page may be accepted as valid if the void message can not be printed.
NPCP Printer Driver Error Codes and Messages Error # Error Code 102 PNRDY 104
RXTMO
106
TXTMO
3-28
Error Message Printer Not Ready Check Connection Not Receiving Check Connection Not Transmitting Check Connection
Explanation Printer not properly connected. Printer stopped sending data in a packet. Printer stopped receiving data in a packet.
PEN*KEY R 6100 Computer Programmer’s Reference Guide
Page 97
SECTION 3
Error # 111 112 113 120 121 122 123 124 200 201 202 203 204 205 206 210 221 222-227 242-247 255 XXX
Supporting Windows Applications
Error Code BADADR GAPERR LSRPE IFTS NS_NE_VR NR_NE_VS RLENERR MAC_CRCERR FRMERR FRMERR_IF FRMERR_NR FRMERR_NS NDMERR FRMERR_SF FRMERR_LF BINDERR IPLDUR (see below) (see below) DEVERR
Error Message MAC Address Error MAC Interchar Gap Error MAC Length Parity Error Invalid Comm Frame NS <> VR Error NR <> VS Error Receive Length Error CRC Error Frame Reject Error Invalid Frame NR Mismatch NS Mismatch Disconnect Error Frame Too Short Frame Too Long Bind Error Invalid PLDU (see below) (see below) Device Error Unknown Error
Explanation Printer rejected MAC address sent in a packet. Length between bytes too long. Actual and declared packet sizes did not match. Frame sent in wrong sequence. Received NS did not match expected NR. Received NR did not match expected NS. Actual and declared packet sizes did not match. Invalid CRC. Frame was rejected. Frame receive was invalid for current mode. NR did not match. NS did not match. Printer is in NDM. Frame was too short. Frame was too long. Invalid bind sequence. Invalid Presentation Layer Data Unit. Messages for DATA WAS RCVD. Messages for DATA WAS LOST. A device error occurred. Unrecognized error occurred.
The following messages are applicable when DATA WAS RECEIVED: Error Code HEADJAM1 PAPEROUT1 LOWVOLTS1 HIVOLTS1 LOWBAT1 COVEROFF1
Error Message Head Jam Paper Out Low Voltage Over Voltage Low Battery Cover Off
Explanation Head jam. All data was flushed. Printer is out of paper. Printer undervoltage condition. Printer overvoltage condition. Printer battery is low. Cover was removed.
3. Windows Applications
Error # 222 223 224 225 226 227
The following messages are applicable when DATA WAS LOST: Error # 242 243 244 245 246 247
Error Code HEADJAM2 PAPEROUT2 LOWVOLTS2 HIVOLTS2 LOWBAT2 COVEROFF2
Error Message Head Jam Paper Out Low Voltage Over Voltage Low Battery Cover Off
Explanation Head jam. All data was flushed. Printer is out of paper. Printer undervoltage condition. Printer overvoltage condition. Printer battery is low. Cover was removed.
PEN*KEY R 6100 Computer Programmer’s Reference Guide
3-29
Page 98
Supporting Windows Applications
SECTION 3
IrDA Printing for Windows: NOR6805.DRV The IrDA printing support, under Windows, consists of the DOS device driver, NORIRDA.DRV, and the Windows printer driver, NOR6805.DRV. These device drivers work together to provide transparent IrDA printing. Applications use the standard Windows printing API (StartDoc(), EndDoc(), etc.) to print to a printer set up for LPT2.DOS output.
Installation Place the files in the following directories: File NORIRDA.DRV NOR6805.DRV UNIDRV.DLL
Directory WINDOWS\SYSTEM WINDOWS\SYSTEM WINDOWS\SYSTEM
Configuration Required WIN.INI Entries The sections of the WIN.INI file, that appear on the next few pages, are necesĆ sary to set up the printer device parameters for IrDA printing: [windows] spooler= DosPrint=no device=IrDA Printer,NOR6805,LPT2.DOS where: spooler= tells Windows not to use Print Manager to spool printing. DosPrint=no tells Windows not to print directly to the printer port. 3. Windows Applications device=IrDA Printer,NOR6805,LPT2.DOS specifies the default printer for WinĆ dows. The following section of the WIN.INI file are necessary to set up the paper paĆ rameters for the printer. [NORAND 6805,LPT2.DOS] PaperSize=256 SizeUnit=1 PaperWidth=480 PaperLength=1450 where: PaperSize= specifies the size that Windows uses. For the 6805 Printer -- 258 selects roll", which has a fixed width of 1.89 inches and a fixed length of 11 inches. 256 selects a userĆdefined paper size, which mandates the use of the SizeUnit, PaperWidth, and PaperLength statements. SizeUnit= establishes the units that specify paper width and length. For the 6805 Printer: indicates a unit of 0.1 millimeter (the default) " indicates a unit of 0.01 inch PaperWidth= For the NORAND 6805 Printer, paper width is fixed at 480 (SiĆ zeUnit=1; 48 millimeters = 1.89 inch) or 189 (for SizeUnit=2) "
3-30
PEN*KEY R 6100 Computer Programmer’s Reference Guide
Page 99
SECTION 3
Supporting Windows Applications
PaperLength= For the NORAND 6805 Printer, length values can be from 60 to 2794 (6 to 279.4 millimeters for SizeUnit=1) or 24 to 1100 (0.24 to 11.00 inches for SizeUnit=2. A value of 1450 for SizeUnit=1 sets the length at 5.7 inches. NORAND 6805=NOR6805,LPT2.DOS,15,45 tells Windows that there is a printĆ er named NORAND 6805 that uses the NOR6805 printer driver to print, using the DOS device LPT2 with 15Ćsecond device timeĆout and 45Ćsecond retry timeĆ out. [devices] NORAND 6805=NOR6805,LPT2.DOS
The following [PrinterPorts] and [devices] sections of the WIN.INI file sets up the printer name and printer driver. [PrinterPorts] IrDA Printer=NOR6805,LPT2.DOS,15,45 where: IrDA Printer=NOR6805,LPT2.DOS,15,45 tells Windows that there is a printer named IrDA Printer that uses the NOR6805 printer driver to print, using the DOS device LPT2 with 15Ćsecond device timeĆout and 45Ćsecond retry timeĆout. [devices] IrDA Printer=NOR6805,LPT2.DOS where: IrDA Printer=NOR6805,LPT2.DOS tells Windows that there is a printer named IrDA Printer that uses the NOR6805 printer driver to print, using the DOS deĆ vice LPT2. This section is included for compatibility with older Windows applicaĆ tions and should match the entry in the [PrinterPorts] section of the WIN.INI file (listed previously).
Required SYSTEM.INI Entries [boot] drivers= power irda pen penwindows scanner npcp
[drivers] irda=norirda.drv irda= tells Windows the actual name of the installable driver named in the [boot] section of the SYSTEM.INI file. [IRDA Driver] deviceName=LPT2 UARTAddress=1000 UARTIRQ=14 Technology=6100 PrinterFlush=TRUE PrtPort=0
DeviceName= is the name of the printer device for output (LPT1, LPT2, LPT3). This option must match settings in WIN.INI (listed previously). UARTAddress= sets the base address on which the driver looks for the IR UART. The default setting is 760 (2f8h). Valid settings are 1016 (3f8h for COM1), 760 (2f8h for COM2), 1000 (3e8h for COM3). Required setting for the 6100 ComputĆ er: 1000 (3e8h for COM3). PEN*KEY R 6100 Computer Programmer’s Reference Guide
3-31
3. Windows Applications where: drivers= tells Windows to load the installable drivers. This list of drivers is the standard driver list (in the required order). The significant driver here, is irda. This is a token driver name. The actual driver name is specified in the [drivers] section of SYSTEM.INI:
Page 100
Supporting Windows Applications
SECTION 3
UARTIRQ= sets the IRQ line on which the UART interrupts. The default setĆ ting is 3 (COM2). Other valid settings: 4 (COM1), 14. Required setting for the 6100 Computer: 14. Technology= sets the type of the handĆheld computer. The default setting is PENKEY. Required setting for the 6100 Computer is: 6100. PrinterFlush= tells Windows to flush the printer's input buffer, as part of the printer initialization stream. PrtPort= PrtPort specifies the printer port to use; 0=LPT1, 1=LPT2, 2=LPT3. This option must match the options set in CONFIG.SYS and WIN.INI. The following section of the SYSTEM.INI file sets up the parameters for the NORAND 6805 printer: [NORAND 6805 Printer] DoGraphicsOnly=FALSE Timeout=10 WakeupChars=200
DoGraphicsOnly= forces the drivers to use Graphics commands for the entire document. The default value is FALSE. Valid settings are TRUE and FALSE (that is, graphics commands are used whenever device fonts are not used). Timeout= sets idle time in seconds for a period of printer inactivity, after which a wakeup is issued to the printer. Default is 10. Valid settings are 10 to 50. WakeupChars= controls the number of NULL characters sent to the printer after the Initialize command, for it to wake up properly. Default is 200. Valid settings are 200 to 500. Setting a lower value may disrupt graphics printing, resulting in garbled output to printer.
Usage Default Error-Handling Mode 3. Windows Applications
Once the drivers are loaded as defined in the preceding paragraphs, no special processing by the application is needed. This makes it possible for offĆtheĆshelf packages to take advantage of the IrDA protocol. In this mode, all printerĆreĆ lated errors are handled by the IrDA driver. A message is displayed and the user has the ability to Cancel or Retry. If the user selects Retry, the driver attempts to continue printing. If the user selects Cancel, the driver attempts to clean up. The standard Windows API returns a standard error, indicating that a problem occurred. This is the application's signal to abort the print job.
Application-Defined Error-Handling Mode This is probably the most common mode of operation. In this mode, the applicaĆ tion can link to the IrDA driver in the same manner that it would link to any Windows DLL. Once linked, the application can use the driver's API to perform various operations. The application registers a callback with the driver. The application needs to perform these actions to define a new error handler: 1. Link to driver and obtain PrtService entry point. 2. Call PrtService to enable the driver, using PRT_ENABLE (0x0001). 3. Call PrtService to register the new handler, using PRT_SETPROC (0x0010) and the address of the new handler. The new handler should have the following prototype: extern “C” WORD _export FAR PASCAL ShowPrtError( WORD wCurErr ) 3-32
PEN*KEY R 6100 Computer Programmer’s Reference Guide
Page 101
SECTION 3
Supporting Windows Applications
This callback is called for each error and must return IDCANCEL (0x02), IDRETRY (0x04) or 0. If the application returns 0, the default handler proĆ cesses the error. For consistency, the application should handle all errors. Use any method for displaying the message. Make the dialog model, if posĆ sible. Note, based on the method of displaying the message, you may need to translate the return values into IDCANCEL or IDRETRY for the printer driver. 4. Perform normal printing operations. 5. Call PrtService to remove the error handler, using PRT_SETPROC (0x0010) and a NULL value for the handler address. 6. Call PrtService to disable the driver, using PRT_DISABLE (0x0002).
Printer Services API The IrDA printer driver includes an API to provide access to the features of the IrDA driver that are not available through the standard Windows API. Retrieving the API Entry Point PrtService
To use the API, the application must first obtain the entry point for the PrtService procedure as described in the following code fragment:
Calling PrtService
NORIRDA.DRV contains an exported procedure PrtService( HINSTANCE hInst, WORD wOpt, LPARAM lParam1, LPARAM lParam2) that provides the API for the driver. The parameters to the procedure are as follows: HINSTANCE hInst WORD wOpt LPARAM lParam1 LPARAM lParam2 instance handle to our application. option for action you want to perform. double word that depends on the particular option. double word that depends on the particular option.
The value returned by PrtService depends on the option selected. See specific options for more details. The entry point can be called just like any Windows procedure, as shown in the following fragment: if (lpfnPrtService(hInst, PRT_ENABLE, (LPARAM)NULL, (LPARAM)NULL ) < 1) { MessageBox( NULL, “Unable to enable printer driver”, “ERROR”, MB_OK | MB_ICONEXCLAMATION ); return FALSE; } PEN*KEY R 6100 Computer Programmer’s Reference Guide
3-33
3. Windows Applications hInstNorPrnt = LoadLibrary( “NORIRDA.DRV” ); if ( hInstNorPrnt <= HINSTANCE_ERROR ) { MessageBox( NULL, “Could not open printer driver.”, “ERROR”, MB_OK | MB_ICONEXCLAMATION ); return FALSE; } lpfnPrtService = (fpPrtService)GetProcAddress( hInstNorPrnt, “PrtService” ); if ( lpfnPrtService == NULL ) { MessageBox( NULL, “Unable to get address for\nPrtService”, “ERROR”, MB_OK | MB_ICONEXCLAMATION ); return FALSE; }
Page 102
Supporting Windows Applications
SECTION 3
Supported PrtService Options
PrtService provides the following services: "
"
"
"
"
Enable Driver. Enables the driver and installs the default error handler. wOpt should be set to PRT_ENABLE (0x0001) lParam1 should be set to 0 lParam2 should be set to 0 Disable Driver. Disables the driver. wOpt should be set to PRT_DISABLE (0x0002) lParam1 should be set to 0 lParam2 should be set to 0 Query Driver for support of an option. Determines whether the driver supĆ ports a particular feature. wOpt should be set to PRT_GETSUPPORT (0x0003) lParam1 should be set to the value of the option you want to check. lParam2 should be set to 0 Install/Remove External Error handler. Installs or removes the applicaĆ tions error handler. wOpt should be PRT_SETPROC (0x0010) lParam1 should be a far pointer to your error handling procedure. A valĆ ue of 0 removes the handler. Call MakeProcInstance(...) to get the value. lParam2 should be set to 0 Flush Driver. Flushes all the data buffers so that everything sent to the printer actually gets printed. wOpt should be set to PRT_FLUSH (0x0020) lParam1 should be set to 0 lParam2 should be set to 0
3. Windows Applications
Error Codes and Messages As pointed out in the topic Error-Handling Mode," the IrDA printer driver can provide the error handler and thereby translate all printerĆrelated erĆ rors into a Cancel or Retry option for any application. However, if the application provides the error handler, custom messages can be attached to the error returns. As shown in this table, seven different numbered returns are made available by the driver as generic hook points for messages. Error # 3 255 254 253 252 251 xxx
Error Wait Failed Error Queue Full Error Node Active Error Bad ConHandle Media Busy Unknown Error
Any of the listed errors can appear under 12 different operational phases or cateĆ gories such as: Initialize, Discover, Discover TimeĆout, Connect, Connect Status Error, Flush ć Allocate, Flush ć Get, Flush ćAppend, Flush Queue Full, Send, Disconnect, and Shutdown. 3-34
PEN*KEY R 6100 Computer Programmer’s Reference Guide