Qt and USB Thermal Printer
-
The
C56Sdk.h
file below:/**********************************************************************\ ** ** Copyright (c) 2004-2014 by ** HENGSTLER GmbH, Aldingen ** ** This software is furnished under a licence and may be used and ** copied only in accordance with the terms of such licence and ** with the inclusion of the above copyright notice. This software ** or any other copies thereof may not be provided or otherwise ** made available to any other person. No title to and ownership ** of the software is hereby transferred. ** ** The information in this software is subject to change without ** notice and should not be construed as a commitment by Hengstler. ** ** Module: C56SDK.h ** Facility: S684002 - Hengstler C56 Printer Driver for Windows XP/7/8/10 ** Component: C56 Software Development Kit (C56SDK) ** Version: R4-V2.01b-BETA-2014MAY04 ** Environment: Windows XP/7/8/10 ** Compiler: Visual Studio 2015 ** Abstract: Header description file of C56 Software Development Kit ** Notes: - ** History: R1-V1.02-2004DEC13 R1-XXX-HOR Added character set upload function C56Sdk_PmUploadCharset(...) ** R1-V1.02-2004DEC13 R1-XXX-HOR Added firmware upload function C56Sdk_PmUploadFirmware (...) ** .... ** R1-V1.05-2005JAN18 R1-XXX-HOR No modifications for this version ** R1-V1.06-2005JAN25 R1-XXX-HOR C56Sdk_PmGetProperties(...) added ** R1-V1.06-2005JAN25 R1-XXX-HOR C56Sdk_PmSetProperties(...) added ** R1-V1.06-2005JAN25 R1-XXX-HOR C56Sdk_PmIsSpoolerEmpty(...) added ** R1-V1.06-2005FEB04 R1-XXX-HOR C56Sdk_PmUploadBinary (...) added ** R1-V1.06-2005FEB08 R1-XXX-HOR C56Sdk_DmPrintDocument2(..) added ** R1-V1.06-2005FEB08 R1-XXX-HOR C56Sdk_PmGetSpoolerJobCount(..) added ** R1-V1.06-2005FEB08 R1-XXX-HOR C56Sdk_PmClearSpooler(..) added ** R1-V1.06-2005JAN25 R1-XXX-HOR C56Sdk_PsPrintoutPrinterInfo(..) added, replaces C56Sdk_PsPrintoutFirmwareVersion(..) ** R1-V1.06-2005FEB28 R1-XXX-HOR Added firmware upload function C56Sdk_PmUploadFirmware2 (...) ** R1-V1.07-2005MAR14 R1-XXX-HOR C56Sdk_PmGetJobNrConfirmed(...) added ** R1-V1.07-2005MAR14 R1-XXX-HOR C56PM_FONT_MAG_2X,C56PM_FONT_MAG_3X,C56PM_FONT_MAG_4X added to C56_PRINT_MODE ** R1-V1.07-2005MAR14 R1-XXX-HOR C56SR_STATE_VERSION added to C56_STATUS_REQUEST ** R1-V1.07-2005MAR14 R1-XXX-HOR C56Sdk_PmGetFwVersion(...) added ** R1-V1.08-2005MAY17 R1-XXX-HOR C56Sdk_PmUploadWideCharset(...) added ** R1-V1.08-2005MAY19 R1-XXX-HOR Type C56_WIDECHARSET_TYPE added ** R1-V1.08-2005MAY19 R1-XXX-HOR Function C56Sdk_PsPrintoutWideCharset(..) added ** R1-V1.08-2005MAY19 R1-XXX-HOR Function C56Sdk_DcAddWideCharset(..) added ** R1-V1.08-2005MAY19 R1-XXX-HOR Function C56Sdk_DcAddRegImgDef(..) parameter corrected ** R1-V1.08-2005MAY19 R1-XXX-HOR Function C56Sdk_DcAddDHisPreBurnFac(..) added ** R1-V1.08-2005JUL13 R1-XXX-HOR Function C56Sdk_DcAddBurnTimeCorr(...) added ** R1-V1.08-2005SEP12 R1-XXX-HOR Function C56Sdk_DcAddMultiStrobeFac(...) added ** R1-V1.08-2005SEP20 R1-XXX-HOR Function C56Sdk_DcAddBarCodeSubTitle(...) added ** R1-V1.08-2005SEP20 R1-XXX-HOR Function C56Sdk_PmUploadFirmware2(..) deleted ** R1-V1.08-2005SEP20 R1-XXX-HOR Function C56Sdk_PmUploadFirmware(..) extended with wFwVersion ** R1-V1.08-2005SEP20 R1-XXX-HOR Function C56Sdk_PmUploadCharset(..) extended with wFwVersion ** R1-V1.08-2005SEP20 R1-XXX-HOR Function C56Sdk_PmUploadWideCharset(..) extended with wFwVersion ** R1-V1.08-2006JAN09 R1-XXX-HOR Type C56_WIDECHARSET_TYPE extended with 20X20 STANDARD/KS5601 ** R1-V1.08-2006JAN12 R1-XXX-HOR Function C56Sdk_DcAddPositionStampSet(...) added ** R1-V1.08-2006JAN12 R1-XXX-HOR Function C56Sdk_DcAddPositionStampFeed(...) added ** R1-V1.08-2006MAR15 R1-XXX-HOR Function C56Sdk_PioPrinterOpen(...) added ** R1-V1.08-2006MAR15 R1-XXX-HOR Function C56Sdk_PioPrinterClose(...) added ** R1-V1.08-2006MAR15 R1-XXX-HOR Function C56Sdk_PioPrinterRead(...) added ** R1-V1.08-2006MAR15 R1-XXX-HOR Function C56Sdk_PioPrinterReadClear(...) added ** R1-V1.08-2006MAR15 R1-XXX-HOR Function C56Sdk_PioPrinterWrite(...) added ** R1-V1.08-2006APR11 R1-XXX-HOR Function C56Sdk_PmUploadFirmware(...) removed ** R1-V1.08-2006APR11 R1-XXX-HOR Function C56Sdk_PmUploadCharset(...) removed ** R1-V1.08-2006APR11 R1-XXX-HOR Function C56Sdk_PmUploadWideCharset(...) removed ** R1-V1.08-2006APR11 R1-XXX-HOR Function C56Sdk_PmUploadBinary(...) removed ** R1-V1.08-2006APR12 R1-XXX-HOR Function C56Sdk_DcAddPositionStampSet(...) removed ** R1-V1.08-2006APR12 R1-XXX-HOR Function C56Sdk_DcAddPositionStampFeed(...) removed ** R1-V1.08-2006APR20 R1-XXX-HOR Function C56Sdk_DcAddFlashWriteProtect(...) added ** R1-V1.08-2006APR20 R1-XXX-HOR Function C56Sdk_DcAddCutterCommand(...) added ** R1-V1.08-2006APR20 R1-XXX-HOR Function C56Sdk_DcAddHostControlCommand(...) added ** R1-V1.08-2006APR25 R1-XXX-HOR Function C56Sdk_DmGetDocumentData(...) added ** R1-V1.08-2006MAY18 R1-XXX-HOR Function C56_STATUS_RESPONSE extended with C56SR_PRINTER_CUSTFLAG1/2 ** R1-V1.08-2007JAN31 R1-XXX-HOR Initial release #1 ** ----------------------------------------------------- ** R2-V1.09-2008MAY31 R2-008-HOR Enumeration C56_STATUS_RESPONSE extended with C56SR_PRINTER_PAPERINCHUTE ** R2-V1.09-2008MAY31 R2-XXX-HOR Release #2 - No modifications ** ----------------------------------------------------- ** R3-V2.00a-2011MAY30 R3-005-HOR ** Complete driver package migrated to VS2010 and windows 7 (64 and 32 bits) and windows XP (32 bits). ** ----------------------------------------------------- ** R4-V2.01a-2013MAR14 R4-001-HOR ** Complete driver package migrated to windows 7+8 (64 and 32 bits) and windows XP (32 bits). ** R4-V2.01b-2014MAY04 R4-002-HOR ** Failure in C56Sdk_PmGetFwVersion(..) regarding buffer size determination resolved. ** R4-V2.01 / 2017APR27 / HOR / M-R4-003-HOR ** Complete driver package converted to VS2015 and adapted to Windows XP/7/8/10 32/64 bit ** R4-V2.01 / 2017APR27 / HOR / 4th RELEASE - FINAL ** ----------------------------------------------------- ** R5-V2.02 / 2018OCT31 / HOR / 5th RELEASE - FINAL ** ----------------------------------------------------- ** R6-V2.03 / 2019JAN02 / HOR / 6th RELEASE - FINAL ** ----------------------------------------------------- ** R7-V2.04 / 2019JUL15 / HOR / 7th RELEASE - FINAL ** ----------------------------------------------------- ** \**********************************************************************/ #ifndef __C56SDK_H #define __C56SDK_H /* ** INCLUDES */ #include <stdarg.h> #include <stdlib.h> /* ** MACROS */ //-- For graphic printout with C56Sdk_DcAddGraphicsLine(..) these macros might be usefull #define N_DOTLINE_DOTS 448 /* Nr of dots in a C56 dot line */ #define N_DOTLINE_BYTES (N_DOTLINE_DOTS / 8) /* Nr of bytes in a C56 dot line */ #define M_DOTLINE_SET_DOT(DOTLINE,DOTNR,STATE) \ DOTLINE[(DOTNR)/8] = (STATE) ? DOTLINE[(DOTNR)/8] | (1 << (7 - ((DOTNR) % 8))) \ : DOTLINE[(DOTNR)/8] & ~(1 << (7 - ((DOTNR) % 8))); \ /* Set bits in a dot line */ //-- C-56 printer I/O error codes from GetLastError() #define C56PIO_ERR_OUTOFMEMORY 0x40000001 /* Error code indicating out of memory */ #define C56PIO_ERR_INVALIDPARAMETER 0x40000003 /* Error code indicating invalid parameter */ #define C56PIO_ERR_OPENPRINTERFAILED 0x40000005 /* Error code indicating open printer failed */ #define C56PIO_ERR_READPRINTERFAILED 0x40000006 /* Error code indicating read printer failed */ #define C56PIO_ERR_WRITEPRINTERFAILED 0x40000007 /* Error code indicating write printer failed */ #define C56PIO_ERR_UNKNOWNPRINTER 0x40000008 /* Error code indicating unknown printer */ /* ** TYPES */ //-- C-56 status request bitmask typedef enum { C56SR_STATE_VERSION = 0x01 // Only for version request , C56SR_STATE_ONOFFLINE = 0x02 // Use C56SR_STATE_AUTO instead , C56SR_STATE_ERROR = 0x04 // Use C56SR_STATE_AUTO instead , C56SR_STATE_PAPERFEED = 0x10 // Use C56SR_STATE_AUTO instead , C56SR_STATE_AUTO = 0x16 } C56_STATUS_REQUEST; //.. Note that C56SR_STATE_VERSION is available from firmware V2.0X //-- C-56 status response bitmask typedef enum { C56SR_PRINTER_PAPERINCHUTE = 0x00000002 // Paper is detected in the chute , C56SR_PRINTER_TEMPALERT = 0x00000004 // Temperature exceeds 70° all printout stopped , C56SR_PRINTER_PRINTOUTLOST = 0x00000008 // Run out of paper during printout , C56SR_PRINTER_PAPERJAM = 0x00000010 // Retract of paper failed due to no sensor detect , C56SR_PRINTER_PAPERLOW = 0x00000020 // Blackmark detected, raised until paper remove-feed , C56SR_PRINTER_OUTOFPAPER = 0x00000040 // Outofpaper detected , C56SR_PRINTER_POWERON = 0x00000080 // Poweron detected , C56SR_PRINTER_CUSTFLAG1 = 0x00002000 // Customer specific flag #1 , C56SR_PRINTER_CUSTFLAG2 = 0x00004000 // Customer specific flag #2 } C56_STATUS_RESPONSE; //-- C-56 printout rotation type typedef enum { C56RT_TEXT = 0x30 // Rotation of text in [0,90,180,270] degrees , C56RT_BITMAP = 0x31 // Rotation of registered bitmaps in [0,90,180,270] degrees , C56RT_BARCODE = 0x33 // Rotation of barcode in [0,90] degrees } C56_ROTATE_TYPE ; //-- C-56 prinout rotation direction typedef enum { C56RD_0_DEG = 0x0 // Rotation of 0 degrees , C56RD_90_DEG = 0x1 // Rotation of 90 degrees , C56RD_180_DEG = 0x2 // Rotation of 180 degrees , C56RD_270_DEG = 0x3 // Rotation of 270 degrees } C56_ROTATE_DIRECTION; //-- C-56 print speed bitmask (Speed in mm/second -> (130 / 4) * (0x65 - Speed)) // 32,5 * (0x65 - Speed) typedef enum { C56PS_HIGH = 0x60 // 162,5 mm per second , C56PS_MEDIUM_1 = 0x61 // 130 mm per second , C56PS_MEDIUM_2 = 0x62 // 97,5 mm per second , C56PS_LOW = 0x63 // 65 mm per second } C56_PRINT_SPEED; //-- C-56 print mode bitmask typedef enum { C56PM_FONT_08X16 = 0x00 // /-------------- , C56PM_FONT_12X24 = 0x01 // | SELECT ONLY , C56PM_FONT_16X16 = 0x02 // | ONE OF THESE , C56PM_FONT_24X24 = 0x03 // \-------------- , C56PM_FONT_MAG_2X = 0x04 // /-------------- , C56PM_FONT_MAG_3X = 0x08 // | SELECT ONLY ONE , C56PM_FONT_MAG_4X = 0x0C // \-------------- , C56PM_DOUBLE_WIDTH = 0x10 , C56PM_DOUBLE_HEIGHT = 0x20 } C56_PRINT_MODE; //.. Note that C56PM_FONT_MAG_2X, C56PM_FONT_MAG_3X, C56PM_FONT_MAG_4X is available from firmware V2.0X //-- C-56 print quality typedef enum { C56PQ_LOW = 0x00 // 220 us burn time , C56PQ_HIGH = 0x01 // 325 us burn time } C56_PRINT_QUALITY; //-- C-56 detection function flags typedef enum { C56DF_PAPER_NEAR_END = 0x20 , C56DF_PAPER_OUT = 0x40 } C56_DETECTION_FUNCTION; //-- C-56 barcode print types typedef enum { C56BT_UPCA = 0x41 // 65d - #Char [11..12] - Value of d [48..57} , C56BT_UPCE = 0x42 // 66d - #Char [11..12] - Value of d [48..57} , C56BT_EAN13 = 0x43 // 67d - #Char [12..13] - Value of d [48..57} , C56BT_EAN8 = 0x44 // 68d - #Char [07..08] - Value of d [48..57} , C56BT_CODE39 = 0x45 // 69d - #Char variable - Value of d // [space,'$','%'.'*'.'+'.'-','.',/,'0'~'9','A'~'Z'] , C56BT_ITF = 0x46 // 70d - #Char variable - Value of d Even nr. 0-9 , C56BT_CODABAR = 0x47 // 71d - #Char variable - Value of d // ['0'~'9','-','$'.':'.'/','-','+','A'~'D'] , C56BT_CODE128 = 0x49 // 73d - #Char variable - Value of d [0..105} } C56_BARCODE_TYPES; //-- C-56 registration image print mode typedef enum { C56RIPM_NORMAL_1 = 0x00 , C56RIPM_DOUBLE_WIDTH_1 = 0x01 , C56RIPM_DOUBLE_HEIGHT_1 = 0x02 , C56RIPM_DOUBLE_WIDTH_HEIGHT_1 = 0x03 , C56RIPM_NORMAL_2 = 0x30 , C56RIPM_DOUBLE_WIDTH_2 = 0x31 , C56RIPM_DOUBLE_HEIGHT_2 = 0x32 , C56RIPM_DOUBLE_WIDTH_HEIGHT_2 = 0x33 } C56_REG_IMG_PRINT_MODE; //-- C-56 character sets type typedef enum { C56CST_PRIMARY // Primary character set , C56CST_SECONDARY // Secondary character set (registered) } C56_CHARSET_TYPE; // C56 character set types //-- C-56 character sets size (per character set 2 sizes) typedef enum { C56CSS_08X16 // 08x16 character set , C56CSS_12X24 // 12x24 character set } C56_CHARSET_SIZE; // C56 character set upload sizes //-- C-56 job status typedef enum { C56JS_IDLE = 0x00 // Job is idle , C56JS_SPOOLING = 0x01 // Job is being spooled , C56JS_SPOOLED = 0x02 // Job is spooled , C56JS_PRINTING = 0x04 // Job is being send to printer , C56JS_PRINTED = 0x08 // Job has been send to printer , C56JS_CONFIRMED = 0x10 // Job is done } C56_JOBSTATUS; // Job status enumeration //-- C-56 Wide charset types typedef enum { C56WCST_NONE = 0 // Wide charset disabled , C56WCST_24X24_STANDARD = 1 // Standard charset, adressable 0xE000..0xFFFF , C56WCST_24X24_GB2312 = 2 // Chinese charset, adressable 0xA000..0xFFFF , C56WCST_20X20_STANDARD = 3 // Standard charset, adressable 0xE000..0xFFFF , C56WCST_20X20_KS5601 = 4 // Korean charset, adressable 0xA000..0xFFFF , N_C56_WIDECHARSET_TYPE // Total number of defined wide charsets , C56WCST_DEFAULT = 7 // Default wide font selection (parameter only) } C56_WIDECHARSET_TYPE; // C56 wide charset types (2 bytes addressable) /* ** FUNCTIONS */ //-- C-56 Printer management functions HANDLE WINAPI C56Sdk_PmStartEnumPrinter (VOID); VOID WINAPI C56Sdk_PmEndEnumPrinter (HANDLE hPrinter); LPSTR WINAPI C56Sdk_PmEnumPrinter (HANDLE hPrinter, BOOL fReset); BOOL WINAPI C56Sdk_PmEnumPrinterName (HANDLE hPrinter, char * pszBuff, WORD wBuffSize, BOOL fReset); LPSTR WINAPI C56Sdk_PmGetDriverName (VOID); BOOL WINAPI C56Sdk_PmIsPrinterName (LPSTR lpszPrinter); //-- C-56 Registry settings functions (to get/set registry settings) INT WINAPI C56Sdk_PmGetProperties (LPSTR lpszPrinter, PSTR pszSettings, INT iSize); INT WINAPI C56Sdk_PmSetProperties (LPSTR lpszPrinter, PSTR pszSettings, INT iSize); //-- C-56 Job managent functions (of job number 0..30) C56_JOBSTATUS WINAPI C56Sdk_PmGetJobStatus (LPSTR lpszPrinter, BYTE bJobNr); BOOL WINAPI C56Sdk_PmSetJobStatus (LPSTR lpszPrinter, BYTE bJobNr, C56_JOBSTATUS eJobStatus); BYTE WINAPI C56Sdk_PmGetJobNr (LPSTR lpszPrinter); //-- C-56 Printer status (or status related) functions DWORD WINAPI C56Sdk_PmGetPrinterStatus (LPSTR lpszPrinter, PDWORD pdwAgeMs); BYTE WINAPI C56Sdk_PmGetJobNrConfirmed (LPSTR lpszPrinter); INT WINAPI C56Sdk_PmGetFwVersion (LPSTR lpszPrinter, LPSTR pszVersion, INT nSize); //.. Note that function 56Sdk_PmGetFwVersion is available from C-56 FW V2.0X //-- C-56 Printer spooler functions BOOL WINAPI C56Sdk_PmIsSpoolerEmpty (LPSTR lpszPrinter); INT WINAPI C56Sdk_PmGetSpoolerJobCount (LPSTR lpszPrinter); BOOL WINAPI C56Sdk_PmClearSpooler (LPSTR lpszPrinter); //-- C-56 Document manager functions HANDLE WINAPI C56Sdk_DmStartDocument (LPSTR lpszPrinter, LPSTR lpszDocument); BOOL WINAPI C56Sdk_DmAddDocumentData (HANDLE hDocument, LPBYTE lpData, DWORD dwSize); LPBYTE WINAPI C56Sdk_DmGetDocumentData (HANDLE hDocument, DWORD * pdwSize, INT iBlock); BYTE WINAPI C56Sdk_DmPrintDocument (HANDLE hDocument); BOOL WINAPI C56Sdk_DmPrintDocument2 (HANDLE hDocument); C56_JOBSTATUS WINAPI C56Sdk_DmGetDocumentStatus (HANDLE hDocument); VOID WINAPI C56Sdk_DmEndDocument (HANDLE hDocument); //-- C-56 Emulation command set functions BOOL WINAPI C56Sdk_DcAddEndOfPage (HANDLE hDocument); BOOL WINAPI C56Sdk_DcAddPrintSpeed (HANDLE hDocument, C56_PRINT_SPEED eSpeed); BOOL WINAPI C56Sdk_DcAddPrintSpeedExtended (HANDLE hDocument, unsigned char uiPrintSpeedMmSec); BOOL WINAPI C56Sdk_DcAddMotorExcitation (HANDLE hDocument, unsigned char ubTimeSec); BOOL WINAPI C56Sdk_DcAddPrintQuality (HANDLE hDocument, C56_PRINT_QUALITY eQuality); BOOL WINAPI C56Sdk_DcAddImprEnergyCorrection (HANDLE hDocument, unsigned char ubCorrection); BOOL WINAPI C56Sdk_DcAddLineSpacing (HANDLE hDocument, unsigned char ubDotLines); BOOL WINAPI C56Sdk_DcAddPageLength (HANDLE hDocument, unsigned char ubLines); BOOL WINAPI C56Sdk_DcAddPrintMode (HANDLE hDocument, C56_PRINT_MODE eMode); BOOL WINAPI C56Sdk_DcAddLinePitch (HANDLE hDocument, unsigned char ubDotLines); BOOL WINAPI C56Sdk_DcAddLinePitch16Inch (HANDLE hDocument); BOOL WINAPI C56Sdk_DcAddHorizontalTabPos (HANDLE hDocument, unsigned int uiTab1, unsigned int uiTab2, unsigned int uiTab3, unsigned int uiTab4, unsigned int uiTab5 ,unsigned int uiTab6, unsigned int uiTab7, unsigned int uiTab8, unsigned int uiTab9, unsigned int uiTab10); BOOL WINAPI C56Sdk_DcAddEnableReversePrinting (HANDLE hDocument); BOOL WINAPI C56Sdk_DcAddDisableReversePrinting (HANDLE hDocument); BOOL WINAPI C56Sdk_DcAddReversePrinting (HANDLE hDocument, BOOL fEnabled); BOOL WINAPI C56Sdk_DcAddHorizontalTab (HANDLE hDocument, int siAmount); BOOL WINAPI C56Sdk_DcAddLineFeed (HANDLE hDocument, int siAmount); BOOL WINAPI C56Sdk_DcAddFormFeed (HANDLE hDocument, int siAmount); BOOL WINAPI C56Sdk_DcAddFeedReduction (HANDLE hDocument, unsigned char ubPercent); BOOL WINAPI C56Sdk_DcAddFeedLengths (HANDLE hDocument, unsigned char ubDotLineInsert, unsigned char ubDotLineOutOfPaper); BOOL WINAPI C56Sdk_DcAddPrinterReset (HANDLE hDocument); BOOL WINAPI C56Sdk_DcAddForwardPaperFeed (HANDLE hDocument, unsigned char ubDotLines); BOOL WINAPI C56Sdk_DcAddBackwardPaperFeed (HANDLE hDocument, unsigned char ubDotLines); BOOL WINAPI C56Sdk_DcAddRotation (HANDLE hDocument, C56_ROTATE_TYPE eType, C56_ROTATE_DIRECTION eDirection); BOOL WINAPI C56Sdk_DcAddForwardLineFeed (HANDLE hDocument, unsigned char ubLines); BOOL WINAPI C56Sdk_DcAddBackwardLineFeed (HANDLE hDocument, unsigned char ubLines); BOOL WINAPI C56Sdk_DcAddUpsideDownPrinting (HANDLE hDocument, BOOL fEnabled); BOOL WINAPI C56Sdk_DcAddDetectionFunction (HANDLE hDocument, C56_DETECTION_FUNCTION eFunction); BOOL WINAPI C56Sdk_DcAddBarCodeWidth (HANDLE hDocument, unsigned char ubDotsNarrow, unsigned char ubDotsWide); BOOL WINAPI C56Sdk_DcAddBarCodeHeight (HANDLE hDocument, unsigned char ubDots); BOOL WINAPI C56Sdk_DcAddBarCodeWidthMagnification (HANDLE hDocument, unsigned char ubMultiplier); BOOL WINAPI C56Sdk_DcAddText (HANDLE hDocument, PSTR pszTxt); BOOL WINAPI C56Sdk_DcAddGraphicsLine (HANDLE hDocument, unsigned char * pubDotLine, int siDots); BOOL WINAPI C56Sdk_DcAddCompressedGraphicsLine (HANDLE hDocument, unsigned char * pubDotLine, int siDots); BOOL WINAPI C56Sdk_DcAddRepeatGraphicsLine (HANDLE hDocument, unsigned char nRepeat); BOOL WINAPI C56Sdk_DcAddPrintInfo (HANDLE hDocument); BOOL WINAPI C56Sdk_DcAddSoftReset (HANDLE hDocument); BOOL WINAPI C56Sdk_DcAddPrintInfoEnabled (HANDLE hDocument, BOOL fOn); BOOL WINAPI C56Sdk_DcAddReset (HANDLE hDocument); BOOL WINAPI C56Sdk_DcAddBarCodePrint (HANDLE hDocument, C56_BARCODE_TYPES eType, unsigned char ubNrOfChar, unsigned char * pubData, BOOL fFilter); BOOL WINAPI C56Sdk_DcAddStatusRequest (HANDLE hDocument, C56_STATUS_REQUEST eRequest); BOOL WINAPI C56Sdk_DcAddExtRegCharSet (HANDLE hDocument, BOOL fEnabled); BOOL WINAPI C56Sdk_DcAddExtRegCharDef (HANDLE hDocument, C56_PRINT_MODE eMode, unsigned char ubStart, unsigned char ubEnd, unsigned char * pubCharset); BOOL WINAPI C56Sdk_DcAddExtRegCharDel (HANDLE hDocument, C56_PRINT_MODE eMode, unsigned char ubStart, unsigned char ubEnd); BOOL WINAPI C56Sdk_DcAddExtRegCharClr (HANDLE hDocument, C56_PRINT_MODE eMode); BOOL WINAPI C56Sdk_DcAddRegImgDef (HANDLE hDocument, unsigned char ubId, unsigned char ubWidth, unsigned int uiHeight, unsigned char * pubImg); BOOL WINAPI C56Sdk_DcAddRegImgClr (HANDLE hDocument, unsigned char ubId); BOOL WINAPI C56Sdk_DcAddRegImgPrint (HANDLE hDocument, unsigned char ubId, C56_REG_IMG_PRINT_MODE eMode); BOOL WINAPI C56Sdk_DcAddLeftMargin (HANDLE hDocument, unsigned int uiDots); BOOL WINAPI C56Sdk_DcAddMarkDetectionExecution (HANDLE hDocument); BOOL WINAPI C56Sdk_DcAddBlackMarkSize (HANDLE hDocument, unsigned int uiMin, unsigned int uiMax); BOOL WINAPI C56Sdk_DcAddWideCharset (HANDLE hDocument, C56_WIDECHARSET_TYPE eType); BOOL WINAPI C56Sdk_DcAddDHisPreBurnFac (HANDLE hDocument, unsigned char ubDhisBurnFac); BOOL WINAPI C56Sdk_DcAddMultiStrobeFac (HANDLE hDocument, unsigned char ubMultiStrobeFac); BOOL WINAPI C56Sdk_DcAddBurnTimeCorr (HANDLE hDocument, char sbCorrMin30DegcUs, char sbCorrMin20DegcUs, char sbCorrMin10DegcUs, char sbCorrZeroDegcUs ,char sbCorrPlu10DegcUs, char sbCorrPlu20DegcUs, char sbCorrPlu30DegcUs, char sbCorrPlu40DegcUs ,char sbCorrPlu50DegcUs, char sbCorrPlu60DegcUs, char sbCorrPlu70DegcUs); BOOL WINAPI C56Sdk_DcAddEscapeCmd (HANDLE hDocument, PSTR pszEscCmd); BOOL WINAPI C56Sdk_DcAddBarCodeSubTitle (HANDLE hDocument, BOOL fEnable, unsigned char ubFont); BOOL WINAPI C56Sdk_DcAddFlashWriteProtect (HANDLE hDocument, BOOL fEnable); BOOL WINAPI C56Sdk_DcAddCutterCommand (HANDLE hDocument, BOOL fFullCut, BOOL fPresent, WORD wFeedLines); BOOL WINAPI C56Sdk_DcAddHostControlCommand (HANDLE hDocument, BYTE ubCommand, DWORD dwParam); //-- C-56 Printer properties functions BOOL WINAPI C56Sdk_DmAddDocumentInitialSettings (HANDLE hDocument); BOOL WINAPI C56Sdk_DmAddDocumentFinalSettings (HANDLE hDocument); //-- C-56 Internal functions (Commands used in SDK only, not for public use!!) BOOL WINAPI C56Sdk_DcAddEndOfDocument (HANDLE hDocument); BOOL WINAPI C56Sdk_DcAddParameter (HANDLE hDocument, unsigned char ubParameter); //-- C-56 General purpose functions int WINAPI C56Sdk_GpCalcEstBurnTime (C56_PRINT_QUALITY ePrintQuality, int siImpressedEnergy, int siPhTempC); BOOL WINAPI C56Sdk_GpExpandStatus (DWORD dwStatus, C56_STATUS_RESPONSE * peResponse, int * psiPhTempC, int * psiPaperState, unsigned char * pubParameter); BOOL WINAPI C56Sdk_GpGetVersion (PSTR pszVersion, DWORD dwSize); //-- C-56 Sample printout functions BOOL WINAPI C56Sdk_PsPrintoutFirmwareVersion (LPSTR lpszPrinter); // OBSOLETE, use C56Sdk_PsPrintoutPrinterInfo(..) instead BOOL WINAPI C56Sdk_PsPrintoutPrinterInfo (LPSTR lpszPrinter); BOOL WINAPI C56Sdk_PsPrintoutCharset (LPSTR lpszPrinter, C56_CHARSET_TYPE eType); BOOL WINAPI C56Sdk_PsPrintoutWideCharset (LPSTR lpszPrinter, C56_WIDECHARSET_TYPE eType, BOOL fIndexed, INT iMagnify); BOOL WINAPI C56Sdk_PsPrintoutPaperfeed (LPSTR lpszPrinter, int nDotLines); //-- C-56 Printer I/O functions (non spooled) HANDLE WINAPI C56Sdk_PioPrinterOpen (LPSTR pszPrinterName, DWORD dwTimeOutMs); DWORD WINAPI C56Sdk_PioPrinterRead (HANDLE hPrinterIo, unsigned char * pubData, DWORD nData, DWORD dwTimeOutMs); BOOL WINAPI C56Sdk_PioPrinterReadClear (HANDLE hPrinterIo); DWORD WINAPI C56Sdk_PioPrinterWrite (HANDLE hPrinterIo, unsigned char * pubData, DWORD nData, DWORD dwTimeOutMs); BOOL WINAPI C56Sdk_PioPrinterClose (HANDLE hPrinterIo); BOOL WINAPI C56Sdk_PioPrintImage (HANDLE hPrinterIo, LPSTR pszImageFile, DWORD dwTimeOutMs); BOOL WINAPI C56Sdk_PioSendFile (HANDLE hPrinterIo, LPSTR pszPrintFile, DWORD dwTimeOutMs); /* ** VARIABLES */ #endif
When I try run my app I got problems:
C:\Users\LENOVO\Documents\qt_proj\AutoCash\c56sdkapp.cpp:-1: błąd: undefined reference to `C56Sdk_PmStartEnumPrinter@0'
C:\Users\LENOVO\Documents\qt_proj\AutoCash\c56sdkapp.cpp:-1: błąd: undefined reference to `C56Sdk_PmEnumPrinter@8'
collect2.exe: error: ld returned 1 exit status
@Damian7546 said in Qt and USB Thermal Printer:
When I try run my app I got problems
No, you are not getting as far as running your program at all, are you? The error states it comes from
ld
, which is the linker....You will indeed need the
extern "C" { #include "C56Sdk.h" }
to have that
extern "C"
around it, becauseC56Sdk.h
is in C not C++.You do not say, but since you are using
ld
I would guess you are using MinGW under Windows to compile/link? Meanwhile your early screenshot showsC56Sdk.lib
&C56Sdk_x64.lib
files. But I thought MinGW uses.a
files for libraries? *Are you sure that these libraries aren't for MSVC not MinGW? It would not surprise me if a manufacturer only supplied for MSVC and not MinGW?Since all of this is down to your SDK and not Qt, you should be looking there for solutions. We don't know. Have you read through what the manufacturer's SDK says about which compiler to use?
-
@Damian7546 said in Qt and USB Thermal Printer:
When I try run my app I got problems
No, you are not getting as far as running your program at all, are you? The error states it comes from
ld
, which is the linker....You will indeed need the
extern "C" { #include "C56Sdk.h" }
to have that
extern "C"
around it, becauseC56Sdk.h
is in C not C++.You do not say, but since you are using
ld
I would guess you are using MinGW under Windows to compile/link? Meanwhile your early screenshot showsC56Sdk.lib
&C56Sdk_x64.lib
files. But I thought MinGW uses.a
files for libraries? *Are you sure that these libraries aren't for MSVC not MinGW? It would not surprise me if a manufacturer only supplied for MSVC and not MinGW?Since all of this is down to your SDK and not Qt, you should be looking there for solutions. We don't know. Have you read through what the manufacturer's SDK says about which compiler to use?
@JonB I do not have any documentation to this library. I did a test. @JonBI you are right. I changed toolkit to MSVC and application has been run. But when I create constructor and call test functions in main.cpp file:
#include <QGuiApplication> #include <QQmlApplicationEngine> #include "c56sdkapp.h" int main(int argc, char *argv[]) { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QGuiApplication app(argc, argv); //test C56SdkApp test; test.AvailablePrinters(); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); }
, I got "system error" -> Code execution cannot continue because C56Sdk.dll was not found....
-
@JonB I do not have any documentation to this library. I did a test. @JonBI you are right. I changed toolkit to MSVC and application has been run. But when I create constructor and call test functions in main.cpp file:
#include <QGuiApplication> #include <QQmlApplicationEngine> #include "c56sdkapp.h" int main(int argc, char *argv[]) { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QGuiApplication app(argc, argv); //test C56SdkApp test; test.AvailablePrinters(); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); }
, I got "system error" -> Code execution cannot continue because C56Sdk.dll was not found....
@Damian7546
Your application has to be able to find theC56Sdk.dll
at runtime. Either the directory it is in must be added onto yourPATH
environment variable prior to running your executable, or copy it to the directory where your Qt executable is.I do not see a
C56Sdk.dll
in theSdk
folder you showed. I do not thinkC56ApiWrapperDotNet.dll
will do it, plus if that is required you are out of luck because that presumably requires MS .NET and Qt is not a .NET assembly. Is there someC56Sdk.dll
anywhere in the supplied SDK folder hierarchy? -
@Damian7546
Your application has to be able to find theC56Sdk.dll
at runtime. Either the directory it is in must be added onto yourPATH
environment variable prior to running your executable, or copy it to the directory where your Qt executable is.I do not see a
C56Sdk.dll
in theSdk
folder you showed. I do not thinkC56ApiWrapperDotNet.dll
will do it, plus if that is required you are out of luck because that presumably requires MS .NET and Qt is not a .NET assembly. Is there someC56Sdk.dll
anywhere in the supplied SDK folder hierarchy?@JonB said in Qt and USB Thermal Printer:
@Damian7546
Your application has to be able to find the C56Sdk.dll at runtime. Either the directory it is in must be added onto your PATH environment variable prior to running your executable, or copy it to the directory where your Qt executable is.I copied my SKD directory
Lib\Printer_SDK
from project directory toC:\Users\LENOVO\Documents\qt_proj\build-AutoCash-Desktop_Qt_5_15_2_MSVC2019_32bit-Release
but still it can't find ....@JonB said in Qt and USB Thermal Printer:
I do not see a C56Sdk.dll in the Sdk folder you showed. I do not think C56ApiWrapperDotNet.dll will do it, plus if that is required you are out of luck because that presumably requires MS .NET and Qt is not a .NET assembly. Is there some C56Sdk.dll anywhere in the supplied SDK folder hierarchy?
In my qt project directory I have a SDK in
Lib\Printer_SDK
where are four files:
C56ApiWrapperDotNet.dll
C56Sdk.h
C56Sdk.lib
C56Sdk_x64.lib
-
@JonB said in Qt and USB Thermal Printer:
@Damian7546
Your application has to be able to find the C56Sdk.dll at runtime. Either the directory it is in must be added onto your PATH environment variable prior to running your executable, or copy it to the directory where your Qt executable is.I copied my SKD directory
Lib\Printer_SDK
from project directory toC:\Users\LENOVO\Documents\qt_proj\build-AutoCash-Desktop_Qt_5_15_2_MSVC2019_32bit-Release
but still it can't find ....@JonB said in Qt and USB Thermal Printer:
I do not see a C56Sdk.dll in the Sdk folder you showed. I do not think C56ApiWrapperDotNet.dll will do it, plus if that is required you are out of luck because that presumably requires MS .NET and Qt is not a .NET assembly. Is there some C56Sdk.dll anywhere in the supplied SDK folder hierarchy?
In my qt project directory I have a SDK in
Lib\Printer_SDK
where are four files:
C56ApiWrapperDotNet.dll
C56Sdk.h
C56Sdk.lib
C56Sdk_x64.lib
@Damian7546
Then if the error saysCode execution cannot continue because C56Sdk.dll was not found....
, you don't have that DLL anywhere (and you have looked thoroughly through whatever the download contained), nor even the sources to build it, and you claim there is no documentation for this SDK from the supplier, what would you like me to say here or anywhere else you are asking about this on the web? -
@JonB sorry, my mistake... I was still searching files with *.lib extensions instead *.dll .
In other directory from manufacturer : ("samples") I copied all *.dll files to directory where my Qt app is executable, and success :)
Below required libraries :
C56Sdk.dll
C56Tb.dll
-
@JonB sorry, my mistake... I was still searching files with *.lib extensions instead *.dll .
In other directory from manufacturer : ("samples") I copied all *.dll files to directory where my Qt app is executable, and success :)
Below required libraries :
C56Sdk.dll
C56Tb.dll
@Damian7546
That's why I said you needed to look carefully! :)
Well done! -
@Damian7546 said in Qt and USB Thermal Printer:
When I try run my app I got problems
No, you are not getting as far as running your program at all, are you? The error states it comes from
ld
, which is the linker....You will indeed need the
extern "C" { #include "C56Sdk.h" }
to have that
extern "C"
around it, becauseC56Sdk.h
is in C not C++.You do not say, but since you are using
ld
I would guess you are using MinGW under Windows to compile/link? Meanwhile your early screenshot showsC56Sdk.lib
&C56Sdk_x64.lib
files. But I thought MinGW uses.a
files for libraries? *Are you sure that these libraries aren't for MSVC not MinGW? It would not surprise me if a manufacturer only supplied for MSVC and not MinGW?Since all of this is down to your SDK and not Qt, you should be looking there for solutions. We don't know. Have you read through what the manufacturer's SDK says about which compiler to use?
@JonB said in Qt and USB Thermal Printer:
You do not say, but since you are using ld I would guess you are using MinGW under Windows to compile/link? Meanwhile your early screenshot shows C56Sdk.lib & C56Sdk_x64.lib files. But I thought MinGW uses .a files for libraries? *Are you sure that these libraries aren't for MSVC not MinGW? It would not surprise me if a manufacturer only supplied for MSVC and not MinGW?
When you want to use it with Qt then you have to use the Qt version compiled against MSVC since it looks like the interface only provides a MSVC import lib (C56sdk.lib).
Not that I said it in my first post...
-
@Damian7546 said in Qt and USB Thermal Printer:
It possible using this library in qtcreator ?
Why not? QtCreator is just an IDE, nothing more.
When your library has a c(++) interface (as it loks) you can use this. When you want to use it with Qt then you have to use the Qt version compiled against MSVC since it looks like the interface only provides a MSVC import lib (C56sdk.lib).
You have to read the API documentation for the printer on how to use it.@Christian-Ehrlicher said in Qt and USB Thermal Printer:
When you want to use it with Qt then you have to use the Qt version compiled against MSVC since it looks like the interface only provides a MSVC import lib (C56sdk.lib).
Yep, didn't see you had already written this :)
-
The big problem will be lack of description function in this library.
Below is a example send text to printer:
void CC56SdkDemo01DlgMain::OnBnPrintout() { CComboBox * pPrinterList; // Pointer to combo box item //-- Get printer list (dialog item combo box) if ((pPrinterList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINTER_LIST))) != NULL) { INT iPrinterSel; // Selected printer //-- Determine selected printer if ((iPrinterSel = pPrinterList->GetCurSel()) != CB_ERR) { LPSTR lpszPrinter = NULL; // Printer name //-- Allocate memory for this printer and get name from combo box if ( ((lpszPrinter = (LPSTR) malloc(pPrinterList->GetLBTextLen(iPrinterSel)+1)) != NULL) && (pPrinterList->GetLBText(iPrinterSel, lpszPrinter) != CB_ERR) ) { HANDLE hDocument; // Handle to document //-- Start this document if ((hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")) != NULL) { //-- Add print speed setup to document { CComboBox * pPrintSpeedList; //-- Get dialog item of print speed list if ((pPrintSpeedList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_SPEED))) != NULL) { //-- Set selected print speed switch (pPrintSpeedList->GetCurSel()) { case 0: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_LOW); break; case 1: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; case 2: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_1); break; case 3: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_HIGH); break; default: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; } } } //-- Add print quality setup to document { CComboBox * pPrintQualityList; //-- Get dialog item of print quality list if ((pPrintQualityList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_QUALITY))) != NULL) { //-- Set selected print quality switch (pPrintQualityList->GetCurSel()) { case 0: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; case 1: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_HIGH); break; default: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; } //-- Set impressed energy correction to ... C56Sdk_DcAddImprEnergyCorrection(hDocument, 50); } } //-- Set print mode to 8x16 (for the initial linefeed) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Set initial linefeeds to power up the motor C56Sdk_DcAddLineFeed(hDocument, 1); //-- Add text to print to document { CEdit * pTextToPrint; // Pointer to text to print box //-- Get text to print (dialog item edit box) if ((pTextToPrint = ((CEdit *) this->GetDlgItem(IDC_EDIT_TEXTTOPRINT))) != NULL) { char szTextToPrint[2000+1]; // Buffer for text //-- Get text to print if (pTextToPrint->GetWindowText(szTextToPrint, sizeof(szTextToPrint)-1) > 0) { //-- Set print mode to 8x16 (as initial text) //.. disable reverse printing //.. select primary font //.. etc. etc. etc. { C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); C56Sdk_DcAddDisableReversePrinting(hDocument); C56Sdk_DcAddExtRegCharSet(hDocument, FALSE); } //-- Add "text to print" to document data C56Sdk_DcAddText(hDocument, szTextToPrint); } } } //-- Set print mode to 8x16 (for the final linefeeds) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Add final linefeeds to get text out of the shoot C56Sdk_DcAddLineFeed(hDocument, 50); //-- Print document and get job number m_bJobNr = C56Sdk_DmPrintDocument(hDocument); //-- End of document C56Sdk_DmEndDocument(hDocument); } } //-- Free memory allocated for printer name if (lpszPrinter) free(lpszPrinter); lpszPrinter = NULL; } } }
Some functions can be confused by the name but what is
C56Sdk_DmStartDocument
Can anyone tell me what this function is for:
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
?lpszPrinter
- is a name of printer driver, and hDocument ? -
The big problem will be lack of description function in this library.
Below is a example send text to printer:
void CC56SdkDemo01DlgMain::OnBnPrintout() { CComboBox * pPrinterList; // Pointer to combo box item //-- Get printer list (dialog item combo box) if ((pPrinterList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINTER_LIST))) != NULL) { INT iPrinterSel; // Selected printer //-- Determine selected printer if ((iPrinterSel = pPrinterList->GetCurSel()) != CB_ERR) { LPSTR lpszPrinter = NULL; // Printer name //-- Allocate memory for this printer and get name from combo box if ( ((lpszPrinter = (LPSTR) malloc(pPrinterList->GetLBTextLen(iPrinterSel)+1)) != NULL) && (pPrinterList->GetLBText(iPrinterSel, lpszPrinter) != CB_ERR) ) { HANDLE hDocument; // Handle to document //-- Start this document if ((hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")) != NULL) { //-- Add print speed setup to document { CComboBox * pPrintSpeedList; //-- Get dialog item of print speed list if ((pPrintSpeedList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_SPEED))) != NULL) { //-- Set selected print speed switch (pPrintSpeedList->GetCurSel()) { case 0: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_LOW); break; case 1: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; case 2: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_1); break; case 3: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_HIGH); break; default: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; } } } //-- Add print quality setup to document { CComboBox * pPrintQualityList; //-- Get dialog item of print quality list if ((pPrintQualityList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_QUALITY))) != NULL) { //-- Set selected print quality switch (pPrintQualityList->GetCurSel()) { case 0: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; case 1: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_HIGH); break; default: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; } //-- Set impressed energy correction to ... C56Sdk_DcAddImprEnergyCorrection(hDocument, 50); } } //-- Set print mode to 8x16 (for the initial linefeed) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Set initial linefeeds to power up the motor C56Sdk_DcAddLineFeed(hDocument, 1); //-- Add text to print to document { CEdit * pTextToPrint; // Pointer to text to print box //-- Get text to print (dialog item edit box) if ((pTextToPrint = ((CEdit *) this->GetDlgItem(IDC_EDIT_TEXTTOPRINT))) != NULL) { char szTextToPrint[2000+1]; // Buffer for text //-- Get text to print if (pTextToPrint->GetWindowText(szTextToPrint, sizeof(szTextToPrint)-1) > 0) { //-- Set print mode to 8x16 (as initial text) //.. disable reverse printing //.. select primary font //.. etc. etc. etc. { C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); C56Sdk_DcAddDisableReversePrinting(hDocument); C56Sdk_DcAddExtRegCharSet(hDocument, FALSE); } //-- Add "text to print" to document data C56Sdk_DcAddText(hDocument, szTextToPrint); } } } //-- Set print mode to 8x16 (for the final linefeeds) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Add final linefeeds to get text out of the shoot C56Sdk_DcAddLineFeed(hDocument, 50); //-- Print document and get job number m_bJobNr = C56Sdk_DmPrintDocument(hDocument); //-- End of document C56Sdk_DmEndDocument(hDocument); } } //-- Free memory allocated for printer name if (lpszPrinter) free(lpszPrinter); lpszPrinter = NULL; } } }
Some functions can be confused by the name but what is
C56Sdk_DmStartDocument
Can anyone tell me what this function is for:
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
?lpszPrinter
- is a name of printer driver, and hDocument ?@Damian7546
Your sample code looks like it was writte for MFC class library. Did you try to compile and run it with Visual Studio? MFC is available in there.Besides that the example looks fairly straightforward to decipher.
lpszPrinter
is a printername displayed in the combo box (of the dialog). The type istypedef char* PSTR, *LPSTR;
which can be found here. What content is displayed: I dont know.hDocument
seems to be the internal handle for the data structure for your SDK and represents the "document" you create to send to the printer at the end viaC56Sdk_DmPrintDocument
. After printing you must delete the document viaC56Sdk_DmEndDocument
.C56Sdk_DmStartDocument
seems to initialize "a new page" that can then be prepared and sent to the printer.Aside the MFC class functions the example code seems to be fairly straightforward to be translated to Qt with a little MFC help via google. Even if you dont know MFC you can realize that a combo box is used and
GetCurSel()
for example may return an index to the current selection which is then used accordingly in the following switch to set the SDK document. -
The big problem will be lack of description function in this library.
Below is a example send text to printer:
void CC56SdkDemo01DlgMain::OnBnPrintout() { CComboBox * pPrinterList; // Pointer to combo box item //-- Get printer list (dialog item combo box) if ((pPrinterList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINTER_LIST))) != NULL) { INT iPrinterSel; // Selected printer //-- Determine selected printer if ((iPrinterSel = pPrinterList->GetCurSel()) != CB_ERR) { LPSTR lpszPrinter = NULL; // Printer name //-- Allocate memory for this printer and get name from combo box if ( ((lpszPrinter = (LPSTR) malloc(pPrinterList->GetLBTextLen(iPrinterSel)+1)) != NULL) && (pPrinterList->GetLBText(iPrinterSel, lpszPrinter) != CB_ERR) ) { HANDLE hDocument; // Handle to document //-- Start this document if ((hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")) != NULL) { //-- Add print speed setup to document { CComboBox * pPrintSpeedList; //-- Get dialog item of print speed list if ((pPrintSpeedList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_SPEED))) != NULL) { //-- Set selected print speed switch (pPrintSpeedList->GetCurSel()) { case 0: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_LOW); break; case 1: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; case 2: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_1); break; case 3: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_HIGH); break; default: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; } } } //-- Add print quality setup to document { CComboBox * pPrintQualityList; //-- Get dialog item of print quality list if ((pPrintQualityList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_QUALITY))) != NULL) { //-- Set selected print quality switch (pPrintQualityList->GetCurSel()) { case 0: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; case 1: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_HIGH); break; default: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; } //-- Set impressed energy correction to ... C56Sdk_DcAddImprEnergyCorrection(hDocument, 50); } } //-- Set print mode to 8x16 (for the initial linefeed) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Set initial linefeeds to power up the motor C56Sdk_DcAddLineFeed(hDocument, 1); //-- Add text to print to document { CEdit * pTextToPrint; // Pointer to text to print box //-- Get text to print (dialog item edit box) if ((pTextToPrint = ((CEdit *) this->GetDlgItem(IDC_EDIT_TEXTTOPRINT))) != NULL) { char szTextToPrint[2000+1]; // Buffer for text //-- Get text to print if (pTextToPrint->GetWindowText(szTextToPrint, sizeof(szTextToPrint)-1) > 0) { //-- Set print mode to 8x16 (as initial text) //.. disable reverse printing //.. select primary font //.. etc. etc. etc. { C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); C56Sdk_DcAddDisableReversePrinting(hDocument); C56Sdk_DcAddExtRegCharSet(hDocument, FALSE); } //-- Add "text to print" to document data C56Sdk_DcAddText(hDocument, szTextToPrint); } } } //-- Set print mode to 8x16 (for the final linefeeds) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Add final linefeeds to get text out of the shoot C56Sdk_DcAddLineFeed(hDocument, 50); //-- Print document and get job number m_bJobNr = C56Sdk_DmPrintDocument(hDocument); //-- End of document C56Sdk_DmEndDocument(hDocument); } } //-- Free memory allocated for printer name if (lpszPrinter) free(lpszPrinter); lpszPrinter = NULL; } } }
Some functions can be confused by the name but what is
C56Sdk_DmStartDocument
Can anyone tell me what this function is for:
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
?lpszPrinter
- is a name of printer driver, and hDocument ?@Damian7546 said in Qt and USB Thermal Printer:
Can anyone tell me what this function is for:
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
?Have you looked at the definition in the header file? what are the variable names in there?
-
I downloaded Hengstler's windows driver with the SDK and in the header file it is quite obvious that
Dm
functions are Document Manager functions,Dc
functions belong to the document.You should be able to get the printer name from above via one of those functions:
HANDLE WINAPI C56Sdk_PmStartEnumPrinter (VOID); VOID WINAPI C56Sdk_PmEndEnumPrinter (HANDLE hPrinter); LPSTR WINAPI C56Sdk_PmEnumPrinter (HANDLE hPrinter, BOOL fReset); BOOL WINAPI C56Sdk_PmEnumPrinterName (HANDLE hPrinter, char * pszBuff, WORD wBuffSize, BOOL fReset);
-
Wouldn't it be better to ask the vendor of this library instead? I mean - you bought it from them so they have to give support. We can only do wild guessing...
-
Wouldn't it be better to ask the vendor of this library instead? I mean - you bought it from them so they have to give support. We can only do wild guessing...
@Christian-Ehrlicher The driver/sdk is free, it contains exe binaries of the examples and the source code. I is only MFC or .NET code that needs to be read. It shouldn't be too difficult.
-
The big problem will be lack of description function in this library.
Below is a example send text to printer:
void CC56SdkDemo01DlgMain::OnBnPrintout() { CComboBox * pPrinterList; // Pointer to combo box item //-- Get printer list (dialog item combo box) if ((pPrinterList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINTER_LIST))) != NULL) { INT iPrinterSel; // Selected printer //-- Determine selected printer if ((iPrinterSel = pPrinterList->GetCurSel()) != CB_ERR) { LPSTR lpszPrinter = NULL; // Printer name //-- Allocate memory for this printer and get name from combo box if ( ((lpszPrinter = (LPSTR) malloc(pPrinterList->GetLBTextLen(iPrinterSel)+1)) != NULL) && (pPrinterList->GetLBText(iPrinterSel, lpszPrinter) != CB_ERR) ) { HANDLE hDocument; // Handle to document //-- Start this document if ((hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")) != NULL) { //-- Add print speed setup to document { CComboBox * pPrintSpeedList; //-- Get dialog item of print speed list if ((pPrintSpeedList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_SPEED))) != NULL) { //-- Set selected print speed switch (pPrintSpeedList->GetCurSel()) { case 0: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_LOW); break; case 1: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; case 2: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_1); break; case 3: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_HIGH); break; default: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; } } } //-- Add print quality setup to document { CComboBox * pPrintQualityList; //-- Get dialog item of print quality list if ((pPrintQualityList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_QUALITY))) != NULL) { //-- Set selected print quality switch (pPrintQualityList->GetCurSel()) { case 0: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; case 1: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_HIGH); break; default: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; } //-- Set impressed energy correction to ... C56Sdk_DcAddImprEnergyCorrection(hDocument, 50); } } //-- Set print mode to 8x16 (for the initial linefeed) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Set initial linefeeds to power up the motor C56Sdk_DcAddLineFeed(hDocument, 1); //-- Add text to print to document { CEdit * pTextToPrint; // Pointer to text to print box //-- Get text to print (dialog item edit box) if ((pTextToPrint = ((CEdit *) this->GetDlgItem(IDC_EDIT_TEXTTOPRINT))) != NULL) { char szTextToPrint[2000+1]; // Buffer for text //-- Get text to print if (pTextToPrint->GetWindowText(szTextToPrint, sizeof(szTextToPrint)-1) > 0) { //-- Set print mode to 8x16 (as initial text) //.. disable reverse printing //.. select primary font //.. etc. etc. etc. { C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); C56Sdk_DcAddDisableReversePrinting(hDocument); C56Sdk_DcAddExtRegCharSet(hDocument, FALSE); } //-- Add "text to print" to document data C56Sdk_DcAddText(hDocument, szTextToPrint); } } } //-- Set print mode to 8x16 (for the final linefeeds) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Add final linefeeds to get text out of the shoot C56Sdk_DcAddLineFeed(hDocument, 50); //-- Print document and get job number m_bJobNr = C56Sdk_DmPrintDocument(hDocument); //-- End of document C56Sdk_DmEndDocument(hDocument); } } //-- Free memory allocated for printer name if (lpszPrinter) free(lpszPrinter); lpszPrinter = NULL; } } }
Some functions can be confused by the name but what is
C56Sdk_DmStartDocument
Can anyone tell me what this function is for:
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
?lpszPrinter
- is a name of printer driver, and hDocument ?@Damian7546
C56SdkDemo01
example shows how to enumerate the printers inBOOL CC56SdkDemo01DlgMain::OnInitDialog
. -
@DerReisende I have a printer name , I published my calss , which one return printer name:
#include "c56sdkapp.h" #include <QDebug> C56SdkApp::C56SdkApp() { } void C56SdkApp::AvailablePrinters() { QString lpszPrinter; // Name of printer HANDLE hEnumPrinter; // Handle for enumeration //-- Start access SDK to go through all C-56 printers if ((hEnumPrinter = C56Sdk_PmStartEnumPrinter()) != NULL) { //-- Go through all C-56 printers for ( lpszPrinter = C56Sdk_PmEnumPrinter(hEnumPrinter, TRUE); lpszPrinter != NULL ; lpszPrinter = C56Sdk_PmEnumPrinter(hEnumPrinter, FALSE)) { //-- List printer to console qDebug()<< "Printer:" << lpszPrinter; } } }
but I askd about
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
I read name printer, but I do not know what is the second parametr"C56SdkDemo01"
To run any function we need hDocument, what is it ? -
@DerReisende I have a printer name , I published my calss , which one return printer name:
#include "c56sdkapp.h" #include <QDebug> C56SdkApp::C56SdkApp() { } void C56SdkApp::AvailablePrinters() { QString lpszPrinter; // Name of printer HANDLE hEnumPrinter; // Handle for enumeration //-- Start access SDK to go through all C-56 printers if ((hEnumPrinter = C56Sdk_PmStartEnumPrinter()) != NULL) { //-- Go through all C-56 printers for ( lpszPrinter = C56Sdk_PmEnumPrinter(hEnumPrinter, TRUE); lpszPrinter != NULL ; lpszPrinter = C56Sdk_PmEnumPrinter(hEnumPrinter, FALSE)) { //-- List printer to console qDebug()<< "Printer:" << lpszPrinter; } } }
but I askd about
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
I read name printer, but I do not know what is the second parametr"C56SdkDemo01"
To run any function we need hDocument, what is it ?@Damian7546 Why dont you look at the other samples?
lpszDocument
seems to be just a name for the document as it changes in all other examples as well. And by trial and error setting it to "whateverIwanttonamemydocument" this should work as well.What is a HANDLE? See https://stackoverflow.com/questions/902967/what-is-a-windows-handle for explanation and https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types for the definition. Basically it is a
void*
to a structure that is used internally. What is inside this structure is irrelevant as you have multiple functions to properly manipulate it.I can't see any problems that will prevent you from using the Sdk. Even at beginner level with all the examples it looks fairly simple to write a small demo to print something and then extend on the knowledge. Or as @Christian-Ehrlicher said: Maybe ask the vendor as I dont have such a printer but even with example 01 I really think I would be able to print a hello world on it and extend this behaviour.
-
@Damian7546 Why dont you look at the other samples?
lpszDocument
seems to be just a name for the document as it changes in all other examples as well. And by trial and error setting it to "whateverIwanttonamemydocument" this should work as well.What is a HANDLE? See https://stackoverflow.com/questions/902967/what-is-a-windows-handle for explanation and https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types for the definition. Basically it is a
void*
to a structure that is used internally. What is inside this structure is irrelevant as you have multiple functions to properly manipulate it.I can't see any problems that will prevent you from using the Sdk. Even at beginner level with all the examples it looks fairly simple to write a small demo to print something and then extend on the knowledge. Or as @Christian-Ehrlicher said: Maybe ask the vendor as I dont have such a printer but even with example 01 I really think I would be able to print a hello world on it and extend this behaviour.
@DerReisende said in Qt and USB Thermal Printer:
And by trial and error setting it to "whateverIwanttonamemydocument" this should work as well.
You are right
-
@Damian7546 Why dont you look at the other samples?
lpszDocument
seems to be just a name for the document as it changes in all other examples as well. And by trial and error setting it to "whateverIwanttonamemydocument" this should work as well.What is a HANDLE? See https://stackoverflow.com/questions/902967/what-is-a-windows-handle for explanation and https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types for the definition. Basically it is a
void*
to a structure that is used internally. What is inside this structure is irrelevant as you have multiple functions to properly manipulate it.I can't see any problems that will prevent you from using the Sdk. Even at beginner level with all the examples it looks fairly simple to write a small demo to print something and then extend on the knowledge. Or as @Christian-Ehrlicher said: Maybe ask the vendor as I dont have such a printer but even with example 01 I really think I would be able to print a hello world on it and extend this behaviour.
This post is deleted!