FreeRDP
|
#include <winpr/config.h>
#include <winpr/assert.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdarg.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include <winpr/crt.h>
#include <winpr/comm.h>
#include <winpr/tchar.h>
#include <winpr/wlog.h>
#include <winpr/handle.h>
#include "comm_ioctl.h"
#include "../log.h"
#include "comm.h"
Macros | |
#define | TAG WINPR_TAG("comm") |
#define | COMM_DEVICE_MAX 128 |
Functions | |
static int | CommGetFd (HANDLE handle) |
HANDLE_CREATOR * | GetCommHandleCreator (void) |
static void | CommInit (void) |
static BOOL | CommInitialized (void) |
void | CommLog_Print (DWORD level,...) |
BOOL | BuildCommDCBA (LPCSTR lpDef, LPDCB lpDCB) |
BOOL | BuildCommDCBW (LPCWSTR lpDef, LPDCB lpDCB) |
BOOL | BuildCommDCBAndTimeoutsA (LPCSTR lpDef, LPDCB lpDCB, LPCOMMTIMEOUTS lpCommTimeouts) |
BOOL | BuildCommDCBAndTimeoutsW (LPCWSTR lpDef, LPDCB lpDCB, LPCOMMTIMEOUTS lpCommTimeouts) |
BOOL | CommConfigDialogA (LPCSTR lpszName, HWND hWnd, LPCOMMCONFIG lpCC) |
BOOL | CommConfigDialogW (LPCWSTR lpszName, HWND hWnd, LPCOMMCONFIG lpCC) |
BOOL | GetCommConfig (HANDLE hCommDev, LPCOMMCONFIG lpCC, LPDWORD lpdwSize) |
BOOL | SetCommConfig (HANDLE hCommDev, LPCOMMCONFIG lpCC, DWORD dwSize) |
BOOL | GetCommMask (HANDLE hFile, PDWORD lpEvtMask) |
BOOL | SetCommMask (HANDLE hFile, DWORD dwEvtMask) |
BOOL | GetCommModemStatus (HANDLE hFile, PDWORD lpModemStat) |
BOOL | GetCommProperties (HANDLE hFile, LPCOMMPROP lpCommProp) |
BOOL | GetCommState (HANDLE hFile, LPDCB lpDCB) |
BOOL | SetCommState (HANDLE hFile, LPDCB lpDCB) |
BOOL | GetCommTimeouts (HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts) |
BOOL | SetCommTimeouts (HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts) |
BOOL | GetDefaultCommConfigA (LPCSTR lpszName, LPCOMMCONFIG lpCC, LPDWORD lpdwSize) |
BOOL | GetDefaultCommConfigW (LPCWSTR lpszName, LPCOMMCONFIG lpCC, LPDWORD lpdwSize) |
BOOL | SetDefaultCommConfigA (LPCSTR lpszName, LPCOMMCONFIG lpCC, DWORD dwSize) |
BOOL | SetDefaultCommConfigW (LPCWSTR lpszName, LPCOMMCONFIG lpCC, DWORD dwSize) |
BOOL | SetCommBreak (HANDLE hFile) |
BOOL | ClearCommBreak (HANDLE hFile) |
BOOL | ClearCommError (HANDLE hFile, PDWORD lpErrors, LPCOMSTAT lpStat) |
BOOL | PurgeComm (HANDLE hFile, DWORD dwFlags) |
BOOL | SetupComm (HANDLE hFile, DWORD dwInQueue, DWORD dwOutQueue) |
BOOL | EscapeCommFunction (HANDLE hFile, DWORD dwFunc) |
BOOL | TransmitCommChar (HANDLE hFile, char cChar) |
BOOL | WaitCommEvent (HANDLE hFile, PDWORD lpEvtMask, LPOVERLAPPED lpOverlapped) |
BOOL | DefineCommDevice (LPCTSTR lpDeviceName, LPCTSTR lpTargetPath) |
DWORD | QueryCommDevice (LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax) |
BOOL | IsCommDevice (LPCTSTR lpDeviceName) |
void | _comm_setServerSerialDriver (HANDLE hComm, SERIAL_DRIVER_ID driverId) |
HANDLE | CommCreateFileA (LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) |
BOOL | CommIsHandled (HANDLE handle) |
BOOL | CommIsHandleValid (HANDLE handle) |
BOOL | CommCloseHandle (HANDLE handle) |
Variables | |
static wLog * | sLog = NULL |
static COMM_DEVICE ** | sCommDevices = NULL |
static CRITICAL_SECTION | sCommDevicesLock |
static HANDLE_CREATOR | sCommHandleCreator = { 0 } |
static pthread_once_t | sCommInitialized = PTHREAD_ONCE_INIT |
static HANDLE_OPS | ops |
#define COMM_DEVICE_MAX 128 |
#define TAG WINPR_TAG("comm") |
WinPR: Windows Portable Runtime Serial Communication API
Copyright 2011 O.S. Systems Software Ltda. Copyright 2011 Eduardo Fiss Beloni belon Copyright 2014 Marc-Andre Moreau i@os syste ms.c om.brmarca Copyright 2014 Hewlett-Packard Development Company, L.P. ndre .more au@g mail. com
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
void _comm_setServerSerialDriver | ( | HANDLE | hComm, |
SERIAL_DRIVER_ID | driverId | ||
) |
Sets
BOOL BuildCommDCBA | ( | LPCSTR | lpDef, |
LPDCB | lpDCB | ||
) |
BOOL BuildCommDCBAndTimeoutsA | ( | LPCSTR | lpDef, |
LPDCB | lpDCB, | ||
LPCOMMTIMEOUTS | lpCommTimeouts | ||
) |
BOOL BuildCommDCBAndTimeoutsW | ( | LPCWSTR | lpDef, |
LPDCB | lpDCB, | ||
LPCOMMTIMEOUTS | lpCommTimeouts | ||
) |
BOOL BuildCommDCBW | ( | LPCWSTR | lpDef, |
LPDCB | lpDCB | ||
) |
BOOL ClearCommBreak | ( | HANDLE | hFile | ) |
BOOL ClearCommError | ( | HANDLE | hFile, |
PDWORD | lpErrors, | ||
LPCOMSTAT | lpStat | ||
) |
BOOL CommCloseHandle | ( | HANDLE | handle | ) |
BOOL CommConfigDialogA | ( | LPCSTR | lpszName, |
HWND | hWnd, | ||
LPCOMMCONFIG | lpCC | ||
) |
BOOL CommConfigDialogW | ( | LPCWSTR | lpszName, |
HWND | hWnd, | ||
LPCOMMCONFIG | lpCC | ||
) |
HANDLE CommCreateFileA | ( | LPCSTR | lpDeviceName, |
DWORD | dwDesiredAccess, | ||
DWORD | dwShareMode, | ||
LPSECURITY_ATTRIBUTES | lpSecurityAttributes, | ||
DWORD | dwCreationDisposition, | ||
DWORD | dwFlagsAndAttributes, | ||
HANDLE | hTemplateFile | ||
) |
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363198%28v=vs.85%29.aspx
lpDeviceName | e.g. COM1, ... |
dwDesiredAccess | expects GENERIC_READ | GENERIC_WRITE, a warning message is printed otherwise. TODO: better support. |
dwShareMode | must be zero, INVALID_HANDLE_VALUE is returned otherwise and GetLastError() should return ERROR_SHARING_VIOLATION. |
lpSecurityAttributes | NULL expected, a warning message is printed otherwise. TODO: better support. |
dwCreationDisposition | must be OPEN_EXISTING. If the communication device doesn't exist INVALID_HANDLE_VALUE is returned and GetLastError() returns ERROR_FILE_NOT_FOUND. |
dwFlagsAndAttributes | zero expected, a warning message is printed otherwise. |
hTemplateFile | must be NULL. |
|
static |
|
static |
|
static |
Returns TRUE when the comm module is correctly intialized, FALSE otherwise with ERROR_DLL_INIT_FAILED set as the last error.
BOOL CommIsHandled | ( | HANDLE | handle | ) |
BOOL CommIsHandleValid | ( | HANDLE | handle | ) |
void CommLog_Print | ( | DWORD | level, |
... | |||
) |
BOOL DefineCommDevice | ( | LPCTSTR | lpDeviceName, |
LPCTSTR | lpTargetPath | ||
) |
Returns TRUE on success, FALSE otherwise. To get extended error information, call GetLastError.
ERRORS: ERROR_DLL_INIT_FAILED ERROR_OUTOFMEMORY was not possible to get mappings. ERROR_INVALID_DATA was not possible to add the device.
BOOL EscapeCommFunction | ( | HANDLE | hFile, |
DWORD | dwFunc | ||
) |
BOOL GetCommConfig | ( | HANDLE | hCommDev, |
LPCOMMCONFIG | lpCC, | ||
LPDWORD | lpdwSize | ||
) |
HANDLE_CREATOR* GetCommHandleCreator | ( | void | ) |
BOOL GetCommMask | ( | HANDLE | hFile, |
PDWORD | lpEvtMask | ||
) |
BOOL GetCommModemStatus | ( | HANDLE | hFile, |
PDWORD | lpModemStat | ||
) |
BOOL GetCommProperties | ( | HANDLE | hFile, |
LPCOMMPROP | lpCommProp | ||
) |
ERRORS: ERROR_DLL_INIT_FAILED ERROR_INVALID_HANDLE
BOOL GetCommState | ( | HANDLE | hFile, |
LPDCB | lpDCB | ||
) |
ERRORS: ERROR_INVALID_HANDLE ERROR_INVALID_DATA ERROR_IO_DEVICE ERROR_OUTOFMEMORY
BOOL GetCommTimeouts | ( | HANDLE | hFile, |
LPCOMMTIMEOUTS | lpCommTimeouts | ||
) |
ERRORS: ERROR_INVALID_HANDLE
BOOL GetDefaultCommConfigA | ( | LPCSTR | lpszName, |
LPCOMMCONFIG | lpCC, | ||
LPDWORD | lpdwSize | ||
) |
BOOL GetDefaultCommConfigW | ( | LPCWSTR | lpszName, |
LPCOMMCONFIG | lpCC, | ||
LPDWORD | lpdwSize | ||
) |
BOOL IsCommDevice | ( | LPCTSTR | lpDeviceName | ) |
Checks whether lpDeviceName is a valid and registered Communication device.
BOOL PurgeComm | ( | HANDLE | hFile, |
DWORD | dwFlags | ||
) |
DWORD QueryCommDevice | ( | LPCTSTR | lpDeviceName, |
LPTSTR | lpTargetPath, | ||
DWORD | ucchMax | ||
) |
Returns the number of target paths in the buffer pointed to by lpTargetPath.
The current implementation returns in any case 0 and 1 target path. A NULL lpDeviceName is not supported yet to get all the paths.
ERRORS: ERROR_SUCCESS ERROR_DLL_INIT_FAILED ERROR_OUTOFMEMORY was not possible to get mappings. ERROR_NOT_SUPPORTED equivalent QueryDosDevice feature not supported. ERROR_INVALID_DATA was not possible to retrieve any device information. ERROR_INSUFFICIENT_BUFFER too small lpTargetPath
BOOL SetCommBreak | ( | HANDLE | hFile | ) |
BOOL SetCommConfig | ( | HANDLE | hCommDev, |
LPCOMMCONFIG | lpCC, | ||
DWORD | dwSize | ||
) |
BOOL SetCommMask | ( | HANDLE | hFile, |
DWORD | dwEvtMask | ||
) |
BOOL SetCommState | ( | HANDLE | hFile, |
LPDCB | lpDCB | ||
) |
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
ioctl calls stage
upcomingTermios stage
BOOL SetCommTimeouts | ( | HANDLE | hFile, |
LPCOMMTIMEOUTS | lpCommTimeouts | ||
) |
ERRORS: ERROR_INVALID_HANDLE
BOOL SetDefaultCommConfigA | ( | LPCSTR | lpszName, |
LPCOMMCONFIG | lpCC, | ||
DWORD | dwSize | ||
) |
BOOL SetDefaultCommConfigW | ( | LPCWSTR | lpszName, |
LPCOMMCONFIG | lpCC, | ||
DWORD | dwSize | ||
) |
BOOL SetupComm | ( | HANDLE | hFile, |
DWORD | dwInQueue, | ||
DWORD | dwOutQueue | ||
) |
BOOL TransmitCommChar | ( | HANDLE | hFile, |
char | cChar | ||
) |
BOOL WaitCommEvent | ( | HANDLE | hFile, |
PDWORD | lpEvtMask, | ||
LPOVERLAPPED | lpOverlapped | ||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Communication Resources: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363196/