Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7dbc4b45 authored by Mike Lockwood's avatar Mike Lockwood Committed by Mike Lockwood
Browse files

Add SerialPort.sendBreak()

parent 21d524ea
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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();
}
+8 −0
Original line number Diff line number Diff line
@@ -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)