0% found this document useful (0 votes)
331 views54 pages

README StarIO PortablePrinter Android SDK

This sample project contains StarIO components from StarIO Version 2.0.0.0. Details of StarIO(Restrictions, Precautions) are found in the manuals located here:

Uploaded by

Zahir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
331 views54 pages

README StarIO PortablePrinter Android SDK

This sample project contains StarIO components from StarIO Version 2.0.0.0. Details of StarIO(Restrictions, Precautions) are found in the manuals located here:

Uploaded by

Zahir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

StarIO Software Development Kit for Android

Android Software Development Kit


How to Use StarIO for Portable Printers

This SDK contains a Java Eclipse project for Android devices.

Supported Versions

Supported Star Interfaces

Compatible StarIO JAR File

Android OS 2.2 and Higher

Bluetooth, Ethernet, WLAN

StarIOPort3.1.jar

Android OS 2.1

Bluetooth, Ethernet, WLAN

StarIOPort.jar

Tools

Needed:
JDK 6
Eclipse
Android SDK Manager
ADT (Android Development Tool) Plugin for Eclipse
USB Windows Driver by Android Device Manufacturer
StarIO Android SDK

StarIO Software Development Kit for Android

Table of Contents
v About this Manual
v Star Portable Printer Compatibility Chart
v Connecting a Star Portable Printer to an Android Device
o Bluetooth
o Network Interface
v Configuring an Android Device for Development
v How to Import and Run the Android SDK
v Using the SDK with Star Micronics Portable Printers
o Wireless LAN
o Bluetooth Port Discovery
o Bluetooth Manual Port Entry
v
v Overview of how this Android SDK is designed
v StarIO - (StarIOPort3.1.jar)
o Selecting a StarIO library
o How to include StarIO into your project
o StarIO Methods Quick Overview
v StarIO Android SDK Functionality
o Port Discovery
o Help
o Get Status
o Sample Receipts
o Begin / End Checked Printing
o 1D Barcodes
o 2D Barcodes
o Text Formatting
o Japanese Kanji Text Formatting
o Raster Graphics Printing
o Image Printing
o MSR
v Tips for software application development when using StarIO
v Additional Resources
o Star Micronics Developers Network
o ASCII Table
v SDK Version History

StarIO Software Development Kit for Android

About this Manual


This manual is designed to help you understand StarIO and how to build an Android
application to interact with Star Micronics Thermal Portable Printers. It is important to
understand the basics of the Java language. Although this SDK is for Android, there are SDKs
available for many different operating systems and programming languages at our Global
Support Site. Check the Developers Section of our site for the newest SDKs, technical
documentation, FAQs, and many more additional resources.

Key Legend:

Warning

Explains potential issues

Avoid Doing This

Explains things not to do

Note

Provides important information and tips

CAUTION:

Android is a trademark of Google Inc.


The information in this manual is subject to change without notice.
STAR MICRONICS CO., LTD. has taken every measure to provide accurate information,
but assumes no liability for errors or omissions.
STAR MICRONICS CO., LTD. is not liable for any damages resulting from the use of
information contained in this manual.
Reproduction in whole or in part is prohibited.

20122013 Star Micronics Co., Ltd.

StarIO Software Development Kit for Android

Star Printer Compatibility Chart


The below chart summarizes the Star Portable Printer Models supported on Android Operating
Systems.

Status

Sample Receipts

2D Barcodes

Text Formatting

Kanji Text Formatting

Sample Images

MSR

SM-S200

Bluetooth

(*1)

(*2)

(*2)

SM-S210i

Bluetooth

Bluetooth

Bluetooth

(*1)

(*2)

(*2)

(*1)

(*2)

(*2)

(Jp model only)

SM-S220i

(Excluding Jp
model)

SM-T300
WLAN

Raster Graphics

Interface

Begin / End Checked


Block
1D Barcodes

Model

Port Discovery

Star Printer

SM-S300

Bluetooth

(*1)

(*2)

(*2)

SM-T300i

Bluetooth

SM-S400

Bluetooth

(*1)

(*2)

(*2)

SM-T400i

Bluetooth

(*1) F/W Ver.2.4 or later is required.


(*2) F/W Ver.2.4 or later is required.
If the F/W Ver.2.3 is used, please read the notes below.
Raster Graphical Text Printing
Image File Pringing
Note: This SDK offers the most popular features, but not all printer functionality has been included. The
commands not included in this SDK application are available in the Star Mobile Printer Programming Manual.

StarIO Software Development Kit for Android

Connecting a Star Portable Printer to an Android


These screenshots were captured using an Android 4.0 tablet. Screenshots and wording can
vary between Android operating systems.
Bluetooth
1. Tap Settings.

