summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/hardware/SerialPort.java8
-rw-r--r--core/jni/android_hardware_SerialPort.cpp8
2 files changed, 16 insertions, 0 deletions
diff --git a/core/java/android/hardware/SerialPort.java b/core/java/android/hardware/SerialPort.java
index 0889790..5ef122b 100644
--- a/core/java/android/hardware/SerialPort.java
+++ b/core/java/android/hardware/SerialPort.java
@@ -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();
}
diff --git a/core/jni/android_hardware_SerialPort.cpp b/core/jni/android_hardware_SerialPort.cpp
index 7922115..728bd7b 100644
--- a/core/jni/android_hardware_SerialPort.cpp
+++ b/core/jni/android_hardware_SerialPort.cpp
@@ -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)