diff --git a/src/RS232.h b/src/RS232.h --- a/src/RS232.h +++ b/src/RS232.h @@ -7,7 +7,7 @@ #define rs232noerr 0 typedef int rs232port_t; typedef int rs232speed_t; -typedef enum {rs232OneStop=1,rs232One5Stop=2,rs232TwoStop=2}rs232stop; +typedef enum {rs232OneStop,rs232One5Stop,rs232TwoStop}rs232stop; typedef enum {rs232parityNo,rs232parityOdd,rs232parityEven}rs232parity; diff --git a/src/RS232_unix.c b/src/RS232_unix.c --- a/src/RS232_unix.c +++ b/src/RS232_unix.c @@ -134,12 +134,18 @@ int rs232setnbstop(rs232port_t fd, rs232 tcgetattr((int)fd, &terminos); switch(NbStop) { - case 2: + case rs232OneStop: + terminos.c_cflag &= ~CSTOPB; + break; + case rs232One5Stop: terminos.c_cflag |= CSTOPB; - break; + break; + case rs232TwoStop: + terminos.c_cflag |= CSTOPB; + break; default: terminos.c_cflag &= ~CSTOPB; - break; + break; } tcsetattr((int)fd, TCSANOW, &terminos); return 0; diff --git a/src/RS232_win.c b/src/RS232_win.c --- a/src/RS232_win.c +++ b/src/RS232_win.c @@ -45,7 +45,7 @@ int privatedecodestop(rs232stop NbStop) case rs232TwoStop: return TWOSTOPBITS; break; - default; + default: return ONESTOPBIT; break; } @@ -101,7 +101,7 @@ rs232port_t rs232open(char* psPortName) rs232port_t fd; fd = (rs232port_t)CreateFile(psPortName,GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0); #ifdef debug - if(fd==INVALID_HANDLE_VALUE) + if(fd==(rs232port_t)INVALID_HANDLE_VALUE) { printf("can't open Port\n"); return (rs232port_t)badPortValue;