2014-04-02 23:51:28 +04:00
|
|
|
/**
|
|
|
|
* WinPR: Windows Portable Runtime
|
|
|
|
* Serial Communication API
|
|
|
|
*
|
|
|
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2014-06-16 21:18:45 +04:00
|
|
|
* Copyright 2014 Hewlett-Packard Development Company, L.P.
|
2014-04-02 23:51:28 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WINPR_COMM_PRIVATE_H
|
|
|
|
#define WINPR_COMM_PRIVATE_H
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
2014-05-14 18:29:10 +04:00
|
|
|
#include <linux/serial.h>
|
2014-05-28 18:41:24 +04:00
|
|
|
#include <sys/eventfd.h>
|
2014-05-14 18:29:10 +04:00
|
|
|
|
2014-04-02 23:51:28 +04:00
|
|
|
#include <winpr/comm.h>
|
|
|
|
|
|
|
|
#include "../handle/handle.h"
|
|
|
|
|
2014-04-25 02:20:48 +04:00
|
|
|
/**
|
|
|
|
* IOCTLs table according the remote serial driver:
|
|
|
|
* http://msdn.microsoft.com/en-us/library/windows/hardware/dn265347%28v=vs.85%29.aspx
|
|
|
|
*/
|
|
|
|
typedef enum _REMOTE_SERIAL_DRIVER_ID
|
|
|
|
{
|
|
|
|
RemoteSerialDriverUnknown = 0,
|
|
|
|
RemoteSerialDriverSerialSys,
|
|
|
|
RemoteSerialDriverSerCxSys,
|
2014-04-29 00:32:27 +04:00
|
|
|
RemoteSerialDriverSerCx2Sys /* default fallback, see also CommDeviceIoControl() */
|
2014-04-25 02:20:48 +04:00
|
|
|
} REMOTE_SERIAL_DRIVER_ID;
|
|
|
|
|
2014-04-02 23:51:28 +04:00
|
|
|
struct winpr_comm
|
|
|
|
{
|
|
|
|
WINPR_HANDLE_DEF();
|
|
|
|
|
|
|
|
int fd;
|
2014-05-28 20:42:23 +04:00
|
|
|
|
|
|
|
int fd_read;
|
|
|
|
int fd_read_event; /* as of today, only used by _purge() */
|
2014-06-17 18:34:20 +04:00
|
|
|
CRITICAL_SECTION ReadLock;
|
2014-06-16 21:18:45 +04:00
|
|
|
|
2014-05-28 18:41:24 +04:00
|
|
|
int fd_write;
|
|
|
|
int fd_write_event; /* as of today, only used by _purge() */
|
2014-06-17 18:34:20 +04:00
|
|
|
CRITICAL_SECTION WriteLock;
|
2014-05-19 18:53:57 +04:00
|
|
|
|
2014-06-16 21:18:45 +04:00
|
|
|
/* permissive mode on errors if TRUE (default is FALSE).
|
2014-05-19 18:53:57 +04:00
|
|
|
*
|
|
|
|
* Since not all features are supported, some devices and applications
|
|
|
|
* can still be functional on such errors.
|
|
|
|
*
|
|
|
|
* TODO: command line switch or getting rid of it.
|
|
|
|
*/
|
|
|
|
BOOL permissive;
|
|
|
|
|
2014-05-21 12:36:55 +04:00
|
|
|
// TMP: to be renamed serverSerialDriverId
|
2014-04-25 02:20:48 +04:00
|
|
|
REMOTE_SERIAL_DRIVER_ID remoteSerialDriverId;
|
2014-05-14 23:21:31 +04:00
|
|
|
|
2014-05-12 19:33:56 +04:00
|
|
|
COMMTIMEOUTS timeouts;
|
2014-06-16 21:18:45 +04:00
|
|
|
|
2014-05-27 14:29:24 +04:00
|
|
|
CRITICAL_SECTION EventsLock; /* protects counters, WaitEventMask and PendingEvents */
|
2014-05-14 18:29:10 +04:00
|
|
|
struct serial_icounter_struct counters;
|
2014-05-23 17:55:44 +04:00
|
|
|
ULONG WaitEventMask;
|
2014-05-23 14:27:09 +04:00
|
|
|
ULONG PendingEvents;
|
2014-04-27 21:41:25 +04:00
|
|
|
|
|
|
|
/* NB: CloseHandle() has to free resources */
|
2014-04-02 23:51:28 +04:00
|
|
|
};
|
2014-04-29 00:32:27 +04:00
|
|
|
|
2014-04-02 23:51:28 +04:00
|
|
|
typedef struct winpr_comm WINPR_COMM;
|
|
|
|
|
2014-04-29 00:32:27 +04:00
|
|
|
void _comm_setRemoteSerialDriver(HANDLE hComm, REMOTE_SERIAL_DRIVER_ID);
|
|
|
|
|
2014-05-27 13:33:10 +04:00
|
|
|
/* TMP: TODO: move all specific defines and types here? at least SERIAL_EV_* */
|
2014-05-27 19:29:55 +04:00
|
|
|
#define SERIAL_EV_FREERDP_WAITING 0x4000 /* bit unused by SERIAL_EV_* */
|
2014-06-16 21:18:45 +04:00
|
|
|
#define SERIAL_EV_FREERDP_STOP 0x8000 /* bit unused by SERIAL_EV_* */
|
2014-05-27 13:33:10 +04:00
|
|
|
|
2014-05-28 18:41:24 +04:00
|
|
|
#define FREERDP_PURGE_TXABORT 0x00000001 /* abort pending transmission */
|
|
|
|
#define FREERDP_PURGE_RXABORT 0x00000002 /* abort pending reception */
|
2014-04-25 02:20:48 +04:00
|
|
|
|
|
|
|
#endif /* _WIN32 */
|
2014-04-02 23:51:28 +04:00
|
|
|
|
|
|
|
#endif /* WINPR_COMM_PRIVATE_H */
|