2. Ensure Bluetooth is enabled and the printer is powered on.


3. Tap Bluetooth to access its settings.
4. Tap Search for Devices. Find the printer you wish to connect to and tap it to pair.

5. Enter the PIN number. The factory default for standard Star Portable Printers is
1234.
5

StarIO Software Development Kit for Android

6. Older Android Operating Systems, such as V2.2 in the above screenshot, display the
message Paired but not connected. This can be neglected as connection is
established at the time of printing.

Wireless LAN
1. Assign an IP Address to the Star Printer and connect it to the network. Standard Star
Printers do not ship with an IP Address pre-assigned; this can set by using the WLAN
Setup Utility for Mobile Printers available on Stars website.
2. Tap Settings.

3. Ensure Wi-Fi is enabled.


4. Connect to the same network the Star Printer is on.
5. No pairing or further settings are necessary to connect the printer as the Android
device will output data directly to the printers TCP/IP port.
6

StarIO Software Development Kit for Android

Configuring an Android Device for Development


1. Tap Settings.

2. Tap Security.

3. Enable Unknown sources.

4. Tap Developer options.

5. Enable USB debugging.

StarIO Software Development Kit for Android

Importing and Running the StarIO Android SDK

It is assumed Eclipse has already been configured to support Android development. Should you
need assistance with this, refer to Stars Android Setup Guide in the documentation folder of
this SDK package.
This section will explain:
1. How to import the Android SDK project into Eclipse.
2. Enabling debug mode in Eclipse.
3. Running the project.
How to import the Android SDK project into Eclipse:

1. Execute Eclipse.

StarIO Software Development Kit for Android

2. File > Import

StarIO Software Development Kit for Android

3. General > Existing Projects into Workspace

10

StarIO Software Development Kit for Android

4. Browse to the location where the Star SDK is saved. Click Finish.

11

StarIO Software Development Kit for Android


Enabling debug mode in Eclipse:

1. Click AndroidManifest.xml.

2. Click the Application tab.


3. Set Debuggable to true.

12

StarIO Software Development Kit for Android


Running the project:

1. Choose PrinterTypeActivity.java.
2. Click the green arrow.

Tip: The above error occurs if you attempt to reinstall the .apk from a different host.
To remedy it, delete the application on your Android device and rerun the app.

13

StarIO Software Development Kit for Android

Using the SDK with Portable Star Micronics Printers


Please make sure you have a compatible Star Micronics Portable Printer Model.
Port Name and Interface Relation:
StarIO uses specific port names to identify what port will be used. These are very important
to understand because not following the naming convention correctly will fail to communicate
with the printer.
Interface
Bluetooth

Wireless LAN (TCP/IP)

Port Name
BT:
BT:Device Name

Port Settings
mini
mini

BT:Printer MAC Address

mini

TCP:IP Address

mini

(Explanation of the portSetting class variable can be found in this document.)

Using a Mobile Printer

1. Tap Star Mobile Printers. This section contains all Mobile Printer samples.

14

StarIO Software Development Kit for Android

Wireless LAN Printers

1. The IP Address must be manually entered into the PortName field.


Enter TCP:<IP Address> without brackets around the printers IP Address.

15

StarIO Software Development Kit for Android


Bluetooth Printers Port Discovery

1. Tap Search to find all connected Star Printers. Alternatively, the device name can be
manually typed into the PortName field. See here for details.

2. Tap the name of printer you want to connect to.

16

StarIO Software Development Kit for Android


Bluetooth Printers Manual Port Entry

Above: No parameters needed if using only one Star Bluetooth Printer

Above: Using the Device Name as the parameter

There are three types of port details that can be used for Star Bluetooth Printers:
1. BT: If only one Star Bluetooth Printer is connected, using BT: with no parameters
will automatically communicate to the only printer connected.
2. BT:<DeviceName> Add the full device name after BT: without brackets. This is
case sensitive so ensure it matches exactly.
3. BT:<MAC Address> Add the printers MAC Address after BT: without brackets.

Using an Android Virtual Device(AVD)


The operation of SDK can be checked by using the AVD (Android Virtual Device).
It is impossible to communicate with Star Bluetooth/USB printers.

17

StarIO Software Development Kit for Android

Overview of How This Android SDK is Designed


This overview will touch briefly on key components of the SDK.

All functionality is located in the src folder in the


