mirror of
git://source.winehq.org/git/wine.git
synced 2024-08-31 13:25:11 +00:00
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.
This commit is contained in:
parent
cd024942af
commit
6b95c0e4b4
|
@ -650,39 +650,6 @@ BOOL WINAPI BuildCommDCBW(
|
|||
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.@)
|
||||
*
|
||||
|
@ -750,7 +717,6 @@ BOOL WINAPI EscapeCommFunction(
|
|||
if(fd<0) return FALSE;
|
||||
|
||||
if (tcgetattr(fd,&port) == -1) {
|
||||
COMM_SetCommError(handle,CE_IOE);
|
||||
release_comm_fd( handle, fd );
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -824,7 +790,6 @@ BOOL WINAPI EscapeCommFunction(
|
|||
if (!direct)
|
||||
if (tcsetattr(fd, TCSADRAIN, &port) == -1) {
|
||||
release_comm_fd( handle, fd );
|
||||
COMM_SetCommError(handle,CE_IOE);
|
||||
return FALSE;
|
||||
} else
|
||||
result= TRUE;
|
||||
|
@ -833,7 +798,6 @@ BOOL WINAPI EscapeCommFunction(
|
|||
if (result == -1)
|
||||
{
|
||||
result= FALSE;
|
||||
COMM_SetCommError(handle,CE_IOE);
|
||||
}
|
||||
else
|
||||
result = TRUE;
|
||||
|
@ -912,8 +876,7 @@ BOOL WINAPI ClearCommError(
|
|||
|
||||
release_comm_fd( handle, fd );
|
||||
|
||||
COMM_GetCommError(handle, errors);
|
||||
COMM_SetCommError(handle, 0);
|
||||
if (errors) *errors = 0; /* FIXME */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1028,7 +991,6 @@ BOOL WINAPI SetCommState(
|
|||
|
||||
if ((tcgetattr(fd,&port)) == -1) {
|
||||
int save_error = errno;
|
||||
COMM_SetCommError(handle,CE_IOE);
|
||||
release_comm_fd( handle, fd );
|
||||
ERR("tcgetattr error '%s'\n", strerror(save_error));
|
||||
return FALSE;
|
||||
|
@ -1134,7 +1096,7 @@ BOOL WINAPI SetCommState(
|
|||
#endif
|
||||
default:
|
||||
#if defined (HAVE_LINUX_SERIAL_H) && defined (TIOCSSERIAL)
|
||||
{ struct serial_struct nuts;
|
||||
{ struct serial_struct nuts;
|
||||
int arby;
|
||||
ioctl(fd, TIOCGSERIAL, &nuts);
|
||||
nuts.custom_divisor = nuts.baud_base / lpdcb->BaudRate;
|
||||
|
@ -1156,7 +1118,6 @@ BOOL WINAPI SetCommState(
|
|||
#endif /* Don't have linux/serial.h or lack TIOCSSERIAL */
|
||||
|
||||
|
||||
COMM_SetCommError(handle,IE_BAUDRATE);
|
||||
release_comm_fd( handle, fd );
|
||||
ERR("baudrate %ld\n",lpdcb->BaudRate);
|
||||
return FALSE;
|
||||
|
@ -1243,7 +1204,6 @@ BOOL WINAPI SetCommState(
|
|||
break;
|
||||
#endif
|
||||
default:
|
||||
COMM_SetCommError(handle,IE_BAUDRATE);
|
||||
release_comm_fd( handle, fd );
|
||||
ERR("baudrate %ld\n",lpdcb->BaudRate);
|
||||
return FALSE;
|
||||
|
@ -1286,7 +1246,6 @@ BOOL WINAPI SetCommState(
|
|||
stopbits = TWOSTOPBITS;
|
||||
port.c_iflag &= ~INPCK;
|
||||
} else {
|
||||
COMM_SetCommError(handle,IE_BYTESIZE);
|
||||
release_comm_fd( handle, fd );
|
||||
ERR("Cannot set MARK Parity\n");
|
||||
return FALSE;
|
||||
|
@ -1297,7 +1256,6 @@ BOOL WINAPI SetCommState(
|
|||
bytesize +=1;
|
||||
port.c_iflag &= ~INPCK;
|
||||
} else {
|
||||
COMM_SetCommError(handle,IE_BYTESIZE);
|
||||
release_comm_fd( handle, fd );
|
||||
ERR("Cannot set SPACE Parity\n");
|
||||
return FALSE;
|
||||
|
@ -1305,7 +1263,6 @@ BOOL WINAPI SetCommState(
|
|||
break;
|
||||
#endif
|
||||
default:
|
||||
COMM_SetCommError(handle,IE_BYTESIZE);
|
||||
release_comm_fd( handle, fd );
|
||||
ERR("Parity\n");
|
||||
return FALSE;
|
||||
|
@ -1327,7 +1284,6 @@ BOOL WINAPI SetCommState(
|
|||
port.c_cflag |= CS8;
|
||||
break;
|
||||
default:
|
||||
COMM_SetCommError(handle,IE_BYTESIZE);
|
||||
release_comm_fd( handle, fd );
|
||||
ERR("ByteSize\n");
|
||||
return FALSE;
|
||||
|
@ -1342,7 +1298,6 @@ BOOL WINAPI SetCommState(
|
|||
port.c_cflag |= CSTOPB;
|
||||
break;
|
||||
default:
|
||||
COMM_SetCommError(handle,IE_BYTESIZE);
|
||||
release_comm_fd( handle, fd );
|
||||
ERR("StopBits\n");
|
||||
return FALSE;
|
||||
|
@ -1368,10 +1323,9 @@ BOOL WINAPI SetCommState(
|
|||
|
||||
if (tcsetattr(fd,TCSANOW,&port)==-1) { /* otherwise it hangs with pending input*/
|
||||
ERR("tcsetattr error '%s'\n", strerror(errno));
|
||||
COMM_SetCommError(handle,CE_IOE);
|
||||
ret = FALSE;
|
||||
} else {
|
||||
COMM_SetCommError(handle,0);
|
||||
ClearCommError(handle, NULL, NULL);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
|
@ -1431,7 +1385,6 @@ BOOL WINAPI GetCommState(
|
|||
if (tcgetattr(fd, &port) == -1) {
|
||||
int save_error=errno;
|
||||
ERR("tcgetattr error '%s'\n", strerror(save_error));
|
||||
COMM_SetCommError(handle,CE_IOE);
|
||||
release_comm_fd( handle, fd );
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1620,8 +1573,6 @@ BOOL WINAPI GetCommState(
|
|||
lpdcb->XonLim = 10;
|
||||
lpdcb->XoffLim = 10;
|
||||
|
||||
COMM_SetCommError(handle,0);
|
||||
|
||||
TRACE("OK\n");
|
||||
|
||||
TRACE("bytesize %d baudrate %ld fParity %d Parity %d stopbits %d\n",
|
||||
|
|
|
@ -804,6 +804,18 @@ static void test_ClearCommErrors(HANDLE hcom)
|
|||
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)
|
||||
{
|
||||
|
@ -1613,7 +1625,7 @@ static void test_WaitBreak(HANDLE hcom)
|
|||
START_TEST(comm)
|
||||
{
|
||||
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_rts_cts = LOOPBACK_CTS_RTS;
|
||||
BOOL loopback_dtr_dsr = LOOPBACK_DTR_DSR;
|
||||
|
@ -1632,10 +1644,16 @@ START_TEST(comm)
|
|||
hcom = test_OpenComm(FALSE);
|
||||
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);
|
||||
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))
|
||||
{
|
||||
test_LoopbackRead(hcom);
|
||||
|
|
|
@ -2349,7 +2349,6 @@ struct get_serial_info_reply
|
|||
unsigned int writeconst;
|
||||
unsigned int writemult;
|
||||
unsigned int eventmask;
|
||||
unsigned int commerror;
|
||||
};
|
||||
|
||||
|
||||
|
@ -2365,7 +2364,6 @@ struct set_serial_info_request
|
|||
unsigned int writeconst;
|
||||
unsigned int writemult;
|
||||
unsigned int eventmask;
|
||||
unsigned int commerror;
|
||||
};
|
||||
struct set_serial_info_reply
|
||||
{
|
||||
|
@ -2373,7 +2371,6 @@ struct set_serial_info_reply
|
|||
};
|
||||
#define SERIALINFO_SET_TIMEOUTS 0x01
|
||||
#define SERIALINFO_SET_MASK 0x02
|
||||
#define SERIALINFO_SET_ERROR 0x04
|
||||
|
||||
|
||||
|
||||
|
@ -4361,6 +4358,6 @@ union generic_reply
|
|||
struct query_symlink_reply query_symlink_reply;
|
||||
};
|
||||
|
||||
#define SERVER_PROTOCOL_VERSION 228
|
||||
#define SERVER_PROTOCOL_VERSION 229
|
||||
|
||||
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
|
||||
|
|
|
@ -1673,7 +1673,6 @@ enum message_type
|
|||
unsigned int writeconst;
|
||||
unsigned int writemult;
|
||||
unsigned int eventmask;
|
||||
unsigned int commerror;
|
||||
@END
|
||||
|
||||
|
||||
|
@ -1687,11 +1686,9 @@ enum message_type
|
|||
unsigned int writeconst;
|
||||
unsigned int writemult;
|
||||
unsigned int eventmask;
|
||||
unsigned int commerror;
|
||||
@END
|
||||
#define SERIALINFO_SET_TIMEOUTS 0x01
|
||||
#define SERIALINFO_SET_MASK 0x02
|
||||
#define SERIALINFO_SET_ERROR 0x04
|
||||
|
||||
|
||||
/* Create an async I/O */
|
||||
|
|
|
@ -82,7 +82,6 @@ struct serial
|
|||
unsigned int writemult;
|
||||
|
||||
unsigned int eventmask;
|
||||
unsigned int commerror;
|
||||
|
||||
struct termios original;
|
||||
|
||||
|
@ -146,7 +145,6 @@ struct object *create_serial( struct fd *fd, unsigned int options )
|
|||
serial->writemult = 0;
|
||||
serial->writeconst = 0;
|
||||
serial->eventmask = 0;
|
||||
serial->commerror = 0;
|
||||
list_init( &serial->read_q );
|
||||
list_init( &serial->write_q );
|
||||
list_init( &serial->wait_q );
|
||||
|
@ -323,9 +321,6 @@ DECL_HANDLER(get_serial_info)
|
|||
/* event mask */
|
||||
reply->eventmask = serial->eventmask;
|
||||
|
||||
/* comm port error status */
|
||||
reply->commerror = serial->commerror;
|
||||
|
||||
release_object( serial );
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, " writeconst=%08x,", req->writeconst );
|
||||
fprintf( stderr, " writemult=%08x,", req->writemult );
|
||||
fprintf( stderr, " eventmask=%08x,", req->eventmask );
|
||||
fprintf( stderr, " commerror=%08x", req->commerror );
|
||||
fprintf( stderr, " eventmask=%08x", req->eventmask );
|
||||
}
|
||||
|
||||
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 *
|
|||
fprintf( stderr, " readmult=%08x,", req->readmult );
|
||||
fprintf( stderr, " writeconst=%08x,", req->writeconst );
|
||||
fprintf( stderr, " writemult=%08x,", req->writemult );
|
||||
fprintf( stderr, " eventmask=%08x,", req->eventmask );
|
||||
fprintf( stderr, " commerror=%08x", req->commerror );
|
||||
fprintf( stderr, " eventmask=%08x", req->eventmask );
|
||||
}
|
||||
|
||||
static void dump_register_async_request( const struct register_async_request *req )
|
||||
|
|
Loading…
Reference in a new issue