Cash box driver

About operating cash box with Sunmi device

Partial Sunmi devices, such as T1, can connect external cash box. The cash box can be opened by App via the following two methods.

One. Open the cash box via the method of encapsulation in AIDL file.

Two. Open the cash box via command.

One. Open the cash box via the method of encapsulation in AIDL file

1.     Download the relevant resource file, establish a new package in the following hierarchy in the project, place the AIDL file in the source file into the package.


2.     To operate the cash box, there are only two methods available, namely open the cash box and obtain the number of times of opening the cash box, as shown in the following figure. These two methods are available in IWoyouService.aidl file, and the developers can invoke them in their own codes.


Two. Via the method of ES/POS command

The developer can send ES/POS command to service via two methods

1.        Establish connection with service via Virtual Bluetooth, send ES/POS command. You can refer to the printer driver document and open the cash box via invoking send command with Bluetooth connection. The ES/POS command to open the cash box is as follows:

byte[] aa = new byte[5];
aa[0] = 0x10;
aa[1] = 0x14;
aa[2] = 0x00;
aa[3] = 0x00;
aa[4] = 0x00;

2.        Send command via sendRAWData(bytes [], callback) method encapsulated in AIDL method. It also requires to use the resource file in method one. You may refer to AIDL printing method in printer driver document:

byte[] aa = new byte[5];

aa[0] = 0x10;
aa[1] = 0x14;
aa[2] = 0x00;
aa[3] = 0x00;
aa[4] = 0x00;

 try {
  woyouService.sendRAWData(aa, callback);
  } catch (RemoteException e1) {

External USB Serial Devices

External USB Serial DeviceInstructions Document for USB、serial device 

1.       Brief introduction:
peripheral interfaces: general communication interfaces such as LAN port, cash drawer port, usb2.0 port, serial port, headphone jack, etc.
This text mainly introduces the usage mode of cash drawer port, usb port and serial port.

2.       Interface description

1)       Cash drawer port: the cash drawer port uses RJ12 port. The developers can control the

cash drawer by sending data to the cash drawer port.

Cash drawer developers document and resources file:Interface Documentation

2)      1)       Serial port: the serial port uses RJ11 port. The developers can control the peripherals

by sending data from the serial port. The RJ11 of sunmi equipment is four-wire and does not support hard-flow control (some peripherals turn on hardware-flow control by default, and these devices can not connect sunmi mainframe through RJ11).

For security reasons, serial port nodes traversal is not supported, but you can directly open the port to communicate (

T1,T1mini:the node path of the serial port at the device base /dev/ttyHSL1,
N1、D2、D1s Single screen:/dev/ttyS1,
N1、D2、D1s Double screen:/dev/ttyS3

T1: the node path of the serial port at the device base/dev/ttyHSL3, T2: ttyHSL1,T2lite:ttyHSL1,

N1、D2、D1s Single screen:/dev/ttyS1;N1、D2、D1s Double screen:/dev/ttyS3)

Serial port reference demoJNI reference

Communication document example:

communication document for electronic scale at Jaynes serial port

(different electronic scale communication agreements need to refer to the documents provided by every manufacturer)

3)          USB port: supports USB devices with USB2.0 agreement.

USB communication developers document :USB communication developer documentation

Sunmi support list of USB to Serial port

List of USB to Serial: CH341, FT series, PL2303, CP210X series

When used USB to Serial port, system will build the node: /dev/ttyUSERx   (like /dev/ttyUSER0,  /dev/ttyUSER1, etc.) 

Don’t use USB to debug system when you use USB to Serial port, it would make USB to Serial port not work

3.1 Obtain USB devices’ PID/VID:

Method 1: java code

try {

Process p=Runtime.getRuntime().exec("cat /proc/bus/input/devices");
BufferedReader in = new BufferedReader(new
String line = null;
while((line = in.readLine())!= null){
String deviceInfo = line.trim();

} catch (Exception e) {
// TODO: handle exception

Method 2: adb command

adb shell cat /proc/bus/input/devices
图片 1

3.2 HID device of universal USB peripherals supports by default the HID agreement devices (mouse, keyboard, code scanning gun, etc.), and you can plug and play.

HID code scanning gun

As for HID code scanning gun, you can plug and play: connect Sunmi device, open an editable box on the Sunmi device to obtain the focal point and scan the code. Then bar code or QR code content should be inputted into this box.

As for obtaining code scanning content from the code, please refer to: Communications Google Developer documentation

  • U diskThe supported U disk format: FAT32: readable & writable; NTFS: readable & non-writable; exFAT: not supportedCameraSunmi supports USB UVC camera (e.g. LogitechC170)


     Source code

  • Sunmi card reader can be connected at the sidebar of Sunmi reader (Slot reader interface)

Development package Demo source

Sunmi card reader includes two parts: one part is magnetic stripe card, which can be referenced to Sunmi card reader SDK and card reader demo. The other part is nfc, which is android native port and can be referenced to android nfc development document:

Sunmi card reader SDK

Sunmi card reader demo

Sunmi card reader demo source code

The third party universal reader & writer Sunmi has now already supported four types of third party usb universal reader & writer. The developers can refer to demo provided by Sunmi to carry out card reading & writing operation.

Shanghai Yixi Intelligent Technology Co., Ltd   UM002 card reader

Shenzhen Deka Technology Co., Ltd   T10 reader & writer (needs to support android version, power charging version)

Hong Kong Longjie Smart Card Co., Ltd    ACR1281U-C1 reader & writer

Hong Kong Longjie Smart Card Co., Ltd    ACR1281U-K1 reader & writer

Development document 2.0

Universal reader & writer demo

Universal reader & writer demo source code