Commit 187ed410 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Rewrite GetCommState16 using GetCommState.

parent 574a10ef
...@@ -1161,122 +1161,32 @@ INT16 WINAPI SetCommState16(LPDCB16 lpdcb) ...@@ -1161,122 +1161,32 @@ INT16 WINAPI SetCommState16(LPDCB16 lpdcb)
*/ */
INT16 WINAPI GetCommState16(INT16 cid, LPDCB16 lpdcb) INT16 WINAPI GetCommState16(INT16 cid, LPDCB16 lpdcb)
{ {
int speed;
struct DosDeviceStruct *ptr; struct DosDeviceStruct *ptr;
struct termios port; DCB dcb;
int fd,r;
TRACE("cid %d, ptr %p\n", cid, lpdcb); TRACE("cid %d, ptr %p\n", cid, lpdcb);
if ((ptr = GetDeviceStruct(cid)) == NULL) { if ((ptr = GetDeviceStruct(cid)) == NULL) {
FIXME("no handle for cid = %0x!\n",cid); FIXME("no handle for cid = %0x!\n",cid);
return -1; return -1;
} }
if ( (fd = FILE_GetUnixHandle(ptr->handle,GENERIC_READ)) == 0 ) if (!GetCommState(ptr->handle,&dcb)) {
return -1;
r = tcgetattr(fd, &port);
close(fd);
if (r == -1) {
ptr->commerror = WinError(); ptr->commerror = WinError();
return -1; return -1;
} }
lpdcb->Id = cid; lpdcb->Id = cid;
#ifndef __EMX__ if(dcb.BaudRate<0x10000)
#ifdef CBAUD lpdcb->BaudRate = dcb.BaudRate;
speed = port.c_cflag & CBAUD; else if(dcb.BaudRate==115200)
#else
speed = port.c_ospeed;
#endif
switch(speed) {
case B110:
lpdcb->BaudRate = 110;
break;
case B300:
lpdcb->BaudRate = 300;
break;
case B600:
lpdcb->BaudRate = 600;
break;
case B1200:
lpdcb->BaudRate = 1200;
break;
case B2400:
lpdcb->BaudRate = 2400;
break;
case B4800:
lpdcb->BaudRate = 4800;
break;
case B9600:
lpdcb->BaudRate = 9600;
break;
case B19200:
lpdcb->BaudRate = 19200;
break;
case B38400:
lpdcb->BaudRate = 38400;
break;
#ifdef B57600
case B57600:
lpdcb->BaudRate = 57600;
break;
#endif
#ifdef B115200
case B115200:
lpdcb->BaudRate = 57601; lpdcb->BaudRate = 57601;
break; else {
#endif WARN("Baud rate can't be converted\n");
lpdcb->BaudRate = 57601;
} }
#endif lpdcb->ByteSize = dcb.ByteSize;
switch (port.c_cflag & CSIZE) { lpdcb->fParity = dcb.fParity;
case CS5: lpdcb->Parity = dcb.Parity;
lpdcb->ByteSize = 5; lpdcb->StopBits = dcb.StopBits;
break;
case CS6:
lpdcb->ByteSize = 6;
break;
case CS7:
lpdcb->ByteSize = 7;
break;
case CS8:
lpdcb->ByteSize = 8;
break;
}
if(port.c_iflag & INPCK)
lpdcb->fParity = TRUE;
else
lpdcb->fParity = FALSE;
#ifdef CMSPAR
switch (port.c_cflag & (PARENB | PARODD | CMSPAR))
#else
switch (port.c_cflag & (PARENB | PARODD))
#endif
{
case 0:
lpdcb->Parity = NOPARITY;
break;
case PARENB:
lpdcb->Parity = EVENPARITY;
break;
case (PARENB | PARODD):
lpdcb->Parity = ODDPARITY;
break;
#ifdef CMSPAR
case (PARENB | CMSPAR):
lpdcb->Parity = MARKPARITY;
break;
case (PARENB | PARODD | CMSPAR):
lpdcb->Parity = SPACEPARITY;
break;
#endif
}
if (port.c_cflag & CSTOPB)
if(lpdcb->ByteSize == 5)
lpdcb->StopBits = ONE5STOPBITS;
else
lpdcb->StopBits = TWOSTOPBITS;
else
lpdcb->StopBits = ONESTOPBIT;
lpdcb->RlsTimeout = 50; lpdcb->RlsTimeout = 50;
lpdcb->CtsTimeout = 50; lpdcb->CtsTimeout = 50;
...@@ -1286,26 +1196,15 @@ INT16 WINAPI GetCommState16(INT16 cid, LPDCB16 lpdcb) ...@@ -1286,26 +1196,15 @@ INT16 WINAPI GetCommState16(INT16 cid, LPDCB16 lpdcb)
lpdcb->fBinary = 1; lpdcb->fBinary = 1;
lpdcb->fDtrDisable = 0; lpdcb->fDtrDisable = 0;
#ifdef CRTSCTS lpdcb->fDtrflow = (dcb.fDtrControl==DTR_CONTROL_ENABLE);
lpdcb->fRtsflow = (dcb.fRtsControl==RTS_CONTROL_ENABLE);
if (port.c_cflag & CRTSCTS) { lpdcb->fOutxCtsFlow = dcb.fOutxCtsFlow;
lpdcb->fDtrflow = 1; lpdcb->fOutxDsrFlow = dcb.fOutxDsrFlow;
lpdcb->fRtsflow = 1; lpdcb->fDtrDisable = (dcb.fDtrControl==DTR_CONTROL_DISABLE);
lpdcb->fOutxCtsFlow = 1;
lpdcb->fOutxDsrFlow = 1;
} else
#endif
lpdcb->fDtrDisable = 1;
if (port.c_iflag & IXON) lpdcb->fInX = dcb.fInX;
lpdcb->fInX = 1;
else
lpdcb->fInX = 0;
if (port.c_iflag & IXOFF) lpdcb->fOutX = dcb.fOutX;
lpdcb->fOutX = 1;
else
lpdcb->fOutX = 0;
/* /*
lpdcb->XonChar = lpdcb->XonChar =
lpdcb->XoffChar = lpdcb->XoffChar =
......
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