40,20 → 40,6 |
|
#endif |
|
/** |
* TODO actually make this an inline function |
*/ |
#define GET_PORT_DESCRIPTOR( array_pos, desc, env, obj ) array_pos = get_handle( env, obj ); \ |
if( array_pos < 0 || array_pos > port_list_size ){ \ |
throw_io_exception_message( env, "Unable to get handle" );\ |
return 0; \ |
} \ |
desc = port_list[ array_pos ]; \ |
if( desc == NULL ){ \ |
throw_io_exception_message( env, "Unable to get descriptor" ); \ |
return 0; \ |
} |
|
#include <stdlib.h> |
#include <errno.h> |
#include <string.h> |
429,7 → 415,7 |
} |
} |
|
{ |
{ |
//Let's check to see if this is a serial port |
DCB io_name = {0}; |
io_name.DCBlength = sizeof( io_name ); |
705,8 → 691,32 |
jint array_pos; |
struct port_descriptor* desc; |
|
GET_PORT_DESCRIPTOR( array_pos, desc, env, obj ); |
array_pos = get_handle( env, obj ); |
|
if( array_pos < 0 ){ |
//throw new exception |
int errNum; |
#ifdef _WIN32 |
errNum = GetLastError(); |
#else |
errNum = errno; |
#endif /* _WIN32 */ |
throw_io_exception( env, errNum ); |
return 0; |
} |
|
desc = port_list[ array_pos ]; |
|
if( desc == NULL ){ |
//throw new exception |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, "Given bad positon in array. Internal SerialPort error." ); |
return 0; |
} |
|
return set_baud_rate( desc, baud_rate ); |
} |
|
720,8 → 730,30 |
jint array_pos; |
struct port_descriptor* desc; |
|
GET_PORT_DESCRIPTOR( array_pos, desc, env, obj ); |
array_pos = get_handle( env, obj ); |
|
if( array_pos < 0 ){ |
//throw new exception |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
desc = port_list[ array_pos ]; |
|
if( desc == NULL ){ |
//throw new exception |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
//Now, let's get the baud rate information |
{ |
GET_SERIAL_PORT_STRUCT( desc->port, newio ); |
770,17 → 802,9 |
struct port_descriptor* desc; |
|
array_pos = get_handle( env, obj ); |
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
return 0; |
} |
|
desc = port_list[ array_pos ]; |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
return 0; |
} |
|
798,9 → 822,14 |
struct port_descriptor* desc; |
|
array_pos = get_handle( env, obj ); |
|
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
808,7 → 837,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
842,17 → 875,9 |
struct port_descriptor* desc; |
|
array_pos = get_handle( env, obj ); |
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
return 0; |
} |
|
desc = port_list[ array_pos ]; |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
return 0; |
} |
|
870,9 → 895,14 |
struct port_descriptor* desc; |
|
array_pos = get_handle( env, obj ); |
|
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
880,7 → 910,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
917,10 → 951,15 |
jint array_pos; |
struct port_descriptor* desc; |
|
array_pos = get_handle( env, obj ); |
array_pos = get_handle( env, obj ); |
|
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
928,7 → 967,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
946,9 → 989,14 |
struct port_descriptor* desc; |
|
array_pos = get_handle( env, obj ); |
|
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
956,7 → 1004,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
1001,9 → 1053,14 |
struct port_descriptor* desc; |
|
array_pos = get_handle( env, obj ); |
|
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
1011,7 → 1068,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
1029,9 → 1090,14 |
struct port_descriptor* desc; |
|
array_pos = get_handle( env, obj ); |
|
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
1039,7 → 1105,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
1083,9 → 1153,14 |
jint ret_val; |
|
array_pos = get_handle( env, obj ); |
|
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
1093,7 → 1168,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
1175,9 → 1254,14 |
jint ret_val; |
|
array_pos = get_handle( env, obj ); |
|
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
1185,7 → 1269,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return 0; |
} |
|
1339,7 → 1427,11 |
array_pos = get_handle( env, obj ); |
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return -1; |
} |
|
1347,7 → 1439,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return -1; |
} |
|
1492,7 → 1588,11 |
array_pos = get_handle( env, obj ); |
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return -1; |
} |
|
1500,7 → 1600,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return -1; |
} |
|
1548,7 → 1652,11 |
array_pos = get_handle( env, obj ); |
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return; |
} |
|
1556,7 → 1664,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return; |
} |
|
1606,7 → 1718,11 |
array_pos = get_handle( env, obj ); |
if( array_pos < 0 ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get handle" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return; |
} |
|
1614,7 → 1730,11 |
|
if( desc == NULL ){ |
//throw new exception |
throw_io_exception_message( env, "Unable to get descriptor" ); |
jclass exception_class; |
(*env)->ExceptionDescribe( env ); |
(*env)->ExceptionClear( env ); |
exception_class = (*env)->FindClass(env, "java/io/IOException"); |
(*env)->ThrowNew(env, exception_class, strerror( errno ) ); |
return; |
} |
|
1647,3 → 1767,13 |
} |
} |
|
//BOOL EscapeCommFunction(HANDLE, DWORD). |
/* |
1. CLRDTR |
2. SETDTR |
3. SETRTS |
4. CLRRTS |
5. SETBREAK |
6. CLRBREAK |
*/ |
|