API: Difference between revisions
(→write) |
No edit summary |
||
Line 1: | Line 1: | ||
== | == API Overview == | ||
The calling sequence is open>query_status>begin>write>end>close. Please notice that: | The calling sequence is open>query_status>begin>write>end>close. Please notice that: | ||
* [[#write|write]] method is used for printing content. | * [[#write|write]] method is used for printing content. | ||
* print content should be between [[#begin|begin]] method and [[#end|end]] method. | * print content should be between [[#begin|begin]] method and [[#end|end]] method. | ||
* [[#query_status|query_status]] should be between [[#open|open]] method and [[#close|close]] method, but should not be between [[#begin|begin]] method and [[#end|end]] method | * [[#query_status|query_status]] should be between [[#open|open]] method and [[#close|close]] method, but should not be between [[#begin|begin]] method and [[#end|end]] method | ||
=== open === | |||
int printer_open() | <syntaxhighlight lang="c">int printer_open()</syntaxhighlight > | ||
Open the printer device.This operation should be used before other operations. | Open the printer device.This operation should be used before other operations. | ||
{|class="wizarpostable" | |||
|- | |||
! scope="row" colspan="2"| Returns | |||
|- | |||
The result code, >= 0, success; <0 [[Error_code|error code]]. | | int || The result code, >= 0, success; <0 [[Error_code|error code]]. | ||
|} | |||
===begin === | |||
int printer_begin() | <syntaxhighlight lang="c">int printer_begin()</syntaxhighlight > | ||
Prepare to print, the app should print data after this funciton. | Prepare to print, the app should print data after this funciton. | ||
{|class="wizarpostable" | |||
|- | |||
! scope="row" colspan="2"| Returns | |||
|- | |||
The result code, >= 0, success; <0 [[Error_code|error code]]. | | int || The result code, >= 0, success; <0 [[Error_code|error code]]. | ||
|} | |||
===end === | |||
int printer_end() | <syntaxhighlight lang="c">int printer_end()</syntaxhighlight > | ||
End to print,the begin and end apis are pair operations. | End to print,the begin and end apis are pair operations. | ||
{|class="wizarpostable" | |||
|- | |||
! scope="row" colspan="2"| Returns | |||
|- | |||
The result code, >= 0, success; <0 [[Error_code|error code]]. | | int || The result code, >= 0, success; <0 [[Error_code|error code]]. | ||
|} | |||
=== close === | |||
int printer_close() | <syntaxhighlight lang="c">int printer_close()</syntaxhighlight > | ||
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. | 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. | ||
{|class="wizarpostable" | |||
|- | |||
! scope="row" colspan="2"| Returns | |||
|- | |||
The result code, >= 0, success; <0 [[Error_code|error code]]. | | int || The result code, >= 0, success; <0 [[Error_code|error code]]. | ||
|} | |||
=== query_status === | |||
int printer_query_status() | <syntaxhighlight lang="c">int printer_query_status()</syntaxhighlight > | ||
Query the status of the printer.This api should be used inner open and close, but not inner begin and end. | Query the status of the printer.This api should be used inner open and close, but not inner begin and end. | ||
{|class="wizarpostable" | |||
|- | |||
! scope="row" colspan="2"| Returns | |||
|- | |||
| int || The result code, == 1, has paper; == 0, success; <0 [[Error_code|error code]]. | |||
|} | |||
===write === | |||
<syntaxhighlight lang="c">int printer_write(unsigned char* pData, int nDataLength)</syntaxhighlight > | |||
int printer_write(unsigned char* pData, int nDataLength) | |||
Write data to the device. The data can be String, Bitmap data or [[ESC Commands]]. | Write data to the device. The data can be String, Bitmap data or [[ESC Commands]]. | ||
{| class="wizarpostable" | {| class="wizarpostable" | ||
|- | |- | ||
| ' | ! scope="row" colspan="2"| Parameters | ||
|- | |||
| pData || '''unsigned char*:''' data or ESC command | |||
|- | |- | ||
| '' | | nDataLength|| '''int:'''Length of data | ||
|} | |} | ||
The result code, >= 0, success; <0 [[Error_code|error code]]. | {|class="wizarpostable" | ||
|- | |||
! scope="row" colspan="2"| Returns | |||
|- | |||
| int || The result code, >= 0, success; <0 [[Error_code|error code]]. | |||
|} | |||
=== read === | |||
=== query_voltage === |
Revision as of 01:54, 2 May 2018
API Overview
The calling sequence is open>query_status>begin>write>end>close. Please notice that:
- write method is used for printing content.
- print content should be between begin method and end method.
- query_status should be between open method and close method, but should not be between begin method and end method
open
int printer_open()
Open the printer device.This operation should be used before other operations.
Returns | |
---|---|
int | The result code, >= 0, success; <0 error code. |
begin
int printer_begin()
Prepare to print, the app should print data after this funciton.
Returns | |
---|---|
int | The result code, >= 0, success; <0 error code. |
end
int printer_end()
End to print,the begin and end apis are pair operations.
Returns | |
---|---|
int | 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.
Returns | |
---|---|
int | 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.
Returns | |
---|---|
int | 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 Commands.
Parameters | |
---|---|
pData | unsigned char*: data or ESC command |
nDataLength | int:Length of data |
Returns | |
---|---|
int | The result code, >= 0, success; <0 error code. |