Posiflex OPOS POS Printer Development Guide v0.0.1
Posiflex OPOS POS Printer Development Guide v0.0.1
POS PRINTER
POSIFLEX OPOS
APPLICATION
DEVELOPMENT GUIDE
POS PRINTER
Version: 0.01
Release Date: Jun. 22nd, 2022
ii
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Revision History
Version Date Changes Editor
0.0.1 2022/06/22 First draft. Wayne Tsai
iii
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
TABLE OF CONTENTS
SOME IMPORTANT NOTES ................................................................................... II
ABOUT THIS MANUAL .......................................................................................................................... II
TRADEMARKS AND SERVICE MARKS .................................................................................................... II
INTRODUCTION........................................................................................................ 1
ABOUT POSIFLEX OPOS CONTROL ............................................................................................................... 1
SUPPORTED OPERATING SYSTEMS ................................................................................................................ 1
SUPPORTED MODELS................................................................................................................................. 1
APPLICATION DEVELOPER ........................................................................................................................... 1
OPOS CONTROL ...................................................................................................................................... 1
iv
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
APPENDIX ................................................................................................................. 28
ABBREVIATIONS ...................................................................................................................................... 28
REFERENCE ............................................................................................................................................ 28
v
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Introduction
Supported Models
Posiflex OPOS Control supports all models of Posiflex POS Printer.
For more POS Printer models, please refer to Posiflex official website.
Application Developer
Application Developer must be familiar with the following items for using this
driver.
• OPOS 1.13 specifications
• General characteristics of Posiflex POS Printer
• Terms and structure of ActiveX control and OLE automation
• ActiveX control container development environment such as Microsoft Visual
Basic and Microsoft Visual C++, etc.
OPOS Control
In order to communicate and control peripherals, OPOS uses Microsoft’s COM
platform which is the first supported architecture of two-layer process, namely
Control Object and Service Object.
Please refer to UnifiedPOS Specification for more information.
1
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Details On Settings
General Settings
General settings are created automatically during the installation of Posiflex OPOS
Control.
All OPOS Service Object entries should be placed under the following main key:
HKEY_LOCAL_MACHINE\SOFTWARE\OLEforRetail\ServiceOPOS
The “OLEforRetail” key is to group all OLEs for retail related configuration
information. The “ServiceOPOS” key is for OPOS Service Objects configuration
information.
The following is a registry structure of POSPrinter as an example.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail]
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceInf
o]
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceInf
o\Posiflex]
@="v.1.3.5.0u"
"Path"="C:\\Program Files (x86)\\Posiflex Inc.\\Posiflex OPOS Control"
"Language"="English-437"
"useCCO"="Yes"
"A39C"="No"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceInf
o\Posiflex\POSPrinter]
@="Posiflex POS Printer OPOS Control"
"Path"="C:\\Program Files (x86)\\Posiflex Inc.\\Posiflex OPOS Control\\Printer"
"Control"="posi.ocx"
"Language"="English"
"Service"="flex.dll"
"AsyncMode0"="No "
"AsyncModeSet1"="No "
"EscapeSequencesL"="No "
2
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
"LockRecLineCharsSetting"="No "
"BarcodeSync"="No "
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceO
POS]
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceO
POS\POSPrinter]
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceO
POS\POSPrinter\PP Demo]
@="Posiflex.POSPrinter"
"Freeze2Close"="no"
"skipRCX"="yes"
"setBM"="notpbm"
"Events"="yes"
"DeviceModel"="PP8x-POS Printer"
"Version"="1.8.1"
"Code"=" "
"DeviceName"="PP8x-POS Printer"
"PwrRpt"="Yes"
"Baud"="115200"
"hmopi"="yes"
"Description"="Posiflex OPOS Control"
"Port"="COM16"
"RecLineChars"="42"
"PrinterFont"="FONT A ( 12 X 24 )"
"DisableMultipleLineFeed"="no"
"RSideCharSpacing"="0"
"CRStatusPolling"="0"
"PPname"=" "
"Manager"="921220-960919"
3
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Manager Configuration
This section introduces how to configure device by OPOS Manager.
4
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
5
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Nordic-865
Cyrillic-866
Win Cyrillic-1251
Win Greek-1253
Win Turkish-1254
Hebrew-1255
Win Arabic-1256
Win Baltic-1257
Thai-11
Thai-14
Hungary-252
Lithuania-255
Bulgaria-255
Japanese-932
Japanese-932-Kanji
Korean-949
TraditionalChinese-950
RecLineChars 42 Selects the number of
48 characters which are
35 printed on a receipt line.
56
64
47
Printer Font FONT A ( 12 X 24 ) Selects the printer font
FONT B ( 8 X 16 ) which corresponds to
user’s device.
6
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
7
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
8
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Setting RecLineChars
RecLineChars holds the number of characters that may be printed on a receipt line.
Supported values of RecLineChars are shown below. The default value is 42.
Value of RecLineChars
42
48
35
56
64
47
Interface
• Serial Devices
For serial printer or virtual serial USB printer, use Posiflex OPOS Manager
to add the device, select a COM port and set the baud rate.
• Parallel Devices
For parallel printer, use Posiflex OPOS Manager to add device with selected
LPT port.
• USB Devices
For USB printer, use Posiflex OPOS Manager to add device with selected
USB port.
• Ethernet Devices
For network printer, use Posiflex OPOS Manager to add device with selected
TCP/IP port and set the IP address.
9
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Function Details
Supported Methods
Name Supported
Open ✓
Close ✓
Claim ✓
Release ✓
CheckHealth ✓
ClearInput
ClearInputProperties
ClearOutput ✓
DirectIO ✓
CompareFirmwareVersion ✓
ResetStatistics ✓
RetrieveStatistics ✓
ReleaseDevice ✓
UpdateFirmware ✓
UpdateStatistics ✓
ClaimDevice ✓
BeginInsertion ✓
BeginRemoval ✓
ChangePrintSide ✓
ClearPrintArea ✓
CutPaper ✓
DrawRuledLine
EndInsersion ✓
EndRemoval ✓
MarkFeed ✓
PageModePrint ✓
PrintBarCode ✓
PrintBitmap ✓
PrintImmediate ✓
PrintMemoryBitmap ✓
PrintNormal ✓
PrintTwoNormal ✓
10
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
RotatePrint ✓
SetBitmap ✓
SetLogo ✓
TransactionPrint ✓
ValidateData ✓
Supported Properties
Name Supported Attribute Mutability May Use After
AutoDisable boolean read-write open
CapCompareFirmwareVersion boolean read-only open
CapPowerReporting ✓ int32 read-only open
CapStatisticsReporting boolean read-only open
CapUpdateFirmware boolean read-only open
CapUpdateStatistics ✓ boolean read-only open
CheckHealthText ✓ string read-only open
Claimed ✓ boolean read-only open
DataCount int32 read-only open
DataEventEnabled boolean read-write open
DeviceEnabled ✓ boolean read-write open
FreezeEvents ✓ boolean read-write open
OutputID ✓ int32 read-only open
PowerNotify ✓ int32 read-write open
PowerState ✓ int32 read-only open
State ✓ int32 read-only open
DeviceControlDescription string read-only open
DeviceControlVersion int32 read-only open
DeviceServiceDescription string read-only open
DeviceServiceVersion int32 read-only open
PhysicalDeviceDescription string read-only open
PhysicalDeviceName string read-only open
CapCharacterSet ✓ int32 read-only open
CapConcurrentJrnRec boolean read-only open
CapConcurrentJrnSlp boolean read-only open
CapConcurrentPageMode boolean read-only open
CapConcurrentRecSlp boolean read-only open
CapCoverSensor boolean read-only open
11
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
12
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
13
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
14
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Supported Events
Name Description
DirectIOEvent Provides Service information directly to
the application. This event provides a
means for a vendor-specific POS Printer
Service to deliver events to the
applications that are not otherwise
supported by the Control Object.
ErrorEvent Notifies the application that a POS
Printer error has been detected and that a
suitable response by the application is
necessary to process the error condition.
Current Posiflex OPOS Control supports
the following events.
EPTR_COVER_OPEN, the printer cover
is open.
EPTR_REC_EMPTY, the receipt station
is our of paper.
OutputCompleteEvent Notifies the application that the queued
output request associated with the
OutputID attribute has completed
successfully.
OutputID is the ID number of the
asynchronous output request that is
completed.
StatusUpdateEvent Notifies the application that a printer has
had an operation status change.
15
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Supported StatusUpdateEvent
The following is the list of StatusUpdateEvent values.
Please refer to UnifiedPOS Specification for more information.
Value Meaning
PTR_SUE_COVER_OPEN Printer cover is open
PTR_SUE_COVER_OK Printer cover is closed
PTR_SUE_REC_EMPTY No receipt paper
PTR_SUE_REC_NEAREMPTY Receipt paper is low
PTR_SUE_REC_PAPEROK Receipt paper is ready
PTR_SUE_IDLE All synchronous output has finished, either
successfully or because output has been cleared.
The printer State is now S_IDLE.
16
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Application Programming
This section demonstrates sample code of OPOS application in Visual Basic.
For more demo programs, please refer to “Release Note Demo Program” in shortcut
of Posiflex OPOS Control. The VB.NET demo is developed in Visual Studio 2005.
Printing Data
Calling PrintNormal() to print data.
Dim printing_string As String
Dim return_code As Long
printing_string = “Calling PrintNormal‘ + vbCrLf
return_code = OPOSPOSPrinter1. PrintNormal (PtrSReceipt, printing_string)
If return_code = OPOS_SUCCESS Then
‘Success
Else
17
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
‘Error
End If
printing_string is the string to be printed. May contain printable characters, escape
sequences, carriage returns (13 decimal), and line feeds (10 decimal).
18
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
file_number = FreeFile
bitmap_path = App.Path + "\my_bitmap.bmp"
Open bitmap_path For Binary As file_number
bitmap_file_Size = LOF(file_number)
ReDim bytes(bitmap_file_Size)
Get file_number, , bytes
Close file_number
Dim return_code As Long
For i = 0 To (bitmap_file_Size) - 1
result = result + Format(bytes(i), "000")
Next
Set ob = OPOSPOSPrinter1
ob.BinaryConversion = OposBcDecimal
return_code = ob.PrintMemoryBitmap(PtrSReceipt, result, PtrBmtBMP, PtrBmAsis,
PtrBmCenter)))
DoEvents
If return_code = OPOS_SUCCESS Then
‘Success
Else
19
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
‘Error
End If
Print Barcode
Calling PrintBarcode() to print barcode like 1D barcode and 2D barcode.
Dim barcode_contents As String
Dim barcode_height As Long
Dim return_code As Long
barcode_contents = “123456789” ‘It bases on what type is chosen.
barcode_height = 40
return_code = OPOSPOSPrinter1.PrintBarCode(PtrSReceipt, barcode_contents,
PtrBcsCode39, barcode_height, OPOSPOSPrinter1.RecLineWidth, PtrBcCenter,
PtrBcTextAbove)
If return_code = OPOS_SUCCESS Then
‘Success
Else
‘Error
End If
Cut Paper
Calling CutPaper() to cut paper.
Dim cut_percentage As Integer
cut_percentage = 90 ‘Leave only a small portion of paper for very easy final
separation
OPOSPOSPrinter1.CutPaper(cut_percentage)
20
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
DirectIO
Calling DirectIO() to send command to device.
Dim command_string As String
Dim command_string_len As Long
Dim command As Long
Dim return_code As Long
command = 0
command_string = Chr(&H1B) + Chr(&H40) ‘Initial Printer
command_string_len = Len(command_string)
return_code = OPOSPOSPrinter1.DirectIO(command, LEN_cmd, IO_cmd)
If return_code = OPOS_SUCCESS Then
‘Success
Else
‘Error
End If
21
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Escape Sequence
Starting with Release 1.7, escape sequences are supported.
Every escape sequence begins with the escape character ESC, whose value is 0x1B,
followed by a vertical bar (‘|’). This escape sequence is terminated by an uppercase
alphabetic character.
Please refer to UnifiedPOS Specification for more information.
Name Data Description
Paper cut ESC|[#]P Cuts receipt paper. The placeholder '#' is replaced by an
ASCII decimal string indicating the percentage cut desired.
Feed and Paper cut ESC|[#]fP Cuts receipt paper, after feeding the paper by the
RecLinesToPaperCut lines. The placeholder '#' is defined by
the "Paper cut" escape sequence.
Print bitmap ESC|#B Prints the pre-stored bitmap. The placeholder '#' is replaced
by the bitmap number. If the given bitmap number has not
been set successfully by the setBitmap method, then the
printing results may be unpredictable.
Print top logo ESC|tL Prints the pre-stored top logo.
Print bottom logo ESC|bL Prints the pre-stored bottom logo.
Feed lines ESC|[#]lF Feeds the paper forward by lines. The placeholder '#' is
replaced by an ASCII decimal string telling the number of
lines to be fed. If '#' is omitted, then one line is fed.
Feed units ESC|[#]uF Feeds the paper forward by mapping mode units. The
placeholder '#' is replaced by an ASCII decimal string telling
the number of units to be fed. If '#' is omitted, then one line
is fed.
Feed reverse ESC|[#]rF Feeds the paper backward. The placeholder '#' is replaced by
an ASCII decimal string telling the number of units to be
fed. If '#' is omitted, then one line is fed.
Pass through embedded ESC|[#]E Sends the following # characters of data through to the
data hardware without modifying it.
Bold ESC|bC Prints in bold or double-strike.
Underline ESC|#uC Prints with underline. The character '#' is replaced by an
ASCII decimal string indicating the thickness of the
underline in printer dot units. If '#' is omitted, then a
printer-specific default thickness is used.
Single high and wide ESC|1C Prints normal size.
22
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
23
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Handling Events
Creating the following functions to handle events.
Private Sub OPOSPOSPrinter1_ErrorEvent(ByVal resultcode As Long, ByVal
ResultCodeExtended As Long, ByVal ErrorLocus As Long, pErrorResponse As Long)
MsgBox "Printer Error." + vbCrLf + vbCrLf + "ResultCode = " +
CStr(resultcode) + vbCrLf + "ResultCodeExtended = " + CStr(ResultCodeExtended),
vbInformation
End Sub
Private Sub OPOSPOSPrinter1_OutputCompleteEvent(ByVal OutputID As Long)
' Notify that printing is completed when it is asnchronous.
MsgBox "Complete printing" & Str(OutputID), vbInformation
End Sub
Private Sub OPOSPOSPrinter1_StatusUpdateEvent(ByVal data As Long)
Select Case data
Case PTR_SUE_COVER_OPEN
MsgBox "PTR_SUE_COVER_OPEN"
Case PTR_SUE_COVER_OK
MsgBox "PTR_SUE_COVER_OK"
Case PTR_SUE_REC_EMPTY
MsgBox "PTR_SUE_REC_EMPTY"
Case PTR_SUE_REC_NEAREMPTY
MsgBox "PTR_SUE_REC_NEAREMPTY"
Case PTR_SUE_REC_PAPEROK
MsgBox "PTR_SUE_REC_PAPEROK"
'** Power status
Case OPOS_PS_UNKNOWN
MsgBox "OPOS_PS_UNKNOWN"
Case OPOS_PS_ONLINE
MsgBox "OPOS_PS_ONLINE"
Case OPOS_PS_OFF
MsgBox "OPOS_PS_OFF"
Case OPOS_PS_OFFLINE
MsgBox "OPOS_PS_OFFLINE"
Case OPOS_PS_OFF_OFFLINE
MsgBox "OPOS_PS_OFF_OFFLINE"
End Select
End Sub
24
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
25
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Error Code
This section lists the general meanings of error codes.
Please refer to UnifiedPOS document for more information about error code.
26
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Value Meaning
OPOS_SUCCESS Successful operation.
OPOS_E_CLOSED An attempt was made to access a closed Device.
OPOS_E_CLAIMED An attempt was made to access a physical device that is
claimed by another Control instance. The other Control
must release the physical device before this access can be
made. For exclusive-use device, the application will also
need to claim the physical device before accessing it.
OPOS_E_NOTCLAIMED An attempt was made to access an exclusive-use device
that must be claimed before the method or property set
action can be performed.
If the physical device is already claimed by another
Control instance, then the status OPOS_E_CLAIMED is
returned instead
OPOS_E_NOSERVICE The Control Object cannot communicate with the Service
Object normally because of setup or configuration error.
OPOS_E_DISABLED Cannot perform this operation while the Device is
disabled
OPOS_E_ILLEGAL An attempt was made to perform an illegal or
unsupported operation with the device, or an invalid
parameter was provided.
OPOS_E_NOHARDWARE The physical device is not connected to the system or is
not powered on.
OPOS_E_OFFLINE The physical device is off-line.
OPOS_E_NOEXIST The file name or other specified value does not exist.
OPOE_E_EXISTS The file name or other specified value already exist.
OPOS_E_FAILURE The device cannot perform the request, even though the
physical device is connected to the system, powered on,
and on-line.
OPOS_E_TIMEOUT The Service Object timed out waiting for a response from
the physical device, or the Control Object timed out
waiting for a response from the Service Object.
OPOS_E_BUSY The current Service state does not allow this request. For
example, if asynchronous output is in progress, certain
methods may not be allowed.
27
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER
Appendix
Abbreviations
Abbreviation Full Name
UnifiedPOS Unified Point of Service
POS Point of Sale
OPOS OLE for Retail Point-of-Sale
OLE Object Linking and Embedding
SO Service Object
CO Control Object
USB Universal Serial Bus
LPT Line Printer Terminal
COM Communication port, always be as serial port.
Reference
For UnifiedPOS documents please refer to
https://www.omg.org/retail/unified-pos.htm
28