ntdll: Implemented COMM IOCTL for modem status: GET_MODEMSTATUS.

This commit is contained in:
Eric Pouech 2006-02-06 11:37:39 +01:00 committed by Alexandre Julliard
parent 58e719ce93
commit 5973955e4e
2 changed files with 55 additions and 43 deletions

View file

@ -1801,55 +1801,20 @@ BOOL WINAPI SetCommTimeouts(
*
* Obtains the four control register bits if supported by the hardware.
*
* PARAMS
*
* hFile [in] The communications device
* lpModemStat [out] The control register bits
*
* RETURNS
*
* True if the communications handle was good and for hardware that
* control register access, false otherwise.
*/
BOOL WINAPI GetCommModemStatus(
HANDLE hFile, /* [in] The communications device. */
LPDWORD lpModemStat) /* [out] The control register bits. */
BOOL WINAPI GetCommModemStatus(HANDLE hFile, LPDWORD lpModemStat)
{
int fd,mstat, result=FALSE;
*lpModemStat=0;
#ifdef TIOCMGET
fd = get_comm_fd( hFile, FILE_READ_DATA );
if(fd<0)
return FALSE;
result = ioctl(fd, TIOCMGET, &mstat);
release_comm_fd( hFile, fd );
if (result == -1)
{
WARN("ioctl failed\n");
return FALSE;
}
#ifdef TIOCM_CTS
if (mstat & TIOCM_CTS)
*lpModemStat |= MS_CTS_ON;
#endif
#ifdef TIOCM_DSR
if (mstat & TIOCM_DSR)
*lpModemStat |= MS_DSR_ON;
#endif
#ifdef TIOCM_RNG
if (mstat & TIOCM_RNG)
*lpModemStat |= MS_RING_ON;
#endif
#ifdef TIOCM_CAR
/*FIXME: Not really sure about RLSD UB 990810*/
if (mstat & TIOCM_CAR)
*lpModemStat |= MS_RLSD_ON;
#endif
TRACE("%04x -> %s%s%s%s\n", mstat,
(*lpModemStat &MS_RLSD_ON)?"MS_RLSD_ON ":"",
(*lpModemStat &MS_RING_ON)?"MS_RING_ON ":"",
(*lpModemStat &MS_DSR_ON)?"MS_DSR_ON ":"",
(*lpModemStat &MS_CTS_ON)?"MS_CTS_ON ":"");
return TRUE;
#else
return FALSE;
#endif
return DeviceIoControl(hFile, IOCTL_SERIAL_GET_MODEMSTATUS,
NULL, 0, lpModemStat, sizeof(DWORD), NULL, NULL);
}
static DWORD WINAPI Comm_CheckEvents(int fd, DWORD mask, serial_irq_info *new, serial_irq_info *old, DWORD new_mstat, DWORD old_mstat)

View file

@ -129,6 +129,45 @@ static const char* iocode2str(DWORD ioc)
}
}
static NTSTATUS get_modem_status(int fd, DWORD* lpModemStat)
{
NTSTATUS status = STATUS_SUCCESS;
int mstat;
#ifdef TIOCMGET
if (ioctl(fd, TIOCMGET, &mstat) == -1)
{
WARN("ioctl failed\n");
status = FILE_GetNtStatus();
}
else
{
*lpModemStat = 0;
#ifdef TIOCM_CTS
if (mstat & TIOCM_CTS) *lpModemStat |= MS_CTS_ON;
#endif
#ifdef TIOCM_DSR
if (mstat & TIOCM_DSR) *lpModemStat |= MS_DSR_ON;
#endif
#ifdef TIOCM_RNG
if (mstat & TIOCM_RNG) *lpModemStat |= MS_RING_ON;
#endif
#ifdef TIOCM_CAR
/* FIXME: Not really sure about RLSD UB 990810 */
if (mstat & TIOCM_CAR) *lpModemStat |= MS_RLSD_ON;
#endif
TRACE("%04x -> %s%s%s%s\n", mstat,
(*lpModemStat & MS_RLSD_ON) ? "MS_RLSD_ON " : "",
(*lpModemStat & MS_RING_ON) ? "MS_RING_ON " : "",
(*lpModemStat & MS_DSR_ON) ? "MS_DSR_ON " : "",
(*lpModemStat & MS_CTS_ON) ? "MS_CTS_ON " : "");
}
#else
status = STATUS_NOT_SUPPORTED;
#endif
return status;
}
static NTSTATUS get_wait_mask(HANDLE hDevice, DWORD* mask)
{
NTSTATUS status;
@ -199,6 +238,14 @@ NTSTATUS COMM_DeviceIoControl(HANDLE hDevice,
switch (dwIoControlCode)
{
case IOCTL_SERIAL_GET_MODEMSTATUS:
if (lpOutBuffer && nOutBufferSize == sizeof(DWORD))
{
if (!(status = get_modem_status(fd, (DWORD*)lpOutBuffer)))
sz = sizeof(DWORD);
}
else status = STATUS_INVALID_PARAMETER;
break;
case IOCTL_SERIAL_GET_WAIT_MASK:
if (lpOutBuffer && nOutBufferSize == sizeof(DWORD))
{