SerialPortpublic class SerialPort extends Object
Fields Summary |
---|
private static final String | TAG | private int | mNativeContext | private final String | mName | private android.os.ParcelFileDescriptor | mFileDescriptor |
Constructors Summary |
---|
public SerialPort(String name)SerialPort should only be instantiated by SerialManager
mName = name;
|
Methods Summary |
---|
public void | close()Closes the serial port
if (mFileDescriptor != null) {
mFileDescriptor.close();
mFileDescriptor = null;
}
native_close();
| public java.lang.String | getName()Returns the name of the serial port
return mName;
| private native void | native_close()
| private native void | native_open(java.io.FileDescriptor pfd, int speed)
| private native int | native_read_array(byte[] buffer, int length)
| private native int | native_read_direct(java.nio.ByteBuffer buffer, int length)
| private native void | native_send_break()
| private native void | native_write_array(byte[] buffer, int length)
| private native void | native_write_direct(java.nio.ByteBuffer buffer, int length)
| public void | open(android.os.ParcelFileDescriptor pfd, int speed)SerialPort should only be instantiated by SerialManager
Speed must be one of 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600,
19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000, 921600, 1000000, 1152000,
1500000, 2000000, 2500000, 3000000, 3500000, 4000000
native_open(pfd.getFileDescriptor(), speed);
mFileDescriptor = pfd;
| public int | read(java.nio.ByteBuffer buffer)Reads data into the provided buffer.
Note that the value returned by {@link java.nio.Buffer#position()} on this buffer is
unchanged after a call to this method.
if (buffer.isDirect()) {
return native_read_direct(buffer, buffer.remaining());
} else if (buffer.hasArray()) {
return native_read_array(buffer.array(), buffer.remaining());
} else {
throw new IllegalArgumentException("buffer is not direct and has no array");
}
| public void | sendBreak()Sends a stream of zero valued bits for 0.25 to 0.5 seconds
native_send_break();
| public void | write(java.nio.ByteBuffer buffer, int length)Writes data from provided buffer.
Note that the value returned by {@link java.nio.Buffer#position()} on this buffer is
unchanged after a call to this method.
if (buffer.isDirect()) {
native_write_direct(buffer, length);
} else if (buffer.hasArray()) {
native_write_array(buffer.array(), length);
} else {
throw new IllegalArgumentException("buffer is not direct and has no array");
}
|
|