FAIL, NOT_PERMISSION, NOT_SUPPORT, STATE_CONNECTED, STATE_CONNECTING, STATE_LISTEN, STATE_NONE, SUCCESS
Constructor and Description |
---|
UsbPort(android.content.Context context) |
Modifier and Type | Method and Description |
---|---|
int |
close()
Disconnect
|
int |
connect()
Open a connection
|
int |
connect(int pid,
int vid)
Open a connection
|
void |
connect(Observer observer)
Open a connection
|
boolean |
isConnected()
Connection state
|
int |
read(byte[] buffer,
int time)
Receive data
|
int |
read(byte[] buffer,
int offset,
int len,
int time)
Receive data
|
boolean |
write(byte[] bytes,
int timeout)
Writing data
|
boolean |
write(byte[] bytes,
int offset,
int len,
int timeout)
Writing data
|
public boolean isConnected()
Connecter
isConnected
in interface Connecter
public int connect()
Connecter
connect
in interface Connecter
Connecter.STATE_NONE
,
Connecter.STATE_LISTEN
,
Connecter.STATE_CONNECTING
,
Connecter.STATE_CONNECTED
,
Connecter.NOT_PERMISSION
,
Connecter.NOT_SUPPORT
public void connect(Observer observer)
Connecter
public int connect(int pid, int vid) throws IOException
Connecter
connect
in interface Connecter
pid
- Usb product id.vid
- Usb vendor id.IOException
- Connecting exception.Connecter.STATE_NONE
,
Connecter.STATE_CONNECTED
public int close()
Connecter
public int read(byte[] buffer, int time) throws IOException
Connecter
read
in interface Connecter
buffer
- Cache area for reading data from the printer.time
- Waiting time in milliseconds (MS).IOException
- Receive data exception.public int read(byte[] buffer, int offset, int len, int time) throws IOException
Connecter
read
in interface Connecter
buffer
- Cache area for reading data from the printer.offset
- Cache data offset.time
- Waiting time in milliseconds (MS).IOException
- Receive data exception.public boolean write(byte[] bytes, int timeout) throws IOException
Connecter
write
in interface Connecter
bytes
- Data sent to printer.timeout
- Send timeout in milliseconds (MS).IOException
- Sending data exception.public boolean write(byte[] bytes, int offset, int len, int timeout) throws IOException
Connecter
write
in interface Connecter
bytes
- Data sent to printer.offset
- The start offset in the data.len
- The number of bytes to write.timeout
- Send timeout in milliseconds (MS).IOException
- Sending data exception.