Subversion Repositories Programming Utils

Compare Revisions

Ignore whitespace Rev 60 → Rev 61

/trunk/JavaSerial/NativeCode/SerialPortImpl.c
1447,7 → 1447,6
(JNIEnv * env, jobject obj, jbyteArray arr){
jbyte* data;
jint len;
int my_errnum;
struct port_descriptor* desc;
#ifdef _WIN32
DWORD bytes_written;
1454,7 → 1453,7
OVERLAPPED overlap;
#else
int bytes_written;
#endif
#endif /* _WIN32 */
 
desc = get_port_descriptor( env, obj );
if( desc == NULL ){
1465,7 → 1464,6
data = (*env)->GetByteArrayElements(env, arr, 0);
 
#ifdef _WIN32
 
memset( &overlap, 0, sizeof( overlap ) );
overlap.hEvent = CreateEvent( 0, TRUE, 0, 0 );
if( !WriteFile( desc->port, data, len, &bytes_written, &overlap ) ){
1477,7 → 1475,6
}
}else{
throw_io_exception( env, GetLastError() );
return;
}
}
1484,10 → 1481,37
#else
bytes_written = write( desc->port, data, len );
if( bytes_written < 0 ){
my_errnum = errno;
throw_io_exception( env, errno );
}
#endif
#endif /* _WIN32 */
 
(*env)->ReleaseByteArrayElements(env, arr, data, 0);
}
 
 
//
// ------------------------------------------------------------------------
// ---------------------Static methods below here--------------------------
// ------------------------------------------------------------------------
//
 
/*
* Class: com_rm5248_serial_SerialPort
* Method: getMajorNativeVersion
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_com_rm5248_serial_SerialPort_getMajorNativeVersion
(JNIEnv * env, jclass cls){
return 0;
}
 
/*
* Class: com_rm5248_serial_SerialPort
* Method: getMinorNativeVersion
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_com_rm5248_serial_SerialPort_getMinorNativeVersion
(JNIEnv * env, jclass cls){
return 2;
}
 
/trunk/JavaSerial/NativeCode/com_rm5248_serial_SerialPort.h
127,6 → 127,22
JNIEXPORT jint JNICALL Java_com_rm5248_serial_SerialPort_setSerialLineStateInternal
(JNIEnv *, jobject, jobject);
 
/*
* Class: com_rm5248_serial_SerialPort
* Method: getMajorNativeVersion
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_com_rm5248_serial_SerialPort_getMajorNativeVersion
(JNIEnv *, jclass);
 
/*
* Class: com_rm5248_serial_SerialPort
* Method: getMinorNativeVersion
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_com_rm5248_serial_SerialPort_getMinorNativeVersion
(JNIEnv *, jclass);
 
#ifdef __cplusplus
}
#endif
/trunk/JavaSerial/src/com/rm5248/serial/SerialPort.java
119,13 → 119,11
* system, then we might have problems putting it in 32-bits. Better safe than sorry.
*/
private int handle;
/* The input stream that user code uses to read from the serial port.
*/
/* The input stream that user code uses to read from the serial port. */
private SerialInputStream inputStream;
/* The buffered serial input stream which filters out events for us. */
private BufferedSerialInputStream bis;
/* The output stream that user code uses to write to the serial port.
*/
/* The output stream that user code uses to write to the serial port. */
private SerialOutputStream outputStream;
/* Make sure we don't close ourselves twice */
private boolean closed;
197,7 → 195,7
* Open the specified port, no flow control
*
* @param portName The name of the port to open
* @param rate The Buad Rate to open this port at
* @param rate The Baud Rate to open this port at
* @throws NoSuchPortException If this port does not exist
* @throws NotASerialPortException If the specified port is not a serial port
*/
209,7 → 207,7
* Open the specified port, no flow control
*
* @param portName The name of the port to open
* @param rate The Buad Rate to open this port at
* @param rate The Baud Rate to open this port at
* @param data The number of data bits
* @throws NoSuchPortException If this port does not exist
* @throws NotASerialPortException If the specified port is not a serial port
222,7 → 220,7
* Open the specified port, no parity or flow control
*
* @param portName The name of the port to open
* @param rate The Buad Rate to open this port at
* @param rate The Baud Rate to open this port at
* @param data The number of data bits
* @param stop The number of stop bits
* @throws NoSuchPortException If this port does not exist
236,7 → 234,7
* Open the specified port, no flow control
*
* @param portName The name of the port to open
* @param rate The Buad Rate to open this port at
* @param rate The Baud Rate to open this port at
* @param data The number of data bits
* @param stop The number of stop bits
* @param parity The parity of the line
772,5 → 770,39
* @return
*/
private native int setSerialLineStateInternal( SerialLineState s );
//
// Static Methods
//
/**
* Get the major version of this library. For example, if this is version
* 0.2, this returns 0
*/
public static int getMajorVersion(){
return 0;
}
/**
* Get the minor version of this library. For example, if this is version
* 0.2, this returns 2.
*/
public static int getMinorVersion(){
return 2;
}
/**
* Get the major version of the native code. This should match up with
* {@link getMajorVersion() getMajorVersion()}, although this is not
* guaranteed. For example, if this is version 0.2, this returns 0
*/
public static native int getMajorNativeVersion();
/**
* Get the minor version of the native code. This should match up with
* {@link getMinorVersion() getMinorVersion()}, although this is not
* guaranteed. For example, if this is version 0.2, this returns 2.
*/
public static native int getMinorNativeVersion();
 
}
/trunk/JavaSerial/src/com/rm5248/serial/BufferedSerialInputStream.java
11,7 → 11,7
* returns actual data. SerialInputStream gives us back data on the status of the serial line,
* as well as if the byte it gave us is real or not.
*
* @author Rob
* @author rm5248
*
*/
class BufferedSerialInputStream extends InputStream implements Runnable {
134,6 → 134,10
public int read( byte[] b, int off, int len ) throws IOException{
int readSoFar = 0;
if( len == 0 ){
return 0;
}
for( int x = off; x < len; x++ ){
b[x] = (byte)read();
readSoFar++;