Return TRUE on success in COMM_BuildOldCommDCB.

DCB16.BaudRate > 57600 means 115200.
OpenComm16 should use overlapped I/O.
This commit is contained in:
Mike McCormack 2001-10-21 15:01:20 +00:00 committed by Alexandre Julliard
parent 32fb580515
commit c5ea29f99b
2 changed files with 30 additions and 7 deletions

View File

@ -211,7 +211,7 @@ BOOL WINAPI COMM_BuildOldCommDCB(LPCSTR device, LPDCB lpdcb)
lpdcb->fRtsControl = RTS_CONTROL_ENABLE; lpdcb->fRtsControl = RTS_CONTROL_ENABLE;
} }
return 0; return TRUE;
} }
/************************************************************************** /**************************************************************************
@ -844,10 +844,6 @@ BOOL WINAPI SetCommState(
port.c_lflag &= ~(ICANON|ECHO|ISIG); port.c_lflag &= ~(ICANON|ECHO|ISIG);
port.c_lflag |= NOFLSH; port.c_lflag |= NOFLSH;
/*
** MJM - removed default baudrate settings
** TRACE(comm,"baudrate %ld\n",lpdcb->BaudRate);
*/
#ifdef CBAUD #ifdef CBAUD
port.c_cflag &= ~CBAUD; port.c_cflag &= ~CBAUD;
switch (lpdcb->BaudRate) { switch (lpdcb->BaudRate) {

View File

@ -504,7 +504,8 @@ INT16 WINAPI OpenComm16(LPCSTR device,UINT16 cbInQueue,UINT16 cbOutQueue)
return IE_OPEN; return IE_OPEN;
handle = CreateFileA(device, GENERIC_READ|GENERIC_WRITE, handle = CreateFileA(device, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, 0 ); FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
FILE_FLAG_OVERLAPPED|FILE_FLAG_NO_BUFFERING, 0 );
if (handle == INVALID_HANDLE_VALUE) { if (handle == INVALID_HANDLE_VALUE) {
ERR("Couldn't open %s ! (%s)\n", COM[port].devicename, strerror(errno)); ERR("Couldn't open %s ! (%s)\n", COM[port].devicename, strerror(errno));
return IE_HARDWARE; return IE_HARDWARE;
@ -874,10 +875,36 @@ INT16 WINAPI SetCommState16(LPDCB16 lpdcb)
memset(&dcb,0,sizeof dcb); memset(&dcb,0,sizeof dcb);
dcb.DCBlength = sizeof dcb; dcb.DCBlength = sizeof dcb;
if(lpdcb->BaudRate==57601)
/*
* according to MSDN, we should first interpret lpdcb->BaudRate as follows:
* 1. if the baud rate is a CBR constant, interpret it.
* 2. if it is greater than 57600, the baud rate is 115200
* 3. use the actual baudrate
* steps 2 and 3 are equivilent to 16550 baudrate divisor = 115200/BaudRate
* see http://support.microsoft.com/support/kb/articles/q108/9/28.asp
*/
switch(lpdcb->BaudRate)
{
case CBR_110: dcb.BaudRate = 110; break;
case CBR_300: dcb.BaudRate = 300; break;
case CBR_600: dcb.BaudRate = 600; break;
case CBR_1200: dcb.BaudRate = 1200; break;
case CBR_2400: dcb.BaudRate = 2400; break;
case CBR_4800: dcb.BaudRate = 4800; break;
case CBR_9600: dcb.BaudRate = 9600; break;
case CBR_14400: dcb.BaudRate = 14400; break;
case CBR_19200: dcb.BaudRate = 19200; break;
case CBR_38400: dcb.BaudRate = 38400; break;
case CBR_56000: dcb.BaudRate = 56000; break;
case CBR_128000: dcb.BaudRate = 128000; break;
case CBR_256000: dcb.BaudRate = 256000; break;
default:
if(lpdcb->BaudRate>57600)
dcb.BaudRate = 115200; dcb.BaudRate = 115200;
else else
dcb.BaudRate = lpdcb->BaudRate; dcb.BaudRate = lpdcb->BaudRate;
}
dcb.ByteSize=lpdcb->ByteSize; dcb.ByteSize=lpdcb->ByteSize;
dcb.StopBits=lpdcb->StopBits; dcb.StopBits=lpdcb->StopBits;