Seiko RP D10 Linux Programmers Guide
Seiko RP D10 Linux Programmers Guide
Seiko RP D10 Linux Programmers Guide
Communication Library
Application Programmer's Guide
U00131031002
RP-D10 Series Communication Library Application Programmer's Guide
MS-DOS®, Microsoft®, Win32®, Windows®, Windows Vista®, Visual Studio®, Visual Basic®, Visual C++®,
Visual C#®, and Microsoft® .NET are either registered trademarks or trademarks of Microsoft Corporation in
the U.S.A., Japan, and other countries.
Bluetooth® is registered trademarks of Bluetooth SIG, Inc.
Seiko Instruments Inc. (hereinafter referred to as "SII") has prepared this manual for use by SII personnel,
licensees, and customers. The information contained herein is the property of SII and shall not be reproduced
in whole or in part without the prior written approval of SII.
SII reserves the right to make changes without notice to the specifications and materials contained herein and
shall not be responsible for any damages (including consequential) caused by reliance on the materials
presented, including but not limited to typographical, arithmetic, or listing errors.
Symbols
This section describes symbols used in this document.
Caution
Notes and limitations are described.
Introduction - 1
Terms
This section describes terms used in this document.
Definition Description
RP-D10 SERIES THERMAL PRINTER TECHNICAL
Technical reference
REFERENCE
Printer command "Automatic Status Back
ASB Setting command
Enable/Disable".
(ASB: Automatic Status Back)
For details, refer to the Technical reference of the printer.
POS printer's status information retrievable by the
Communication library.
This information includes the status to respond for the
POS printer status
printer command "Automatic Status Back
Enable/Disable" and some extended statuses.
For details, see "6.1 POS Printer Status List".
Printer driver user's guide RP-D10 SERIES PRINTER DRIVER USER'S GUIDE.
Disclaimer
Seiko Instruments Inc. shall not be liable for any damages that may occur either directly or
indirectly from use of this product.
Seiko Instruments Inc. shall not be liable for any damages or losses caused by or related to
improper use of this product, improper handling without adherence to this document, repair or
modification from third-party other than our personnel, and so forth.
Introduction - 2
Chapter 1 Overview 1-1
1.1 Introduction ............................................................................................................................... 1-1
1.2 Operating Conditions ................................................................................................................ 1-1
TOC - 1
Chapter 4 .NET API 4-1
4.1 Overview ................................................................................................................................... 4-1
4.2 Development Language............................................................................................................ 4-1
4.3 Library File ................................................................................................................................ 4-1
4.4 API List ...................................................................................................................................... 4-2
4.5 Property .................................................................................................................................... 4-3
Status ............................................................................................................................................... 4-3
LastError........................................................................................................................................... 4-3
IsValid ............................................................................................................................................... 4-4
4.6 Method ...................................................................................................................................... 4-4
OpenMonPrinter ............................................................................................................................... 4-4
CloseMonPrinter .............................................................................................................................. 4-5
LockPrinter ....................................................................................................................................... 4-5
UnlockPrinter .................................................................................................................................... 4-6
DirectIOEx ........................................................................................................................................ 4-6
ResetPrinter ..................................................................................................................................... 4-7
SetStatusBack .................................................................................................................................. 4-8
CancelStatusBack ............................................................................................................................ 4-8
PowerOff .......................................................................................................................................... 4-9
GetCounter ....................................................................................................................................... 4-9
ResetCounter ................................................................................................................................. 4-10
GetType .......................................................................................................................................... 4-11
GetPrnCapability ............................................................................................................................ 4-12
OpenDrawer ................................................................................................................................... 4-13
SendDataFile.................................................................................................................................. 4-13
DirectSendRead ............................................................................................................................. 4-14
GetProperty .................................................................................................................................... 4-15
SetProperty .................................................................................................................................... 4-16
4.7 Event ....................................................................................................................................... 4-18
StatusCallback ............................................................................................................................... 4-18
TOC - 2
6.5 Printer ID ................................................................................................................................... 6-4
6.6 Target Drawer ........................................................................................................................... 6-4
6.7 Drawer Kick Time ...................................................................................................................... 6-5
6.8 Property ID ................................................................................................................................ 6-6
TOC - 3
Chapter 1 Overview
1.1 Introduction
This chapter describes the overview of the Communication library.
The Communication library is a dynamic library to directly control printers, provided with the
printer driver for developers.
The Communication library uses the printer driver to work.
You can use the Communication library to directly control printers in an application
development and design the application independent of the port type.
Also, it is possible to retrieve or change values of some private DEVMODE setting items.
For details of specific usages of the Communication library, see sample programs provided for
each language.
1-1
Chapter 2 Installation
2-1
Chapter 3 Win32 API
3.1 Overview
This chapter describes the Communication library for Win32 development environment (Win32
API).
3-1
3.4 API List
The following APIs are implemented in the Communication library.
API Brief Description of the Function
RpOpenMonPrinterA*1 Starts using the Communication library in the specified printer
RpOpenMonPrinterW *1 and returns the API handle.
Ends using the Communication library with the specified API
RpCloseMonPrinter
handle.
RpLockPrinter*2 Locks the data transmission and reset control to the printer.
RpUnlockPrinter Unlocks the data transmission and reset control to the printer.
Sends/Receives binary data.
RpDirectIO*2,*3 (Receive data does not include responses for the ASB Setting
command)
RpDirectIOEx*2,*3 Sends/Receives binary data.
*2,*3
RpResetPrinter Resets the printer.
RpGetStatus Retrieves the latest POS printer status.
Registers the callback function to be called when a change of
RpSetStatusBackFunction
the POS printer status is detected.
Registers the window handle of a button for which the click
RpSetStatusBackWnd event is called when a change of the POS printer status is
detected, and the variable to set the POS printer status.
Unregisters the callback function which was executed in
RpCancelStatusBack
RpSetStatusBackWnd and RpSetStatusBackFunction.
RpPowerOff*2,*3 Turns the printer power off.
*2,*3
RpGetCounter Retrieves the specified maintenance counter.
*2,*3
RpResetCounter Initializes the specified maintenance counter.
*2,*3
RpGetType Retrieves the type ID and font type of the printer.
*2,*3
RpGetPrnCapability Retrieves the specified printer information.
*2,*3
RpOpenDrawer Opens the specified drawer.
*1
RpSendDataFileA Registers the command using the specified command
RpSendDataFileW *1 definition file.
RpDirectSendReadA*1,*2,*3
Executes a command registered by RpSendDataFile.
RpDirectSendReadW*1,*2,*3
RpGetProperty Retrieves the specified property ID.
RpSetProperty Changes the specified property ID.
*1: Specify arguments of strings by MBCS (MultiByte Character Set) or Unicode. Use API added the
suffix 'A' for MBCS or 'W' for Unicode. Note that a suffix of 'A' or 'W' is omitted in the following
descriptions.
*2: When RpLockPrinter was called from another process, this API fails.
*3: When there is a print job in the spooler, or any disconnection or communication failure with the
printer occurs, this API fails.
3-2
3.5 API Details
Caution
For Bluetooth connection, when the connection is once disconnected, part of response
data may not be retrieved.
For Bluetooth connection, response data of the disconnected printer cannot be
retrieved.
RpOpenMonPrinter
Starts using the Communication library in the specified printer and returns the API handle.
INT RpOpenMonPrinter(
INT i_type,
LPCTSTR i_prt )
Parameters
i_type
Open type
2 (fixed)
i_prt
Name of the printer that uses the Communication library
Specifies the printer name (friendly name).
Return value
Returns the API handle to identify the printer for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• The number that printers open per process is up to eight.
• When the API handle retrieved in this API is not used, be sure to close it by
RpCloseMonPrinter.
• When the printer driver connects to FILE, this API fails.
• This API succeeds even when the printer is not connected to the system or the printer
power is turned off.
3-3
RpCloseMonPrinter
Ends using the Communication library with the specified API handle.
INT RpCloseMonPrinter(
INT i_hdl )
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• RpSetStatusBackFunction and RpSetStatusBackWnd stop monitoring the POS printer
status.
• When the API handle called with this API is used in another API, this API is not executed
until it is completed.
• The command data registered by RpSendDataFile is discarded.
RpLockPrinter
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_timeout
Timeout period
Specifies the timeout period in msec (millisecond).
3-4
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• This API allows to exclusively occupy the data transmission and reset control to the
printer. To release it, use RpUnlockPrinter.
• When an API which performs data transmission or reset control to the printer from
another process is used after the calling of this API until RpUnlockPrinter execution, it will
fail.
• An occupation by this API is valid within the process. Therefore, during the occupation,
an API can directly access the device from another thread in the same process.
• The number of times this API is repeatedly executed with an already occupied API
handle is up to 99 times. To release it, execute RpUnlockPrinter the same times as for
this API.
• The range of i_timeout is from 3000 ms to 90000 ms. When the value is less than 3000
ms, it is corrected to 3000 ms and when the value is more than 90000 ms, it is corrected
to 90000 ms.
RpUnlockPrinter
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• Unlocks the lock of the printer set by RpLockPrinter.
• When RpLockPrinter is called more than one time, this API must be called the same time
as for RpLockPrinter to release the lock.
3-5
RpDirectIO
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_wlen
Size of data to send
Specifies the size of data to send.
i_wcmd
Buffer of data to send
Specifies the buffer to store the data to send.
io_rlen
Size of data to receive
Specifies the maximum length of data to be received from the printer.
When no data retrieval is needed, specify "0".
When the API returns, the size of the retrieved receive data is stored.
o_rbuf
Buffer of data to receive
Specifies the buffer to store the data to retrieve.
i_timeout
Timeout period
Specifies the timeout period in msec (millisecond).
3-6
i_flag
Receive operation flag
Specifies one of the following flags for the receive operation.
TRUE: Continues receiving until anything is received or timeout occurs.
FALSE: Continues receiving until the data of read size is received or timeout occurs.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• This API is aborted by RpResetPrinter.
• The range of i_timeout is from 3000 ms to 90000 ms. When the value is less than 3000
ms, it is corrected to 3000 ms and when the value is more than 90000 ms, it is corrected
to 90000 ms.
• When multiple processes use the Communication library and they use this API to send
divided data more than one time, unexpected output from other processes may interrupt
before completion of transmission. When outputting such commands and data that do
not allow interrupting of other data, especially for image data, be sure to use this API after
calling RpLockPrinter.
• Receive data does not include responses for the ASB Setting command. When
responses including ones of the ASB Setting command are retrieved, execute
RpDirectIOEx.
• Do not include the data which the ASB Setting command is disabled in the binary data to
send. Otherwise, an API which retrieves POS printer status does not work properly.
• For Bluetooth connection, do not include a printer command "Hardware Reset" or "Printer
Reset" in the binary data to send.
When executing hardware reset, use RpResetPrinter.
RpDirectIOEx
3-7
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_wlen
Size of data to send
Specifies the size of data to send.
i_wcmd
Buffer of data to send
Specifies the buffer to store the data to send.
io_rlen
Size of data to receive
Specifies the maximum length of data to be received from the printer.
When no data retrieval is needed, specify "0".
When the API returns, the size of the receive data is stored.
o_rbuf
Buffer of data to receive
Specifies the buffer to store the data to retrieve.
i_timeout
Timeout period
Specifies the timeout period in msec (millisecond).
i_flag
Receive operation flag
Specifies one of the following flags for the receive operation.
TRUE: Continues receiving until anything is received or timeout occurs.
FALSE: Continues receiving until the data of read size is received or timeout occurs.
i_op
Receive target option
Specifies one of the following options for data to receive.
0: Retrieves response data excluding responses for the ASB Setting command
1: Retrieves response data including responses for the ASB Setting command
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
3-8
Remarks
• This API is aborted by RpResetPrinter.
• The range of i_timeout is from 3000 ms to 90000 ms. When the value is less than 3000
ms, it is corrected to 3000 ms and when the value is more than 90000 ms, it is corrected
to 90000 ms.
• When multiple processes use the Communication library and they use this API to send
divided data more than one time, unexpected output from other processes may interrupt
before completion of transmission. When outputting such commands and data that do
not allow interrupting of other data, especially for image data, be sure to use this API after
calling RpLockPrinter.
• Size of data to receive is up to 4096 bytes. When an exceeding data size is specified,
data for 4096 bytes is set.
• Do not include the data which the ASB Setting command is disabled in the binary data to
send. Otherwise, an API which retrieves POS printer status does not work properly.
• For Bluetooth connection, do not include a printer command "Hardware Reset" or "Printer
Reset" in the binary data to send.
When executing hardware reset, use RpResetPrinter.
RpResetPrinter
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• Resets the printer using the communication protocol (without using printer commands).
• When this API is called during execution of RpDirectIO, RpDirectIOEx, or
RpDirectSendRead, these APIs are aborted.
• After performing hardware reset with this API, wait for a few seconds until the printer
reset process completes before outputting any data. Data output during the hardware
reset may cause skipped data.
• During execution of this API, POS printer status responds disconnected status.
• When executing this function but the printer is in data unaccepting status, the printer
resetting may not be correctly completed and garble character may occur.
3-9
RpGetStatus
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
o_status
POS printer status variable
Specifies the variable to store the POS printer status.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• When reconnection of the printer is detected, the POS printer status that was received
last will be returned.
• When the POS printer status cannot be retrieved in connected condition, this API fails.
• For details of the POS printer status, see "6.1 POS Printer Status List".
RpSetStatusBackFunction
Registers the callback function to be called when a change of the POS printer status is
detected.
INT RpSetStatusBackFunction(
INT i_hdl,
INT ( CALLBACK EXPORT *lpStatusCB ) ( DWORD o_st ) )
3-10
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
lpStatusCB
Callback function address
Specifies the address of an application-defined callback function to receive the POS
printer status.
o_st
POS printer status variable
Specifies the variable to store the POS printer status.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• The callback function registered by this API is unregistered by RpCancelStatusBack and
RpCloseMonPrinter. It is also unregistered by specifying NULL for lpStatusCB.
• APIs in the Communication library cannot be called with the same API handle from the
registered callback function.
• When the POS printer status cannot be retrieved in connected condition, this API fails.
• When reconnection is detected, the POS printer status that was received last will be
returned.
• Even when the POS printer status is received, the callback function will not be called
when the POS printer status has not changed from when it was last received.
• When the callback function is registered with this API, the callback function is called with
the current POS printer status.
• When the callback function is already registered and this API is called again, the
registered API becomes invalid and the new callback function will be registered.
• Even when this API is called again specifying the already registered valid callback
function, the POS printer status response is performed immediately after it.
• The return value of the callback function is ignored.
• The time between receiving the POS printer status and calling the callback function is not
guaranteed.
• For details of the POS printer status, see "6.1 POS Printer Status List".
3-11
RpSetStatusBackWnd
Registers the window handle of a button for which the click event is called when a change of
the POS printer status is detected, and the variable to set the POS printer status.
INT RpSetStatusBackWnd(
INT i_hdl,
HANDLE i_Wnd,
LPDWORD i_status )
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_Wnd
Window handle
Specifies the window handle of the button to send the click event.
i_status
POS printer status variable
Specifies the variable to store the POS printer status.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• This API is unregistered by RpCancelStatusBack and RpCloseMonPrinter. It is also
unregistered by specifying NULL for the window handle of the button.
• When the POS printer status cannot be retrieved in connected condition, this API fails.
• When reconnection is detected, the POS status that was received last will be returned.
• Even when the POS printer status is received, the click event will not be called when the
POS printer status has not changed from when it was last received.
• When the window handle of a button is registered by this API, the click event with the
current POS printer status is called.
• When the callback function is registered with this API, the click event is called with the
current POS printer status.
• When this API is called again when the window handle of a button is already registered, it
is disabled and the one of the new button is registered.
• Even when this API is called again specifying the already registered valid window handle
of a button, the POS printer status response is performed immediately after it.
• The return value of the click event is ignored.
3-12
• The time between receiving the POS printer status and calling the click event is not
guaranteed.
• For details of the POS printer status, see "6.1 POS Printer Status List".
RpCancelStatusBack
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• This API succeeds even when neither RpSetStatusBackWnd nor
RpSetStatusBackFunction are registered.
RpPowerOff
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
3-13
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• When this API is executed, the power off operation is performed on the printer.
RpGetCounter
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_readno
Counter ID
Specifies the counter ID to retrieve.
o_readcounter
Counter variable
Specifies the variable to store the counter value to retrieve.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• For details of the counter ID, see "6.2 Counter ID".
3-14
RpResetCounter
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_readno
Counter ID
Specifies the counter ID to initialize.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• For details of the counter ID, see "6.2 Counter ID".
• Check that the counter ID value specified by this API is initialized by using
RpGetCounter.
RpGetType
3-15
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
o_typeID
Type ID variable
Specifies the variable to store the type ID.
o_font
Font type variable
Specifies the variable to store the font type.
o_exrom
Reserved
Specifies NULL.
o_special
Reserved
Specifies NULL.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• For details of the type ID, see "6.3 Type ID".
• For details of the font type, see "6.4 Font Type".
RpGetPrnCapability
3-16
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_id
Printer ID
Specifies the printer ID to retrieve.
io_datsize
Size of data to receive
Specifies the size of the buffer to store the printer ID to retrieve.
When the API returns, retrieved size of data to receive is stored.
o_dat
Buffer of data to receive
Specifies the buffer to store the value of printer ID to retrieve.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• For details of the printer ID, see "6.5 Printer ID".
• When the size specified by io_datsize is smaller than the response size of the specified
printer ID or NULL is specified for o_dat, API fails and the response size of the specified
printer ID is stored in io_datsize.
RpOpenDrawer
3-17
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_drawer
Target drawer
Specifies the drawer to use.
i_pulse
Drawer kick time
Specifies the drawer kick time for the target drawer.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• For details of the target drawer, see "6.6 Target Drawer".
• For details of the drawer kick time, see "6.7 Drawer Kick Time".
RpSendDataFile
Registers the command data using the specified command definition file.
INT RpSendDataFile(
INT i_hdl,
LPCTSTR i_fname )
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_fname
Command definition file name
Specifies the name of a command definition file created in the predefined format.
3-18
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• For details of the command definition file, see "Chapter 7 Command Definition File".
• The command data registered by this API is discarded by calling RpCloseMonPrinter.
RpDirectSendRead
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_cname
Command name
Specifies a command name defined in RpSendDataFile.
i_rtype
Receive data type name
ASB: Stores only the responses for the ASB Setting command in the receive data.
Other: Stores the other responses from the printer in the receive data.
3-19
io_rlen
Size of data to receive
Specifies the maximum length of data to be received from the printer.
When no data retrieval is needed, specify "0".
When the API returns, the size of the retrieved receive data is stored.
o_rbuf
Buffer of data to receive
Specifies the buffer to store the data to retrieve.
i_timeout
Timeout period
Specifies the timeout period in msec (millisecond).
i_flag
Receive operation flag
Specifies one of the following flags for the receive operation.
TRUE: Continues receiving until anything is received or timeout occurs.
FALSE: Continues receiving until the data of read size is received or timeout occurs.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
Remarks
• Do not include the data which the ASB Setting command is disabled in the binary data to
send. Otherwise, an API which retrieves POS printer status does not work properly.
• This API is aborted by RpResetPrinter.
• The range of i_timeout is from 3000 ms to 90000 ms. When the value is less than 3000
ms, it is corrected to 3000 ms and when the value is more than 90000 ms, it is corrected
to 90000 ms.
• Size of data to receive is up to 4096 bytes. When an exceeding data size is specified,
data for 4096 bytes is set.
• For Bluetooth connection, do not include a printer command "Hardware Reset" or "Printer
Reset" in the binary data to send.
When executing hardware reset, use RpResetPrinter.
3-20
RpGetProperty
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_devmode
Devmode address
Specifies the Devmode address.
i_pid
Property ID
Specifies the property ID to retrieve.
o_dat
Buffer of data to retrieve
Specifies the buffer to store the content of the property ID to retrieve.
io_size
Size of data to retrieve
Specifies the maximal length of data to retrieve.
When the API returns, the size of the retrieved data is stored.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
3-21
Remarks
• For details of the property ID, see "6.8 Property ID".
• When the size specified by io_size is smaller than the response size of the specified
property ID or NULL is specified for o_dat, the response size of the specified property ID
is stored in io_size.
RpSetProperty
Parameters
i_hdl
API handle
Specifies the API handle retrieved by RpOpenMonPrinter.
i_devmode
Devmode address
Specifies the Devmode address.
i_pid
Property ID
Specifies the property ID to change.
o_dat
Buffer of data to set
Specifies the buffer to store the content of the property ID to change.
i_size
Size of data to set
Specifies the buffer size to store the content of the property ID to change.
Return value
Returns 0 for success.
Returns an error code for failure. See "Chapter 5 Error Code List" for details.
3-22
Remarks
• For details of the property ID, see "6.8 Property ID".
3-23
Chapter 4 .NET API
4.1 Overview
This chapter describes the Communication library for .NET development environment (.NET
API).
• SiiRpd1ClassLib.dll
The Communication library file is stored in the Global Assembly Cache (GAC) folder.
4-1
4.4 API List
The following APIs are implemented in the Communication library.
• Namespace: SiiPrinterSdk
• Class name: StatusAPI
4-2
4.5 Property
Status
Initial value
0
Remarks
• To retrieve a failure of this property, use LastError. In case of a failure, the value of this
property is not defined.
• For details of retrievable values, see "6.1 POS Printer Status List".
• For details, see RpGetStatus in "Chapter 3 Win32 API".
LastError
Initial value
SUCCESS
Remarks
For details of retrievable values, see "Chapter 5 Error Code List".
4-3
IsValid
Initial value
FALSE
Remarks
One of the following values are retrieved.
4.6 Method
OpenMonPrinter
Starts using the Communication library in the specified printer and returns the API handle.
ErrorCode OpenMonPrinter(
OpenType type,
string name )
Parameters
type
Open type
TYPE_PRINTER: Specifies the printer driver name to open the printer (fixed).
name
Name of the printer that uses the Communication library
Specifies the printer name (friendly name) to output.
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details, see RpOpenMonPrinter in "Chapter 3 Win32 API".
4-4
CloseMonPrinter
Ends using the Communication library with the specified API handle.
ErrorCode CloseMonPrinter ()
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details, see RpCloseMonPrinter in "Chapter 3 Win32 API".
LockPrinter
Parameters
timeout
Timeout period
Specifies the timeout period in msec (millisecond).
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details, see RpLockPrinter in "Chapter 3 Win32 API".
4-5
UnlockPrinter
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details, see RpUnlockPrinter in "Chapter 3 Win32 API".
DirectIOEx
4-6
Parameters
cmd
Buffer of data to send
Specifies the buffer to store the data to send.
data
Buffer of data to receive
Specifies the buffer to store the data to retrieve.
timeout
Timeout period
Specifies the timeout period in msec (millisecond).
readFlag
Receive operation flag
Specifies one of the following flags for the receive operation.
TRUE: Continues receiving until anything is received or timeout occurs.
FALSE: Continues receiving until the data of read size is received or timeout occurs.
option
Receive target option
Specifies one of the following options for data to receive.
0: Retrieves response data excluding responses for the ASB Setting command
1: Retrieves response data including responses for the ASB Settiing command
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
• When this API succeeds, ref byte[] data is resized to the size of the receive data, with an
upper limit of the size specified before the call.
• Any 0x02 included in the receive data is converted to 0x5f.
• For details, see RpDirectIOEx in "Chapter 3 Win32 API".
ResetPrinter
4-7
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details, see RpResetPrinter in "Chapter 3 Win32 API".
SetStatusBack
Registers the callback method to be called when a change of the POS printer status is
detected.
ErrorCode SetStatusBack()
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details, see RpSetStatusBackFunction in "Chapter 3 Win32 API".
CancelStatusBack
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details, see RpCancelStatusBack in "Chapter 3 Win32 API".
4-8
PowerOff
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details, see RpPowerOff in "Chapter 3 Win32 API".
GetCounter
Parameters
index
Counter ID
Specifies the counter ID to retrieve or the value of a counter ID defined in
SII.Driver.PosPrinter.CounterIndex.
type
Type of maintenance counter
One of the following types of maintenance counter to retrieve
TRUE: Integrated counter
FALSE: Initializable counter
4-9
data
Counter variable
Specifies the variable to store the counter value to retrieve.
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details of the counter ID, see "6.2 Counter ID".
For details, see RpGetCounter in "Chapter 3 Win32 API".
ResetCounter
Parameters
index
Counter ID
Specifies the counter ID to initialize or the value of a counter ID defined in
SII.Driver.PosPrinter.CounterIndex.
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details, see RpResetCounter in "Chapter 3 Win32 API".
4-10
GetType
Parameters
typeId
Type ID variable
Specifies the variable to store the type ID.
font
Font type variable
Specifies the variable to store the font type.
exrom
Reserved
Specifies NULL.
special
Reserved
Specifies NULL.
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details of the type ID, see "6.3 Type ID".
For details of the font type, see "6.4 Font Type".
For details, see RpGetType in "Chapter 3 Win32 API".
4-11
GetPrnCapability
Parameters
id
Printer ID
Specifies the printer ID to retrieve.
data
Buffer of data to receive
Specifies the buffer to store the value of printer ID to retrieve.
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details of the printer ID, see "6.5 Printer ID".
For details, see RpGetPrnCapability in "Chapter 3 Win32 API".
4-12
OpenDrawer
Parameters
drawer
Target drawer
Specifies the value of target drawer to open, defined in SII.Driver.PosPrinter.Drawer.
pulse
Drawer kick time
Specifies the value of drawer kick time, defined in SII.Driver.PosPrinter.Drawer.
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details of the target drawer, see "6.6 Target Drawer".
For details of the drawer kick time, see "6.7 Drawer Kick Time".
For details, see RpOpenDrawer in "Chapter 3 Win32 API".
SendDataFile
Registers the transmission data using the specified command definition file.
ErrorCode SendDataFile(
string fileName )
4-13
Parameters
fileName
Command definition file name
Specifies the name of a command definition file created in the predefined format.
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details of the command definition file, see "Chapter 7 Command Definition File".
For details, see RpSendDataFile in "Chapter 3 Win32 API".
DirectSendRead
4-14
Parameters
cmdName
Command name
Specifies a command name defined in SendDataFile.
readType
Receive data type name
ASB: Stores only the responses for the ASB Setting command in the receive data.
Other: Stores the other responses from the printer in the receive data.
data
Buffer of data to receive
Specifies the buffer to store the data to retrieve.
timeout
Timeout period
Specifies the timeout period in msec (millisecond).
readFlag
Receive operation flag
Specifies one of the following flags for the receive operation.
TRUE: Continues receiving until anything is received or timeout occurs.
FALSE: Continues receiving until the data of read size is received or timeout occurs.
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
• Any 0x02 included in the receive data is converted to 0x5f.
• For details, see RpDirectSendRead in "Chapter 3 Win32 API".
GetProperty
4-15
Parameters
devmode
DevMode address
Specifies the Devmode address.
id
Property ID
Specifies the property ID to retrieve.
data
Buffer of data to retrieve
Specifies the buffer to store the content of the property ID to retrieve.
size
Size of data to retrieve
Specifies the maximal length of data to retrieve.
When the API returns, the size of the retrieved data is stored.
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
For details of the property ID, see "6.8 Property ID".
For details, see RpGetProperty in "Chapter 3 Win32 API".
SetProperty
Parameters
devmode
DevMode address
Specifies the Devmode address.
4-16
id
Property ID
Specifies the property ID to change.
data
Buffer of data to set
Specifies the buffer to store the content of the property ID to change.
size
Size of data to set
Specifies the size of the buffer to store the content of the property ID data to
change.
Return value
For details of the return value, see "Chapter 5 Error Code List".
Remarks
• For details of the property ID, see "6.8 Property ID".
• For details, see RpSetProperty in "Chapter 3 Win32 API".
4-17
4.7 Event
StatusCallback
Parameters
status
POS printer status variable
Specifies the variable to store the POS printer status.
Remarks
• For details of the POS printer status, see "6.1 POS Printer Status List".
• For details, see RpSetStatusBackFunction in "Chapter 3 Win32 API".
4-18
Chapter 5 Error Code List
5-1
Macro Definition (Constant) Value Description
ERR_UNKNOWN_PORT -1070 Port is not supported.
ERR_INVALID_PRINTER_STATE -1080 Printer status is abnormal.
ERR_BAD_ENVIRONMENT -1090 Printer driver installation may be abnormal.
5-2
Chapter 6 Argument Information
Caution
The POS printer status includes the status to respond for the ASB Setting command
and some extended statuses.
The responses not described below are reserved.
There are the following responses for the POS printer status.
Status Response Value Description
No head
0x00000000
ASB_HEAD_ temperature error
Head temperature error
TEMPERATUR_ERR Head temperature
0x00000004
error
No out-of-paper
0x00000000
error
Out-of-paper error ASB_RECEIPT_END
0x00000010 Out-of-paper error
6-1
Status Response Value Description
0x00000000 Stop
Paper feed status ASB_NOW_PRINTING
0x00000400 Operating
0x00000000 -
Recovery waiting status ASB_RETURN_WAITING
Recovery waiting
0x00000800
status
Drawer sensor
0x00000000
status = "Low"
Drawer sensor status ASB_DRAWER_KICK
Drawer sensor
0x00008000
status = "High"
0x00000000 -
ASB_FLASH_MEMORY_
FLASH memory rewriting
REWRITING FLASH memory
0x00010000
rewriting
0x00000000 Printer
Peripheral device ASB_PERIPHERAL_
selection EQUIPMENT
0x00020000 Other
No automatic
0x00000000
ASB_AUTORECOVER_ recovery error
Automatic recovery error
ERR*1 Automatic recovery
0x20000000
error
No unrecoverable
0x00000000
ASB_UNRECOVER_ error
Unrecoverable error
ERR*1
0x40000000 Unrecoverable error
6-2
6.2 Counter ID
There are the following responses for the counter ID.
Counter ID Description
Number of dot lines for paper feed
ROLL_FEED_LINES 20 Initializable
(unit: 100-dot line)
Thermal head activation time
ROLL_HEAD_CHARGE 21 Initializable
(unit: 100-dot line)
PAPER_CUT 50 Initializable Number of autocutter drive times
OPERATION_TIME 70 Initializable Product drive time (unit: minute)
Integrated Number of dot lines for paper feed
ROLL_FEED_LINES 148
value (unit: 100-dot line)
Integrated Thermal head activation time
ROLL_HEAD_CHARGE 149
value (unit: 100-dot line)
Integrated
PAPER_CUT 178 Number of autocutter drive times
value
Integrated
OPERATION_TIME 198 Product drive time (unit: minute)
value
6.3 Type ID
There are the following responses for the type ID.
Response Value Description
0: Multi-byte code not supported
0x01
1: Multi-byte code supported
0: Autocutter not available
0x02
1: Autocutter available
0x04 Fixed to zero
0x08 Fixed to zero
0x10 Fixed to zero
0x20 Fixed to zero
0x40 Fixed to zero
0x80 Fixed to zero
An retrievable response value is the addition of the above value.
6-3
6.4 Font Type
There are the following responses for the font type.
Response Value Description
2 Japanese kanji(JIS)
6.5 Printer ID
There are the following available printer IDs with their responses.
Response
Printer ID Description
Format
1 Printer model ID 0x1c HEX code
2 Type ID See "6.3 Type ID". HEX code
3 ROM version ID Depends on ROM version HEX code
65 Firmware version (main) "X.XX.XX" ASCII string
66 Manufacturer "Seiko Instruments Inc." ASCII string
67 Model name "SII RP-D10 Series." ASCII string
For Japanese: "KANJI
69 Multi-language font type ASCII string
JAPANESE"
6-4
6.7 Drawer Kick Time
There are the following available drawer kick times.
Drawer Kick Time Description
1 SII_RP_ PULSE_100 Drives the drawer in 100 millisecond
2 SII_RP_ PULSE_200 Drives the drawer in 200 millisecond
3 SII_RP_ PULSE_300 Drives the drawer in 300 millisecond
4 SII_RP_ PULSE_400 Drives the drawer in 400 millisecond
5 SII_RP_ PULSE_500 Drives the drawer in 500 millisecond
6 SII_RP_ PULSE_600 Drives the drawer in 600 millisecond
7 SII_RP_ PULSE_700 Drives the drawer in 700 millisecond
8 SII_RP_ PULSE_800 Drives the drawer in 800 millisecond
6-5
6.8 Property ID
Caution
For a property ID not described below, the value set in the printer driver is valid.
Specify the data size to 1 byte except for custom command for using RpSetProperty.
The phrase in square brackets ([ ]) indicates the timing of corresponding process.
There are the following available property IDs with their contents.
Property ID Description
0: Enabled
1 Initialize
1: Disabled
0: Middle (Silent)
1: Low
2 Speed
2: Middle (Quality)
3: High
0: Minimum Margin
1: Minimum Top Margin
3 Margins
2: Minimum Bottom Margin
3: Maximum Margin
4 Density (percentage) 70 to 130
0: Front to Back
5 Direction
1: Back to Front
0: None
6 Reduction
25 to 100: Scale (percentage)
0: None
1: Full cut (Each job)
2: Partial cut (Each job)
7 Paper Cut
3: Full cut (Each page)
4: Partial cut (Each page)
5: Partial cut (Between pages)
0: Enabled
9 Feed to Cut Position
1: Disabled
0: Disabled
[Print Start] 1: Left
10
Logo 2: Center
3: Right
[Print Start]
11 0 to 99
Logo Keycode
0: Disabled
[Print Start]
12 1: Drawer 1
Drawer*1
2: Drawer 2
6-6
Property ID Description
[Print Start]
13 1 to 255
ON Time (×2 ms)
[Print Start]
14 1 to 255
OFF Time (×2 ms)
[Print Start]
15 Command data
Custom Command. (128 bytes)
[Print Start]
16*2 Paper feed (backward feed) 0 to 72
(dot)
[Print Start]
17*2 0 to 255
Paper feed (feed) (dot)
[Print Start] 0: ON
18
Buzzer 1: OFF
0: Disabled
[Page Start] 1: Left
20
Logo 2: Center
3: Right
[Page Start]
21 0 to 99
Logo Keycode
[Page Start]
25 Command data
Custom Cmd. (128 bytes)
[Page Start]
26*2 Paper feed (backward feed) 0 to 72
(dot)
[Page Start]
27*2 0 to 255
Paper feed (feed) (dot)
[Page Start] 0: ON
28
Buzzer 1: OFF
0: Disabled
[Page End] 1: Left
30
Logo 2: Center
3: Right
[Page End]
31 0 to 99
Logo Keycode
[Page End]
35 Command data
Custom Cmd. (128 bytes)
[Page End]
36*2 Paper feed (backward feed) 0 to 72
(dot)
[Page End]
37*2 0 to 255
Paper feed (feed) (dot)
[Page End] 0: ON
38
Buzzer 1: OFF
0: Disabled
[Print End] 1: Left
40
Logo 2: Center
3: Right
6-7
Property ID Description
[Print End]
41 0 to 99
Logo Keycode
0: Disabled
[Print End]
42 1: Drawer 1
Drawer*1
2: Drawer 2
[Print End]
43 1 to 255
ON Time (×2 ms)
[Print End]
44 1 to 255
OFF Time (×2 ms)
[Print End]
45 Command data
Custom Cmd. (128 bytes)
[Print End]
46*2 Paper feed (backward feed) 0 to 72
(dot)
[Print End]
47*2 0 to 255
Paper feed (feed) (dot)
[Print End] 0: ON
48
Buzzer 1: OFF
0: Letter
1: A4
50 Paper Size 2: 80 mm
3: 58 mm
4 to 255: Paper except for the above*3
0: Portrait
51 Orientation
1: Landscape
0: System*4
52 Color Printing Mode
1: Driver*4
0: None
1: Top Left
2: Top Center
3: Top Right
4: Left
53 Watermark
5: Center
6: Right
7: Bottom Left
8: Bottom Center
9: Bottom Right
0: 80mm Receipt Setting
1: 58mm Receipt Setting
60*5 Preset 4: A4->80mm Reduction Setting
5: A4->58mm Reduction Setting
6: User Setting
*1: The drawer at specific timing is not available simultaneously.
*2: When setting feed and backward feed at same timing, the last setting is valid.
*3: Cannot be set. Retrieval only.
*4: See "3.3.1 Setting of Paper/Quality" in the Printer driver user's guide for details.
*5: When specified this property, some data of other property IDs is ignored. See "3.4.4 Use of
[Preset]" in the Printer driver user's guide.
6-8
Chapter 7 Command Definition File
7.1 Format
A command definition file is created in the following format.
Command definition
• One command definition must be specified in one line.
• Multiple commands must be specified in multiple lines.
• Comments are optional.
[Command name 1] = [Command data to send 1]#[Comment 1]
[Command name 2] = [Command data to send 2]#[Comment 2]
[Command name 3] = [Command data to send 3]#[Comment 3]
•
•
•
Example of command definitions:
CmdName_1="SII"#Comments1
CmdName_2="SII" 0A#Comments2
CmdName_3=53 49 49 0A
[Command name]
• Specifies the command name for data to send to the printer on the left of "=".
• Use ASCII characters except for "=" and "#" as command name.
• When characters other than ASCII characters are found in command name, they are
ignored.
• Command name is case-sensitive.
• Registerable command name is up to 33 bytes. When 34 bytes or more is used for
command name specification, up to 33 bytes are registered, and subsequent characters
are ignored.
• When command name which is already registered is specified, it is ignored.
7-1
[Command data to send]
• Specifies command data to send to the printer on the right of "=".
• When you include strings in command data to send, enclose them with "".
• When you use binary data as command data to send, describe it in two-digit hexadecimal
numbers.
Separate each number with a space.
• Use ASCII characters for specifying the command data to send with the characters.
• Size of of command data to send is up to 10240 bytes. Specify command data to send up
to 10240 bytes.
However, when you use strings to specify command data to send, they are converted to
binary data to determine the actual size.
In the above example of command definitions, the size of data to send is 3 bytes for
CmdName_1, 4 bytes for CmdName_2, and 4 bytes for CmdName_3.
[Comment]
• Specify "#" at the beginning of the comment to describe.
• There is no limitation of characters used for comment.
7.2 Limitation
There are the following limitations on the command definition file.
7-2
Seiko Instruments Inc.
1-8, Nakase, Mihama-ku, Chiba-shi,
Chiba 261-8507, Japan
Print System Division
Telephone:+81-43-211-1106
Facsimile:+81-43-211-8037