Subversion Repositories Programming Utils

Compare Revisions

Ignore whitespace Rev 13 → Rev 14

/JavaSerial/NativeCode/SerialPortImpl.c
16,6 → 16,12
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
 
#ifdef CRTSCTS
#define HW_FLOW CRTSCTS
#elif CNEW_RTSCTS
#define HW_FLOW CNEW_RTSCTS
#endif
#define SPEED_SWITCH(SPD,io) case SPD: cfsetospeed( &io, B##SPD ); break;
114,6 → 120,25
return 1;
}
 
static int set_raw_input( struct port_descriptor* desc ){
GET_SERIAL_PORT_STRUCT( desc->port, newio );
 
#ifdef _WIN32
#else
newio.c_iflag |= IGNBRK;
newio.c_iflag &= ~BRKINT;
newio.c_iflag &= ~ICRNL;
newio.c_oflag = 0;
newio.c_lflag = 0;
newio.c_cc[VTIME] = 0;
newio.c_cc[VMIN] = 1;
#endif
SET_SERIAL_PORT_STRUCT( desc->port, newio );
 
return 1;
}
 
static int set_data_bits( struct port_descriptor* desc, int data_bits ){
GET_SERIAL_PORT_STRUCT( desc->port, newio );
 
120,7 → 145,16
#ifdef _WIN32
newio.ByteSize = data_bits;
#else
newio.
newio.c_cflag &= ~CSIZE;
if( data_bits == 8 ){
newio.c_cflag |= CS8;
}else if( data_bits == 7 ){
newio.c_cflag |= CS7;
}else if( data_bits == 6 ){
newio.c_cflag |= CS6;
}else if( data_bits == 5 ){
newio.c_cflag |= CS5;
}
#endif
SET_SERIAL_PORT_STRUCT( desc->port, newio );
138,7 → 172,11
newio.StopBits = TWOSTOPBITS;
}
#else
newio.
if( stop_bits == 1 ){
newio.c_cflag &= ~CSTOPB;
}else if( stop_bits == 2 ){
newio.c_cflag |= CSTOPB;
}
#endif
SET_SERIAL_PORT_STRUCT( desc->port, newio );
158,7 → 196,13
newio.Parity = EVENPARITY;
}
#else
newio.
if( parity == 0 ){
newio.c_cflag |= IGNPAR;
}else if( parity == 1 ){
newio.c_cflag |= PARODD;
}else if( parity == 2 ){
newio.c_cflag |= PARENB;
}
#endif
SET_SERIAL_PORT_STRUCT( desc->port, newio );
171,7 → 215,13
 
#ifdef _WIN32
#else
newio.
if( flow_control == 0 ){
newio.c_cflag &= ~( IXON | IXOFF | IXANY );
}else if( flow_control == 1 ){
newio.c_cflag |= HW_FLOW;
}else if( flow_control == 2 ){
newio.c_cflag |= ( IXON | IXOFF | IXANY );
}
#endif
SET_SERIAL_PORT_STRUCT( desc->port, newio );
305,6 → 355,7
free( new_port );
return -1;
}
set_raw_input( new_port );
//Set the data bits( character size )
set_data_bits( new_port, dataBits );
//Set the stop bits