com.StarMicronics.StarIOSDK package.
Run the program by selecting
PrinterTypeActivity.java; this source code is the
starting point for both POS and Mobile Printers.
See how specific functions work by clicking on
the other source files. For example,
code128Activity.java corresponds to the 1D
barcode Code128 in the GUI.
It is important to note that not every function is
available for both printer types. The first page of
each SDK manual shows which functions are
supported. They are listed again here for
convenience:
Portable Printers
No Cash Drawer support
No Cut Pattern support
POS Printers
No Magnetic Stripe Reader support
In addition, source files containing Mini are for
portable printer models only. StarBitmap.java
applies to both printer types.

18

StarIO Software Development Kit for Android

StarIO (StarIOPort3.1.jar)
The file StarIOPort3.1.jar is a library that you can include into your Java projects to expose
StarIO methods.
Selecting a StarIO Library:
The StarIO SDK contains two library files. Use the one which corresponds to the Android OS
Version your application is being developed for.

Supported Versions
Android OS 2.2 and Higher
Android OS 2.1

Supported Star Interfaces


Bluetooth, Ethernet, WLAN
Bluetooth, Ethernet, WLAN

Compatible StarIO JAR File


StarIOPort3.1.jar
StarIOPort.jar

How to include StarIO into your project:


To include this library into your project:
1. Drag the appropriate StarIO library file into the Project Explorer from the SDK package
2. Right click the project folder and choose Properties
3. Click Java Build Path

4. Click Libraries and the Add JARs button


5. At the top of your main code add:

import com.starmicronics.stario.StarIOPort;
import com.starmicronics.stario.StarIOPortException;
import com.starmicronics.stario.StarPrinterStatus;

6. Now you can access all of StarIOs methods!

19

StarIO Software Development Kit for Android


Android SDK Tools r17 and Higher:
Library management has been changed starting from Android SDK Tools r17. It is essential to
order the StarIOPort JAR before StarIOSDK/src. This method presented no problem from
Android SDK Tools r16 and lower, but caused the application to crash beginning with r17.
Star Micronics rectified this issue in the StarIO Android SDK V2.4. Please ensure the same
caution is taken when using the StarIOPort JAR in your own application.

1. Right click the project name and select properties


2. Click Java Build Path and then Order and Export
3. Highlight the StarIOPort JAR and relocate it to above the application code

20

StarIO Software Development Kit for Android

Android OS V2.2 and Higher:


Include the default library: StarIOPort3.1.jar
Upon including this library, the StarIO SDK application will successfully run. No modifications
to the source code are necessary.
Android OS 2.2 and higher support Ethernet, WLAN, and Bluetooth connections.

Android OS V2.1:
Include the legacy library: StarIOPort.jar
Upon including this library, the source code of the StarIO SDK application must be modified.

1. Comment this line:


port = StarIOPort.getPort(portName, portSettings, 10000, context);
2. Uncomment this line: port = StarIOPort.getPort(portName, portSettings, 10000);
This allows for the use of the legacy StarIOPort.jar library.
Android OS 2.1 supports Ethernet, WLAN, and Bluetooth connections.

21

StarIO Software Development Kit for Android


StarIO Methods Overview:

Property
StarIO Port class includes 3 properties; portName(String),portSettings(String),and timeout(int).

These 3 variables will be read only if accessed directly. To assign them use
getPort(portName,portSettings,timeout); which will allow you to pass in
variables to this methods which then assigns the 3 class variables with values.

portName is what you will be using to specify the port of communication to the printer.
Ex. TCP:192.168.1.2 / BT:DeviceName

portSettings must be set to mini for portable printers.

millisecond timeout controlled internally and is used for communication


in the APIs (this parameter guarantees that all of the below APIs will complete in a
bounded amount of time, but does NOT guarantee the exact timeout length)

timeout is a

22

StarIO Software Development Kit for Android


getPort
public static StarIOPort getPort(String portName, String portSettings, int timeoutMillis)
throws StarIOPortException

GetPort is what you will be using to open the port to the printer. Using one of the valid
inputs for portName and portSettings as mentioned previously before this, you can pass your
connection string into the StarIO class so that it will correctly set its private variables.
//The following would be an actual usage of getPort:
StarIOPort port = null;
try
{
port = StarIOPort.getPort(portName, portSettings, 10000);
}
catch (StarIOPortException e)
{
//There was an error opening the port
}

StarIOPort is a part of StarIO and this will allow you to create a port handle. The
above example shows the port being created and set to null then being assigned the actual
port hook on the following line that contains getPort.

Always use a try, catch when using getPort. If the port cannot be opened
because of connection problems, your program will crash unless you use a
try, catch like the above example.
When Sleep Mode is enabled, it is necessary to execute getPort() and
releasePort() before the printer physically enters Sleep Mode

23

StarIO Software Development Kit for Android


searchPrinter
public static ArrayList<PortInfo> searchPrinter(String target)
throws StarIOPortException

