mirror of https://github.com/FreeRDP/FreeRDP
Merge pull request #2205 from eledoux/ports
winpr-comm: ignore errors on TIOCGICOUNT during the port initialization.
This commit is contained in:
commit
49e5edebbe
|
@ -175,7 +175,7 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
|
||||||
|
|
||||||
if (!serial->hComm || (serial->hComm == INVALID_HANDLE_VALUE))
|
if (!serial->hComm || (serial->hComm == INVALID_HANDLE_VALUE))
|
||||||
{
|
{
|
||||||
WLog_Print(serial->log, WLOG_WARN, "CreateFile failure: %s last-error: Ox%lX\n", serial->device.name, GetLastError());
|
WLog_Print(serial->log, WLOG_WARN, "CreateFile failure: %s last-error: 0x%lX\n", serial->device.name, GetLastError());
|
||||||
|
|
||||||
irp->IoStatus = STATUS_UNSUCCESSFUL;
|
irp->IoStatus = STATUS_UNSUCCESSFUL;
|
||||||
goto error_handle;
|
goto error_handle;
|
||||||
|
|
|
@ -1373,9 +1373,17 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
|
||||||
|
|
||||||
if (ioctl(pComm->fd, TIOCGICOUNT, &(pComm->counters)) < 0)
|
if (ioctl(pComm->fd, TIOCGICOUNT, &(pComm->counters)) < 0)
|
||||||
{
|
{
|
||||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s.", errno, strerror(errno));
|
||||||
SetLastError(ERROR_IO_DEVICE);
|
CommLog_Print(WLOG_WARN, "could not read counters.");
|
||||||
goto error_handle;
|
|
||||||
|
/* could not initialize counters but keep on.
|
||||||
|
*
|
||||||
|
* Not all drivers, especially for USB to serial
|
||||||
|
* adapters (e.g. those based on pl2303), does support
|
||||||
|
* this call.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZeroMemory(&(pComm->counters), sizeof(struct serial_icounter_struct));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1042,11 +1042,19 @@ static BOOL _set_wait_mask(WINPR_COMM *pComm, const ULONG *pWaitMask)
|
||||||
|
|
||||||
if (ioctl(pComm->fd, TIOCGICOUNT, &(pComm->counters)) < 0)
|
if (ioctl(pComm->fd, TIOCGICOUNT, &(pComm->counters)) < 0)
|
||||||
{
|
{
|
||||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s.", errno, strerror(errno));
|
||||||
SetLastError(ERROR_IO_DEVICE);
|
|
||||||
|
if (pComm->permissive)
|
||||||
LeaveCriticalSection(&pComm->EventsLock);
|
{
|
||||||
return FALSE;
|
/* counters could not be reset but keep on */
|
||||||
|
ZeroMemory(&(pComm->counters), sizeof(struct serial_icounter_struct));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_IO_DEVICE);
|
||||||
|
LeaveCriticalSection(&pComm->EventsLock);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pComm->PendingEvents = 0;
|
pComm->PendingEvents = 0;
|
||||||
|
@ -1188,11 +1196,22 @@ static BOOL _get_commstatus(WINPR_COMM *pComm, SERIAL_STATUS *pCommstatus)
|
||||||
ZeroMemory(¤tCounters, sizeof(struct serial_icounter_struct));
|
ZeroMemory(¤tCounters, sizeof(struct serial_icounter_struct));
|
||||||
if (ioctl(pComm->fd, TIOCGICOUNT, ¤tCounters) < 0)
|
if (ioctl(pComm->fd, TIOCGICOUNT, ¤tCounters) < 0)
|
||||||
{
|
{
|
||||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s.", errno, strerror(errno));
|
||||||
SetLastError(ERROR_IO_DEVICE);
|
CommLog_Print(WLOG_WARN, " coult not read counters.");
|
||||||
|
|
||||||
LeaveCriticalSection(&pComm->EventsLock);
|
if (pComm->permissive)
|
||||||
return FALSE;
|
{
|
||||||
|
/* Errors and events based on counters could not be
|
||||||
|
* detected but keep on.
|
||||||
|
*/
|
||||||
|
ZeroMemory(¤tCounters, sizeof(struct serial_icounter_struct));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_IO_DEVICE);
|
||||||
|
LeaveCriticalSection(&pComm->EventsLock);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NB: preferred below (currentCounters.* != pComm->counters.*) over (currentCounters.* > pComm->counters.*) thinking the counters can loop */
|
/* NB: preferred below (currentCounters.* != pComm->counters.*) over (currentCounters.* > pComm->counters.*) thinking the counters can loop */
|
||||||
|
|
Loading…
Reference in New Issue