API: Difference between revisions
No edit summary |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
* 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 === | === <big>open</big> === | ||
<syntaxhighlight lang="c">int printer_open()</syntaxhighlight > | <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" | {|class="wizarpostable" | ||
|- | |- | ||
Line 16: | Line 15: | ||
|} | |} | ||
===begin === | |||
===<big>begin</big> === | |||
<syntaxhighlight lang="c">int printer_begin()</syntaxhighlight > | <syntaxhighlight lang="c">int printer_begin()</syntaxhighlight > | ||
Prepare to print, the app should print data after this | Prepare to print, the app should print data after this function. | ||
{|class="wizarpostable" | {|class="wizarpostable" | ||
|- | |- | ||
Line 27: | Line 26: | ||
|} | |} | ||
===end === | |||
===<big>end</big> === | |||
<syntaxhighlight lang="c">int printer_end()</syntaxhighlight > | <syntaxhighlight lang="c">int printer_end()</syntaxhighlight > | ||
End to print,the begin and end | End to print,the begin and end API are pair operations. | ||
{|class="wizarpostable" | {|class="wizarpostable" | ||
|- | |- | ||
Line 38: | Line 37: | ||
|} | |} | ||
=== close === | |||
=== <big>close</big> === | |||
<syntaxhighlight lang="c">int printer_close()</syntaxhighlight > | <syntaxhighlight lang="c">int printer_close()</syntaxhighlight > | ||
Close the device.The open and close | Close the device.The open and close API are pair operations. If you don’t want to use the device, you should call close to release the device. | ||
{|class="wizarpostable" | {|class="wizarpostable" | ||
|- | |- | ||
Line 49: | Line 48: | ||
|} | |} | ||
=== query_status === | |||
=== <big>query_status</big> === | |||
<syntaxhighlight lang="c">int printer_query_status()</syntaxhighlight > | <syntaxhighlight lang="c">int printer_query_status()</syntaxhighlight > | ||
Query the status of the printer.This | Query the status of the printer.This API should be used inner open and close, but not inner begin and end. | ||
{|class="wizarpostable" | {|class="wizarpostable" | ||
|- | |- | ||
! scope="row" colspan="2"| Returns | ! scope="row" colspan="2"| Returns | ||
|- | |- | ||
| int || The result code, == 1 | | int || The result code, '''== 1: has paper'''; '''== 0: success'''; <0 [[Error_code|error code]]. | ||
|} | |} | ||
===write === | ===<big>write</big> === | ||
<syntaxhighlight lang="c">int printer_write(unsigned char* pData, int nDataLength)</syntaxhighlight > | <syntaxhighlight lang="c">int printer_write(unsigned char* pData, int nDataLength)</syntaxhighlight > | ||
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" | ||
|- | |- | ||
Line 71: | Line 69: | ||
|- | |- | ||
| nDataLength|| '''int:'''Length of data | | nDataLength|| '''int:'''Length of data | ||
|} | |||
{| | |||
|- | |||
| | |||
|} | |} | ||
Line 77: | Line 79: | ||
! scope="row" colspan="2"| Returns | ! scope="row" colspan="2"| Returns | ||
|- | |- | ||
| int || The result code, >= 0, success; <0 [[Error_code|error code]]. | | int || The result code, >= 0, write success, the data length of wrote; <0 [[Error_code|error code]]. | ||
|} | |} | ||
=== read === | === read === | ||
=== query_voltage === | === query_voltage === |
Latest revision as of 09:03, 11 July 2019
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 function.
Returns | |
---|---|
int | The result code, >= 0, success; <0 error code. |
end
int printer_end()
End to print,the begin and end API are pair operations.
Returns | |
---|---|
int | The result code, >= 0, success; <0 error code. |
close
int printer_close()
Close the device.The open and close API 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, write success, the data length of wrote; <0 error code. |