searchPrinter gets Bluetooth devices which connect with Android terminal, as a list.
When set BT: as a Argument value, return all Bluetooth devices, set BT: with specifc
string returns Bluetooth deivces which name from specific strings.
PortInfo class of return value includes, PortName, MAC address for Bluetooth devices and
you can get them by String getPortName(), and String getMacAddress() method.).
You can use PortName as a Argument value of getPort().

//The following would be an actual usage of searchPrinter:


try
{
List<PortInfo> portList = StarIOPort.searchPrinter(BT:Star);
for (PortInfo port : portList) {
Log.i (LOG, Port Name: + port.getPortName());
Log.i (LOG, MAC Address: + port.getMacAddress());
}
}
catch (StarIOPortException e)
{
//There was an error searching the port
}

24

StarIO Software Development Kit for Android

This sample shows, get connected Bluetooth devices which name start from Star
and output to log.

searchPrinter detects not only Star portable printers but also any
Bluetooth devices. To use original name, just search specific pritners.

25

StarIO Software Development Kit for Android


readPort
public int readPort(byte[] readBuffer, int offset, int size)
throws StarIOPortException

This method reads data from the device. Only use this if you really need to
read raw bytes from the printer.
Do not use this method to read raw status.
Use retreiveStatus for getting status.
Parameters:
readBuffer

- A byte array buffer into which data is read.

offset

- specifies where to begin writing data into the readBuffer[]

size

- Total number of bytes to read.

Returns:
The number of bytes that were actually read. Under some interface types, this
function will succeed even when no data was read in. Your application should
call this function a limited number of times until the expected data has been
read in or until an application determined retry threshold has been reached.
Throws:
StarIOPortException

26

- when a communication failure occurs

StarIO Software Development Kit for Android


releasePort
public static void releasePort(StarIOPort port)

This function closes a connection to the port specified.

Parameters:
port StarIOPort type representing a previously initialized port.
When do not send the data, release (close) ports.
Leaving a port open will cause future calls to open the port to fail.

For Ethernet Interface:


The getPort method may fail if you run it just after running releasePort.
You must run the getPort method after 500msec from releasePort.

27

StarIO Software Development Kit for Android


writePort
public int writePort(Byte[] writeBuffer, int offset, int size)
throws StarIOPortException

This method writes data to the device. Use this to print to the printer, send
commands, etc. The following is an example of how to use this method:
Please keep in mind this is the simplest way to send data to the printer.
The SDK has code in printToPrinter that is more complex than this but that code block will show you
how to verify data transmission to the printer whereas this code is just dumping it:
//Set a byte array to send to the printer
//command = { A, B, C, D, Feed 3mm, Full Cut}
Byte[] command = new Byte[] { 0x41, 0x42, 0x43, 0x44, 0x1B, 0x7A, 0x00, 0x1B, 0x64, 0x02 };
try
{
port.writePort(command, 0, command.length);
}
catch (StarIOPortException e)
{
//There was an error writing to the port
}

Remember to use a try, catch for safe programming practices.

Parameters:
writeBuffer

- Contains the output data in a byte array.

offset

- Specifies where to begin pulling data from writeBuffer .

size

- Number of bytes to write.

Returns:
The number of bytes that were actually written. Under some interface types, this
function will succeed even when no data was written out. Your application should call
this function a limited number of times until all the data has been written out or until an
application determined retry threshold has been reached.

Throws:
StarIOPortException

28

- when a communication failure occurs

StarIO Software Development Kit for Android


retreiveStatus
public StarPrinterStatus retreiveStatus ()
throws StarIOPortException

This method retrieves detailed status from the printer with StarIO.

Returns:
StarPrinterStatus structure giving the current device status
Throws:
StarIOPortException

- when a communication failure occurs

This method uses a class structure that is included with StarIO called StarPrinterStatus

This structure gives the printer's status in both boolean and binary form.
Create the StarPrinterStatus object in your project by doing the following:
StarPrinterStatus status = port.retreiveStatus();
if (printerStatus.offline == false)
{
if (status.blackMarkError == true) {
//There was a black mark error
}
if (status.compulsionSwitch == true) {
//Cash drawer is open
}
else {
//Cash drawer is closed
}
}
else {
//If true, then the printer is offline.
}

This is a list of statuses that are in the class structure StarPrinterStatus:


offline returns a Boolean.
coverOpen returns a Boolean. (SM-T300 Only)
receiptPaperEmpty returns a Boolean.

29

StarIO Software Development Kit for Android


beginCheckedBlock
public StarPrinterStatus beginCheckdBlock ()

throws StarIOPortException

