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()
关闭连接
|
int |
connect()
打开连接
|
int |
connect(int pid,
int vid)
打开连接
|
void |
connect(Observer observer)
打开连接
|
boolean |
isConnected()
连接状态
|
int |
read(byte[] buffer,
int time)
读取数据
|
int |
read(byte[] buffer,
int offset,
int len,
int time)
读取数据
|
boolean |
write(byte[] bytes,
int timeout)
写数据
|
boolean |
write(byte[] bytes,
int offset,
int len,
int timeout)
写数据
|
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 int connect(int pid, int vid) throws IOException
Connecter
connect
in interface Connecter
pid
- usb product idvid
- usb vendor idIOException
- 连接异常public int close()
Connecter
public int read(byte[] buffer, int time) throws IOException
Connecter
read
in interface Connecter
buffer
- 存放从打印机中读取数据的缓存区域time
- 等待时间,单位:毫秒(ms)IOException
- 读取数据异常public int read(byte[] buffer, int offset, int len, int time) throws IOException
Connecter
read
in interface Connecter
buffer
- 存放从打印机中读取数据的缓存区域offset
- 缓存数据偏移量(默认为0)time
- 等待时间,单位:毫秒(ms)IOException
- 读取数据异常public boolean write(byte[] bytes, int timeout) throws IOException
Connecter
write
in interface Connecter
bytes
- 发送到打印机的数据timeout
- 发送超时时间,单位:毫秒(ms)IOException
- 发送数据异常public boolean write(byte[] bytes, int offset, int len, int timeout) throws IOException
Connecter
write
in interface Connecter
bytes
- 发送到打印机的数据offset
- 偏移量len
- 发送的数据长度timeout
- 发送超时时间,单位:毫秒(ms)IOException
- 发送数据异常