API description: Difference between revisions

From wizarPOS
Line 6: Line 6:
==== Functions ====
==== Functions ====
===== open =====
===== open =====
  int printer_open()
Open the printer device.This operation should be used before other operations.
'''Parameters'''
'''Returns'''
The result code, >= 0, success; <0 [[Error_code|error code]].
===== begin =====
  int printer_begin()
Prepare to print, the app should print data after this funciton.
'''Parameters'''
'''Returns'''
The result code, >= 0, success; <0 [[Error_code|error code]].
===== end =====
  int printer_end()
End to print,the begin and end apis are pair operations.
'''Parameters'''
'''Returns'''
The result code, >= 0, success; <0 [[Error_code|error code]].
===== close =====
  int printer_close()
Close the device.The open and close apis are pair operations. If you don’t want to use the device, you should call close to release the device.
'''Parameters'''
'''Returns'''
The result code, >= 0, success; <0 [[Error_code|error code]].
===== query_status =====
  int printer_query_status()
Query the status of the printer.This api should be used inner open and close, but not inner begin and end.
'''Parameters'''
'''Returns'''
The result code, == 1, has paper; == 0, success; <0 [[Error_code|error code]].
===== write =====
  int printer_write(unsigned char* pData, int nDataLength)
Write data to the device. The data can be String, Bitmap data or [[ESC command]].
'''Parameters'''
{|
|-
| ''pData'' || data or ESC command
|-
| ''nDataLength''|| Length of data
|}
'''Returns'''
The result code, >= 0, success; <0 [[Error_code|error code]].
===== read =====
===== query_voltage =====


=== JNI interface ===
=== JNI interface ===

Revision as of 06:18, 3 April 2018

Printer API

 There are three layers of printer API, the lower layer is C, the device provid C interface, and the third app to write their own JNI source by calling the C interface.
 The middle layer is JNI interface, wizarPOS write JNI source and generate the device so files, so the third app just use the JNIInterface to finish the calling.
 The upper layer is Java interface, wizarPOS provide Java interface for the third app, the third app only need to import the .aar pakcage to their libs.

C interface

Functions

open
 int printer_open()

Open the printer device.This operation should be used before other operations.

Parameters

Returns

The result code, >= 0, success; <0 error code.

begin
 int printer_begin()

Prepare to print, the app should print data after this funciton.

Parameters

Returns

The result code, >= 0, success; <0 error code.

end
 int printer_end()

End to print,the begin and end apis are pair operations.

Parameters

Returns

The result code, >= 0, success; <0 error code.

close
 int printer_close()

Close the device.The open and close apis are pair operations. If you don’t want to use the device, you should call close to release the device.

Parameters

Returns

The result code, >= 0, success; <0 error code.

query_status
 int printer_query_status()

Query the status of the printer.This api should be used inner open and close, but not inner begin and end.


Parameters

Returns

The result code, == 1, has paper; == 0, success; <0 error code.

write
 int printer_write(unsigned char* pData, int nDataLength)

Write data to the device. The data can be String, Bitmap data or ESC command.


Parameters

pData data or ESC command
nDataLength Length of data

Returns

The result code, >= 0, success; <0 error code.

read
query_voltage

JNI interface

Functions

open

Sample

Java interface

Functions

open

Sample