public class SerialPort
extends java.lang.Object
| Constructor and Description |
|---|
SerialPort(java.io.File device,
int baudrate,
int flags)
Create a serial port object.
|
SerialPort(java.io.File device,
int baudrate,
int flags,
boolean hwflow)
Create a serial port object.
|
SerialPort(java.lang.String path,
int baudrate,
int flags)
Create a serial port object.
|
SerialPort(java.lang.String path,
int baudrate,
int flags,
boolean hwflow)
Create a serial port object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
closePort()
Close a serial port
|
java.io.FileDescriptor |
getFileDescriptor()
Deprecated.
Don't supported since Android 6.0.1.
|
int |
read(byte[] buffer)
Reads data from this serial port in the byte array
buffer. |
void |
sendBreak()
Sends a stream of zero valued bits for 0.25 to 0.5 seconds
|
void |
write(byte[] buffer)
Equivalent to
write(buffer, 0, buffer.length). |
void |
write(byte[] buffer,
int offset,
int length)
Writes
length bytes from the byte array buffer starting at
position offset to this serial port. |
public SerialPort(java.io.File device,
int baudrate,
int flags)
throws java.io.IOException
device - the file object of device.baudrate - the baudrate of serial port.flags - the flags of serial port.java.io.IOExceptionpublic SerialPort(java.lang.String path,
int baudrate,
int flags)
throws java.io.IOException
path - the absolute path of device.baudrate - the baudrate of serial port.flags - the flags of serial port.java.io.IOExceptionpublic SerialPort(java.io.File device,
int baudrate,
int flags,
boolean hwflow)
throws java.io.IOException
device - the file object of device.baudrate - the baudrate of serial port.flags - the flags of serial port.hwflow - the hardware flow of serial port.java.io.IOExceptionpublic SerialPort(java.lang.String path,
int baudrate,
int flags,
boolean hwflow)
throws java.io.IOException
path - the absolute path of device.baudrate - the baudrate of serial port.flags - the flags of serial port.hwflow - the hardware flow of serial port.java.io.IOExceptionpublic void closePort()
public java.io.FileDescriptor getFileDescriptor()
public int read(byte[] buffer)
throws java.io.IOException
buffer.buffer - to read intojava.io.IOExceptionpublic void write(byte[] buffer)
throws java.io.IOException
write(buffer, 0, buffer.length).java.io.IOExceptionpublic void write(byte[] buffer,
int offset,
int length)
throws java.io.IOException
length bytes from the byte array buffer starting at
position offset to this serial port.buffer - the buffer to be written.offset - the start position in buffer from where to get bytes.length - the number of bytes from buffer to write to this serial port.java.io.IOExceptionpublic void sendBreak()