Commit 6b95c0e4 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

kernel32: ClearCommError.

ClearCommError should only deal with *communication* errors (are being seen on the serial interface) rather than API errors (which can be reported to the caller by the API itself). I then removed all the stuff related to storing the error status in the server object.
parent cd024942
...@@ -650,39 +650,6 @@ BOOL WINAPI BuildCommDCBW( ...@@ -650,39 +650,6 @@ BOOL WINAPI BuildCommDCBW(
return BuildCommDCBAndTimeoutsW(devid,lpdcb,NULL); return BuildCommDCBAndTimeoutsW(devid,lpdcb,NULL);
} }
static BOOL COMM_SetCommError(HANDLE handle, DWORD error)
{
DWORD ret;
SERVER_START_REQ( set_serial_info )
{
req->handle = handle;
req->flags = SERIALINFO_SET_ERROR;
req->commerror = error;
ret = !wine_server_call_err( req );
}
SERVER_END_REQ;
return ret;
}
static BOOL COMM_GetCommError(HANDLE handle, LPDWORD lperror)
{
DWORD ret;
if(!lperror)
return FALSE;
SERVER_START_REQ( get_serial_info )
{
req->handle = handle;
ret = !wine_server_call_err( req );
*lperror = reply->commerror;
}
SERVER_END_REQ;
return ret;
}
/***************************************************************************** /*****************************************************************************
* SetCommBreak (KERNEL32.@) * SetCommBreak (KERNEL32.@)
* *
...@@ -750,7 +717,6 @@ BOOL WINAPI EscapeCommFunction( ...@@ -750,7 +717,6 @@ BOOL WINAPI EscapeCommFunction(
if(fd<0) return FALSE; if(fd<0) return FALSE;
if (tcgetattr(fd,&port) == -1) { if (tcgetattr(fd,&port) == -1) {
COMM_SetCommError(handle,CE_IOE);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
return FALSE; return FALSE;
} }
...@@ -824,7 +790,6 @@ BOOL WINAPI EscapeCommFunction( ...@@ -824,7 +790,6 @@ BOOL WINAPI EscapeCommFunction(
if (!direct) if (!direct)
if (tcsetattr(fd, TCSADRAIN, &port) == -1) { if (tcsetattr(fd, TCSADRAIN, &port) == -1) {
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
COMM_SetCommError(handle,CE_IOE);
return FALSE; return FALSE;
} else } else
result= TRUE; result= TRUE;
...@@ -833,7 +798,6 @@ BOOL WINAPI EscapeCommFunction( ...@@ -833,7 +798,6 @@ BOOL WINAPI EscapeCommFunction(
if (result == -1) if (result == -1)
{ {
result= FALSE; result= FALSE;
COMM_SetCommError(handle,CE_IOE);
} }
else else
result = TRUE; result = TRUE;
...@@ -912,8 +876,7 @@ BOOL WINAPI ClearCommError( ...@@ -912,8 +876,7 @@ BOOL WINAPI ClearCommError(
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
COMM_GetCommError(handle, errors); if (errors) *errors = 0; /* FIXME */
COMM_SetCommError(handle, 0);
return TRUE; return TRUE;
} }
...@@ -1028,7 +991,6 @@ BOOL WINAPI SetCommState( ...@@ -1028,7 +991,6 @@ BOOL WINAPI SetCommState(
if ((tcgetattr(fd,&port)) == -1) { if ((tcgetattr(fd,&port)) == -1) {
int save_error = errno; int save_error = errno;
COMM_SetCommError(handle,CE_IOE);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
ERR("tcgetattr error '%s'\n", strerror(save_error)); ERR("tcgetattr error '%s'\n", strerror(save_error));
return FALSE; return FALSE;
...@@ -1134,7 +1096,7 @@ BOOL WINAPI SetCommState( ...@@ -1134,7 +1096,7 @@ BOOL WINAPI SetCommState(
#endif #endif
default: default:
#if defined (HAVE_LINUX_SERIAL_H) && defined (TIOCSSERIAL) #if defined (HAVE_LINUX_SERIAL_H) && defined (TIOCSSERIAL)
{ struct serial_struct nuts; { struct serial_struct nuts;
int arby; int arby;
ioctl(fd, TIOCGSERIAL, &nuts); ioctl(fd, TIOCGSERIAL, &nuts);
nuts.custom_divisor = nuts.baud_base / lpdcb->BaudRate; nuts.custom_divisor = nuts.baud_base / lpdcb->BaudRate;
...@@ -1156,7 +1118,6 @@ BOOL WINAPI SetCommState( ...@@ -1156,7 +1118,6 @@ BOOL WINAPI SetCommState(
#endif /* Don't have linux/serial.h or lack TIOCSSERIAL */ #endif /* Don't have linux/serial.h or lack TIOCSSERIAL */
COMM_SetCommError(handle,IE_BAUDRATE);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
ERR("baudrate %ld\n",lpdcb->BaudRate); ERR("baudrate %ld\n",lpdcb->BaudRate);
return FALSE; return FALSE;
...@@ -1243,7 +1204,6 @@ BOOL WINAPI SetCommState( ...@@ -1243,7 +1204,6 @@ BOOL WINAPI SetCommState(
break; break;
#endif #endif
default: default:
COMM_SetCommError(handle,IE_BAUDRATE);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
ERR("baudrate %ld\n",lpdcb->BaudRate); ERR("baudrate %ld\n",lpdcb->BaudRate);
return FALSE; return FALSE;
...@@ -1286,7 +1246,6 @@ BOOL WINAPI SetCommState( ...@@ -1286,7 +1246,6 @@ BOOL WINAPI SetCommState(
stopbits = TWOSTOPBITS; stopbits = TWOSTOPBITS;
port.c_iflag &= ~INPCK; port.c_iflag &= ~INPCK;
} else { } else {
COMM_SetCommError(handle,IE_BYTESIZE);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
ERR("Cannot set MARK Parity\n"); ERR("Cannot set MARK Parity\n");
return FALSE; return FALSE;
...@@ -1297,7 +1256,6 @@ BOOL WINAPI SetCommState( ...@@ -1297,7 +1256,6 @@ BOOL WINAPI SetCommState(
bytesize +=1; bytesize +=1;
port.c_iflag &= ~INPCK; port.c_iflag &= ~INPCK;
} else { } else {
COMM_SetCommError(handle,IE_BYTESIZE);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
ERR("Cannot set SPACE Parity\n"); ERR("Cannot set SPACE Parity\n");
return FALSE; return FALSE;
...@@ -1305,7 +1263,6 @@ BOOL WINAPI SetCommState( ...@@ -1305,7 +1263,6 @@ BOOL WINAPI SetCommState(
break; break;
#endif #endif
default: default:
COMM_SetCommError(handle,IE_BYTESIZE);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
ERR("Parity\n"); ERR("Parity\n");
return FALSE; return FALSE;
...@@ -1327,7 +1284,6 @@ BOOL WINAPI SetCommState( ...@@ -1327,7 +1284,6 @@ BOOL WINAPI SetCommState(
port.c_cflag |= CS8; port.c_cflag |= CS8;
break; break;
default: default:
COMM_SetCommError(handle,IE_BYTESIZE);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
ERR("ByteSize\n"); ERR("ByteSize\n");
return FALSE; return FALSE;
...@@ -1342,7 +1298,6 @@ BOOL WINAPI SetCommState( ...@@ -1342,7 +1298,6 @@ BOOL WINAPI SetCommState(
port.c_cflag |= CSTOPB; port.c_cflag |= CSTOPB;
break; break;
default: default:
COMM_SetCommError(handle,IE_BYTESIZE);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
ERR("StopBits\n"); ERR("StopBits\n");
return FALSE; return FALSE;
...@@ -1368,10 +1323,9 @@ BOOL WINAPI SetCommState( ...@@ -1368,10 +1323,9 @@ BOOL WINAPI SetCommState(
if (tcsetattr(fd,TCSANOW,&port)==-1) { /* otherwise it hangs with pending input*/ if (tcsetattr(fd,TCSANOW,&port)==-1) { /* otherwise it hangs with pending input*/
ERR("tcsetattr error '%s'\n", strerror(errno)); ERR("tcsetattr error '%s'\n", strerror(errno));
COMM_SetCommError(handle,CE_IOE);
ret = FALSE; ret = FALSE;
} else { } else {
COMM_SetCommError(handle,0); ClearCommError(handle, NULL, NULL);
ret = TRUE; ret = TRUE;
} }
...@@ -1431,7 +1385,6 @@ BOOL WINAPI GetCommState( ...@@ -1431,7 +1385,6 @@ BOOL WINAPI GetCommState(
if (tcgetattr(fd, &port) == -1) { if (tcgetattr(fd, &port) == -1) {
int save_error=errno; int save_error=errno;
ERR("tcgetattr error '%s'\n", strerror(save_error)); ERR("tcgetattr error '%s'\n", strerror(save_error));
COMM_SetCommError(handle,CE_IOE);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
return FALSE; return FALSE;
} }
...@@ -1620,8 +1573,6 @@ BOOL WINAPI GetCommState( ...@@ -1620,8 +1573,6 @@ BOOL WINAPI GetCommState(
lpdcb->XonLim = 10; lpdcb->XonLim = 10;
lpdcb->XoffLim = 10; lpdcb->XoffLim = 10;
COMM_SetCommError(handle,0);
TRACE("OK\n"); TRACE("OK\n");
TRACE("bytesize %d baudrate %ld fParity %d Parity %d stopbits %d\n", TRACE("bytesize %d baudrate %ld fParity %d Parity %d stopbits %d\n",
......
...@@ -804,6 +804,18 @@ static void test_ClearCommErrors(HANDLE hcom) ...@@ -804,6 +804,18 @@ static void test_ClearCommErrors(HANDLE hcom)
trace("test_ClearCommErrors done\n"); trace("test_ClearCommErrors done\n");
} }
static void test_non_pending_errors(HANDLE hcom)
{
DCB dcb;
DWORD err;
ok(GetCommState(hcom, &dcb), "GetCommState failed\n");
dcb.ByteSize = 255; /* likely bogus */
ok(!SetCommState(hcom, &dcb), "SetCommState should have failed\n");
ok(ClearCommError(hcom, &err, NULL), "ClearCommError should succeed\n");
ok(!(err & CE_MODE), "ClearCommError shouldn't set CE_MODE byte in this case (%lx)\n", err);
}
/**/ /**/
static void test_LoopbackRead(HANDLE hcom) static void test_LoopbackRead(HANDLE hcom)
{ {
...@@ -1613,7 +1625,7 @@ static void test_WaitBreak(HANDLE hcom) ...@@ -1613,7 +1625,7 @@ static void test_WaitBreak(HANDLE hcom)
START_TEST(comm) START_TEST(comm)
{ {
HANDLE hcom; HANDLE hcom;
/* use variabel and not #define to compile the code */ /* use variables and not #define to compile the code */
BOOL loopback_txd_rxd = LOOPBACK_TXD_RXD; BOOL loopback_txd_rxd = LOOPBACK_TXD_RXD;
BOOL loopback_rts_cts = LOOPBACK_CTS_RTS; BOOL loopback_rts_cts = LOOPBACK_CTS_RTS;
BOOL loopback_dtr_dsr = LOOPBACK_DTR_DSR; BOOL loopback_dtr_dsr = LOOPBACK_DTR_DSR;
...@@ -1632,10 +1644,16 @@ START_TEST(comm) ...@@ -1632,10 +1644,16 @@ START_TEST(comm)
hcom = test_OpenComm(FALSE); hcom = test_OpenComm(FALSE);
if (hcom != INVALID_HANDLE_VALUE) if (hcom != INVALID_HANDLE_VALUE)
{ {
Sleep(200); /* Give the laster cahacter of test_waittxempty to drop into the receiver*/ Sleep(200); /* Give the laster character of test_waittxempty to drop into the receiver */
test_ClearCommErrors(hcom); test_ClearCommErrors(hcom);
CloseHandle(hcom); CloseHandle(hcom);
} }
hcom = test_OpenComm(FALSE);
if (hcom != INVALID_HANDLE_VALUE)
{
test_non_pending_errors(hcom);
CloseHandle(hcom);
}
if((loopback_txd_rxd) && ((hcom = test_OpenComm(FALSE))!=INVALID_HANDLE_VALUE)) if((loopback_txd_rxd) && ((hcom = test_OpenComm(FALSE))!=INVALID_HANDLE_VALUE))
{ {
test_LoopbackRead(hcom); test_LoopbackRead(hcom);
......
...@@ -2349,7 +2349,6 @@ struct get_serial_info_reply ...@@ -2349,7 +2349,6 @@ struct get_serial_info_reply
unsigned int writeconst; unsigned int writeconst;
unsigned int writemult; unsigned int writemult;
unsigned int eventmask; unsigned int eventmask;
unsigned int commerror;
}; };
...@@ -2365,7 +2364,6 @@ struct set_serial_info_request ...@@ -2365,7 +2364,6 @@ struct set_serial_info_request
unsigned int writeconst; unsigned int writeconst;
unsigned int writemult; unsigned int writemult;
unsigned int eventmask; unsigned int eventmask;
unsigned int commerror;
}; };
struct set_serial_info_reply struct set_serial_info_reply
{ {
...@@ -2373,7 +2371,6 @@ struct set_serial_info_reply ...@@ -2373,7 +2371,6 @@ struct set_serial_info_reply
}; };
#define SERIALINFO_SET_TIMEOUTS 0x01 #define SERIALINFO_SET_TIMEOUTS 0x01
#define SERIALINFO_SET_MASK 0x02 #define SERIALINFO_SET_MASK 0x02
#define SERIALINFO_SET_ERROR 0x04
...@@ -4361,6 +4358,6 @@ union generic_reply ...@@ -4361,6 +4358,6 @@ union generic_reply
struct query_symlink_reply query_symlink_reply; struct query_symlink_reply query_symlink_reply;
}; };
#define SERVER_PROTOCOL_VERSION 228 #define SERVER_PROTOCOL_VERSION 229
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
...@@ -1673,7 +1673,6 @@ enum message_type ...@@ -1673,7 +1673,6 @@ enum message_type
unsigned int writeconst; unsigned int writeconst;
unsigned int writemult; unsigned int writemult;
unsigned int eventmask; unsigned int eventmask;
unsigned int commerror;
@END @END
...@@ -1687,11 +1686,9 @@ enum message_type ...@@ -1687,11 +1686,9 @@ enum message_type
unsigned int writeconst; unsigned int writeconst;
unsigned int writemult; unsigned int writemult;
unsigned int eventmask; unsigned int eventmask;
unsigned int commerror;
@END @END
#define SERIALINFO_SET_TIMEOUTS 0x01 #define SERIALINFO_SET_TIMEOUTS 0x01
#define SERIALINFO_SET_MASK 0x02 #define SERIALINFO_SET_MASK 0x02
#define SERIALINFO_SET_ERROR 0x04
/* Create an async I/O */ /* Create an async I/O */
......
...@@ -82,7 +82,6 @@ struct serial ...@@ -82,7 +82,6 @@ struct serial
unsigned int writemult; unsigned int writemult;
unsigned int eventmask; unsigned int eventmask;
unsigned int commerror;
struct termios original; struct termios original;
...@@ -146,7 +145,6 @@ struct object *create_serial( struct fd *fd, unsigned int options ) ...@@ -146,7 +145,6 @@ struct object *create_serial( struct fd *fd, unsigned int options )
serial->writemult = 0; serial->writemult = 0;
serial->writeconst = 0; serial->writeconst = 0;
serial->eventmask = 0; serial->eventmask = 0;
serial->commerror = 0;
list_init( &serial->read_q ); list_init( &serial->read_q );
list_init( &serial->write_q ); list_init( &serial->write_q );
list_init( &serial->wait_q ); list_init( &serial->wait_q );
...@@ -323,9 +321,6 @@ DECL_HANDLER(get_serial_info) ...@@ -323,9 +321,6 @@ DECL_HANDLER(get_serial_info)
/* event mask */ /* event mask */
reply->eventmask = serial->eventmask; reply->eventmask = serial->eventmask;
/* comm port error status */
reply->commerror = serial->commerror;
release_object( serial ); release_object( serial );
} }
} }
...@@ -356,12 +351,6 @@ DECL_HANDLER(set_serial_info) ...@@ -356,12 +351,6 @@ DECL_HANDLER(set_serial_info)
} }
} }
/* comm port error status */
if (req->flags & SERIALINFO_SET_ERROR)
{
serial->commerror = req->commerror;
}
release_object( serial ); release_object( serial );
} }
} }
...@@ -2151,8 +2151,7 @@ static void dump_get_serial_info_reply( const struct get_serial_info_reply *req ...@@ -2151,8 +2151,7 @@ static void dump_get_serial_info_reply( const struct get_serial_info_reply *req
fprintf( stderr, " readmult=%08x,", req->readmult ); fprintf( stderr, " readmult=%08x,", req->readmult );
fprintf( stderr, " writeconst=%08x,", req->writeconst ); fprintf( stderr, " writeconst=%08x,", req->writeconst );
fprintf( stderr, " writemult=%08x,", req->writemult ); fprintf( stderr, " writemult=%08x,", req->writemult );
fprintf( stderr, " eventmask=%08x,", req->eventmask ); fprintf( stderr, " eventmask=%08x", req->eventmask );
fprintf( stderr, " commerror=%08x", req->commerror );
} }
static void dump_set_serial_info_request( const struct set_serial_info_request *req ) static void dump_set_serial_info_request( const struct set_serial_info_request *req )
...@@ -2164,8 +2163,7 @@ static void dump_set_serial_info_request( const struct set_serial_info_request * ...@@ -2164,8 +2163,7 @@ static void dump_set_serial_info_request( const struct set_serial_info_request *
fprintf( stderr, " readmult=%08x,", req->readmult ); fprintf( stderr, " readmult=%08x,", req->readmult );
fprintf( stderr, " writeconst=%08x,", req->writeconst ); fprintf( stderr, " writeconst=%08x,", req->writeconst );
fprintf( stderr, " writemult=%08x,", req->writemult ); fprintf( stderr, " writemult=%08x,", req->writemult );
fprintf( stderr, " eventmask=%08x,", req->eventmask ); fprintf( stderr, " eventmask=%08x", req->eventmask );
fprintf( stderr, " commerror=%08x", req->commerror );
} }
static void dump_register_async_request( const struct register_async_request *req ) static void dump_register_async_request( const struct register_async_request *req )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment