winpr-comm: ignore errors on TIOCGICOUNT during the port initialization but the permissive mode must be on afterwards.
This commit is contained in:
parent
8fef94f528
commit
096159054b
@ -175,7 +175,7 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
|
||||
|
||||
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;
|
||||
goto error_handle;
|
||||
|
@ -1373,9 +1373,17 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
|
||||
|
||||
if (ioctl(pComm->fd, TIOCGICOUNT, &(pComm->counters)) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
goto error_handle;
|
||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s.", errno, strerror(errno));
|
||||
CommLog_Print(WLOG_WARN, "could not read counters.");
|
||||
|
||||
/* 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,12 +1042,20 @@ static BOOL _set_wait_mask(WINPR_COMM *pComm, const ULONG *pWaitMask)
|
||||
|
||||
if (ioctl(pComm->fd, TIOCGICOUNT, &(pComm->counters)) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s.", errno, strerror(errno));
|
||||
|
||||
if (pComm->permissive)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
@ -1188,12 +1196,23 @@ static BOOL _get_commstatus(WINPR_COMM *pComm, SERIAL_STATUS *pCommstatus)
|
||||
ZeroMemory(¤tCounters, sizeof(struct serial_icounter_struct));
|
||||
if (ioctl(pComm->fd, TIOCGICOUNT, ¤tCounters) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s.", errno, strerror(errno));
|
||||
CommLog_Print(WLOG_WARN, " coult not read counters.");
|
||||
|
||||
if (pComm->permissive)
|
||||
{
|
||||
/* 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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user