ntdll/kernel32: GetCommState & IOCTL_GET_CHARS

- implemented SERIAL_GET_CHARS ioctl
- made use of it in kernel32.GetCommState
This commit is contained in:
Eric Pouech 2006-05-07 14:10:55 +02:00 committed by Alexandre Julliard
parent 48646ea82b
commit 28cd4fae3b
2 changed files with 37 additions and 5 deletions

View File

@ -1080,6 +1080,7 @@ BOOL WINAPI GetCommState(HANDLE handle, LPDCB lpdcb)
SERIAL_BAUD_RATE sbr;
SERIAL_LINE_CONTROL slc;
SERIAL_HANDFLOW shf;
SERIAL_CHARS sc;
TRACE("handle %p, ptr %p\n", handle, lpdcb);
@ -1094,7 +1095,9 @@ BOOL WINAPI GetCommState(HANDLE handle, LPDCB lpdcb)
!DeviceIoControl(handle, IOCTL_SERIAL_GET_LINE_CONTROL,
NULL, 0, &slc, sizeof(slc), NULL, NULL) ||
!DeviceIoControl(handle, IOCTL_SERIAL_GET_HANDFLOW,
NULL, 0, &shf, sizeof(shf), NULL, NULL))
NULL, 0, &shf, sizeof(shf), NULL, NULL) ||
!DeviceIoControl(handle, IOCTL_SERIAL_GET_CHARS,
NULL, 0, &sc, sizeof(sc), NULL, NULL))
return FALSE;
memset(lpdcb, 0, sizeof(*lpdcb));
@ -1137,10 +1140,11 @@ BOOL WINAPI GetCommState(HANDLE handle, LPDCB lpdcb)
if (shf.FlowReplace & SERIAL_AUTO_TRANSMIT) lpdcb->fOutX = 1;
if (shf.FlowReplace & SERIAL_AUTO_RECEIVE) lpdcb->fInX = 1;
/*
lpdcb->XonChar =
lpdcb->XoffChar =
*/
lpdcb->EofChar = sc.EofChar;
lpdcb->ErrorChar = sc.ErrorChar;
lpdcb->EvtChar = sc.EventChar;
lpdcb->XonChar = sc.XonChar;
lpdcb->XoffChar = sc.XoffChar;
TRACE("OK\n");
dump_dcb(lpdcb);

View File

@ -319,6 +319,25 @@ static NTSTATUS get_modem_status(int fd, DWORD* lpModemStat)
return status;
}
static NTSTATUS get_special_chars(int fd, SERIAL_CHARS* sc)
{
struct termios port;
if (tcgetattr(fd, &port) == -1)
{
ERR("tcgetattr error '%s'\n", strerror(errno));
return FILE_GetNtStatus();
}
sc->EofChar = port.c_cc[VEOF];
sc->ErrorChar = 0xFF;
sc->BreakChar = 0; /* FIXME */
sc->EventChar = 0; /* FIXME */
sc->XonChar = port.c_cc[VSTART];
sc->XoffChar = port.c_cc[VSTOP];
return STATUS_SUCCESS;
}
static NTSTATUS get_status(int fd, SERIAL_STATUS* ss)
{
NTSTATUS status = STATUS_SUCCESS;
@ -779,6 +798,15 @@ NTSTATUS COMM_DeviceIoControl(HANDLE hDevice,
else
status = STATUS_INVALID_PARAMETER;
break;
case IOCTL_SERIAL_GET_CHARS:
if (lpOutBuffer && nOutBufferSize == sizeof(SERIAL_CHARS))
{
if (!(status = get_special_chars(fd, (SERIAL_CHARS*)lpOutBuffer)))
sz = sizeof(SERIAL_CHARS);
}
else
status = STATUS_INVALID_PARAMETER;
break;
case IOCTL_SERIAL_GET_COMMSTATUS:
if (lpOutBuffer && nOutBufferSize == sizeof(SERIAL_STATUS))
{