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()
ConnecterisConnected in interface Connecterpublic int connect()
Connecterconnect in interface ConnecterConnecter.STATE_NONE,
Connecter.STATE_LISTEN,
Connecter.STATE_CONNECTING,
Connecter.STATE_CONNECTED,
Connecter.NOT_PERMISSION,
Connecter.NOT_SUPPORTpublic int connect(int pid,
int vid)
throws IOException
Connecterconnect in interface Connecterpid - usb product idvid - usb vendor idIOException - 连接异常public int close()
Connecterpublic int read(byte[] buffer,
int time)
throws IOException
Connecterread in interface Connecterbuffer - 存放从打印机中读取数据的缓存区域time - 等待时间,单位:毫秒(ms)IOException - 读取数据异常public int read(byte[] buffer,
int offset,
int len,
int time)
throws IOException
Connecterread in interface Connecterbuffer - 存放从打印机中读取数据的缓存区域offset - 缓存数据偏移量(默认为0)time - 等待时间,单位:毫秒(ms)IOException - 读取数据异常public boolean write(byte[] bytes,
int timeout)
throws IOException
Connecterwrite in interface Connecterbytes - 发送到打印机的数据timeout - 发送超时时间,单位:毫秒(ms)IOException - 发送数据异常public boolean write(byte[] bytes,
int offset,
int len,
int timeout)
throws IOException
Connecterwrite in interface Connecterbytes - 发送到打印机的数据offset - 偏移量len - 发送的数据长度timeout - 发送超时时间,单位:毫秒(ms)IOException - 发送数据异常