这篇教程C++ CommLog_Print函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CommLog_Print函数的典型用法代码示例。如果您正苦于以下问题:C++ CommLog_Print函数的具体用法?C++ CommLog_Print怎么用?C++ CommLog_Print使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CommLog_Print函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: _set_wait_maskstatic BOOL _set_wait_mask(WINPR_COMM *pComm, const ULONG *pWaitMask){ ULONG possibleMask; /* Stops pending IOCTL_SERIAL_WAIT_ON_MASK * http://msdn.microsoft.com/en-us/library/ff546805%28v=vs.85%29.aspx */ if (pComm->PendingEvents & SERIAL_EV_FREERDP_WAITING) { /* FIXME: any doubt on reading PendingEvents out of a critical section? */ EnterCriticalSection(&pComm->EventsLock); pComm->PendingEvents |= SERIAL_EV_FREERDP_STOP; LeaveCriticalSection(&pComm->EventsLock); /* waiting the end of the pending _wait_on_mask() */ while (pComm->PendingEvents & SERIAL_EV_FREERDP_WAITING) Sleep(10); /* 10ms */ } /* NB: ensure to leave the critical section before to return */ EnterCriticalSection(&pComm->EventsLock); if (*pWaitMask == 0) { /* clearing pending events */ 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); LeaveCriticalSection(&pComm->EventsLock); return FALSE; } pComm->PendingEvents = 0; } possibleMask = *pWaitMask & _SERIAL_SYS_SUPPORTED_EV_MASK; if (possibleMask != *pWaitMask) { CommLog_Print(WLOG_WARN, "Not all wait events supported (Serial.sys), requested events= 0X%lX, possible events= 0X%lX", *pWaitMask, possibleMask); /* FIXME: shall we really set the possibleMask and return FALSE? */ pComm->WaitEventMask = possibleMask; LeaveCriticalSection(&pComm->EventsLock); return FALSE; } pComm->WaitEventMask = possibleMask; LeaveCriticalSection(&pComm->EventsLock); return TRUE;}
开发者ID:10084462,项目名称:FreeRDP,代码行数:59,
示例2: SetupCommBOOL SetupComm(HANDLE hFile, DWORD dwInQueue, DWORD dwOutQueue){ WINPR_COMM* pComm = (WINPR_COMM*) hFile; SERIAL_QUEUE_SIZE queueSize; DWORD bytesReturned = 0; if (!CommInitialized()) return FALSE; if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd ) { SetLastError(ERROR_INVALID_HANDLE); return FALSE; } queueSize.InSize = dwInQueue; queueSize.OutSize = dwOutQueue; if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_QUEUE_SIZE, &queueSize, sizeof(SERIAL_QUEUE_SIZE), NULL, 0, &bytesReturned, NULL)) { CommLog_Print(WLOG_WARN, "SetCommTimeouts failure."); return FALSE; } return TRUE;}
开发者ID:shattars3d,项目名称:FreeRDP-1,代码行数:26,
示例3: _set_queue_sizestatic BOOL _set_queue_size(WINPR_COMM *pComm, const SERIAL_QUEUE_SIZE *pQueueSize){ if ((pQueueSize->InSize <= N_TTY_BUF_SIZE) && (pQueueSize->OutSize <= N_TTY_BUF_SIZE)) return TRUE; /* nothing to do */ /* FIXME: could be implemented on top of N_TTY */ if (pQueueSize->InSize > N_TTY_BUF_SIZE) CommLog_Print(WLOG_WARN, "Requested an incompatible input buffer size: %"PRIu32", keeping on with a %"PRIu32" bytes buffer.", pQueueSize->InSize, N_TTY_BUF_SIZE); if (pQueueSize->OutSize > N_TTY_BUF_SIZE) CommLog_Print(WLOG_WARN, "Requested an incompatible output buffer size: %"PRIu32", keeping on with a %"PRIu32" bytes buffer.", pQueueSize->OutSize, N_TTY_BUF_SIZE); SetLastError(ERROR_CANCELLED); return FALSE;}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:16,
示例4: _get_modemstatusstatic BOOL _get_modemstatus(WINPR_COMM *pComm, ULONG *pRegister){ UINT32 lines=0; if (ioctl(pComm->fd, TIOCMGET, &lines) < 0) { CommLog_Print(WLOG_WARN, "TIOCMGET ioctl failed, errno=[%d] %s", errno, strerror(errno)); SetLastError(ERROR_IO_DEVICE); return FALSE; } ZeroMemory(pRegister, sizeof(ULONG)); /* FIXME: Is the last read of the MSR register available or * cached somewhere? Not quite sure we need to return the 4 * LSBits anyway. A direct access to the register -- which * would reset the register -- is likely not expected from * this function. */ /* #define SERIAL_MSR_DCTS 0x01 */ /* #define SERIAL_MSR_DDSR 0x02 */ /* #define SERIAL_MSR_TERI 0x04 */ /* #define SERIAL_MSR_DDCD 0x08 */ if (lines & TIOCM_CTS) *pRegister |= SERIAL_MSR_CTS; if (lines & TIOCM_DSR) *pRegister |= SERIAL_MSR_DSR; if (lines & TIOCM_RI) *pRegister |= SERIAL_MSR_RI; if (lines & TIOCM_CD) *pRegister |= SERIAL_MSR_DCD; return TRUE;}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:35,
示例5: _get_baud_ratestatic BOOL _get_baud_rate(WINPR_COMM *pComm, SERIAL_BAUD_RATE *pBaudRate){ int i; speed_t currentSpeed; struct termios currentState; ZeroMemory(¤tState, sizeof(struct termios)); if (tcgetattr(pComm->fd, ¤tState) < 0) { SetLastError(ERROR_IO_DEVICE); return FALSE; } currentSpeed = cfgetispeed(¤tState); for (i=0; _BAUD_TABLE[i][0]<_BAUD_TABLE_END; i++) { if (_BAUD_TABLE[i][0] == currentSpeed) { pBaudRate->BaudRate = _BAUD_TABLE[i][1]; return TRUE; } } CommLog_Print(WLOG_WARN, "could not find a matching baud rate for the speed 0x%x", currentSpeed); SetLastError(ERROR_INVALID_DATA); return FALSE;}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:28,
示例6: SetCommTimeouts/** * ERRORS: * ERROR_INVALID_HANDLE */BOOL SetCommTimeouts(HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts){ WINPR_COMM* pComm = (WINPR_COMM*) hFile; DWORD bytesReturned; if (!CommInitialized()) return FALSE; if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd) { SetLastError(ERROR_INVALID_HANDLE); return FALSE; } /* as of today, SERIAL_TIMEOUTS and COMMTIMEOUTS structures are identical */ if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_TIMEOUTS, lpCommTimeouts, sizeof(COMMTIMEOUTS), NULL, 0, &bytesReturned, NULL)) { CommLog_Print(WLOG_WARN, "SetCommTimeouts failure."); return FALSE; } return TRUE;}
开发者ID:JunaidLoonat,项目名称:FreeRDP,代码行数:29,
示例7: SetDefaultCommConfigWBOOL SetDefaultCommConfigW(LPCWSTR lpszName, LPCOMMCONFIG lpCC, DWORD dwSize){ if (!CommInitialized()) return FALSE; /* TODO: not implemented */ CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE;}
开发者ID:JunaidLoonat,项目名称:FreeRDP,代码行数:10,
示例8: CommConfigDialogWBOOL CommConfigDialogW(LPCWSTR lpszName, HWND hWnd, LPCOMMCONFIG lpCC){ if (!CommInitialized()) return FALSE; /* TODO: not implemented */ CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE;}
开发者ID:JunaidLoonat,项目名称:FreeRDP,代码行数:10,
示例9: BuildCommDCBWBOOL BuildCommDCBW(LPCWSTR lpDef, LPDCB lpDCB){ if (!CommInitialized()) return FALSE; /* TODO: not implemented */ CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE;}
开发者ID:JunaidLoonat,项目名称:FreeRDP,代码行数:10,
示例10: _set_xonstatic BOOL _set_xon(WINPR_COMM *pComm){ if (tcflow(pComm->fd, TCION) < 0) { CommLog_Print(WLOG_WARN, "TCION failure, errno=[%d] %s", errno, strerror(errno)); SetLastError(ERROR_IO_DEVICE); return FALSE; } return TRUE;}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:11,
示例11: _set_break_offstatic BOOL _set_break_off(WINPR_COMM *pComm){ if (ioctl(pComm->fd, TIOCCBRK, NULL) < 0) { CommLog_Print(WLOG_WARN, "TIOCSBRK ioctl failed, errno=[%d] %s", errno, strerror(errno)); SetLastError(ERROR_IO_DEVICE); return FALSE; } return TRUE;}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:11,
示例12: _clear_linesstatic BOOL _clear_lines(WINPR_COMM *pComm, UINT32 lines){ if (ioctl(pComm->fd, TIOCMBIC, &lines) < 0) { CommLog_Print(WLOG_WARN, "TIOCMBIC ioctl failed, lines=0x%"PRIX32", errno=[%d] %s", lines, errno, strerror(errno)); SetLastError(ERROR_IO_DEVICE); return FALSE; } return TRUE;}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:11,
示例13: BuildCommDCBAndTimeoutsABOOL BuildCommDCBAndTimeoutsA(LPCSTR lpDef, LPDCB lpDCB, LPCOMMTIMEOUTS lpCommTimeouts){ if (!CommInitialized()) return FALSE; /* TODO: not implemented */ CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE;}
开发者ID:JunaidLoonat,项目名称:FreeRDP,代码行数:11,
示例14: _set_timeoutsstatic BOOL _set_timeouts(WINPR_COMM *pComm, const SERIAL_TIMEOUTS *pTimeouts){ /* NB: timeouts are applied on system during read/write I/O */ /* http://msdn.microsoft.com/en-us/library/windows/hardware/hh439614%28v=vs.85%29.aspx */ if ((pTimeouts->ReadIntervalTimeout == MAXULONG) && (pTimeouts->ReadTotalTimeoutConstant == MAXULONG)) { CommLog_Print(WLOG_WARN, "ReadIntervalTimeout and ReadTotalTimeoutConstant cannot be both set to MAXULONG"); SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } pComm->timeouts.ReadIntervalTimeout = pTimeouts->ReadIntervalTimeout; pComm->timeouts.ReadTotalTimeoutMultiplier = pTimeouts->ReadTotalTimeoutMultiplier; pComm->timeouts.ReadTotalTimeoutConstant = pTimeouts->ReadTotalTimeoutConstant; pComm->timeouts.WriteTotalTimeoutMultiplier = pTimeouts->WriteTotalTimeoutMultiplier; pComm->timeouts.WriteTotalTimeoutConstant = pTimeouts->WriteTotalTimeoutConstant; CommLog_Print(WLOG_DEBUG, "ReadIntervalTimeout %"PRIu32"", pComm->timeouts.ReadIntervalTimeout); CommLog_Print(WLOG_DEBUG, "ReadTotalTimeoutMultiplier %"PRIu32"", pComm->timeouts.ReadTotalTimeoutMultiplier); CommLog_Print(WLOG_DEBUG, "ReadTotalTimeoutConstant %"PRIu32"", pComm->timeouts.ReadTotalTimeoutConstant); CommLog_Print(WLOG_DEBUG, "WriteTotalTimeoutMultiplier %"PRIu32"", pComm->timeouts.WriteTotalTimeoutMultiplier); CommLog_Print(WLOG_DEBUG, "WriteTotalTimeoutConstant %"PRIu32"", pComm->timeouts.WriteTotalTimeoutConstant); return TRUE;}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:26,
示例15: _set_baud_ratestatic BOOL _set_baud_rate(WINPR_COMM *pComm, const SERIAL_BAUD_RATE *pBaudRate){ int i; speed_t newSpeed; struct termios futureState; ZeroMemory(&futureState, sizeof(struct termios)); if (tcgetattr(pComm->fd, &futureState) < 0) /* NB: preserves current settings not directly handled by the Communication Functions */ { SetLastError(ERROR_IO_DEVICE); return FALSE; } for (i=0; _BAUD_TABLE[i][0]<_BAUD_TABLE_END; i++) { if (_BAUD_TABLE[i][1] == pBaudRate->BaudRate) { newSpeed = _BAUD_TABLE[i][0]; if (cfsetspeed(&futureState, newSpeed) < 0) { CommLog_Print(WLOG_WARN, "failed to set speed 0x%x (%"PRIu32")", newSpeed, pBaudRate->BaudRate); return FALSE; } assert(cfgetispeed(&futureState) == newSpeed); if (_comm_ioctl_tcsetattr(pComm->fd, TCSANOW, &futureState) < 0) { CommLog_Print(WLOG_WARN, "_comm_ioctl_tcsetattr failure: last-error: 0x%"PRIX32"", GetLastError()); return FALSE; } return TRUE; } } CommLog_Print(WLOG_WARN, "could not find a matching speed for the baud rate %"PRIu32"", pBaudRate->BaudRate); SetLastError(ERROR_INVALID_DATA); return FALSE;}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:40,
示例16: _set_baud_ratestatic BOOL _set_baud_rate(WINPR_COMM *pComm, const SERIAL_BAUD_RATE *pBaudRate){ int i; speed_t newSpeed; struct termios upcomingTermios; ZeroMemory(&upcomingTermios, sizeof(struct termios)); if (tcgetattr(pComm->fd, &upcomingTermios) < 0) { SetLastError(ERROR_IO_DEVICE); return FALSE; } for (i=0; _SERIAL_SYS_BAUD_TABLE[i][0]<=_SERIAL_MAX_BAUD; i++) { if (_SERIAL_SYS_BAUD_TABLE[i][1] == pBaudRate->BaudRate) { newSpeed = _SERIAL_SYS_BAUD_TABLE[i][0]; if (cfsetspeed(&upcomingTermios, newSpeed) < 0) { CommLog_Print(WLOG_WARN, "failed to set speed %u (%lu)", newSpeed, pBaudRate->BaudRate); return FALSE; } if (_comm_ioctl_tcsetattr(pComm->fd, TCSANOW, &upcomingTermios) < 0) { CommLog_Print(WLOG_WARN, "_comm_ioctl_tcsetattr failure: last-error: 0x%lX", GetLastError()); return FALSE; } return TRUE; } } CommLog_Print(WLOG_WARN, "could not find a matching speed for the baud rate %lu", pBaudRate->BaudRate); SetLastError(ERROR_INVALID_DATA); return FALSE;}
开发者ID:10084462,项目名称:FreeRDP,代码行数:38,
示例17: CommCloseHandleBOOL CommCloseHandle(HANDLE handle){ WINPR_COMM *pComm; if (!CommInitialized()) return FALSE; pComm = (WINPR_COMM*)handle; if (!pComm || pComm->Type != HANDLE_TYPE_COMM) { SetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (pComm->PendingEvents & SERIAL_EV_FREERDP_WAITING) { ULONG WaitMask = 0; DWORD BytesReturned = 0; /* ensures to gracefully stop the WAIT_ON_MASK's loop */ if (!CommDeviceIoControl(handle, IOCTL_SERIAL_SET_WAIT_MASK, &WaitMask, sizeof(ULONG), NULL, 0, &BytesReturned, NULL)) { CommLog_Print(WLOG_WARN, "failure to WAIT_ON_MASK's loop!"); } } DeleteCriticalSection(&pComm->ReadLock); DeleteCriticalSection(&pComm->WriteLock); DeleteCriticalSection(&pComm->EventsLock); if (pComm->fd > 0) close(pComm->fd); if (pComm->fd_write > 0) close(pComm->fd_write); if (pComm->fd_write_event > 0) close(pComm->fd_write_event); if (pComm->fd_read > 0) close(pComm->fd_read); if (pComm->fd_read_event > 0) close(pComm->fd_read_event); free(pComm); return TRUE;}
开发者ID:shattars3d,项目名称:FreeRDP-1,代码行数:50,
示例18: WaitCommEventBOOL WaitCommEvent(HANDLE hFile, PDWORD lpEvtMask, LPOVERLAPPED lpOverlapped){ WINPR_COMM* pComm = (WINPR_COMM*) hFile; if (!CommInitialized()) return FALSE; /* TODO: not implemented */ if (!pComm) return FALSE; CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE;}
开发者ID:JunaidLoonat,项目名称:FreeRDP,代码行数:16,
示例19: SetCommConfigBOOL SetCommConfig(HANDLE hCommDev, LPCOMMCONFIG lpCC, DWORD dwSize){ WINPR_COMM* pComm = (WINPR_COMM*) hCommDev; if (!CommInitialized()) return FALSE; /* TODO: not implemented */ if (!pComm) return FALSE; CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE;}
开发者ID:JunaidLoonat,项目名称:FreeRDP,代码行数:16,
示例20: ClearCommErrorBOOL ClearCommError(HANDLE hFile, PDWORD lpErrors, LPCOMSTAT lpStat){ WINPR_COMM* pComm = (WINPR_COMM*) hFile; if (!CommInitialized()) return FALSE; /* TODO: not implemented */ if (!pComm) return FALSE; CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE;}
开发者ID:JunaidLoonat,项目名称:FreeRDP,代码行数:16,
示例21: EscapeCommFunctionBOOL EscapeCommFunction(HANDLE hFile, DWORD dwFunc){ WINPR_COMM* pComm = (WINPR_COMM*) hFile; if (!CommInitialized()) return FALSE; /* TODO: not implemented */ if (!pComm) return FALSE; CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE;}
开发者ID:JunaidLoonat,项目名称:FreeRDP,代码行数:16,
示例22: TransmitCommCharBOOL TransmitCommChar(HANDLE hFile, char cChar){ WINPR_COMM* pComm = (WINPR_COMM*) hFile; if (!CommInitialized()) return FALSE; /* TODO: not implemented */ if (!pComm) return FALSE; CommLog_Print(WLOG_ERROR, "%s: Not implemented", __FUNCTION__); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE;}
开发者ID:JunaidLoonat,项目名称:FreeRDP,代码行数:16,
示例23: _comm_setServerSerialDriver/** * Sets */void _comm_setServerSerialDriver(HANDLE hComm, SERIAL_DRIVER_ID driverId){ ULONG Type; PVOID Object; WINPR_COMM* pComm; if (!CommInitialized()) return; if (!winpr_Handle_GetInfo(hComm, &Type, &Object)) { CommLog_Print(WLOG_WARN, "_comm_setServerSerialDriver failure"); return; } pComm = (WINPR_COMM*)Object; pComm->serverSerialDriverId = driverId;}
开发者ID:shattars3d,项目名称:FreeRDP-1,代码行数:21,
示例24: _get_dtrrtsBOOL _get_dtrrts(WINPR_COMM *pComm, ULONG *pMask){ UINT32 lines=0; if (ioctl(pComm->fd, TIOCMGET, &lines) < 0) { CommLog_Print(WLOG_WARN, "TIOCMGET ioctl failed, errno=[%d] %s", errno, strerror(errno)); SetLastError(ERROR_IO_DEVICE); return FALSE; } *pMask = 0; if (!(lines & TIOCM_DTR)) *pMask |= SERIAL_DTR_STATE; if (!(lines & TIOCM_RTS)) *pMask |= SERIAL_RTS_STATE; return TRUE;}
开发者ID:FreeRDP,项目名称:FreeRDP,代码行数:19,
示例25: GetCommProperties/** * ERRORS: * ERROR_DLL_INIT_FAILED * ERROR_INVALID_HANDLE */BOOL GetCommProperties(HANDLE hFile, LPCOMMPROP lpCommProp){ WINPR_COMM* pComm = (WINPR_COMM*) hFile; DWORD bytesReturned; if (!CommInitialized()) return FALSE; if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd ) { SetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_PROPERTIES, NULL, 0, lpCommProp, sizeof(COMMPROP), &bytesReturned, NULL)) { CommLog_Print(WLOG_WARN, "GetCommProperties failure."); return FALSE; } return TRUE;}
开发者ID:shattars3d,项目名称:FreeRDP-1,代码行数:27,
示例26: PurgeCommBOOL PurgeComm(HANDLE hFile, DWORD dwFlags){ WINPR_COMM* pComm = (WINPR_COMM*) hFile; DWORD bytesReturned = 0; if (!CommInitialized()) return FALSE; if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd ) { SetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_PURGE, &dwFlags, sizeof(DWORD), NULL, 0, &bytesReturned, NULL)) { CommLog_Print(WLOG_WARN, "PurgeComm failure."); return FALSE; } return TRUE;}
开发者ID:shattars3d,项目名称:FreeRDP-1,代码行数:22,
示例27: CommReadFile/** * ERRORS: * ERROR_INVALID_HANDLE * ERROR_NOT_SUPPORTED * ERROR_INVALID_PARAMETER * ERROR_TIMEOUT * ERROR_IO_DEVICE * ERROR_BAD_DEVICE */BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped){ WINPR_COMM* pComm = (WINPR_COMM*) hDevice; int biggestFd = -1; fd_set read_set; int nbFds; COMMTIMEOUTS *pTimeouts; UCHAR vmin = 0; UCHAR vtime = 0; ULONGLONG Tmax = 0; struct timeval tmaxTimeout, *pTmaxTimeout; struct termios currentTermios; EnterCriticalSection(&pComm->ReadLock); /* KISSer by the function's beginning */ if (hDevice == INVALID_HANDLE_VALUE) { SetLastError(ERROR_INVALID_HANDLE); goto return_false; } if (!pComm || pComm->Type != HANDLE_TYPE_COMM) { SetLastError(ERROR_INVALID_HANDLE); goto return_false; } if (lpOverlapped != NULL) { SetLastError(ERROR_NOT_SUPPORTED); goto return_false; } if (lpNumberOfBytesRead == NULL) { SetLastError(ERROR_INVALID_PARAMETER); /* since we doesn't suppport lpOverlapped != NULL */ goto return_false; } *lpNumberOfBytesRead = 0; /* will be ajusted if required ... */ if (nNumberOfBytesToRead <= 0) /* N */ { goto return_true; /* FIXME: or FALSE? */ } if (tcgetattr(pComm->fd, ¤tTermios) < 0) { SetLastError(ERROR_IO_DEVICE); goto return_false; } if (currentTermios.c_lflag & ICANON) { CommLog_Print(WLOG_WARN, "Canonical mode not supported"); /* the timeout could not be set */ SetLastError(ERROR_NOT_SUPPORTED); goto return_false; } /* http://msdn.microsoft.com/en-us/library/hh439614%28v=vs.85%29.aspx * http://msdn.microsoft.com/en-us/library/windows/hardware/hh439614%28v=vs.85%29.aspx * * ReadIntervalTimeout | ReadTotalTimeoutMultiplier | ReadTotalTimeoutConstant | VMIN | VTIME | TMAX | * 0 | 0 | 0 | N | 0 | INDEF | Blocks for N bytes available. * 0< Ti <MAXULONG | 0 | 0 | N | Ti | INDEF | Blocks on first byte, then use Ti between bytes. * MAXULONG | 0 | 0 | 0 | 0 | 0 | Returns immediately with bytes available (don't block) * MAXULONG | MAXULONG | 0< Tc <MAXULONG | N | 0 | Tc | Blocks on first byte during Tc or returns immediately whith bytes available * MAXULONG | m | MAXULONG | | Invalid * 0 | m | 0< Tc <MAXULONG | N | 0 | Tmax | Blocks on first byte during Tmax or returns immediately whith bytes available * 0< Ti <MAXULONG | m | 0< Tc <MAXULONG | N | Ti | Tmax | Blocks on first byte, then use Ti between bytes. Tmax is used for the whole system call. */ /* NB: timeouts are in milliseconds, VTIME are in deciseconds and is an unsigned char */ /* FIXME: double check whether open(pComm->fd_read_event, O_NONBLOCK) doesn't conflict with above use cases */ pTimeouts = &(pComm->timeouts); if ((pTimeouts->ReadIntervalTimeout == MAXULONG) && (pTimeouts->ReadTotalTimeoutConstant == MAXULONG)) { CommLog_Print(WLOG_WARN, "ReadIntervalTimeout and ReadTotalTimeoutConstant cannot be both set to MAXULONG"); SetLastError(ERROR_INVALID_PARAMETER); goto return_false; } /* VMIN */ if ((pTimeouts->ReadIntervalTimeout == MAXULONG) && (pTimeouts->ReadTotalTimeoutMultiplier == 0) && (pTimeouts->ReadTotalTimeoutConstant == 0)) { vmin = 0;//.........这里部分代码省略.........
开发者ID:AMV007,项目名称:FreeRDP,代码行数:101,
示例28: CommWriteFile/** * ERRORS: * ERROR_INVALID_HANDLE * ERROR_NOT_SUPPORTED * ERROR_INVALID_PARAMETER * ERROR_BAD_DEVICE */BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped){ WINPR_COMM* pComm = (WINPR_COMM*) hDevice; struct timeval tmaxTimeout, *pTmaxTimeout; EnterCriticalSection(&pComm->WriteLock); /* KISSer by the function's beginning */ if (hDevice == INVALID_HANDLE_VALUE) { SetLastError(ERROR_INVALID_HANDLE); goto return_false; } if (!pComm || pComm->Type != HANDLE_TYPE_COMM) { SetLastError(ERROR_INVALID_HANDLE); goto return_false; } if (lpOverlapped != NULL) { SetLastError(ERROR_NOT_SUPPORTED); goto return_false; } if (lpNumberOfBytesWritten == NULL) { SetLastError(ERROR_INVALID_PARAMETER); /* since we doesn't suppport lpOverlapped != NULL */ goto return_false; } *lpNumberOfBytesWritten = 0; /* will be ajusted if required ... */ if (nNumberOfBytesToWrite <= 0) { goto return_true; /* FIXME: or FALSE? */ } /* FIXME: had expected eventfd_write() to return EAGAIN when * there is no eventfd_read() but this not the case. */ /* discard a possible and no more relevant event */ eventfd_read(pComm->fd_write_event, NULL); /* ms */ ULONGLONG Tmax = nNumberOfBytesToWrite * pComm->timeouts.WriteTotalTimeoutMultiplier + pComm->timeouts.WriteTotalTimeoutConstant; /* NB: select() may update the timeout argument to indicate * how much time was left. Keep the timeout variable out of * the while() */ pTmaxTimeout = &tmaxTimeout; ZeroMemory(pTmaxTimeout, sizeof(struct timeval)); if (Tmax > 0) { pTmaxTimeout->tv_sec = Tmax / 1000; /* s */ pTmaxTimeout->tv_usec = (Tmax % 1000) * 1000; /* us */ } else if ((pComm->timeouts.WriteTotalTimeoutMultiplier == 0) && (pComm->timeouts.WriteTotalTimeoutConstant == 0)) { pTmaxTimeout = NULL; } /* else return immdiately */ while (*lpNumberOfBytesWritten < nNumberOfBytesToWrite) { int biggestFd = -1; fd_set event_set, write_set; int nbFds; biggestFd = pComm->fd_write; if (pComm->fd_write_event > biggestFd) biggestFd = pComm->fd_write_event; FD_ZERO(&event_set); FD_ZERO(&write_set); assert(pComm->fd_write_event < FD_SETSIZE); assert(pComm->fd_write < FD_SETSIZE); FD_SET(pComm->fd_write_event, &event_set); FD_SET(pComm->fd_write, &write_set); nbFds = select(biggestFd+1, &event_set, &write_set, NULL, pTmaxTimeout); if (nbFds < 0) { CommLog_Print(WLOG_WARN, "select() failure, errno=[%d] %s/n", errno, strerror(errno)); SetLastError(ERROR_IO_DEVICE); goto return_false; } if (nbFds == 0)//.........这里部分代码省略.........
开发者ID:AMV007,项目名称:FreeRDP,代码行数:101,
示例29: SetCommState/** * @return TRUE on success, FALSE otherwise. * * As of today, SetCommState() can fail half-way with some settings * applied and some others not. SetCommState() returns on the first * failure met. FIXME: or is it correct? * * ERRORS: * ERROR_INVALID_HANDLE * ERROR_IO_DEVICE */BOOL SetCommState(HANDLE hFile, LPDCB lpDCB){ struct termios upcomingTermios; WINPR_COMM* pComm = (WINPR_COMM*) hFile; DWORD bytesReturned; /* FIXME: validate changes according GetCommProperties? */ if (!CommInitialized()) return FALSE; if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd ) { SetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (!lpDCB) { SetLastError(ERROR_INVALID_DATA); return FALSE; } /* NB: did the choice to call ioctls first when available and then to setup upcomingTermios. Don't mix both stages. */ /** ioctl calls stage **/ SERIAL_BAUD_RATE baudRate; baudRate.BaudRate = lpDCB->BaudRate; if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_BAUD_RATE, &baudRate, sizeof(SERIAL_BAUD_RATE), NULL, 0, &bytesReturned, NULL)) { CommLog_Print(WLOG_WARN, "SetCommState failure: could not set the baud rate."); return FALSE; } SERIAL_CHARS serialChars; if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_CHARS, NULL, 0, &serialChars, sizeof(SERIAL_CHARS), &bytesReturned, NULL)) /* as of today, required for BreakChar */ { CommLog_Print(WLOG_WARN, "SetCommState failure: could not get the initial serial chars."); return FALSE; } serialChars.XonChar = lpDCB->XonChar; serialChars.XoffChar = lpDCB->XoffChar; serialChars.ErrorChar = lpDCB->ErrorChar; serialChars.EofChar = lpDCB->EofChar; serialChars.EventChar = lpDCB->EvtChar; if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_CHARS, &serialChars, sizeof(SERIAL_CHARS), NULL, 0, &bytesReturned, NULL)) { CommLog_Print(WLOG_WARN, "SetCommState failure: could not set the serial chars."); return FALSE; } SERIAL_LINE_CONTROL lineControl; lineControl.StopBits = lpDCB->StopBits; lineControl.Parity = lpDCB->Parity; lineControl.WordLength = lpDCB->ByteSize; if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_LINE_CONTROL, &lineControl, sizeof(SERIAL_LINE_CONTROL), NULL, 0, &bytesReturned, NULL)) { CommLog_Print(WLOG_WARN, "SetCommState failure: could not set the control settings."); return FALSE; } SERIAL_HANDFLOW handflow; ZeroMemory(&handflow, sizeof(SERIAL_HANDFLOW)); if (lpDCB->fOutxCtsFlow) { handflow.ControlHandShake |= SERIAL_CTS_HANDSHAKE; } if (lpDCB->fOutxDsrFlow) { handflow.ControlHandShake |= SERIAL_DSR_HANDSHAKE; } switch (lpDCB->fDtrControl) { case SERIAL_DTR_HANDSHAKE: handflow.ControlHandShake |= DTR_CONTROL_HANDSHAKE; break; case SERIAL_DTR_CONTROL: handflow.ControlHandShake |= DTR_CONTROL_ENABLE; break; case DTR_CONTROL_DISABLE://.........这里部分代码省略.........
开发者ID:shattars3d,项目名称:FreeRDP-1,代码行数:101,
示例30: GetCommState/** * * * ERRORS: * ERROR_INVALID_HANDLE * ERROR_INVALID_DATA * ERROR_IO_DEVICE * ERROR_OUTOFMEMORY */BOOL GetCommState(HANDLE hFile, LPDCB lpDCB){ DCB *lpLocalDcb; struct termios currentState; WINPR_COMM* pComm = (WINPR_COMM*) hFile; DWORD bytesReturned; if (!CommInitialized()) return FALSE; if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd ) { SetLastError(ERROR_INVALID_HANDLE); return FALSE; } if (!lpDCB) { SetLastError(ERROR_INVALID_DATA); return FALSE; } if (lpDCB->DCBlength < sizeof(DCB)) { SetLastError(ERROR_INVALID_DATA); return FALSE; } if (tcgetattr(pComm->fd, ¤tState) < 0) { SetLastError(ERROR_IO_DEVICE); return FALSE; } lpLocalDcb = (DCB*)calloc(1, lpDCB->DCBlength); if (lpLocalDcb == NULL) { SetLastError(ERROR_OUTOFMEMORY); return FALSE; } /* error_handle */ lpLocalDcb->DCBlength = lpDCB->DCBlength; SERIAL_BAUD_RATE baudRate; if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_BAUD_RATE, NULL, 0, &baudRate, sizeof(SERIAL_BAUD_RATE), &bytesReturned, NULL)) { CommLog_Print(WLOG_WARN, "GetCommState failure: could not get the baud rate."); goto error_handle; } lpLocalDcb->BaudRate = baudRate.BaudRate; lpLocalDcb->fBinary = (currentState.c_cflag & ICANON) == 0; if (!lpLocalDcb->fBinary) { CommLog_Print(WLOG_WARN, "Unexpected nonbinary mode, consider to unset the ICANON flag."); } lpLocalDcb->fParity = (currentState.c_iflag & INPCK) != 0; SERIAL_HANDFLOW handflow; if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_HANDFLOW, NULL, 0, &handflow, sizeof(SERIAL_HANDFLOW), &bytesReturned, NULL)) { CommLog_Print(WLOG_WARN, "GetCommState failure: could not get the handflow settings."); goto error_handle; } lpLocalDcb->fOutxCtsFlow = (handflow.ControlHandShake & SERIAL_CTS_HANDSHAKE) != 0; lpLocalDcb->fOutxDsrFlow = (handflow.ControlHandShake & SERIAL_DSR_HANDSHAKE) != 0; if (handflow.ControlHandShake & SERIAL_DTR_HANDSHAKE) { lpLocalDcb->fDtrControl = DTR_CONTROL_HANDSHAKE; } else if (handflow.ControlHandShake & SERIAL_DTR_CONTROL) { lpLocalDcb->fDtrControl = DTR_CONTROL_ENABLE; } else { lpLocalDcb->fDtrControl = DTR_CONTROL_DISABLE; } lpLocalDcb->fDsrSensitivity = (handflow.ControlHandShake & SERIAL_DSR_SENSITIVITY) != 0; lpLocalDcb->fTXContinueOnXoff = (handflow.FlowReplace & SERIAL_XOFF_CONTINUE) != 0; lpLocalDcb->fOutX = (handflow.FlowReplace & SERIAL_AUTO_TRANSMIT) != 0;//.........这里部分代码省略.........
开发者ID:shattars3d,项目名称:FreeRDP-1,代码行数:101,
注:本文中的CommLog_Print函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CommandCost函数代码示例 C++ CommDlgExtendedError函数代码示例 |