This method is used in combination with endCheckedBlock and checks the completion of
printing. To check if the whole data is completely printed, you need to run this method just
before sending print data and endCheckedBlock just after sending print data.

Returns:
StarPrinterStatus structure giving the current device status
Throws:
StarIOPortException

- when a communication failure occurs


- when the printer is off line

See the sample code here.

endCheckedBlock
public StarPrinterStatus endCheckdBlock ()

throws StarIOPortException

This method is used in combination with beginCheckedBlock and checks the completion of
printing. If an error has occurred while printing, can get the return value which is the current
device status when this method is executed. You must run beginCheckedBlock just before
sending print data.

Returns:
StarPrinterStatus structure giving the current device status
Throws:
StarIOPortException

- An error sending the command (such as Off-Line)


- No response for the completion of printing from a printer within the timeout
Timeout length is specified by getPort, or is 10 seconds if specified less
than 10 seconds.
See the sample code here.

Note: The following models requires firmware 2.4 or later.


SM-S200, SM-S300, SM-S400, SM-T300 (Wi-Fi, Bluetooth model)
30

StarIO Software Development Kit for Android

try
{

port = StarIOPort.getPort(portName, portSettings, 10000, context);


//Start checking the completion of printing
StarPrinterStatus status = port.beginCheckedBlock();
//Printing
byte[] command = MiniPrinterFunctions.createPrintData(paperWidthInch);
port.writePort(command, 0, command.length);
//End checking the completion of printing
status = port.endCheckedBlock();
if (status.offline == true) {
//If true, then the printer is offline.
}

}
catch (StarIOPortException e)
{
Log.d("StarIOSample", "An timeout error has occurred during printing.");
}
finally
{
if (port != null)
{
try
{
StarIOPort.releasePort(port);
}
catch (StarIOPortException e) {}
}
}

31

StarIO Software Development Kit for Android

generateBitImageCommand
public byte[] generateBitImageCommand (int width, int height,
byte[] imageData, String portSettings)
throws StarIOPortException

This method generates the print command from image data.


Parameters:
width

Width of image data (pixel)

height

Height of image data (pixel)

imageData

Byte array of image data to convert

portSettings

Port settings
mini is specified for a portable printer

Returns:
Success: Print command
Failure: null

Throws:
StarIOPortException

32

- When failed to generate the print command

StarIO Software Development Kit for Android


Status List of the class structure StarPrinterStatus
Member name

Contents

Type

Detail

blackMarkError

Black Mark Error

boolean

Portable printers are not supported.

compulsionSwitch

Compulsion SW

boolean

Portable printers are not supported.

coverOpen

Cover Status

boolean

You can check status of Cover


" true " : Cover is opened.
" false " : Cover is closed.

cutterError

Auto-cutter Error

boolean

Portable printers are not supported.

etbAvailable

ETB available or not

boolean

" true " : available to use


" false " : not available to use

etbCounter

ETB Counter

int

Portable printers are not supported.

headThermistorError

Head Thermistor Error

boolean

Portable printers are not supported.

offline

ONLINE/OFFLINE
Status

boolean

You can check status of Online or offline.


" true " : Printer is Offline.
" false " : Printer is Online

overTemp

Stopped by high head


temperature

boolean

Portable printers are not supported.

presenterPaperJamError

Presenter Paper Jam


Error

boolean

Portable printers are not supported.

presenterState

Presenter Paper
Position

int

Portable printers are not supported.

raw

Byte column of status

byte[63]

Byte column of status


(example : HEX 23 86 00 00 00 00 00 00 00)

rawLength

raw length

int

raw length

receiptPaperEmpty

Paper end

boolean

" true " : Paper end.


" false " : Paper does not end.

receiptPaperNearEmptyInner

Paper Near-end (Inner


Side)

boolean

Portable printers are not supported.

receiveBufferOverflow

Receive Buffer
Overflow

boolean

Portable printers are not supported.

unrecoverableError

Non-recoverable Error

boolean

Portable printers are not supported.

voltageError

Electric Voltage Error

boolean

Portable printers are not supported.

33

StarIO Software Development Kit for Android


Class structure StarPrinterStatus Supported by Portable Printers
SMT300

SMS200

SMS300

SMS400

SM-S210i
(Jp model only)

SM-S220i
( Excluding
Jp model )

SMT300i

SMT400i

raw

rawLength

receiptPaperEmpty

Member name
blackMarkError
compulsionSwitch
coverOpen
cutterError
etbAvailable
etbCounter
headThermistorError
offline
overTemp
presenterPaperJamError
presenterState

receiptPaperNearEmptyInner
receiveBufferOverflow
unrecoverableError
voltageError

34

StarIO Software Development Kit for Android

