-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsio.h
55 lines (45 loc) · 950 Bytes
/
sio.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
#ifndef SIO_H
#define SIO_H
#define SIO_OUT 0x01
#define SIO_IN 0x02
#define SIO_PARITY_NONE 0
#define SIO_PARITY_EVEN 1
#define SIO_PARITY_ODD 2
#include <stdio.h>
#if defined(__WIN32__)
# define SIO_WIN32
//# define SIO_TTY
#elif defined(__UNIX__)
# define SIO_TTY
#endif
#if defined(SIO_WIN32)
# include <windows.h>
#endif
typedef struct
{
short port;
long baud;
int parity;
int stopbits;
int databits;
} serialinfo_s;
typedef struct
{
int fd;
#ifdef SIO_WIN32
HANDLE hComm;
#endif
serialinfo_s info;
} sio_s;
int sio_init(sio_s *sio);
void sio_cleanup(sio_s *sio);
int sio_open(sio_s *sio);
void sio_close(sio_s *sio);
int sio_read(sio_s *sio, void *buf, size_t count);
int sio_write(sio_s *sio, void *buf, size_t count);
int sio_isopen(sio_s *sio);
int sio_setinfo(sio_s *sio, serialinfo_s *info);
void sio_flush(sio_s *sio, int dir);
void sio_drain(sio_s *sio);
void sio_debug(sio_s *sio, FILE *f);
#endif /* SIO_H */