MASUNG Printers Software Development Kit Reference Manual: Shenzhen Masung Technology Co.,Ltd
MASUNG Printers Software Development Kit Reference Manual: Shenzhen Masung Technology Co.,Ltd
MASUNG Printers
Software Development Kit
Reference Manual
1/60
SDK Reference Manual
Revising history
date
2/60
SDK Reference Manual
Content
1. SDK introduction .................................................................................................................................... 6
1.1 overview ...................................................................................................................................... 6
1.2 To whom should concern ............................................................................................................ 6
1.3 Support printer model.................................................................................................................. 6
1.4 Communication interfaces ........................................................................................................... 6
1.5 SDK library ................................................................................................................................. 6
2. interface description ................................................................................................................................ 7
2.1 Printer Initialization and close ..................................................................................................... 7
2.1.1 Set device name (Windows) ....................................................................................... 7
2.1.2 Set device connection(Windows) ............................................................................. 8
2.1.3 Set device name(Linux) ............................................................................................. 9
2.1.4 set flow control ....................................................................................................... 11
2.1.5 Automatically configure USB interface ............................................................. 12
2.1.6 Automatically configure Serial port interface ............................................. 12
2.1.7 Printer initialization ........................................................................................... 13
2.1.8 Clear buffer memory ................................................................................................. 14
2.1.9 Printer close ............................................................................................................. 14
2.1.10 Set chinese mode ............................................................................................... 15
2.1.11 Set country & language codepage ................................................................. 15
2.2 Normal printing function ........................................................................................................... 17
2.2.1 Print character string ........................................................................................... 17
2.2.2 Cutting ......................................................................................................................... 17
2.2.3 Print & line feed ..................................................................................................... 18
2.2.4 Print & feed paper ................................................................................................... 18
2.2.5 Print self test page ............................................................................................... 19
2.3 printing function ........................................................................................................................ 20
2.3.1 Set line space ........................................................................................................... 20
2.3.2 Set character pitch ................................................................................................. 20
2.3.3 Set left margin ......................................................................................................... 21
2.3.4 set character size ................................................................................................... 21
2.3.5 Set text size ............................................................................................................. 22
2.3.6 Set character alignment ......................................................................................... 23
2.3.7 Set bold character ................................................................................................... 23
2.3.8 Set character rotation ........................................................................................... 24
2.3.9 Set character direction ......................................................................................... 24
2.3.10 Set inverse white ............................................................................................. 25
2.3.11 Set italic ........................................................................................................... 26
2.3.12 Set underline ..................................................................................................... 26
2.3.13 Set chinese size ............................................................................................... 27
2.3.14 Set chinese pitch ............................................................................................. 28
2.3.15 Set horizontal table position ..................................................................... 28
2.3.16 Execute to next HT position ......................................................................... 29
2.4 Bit-image & barcodes................................................................................................................ 30
3/60
SDK Reference Manual
2.4.1 Print QR code ............................................................................................................. 30
2.4.2 Print mixed QR code ................................................................................................. 31
2.4.3 Print 1D barcode ....................................................................................................... 32
2.4.4 Print BMP file from local disk I ....................................................................... 34
2.4.5 Print BMP file from local disk II ..................................................................... 34
2.4.6 Set NV BMP file ......................................................................................................... 35
2.4.7 Print NV BMP file ..................................................................................................... 36
5/60
SDK Reference Manual
1. SDK introduction
1.1 overview
SDK means Software Development Kit
This SDK manual provides technical reference to all printers manufactured
from MASUNG , it will ease developers work and help them to finish terminal
application software.
Its advantages:
⚫ There is no need to understand the specific instructions of the printer.
⚫ Packaging the communication with the printer, No need to care processing
and printer specific communication protocol.
⚫ Easy bit-image printing
⚫ Easy QR code printing
⚫ Access to printer status checking
used on Windows platform, Support VB, VC, C#, QT, JAVA and other development
languages, mainly used in web development calls.
⚫ Msprintsdk.so
SO means shared object, it is used on Linux platform.
This SDK manual explained to those three kind libraries. Most of them are
same communication interface, difference part will be marked with those signs
2. interface description
[Interface]
7/60
SDK Reference Manual
int r = SetPrintport("USB001",0);
[interface]
8/60
SDK Reference Manual
1, 2, 3) or Bluetooth name.
strValue char * Communication baud rate if the connection mode
is serial port
Support 9600,38400,115200,need to be
consistent with the hardware settings of the
printer.
This parameter is invalid when the connection
mode is USB.
When the connection mode is Bluetooth, it is
the connection password.
[return value]
0 success
1 failure
[sample]
int r = SetPrintConn (1,"COM1","115200");
[note]
This upgrade to version 2.2 adds support for bluetooth printers and can
replaces the SetPrintport interface.
[interface]
9/60
SDK Reference Manual
[parameter]
name type parameter description
iDevtype int Printer interfaces
1 COM (including direct COM or virtual COM)
2 USB
3 Automatically match USB
cDevname char * Printer name
In generally, when iDevtype=1,
Direct COM value as/dev/ttySX(X stands for
COM number 0、1、2)
Virtual COM value as/dev/ttyUSBX(X stands
for COM number 0、1、2)
When iDevtype=2,
USB value as /dev/usb/lpX(X stands for USB
number 0、1、2)
iBaudrate int Serial baud rate
9600、38400、115200,this parameter should be
pair with printer hardware baud rate
configuration.
iDevtype=1 this parameter is valid
iDevtype=2,this paramter is invalid
10/60
SDK Reference Manual
0 success
1 failure
[sample]
int r = SetDevname(1,"/dev/ttyS0",115200);
int r = SetDevname(2,"/dev/usb/lp0",0);
[interface]
11/60
SDK Reference Manual
[interface]
SetUsbportauto()
[function]
Automatically search USB interface name
[parameter]
none
[return value]
0 success
1 failure
[sample]
int r = SetUsbportauto();
[note]
This interface is only suitable for printer USB communication.
[interface]
SetComportauto()
[function]
Automatic search serial port
[parameter]
none
[return value]
0 success
1 failure
[sample]
int r = SetComportauto();
[note]
12/60
SDK Reference Manual
[interface]
SetInit()
[function]
Open the device or port to connect to the printer, initial printer , clear
butter memory.
[parameter]
none
[return value]
0 success
1 failure
[sample]
int r = SetInit();
[note]
Only when this interface is invoked successfully, then developer can make
printer working
Please setup printer connection method , name and other parameters before
invoking this interface, below are explains for different SDK libraries.
⚫ Msprintsdk.dll
[interface]
SetClean()
[function]
Clear printer buffer memory and previous configuration parameters.
[parameter]
none
[return value]
0 success
1 failure
[sample]
int r = SetClean();
[interface]
SetClose()
[function]
Close printer interface and release printer resource
[paramter]
none
[return value]
0 success
1 failure
[sample]
14/60
SDK Reference Manual
int r = SetClose();
[interface]
SetReadZKmode(int mode)
[function]
Set chinese mode
[parameter]
[interface]
15/60
SDK Reference Manual
Country table
parameter country
0 US
1 france
2 germany
3 UK
4 denmark I
5 sweden
6 italy
7 spain
8 japan
9 norway
10 denmark II
Codepage table
paramter codepage
0 PC437[USA-Europe standard]
1 Katakana
2 PC850[multiple language]
3 PC860 [portuguese]
4 PC863 [canadian-french]
5 PC865 [north Europe]
16 WPC1252
17 PC866[slavic2]
18 PC852[latin2]
19 PC858 [Europe]
[return value]
16/60
SDK Reference Manual
0 success
1 failure
[sample]
int r = SetCodepage(0,0);
[interface]
int PrintString(char* strData, int iImme)
[function]
Print character string
[parameter]
2.2.2 Cutting
[interface]
int PrintCutpaper(int iMode)
[function]
cutting
[parameter]
17/60
SDK Reference Manual
[interface]
int PrintChargeRow()
[function]
Printing data and line feed, if without printing data, printer will feed one
blank line.
[parameter]
none
[return value]
0 success
1 failure
[sample]
int r = PrintString("PrintTest1",1);
r = PrintString("PrintTest2",1);
r = PrintChargeRow();
[interface]
[function]
Feeding paper.
[parameter]
name type parameter description
Lnumber int unit
Value range: 0-250
Unit value = 0.125 mm
[return value]
0 success
1 failure
[sample]
int r = PrintFeedDot(10);
[interface]
int PrintSelfcheck()
[function]
Print self test page.
[parameter]
none
[return value]
0 success
1 failure
[sample]
int r = PrintSelfcheck();
19/60
SDK Reference Manual
[interface]
int SetLinespace(int iLinespace)
[function]
Set line space
[parameter]
[interface]
int SetSpacechar(int iSpace)
[function]
Set character pitch
[parameter]
name type parameter description
iSpace int Character pitch
Value range 0-64
Unit value = 0.125mm
[return value]
20/60
SDK Reference Manual
0 success
1 failure
[sample]
int r = SetSpacechar(10);
[interface]
int SetLeftmargin(int iLeftspace)
[function]
Set left margin
[parameter]
name type parameter description
iLeftspace int Left margin
Value range 0-576
Unit value = 0.125mm
[return value]
0 success
1 failure
[sample]
int r = SetLeftmargin(10);
[interface]
int SetSizechar(int iHeight,int iWidth,int iUnderline,int iAsciitype)
[function]
Set character size
[parameter]
name type parameter description
iHeight int Double height
21/60
SDK Reference Manual
0 invalid
1 valid
iWidth int Double width
0 invalid
1 valid
iUnderline int Underline
0 invalid
1 valid
iAsciitype int ASCII font type
0 12*24
1 9*17
[return value]
0 success
1 failure
[sample]
int r = SetSizechar(1,1,1,1);
[interface]
int SetSizetext(int iHeight, int iWidth)
[function]
Set text size
[parameter]
name type parameter description
22/60
SDK Reference Manual
0 success
1 failure
[sample]
int r = SetSizetext (2,2);
[interface]
int SetAlignment(int iAlignment)
[function]
Set character alignment
[parameter]
name type parameter description
iAlignment int Character alignment
0 Left alignment
1 Central alignment
2 right alignment
[return value]
0 success
1 failure
[sample]
int r = SetAlignment(1);
[interface]
int SetBold(int iBold)
[function]
Set bold character
[parameter]
name type parameter description
23/60
SDK Reference Manual
[interface]
int SetRotate(int iRotate)
[function]
Set character rotation
[parameter]
name type parameter description
iRotate int Character rotation
0 cancel character rotation
1 clockwise rotation 90°
[return value]
0 success
1 failure
[sample]
int r = SetRotate(1);
[interface]
int SetDirection(int iDirection)
[function]
24/60
SDK Reference Manual
[interface]
int SetWhitemodel(int iWhite)
[function]
Set inverse white
[parameter]
name type parameter description
iWhite int Inverse white
0 cancel inverse white
1 set inverse white
[return value]
0 success
1 failure
[sample]
int r = SetWhitemodel(1);
25/60
SDK Reference Manual
[interface]
int SetItalic(int iItalic)
[function]
Set italic
[parameter]
name type parameter description
iItalic int italic
0 cancel italic
1 set italic
[return value]
0 success
1 failure
[sample]
int r = SetItalic (1);
[interface]
26/60
SDK Reference Manual
0 success
1 failure
[sample]
int r = SetUnderline (1);
[interface]
int SetSizechinese(int iHeight,int iWidth,int iUnderline,int iChinesetype)
[function]
Set chinese size
[parameter]
name type parameter description
iHeight int Double height
0 invalid
1 valid
iWidth int Double width
0 invalid
1 valid
iUnderline int underline
0 invalid
1 valid
iChinesetype int Chinese font type
0 24*24
1 16*16
[return value]
0 success
1 failure
[sample]
int r = SetSizechinese(1,1,1,1);
27/60
SDK Reference Manual
[interface]
int SetSpacechinese(int iChsleftspace,int iChsrightspace)
[function]
Set chinese pitch
[parameter]
name type parameter description
iChsleftspace int Chinese left margin
Value range 0-64
Unit value = 0.125mm
iChsrightspace int Chinese right margin
Value range 0-64
Unit value = 0.125mm
[return value]
0 success
1 failure
[sample]
int r = SetSpacechinese(10,10);
[interface]
int SetHTseat(const char* bHTseat,int iLength)
[function]
Set horizontal table position
[parameter]
“0”
iLength int HT position data quantity
Value range 1-32
[return value]
0 success
1 failure
[sample]
Refer to Execure to next HT position;
[interface]
int PrintNextHT()
[function]
Execure to next HT position
[parameter]
none
[return value]
0 success
1 failure
[sample]
char cSeat[3]={10,18,25};
SetHTseat(cSeat,3);
PrintString("1",1);
PrintNextHT();
PrintString("2",1);
PrintNextHT();
PrintString("3",1);
PrintNextHT();
PrintString("4",0);
29/60
SDK Reference Manual
PrintString("1a",1);
PrintNextHT();
PrintString("2a",1);
PrintNextHT();
PrintString("3a",1);
PrintNextHT();
PrintString("4a",0);
PrintString("1b",1);
PrintNextHT();
PrintString("2b",1);
PrintNextHT();
PrintString("3b",1);
PrintNextHT();
PrintString("4b",0);
Printing result
1 2 3 4
1a 2a 3a 4a
1b 2b 3b 4b
[interface]
int PrintQrcode(const char* strData,int iLmargin,int iMside,int iRound)
[function]
Print QR code
[parameter]
30/60
SDK Reference Manual
[interface]
PrintRemainQR()
[function]
Print mixed QR code
[parameter]
none
[return value]
31/60
SDK Reference Manual
0 success
1 failure
[sample]
PrintQrcode("QR Code:123456",2,4,1);
SetLeftmargin(120);
PrintString("QR Code:",0);
PrintString("123456",0);
int r = PrintRemainQR();
Printing result:
[interface]
int Print1Dbar(int iWidth,int iHeight,int iHrisize,int iHriseat,int
iCodetype,const char* strData)
[function]
Print 1D barcode
[parameter]
name type parameter description
iWidth int Barcode width
Value range 2-6
Unit value = 0.125mm
iHeight int Barcode height
Value range 1-255
Unit value = 0.125mm
iHrisize int Character font type
32/60
SDK Reference Manual
0 12*24
1 9*17
iHriseat int Character position
0 none
1 Above
2 below
3 up and down
iCodetype int Barcode type
Barcode type refers to below table
strData char* Barcode content
4 * CODE39
5 * ITF
6 * CODABAR
7 * Standard EAN13
8 * Standard EAN8
9 * CODE93
10 * CODE128
[return value]
0 success
1 failure
[sample]
33/60
SDK Reference Manual
int r = Print1Dbar(2,10,0,1,10,"1Dbar");
[interface]
int PrintDiskbmpfile(const char* strPath)
[function]
Print BMP file from local disk
[parameter]
[note]
Only supports 1bit single color BMP format file
[interface]
34/60
SDK Reference Manual
[note]
Supports 1bit and 24 bits single color BMP format file
[interface]
35/60
SDK Reference Manual
[parameter]
name type parameter description
iNums int BMP file quantity
Single file size is within 64KB
Total files size is within 192KB
(BMP file quantity is without limitation )
strPath char* BMP file path
• If the full path to any image file is not
provided, then the current working
folder will be assumed
• If multiple image files are specified,
then each entry must be separated with
a “;” character
• The iNums parameter must match the no.
of image files specified
[return value]
0 success
1 failure
[sample]
int r = SetNvbmp(3, "D:\\test1.bmp;D:\\BMP\\test2.bmp;test3.bmp");
[note]
Only supports 1bit single color BMP format file
this function completely replaces any images currently stored in NV memory
BMP file will be saved at printer flash, this interface is used to fixed
BMP file content, such as LOGO information.
[interface]
int PrintNvbmp(int iNvindex,int iMode)
[function]
Print NV BMP file
36/60
SDK Reference Manual
[parameter]
name type parameter description
iNvindex int NV BMP file index,from 1 begin
Value range 1-N,N depends on
“SetNvbmp”setup quantity,when N is over
“SetNvbmp”setup quantity, printer won’t
work.
iMode int BMP file size
48 normal
49 double width
50 double height
51 double width and double height
[retun value]
0 success
1 failure
[sample]
int r = PrintNvbmp(1,48);
Printing result:
int r = PrintNvbmp(1,49);
Printing result:
int r = PrintNvbmp(1,50);
Printing result:
37/60
SDK Reference Manual
int r = PrintNvbmp(1,51);
Printing result:
[interface]
int PrintDataMatrix(const char* strData, int iSize)
[function]
Print Data Matrix code.
[parameter]
38/60
SDK Reference Manual
[sample]
int r = PrintDataMatrix("DataMatrix",6);
[interface]
int GetStatus()
[function]
Check printer status
[parameter]
none
[return value]
39/60
SDK Reference Manual
[sample]
int r = GetStatus();
[interface]
int GetStatusspecial ()
[function]
Get printer special function status
[parameter]
none
[return value]
40/60
SDK Reference Manual
[interface]
[interface]
GetSDKinformation(char* bInfodata)
[function]
Get SDK version information
[parameter]
2.6 Blackmark
[interface]
int SetMarkoffsetcut(int iOffset)
[function]
Set blackmark cutting offset
[parameter]
name type parameter description
iOffset int offset
Value range 0-1600
42/60
SDK Reference Manual
[interface]
int SetMarkoffsetprint(int iOffset)
[function]
Set blackmark printing offset.
[parameter]
name type parameter description
iOffset int offset
Value range 0-1600
Unit value = 0.125mm
[return value]
0 success
1 failure
[sample]
int r = SetMarkoffsetprint(10);
[interface]
int PrintMarkposition()
[function]
Under blackmark mode detection, printer will feed paper and stop on
blackmark position
43/60
SDK Reference Manual
[parameter]
none
[return value]
0 success
1 failure
[sample]
int r = PrintMarkposition();
[note]
Pinting offset will influence paper feed distance
[interface]
int PrintMarkpositionPrint()
[function]
Under blackmark detection mode, printer will feed paper and stop on printing
position
[parameter]
none
[return value]
0 success
1 failure
[sample]
int r = PrintMarkpositionPrint();
[note]
Printing offset will influence paper feed distance
[interface]
int PrintMarkpositioncut()
44/60
SDK Reference Manual
[function]
Under blackmark detection mode, printer will feed paper and stop on cutting
position
[parameter]
none
[return value]
0 success
1 failure
[sample]
int r = PrintMarkpositioncut();
[note]
Cutting offset will influence paper feed distance
[interface]
int PrintMarkcutpaper(int iMode)
[function]
Cut blackmark
[parameter]
45/60
SDK Reference Manual
[interface]
int PrintTransmit(const char* bCmd,int iLength)
[function]
Transmit original command to printer
[parameter]
[interface]
[function]
Transmit original command to printer and receive return value
[parameter]
name type parameter description
bCmd char* command
iLength int Command length
46/60
SDK Reference Manual
[interface]
SetCommandmode(int iMode)
[function]
Switching printer into different command mode, in order to realize customized
printing interface function
[parameter]
name type parameter description
iMode int Command mode
2 EPIC mode
3 EPOS mode
[return value]
47/60
SDK Reference Manual
0 success
1 failure
[sample]
int r = SetCommandmode(2);
[note]
If developer needs to use customized printing interface , he needs to switch
printer into EPIC command mode. after that function is accomplished, developer
needs to switch printer into EPOS command mode, then he can use common standard
printing interface.
[interface]
int SetRotation_Intomode()
[function]
Set rotation printing mode
[parameter]
none
[return value]
0 success
1 failure
[sample]
int r = SetRotation_Intomode();
[interface]
[interface]
int PrintRotation_Sendcode(int leftspace,int iWidth,int iHeight,int
49/60
SDK Reference Manual
0 * UPC-A
1 * UPC-E
2 * EAN13
3 * EAN8
4 * CODE39
5 * ITF
6 * CODABAR
7 * Standard EAN13
8 * Standard EAN8
9 * CODE93
10 * CODE128
[return value]
0 success
1 failure
[sample]
int r = PrintRotation_Sendcode(10,3,60,10,"1Dbar");
[interface]
int PrintRotation_Changeline()
[function]
Send line feed in rotation
[parameter]
none
50/60
SDK Reference Manual
[return value]
0 success
1 failure
[sample]
int r = PrintRotation_Changeline();
[interface]
[interface]
int PrintRotation_Data()
[function]
After rotation printing and save data, then exit rotation mode, enter into
EPOS command mode
[parameter]
51/60
SDK Reference Manual
none
[return value]
0 success
1 failure
[sample]
int r = PrintRotation_Data();
[interface]
[interface]
52/60
SDK Reference Manual
[interface]
53/60
SDK Reference Manual
[note]
must use this as an example, or you might cause data errors.
[interface]
[interface]
54/60
SDK Reference Manual
[interface]
[interface]
int PrintPagedata()
[function]
55/60
SDK Reference Manual
[interface]
[return value]
0 success
1 failure
[sample]
char cQRData[128]={0x31,0x32,0x33,0x34,0x35,0x36};
int r = PrintQrcodeII(cQRData,6,8);
56/60
SDK Reference Manual
[interface]
3. Invoking sample
3.1 Msprintsdk.dll
VC sample
Msprintdemo
Visual Studio 2008 VC++ compile
57/60
SDK Reference Manual
C# sample
Msprintcsharp
Visual Studio 2008 C# compile
58/60
SDK Reference Manual
3.2 Msprintsdk.ocx
3.3 Msprintsdk.so
4. appendix
[file name]
Config.ini
[sample]
[PortConfig]
Portname=COM3
Baudrate=115200
[configuration description]
Same as manual Set device name (Windows) parameter
[file name]
Config.ini
[sample]
[DevConfig]
DevType=1
DevName=/dev/ttyUSB0
Baudrate=115200
Or
[DevConfig]
DevType=3
PID=8211
[configuration description]
Same as manual Set device name(Linux) parameter
60/60