StarIO Android SDK Functionality


Overview of this SDK functionality and StarIO Printer Commands
All of these commands can be found in the Star Mobile Printer Command Manual.
This SDK also has page and section references to the Mobile Command Manual for more
information so please download and study it if you need more detail on a specific command.
Upon running the SDK, the above buttons are displayed to demonstrate different functionality.
This section describes what each does and how the command can be tailored to fit your needs.
Choosing Portable Printer Commands

1. Tap Star Portable Printers.

35

StarIO Software Development Kit for Android


Supported Samples
Port Discovery
Get Status
Sample Receipt
JP Sample Receipt
Begin/End Checked Block
1D Barcodes
2D Barcodes
Text Formatting
JP Kanji Text Formatting
Raster Graphics Text Printing
Image File Printing
Magnetic Stripe Reading

36

StarIO Software Development Kit for Android


Port Discovery

Automatically detects which Star Micronics Bluetooth Printers are paired. Tap the printer to
connect to it. This feature is documented in greater detail here. Wireless portable printers
currently do not support this feature.

Help

Displays rules for manually entering the printers port data into the PortName field.
Manually entering port data is unnecessary if Port Discovery is used.

37

StarIO Software Development Kit for Android


Get Status

StarPrinterStatus
public boolean retreiveStatus()

See status return values here

offline

false = printer online; true = printer offline

other

See status return values here

Sample Receipts

Prints a premade sample receipt in the chosen command type. Sample Receipt outputs a
receipt in English, while JP Sample Receipt outputs one in Japanese.
Select the samples width and tap OK to print it. This part of the source code is heavily
commented to demonstrate how receipts can be fully customized.

38

StarIO Software Development Kit for Android


Begin / End Checked Block

This sample program checks the completion of printing using


beginCheckedBlock and endCheckedBlock.

See details of success and error of printing here.

39

StarIO Software Development Kit for Android


1D Barcodes

Set Barcode Height


GS h n

0 n 255

Set Barcode Width


GS w n

1n8

Print Barcode
GS k m n d1...dn NUL m = Barcode Type
n = Number of data
d1dn = Barcode Data

40

StarIO Software Development Kit for Android


2D Barcodes
QR Code

Select QR Code
GS Z n

n = 2 (QR Code)

Print QR Code
ESC Z m a k nL nH d1dn
m = Version of the symbol

m = 1~40, 0 = Auto size

a = Correction Level

L = 7%, M = 15%, Q = 25%, H = 30%

k = Model Size

k = 1~8

nL = Lower Byte Value; nH = Higher Byte Value


d1...dn = QR Code Data

41

StarIO Software Development Kit for Android


PDF417

Select PDF417
GS Z n

n = 0 (PDF417)

Set PDF417 Size


GS w n

1n8

Print PDF417
ESC Z m a k nL nH d1dn
m = Column Number

1 m 30

a = Correction Level

0n8

k = Horizontal/Vertical Ratios

2k5

nL = Lower Byte Value; nH = Higher Byte Value


d1dn = Barcode Data

42

StarIO Software Development Kit for Android


Text Formatting

43

StarIO Software Development Kit for Android


Text Formatting (continued from above)

Underline
ESC n

1 = Underline On, 1 dot thick


2 = Underline On, 2 dots thick
0 = Underline Off [Default]

Emphasized
ESC E n

1 = On

0 = Off [Default]

1 = On

0 = Off [Default]

1 = On

0 = Off [Default]

Upside Down Text


