Merge "Add SerialPort.sendBreak()" into ics-aah

This commit is contained in:
Mike Lockwood
2011-09-23 09:02:20 -07:00
committed by Android (Google) Code Review
3 changed files with 17 additions and 0 deletions

View File

@@ -9614,6 +9614,7 @@ package android.hardware {
method public void close() throws java.io.IOException;
method public java.lang.String getName();
method public int read(java.nio.ByteBuffer) throws java.io.IOException;
method public void sendBreak();
method public void write(java.nio.ByteBuffer, int) throws java.io.IOException;
}

View File

@@ -113,10 +113,18 @@ public class SerialPort {
}
}
/**
* Sends a stream of zero valued bits for 0.25 to 0.5 seconds
*/
public void sendBreak() {
native_send_break();
}
private native void native_open(FileDescriptor pfd, int speed) throws IOException;
private native void native_close();
private native int native_read_array(byte[] buffer, int length) throws IOException;
private native int native_read_direct(ByteBuffer buffer, int length) throws IOException;
private native void native_write_array(byte[] buffer, int length) throws IOException;
private native void native_write_direct(ByteBuffer buffer, int length) throws IOException;
private native void native_send_break();
}

View File

@@ -234,6 +234,13 @@ android_hardware_SerialPort_write_direct(JNIEnv *env, jobject thiz, jobject buff
jniThrowException(env, "java/io/IOException", NULL);
}
static void
android_hardware_SerialPort_send_break(JNIEnv *env, jobject thiz)
{
int fd = env->GetIntField(thiz, field_context);
tcsendbreak(fd, 0);
}
static JNINativeMethod method_table[] = {
{"native_open", "(Ljava/io/FileDescriptor;I)V",
(void *)android_hardware_SerialPort_open},
@@ -246,6 +253,7 @@ static JNINativeMethod method_table[] = {
(void *)android_hardware_SerialPort_write_array},
{"native_write_direct", "(Ljava/nio/ByteBuffer;I)V",
(void *)android_hardware_SerialPort_write_direct},
{"native_send_break", "()V", (void *)android_hardware_SerialPort_send_break},
};
int register_android_hardware_SerialPort(JNIEnv *env)