Zebra P640 Programmer's Manual - 2 Driver Architecture

Manual is about: Photo ID Printers

Summary of P640

  • Page 1

    Programmer’s manual for zebra p640/p640i photo id printers p/n: 980552-001 zebra card solutions 6/15/2005 page 1 of 40 www.Zebracard.Com.

  • Page 2

    Disclaimer zebra technologies has made every effort to document this product fully and accurately. The software and documentation is, nevertheless, provided and licensed “as is.” developer acknowledges and agrees that it has no rights to any upgrades, modifications, enhancements or revisions which z...

  • Page 3: 1 Introduction

    1 introduction this document describes the programming interface to control zebra technologies p640 and p640i card printers. This manual along with the code and the reference distributed with it are known as the zebra technologies p640 programmer’s manual. This manual is intended as a reference for ...

  • Page 4

    1 driver architecture 5 1.1 u ser i nterface dll 5 1.2 k ernel /u ser mode dll 5 1.3 l anguage m onitor 5 1.4 p ort m onitors 5 2 sending commands to the printer through the driver 6 2.1 e xample c ode – s ending command to printer 7 2.2 o pen p rinter 8 2.3 c lose p rinter 8 2.4 g et p rinter d ata...

  • Page 6

    3 sending commands to the printer through the driver an application program can send commands to the printer through the language monitor, using the getprinterdata function. The command sent can be either a simple command or a request for the printer to return data. If data is to be returned, the ca...

  • Page 7

    3.1 example code – sending command to printer #define unicode #define _unicode #include “printerdefs.H” #include “messages.H” handle hprinter=null; dword dwtype=0; dword dwread=0; int retvalue, count; tchar data[error_text_size]; printer_defaults pd; pd.Desiredaccess = printer_all_access; pd.Pdataty...

  • Page 8

    3.2 openprinter before making any other calls to the printer, you must first call openprinter to establish a connection with the printer. Bool openprinter(lptstr pprintername,lphandle phprinter, lpprinter_defaults pdefaults); pprintername pointer to a null-terminated string that specifies the name o...

  • Page 9

    3.4 getprinterdata dword getprinterdata(handle hprinter,lptstr pvaluename, lpdword ptype,lpbyte pdata,dword nsize, lpdword pcbneeded); hprinter handle to a printer from openprinter pvaluename pointer to a string of tchar type. Unicode should be defined in the project. Make sure it is nul terminated....

  • Page 10

    These few defines are used by multiple commands: #define bool_no_text text("0") #define bool_yes_text text("1") #define reduced_text text("2") #define bool_no 0 #define bool_yes 1 #define reduced 2 ¾ note: all reg_sz type values should be unicode strings get sense data #define request_sense text("re...

  • Page 11

    } sensedata, far *lpsensedata; feed ribbon #define ribbon_feed text("ribbonfeed") input: no output: no data: no clean cycle #define clean_cycle text("cleancycle") input: no output: no data: no eject card #define eject_card text("ejectcard") input: no output: no data: no p/n: 980552-001 zebra card so...

  • Page 12

    Request sensor data #define request_sensor_data text("sensordata") input: no output: yes – sensordata structure data: no typedef struct tagsensordata { union { word wfliplift; struct { // note: this assumes that you will be doing a big->little endian conversion // on this word, since wfliplift needs...

  • Page 13

    Feed laminate #define laminate_feed text("laminatefeed") input: no output: no data: no request status #define request_status text("requeststatus") input: no output: yes – printer status code see below data: no #define diag_err_start 0x4080 // diagnostic failure on comp nn (80h-ffh) #define diag_err_...

  • Page 14

    Request status without clearing error codes #define request_status_no_clear text("requeststatusnoclr") input: no output: yes – printer status code see above data: no get device id #define get_device_id text("getdeviceid") input: no output: yes – printer’s device id string data: no get data block #de...

  • Page 15

    Request features #define request_features text("requestfeatures") input: no output: yes – featuredata structure data: no typedef struct tagfeaturedata { word wcmdlen; char bcmdid[2]; word wfeatures; } featuredata, far *lpfeaturedata; wfeatures can be a combination of the following: #define feature_u...

  • Page 16

    #define move_flip_rotate_pos text("19") #define move_flip_pause_pos text("20") reprint #define reprint text("reprint") input: yes, number of times to reprint as an ascii number output: no data: no retry - number of times to retry communications #define retry text("retry") input: yes, number of times...

  • Page 17

    Mag options #define set_mag_options text("setmagoptions") input: yes – see below for mag_ codes output: yes - sometimes data: no notes: - the code should be concatenated on to the end of the string, so that the actual string is "setmagoptions0" or some such - some of the mag commands are not support...

  • Page 18

    Send smart card command data #define send_smartcard text("sendsmartcard") #define smartcard_data text("smartdata") input: yes, data size output: yes, same as receive_smartcard data: yes, a command to send to the smart card. Please use reg_binary for the type. Move a card to the probe position #defin...

  • Page 19

    Note: the following commands are to ask the language monitor to perform certain functions, they are not passed on to the printer. Set format string #define set_format_string text("setformatstring") #define format_string_data text("formatstringdata") input: no output: no data: yes, format_string_data...

  • Page 20

    - size needed is determined like one of the normal windows functions. P/n: 980552-001 zebra card solutions 6/15/2005 page 20 of 40 www.Zebracard.Com.

  • Page 21

    Set log path #define set_log_path text("setlogpath") #define log_file_path text("logfilepath") input: no output: no data: yes, log_file_path should be a reg_sz type that is the path to the log file to use for logging as a nul terminated unicode string. Notes: - this doesn't actually talk to the prin...

  • Page 22

    Set logging setting #define set_logging text("setlogging") #define logging_no_text bool_no_text #define logging_yes_text bool_yes_text input: yes output: no data: no notes: - this doesn't actually talk to the printer, it just sets the logging setting - this value is set per printer - the yes/no valu...

  • Page 23

    Set send uv file setting #define set_send_uv_file text("setsenduvfile") #define send_uv_file_no_text bool_no_text #define send_uv_file_yes_text bool_yes_text input: yes output: no data: no notes: - this doesn't actually talk to the printer, it just sets the send uv file state - this value is set per...

  • Page 24

    Set disable other buttons #define set_disable_other_button text("setdisableother") #define disable_other_button_no_text bool_no_text #define disable_other_button_yes_text bool_yes_text input: yes output: no data: no notes: - this doesn't actually talk to the printer, it just sets the send disable ot...

  • Page 25

    Assert printer name #define assert_printer_name text("asstname") input: yes output: no data: no notes: - this doesn't actually talk to the printer. - this is used by the ui to assert that the next getprinterdata() call will be intended for the printer in the name 3.5 setprinterdata setprinterdata is...

  • Page 26

    3.6 setprinterdataex registry holding area for messages. #define atl_message_key text("atlmessages") setprinterdataex is used to set data to be passed to the printer/driver. The atl_message_key refers to the location in the registry that the data is stored for retrieval by the language monitor. Dwor...

  • Page 27: 4  Printing A Document

    4 printing a document the startdoc function must be called first to let the printer driver know that a print is being started. After sending all the pages of image data, enddoc must be called to inform the driver that the print is complete. 4.1 startdoc definition int startdoc(hdc hdcprinter, docinf...

  • Page 28

    4.3 startpage, endpage definition prior to sending each page of image data, startpage must be called. After all data for a page is sent, endpage must be called. If you are creating a double- sided card the sequence of calls should be like this: startdoc(hdcprinter, &docinfo); startpage(hdcprinter); ...

  • Page 29

    4.5 setdibitstodevice definition the setdibitstodevice function sets the pixels in the specified rectangle on the device that is associated with the destination device context using color data from a device-independent bitmap (dib). Setdibitstodevice (hdc hdcprinter, int xdest, int ydest, dword dwwi...

  • Page 30

    Lpvbits pointer to dib color data stored as an array of bytes. For more information, see the following remarks section lpbmi. Lpbmi pointer to a bitmapinfo structure that contains information about the dib. Fucoloruse specifies whether the bmicolors member of the bitmapinfo structure contains explic...

  • Page 31

    Return values if the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call getlasterror. 4.7 output definition gdi calls this function when an application calls functions, such as lineto, rectangle, and ellipse. Word ...

  • Page 32

    Address of a rect structure that contains coordinates for the clipping rectangle. If this parameter is null, the clipping rectangle is the entire display surface. Return values are as follows: 1 function was successful. 0 unrecoverable error occurred. -1 function does not support the specified style...

  • Page 33

    4.9 devicebitmapbits definition this function will copy a dib to a device-specific bitmap. Void devicebitmapbits(lppdevice lpbitmap, word fget, word istart, word cscans, lpstr lpdibits, lpbitmapinfo lpbitmapinfo, lpdrawmode lpdrawmode, lpint lptranslate); lpbitmap address of a pbitmap structure that...

  • Page 34

    4.10 bitblt definition the bitblt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context. Bool bitblt(hdc hdcdest, int nxdest, int nydest, int nwidth, int nheight, hdc hdcsrc, int nxsr...

  • Page 35

    Mergecopy merges the colors of the source rectangle with the specified pattern by using the boolean and operator. Mergepaint merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the boolean or operator. Notsrccopy copies the inverted source rectang...

  • Page 36: 5  Magnetic Encoder Data

    5 magnetic encoder data magnetic encoder data is sent to the printer before the image is sent, but after the document is started with the startdoc escape command. The magnetic stripe data can be sent anytime after the startdoc escape command. If more than one card is being printed as a single docume...

  • Page 37

    Lstrcpy(lpszstring, "~2="); lstrcat(lpszstring, track2); cbstring = lstrlen(lpszstring); textout(hdcprinter,0,0, lpszstring, cbstring); lstrcpy(lpszstring, "~3="); lstrcat(lpszstring, track3); cbstring = lstrlen(lpszstring); textout(hdcprinter,0,0, lpszstring, cbstring); if (noimage) endpage(hdcprin...

  • Page 38

    5.3 iso versus aamva data format the two magnetic data formats supported by zebra p640 photo id printers are iso and aamva. The format of the data encoded is dependent on the selection made on the magnetic encoding property sheet under printing preferences. The following table defines the data lengt...

  • Page 39

    Table 1 table 2 table 3 0xh 1xh 2xh 3xh 0xh 1xh 2xh 3xh x0h sp 0 @ 1 p 00h 0 x0h sp 0 @ 6 p x1h ! 1 1 a q 01h 1 x1h ! 6 1 a q x2h " 1 2 b r 02h 2 x2h " 6 2 b r x3h # 3 3 c s 03h 3 x3h # 6 3 c s x4h $ 4 d t 04h 4 x4h $ 4 d t x5h % 4 5 e u 05h 5 x5h % 6 5 e u x6h & 1 6 f v 06h 6 x6h & 6 6 f v x7h ' 1 ...

  • Page 40

    5. These characters shall have the following meaning for this application: ; - start sentinel ? - end sentinel = - field separator warning! The start sentinel and end sentinel characters should not be sent to the windows printer driver as track data. The printer will automatically program the start ...