ESC { n
Invert Color
GS B n
Character Expansion
GS ! n

0n8

Left Margin
GS L nL nH

0 nL 255

0 nH 255

0 = Left [Default]

1 = Center

Alignment
ESC a n

44

2 = Right

StarIO Software Development Kit for Android


Japanese Kanji Text Formatting

This functionality is the same as that of Text Formatting, except Japanese Kanji is supported.

45

StarIO Software Development Kit for Android


Japanese Kanji Text Formatting (continued from above)

Enable Shift JIS Mode


FS C 1
Cancel Shift JIS Mode
FS C 0
Underline
ESC n

1 = Underline On, 1 dot thick


2 = Underline On, 2 dots thick
0 = Underline Off [Default]

Emphasized
ESC E n

1 = On

0 = Off [Default]

1 = On

0 = Off [Default]

1 = On

0 = Off [Default]

Upside Down Text


ESC { n
Invert Color
GS B n
Character Expansion
GS ! n

0n8

Left Margin
GS L nL nH

0 nL 255

0 nH 255

0 = Left [Default]

1 = Center

Alignment
ESC a n

46

2 = Right

StarIO Software Development Kit for Android


Raster Graphical Text Printing

Raster Mode converts all print data into image data and then outputs it to the printer. This
enables Star Printers to print at high speeds, regardless of outputting receipts with only text or
text and logos/coupons. As there are many options on how to customize output in Raster Mode,
refer to the programming manual for a listing of all Raster commands. These commands are also
conveniently listed right on the Android device by tapping the Help button on the screen.
Note: If send large amounts of raster data command, refer to the following in order to prevent "data
defective". Detail refer to the "printBitmap" method in the "MiniPrinterFunctions.java".
[Printer Device Firmware version 2.4 later]
Use beginCheckedBlock / endCheckBlock method before / after sending data by writePort method.
[Printer Device Firmware version 2.3 earlier]
For confirming the end of printing, send query commands after writePort data.

Store Print Job as Raster Graphic


ESC X 4
Print Stored Raster Graphic Data
ESC X 2

47

StarIO Software Development Kit for Android


Image File Printing

Use the dropdown box to select one of four different sample images to print via Raster Graphics
and choose the desired paper width.
Raster Mode converts all print data into image data and then outputs it to the printer. This
enables Star Printers to print at high speeds, regardless of outputting receipts with only text or
text and logos/coupons. As there are many options on how to customize output in Raster Mode,
refer to the programming manual for a listing of all Raster commands. These commands are also
conveniently listed right on the Android device by tapping the Help button on the screen.

Note: If send large amounts of raster data command, refer to the following in order to prevent "data
defective". Detail refer to the "printBitmapImage" method in the "MiniPrinterFunctions.java".

48

StarIO Software Development Kit for Android


MSR (Magnetic Stripe Reading)

Read One Track


ESC M C

Read Track 1 or Read Track 2

Read One Track


ESC M D

Read Track 2 or Read Track 3

Read Two Tracks


ESC M E

Read Track 1&2 or Read Tracks 2&3

Set JIS-II Mode


ESC M J

Read Japanese Characters

Cancel MSR Mode


EOT

49

Return to standard print mode

StarIO Software Development Kit for Android

Tips for App Development when using StarIO


Star Micronics prides itself as the industry leader in great POS products and with great power
comes great responsibility. Below is a tips section just to help you get on the fast track to
software development with StarIO.
TIP #1: If you are going to be coding a large project, create a class to abstract all the printing
methods into class(s) instead of having the code reside in the main code block. This will help
with code reusability and will also save you time in the long run from having to find one line
of code in the main code. By having StarIO only reside in the class(s), you will be fully taking
advantage of object oriented programming.
TIP #2: Know what the differences and definitions of (ASCII & Unicode), (Hex & Decimal), and
(Byte & Char) are. A byte is normally 8-bits long which would be 8 digits of binary (1s and 0s).
These bytes are just 8 bits of binary data but bytes can also be int or char. The three
different variable types basically hold the data in the same way but there are slight
differences. Try to code with Bytes instead of Chars, ints, or strings when choosing a variable
to contain your print job data. ASCII to Unicode and vice versa conversions are sometimes
unsecure so make sure you know what and how the encoding class works with these. Big
mistakes made in Unicode are culture-sensitive search and casing, surrogate pairs, combining
characters, and normalization which are answered here.
TIP #3: Do not waste time trying to reverse engineer StarIO command codes. All the available
StarIO commands are available in the Thermal Line Mode Spec Manual and that is the best
resource to use when researching a specific StarIO command. This SDK & Manual was built to
help you (The Developer) have a very easy job ahead of you to program for Star Printers.
TIP #4: If there is a command that is not covered in this SDK but you wish to see a code
snippet of that command in use then visit our Developers section for a possible code block
that matches your needs.
TIP #5: Looking for an iOS printing SDK? Visit our Developers section to get access to Star
developer tools for these environments.

50

StarIO Software Development Kit for Android

Additional Resources

Please get the programmers manual for Star Portable Printers from the link below.
Star Micronics Developers Network
Browse Star Micronics FAQs, ask a question, look up information, etc.
The Developers Network gets you access to:

Updated Versions of this Manual and Source Code


Star Micronics Printer Drivers
Technical Questions/Support

Android Developers Resource


The official Android development resource.
System Requirements for Android Development
See requirements for Windows, Linux, and Mac.
Unicode.org
The Unicode Consortium Good place to learn more about Unicode.
1D Barcodes
Barcode Island is a great resource for specs on 1D barcodes.
2D Barcodes
Great place for information on 2D Barcodes, QR Codes, and PDF417
Code Pages
Learn about Code Pages here.

51

StarIO Software Development Kit for Android

ASCII Table Resource


ASCII Hex Symbol
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F

NUL
SOH
STX
ETX
EOT
ENQ
ACK
BEL
BS
TAB
LF
VT
FF
CR
SO
SI

ASCII Hex Symbol


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

40
41
42
43
44
45
46
47
48
49
4A
4B
4C
4D
4E
4F

@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O

ASCII Hex Symbol


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F

DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
RS
US

ASCII Hex Symbol


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

50
51
52
53
54
55
56
57
58
59
5A
5B
5C
5D
5E
5F

P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_

ASCII Hex Symbol


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

ASCII Hex Symbol


96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

Use this to compare hex values to symbol (ASCII) values.


52

20 (space)
21
!
22
"
23
#
24
$
25
%
26
&
27
'
28
(
29
)
2A
*
2B
+
2C
,
2D
2E
.
2F
/

60
61
62
63
64
65
66
67
68
69
6A
6B
6C
6D
6E
6F

`
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o

ASCII Hex Symbol


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

30
31
32
33
34
35
36
37
38
39
3A
3B
3C
3D
3E
3F

0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?

ASCII Hex Symbol


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

70
71
72
73
74
75
76
77
78
79
7A
7B
7C
7D
7E
7F

p
q
r
s
t
u
v
w
x
y
z
{
|
}
~


StarIO Software Development Kit for Android

SDK Package Version History


Release Date

SDK Package
Version

Jul. 3 2013

3.7.0

- Added Star Printer Status List

Feb. 25 2013

3.4.0

- Added generateBitmapCommand support


- Added SM-T300i, SM-T400i

Jan. 18 2013

3.3.0

- Added SM-S210i
- Updated Raster Graphical Text Printing,
- Updated Begin / End Checked Block method

Nov. 30 2012

3.2.0

- Added Bluetooth support


- Added Begin/End Checked Block support

Jul. 27 2012

3.1.0

- Changed SDK UI to tree structure


- Added Port Discovery support
- Added Apple AirPort Express support (POS Printers Only)
- Added Sample Receipt Printing support

May. 31 2012

2.4.0

- Updated default StarIO Port Class name


- Revised default order of StarIOPort JAR to support
Android SDK r17 and higher

Mar. 15 2012

2.3.0 Beta

- Added USB Printing Support (POS Printers Only)

Jan. 18 2012

2.2.0 Beta

- Added Raster Image Printing Sample

Jan. 12 2012

2.1.0

- Added Japanese Text Formatting Sample


- Added Japanese Manuals

Oct. 14 2011

2.0.0

- Updated Sample Printing

Jun. 03 2011

1.0.0

- Initial Release

53

Update

Star Micronics Worldwide


Star Micronics Co., Ltd.
536 Nanatsushinya
Shimizu-ku, Shizuoka 424-0066
Japan
+81-54-347-2163
http://www.star-m.jp/eng/index.htm

Star Micronics is a global leader in the manufacturing of small


printers. We apply over 50 years of knowhow and innovation
to provide elite printing solutions that are rich in stellar
reliability and industry-respected features. Offering a diverse
line of Thermal, Hybrid, Mobile, Kiosk and Impact Dot Matrix
printers, we are obsessed with exceeding the demands of our
valued customers every day.
We have a long history of implementations into Retail, Point
of Sale, Hospitality, Restaurants and Kitchens, Kiosks and
Digital Signage, Gaming and Lottery, ATMs, Ticketing,
Labeling, Salons and Spas, Banking and Credit Unions,
Medical, Law Enforcement, Payment Processing, and more!
High Quality POS Receipts, Interactive Coupons with Triggers,
Logo Printing for Branding, Advanced Drivers for Windows,
Mac and Linux, Complete SDK Packages, Android, iOS,
Blackberry Printing Support, OPOS, JavaPOS, POS for .NET,
Eco-Friendly Paper and Power Savings with Reporting Utility,
ENERGY STAR, MSR Reading, futurePRNT, StarPRNT How
can Star help you fulfill the needs of your application?
Dont just settle on hardware that wont work as hard as you
do. Demand everything from your printer. Demand a Star!

Star Micronics America, Inc.


1150 King Georges Post Road
Edison, NJ 08837
USA
1-800-782-7636
+1-732-623-5500
http://www.starmicronics.com

Star Micronics EMEA


Star House
Peregrine Business Park, Gomm Road
High Wycombe, Buckinghamshire HP13 7DL
UK
+44-(0)-1494-471111
http://www.star-emea.com

Star Micronics Southeast Asia Co., Ltd.


Room 2902C. 29th Fl. United Center Bldg.
323 Silom Road, Silom Bangrak, Bangkok 10500
Thailand
+66-2-631-1161 x 2
http://www.starmicronics.co.th/

You might also like