-
Notifications
You must be signed in to change notification settings - Fork 1
/
sim_serial.h
105 lines (78 loc) · 3.76 KB
/
sim_serial.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* sim_serial.h: OS-dependent serial port routines header file
Copyright (c) 2008, J. David Bryan, Mark Pizzolato
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the author shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the author.
07-Oct-08 JDB [serial] Created file
22-Apr-12 MP Adapted from code originally written by J. David Bryan
*/
#ifndef SIM_SERIAL_H_
#define SIM_SERIAL_H_ 0
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SIMH_SERHANDLE_DEFINED
#define SIMH_SERHANDLE_DEFINED 0
typedef struct SERPORT *SERHANDLE;
#endif /* SERHANDLE_DEFINED */
#if defined (_WIN32) /* Windows definitions */
/* We need the basic Win32 definitions, but including "windows.h" also includes
"winsock.h" as well. However, "sim_sock.h" explicitly includes "winsock2.h,"
and this file cannot coexist with "winsock.h". So we set a guard definition
that prevents "winsock.h" from being included.
*/
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#if !defined(INVALID_HANDLE)
#define INVALID_HANDLE (SERHANDLE)INVALID_HANDLE_VALUE
#endif /* !defined(INVALID_HANDLE) */
#elif defined (__unix__) || defined (__APPLE__) || defined (__hpux) /* UNIX definitions */
#include <fcntl.h>
#ifdef __hpux
#include <sys/modem.h>
#endif
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>
#if !defined(INVALID_HANDLE)
#define INVALID_HANDLE ((SERHANDLE)(void *)-1)
#endif /* !defined(INVALID_HANDLE) */
#elif defined (VMS) /* VMS definitions */
#if !defined(INVALID_HANDLE)
#define INVALID_HANDLE ((SERHANDLE)(void *)-1)
#endif /* !defined(INVALID_HANDLE) */
#else /* Non-implemented definitions */
#if !defined(INVALID_HANDLE)
#define INVALID_HANDLE ((SERHANDLE)(void *)-1)
#endif /* !defined(INVALID_HANDLE) */
#endif /* OS variants */
/* Common definitions */
/* Global routines */
#include "sim_tmxr.h" /* need TMLN definition and modem definitions */
extern SERHANDLE sim_open_serial (char *name, TMLN *lp, t_stat *status);
extern t_stat sim_config_serial (SERHANDLE port, CONST char *config);
extern t_stat sim_control_serial (SERHANDLE port, int32 bits_to_set, int32 bits_to_clear, int32 *incoming_bits);
extern int32 sim_read_serial (SERHANDLE port, char *buffer, int32 count, char *brk);
extern int32 sim_write_serial (SERHANDLE port, char *buffer, int32 count);
extern void sim_close_serial (SERHANDLE port);
extern t_stat sim_show_serial (FILE* st, DEVICE *dptr, UNIT* uptr, int32 val, CONST char* desc);
#ifdef __cplusplus
}
#endif
#endif