Added "bytes awaiting write" functionality

This commit is contained in:
hedgecrw85 2016-03-25 11:19:29 -05:00
parent 3957c116fb
commit b30504e5b2
4 changed files with 17 additions and 0 deletions

View File

@ -143,6 +143,14 @@ JNIEXPORT jint JNICALL Java_com_fazecast_jSerialComm_SerialPort_waitForEvent
JNIEXPORT jint JNICALL Java_com_fazecast_jSerialComm_SerialPort_bytesAvailable
(JNIEnv *, jobject, jlong);
/*
* Class: com_fazecast_jSerialComm_SerialPort
* Method: bytesAwaitingWrite
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_com_fazecast_jSerialComm_SerialPort_bytesAwaitingWrite
(JNIEnv *, jobject, jlong);
/*
* Class: com_fazecast_jSerialComm_SerialPort
* Method: readBytes

View File

@ -378,6 +378,15 @@ JNIEXPORT jint JNICALL Java_com_fazecast_jSerialComm_SerialPort_bytesAvailable(J
return numBytesAvailable;
}
JNIEXPORT jint JNICALL Java_com_fazecast_jSerialComm_SerialPort_bytesAwaitingWrite(JNIEnv *env, jobject obj, jlong serialPortFD)
{
int numBytesToWrite = -1;
if (serialPortFD > 0)
ioctl(serialPortFD, TIOCOUTQ, &numBytesToWrite);
return numBytesToWrite;
}
JNIEXPORT jint JNICALL Java_com_fazecast_jSerialComm_SerialPort_readBytes(JNIEnv *env, jobject obj, jlong serialPortFD, jbyteArray buffer, jlong bytesToRead)
{
// Get port handle and read timeout from Java class