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
|
|
|
|
|
2014-07-04 19:40:06 +04:00
|
|
|
#if defined __linux__ && !defined ANDROID
|
2014-04-02 23:51:28 +04:00
|
|
|
|
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"
|
2022-02-16 12:08:00 +03:00
|
|
|
#include <winpr/config.h>
|
2014-04-02 23:51:28 +04:00
|
|
|
|
|
|
|
struct winpr_comm
|
|
|
|
{
|
2022-04-27 16:56:39 +03:00
|
|
|
WINPR_HANDLE common;
|
2014-04-02 23:51:28 +04:00
|
|
|
|
|
|
|
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-09-16 14:08:33 +04:00
|
|
|
/* permissive mode on errors. If TRUE (default is FALSE)
|
|
|
|
* CommDeviceIoControl always return TRUE.
|
2014-05-19 18:53:57 +04:00
|
|
|
*
|
2014-09-16 14:08:33 +04:00
|
|
|
* Not all features are supported yet and an error is then returned when
|
|
|
|
* an application turns them on (e.g: i/o buffers > 4096). It appeared
|
|
|
|
* though that devices and applications can be still functional on such
|
|
|
|
* errors.
|
2014-05-19 18:53:57 +04:00
|
|
|
*
|
2014-09-16 14:08:33 +04:00
|
|
|
* see also: comm_ioctl.c
|
|
|
|
*
|
|
|
|
* FIXME: getting rid of this flag once all features supported.
|
2014-05-19 18:53:57 +04:00
|
|
|
*/
|
|
|
|
BOOL permissive;
|
|
|
|
|
2014-06-18 17:58:08 +04:00
|
|
|
SERIAL_DRIVER_ID serverSerialDriverId;
|
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
|
|
|
|
2016-10-07 15:04:40 +03: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
|
|
|
|
2017-11-07 00:23:07 +03:00
|
|
|
char eventChar;
|
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;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define SERIAL_EV_RXCHAR 0x0001
|
|
|
|
#define SERIAL_EV_RXFLAG 0x0002
|
|
|
|
#define SERIAL_EV_TXEMPTY 0x0004
|
|
|
|
#define SERIAL_EV_CTS 0x0008
|
|
|
|
#define SERIAL_EV_DSR 0x0010
|
|
|
|
#define SERIAL_EV_RLSD 0x0020
|
|
|
|
#define SERIAL_EV_BREAK 0x0040
|
|
|
|
#define SERIAL_EV_ERR 0x0080
|
|
|
|
#define SERIAL_EV_RING 0x0100
|
|
|
|
#define SERIAL_EV_PERR 0x0200
|
|
|
|
#define SERIAL_EV_RX80FULL 0x0400
|
|
|
|
#define SERIAL_EV_EVENT1 0x0800
|
|
|
|
#define SERIAL_EV_EVENT2 0x1000
|
2021-06-16 15:43:07 +03:00
|
|
|
#define SERIAL_EV_WINPR_WAITING 0x4000 /* bit today unused by other SERIAL_EV_* */
|
|
|
|
#define SERIAL_EV_WINPR_STOP 0x8000 /* bit today unused by other SERIAL_EV_* */
|
2019-11-06 17:24:51 +03:00
|
|
|
|
2021-06-16 15:43:07 +03:00
|
|
|
#define WINPR_PURGE_TXABORT 0x00000001 /* abort pending transmission */
|
|
|
|
#define WINPR_PURGE_RXABORT 0x00000002 /* abort pending reception */
|
2014-07-02 17:59:16 +04:00
|
|
|
|
2018-10-24 15:36:12 +03:00
|
|
|
void CommLog_Print(DWORD wlog_level, ...);
|
2014-07-02 17:59:16 +04:00
|
|
|
|
2014-07-02 18:57:20 +04:00
|
|
|
BOOL CommIsHandled(HANDLE handle);
|
2022-04-27 16:56:39 +03:00
|
|
|
BOOL CommIsHandleValid(HANDLE handle);
|
2014-06-19 21:07:45 +04:00
|
|
|
BOOL CommCloseHandle(HANDLE handle);
|
2021-07-28 16:18:03 +03:00
|
|
|
HANDLE_CREATOR* GetCommHandleCreator(void);
|
2014-06-19 21:07:45 +04:00
|
|
|
|
2015-04-28 09:30:45 +03:00
|
|
|
#ifndef WITH_EVENTFD_READ_WRITE
|
2014-08-07 06:06:01 +04:00
|
|
|
int eventfd_read(int fd, eventfd_t* value);
|
|
|
|
int eventfd_write(int fd, eventfd_t value);
|
|
|
|
#endif
|
|
|
|
|
2014-07-04 18:16:26 +04:00
|
|
|
#endif /* __linux__ */
|
2014-04-02 23:51:28 +04:00
|
|
|
|
|
|
|
#endif /* WINPR_COMM_PRIVATE_H */
|